From 47523fe8b62149a60e374ff12fad7d9302e82cfb Mon Sep 17 00:00:00 2001 From: Jeb Bearer Date: Thu, 17 Oct 2024 12:36:33 -0700 Subject: [PATCH] Prefetch accounts used for paying fees during state reconstruction --- sequencer/src/api/sql.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sequencer/src/api/sql.rs b/sequencer/src/api/sql.rs index 9506723e24..4c529e9caa 100644 --- a/sequencer/src/api/sql.rs +++ b/sequencer/src/api/sql.rs @@ -2,8 +2,9 @@ use anyhow::{bail, ensure, Context}; use async_trait::async_trait; use committable::{Commitment, Committable}; use espresso_types::{ - get_l1_deposits, v0_3::ChainConfig, BlockMerkleTree, FeeAccount, FeeMerkleTree, Leaf, - NodeState, ValidatedState, + get_l1_deposits, + v0_3::{ChainConfig, IterableFeeInfo}, + BlockMerkleTree, FeeAccount, FeeMerkleTree, Leaf, NodeState, ValidatedState, }; use hotshot::traits::ValidatedState as _; use hotshot_query_service::{ @@ -339,7 +340,6 @@ async fn reconstruct_state<'a>( let mut accounts = accounts.iter().copied().collect::>(); // Add in all the accounts we will need to replay any of the headers, to ensure that we don't // need to do catchup recursively. - accounts.insert(instance.chain_config.fee_recipient); accounts.extend(fee_account_dependencies(instance, parent, &leaves).await); let accounts = accounts.into_iter().collect::>(); state.fee_merkle_tree = load_accounts(tx, from_height, &accounts) @@ -396,6 +396,8 @@ async fn fee_account_dependencies( leaves: impl IntoIterator, ) -> HashSet { let mut accounts = HashSet::default(); + accounts.insert(instance.chain_config.fee_recipient); + for proposal in leaves { accounts.extend( get_l1_deposits( @@ -408,6 +410,7 @@ async fn fee_account_dependencies( .into_iter() .map(|fee| fee.account()), ); + accounts.extend(proposal.block_header().fee_info().accounts()); parent = proposal; } accounts