diff --git a/bin/citrea/tests/bitcoin_e2e/light_client_test.rs b/bin/citrea/tests/bitcoin_e2e/light_client_test.rs index 5ca293243..979fcaaa1 100644 --- a/bin/citrea/tests/bitcoin_e2e/light_client_test.rs +++ b/bin/citrea/tests/bitcoin_e2e/light_client_test.rs @@ -321,16 +321,6 @@ impl TestCase for LightClientProvingTestMultipleProofs { light_client_proof.light_client_proof_output.last_l2_height ); - // Should always be the same - assert_eq!( - light_client_proof2 - .light_client_proof_output - .l2_genesis_state_root, - light_client_proof - .light_client_proof_output - .l2_genesis_state_root - ); - assert!(light_client_proof2 .light_client_proof_output .unchained_batch_proofs_info @@ -417,15 +407,6 @@ impl TestCase for LightClientProvingTestMultipleProofs { batch_proofs[0].proof_output.final_state_root ); - assert_eq!( - light_client_proof3 - .light_client_proof_output - .l2_genesis_state_root, - light_client_proof - .light_client_proof_output - .l2_genesis_state_root - ); - assert_ne!( light_client_proof3.light_client_proof_output.last_l2_height, light_client_proof.light_client_proof_output.last_l2_height diff --git a/crates/light-client-prover/src/circuit.rs b/crates/light-client-prover/src/circuit.rs index 8b54f3bc6..eb80f3705 100644 --- a/crates/light-client-prover/src/circuit.rs +++ b/crates/light-client-prover/src/circuit.rs @@ -18,6 +18,9 @@ pub enum LightClientVerificationError { pub fn run_circuit( da_verifier: DaV, input: LightClientCircuitInput, + l2_genesis_root: [u8; 32], + batch_proof_method_id: [u32; 8], + batch_prover_da_public_key: &[u8], ) -> Result, LightClientVerificationError> { // Extract previous light client proof output let previous_light_client_proof_output = @@ -55,21 +58,13 @@ pub fn run_circuit( // Mapping from initial state root to final state root and last L2 height let mut initial_to_final = std::collections::BTreeMap::<[u8; 32], ([u8; 32], u64)>::new(); - let (mut last_state_root, mut last_l2_height, l2_genesis_state_root) = + let (mut last_state_root, mut last_l2_height) = previous_light_client_proof_output.as_ref().map_or_else( || { - let r = input - .l2_genesis_state_root - .expect("if no preious proof, genesis must exist"); - (r, 0, r) - }, - |prev_journal| { - ( - prev_journal.state_root, - prev_journal.last_l2_height, - prev_journal.l2_genesis_state_root, - ) + // if no previous proof, we start from genesis state root + (l2_genesis_root, 0) }, + |prev_journal| (prev_journal.state_root, prev_journal.last_l2_height), ); // If we have a previous light client proof, check they can be chained @@ -88,10 +83,9 @@ pub fn run_circuit( } // TODO: Test for multiple assumptions to see if the env::verify function does automatic matching between the journal and the assumption or do we need to verify them in order? // https://github.com/chainwayxyz/citrea/issues/1401 - let batch_proof_method_id = input.batch_proof_method_id; // Parse the batch proof da data for blob in input.da_data { - if blob.sender().as_ref() == input.batch_prover_da_pub_key { + if blob.sender().as_ref() == batch_prover_da_public_key { let data = DaDataLightClient::try_from_slice(blob.verified_data()); if let Ok(data) = data { @@ -157,6 +151,5 @@ pub fn run_circuit( da_prev_11_timestamps: block_updates.prev_11_timestamps, unchained_batch_proofs_info: unchained_outputs, last_l2_height, - l2_genesis_state_root, }) } diff --git a/crates/light-client-prover/src/da_block_handler.rs b/crates/light-client-prover/src/da_block_handler.rs index d2d2c07f8..42c81a8a7 100644 --- a/crates/light-client-prover/src/da_block_handler.rs +++ b/crates/light-client-prover/src/da_block_handler.rs @@ -182,7 +182,6 @@ where } let previous_l1_height = l1_height - 1; let mut light_client_proof_journal = None; - let mut l2_genesis_state_root = None; let l2_last_height = match self .ledger_db .get_light_client_proof_data_by_l1_height(previous_l1_height)? @@ -204,13 +203,6 @@ where // If the prev block is the block before the first processed l1 block // then we don't have a previous light client proof, so just give an info if previous_l1_height == initial_l1_height { - // TODO: Provide genesis state root here to the light client proof circuit input - l2_genesis_state_root = self - .sequencer_client - .get_l2_genesis_state_root() - .await? - .map(|v| v.as_slice().try_into().unwrap()); - tracing::info!( "No previous light client proof found for L1 block: {}", previous_l1_height @@ -231,10 +223,6 @@ where "Could not determine the last L2 height for batch proof" ))?; let current_fork = fork_from_block_number(l2_last_height); - let batch_proof_method_id = self - .batch_proof_code_commitments - .get(¤t_fork.spec_id) - .expect("Fork should have a guest code attached"); let light_client_proof_code_commitment = self .light_client_proof_code_commitments .get(¤t_fork.spec_id) @@ -250,11 +238,8 @@ where inclusion_proof, completeness_proof, da_block_header: l1_block.header().clone(), - batch_prover_da_pub_key: self.batch_prover_da_pub_key.clone(), - batch_proof_method_id: batch_proof_method_id.clone().into(), light_client_proof_method_id: light_client_proof_code_commitment.clone().into(), previous_light_client_proof_journal: light_client_proof_journal, - l2_genesis_state_root, }; let proof = self @@ -281,7 +266,6 @@ where da_prev_11_timestamps: circuit_output.da_prev_11_timestamps, unchained_batch_proofs_info: circuit_output.unchained_batch_proofs_info, last_l2_height: circuit_output.last_l2_height, - l2_genesis_state_root: circuit_output.l2_genesis_state_root, }; self.ledger_db.insert_light_client_proof_data_by_l1_height( diff --git a/crates/light-client-prover/src/tests/mod.rs b/crates/light-client-prover/src/tests/mod.rs index 018b16ead..e2f689f70 100644 --- a/crates/light-client-prover/src/tests/mod.rs +++ b/crates/light-client-prover/src/tests/mod.rs @@ -25,12 +25,19 @@ fn test_light_client_circuit_valid_da_valid_data() { da_data: vec![blob_1, blob_2], inclusion_proof: [1u8; 32], completeness_proof: (), - l2_genesis_state_root: Some([1u8; 32]), - batch_proof_method_id, - batch_prover_da_pub_key: [9; 32].to_vec(), }; - let output_1 = run_circuit::<_, MockZkGuest>(da_verifier.clone(), input).unwrap(); + let l2_genesis_state_root = [1u8; 32]; + let batch_prover_da_pub_key = [9; 32].to_vec(); + + let output_1 = run_circuit::<_, MockZkGuest>( + da_verifier.clone(), + input, + l2_genesis_state_root, + batch_proof_method_id, + &batch_prover_da_pub_key, + ) + .unwrap(); // Check that the state transition actually happened assert_eq!(output_1.state_root, [3; 32]); @@ -52,12 +59,16 @@ fn test_light_client_circuit_valid_da_valid_data() { light_client_proof_method_id, inclusion_proof: [1u8; 32], completeness_proof: (), - l2_genesis_state_root: None, - batch_proof_method_id, - batch_prover_da_pub_key: [9; 32].to_vec(), }; - let output_2 = run_circuit::<_, MockZkGuest>(da_verifier.clone(), input_2).unwrap(); + let output_2 = run_circuit::<_, MockZkGuest>( + da_verifier.clone(), + input_2, + l2_genesis_state_root, + batch_proof_method_id, + &batch_prover_da_pub_key, + ) + .unwrap(); // Check that the state transition actually happened assert_eq!(output_2.state_root, [5; 32]); @@ -68,6 +79,7 @@ fn test_light_client_circuit_valid_da_valid_data() { #[test] fn test_wrong_order_da_blocks_should_still_work() { let light_client_proof_method_id = [1u32; 8]; + let batch_proof_method_id = [1u32; 8]; let da_verifier = MockDaVerifier {}; let blob_1 = create_mock_blob([1u8; 32], [2u8; 32], 2, true); @@ -82,12 +94,19 @@ fn test_wrong_order_da_blocks_should_still_work() { da_data: vec![blob_2, blob_1], inclusion_proof: [1u8; 32], completeness_proof: (), - l2_genesis_state_root: Some([1u8; 32]), - batch_proof_method_id: light_client_proof_method_id, - batch_prover_da_pub_key: [9; 32].to_vec(), }; - let output_1 = run_circuit::<_, MockZkGuest>(da_verifier.clone(), input).unwrap(); + let l2_genesis_state_root = [1u8; 32]; + let batch_prover_da_pub_key = [9; 32].to_vec(); + + let output_1 = run_circuit::<_, MockZkGuest>( + da_verifier.clone(), + input, + l2_genesis_state_root, + batch_proof_method_id, + &batch_prover_da_pub_key, + ) + .unwrap(); // Check that the state transition actually happened assert_eq!(output_1.state_root, [3; 32]); @@ -98,6 +117,7 @@ fn test_wrong_order_da_blocks_should_still_work() { #[test] fn create_unchainable_outputs_then_chain_them_on_next_block() { let light_client_proof_method_id = [1u32; 8]; + let batch_proof_method_id = [1u32; 8]; let da_verifier = MockDaVerifier {}; let block_header_1 = MockBlockHeader::from_height(1); @@ -112,12 +132,19 @@ fn create_unchainable_outputs_then_chain_them_on_next_block() { da_data: vec![blob_2, blob_1], inclusion_proof: [1u8; 32], completeness_proof: (), - l2_genesis_state_root: Some([1u8; 32]), - batch_proof_method_id: light_client_proof_method_id, - batch_prover_da_pub_key: [9; 32].to_vec(), }; - let output_1 = run_circuit::<_, MockZkGuest>(da_verifier.clone(), input).unwrap(); + let l2_genesis_state_root = [1u8; 32]; + let batch_prover_da_pub_key = [9; 32].to_vec(); + + let output_1 = run_circuit::<_, MockZkGuest>( + da_verifier.clone(), + input, + l2_genesis_state_root, + batch_proof_method_id, + &batch_prover_da_pub_key, + ) + .unwrap(); // Check that the state transition has not happened because we are missing 1->2 assert_eq!(output_1.state_root, [1; 32]); @@ -150,12 +177,16 @@ fn create_unchainable_outputs_then_chain_them_on_next_block() { da_data: vec![blob_1], inclusion_proof: [1u8; 32], completeness_proof: (), - l2_genesis_state_root: None, - batch_proof_method_id: light_client_proof_method_id, - batch_prover_da_pub_key: [9; 32].to_vec(), }; - let output_2 = run_circuit::<_, MockZkGuest>(da_verifier, input_2).unwrap(); + let output_2 = run_circuit::<_, MockZkGuest>( + da_verifier.clone(), + input_2, + l2_genesis_state_root, + batch_proof_method_id, + &batch_prover_da_pub_key, + ) + .unwrap(); // Check that the state transition actually happened from 1-4 now @@ -167,6 +198,7 @@ fn create_unchainable_outputs_then_chain_them_on_next_block() { #[test] fn test_header_chain_proof_height_and_hash() { let light_client_proof_method_id = [1u32; 8]; + let batch_proof_method_id = [1u32; 8]; let da_verifier = MockDaVerifier {}; let blob_1 = create_mock_blob([1u8; 32], [2u8; 32], 2, true); @@ -181,12 +213,19 @@ fn test_header_chain_proof_height_and_hash() { da_data: vec![blob_1, blob_2], inclusion_proof: [1u8; 32], completeness_proof: (), - l2_genesis_state_root: Some([1u8; 32]), - batch_proof_method_id: light_client_proof_method_id, - batch_prover_da_pub_key: [9; 32].to_vec(), }; - let output_1 = run_circuit::<_, MockZkGuest>(da_verifier.clone(), input).unwrap(); + let l2_genesis_state_root = [1u8; 32]; + let batch_prover_da_pub_key = [9; 32].to_vec(); + + let output_1 = run_circuit::<_, MockZkGuest>( + da_verifier.clone(), + input, + l2_genesis_state_root, + batch_proof_method_id, + &batch_prover_da_pub_key, + ) + .unwrap(); // Check that the state transition actually happened assert_eq!(output_1.state_root, [3; 32]); @@ -208,13 +247,16 @@ fn test_header_chain_proof_height_and_hash() { light_client_proof_method_id, inclusion_proof: [1u8; 32], completeness_proof: (), - l2_genesis_state_root: None, - batch_proof_method_id: light_client_proof_method_id, - batch_prover_da_pub_key: [9; 32].to_vec(), }; // Header chain verification must fail because the l1 block 3 was given before l1 block 2 - let res = run_circuit::<_, MockZkGuest>(da_verifier, input_2); + let res = run_circuit::<_, MockZkGuest>( + da_verifier, + input_2, + l2_genesis_state_root, + batch_proof_method_id, + &batch_prover_da_pub_key, + ); assert!(matches!( res, Err(LightClientVerificationError::HeaderChainVerificationFailed) @@ -239,12 +281,19 @@ fn test_unverifiable_batch_proofs() { da_data: vec![blob_1, blob_2], inclusion_proof: [1u8; 32], completeness_proof: (), - l2_genesis_state_root: Some([1u8; 32]), - batch_proof_method_id, - batch_prover_da_pub_key: [9; 32].to_vec(), }; - let output_1 = run_circuit::<_, MockZkGuest>(da_verifier.clone(), input).unwrap(); + let l2_genesis_state_root = [1u8; 32]; + let batch_prover_da_pub_key = [9; 32].to_vec(); + + let output_1 = run_circuit::<_, MockZkGuest>( + da_verifier.clone(), + input, + l2_genesis_state_root, + batch_proof_method_id, + &batch_prover_da_pub_key, + ) + .unwrap(); // Check that the state transition actually happened but only for verified batch proof // and assert the unverified is ignored, so it is not even in the unchained outputs @@ -272,12 +321,19 @@ fn test_unverifiable_prev_light_client_proof() { da_data: vec![blob_1, blob_2], inclusion_proof: [1u8; 32], completeness_proof: (), - l2_genesis_state_root: Some([1u8; 32]), - batch_proof_method_id, - batch_prover_da_pub_key: [9; 32].to_vec(), }; - let output_1 = run_circuit::<_, MockZkGuest>(da_verifier.clone(), input).unwrap(); + let l2_genesis_state_root = [1u8; 32]; + let batch_prover_da_pub_key = [9; 32].to_vec(); + + let output_1 = run_circuit::<_, MockZkGuest>( + da_verifier.clone(), + input, + l2_genesis_state_root, + batch_proof_method_id, + &batch_prover_da_pub_key, + ) + .unwrap(); // Check that the state transition actually happened but only for verified batch proof // and assert the unverified is ignored, so it is not even in the unchained outputs @@ -297,12 +353,15 @@ fn test_unverifiable_prev_light_client_proof() { light_client_proof_method_id, inclusion_proof: [1u8; 32], completeness_proof: (), - l2_genesis_state_root: None, - batch_proof_method_id: light_client_proof_method_id, - batch_prover_da_pub_key: [9; 32].to_vec(), }; - let res = run_circuit::<_, MockZkGuest>(da_verifier, input_2); + let res = run_circuit::<_, MockZkGuest>( + da_verifier, + input_2, + l2_genesis_state_root, + light_client_proof_method_id, + &batch_prover_da_pub_key, + ); assert!(matches!( res, Err(LightClientVerificationError::InvalidPreviousLightClientProof) diff --git a/crates/sovereign-sdk/full-node/db/sov-db/src/schema/types.rs b/crates/sovereign-sdk/full-node/db/sov-db/src/schema/types.rs index 390163557..447757588 100644 --- a/crates/sovereign-sdk/full-node/db/sov-db/src/schema/types.rs +++ b/crates/sovereign-sdk/full-node/db/sov-db/src/schema/types.rs @@ -95,8 +95,6 @@ pub struct StoredLightClientProofOutput { pub unchained_batch_proofs_info: Vec, /// Last l2 height after proof. pub last_l2_height: u64, - /// L2 genesis state root. - pub l2_genesis_state_root: [u8; 32], } impl From for LightClientProofOutputRpcResponse { @@ -112,7 +110,6 @@ impl From for LightClientProofOutputRpcResponse { da_prev_11_timestamps: value.da_prev_11_timestamps, unchained_batch_proofs_info: value.unchained_batch_proofs_info, last_l2_height: value.last_l2_height, - l2_genesis_state_root: value.l2_genesis_state_root, } } } diff --git a/crates/sovereign-sdk/rollup-interface/src/node/rpc/mod.rs b/crates/sovereign-sdk/rollup-interface/src/node/rpc/mod.rs index 5d7e18205..3a3c4afbb 100644 --- a/crates/sovereign-sdk/rollup-interface/src/node/rpc/mod.rs +++ b/crates/sovereign-sdk/rollup-interface/src/node/rpc/mod.rs @@ -166,9 +166,6 @@ pub struct LightClientProofOutputRpcResponse { pub unchained_batch_proofs_info: Vec, /// Last l2 height the light client proof verifies pub last_l2_height: u64, - /// Genesis state root of Citrea - #[serde(with = "hex::serde")] - pub l2_genesis_state_root: [u8; 32], } #[derive(Debug, Clone, Serialize, Deserialize)] diff --git a/crates/sovereign-sdk/rollup-interface/src/state_machine/zk/mod.rs b/crates/sovereign-sdk/rollup-interface/src/state_machine/zk/mod.rs index 3f2248ade..90502ccab 100644 --- a/crates/sovereign-sdk/rollup-interface/src/state_machine/zk/mod.rs +++ b/crates/sovereign-sdk/rollup-interface/src/state_machine/zk/mod.rs @@ -236,8 +236,6 @@ pub struct LightClientCircuitOutput { pub unchained_batch_proofs_info: Vec, /// Last l2 height the light client proof verifies pub last_l2_height: u64, - /// Genesis state root of Citrea - pub l2_genesis_state_root: [u8; 32], } /// The input of light client proof @@ -252,15 +250,9 @@ pub struct LightClientCircuitInput { /// DA block header that the batch proofs were found in. pub da_block_header: Da::BlockHeader, - /// Public key of the batch prover - pub batch_prover_da_pub_key: Vec, - /// Batch proof method id - pub batch_proof_method_id: [u32; 8], /// Light client proof method id pub light_client_proof_method_id: [u32; 8], /// Light client proof output /// Optional because the first light client proof doesn't have a previous proof pub previous_light_client_proof_journal: Option>, - /// L2 Genesis state root - pub l2_genesis_state_root: Option<[u8; 32]>, } diff --git a/guests/risc0/light-client-proof-bitcoin/Cargo.lock b/guests/risc0/light-client-proof-bitcoin/Cargo.lock index 1d066ebc3..7891d5e6d 100644 --- a/guests/risc0/light-client-proof-bitcoin/Cargo.lock +++ b/guests/risc0/light-client-proof-bitcoin/Cargo.lock @@ -855,12 +855,39 @@ version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" +[[package]] +name = "const_panic" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53857514f72ee4a2b583de67401e3ff63a5472ca4acf289d09a9ea7636dfec17" + [[package]] name = "constant_time_eq" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6" +[[package]] +name = "constmuck" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0e253ed9cc2e1bcc63d791dbe28f818fdff4fceb00d2ff1d3eb943574c623f8" +dependencies = [ + "bytemuck", + "constmuck_internal", + "typewit", +] + +[[package]] +name = "constmuck_internal" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5927bf986ef0398efc2725a986975c1bad3140c883e7bf102f3dec8bcdf0375" +dependencies = [ + "bytemuck", + "const_panic", +] + [[package]] name = "convert_case" version = "0.4.0" @@ -1645,6 +1672,7 @@ dependencies = [ "citrea-primitives", "citrea-risc0-adapter", "const-hex", + "constmuck", "risc0-zkvm", "risc0-zkvm-platform", "sov-modules-api", @@ -3036,6 +3064,12 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +[[package]] +name = "typewit" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb77c29baba9e4d3a6182d51fa75e3215c7fd1dab8f4ea9d107c716878e55fc0" + [[package]] name = "ucd-trie" version = "0.1.7" diff --git a/guests/risc0/light-client-proof-bitcoin/Cargo.toml b/guests/risc0/light-client-proof-bitcoin/Cargo.toml index 30f9e8a41..035b16576 100644 --- a/guests/risc0/light-client-proof-bitcoin/Cargo.toml +++ b/guests/risc0/light-client-proof-bitcoin/Cargo.toml @@ -16,6 +16,7 @@ citrea-light-client-prover = { path = "../../../crates/light-client-prover", def citrea-primitives = { path = "../../../crates/primitives" } citrea-risc0-adapter = { path = "../../../crates/risc0" } const-hex = "1.12" +constmuck = "1.1" sov-modules-api = { path = "../../../crates/sovereign-sdk/module-system/sov-modules-api", default-features = false } sov-modules-stf-blueprint = { path = "../../../crates/sovereign-sdk/module-system/sov-modules-stf-blueprint" } sov-rollup-interface = { path = "../../../crates/sovereign-sdk/rollup-interface" } diff --git a/guests/risc0/light-client-proof-bitcoin/src/bin/light_client_proof_bitcoin.rs b/guests/risc0/light-client-proof-bitcoin/src/bin/light_client_proof_bitcoin.rs index f9797e49d..e6697337f 100644 --- a/guests/risc0/light-client-proof-bitcoin/src/bin/light_client_proof_bitcoin.rs +++ b/guests/risc0/light-client-proof-bitcoin/src/bin/light_client_proof_bitcoin.rs @@ -18,11 +18,11 @@ const L2_GENESIS_ROOT: [u8; 32] = { } }; -const BATCH_PROOF_METHOD_ID: [u8; 32] = { +const BATCH_PROOF_METHOD_ID: [u32; 8] = { let hex_method_id = env!("BATCH_PROOF_METHOD_ID"); - match const_hex::const_decode_to_array(hex_method_id.as_bytes()) { - Ok(method_id) => method_id, + match const_hex::const_decode_to_array::<32>(hex_method_id.as_bytes()) { + Ok(method_id) => constmuck::cast(method_id), Err(_) => panic!("BATCH_PROOF_METHOD_ID must be valid 32-byte hex string"), } }; @@ -51,7 +51,7 @@ pub fn main() { let input = guest.read_from_host(); - let output = run_circuit::(da_verifier, input).unwrap(); + let output = run_circuit::(da_verifier, input, L2_GENESIS_ROOT, BATCH_PROOF_METHOD_ID, &BATCH_PROVER_DA_PUBLIC_KEY).unwrap(); guest.commit(&output); } diff --git a/guests/risc0/light-client-proof-mock/Cargo.lock b/guests/risc0/light-client-proof-mock/Cargo.lock index aecf6f26f..f91d1160b 100644 --- a/guests/risc0/light-client-proof-mock/Cargo.lock +++ b/guests/risc0/light-client-proof-mock/Cargo.lock @@ -764,12 +764,39 @@ version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" +[[package]] +name = "const_panic" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53857514f72ee4a2b583de67401e3ff63a5472ca4acf289d09a9ea7636dfec17" + [[package]] name = "constant_time_eq" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6" +[[package]] +name = "constmuck" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0e253ed9cc2e1bcc63d791dbe28f818fdff4fceb00d2ff1d3eb943574c623f8" +dependencies = [ + "bytemuck", + "constmuck_internal", + "typewit", +] + +[[package]] +name = "constmuck_internal" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5927bf986ef0398efc2725a986975c1bad3140c883e7bf102f3dec8bcdf0375" +dependencies = [ + "bytemuck", + "const_panic", +] + [[package]] name = "convert_case" version = "0.4.0" @@ -1449,6 +1476,7 @@ dependencies = [ "citrea-primitives", "citrea-risc0-adapter", "const-hex", + "constmuck", "risc0-zkvm", "risc0-zkvm-platform", "sov-mock-da", @@ -2822,6 +2850,12 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +[[package]] +name = "typewit" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb77c29baba9e4d3a6182d51fa75e3215c7fd1dab8f4ea9d107c716878e55fc0" + [[package]] name = "ucd-trie" version = "0.1.7" diff --git a/guests/risc0/light-client-proof-mock/Cargo.toml b/guests/risc0/light-client-proof-mock/Cargo.toml index a6290b451..7e14d80b0 100644 --- a/guests/risc0/light-client-proof-mock/Cargo.toml +++ b/guests/risc0/light-client-proof-mock/Cargo.toml @@ -17,6 +17,7 @@ citrea-light-client-prover = { path = "../../../crates/light-client-prover", def citrea-primitives = { path = "../../../crates/primitives" } citrea-risc0-adapter = { path = "../../../crates/risc0" } const-hex = "1.12" +constmuck = "1.1" sov-modules-api = { path = "../../../crates/sovereign-sdk/module-system/sov-modules-api", default-features = false } sov-modules-stf-blueprint = { path = "../../../crates/sovereign-sdk/module-system/sov-modules-stf-blueprint" } sov-rollup-interface = { path = "../../../crates/sovereign-sdk/rollup-interface" } diff --git a/guests/risc0/light-client-proof-mock/src/bin/light_client_proof_mock.rs b/guests/risc0/light-client-proof-mock/src/bin/light_client_proof_mock.rs index 23a5298c7..64068b89b 100644 --- a/guests/risc0/light-client-proof-mock/src/bin/light_client_proof_mock.rs +++ b/guests/risc0/light-client-proof-mock/src/bin/light_client_proof_mock.rs @@ -15,11 +15,11 @@ const L2_GENESIS_ROOT: [u8; 32] = { } }; -const BATCH_PROOF_METHOD_ID: [u8; 32] = { +const BATCH_PROOF_METHOD_ID: [u32; 8] = { let hex_method_id = env!("BATCH_PROOF_METHOD_ID"); - match const_hex::const_decode_to_array(hex_method_id.as_bytes()) { - Ok(method_id) => method_id, + match const_hex::const_decode_to_array::<32>(hex_method_id.as_bytes()) { + Ok(method_id) => constmuck::cast(method_id), Err(_) => panic!("BATCH_PROOF_METHOD_ID must be valid 32-byte hex string"), } }; @@ -45,7 +45,7 @@ pub fn main() { let input = guest.read_from_host(); - let output = run_circuit::(da_verifier, input).unwrap(); + let output = run_circuit::(da_verifier, input, L2_GENESIS_ROOT, BATCH_PROOF_METHOD_ID, &BATCH_PROVER_DA_PUBLIC_KEY).unwrap(); guest.commit(&output); }