Skip to content

Commit

Permalink
Rename merkle_root to txs_commitment
Browse files Browse the repository at this point in the history
  • Loading branch information
kpp committed Mar 29, 2024
1 parent 65859e4 commit 0297a0e
Show file tree
Hide file tree
Showing 25 changed files with 85 additions and 85 deletions.
4 changes: 2 additions & 2 deletions bin/citrea/src/test_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ fn regular_test_helper(payload: serde_json::Value, expected: &serde_json::Value)
header: MockBlockHeader {
prev_hash: sha2::Sha256::digest(b"prev_header").into(),
hash: sha2::Sha256::digest(b"slot_data").into(),
merkle_root: sha2::Sha256::digest(b"merkle_root").into(),
txs_commitment: sha2::Sha256::digest(b"txs_commitment").into(),
height: 0,
time: Time::now(),
},
Expand Down Expand Up @@ -304,7 +304,7 @@ prop_compose! {
let mut new_slot = SlotCommit::new(MockBlock {
header: MockBlockHeader {
hash: hash.into(),
merkle_root: hash.into(),
txs_commitment: hash.into(),
prev_hash,
height: 0,
time: Time::now(),
Expand Down
4 changes: 2 additions & 2 deletions crates/bitcoin-da/src/spec/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl BlockHeaderTrait for HeaderWrapper {
BlockHashWrapper(self.header.block_hash())
}

fn merkle_root(&self) -> Self::Hash {
fn txs_commitment(&self) -> Self::Hash {
BlockHashWrapper(BlockHash::from_raw_hash(self.header.merkle_root.into()))
}

Expand All @@ -51,7 +51,7 @@ impl HeaderWrapper {
self.header.block_hash()
}

pub fn merkle_root(&self) -> TxMerkleNode {
pub fn txs_commitment(&self) -> TxMerkleNode {
self.header.merkle_root
}
}
2 changes: 1 addition & 1 deletion crates/bitcoin-da/src/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ impl DaVerifier for BitcoinVerifier {
return Err(ValidationError::NonRelevantTxInProof);
}

let tx_root = block_header.merkle_root().to_raw_hash().to_byte_array();
let tx_root = block_header.txs_commitment().to_raw_hash().to_byte_array();

// Inclusion proof is all the txs in the block.
let tx_hashes = inclusion_proof
Expand Down
2 changes: 1 addition & 1 deletion crates/citrea-stf/src/hooks_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl<C: Context, Da: DaSpec> ApplySoftConfirmationHooks<Da> for Runtime<C, Da> {

self.evm.begin_soft_confirmation_hook(
soft_batch.da_slot_hash(),
soft_batch.da_slot_merkle_root(),
soft_batch.da_slot_txs_commitment(),
&soft_batch.pre_state_root(),
soft_batch.l1_fee_rate(),
working_set,
Expand Down
2 changes: 1 addition & 1 deletion crates/evm/src/hooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ where
pub fn begin_soft_confirmation_hook(
&self,
da_slot_hash: [u8; 32],
_da_slot_merkle_root: [u8; 32],
_da_slot_txs_commitment: [u8; 32],
pre_state_root: &[u8],
l1_fee_rate: u64,
working_set: &mut WorkingSet<C>,
Expand Down
4 changes: 2 additions & 2 deletions crates/sequencer-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub struct GetSoftBatchResponse {
#[serde(with = "hex::serde")]
pub da_slot_hash: [u8; 32],
#[serde(with = "hex::serde")]
pub da_slot_merkle_root: [u8; 32],
pub da_slot_txs_commitment: [u8; 32],
#[serde(skip_serializing_if = "Option::is_none")]
pub txs: Option<Vec<Vec<u8>>>,
#[serde(with = "hex::serde")]
Expand All @@ -95,7 +95,7 @@ impl From<GetSoftBatchResponse> for SignedSoftConfirmationBatch {
val.hash,
val.da_slot_height,
val.da_slot_hash,
val.da_slot_merkle_root,
val.da_slot_txs_commitment,
val.pre_state_root,
val.l1_fee_rate,
val.txs.unwrap_or_default(),
Expand Down
8 changes: 4 additions & 4 deletions crates/sequencer/src/sequencer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ where
let batch_info = HookSoftConfirmationInfo {
da_slot_height: da_block.header().height(),
da_slot_hash: da_block.header().hash().into(),
da_slot_merkle_root: da_block.header().merkle_root().into(),
da_slot_txs_commitment: da_block.header().txs_commitment().into(),
pre_state_root: self.state_root.clone().as_ref().to_vec(),
pub_key: self.sov_tx_signer_priv_key.pub_key().try_to_vec().unwrap(),
l1_fee_rate,
Expand Down Expand Up @@ -240,7 +240,7 @@ where
let unsigned_batch = UnsignedSoftConfirmationBatch::new(
da_block.header().height(),
da_block.header().hash().into(),
da_block.header().merkle_root().into(),
da_block.header().txs_commitment().into(),
self.state_root.clone().as_ref().to_vec(),
txs,
l1_fee_rate,
Expand Down Expand Up @@ -296,7 +296,7 @@ where
batch_hash: batch_receipt.batch_hash,
da_slot_hash: da_block.header().hash(),
da_slot_height: da_block.header().height(),
da_slot_merkle_root: da_block.header().merkle_root(),
da_slot_txs_commitment: da_block.header().txs_commitment(),
tx_receipts: batch_receipt.tx_receipts,
soft_confirmation_signature: signed_soft_batch.signature().to_vec(),
pub_key: signed_soft_batch.pub_key().to_vec(),
Expand Down Expand Up @@ -525,7 +525,7 @@ where
hash,
soft_confirmation.da_slot_height(),
soft_confirmation.da_slot_hash(),
soft_confirmation.da_slot_merkle_root(),
soft_confirmation.da_slot_txs_commitment(),
soft_confirmation.pre_state_root(),
soft_confirmation.l1_fee_rate(),
soft_confirmation.txs(),
Expand Down
2 changes: 1 addition & 1 deletion crates/sovereign-sdk/adapters/avail/src/spec/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl BlockHeaderTrait for AvailHeader {
self.hash.clone()
}

fn merkle_root(&self) -> Self::Hash {
fn txs_commitment(&self) -> Self::Hash {
AvailHash::new(self.header.state_root)
}

Expand Down
2 changes: 1 addition & 1 deletion crates/sovereign-sdk/adapters/celestia/src/celestia.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ impl BlockHeader for CelestiaHeader {
TmHash(self.header.hash())
}

fn merkle_root(&self) -> Self::Hash {
fn txs_commitment(&self) -> Self::Hash {
TmHash(self.header.merkle_root())
}

Expand Down
8 changes: 4 additions & 4 deletions crates/sovereign-sdk/adapters/mock-da/src/db_connector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl DbConnector {
"CREATE TABLE IF NOT EXISTS blocks (
prev_hash BLOB,
hash BLOB,
merkle_root BLOB,
txs_commitment BLOB,
height INTEGER unique,
time TEXT,
is_valid INTEGER,
Expand All @@ -64,12 +64,12 @@ impl DbConnector {
pub fn push_back(&self, block: MockBlock) {
self.conn
.execute(
"INSERT INTO blocks (prev_hash, hash, merkle_root, height, time, is_valid, blobs)
"INSERT INTO blocks (prev_hash, hash, txs_commitment, height, time, is_valid, blobs)
VALUES (?, ?, ?, ?, ?, ?, ?)",
params![
block.header.prev_hash.0,
block.header.hash.0,
block.header.merkle_root.0,
block.header.txs_commitment.0,
block.header.height,
serde_json::to_string(&block.header.time)
.expect("DbConnector: Failed to serialize time"),
Expand Down Expand Up @@ -152,7 +152,7 @@ impl DbConnector {
header: MockBlockHeader {
prev_hash: MockHash(row.get(0).unwrap()),
hash: MockHash(row.get(1).unwrap()),
merkle_root: MockHash(row.get(2).unwrap()),
txs_commitment: MockHash(row.get(2).unwrap()),
height: row.get(3).unwrap(),
time: serde_json::from_str(row.get::<_, String>(4).unwrap().as_str()).unwrap(),
},
Expand Down
4 changes: 2 additions & 2 deletions crates/sovereign-sdk/adapters/mock-da/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use crate::{MockBlockHeader, MockHash};
const GENESIS_HEADER: MockBlockHeader = MockBlockHeader {
prev_hash: MockHash([0; 32]),
hash: MockHash([1; 32]),
merkle_root: MockHash([1; 32]),
txs_commitment: MockHash([1; 32]),
height: 0,
// 2023-01-01T00:00:00Z
time: Time::from_secs(1672531200),
Expand Down Expand Up @@ -202,7 +202,7 @@ impl MockDaService {
let header = MockBlockHeader {
prev_hash: previous_block_hash,
hash: block_hash,
merkle_root: block_hash,
txs_commitment: block_hash,
height,
time: Time::from_secs(10000000000), // TODO: had to mock this for now, causes different state roots
};
Expand Down
12 changes: 6 additions & 6 deletions crates/sovereign-sdk/adapters/mock-da/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ pub struct MockBlockHeader {
pub prev_hash: MockHash,
/// The hash of this block.
pub hash: MockHash,
/// The merkle root of this block.
pub merkle_root: MockHash,
/// The transactions commitment of this block.
pub txs_commitment: MockHash,
/// The height of this block
pub height: u64,
/// The time at which this block was created
Expand All @@ -85,11 +85,11 @@ impl MockBlockHeader {
pub fn from_height(height: u64) -> MockBlockHeader {
let prev_hash = u64_to_bytes(height);
let hash = u64_to_bytes(height + 1);
let merkle_root = u64_to_bytes(height + 1);
let txs_commitment = u64_to_bytes(height + 1);
MockBlockHeader {
prev_hash: MockHash(prev_hash),
hash: MockHash(hash),
merkle_root: MockHash(merkle_root),
txs_commitment: MockHash(txs_commitment),
height,
time: Time::now(),
}
Expand Down Expand Up @@ -125,8 +125,8 @@ impl BlockHeaderTrait for MockBlockHeader {
self.hash
}

fn merkle_root(&self) -> Self::Hash {
self.merkle_root
fn txs_commitment(&self) -> Self::Hash {
self.txs_commitment
}

fn height(&self) -> u64 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ impl LedgerDB {
let batch_to_store = StoredSoftBatch {
da_slot_height: batch_receipt.da_slot_height,
da_slot_hash: batch_receipt.da_slot_hash.into(),
da_slot_merkle_root: batch_receipt.da_slot_merkle_root.into(),
da_slot_txs_commitment: batch_receipt.da_slot_txs_commitment.into(),
hash: batch_receipt.batch_hash,
tx_range: TxNumber(first_tx_number)..TxNumber(last_tx_number),
txs,
Expand Down
6 changes: 3 additions & 3 deletions crates/sovereign-sdk/full-node/db/sov-db/src/schema/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ pub struct StoredSoftBatch {
pub da_slot_height: u64,
/// The da hash of the batch
pub da_slot_hash: [u8; 32],
/// The da merkle root of the batch
pub da_slot_merkle_root: [u8; 32],
/// The da transactions commitment of the batch
pub da_slot_txs_commitment: [u8; 32],
/// The hash of the batch
pub hash: DbHash,
/// The range of transactions which occurred in this batch.
Expand Down Expand Up @@ -106,7 +106,7 @@ impl TryFrom<StoredSoftBatch> for SoftBatchResponse {
Ok(Self {
da_slot_hash: value.da_slot_hash,
da_slot_height: value.da_slot_height,
da_slot_merkle_root: value.da_slot_merkle_root,
da_slot_txs_commitment: value.da_slot_txs_commitment,
hash: value.hash,
txs: Some(value.txs.into_iter().filter_map(|tx| tx.body).collect()), // Rollup full nodes don't store tx bodies
pre_state_root: value.pre_state_root,
Expand Down
Loading

0 comments on commit 0297a0e

Please sign in to comment.