From fbaccb18e820c3f639ee31e2121d85edd7f2af4f Mon Sep 17 00:00:00 2001 From: Alexey Shekhirin Date: Thu, 2 May 2024 14:00:14 +0100 Subject: [PATCH] recalculate tx hash --- examples/exex/rollup/src/main.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/examples/exex/rollup/src/main.rs b/examples/exex/rollup/src/main.rs index 2f113d7df138..44972e5fd198 100644 --- a/examples/exex/rollup/src/main.rs +++ b/examples/exex/rollup/src/main.rs @@ -75,6 +75,7 @@ impl Rollup { let events = decode_chain_into_rollup_events(chain); for (_, tx, event) in events { + let tx_hash = tx.recalculate_hash(); match event { // A new block is submitted to the rollup contract. // The block is executed on top of existing rollup state and committed into the @@ -95,7 +96,7 @@ impl Rollup { let block = block.seal_slow(); self.db.insert_block_with_bundle(&block, bundle)?; info!( - tx_hash = %tx.hash, + %tx_hash, chain_id = %header.rollupChainId, sequence = %header.sequence, transactions = block.body.len(), @@ -105,7 +106,7 @@ impl Rollup { Err(err) => { error!( %err, - tx_hash = %tx.hash, + %tx_hash, chain_id = %header.rollupChainId, sequence = %header.sequence, "Failed to execute block" @@ -123,11 +124,11 @@ impl Rollup { amount, }) => { if rollupChainId != U256::from(CHAIN_ID) { - error!(tx_hash = %tx.hash, "Invalid rollup chain ID"); + error!(%tx_hash, "Invalid rollup chain ID"); continue } if token != Address::ZERO { - error!(tx_hash = %tx.hash, "Only ETH deposits are supported"); + error!(%tx_hash, "Only ETH deposits are supported"); continue } @@ -138,7 +139,7 @@ impl Rollup { })?; info!( - tx_hash = %tx.hash, + %tx_hash, %amount, recipient = %rollupRecipient, "Deposit", @@ -161,6 +162,7 @@ impl Rollup { events.reverse(); for (_, tx, event) in events { + let tx_hash = tx.recalculate_hash(); match event { // The block is reverted from the database. RollupContractEvents::BlockSubmitted(_) => { @@ -173,7 +175,7 @@ impl Rollup { { self.db.revert_tip_block(header.sequence)?; info!( - tx_hash = %tx.hash, + %tx_hash, chain_id = %header.rollupChainId, sequence = %header.sequence, "Block reverted" @@ -188,11 +190,11 @@ impl Rollup { amount, }) => { if rollupChainId != U256::from(CHAIN_ID) { - error!(tx_hash = %tx.hash, "Invalid rollup chain ID"); + error!(%tx_hash, "Invalid rollup chain ID"); continue } if token != Address::ZERO { - error!(tx_hash = %tx.hash, "Only ETH deposits are supported"); + error!(%tx_hash, "Only ETH deposits are supported"); continue } @@ -203,7 +205,7 @@ impl Rollup { })?; info!( - tx_hash = %tx.hash, + %tx_hash, %amount, recipient = %rollupRecipient, "Deposit reverted",