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

Conversation

LarryRuane
Copy link
Collaborator

@LarryRuane LarryRuane commented Jun 4, 2023

Closes #432.

(These are also added to GetBlockRange.) This requires an updated version of zcashd getblock RPC that returns these values. This is planned to be added in zcash release v5.6.0.

These values are written to the compact block cache (/var/lib/lightwalletd/db/main/blocks), but of course older cached compact blocks won't have these values. To get these values into all cached blocks, shut down lightwalletd, restart it with the --redownload option, and let it sync (which will take 12 hours or more). This needs to be done only once. Or remove that file (which has the same effect as --redownload) and restart.

Here's an example of the new output:

$ grpcurl -plaintext -d '{"height":2091941}' localhost:9067 cash.z.wallet.sdk.rpc.CompactTxStreamer/GetBlock
{
  "height": "2091941",
  "hash": "3YuXLwZEKxefuXhZFrWU8ceujZcT7ldB0SNJAQAAAAA=",
  "prevHash": "qUUafE5QSka8lBVSPDRGHf88ilQvg0v2miEeAQAAAAA=",
  "time": 1684534214,
  "vtx": [
    {
      "index": "1",
      "hash": "AQ9hMLIbQFewkoBu3tvWThGbBjkPOikgYsUL7Etj++g=",
      "actions": [
        {
          "nullifier": "CWyqMBMUtyMxx2tu6jxTGoEqnae1OrYj2Zbu73bqMA8=",
          "cmx": "p0jePfxZ8/U/t8HbVRabKOTRkCvyzLJ7ixUMqllttiM=",
          "ephemeralKey": "tRmdkZ4OmKu4UoHf2wVSrqrvoJf1sK2ia0EpdzUEbrI=",
          "ciphertext": "bK3YNV9UHYdkF0kffKkhepGwPdAgibYO/RhZ4lwFzOn2/bpqQozCE3d0rXiGeX3V6f5mww=="
        },
        {
          "nullifier": "NUeun9DQdYyN5pyk6mBUBVRwCBKcF0GCfHTOckWRzzk=",
          "cmx": "aOSig8t9Y7ImjIC7yAu4y227OEMdbfiqH+46I0pY5zk=",
          "ephemeralKey": "e8Lbd2qB1SUVMP/x60B+6wfXopH/5ZqDP+nWfkGAzCc=",
          "ciphertext": "avS/hvokWzkL71jP3SnhNF0A7X6AG2AGJ2+e1Gv80D2MQoEdR0s5fZwRYYCt7UMOnp4/7g=="
        }
      ]
    }
  ],
  "saplingCommitmentTreeSize": 71859610,
  "orchardCommitmentTreeSize": 46561151
}

Note that if the version of the running zcashd's getblock RPC doesn't include these new fields, then they will be set to zero in the compact block (it's not considered an error).

And also to GetBlockRange. This requires an updated version of zcashd
`getblock` RPC that returns these values. These values are written to
the compact block cache (/var/lib/lightwalletd/db/main/blocks), but of
course older cached compact blocks won't have these values. To get these
values into all cached blocks, shut down lightwalletd, remove that file,
and restart (with, of course, an updated version of zcashd running).
@LarryRuane LarryRuane added the enhancement New feature or request label Jun 4, 2023
@LarryRuane LarryRuane self-assigned this Jun 4, 2023
@LarryRuane LarryRuane merged commit d55679f into zcash:master Jun 5, 2023
@@ -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.

@LarryRuane LarryRuane deleted the 2023-06-GetBlock-tree-commitment-tree-size branch June 5, 2023 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add note commitment tree sizes to CompactBlock values.
2 participants