Skip to content

Commit

Permalink
Showing 3 changed files with 31 additions and 10 deletions.
8 changes: 6 additions & 2 deletions sequencer/src/block.rs
Original file line number Diff line number Diff line change
@@ -56,10 +56,14 @@ impl BlockPayload<SeqTypes> for Payload<TxTableEntryWord> {
/// TODO(746) refactor and make pretty "table" code for tx, namespace tables?
async fn from_transactions(
txs: impl IntoIterator<Item = Self::Transaction> + 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)
}
2 changes: 1 addition & 1 deletion sequencer/src/block/queryable.rs
Original file line number Diff line number Diff line change
@@ -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};
31 changes: 24 additions & 7 deletions sequencer/src/state.rs
Original file line number Diff line number Diff line change
@@ -559,6 +559,21 @@ impl<T> 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))

0 comments on commit cfd2662

Please sign in to comment.