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

separate L2 update as a standalone function #390

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

varun-doshi
Copy link

Ref #239

Note: this creates an additional trait function, hence currently is a breaking change. Will update as adviced

Comment on lines 142 to 150
/// Process the L2 state update
fn verify_l2_state_update(
&self,
trusted_consensus_state: Vec<u8>,
consensus_state_id: ConsensusStateId,
state_machine_map: &mut BTreeMap<StateMachine, Vec<StateCommitmentHeight>>,
consensus_proof: Vec<u8>
)-> Result<Vec<u8>, Error>;

Copy link
Member

Choose a reason for hiding this comment

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

So this isn't really the intended direction. Rather you should construct new implementations of the ConsensusClient trait for the various L2 proof types. This trait implementation will be configured with the state machine id of the ethereum chain, and accepts storage proofs of ethereum, proving new finalized L2 state commitments

Comment on lines +296 to +323
let consensus_state = ConsensusState::decode(&mut &trusted_consensus_state[..])
.map_err(|_| Error::Custom("Cannot decode trusted consensus state".to_string()))?;

// Parse update based on the type
let update = match BeaconClientUpdate::decode(&mut &consensus_proof[..]) {
Ok(update) => update,
Err(_) => {
// Try to decode as a standalone L2 update
match L2StateUpdate::decode(&mut &consensus_proof[..]) {
Ok(l2_update) => {
// Handle standalone L2 update without changing beacon state
return self.process_l2_update(
host,
consensus_state_id,
consensus_state,
l2_update,
);
},
Err(_) => {
return Err(Error::Custom("Cannot decode update".to_string()));
},
}
},
};

// Process full beacon update with optional L2 updates
self.process_beacon_update(host, consensus_state_id, consensus_state, update)
}
Copy link
Member

Choose a reason for hiding this comment

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

The goal is that the verification of L2 state assertions to happen independent of the sync-committee client so it can be updated independently, potentially replacing it entirely with our future zk-casper light client. So you'd have to put the verifiers into new crates

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants