Skip to content

Commit

Permalink
recalculate tx hash
Browse files Browse the repository at this point in the history
  • Loading branch information
shekhirin committed May 2, 2024
1 parent 22ccd83 commit fbaccb1
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions examples/exex/rollup/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ impl<Node: FullNodeComponents> Rollup<Node> {
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
Expand All @@ -95,7 +96,7 @@ impl<Node: FullNodeComponents> Rollup<Node> {
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(),
Expand All @@ -105,7 +106,7 @@ impl<Node: FullNodeComponents> Rollup<Node> {
Err(err) => {
error!(
%err,
tx_hash = %tx.hash,
%tx_hash,
chain_id = %header.rollupChainId,
sequence = %header.sequence,
"Failed to execute block"
Expand All @@ -123,11 +124,11 @@ impl<Node: FullNodeComponents> Rollup<Node> {
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
}

Expand All @@ -138,7 +139,7 @@ impl<Node: FullNodeComponents> Rollup<Node> {
})?;

info!(
tx_hash = %tx.hash,
%tx_hash,
%amount,
recipient = %rollupRecipient,
"Deposit",
Expand All @@ -161,6 +162,7 @@ impl<Node: FullNodeComponents> Rollup<Node> {
events.reverse();

for (_, tx, event) in events {
let tx_hash = tx.recalculate_hash();
match event {
// The block is reverted from the database.
RollupContractEvents::BlockSubmitted(_) => {
Expand All @@ -173,7 +175,7 @@ impl<Node: FullNodeComponents> Rollup<Node> {
{
self.db.revert_tip_block(header.sequence)?;
info!(
tx_hash = %tx.hash,
%tx_hash,
chain_id = %header.rollupChainId,
sequence = %header.sequence,
"Block reverted"
Expand All @@ -188,11 +190,11 @@ impl<Node: FullNodeComponents> Rollup<Node> {
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
}

Expand All @@ -203,7 +205,7 @@ impl<Node: FullNodeComponents> Rollup<Node> {
})?;

info!(
tx_hash = %tx.hash,
%tx_hash,
%amount,
recipient = %rollupRecipient,
"Deposit reverted",
Expand Down

0 comments on commit fbaccb1

Please sign in to comment.