Conversation
|
PR should include the beacon kit prover, that can fetch these updates, and also define all the types required by the prover e.g BeaconState, BeaconBlock, BeaconBlockHeader etc. |
| /// - Empty hash = sha256("") | ||
| /// | ||
| /// The proof consists of sibling hashes (aunts) from leaf to root. | ||
| pub fn verify_tx_proof( |
There was a problem hiding this comment.
Can't we just use a regular merkle proof library to verify this like rs_merkle? have you tried that?
| /// - Inner hash = sha256(0x01 || left || right) | ||
| /// | ||
| /// Returns the aunt hashes (sibling hashes) from leaf to root. | ||
| pub fn generate_tx_merkle_proof( |
There was a problem hiding this comment.
I think we can also just use rs_merkle for this, also this function should be defined in the relayer
| use tendermint_primitives::{CodecConsensusProof, CodecTrustedState, TrustedState}; | ||
| use tendermint_verifier::verify_header_update; | ||
|
|
||
| pub const BEACON_KIT_CONSENSUS_CLIENT_ID: ConsensusClientId = *b"BKIT"; |
There was a problem hiding this comment.
Move these constants and types to a primitives.rs file
| trusted_validators, | ||
| trusted_next_validators, | ||
| trusted_header.header.next_validators_hash.as_bytes().try_into().unwrap(), | ||
| self.host.trusting_period_secs.unwrap_or(82 * 3600), |
There was a problem hiding this comment.
| self.host.trusting_period_secs.unwrap_or(82 * 3600), | |
| self.host.trusting_period_secs.unwrap_or(300), |
| pub tendermint_update: CodecConsensusProof, | ||
| /// All transactions in the CometBFT block. | ||
| /// The first transaction (txs[0]) is the SSZ-encoded SignedBeaconBlock. | ||
| pub txs: Vec<Vec<u8>>, |
There was a problem hiding this comment.
Let's use a boundedVec here, since we know the transactions should be maximum of 2
|
|
||
| fn get_beaconkit_rpc() -> String { | ||
| let base_url = | ||
| std::env::var("BEACONKIT_COMETBFT_RPC").expect("BEACONKIT_COMETBFT_RPC must be set"); |
There was a problem hiding this comment.
Not necessary, the RPC endpoint should come with the api key.
| let mut height = latest_height - 1; | ||
| let mut matched_header = None; | ||
| while height > trusted_state.height { | ||
| log::trace!(target: "tesseract", "BeaconKit: Checking for validator set match at {height}"); |
There was a problem hiding this comment.
Let's use tesseract-beaconkit as the target for these trace logs
| log::trace!(target: "tesseract", "BeaconKit: Checking for validator set match at {height}"); | |
| log::trace!(target: "tesseract-beaconkit", "BeaconKit: Checking for validator set match at {height}"); |
…/beacon-kit-verifier # Conflicts: # .github/workflows/ci.yml
…/beacon-kit-verifier # Conflicts: # .github/workflows/ci.yml # Cargo.lock # Cargo.toml # modules/pallets/testsuite/Cargo.toml
| fn state_machine(&self, id: StateMachine) -> Result<Box<dyn StateMachineClient>, Error> { | ||
| match id { | ||
| StateMachine::Evm(chain_id) | ||
| if chain_id == BERACHAIN_MAINNET_CHAIN_ID |
There was a problem hiding this comment.
Instead of using constants for this, let's add a simple pallet for storing supported state machines for beacon kit, so we can extend this to other chains
| header.header.validators_hash, | ||
| true, | ||
| ); | ||
| if validator_set_hash_match.is_ok() && next_validator_set_hash_match.is_ok() { |
There was a problem hiding this comment.
| if validator_set_hash_match.is_ok() && next_validator_set_hash_match.is_ok() { | |
| if validator_set_hash_match.is_ok() || next_validator_set_hash_match.is_ok() { |
| true, | ||
| ); | ||
|
|
||
| match validator_set_hash_match.is_ok() && next_validator_set_hash_match.is_ok() { |
There was a problem hiding this comment.
| match validator_set_hash_match.is_ok() && next_validator_set_hash_match.is_ok() { | |
| match validator_set_hash_match.is_ok() || next_validator_set_hash_match.is_ok() { |
Introducing the Beacon Kit Verifier crate for verifying consensus/light client updates from the beacon kit consensus engine.
closes #610