diff --git a/bin/citrea/tests/bitcoin/bitcoin_verifier.rs b/bin/citrea/tests/bitcoin/bitcoin_verifier.rs index a97674338b..f059e264a4 100644 --- a/bin/citrea/tests/bitcoin/bitcoin_verifier.rs +++ b/bin/citrea/tests/bitcoin/bitcoin_verifier.rs @@ -727,7 +727,7 @@ impl BitcoinVerifierTest { new_header, block.header.tx_count(), block.header.height(), - block.header.txs_commitment().to_byte_array(), + block.header.txs_commitment(), ); // The verifier should still successfully extract the relevant txs diff --git a/crates/bitcoin-da/src/spec/header.rs b/crates/bitcoin-da/src/spec/header.rs index 06d71f456a..e0268fe2c3 100644 --- a/crates/bitcoin-da/src/spec/header.rs +++ b/crates/bitcoin-da/src/spec/header.rs @@ -42,8 +42,8 @@ impl BlockHeaderTrait for HeaderWrapper { self.hash() == BlockHashWrapper(self.block_hash()) } - fn txs_commitment(&self) -> Self::Hash { - BlockHashWrapper::from(self.txs_commitment) + fn txs_commitment(&self) -> [u8; 32] { + self.txs_commitment } fn height(&self) -> u64 { diff --git a/crates/bitcoin-da/src/spec/short_proof.rs b/crates/bitcoin-da/src/spec/short_proof.rs index 30c93e7625..779d52a869 100644 --- a/crates/bitcoin-da/src/spec/short_proof.rs +++ b/crates/bitcoin-da/src/spec/short_proof.rs @@ -82,12 +82,11 @@ impl VerifiableShortHeaderProof for BitcoinHeaderShortProof { // If non-segwit block, claimed tx commitment should equal to // header.merkle_root if there are more than one tx if self.header.tx_count > 1 - && self.header.merkle_root() - != Into::<[u8; 32]>::into(self.header.txs_commitment()) + && self.header.merkle_root() != self.header.txs_commitment() { return Err(ShortHeaderProofVerificationError::WrongTxCommitment { expected: self.header.merkle_root(), - actual: Into::<[u8; 32]>::into(self.header.txs_commitment()), + actual: self.header.txs_commitment(), }); } } @@ -99,7 +98,7 @@ impl VerifiableShortHeaderProof for BitcoinHeaderShortProof { let mut vec_merkle = Vec::with_capacity(input_witness_value.len() + 32); - vec_merkle.extend_from_slice(&self.header.txs_commitment().to_byte_array()); + vec_merkle.extend_from_slice(&self.header.txs_commitment()); vec_merkle.extend_from_slice(input_witness_value); // check with sha256(sha256()) @@ -110,7 +109,7 @@ impl VerifiableShortHeaderProof for BitcoinHeaderShortProof { expected: script_pubkey[6..38] .try_into() .expect("Must have hash in witness commitment output"), - actual: Into::<[u8; 32]>::into(self.header.txs_commitment()), + actual: self.header.txs_commitment(), }); } } @@ -154,7 +153,7 @@ impl VerifiableShortHeaderProof for BitcoinHeaderShortProof { .prev_blockhash .as_raw_hash() .to_byte_array(), - tx_commitment: self.header.txs_commitment().into(), + tx_commitment: self.header.txs_commitment(), coinbase_txid_merkle_proof_height: self.coinbase_tx_txid_merkle_proof.len() as u8, block_height: height, }) diff --git a/crates/sequencer/src/runner.rs b/crates/sequencer/src/runner.rs index 9ad97c3bb8..c98753fdd2 100644 --- a/crates/sequencer/src/runner.rs +++ b/crates/sequencer/src/runner.rs @@ -1498,11 +1498,11 @@ where if l2_block_info.l2_height() == 1 && index == 0 { let bridge_init_param = self.config.bridge_initialize_params.clone(); - info!("Initializing Bitcoin Light Client with L1 block: #{} with hash {}, tx commitment {}, and coinbase depth {}. Using {:?} for bridge initialization params.", l1_block.header().height(), hex::encode(Into::<[u8; 32]>::into(l1_block.header().txs_commitment())), hex::encode(l1_block.hash()), l1_block.header().coinbase_txid_merkle_proof_height(), bridge_init_param); + info!("Initializing Bitcoin Light Client with L1 block: #{} with hash {}, tx commitment {}, and coinbase depth {}. Using {:?} for bridge initialization params.", l1_block.header().height(), hex::encode(l1_block.header().txs_commitment()), hex::encode(l1_block.hash()), l1_block.header().coinbase_txid_merkle_proof_height(), bridge_init_param); let initialize_events = create_initial_system_events( l1_block.header().hash().into(), - l1_block.header().txs_commitment().into(), + l1_block.header().txs_commitment(), l1_block.header().coinbase_txid_merkle_proof_height(), l1_block.header().height(), bridge_init_param, @@ -1517,7 +1517,7 @@ where let set_block_info_event = populate_set_block_info_event( da_block_header.hash().into(), - da_block_header.txs_commitment().into(), + da_block_header.txs_commitment(), coinbase_depth, ); system_events.push(set_block_info_event); diff --git a/crates/sovereign-sdk/adapters/mock-da/src/db_connector.rs b/crates/sovereign-sdk/adapters/mock-da/src/db_connector.rs index 68a1fcd804..df16783dd8 100644 --- a/crates/sovereign-sdk/adapters/mock-da/src/db_connector.rs +++ b/crates/sovereign-sdk/adapters/mock-da/src/db_connector.rs @@ -46,7 +46,7 @@ impl DbConnector { params![ block.header.prev_hash.0, block.header.hash.0, - block.header.txs_commitment.0, + block.header.txs_commitment, block.header.height, serde_json::to_string(&block.header.time) .expect("DbConnector: Failed to serialize time"), @@ -129,7 +129,7 @@ impl DbConnector { header: MockBlockHeader { prev_hash: MockHash(row.get(0).unwrap()), hash: MockHash(row.get(1).unwrap()), - txs_commitment: MockHash(row.get(2).unwrap()), + txs_commitment: row.get(2).unwrap(), height: row.get(3).unwrap(), time: serde_json::from_str(row.get::<_, String>(4).unwrap().as_str()).unwrap(), bits: 0, diff --git a/crates/sovereign-sdk/adapters/mock-da/src/service.rs b/crates/sovereign-sdk/adapters/mock-da/src/service.rs index 2ddefaa84d..75f358ba01 100644 --- a/crates/sovereign-sdk/adapters/mock-da/src/service.rs +++ b/crates/sovereign-sdk/adapters/mock-da/src/service.rs @@ -23,7 +23,7 @@ use crate::{MockBlockHeader, MockHash}; const GENESIS_HEADER: MockBlockHeader = MockBlockHeader { prev_hash: MockHash([0; 32]), hash: MockHash([1; 32]), - txs_commitment: MockHash([1; 32]), + txs_commitment: [1; 32], height: 0, // 2023-01-01T00:00:00Z time: Time::from_secs(1672531200), @@ -219,7 +219,7 @@ impl MockDaService { let header = MockBlockHeader { prev_hash: previous_block_hash, hash: block_hash, - txs_commitment: block_hash, + txs_commitment: block_hash.into(), height, time: Time::from_secs(10000000000), // TODO: had to mock this for now, causes different state roots bits: 0, @@ -496,7 +496,7 @@ impl DaService for MockDaService { MockShortHeaderProof { header_hash: block.header.hash.0, prev_header_hash: block.header.prev_hash.0, - txs_commitment: block.header.txs_commitment.0, + txs_commitment: block.header.txs_commitment, height: block.header.height, } } diff --git a/crates/sovereign-sdk/adapters/mock-da/src/types/mod.rs b/crates/sovereign-sdk/adapters/mock-da/src/types/mod.rs index 4bbd6b739f..a2e9b8a476 100644 --- a/crates/sovereign-sdk/adapters/mock-da/src/types/mod.rs +++ b/crates/sovereign-sdk/adapters/mock-da/src/types/mod.rs @@ -73,7 +73,7 @@ pub struct MockBlockHeader { /// The hash of this block. pub hash: MockHash, /// The transactions commitment of this block. - pub txs_commitment: MockHash, + pub txs_commitment: [u8; 32], /// The height of this block pub height: u64, /// The time at which this block was created @@ -93,7 +93,7 @@ impl MockBlockHeader { MockBlockHeader { prev_hash: MockHash(prev_hash), hash: MockHash(hash), - txs_commitment: MockHash(txs_commitment), + txs_commitment, height, time: Time::now(), bits, @@ -130,7 +130,7 @@ impl BlockHeaderTrait for MockBlockHeader { self.hash } - fn txs_commitment(&self) -> Self::Hash { + fn txs_commitment(&self) -> [u8; 32] { self.txs_commitment } diff --git a/crates/sovereign-sdk/rollup-interface/src/state_machine/da.rs b/crates/sovereign-sdk/rollup-interface/src/state_machine/da.rs index bdb68e5aa1..5bf0a5533e 100644 --- a/crates/sovereign-sdk/rollup-interface/src/state_machine/da.rs +++ b/crates/sovereign-sdk/rollup-interface/src/state_machine/da.rs @@ -396,7 +396,7 @@ pub trait BlockHeaderTrait: fn verify_hash(&self) -> bool; /// Transactions commitment of the block. - fn txs_commitment(&self) -> Self::Hash; + fn txs_commitment(&self) -> [u8; 32]; /// The current header height fn height(&self) -> u64;