Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

structured tx in block #1172

Merged
merged 1 commit into from
Dec 19, 2024
Merged

Conversation

jchappelow
Copy link
Member

@jchappelow jchappelow commented Dec 18, 2024

types: use structured tx in block, no error Tx srlzn

This updates the block structure with a `Txns []*Transaction` field
insead of `[][]byte`.

This also updates transaction serialization so that it is guaranteed
not to error (except if a writer fails). This means that it supports
a nil Body even if that is invalid in a block. The Bytes() method may
be used instead of MarshalBinary for this.

Finally, two bytes for version are added to transaction and transaction
results serializations.

@jchappelow jchappelow marked this pull request as draft December 18, 2024 22:24
@@ -11,7 +11,7 @@ type blockExecStatus struct {
startTime, endTime time.Time
height int64
txIDs []ktypes.Hash
txStatus map[string]bool
txStatus map[ktypes.Hash]bool
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of the nice things about defining a Hash type as a fixed length array [32]byte is that it is comparable and can be a map key. It's also nice to ensure we always encode to the same length hex chars, which we didn't do before (see old display tests where we had "hashes" displayed of just a few chars 🤯 )

This updates the block structure with a `Txns []*Transaction` field
insead of `[][]byte`.

This also updates transaction serialization so that it is guaranteed
not to error (except if a writer fails). This means that it supports
a nil Body even if that is invalid in a block. The Bytes() method may
be used instead of MarshalBinary for this.

Finally, two bytes for version are added to transaction and transaction
results serializations.
@jchappelow jchappelow marked this pull request as ready for review December 19, 2024 16:25
Copy link
Contributor

@charithabandi charithabandi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks way better :)

@charithabandi charithabandi merged commit 85849c3 into kwilteam:main Dec 19, 2024
4 checks passed
@jchappelow jchappelow deleted the block-txn-strucutre branch December 19, 2024 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants