-
Notifications
You must be signed in to change notification settings - Fork 56
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
base: main
Are you sure you want to change the base?
Conversation
modules/ismp/core/src/consensus.rs
Outdated
/// 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>; | ||
|
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.
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
148ff38
to
fdd4b49
Compare
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) | ||
} |
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.
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
Ref #239
Note: this creates an additional trait function, hence currently is a breaking change. Will update as adviced