Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: make extended commit info third injected tx #1791

Open
wants to merge 5 commits into
base: feat/oracle
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 28 additions & 15 deletions crates/astria-core/src/protocol/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ use crate::{
},
protocol::transaction::v1::TransactionBody,
sequencerblock::v1::{
block::Deposit,
block::{
Deposit,
SequencerBlockBuilder,
},
SequencerBlock,
},
Protobuf as _,
Expand Down Expand Up @@ -53,13 +56,15 @@ pub struct ConfigureSequencerBlock {
pub sequence_data: Vec<(RollupId, Vec<u8>)>,
pub deposits: Vec<Deposit>,
pub unix_timestamp: UnixTimeStamp,
pub with_extended_commit_info: bool,
}

impl ConfigureSequencerBlock {
/// Construct a [`SequencerBlock`] with the configured parameters.
#[must_use]
#[expect(
clippy::missing_panics_doc,
clippy::too_many_lines,
reason = "This should only be used in tests, so everything here is unwrapped"
)]
pub fn make(self) -> SequencerBlock {
Expand All @@ -79,6 +84,7 @@ impl ConfigureSequencerBlock {
sequence_data,
unix_timestamp,
deposits,
with_extended_commit_info,
} = self;

let block_hash = block_hash.unwrap_or_default();
Expand Down Expand Up @@ -142,35 +148,42 @@ impl ConfigureSequencerBlock {
rollup_transactions.sort_unstable_keys();
let rollup_transactions_tree = derive_merkle_tree_from_rollup_txs(&rollup_transactions);

let extended_commit_info: tendermint_proto::abci::ExtendedCommitInfo = ExtendedCommitInfo {
round: 0u16.into(),
votes: vec![],
}
.into();
let extended_commit_info_bytes = extended_commit_info.encode_to_vec();

let rollup_ids_root = merkle::Tree::from_leaves(
rollup_transactions
.keys()
.map(|rollup_id| rollup_id.as_ref().to_vec()),
)
.root();
let mut data = vec![
extended_commit_info_bytes,
rollup_transactions_tree.root().to_vec(),
rollup_ids_root.to_vec(),
];

if with_extended_commit_info {
let extended_commit_info: tendermint_proto::abci::ExtendedCommitInfo =
ExtendedCommitInfo {
round: 0u16.into(),
votes: vec![],
}
.into();
let extended_commit_info_bytes = extended_commit_info.encode_to_vec();
data.push(extended_commit_info_bytes);
}

data.extend(txs.into_iter().map(|tx| tx.into_raw().encode_to_vec()));
let data = data.into_iter().map(Bytes::from).collect();
SequencerBlock::try_from_block_info_and_data(

SequencerBlockBuilder {
block_hash,
chain_id.try_into().unwrap(),
height.into(),
Time::from_unix_timestamp(unix_timestamp.secs, unix_timestamp.nanos).unwrap(),
chain_id: chain_id.try_into().unwrap(),
height: height.into(),
time: Time::from_unix_timestamp(unix_timestamp.secs, unix_timestamp.nanos).unwrap(),
proposer_address,
data,
deposits_map,
)
deposits: deposits_map,
with_extended_commit_info,
}
.try_build()
.unwrap()
}
}
Loading
Loading