-
Notifications
You must be signed in to change notification settings - Fork 111
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
Map out block validation data flow #560
Conversation
- https://github.com/zcash/zcash/blob/ab2b7c0969391d8a57d90d008665da02f3f618e7/src/pow.cpp#L96 | ||
- requires no information except `n`, `k` params | ||
- checks that the proof of work parameters are valid | ||
- requires the current proof of work amount `params.powLimit` |
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.
Added to the consensus parameters tracking issue #565
- Calls `ContextualCheckBlockHeader`, defined at: https://github.com/zcash/zcash/blob/ab2b7c0969391d8a57d90d008665da02f3f618e7/src/main.cpp#L3900 | ||
- Does checks given a pointer to the previous block | ||
- Check Equihash solution is valid | ||
- In our code we compute the equihash solution on the block alone, we will need to also do a step to check that its block height is the appopriate N+1 re: the previous block |
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.
Fixed in PR #748
- Does checks given a pointer to the previous block | ||
- Check Equihash solution is valid | ||
- In our code we compute the equihash solution on the block alone, we will need to also do a step to check that its block height is the appopriate N+1 re: the previous block | ||
- Check proof of work |
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.
- https://github.com/zcash/zcash/blob/ab2b7c0969391d8a57d90d008665da02f3f618e7/src/main.cpp#L4040 | ||
- Reject block.nVersion < 4 blocks | ||
- Don't accept any forks from the main chain prior to last checkpoint | ||
- We will probably get this 'more naturally' and don't need to explicitly check it like this |
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.
CheckpointVerifier effectively does this, and when we don't have hard-coded checkpoints, the parallel verification RFC should handle it #763
- Calls `ContextualCheckBlock`, defined at https://github.com/zcash/zcash/blob/ab2b7c0969391d8a57d90d008665da02f3f618e7/src/main.cpp#L4065 | ||
- For each transaction: | ||
- Calls `ContextualCheckTransaction`, defined at https://github.com/zcash/zcash/blob/ab2b7c0969391d8a57d90d008665da02f3f618e7/src/main.cpp#L760 | ||
- For Zebra, we should only be doing Transaction v4 (Sapling+) checks, because checkpointing |
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.
Do we need to keep context from v1-v3 transactions, so we can verify v4 transactions?
For example, UTXOs and revealed nullifiers.
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 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.
- Calls `IsFinalTx`, defined at https://github.com/zcash/zcash/blob/ab2b7c0969391d8a57d90d008665da02f3f618e7/src/main.cpp#L675 | ||
- Calls tx::IsFinal(): https://github.com/zcash/zcash/blob/6d9573c66e33b5b742c49ab35e816d74d4ab55b1/src/primitives/transaction.h#L401 | ||
- Enforce BIP 34: https://github.com/zcash/zcash/blob/ab2b7c0969391d8a57d90d008665da02f3f618e7/src/main.cpp#L4090 | ||
- If blockheight < the block just before the first subsidy halving block, dispense Founder's Reward: https://github.com/zcash/zcash/blob/ab2b7c0969391d8a57d90d008665da02f3f618e7/src/main.cpp#L4104 |
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 blockheight < the block just before the first subsidy halving block, dispense Founder's Reward: https://github.com/zcash/zcash/blob/ab2b7c0969391d8a57d90d008665da02f3f618e7/src/main.cpp#L4104 | ||
- Everything else is state/index management after good verification | ||
- Calls `CheckBlockIndex`, defined at https://github.com/zcash/zcash/blob/ab2b7c0969391d8a57d90d008665da02f3f618e7/src/main.cpp#L5125 | ||
- Calls `ActivateBestChain`, defined at https://github.com/zcash/zcash/blob/ab2b7c0969391d8a57d90d008665da02f3f618e7/src/main.cpp#L3513 |
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.
See the parallel verification RFC #763
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.
Looks great, thanks for doing this work!
I had one question about using v1-v3 transaction state to verify v4 transactions.
Is this good to merge? |
Part of #529