From e6fa92dd1ed7a72c5e0711a35a64b4322fef8f2c Mon Sep 17 00:00:00 2001 From: erhant Date: Wed, 10 Jun 2026 14:51:01 +0300 Subject: [PATCH] initial hotfixes to bypass system account guards to allow deposit txes --- lez/common/src/transaction.rs | 57 +++++++++++++++++++++++------ lez/indexer/core/src/block_store.rs | 5 ++- lez/storage/src/indexer/mod.rs | 5 ++- 3 files changed, 54 insertions(+), 13 deletions(-) diff --git a/lez/common/src/transaction.rs b/lez/common/src/transaction.rs index 42a7b761..60e3dcd9 100644 --- a/lez/common/src/transaction.rs +++ b/lez/common/src/transaction.rs @@ -78,18 +78,9 @@ impl LeeTransaction { block_id: BlockId, timestamp: Timestamp, ) -> Result { - let diff = match self { - Self::Public(tx) => { - ValidatedStateDiff::from_public_transaction(tx, state, block_id, timestamp) - } - Self::PrivacyPreserving(tx) => ValidatedStateDiff::from_privacy_preserving_transaction( - tx, state, block_id, timestamp, - ), - Self::ProgramDeployment(tx) => { - ValidatedStateDiff::from_program_deployment_transaction(tx, state) - } - }?; + let diff = self.compute_state_diff(state, block_id, timestamp)?; + // system accounts guard let system_accounts = lee::CLOCK_PROGRAM_ACCOUNT_IDS.iter().copied().chain([ lee::system_faucet_account_id(), lee::system_bridge_account_id(), @@ -101,6 +92,28 @@ impl LeeTransaction { Ok(diff) } + /// Computes the validated state diff without enforcing the system-account + /// restriction. Shared by [`Self::validate_on_state`] and + /// [`Self::execute_unchecked_on_state`]. + fn compute_state_diff( + &self, + state: &V03State, + block_id: BlockId, + timestamp: Timestamp, + ) -> Result { + match self { + Self::Public(tx) => { + ValidatedStateDiff::from_public_transaction(tx, state, block_id, timestamp) + } + Self::PrivacyPreserving(tx) => ValidatedStateDiff::from_privacy_preserving_transaction( + tx, state, block_id, timestamp, + ), + Self::ProgramDeployment(tx) => { + ValidatedStateDiff::from_program_deployment_transaction(tx, state) + } + } + } + /// Validates the transaction against the current state, rejects modifications to clock /// system accounts, and applies the resulting diff to the state. pub fn execute_check_on_state( @@ -115,6 +128,28 @@ impl LeeTransaction { state.apply_state_diff(diff); Ok(self) } + + /// Similar to [`Self::execute_check_on_state`], but skips the system-account guard. + /// + /// FIXME: HOT FIX (testnet v0.2): the indexer replays blocks the sequencer already + /// accepted, including sequencer-generated deposit transactions that + /// legitimately modify the bridge account. The `TransactionOrigin::Sequencer` + /// tag that lets the sequencer bypass the guard is not carried in the block, + /// so the indexer cannot yet distinguish deposit txs from user txs. + /// + /// REMOVE ME when the indexer can authenticate deposit transactions + pub fn execute_unchecked_on_state( + self, + state: &mut V03State, + block_id: BlockId, + timestamp: Timestamp, + ) -> Result { + let diff = self + .compute_state_diff(state, block_id, timestamp) + .inspect_err(|err| warn!("Error at transition {err:#?}"))?; + state.apply_state_diff(diff); + Ok(self) + } } impl From for LeeTransaction { diff --git a/lez/indexer/core/src/block_store.rs b/lez/indexer/core/src/block_store.rs index d293637c..810cfa1b 100644 --- a/lez/indexer/core/src/block_store.rs +++ b/lez/indexer/core/src/block_store.rs @@ -171,7 +171,10 @@ impl IndexerStore { transaction .clone() .transaction_stateless_check()? - .execute_check_on_state( + // FIXME: HOT FIX (testnet v0.2): does not check for system account updates due to + // sequencer-generated deposit tx'es; + // CHANGE ME back to `execute_check_on_state` when the indexer can authenticate deposit transactions + .execute_unchecked_on_state( &mut state_guard, block.header.block_id, block.header.timestamp, diff --git a/lez/storage/src/indexer/mod.rs b/lez/storage/src/indexer/mod.rs index 51df8042..008958ed 100644 --- a/lez/storage/src/indexer/mod.rs +++ b/lez/storage/src/indexer/mod.rs @@ -208,7 +208,10 @@ impl RocksDBIO { "transaction pre check failed with err {err:?}" )) })? - .execute_check_on_state( + // FIXME: HOT FIX (testnet v0.2): does not check for system account updates due to + // sequencer-generated deposit tx'es; + // CHANGE ME back to `execute_check_on_state` when the indexer can authenticate deposit transactions + .execute_unchecked_on_state( &mut breakpoint, block.header.block_id, block.header.timestamp,