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

Add support for new block header: TxnRoot SHA256 #989

Merged
merged 7 commits into from
Aug 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
338 changes: 170 additions & 168 deletions api/generated/common/routes.go

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions api/generated/common/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

396 changes: 199 additions & 197 deletions api/generated/v2/routes.go

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions api/generated/v2/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 14 additions & 13 deletions api/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -1150,19 +1150,20 @@ func (si *ServerImplementation) fetchBlock(ctx context.Context, round uint64) (g
}

ret = generated.Block{
GenesisHash: blockHeader.GenesisHash[:],
GenesisId: blockHeader.GenesisID,
PreviousBlockHash: blockHeader.Branch[:],
Rewards: &rewards,
Round: uint64(blockHeader.Round),
Seed: blockHeader.Seed[:],
StateProofTracking: &trackingArray,
Timestamp: uint64(blockHeader.TimeStamp),
Transactions: nil,
TransactionsRoot: blockHeader.TxnCommitments.NativeSha512_256Commitment[:],
TxnCounter: uint64Ptr(blockHeader.TxnCounter),
UpgradeState: &upgradeState,
UpgradeVote: &upgradeVote,
GenesisHash: blockHeader.GenesisHash[:],
GenesisId: blockHeader.GenesisID,
PreviousBlockHash: blockHeader.Branch[:],
Rewards: &rewards,
Round: uint64(blockHeader.Round),
Seed: blockHeader.Seed[:],
StateProofTracking: &trackingArray,
Timestamp: uint64(blockHeader.TimeStamp),
Transactions: nil,
TransactionsRoot: blockHeader.TxnCommitments.NativeSha512_256Commitment[:],
TransactionsRootSha256: blockHeader.TxnCommitments.Sha256Commitment[:],
TxnCounter: uint64Ptr(blockHeader.TxnCounter),
UpgradeState: &upgradeState,
UpgradeVote: &upgradeVote,
}

results := make([]generated.Transaction, 0)
Expand Down
6 changes: 6 additions & 0 deletions api/indexer.oas2.json
Original file line number Diff line number Diff line change
Expand Up @@ -1452,6 +1452,7 @@
"previous-block-hash",
"seed",
"transactions-root",
"transactions-root-sha256",
"timestamp",
"genesis-id",
"genesis-hash"
Expand Down Expand Up @@ -1506,6 +1507,11 @@
"type": "string",
"format": "byte"
},
"transactions-root-sha256": {
"description": "\\[txn256\\] TransactionsRootSHA256 is an auxiliary TransactionRoot, built using a vector commitment instead of a merkle tree, and SHA256 hash function instead of the default SHA512_256. This commitment can be used on environments where only the SHA256 function exists.",
"type": "string",
"format": "byte"
},
"txn-counter": {
"description": "\\[tc\\] TxnCounter counts the number of transactions committed in the ledger, from the time at which support for this feature was introduced.\n\nSpecifically, TxnCounter is the number of the next transaction that will be committed after this block. It is 0 when no transactions have ever been committed (since TxnCounter started being supported).",
"type": "integer"
Expand Down
9 changes: 8 additions & 1 deletion api/indexer.oas3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1176,6 +1176,12 @@
"pattern": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$",
"type": "string"
},
"transactions-root-sha256": {
"description": "\\[txn256\\] TransactionsRootSHA256 is an auxiliary TransactionRoot, built using a vector commitment instead of a merkle tree, and SHA256 hash function instead of the default SHA512_256. This commitment can be used on environments where only the SHA256 function exists.",
"format": "byte",
"pattern": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$",
"type": "string"
},
"txn-counter": {
"description": "\\[tc\\] TxnCounter counts the number of transactions committed in the ledger, from the time at which support for this feature was introduced.\n\nSpecifically, TxnCounter is the number of the next transaction that will be committed after this block. It is 0 when no transactions have ever been committed (since TxnCounter started being supported).",
"type": "integer"
Expand All @@ -1194,7 +1200,8 @@
"round",
"seed",
"timestamp",
"transactions-root"
"transactions-root",
"transactions-root-sha256"
],
"type": "object"
},
Expand Down
2 changes: 1 addition & 1 deletion api/test_resources/stpf_block_response.json

Large diffs are not rendered by default.