diff --git a/sequencer/src/block.rs b/sequencer/src/block.rs index 987a2bf675..5ad007e78a 100644 --- a/sequencer/src/block.rs +++ b/sequencer/src/block.rs @@ -56,10 +56,14 @@ impl BlockPayload for Payload { /// TODO(746) refactor and make pretty "table" code for tx, namespace tables? async fn from_transactions( txs: impl IntoIterator + Send, - _validated_state: &Self::ValidatedState, + validated_state: &Self::ValidatedState, instance_state: &Self::Instance, ) -> Result<(Self, Self::Metadata), Self::Error> { - let payload = Payload::from_txs(txs, &instance_state.chain_config)?; + let cf = validated_state + .get_chain_config(&instance_state, &validated_state.chain_config) + .await; + + let payload = Payload::from_txs(txs, &cf)?; let ns_table = payload.get_ns_table().clone(); // TODO don't clone ns_table Some((payload, ns_table)).context(BlockBuildingSnafu) } diff --git a/sequencer/src/block/queryable.rs b/sequencer/src/block/queryable.rs index c555596d5e..114f0a8269 100644 --- a/sequencer/src/block/queryable.rs +++ b/sequencer/src/block/queryable.rs @@ -1,6 +1,6 @@ -use crate::{block::entry::TxTableEntryWord, SeqTypes}; use crate::block::payload::Payload; use crate::block::tables::TxTable; +use crate::{block::entry::TxTableEntryWord, SeqTypes}; use hotshot_query_service::availability::QueryablePayload; use hotshot_types::vid::{vid_scheme, SmallRangeProofType}; use jf_vid::payload_prover::{PayloadProver, Statement}; diff --git a/sequencer/src/state.rs b/sequencer/src/state.rs index 44a3df6cae..9567b65768 100644 --- a/sequencer/src/state.rs +++ b/sequencer/src/state.rs @@ -559,6 +559,21 @@ impl SequencerStateDataSource for T where } impl ValidatedState { + pub(crate) async fn get_chain_config( + &self, + instance: &NodeState, + cf: &ResolvableChainConfig, + ) -> ChainConfig { + if cf.commit() == instance.chain_config.commit() { + instance.chain_config + } else { + match cf.resolve() { + Some(cf) => cf, + None => ChainConfig::default(), // TODO: DO CATCHUP + } + } + } + pub(crate) async fn apply_header( &self, instance: &NodeState, @@ -571,17 +586,19 @@ impl ValidatedState { let l1_deposits = get_l1_deposits(instance, proposed_header, parent_leaf).await; let mut validated_state = self.clone(); + let chain_config = validated_state + .get_chain_config(instance, &proposed_header.chain_config) + .await; + + validated_state.chain_config = chain_config.into(); // Find missing fee state entries. We will need to use the builder account which is paying a // fee and the recipient account which is receiving it, plus any counts receiving deposits // in this block. let missing_accounts = self.forgotten_accounts( - [ - proposed_header.fee_info.account, - instance.chain_config().fee_recipient, - ] - .into_iter() - .chain(l1_deposits.iter().map(|fee_info| fee_info.account)), + [proposed_header.fee_info.account, chain_config.fee_recipient] + .into_iter() + .chain(l1_deposits.iter().map(|fee_info| fee_info.account)), ); let parent_height = parent_leaf.height(); @@ -643,7 +660,7 @@ impl ValidatedState { &mut validated_state, &mut delta, proposed_header.fee_info, - instance.chain_config().fee_recipient, + chain_config.fee_recipient, )?; Ok((validated_state, delta))