Skip to content

Beacon Kit Verifier#612

Draft
dharjeezy wants to merge 17 commits intomainfrom
dami/beacon-kit-verifier
Draft

Beacon Kit Verifier#612
dharjeezy wants to merge 17 commits intomainfrom
dami/beacon-kit-verifier

Conversation

@dharjeezy
Copy link
Contributor

@dharjeezy dharjeezy commented Dec 17, 2025

Introducing the Beacon Kit Verifier crate for verifying consensus/light client updates from the beacon kit consensus engine.

closes #610

@dharjeezy dharjeezy requested a review from Wizdave97 December 17, 2025 15:44
@Wizdave97
Copy link
Member

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.

@dharjeezy dharjeezy marked this pull request as draft December 17, 2025 20:45
/// - Empty hash = sha256("")
///
/// The proof consists of sibling hashes (aunts) from leaf to root.
pub fn verify_tx_proof(
Copy link
Member

Choose a reason for hiding this comment

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

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(
Copy link
Member

@Wizdave97 Wizdave97 Jan 6, 2026

Choose a reason for hiding this comment

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

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";
Copy link
Member

@Wizdave97 Wizdave97 Jan 6, 2026

Choose a reason for hiding this comment

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

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),
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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>>,
Copy link
Member

Choose a reason for hiding this comment

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

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");
Copy link
Member

Choose a reason for hiding this comment

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

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}");
Copy link
Member

Choose a reason for hiding this comment

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

Let's use tesseract-beaconkit as the target for these trace logs

Suggested change
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}");

@dharjeezy dharjeezy marked this pull request as ready for review January 9, 2026 04:55
…/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
@dharjeezy dharjeezy marked this pull request as draft February 26, 2026 10:07
@dharjeezy dharjeezy requested a review from Wizdave97 February 26, 2026 10:07
fn state_machine(&self, id: StateMachine) -> Result<Box<dyn StateMachineClient>, Error> {
match id {
StateMachine::Evm(chain_id)
if chain_id == BERACHAIN_MAINNET_CHAIN_ID
Copy link
Member

Choose a reason for hiding this comment

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

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() {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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() {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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() {

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.

BeaconKit Light client

3 participants