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 Sapling and Orchard tree commitment sizes to GetBlock result #435

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
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Please ensure this checklist is followed for any pull requests for this repo. This checklist must be checked by both the PR creator and by anyone who reviews the PR.
* [ ] Relevant documentation for this PR has to be completed and reviewed by @lindanlee before the PR can be merged
* [ ] Relevant documentation for this PR has to be completed before the PR can be merged
* [ ] A test plan for the PR must be documented in the PR notes and included in the test plan for the next regular release

As a note, all CI tests need to be passing and all appropriate code reviews need to be done before this PR can be merged
17 changes: 14 additions & 3 deletions common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,16 @@ type (

// reply to getblock verbose=1 (json includes txid list)
ZcashRpcReplyGetblock1 struct {
Hash string
Tx []string
Hash string
Tx []string
Trees struct {
Sapling struct {
Size uint32
}
Orchard struct {
Size uint32
}
}
}
)

Expand Down Expand Up @@ -322,7 +330,10 @@ func getBlockFromRPC(height int) (*walletrpc.CompactBlock, error) {
// convert from big-endian
t.SetTxID(parser.Reverse(txid))
}
return block.ToCompact(), nil
r := block.ToCompact()
r.SaplingCommitmentTreeSize = block1.Trees.Sapling.Size
r.OrchardCommitmentTreeSize = block1.Trees.Orchard.Size
return r, nil
}

var (
Expand Down
14 changes: 14 additions & 0 deletions docs/rtd/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,20 @@ <h3 id="cash.z.wallet.sdk.rpc.CompactBlock">CompactBlock</h3>
<td><p>zero or more compact transactions from this block </p></td>
</tr>

<tr>
<td>saplingCommitmentTreeSize</td>
<td><a href="#uint32">uint32</a></td>
<td></td>
<td><p>the size of the Sapling note commitment tree as of the end of this block </p></td>
</tr>

<tr>
<td>orchardCommitmentTreeSize</td>
<td><a href="#uint32">uint32</a></td>
<td></td>
<td><p>the size of the Orchard note commitment tree as of the end of this block </p></td>
</tr>

</tbody>
</table>

Expand Down
129 changes: 77 additions & 52 deletions walletrpc/compact_formats.pb.go

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

2 changes: 2 additions & 0 deletions walletrpc/compact_formats.proto
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ message CompactBlock {
uint32 time = 5; // Unix epoch time when the block was mined
bytes header = 6; // (hash, prevHash, and time) OR (full header)
repeated CompactTx vtx = 7; // zero or more compact transactions from this block
uint32 saplingCommitmentTreeSize = 8; // the size of the Sapling note commitment tree as of the end of this block
Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't realize there were multiple versions of this .proto file around; there's also one in librustzcash. We should perhaps figure out a way to have a single source of truth.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I noticed this some time ago, but didn't know how to have multiple repositories share a single copy. Maybe a submodule? It looks like currently this file is replicated in 23 repositories:

https://github.com/search?q=path%3Acompact_formats.proto&type=code

But that list is incomplete since for some reason it doesn't include zcash/librustzcash.

The good news is that this file doesn't change often, so maybe it's okay. But I can investigate setting up a submodule (or something similar) if you think it's worth it.

uint32 orchardCommitmentTreeSize = 9; // the size of the Orchard note commitment tree as of the end of this block
}

// CompactTx contains the minimum information for a wallet to know if this transaction
Expand Down