-
Notifications
You must be signed in to change notification settings - Fork 95
refactor: enforce sequencer blob invariants, simplify conductor #576
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
Conversation
| return Err(Error::ChainIdsCommitmentVerification); | ||
| } | ||
|
|
||
| // genesis and height 1 do not have a last commit |
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.
| return Err(Error::ActionTreeRootVerification); | ||
| } | ||
|
|
||
| let chain_ids_commitment_hash = sha2::Sha256::digest(chain_ids_commitment); |
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.
note: all of this is rolled into assert_chain_ids_are_included because that's used elsewhere.
| /// | ||
| /// # Errors | ||
| /// Returns one of the variants described in [`ChainIdsVerificationFailure`] as an error. | ||
| pub fn assert_chain_ids_are_included<'a, TChainIds: 'a>( |
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.
This function is now also used when constructing SequencerBlockData.
I also noticed that we were not ensuring that the chain ids commitment/root was checked, so it felt natural to also add that here. This essentially extends #548
aff5474 to
5796f0e
Compare
da8aca0 to
72794ca
Compare
noot
left a comment
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 good, just a few smaller comments!
+ sequencer-types: make data_hash being a valid sha256 hash invariant + sequencer-types: provide a utility fn to check chain IDs + conductor: simplify block verifier by enforcing sequencer blob invariants
dd3b730 to
71c549c
Compare
Summary
Enforce invariants when constructing sequencer blobs.
Background
The sequencer blob type
SequencerNamespaceDatathat was written to and read from celestia was treated as a dumb container, delegating consistency checks to downstream users (for example, to theblock_verifiermodule inastria-conductor). In the spirit of making invalid states unrepresentable, this patch introdues aRawSequencerNamespaceDataas the dumb (de)serialization container, from which a verifiedSequencerNamespaceDatacan be built. In particular, the following invariants are upheld at construction, rejecting a conversion otherwise (SMDstands forSequencerNamespaceDataandSMD.fieldrefers to thefieldof the same):SMD.header.data_hashmust be setSMD.block_hashmust match the result ofSMD.header.hash()SMD.action_tree_rootandSMD.action_tree_root_inclusion_proofmust verify againstSMD.data_hashSMD.rollup_chain_idsmust matchSMD.chain_ids_commitmentSMD.chain_ids_commitmentandSMD.chain_ids_commitment_proofmust verifiy againstSMD.data_hashWith these changes conductor's
BlockVerifiercan be simplified significantly and is now only responsible for checking the validity of a given sequencer blob against the remote sequencer.Changes
RawSequencerNamespaceDatatypeSequencerNamespaceDatafields private, add read-only gettersSequencerNamespaceDataserialization to be in terms of theRaw*typeSequencerNamespaceData::try_from_rawas the only fallible constructorSMD::data_hashgetter for convenience which panics if the invariants are violatedBlockVerifierby removing all checks that now happen duringSequencerNamespaceDataconstructionTesting
How are these changes tested?
Related Issues
This is done as part of #356
Blocked on #554 being merged