-
Notifications
You must be signed in to change notification settings - Fork 300
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
Update core data types #17
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
997d377
unrelated change: update go.mod file
liamsi ca22348
Add all non-breaking changes to core types (Block, Header)
liamsi e87db6d
Update types/block.go
liamsi 6373e88
consistent json annotation
liamsi 2da6caf
Merge branch 'ismail/align_block_with_spec' of https://github.com/Laz…
liamsi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,13 +34,34 @@ const ( | |
MaxAminoOverheadForBlock int64 = 11 | ||
) | ||
|
||
// DataAvailabilityHeader contains the row and column roots of the erasure | ||
// coded version of the data in Block.Data. | ||
// Therefor the original Block.Data is arranged in a | ||
// k × k matrix, which is then "extended" to a | ||
// 2k × 2k matrix applying multiple times Reed-Solomon encoding. | ||
// For details see Section 5.2: https://arxiv.org/abs/1809.09044 | ||
type DataAvailabilityHeader struct { | ||
// RowRoot_j = root((M_{j,1} || M_{j,2} || ... || M_{j,2k} )) | ||
RowsRoots [][]byte | ||
// ColumnRoot_j = root((M_{1,j} || M_{2,j} || ... || M_{2k,j} )) | ||
ColumnRoots [][]byte | ||
} | ||
|
||
// Hash computes the root of the row and column roots | ||
// TODO: feed this into Header.DataHash. | ||
func (dah *DataAvailabilityHeader) Hash() { | ||
panic("TODO: implement") | ||
} | ||
|
||
// Block defines the atomic unit of a Tendermint blockchain. | ||
type Block struct { | ||
mtx sync.Mutex | ||
Header `json:"header"` | ||
Data `json:"data"` | ||
Evidence EvidenceData `json:"evidence"` | ||
LastCommit *Commit `json:"last_commit"` | ||
mtx sync.Mutex | ||
|
||
Header `json:"header"` | ||
Data `json:"data"` | ||
DataAvailabilityHeader DataAvailabilityHeader | ||
liamsi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Evidence EvidenceData `json:"evidence"` | ||
LastCommit *Commit `json:"last_commit"` | ||
} | ||
|
||
// ValidateBasic performs basic validation that doesn't involve state data. | ||
|
@@ -332,7 +353,9 @@ type Header struct { | |
|
||
// hashes of block data | ||
LastCommitHash tmbytes.HexBytes `json:"last_commit_hash"` // commit from validators from the last block | ||
DataHash tmbytes.HexBytes `json:"data_hash"` // transactions | ||
// DataHash = root((rowRoot_1 || rowRoot_2 || ... ||rowRoot_2k || columnRoot1 || columnRoot2 || ... || columnRoot2k)) | ||
// Block.DataAvailabilityHeader for stores (row|column)Root_i // TODO ... | ||
DataHash tmbytes.HexBytes `json:"data_hash"` // transactions | ||
|
||
// hashes from the app output from the prev block | ||
ValidatorsHash tmbytes.HexBytes `json:"validators_hash"` // validators for the current block | ||
|
@@ -806,18 +829,53 @@ func (sh SignedHeader) StringIndented(indent string) string { | |
|
||
//----------------------------------------------------------------------------- | ||
|
||
// Data contains the set of transactions included in the block | ||
// Data contains the data that will be erasure coded and is guaranteed to be available | ||
// via the data availability scheme. | ||
// | ||
// TODO: update Data.Hash() to data availability root | ||
// and clarify this here too. | ||
// | ||
// Data consists of: | ||
// - the set of transactions included in the block | ||
// - intermediate state roots computed from the Tx of the previous block | ||
// - Evidence included in the block | ||
// - LazyLedger (namespaced) messages included in the block | ||
type Data struct { | ||
|
||
// Txs that will be applied by state @ block.Height+1. | ||
// NOTE: not all txs here are valid. We're just agreeing on the order first. | ||
// This means that block.AppHash does not include these txs. | ||
Txs Txs `json:"txs"` | ||
|
||
// Intermediate state roots of the Txs included in block.Height | ||
// and executed by state state @ block.Height+1. | ||
// | ||
// TODO: replace with a dedicated type `IntermediateStateRoot` | ||
// as soon as we settle on the format / sparse Merkle tree etc | ||
IntermediateStateRoots []tmbytes.HexBytes | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you wonder about |
||
|
||
// The messages included in this block. | ||
// TODO: clarify the relation between Txs and Messages and | ||
// define a mechanism to split up both (maybe via CheckTx) | ||
Messages []Message | ||
|
||
// Volatile | ||
hash tmbytes.HexBytes | ||
} | ||
|
||
type Message struct { | ||
// NamespaceID defines the namespace of this message, i.e. the | ||
// namespace it will use in the namespaced Merkle tree. | ||
// | ||
// TODO: spec out constrains and | ||
// introduce dedicated type instead of just []byte | ||
NamespaceID []byte | ||
|
||
// Data is the actual data contained in the message | ||
// (e.g. a block of an optimistic rollup sidechain). | ||
liamsi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Data []byte | ||
} | ||
|
||
// Hash returns the hash of the data | ||
func (data *Data) Hash() tmbytes.HexBytes { | ||
if data == nil { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there's not a type for hash digests then we should add one. Is there is then
[]byte
can be replaced with it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is none. At least a type alias would be good! Will add in a followup PR!