Skip to content

Commit

Permalink
[consensus] remove input_transactions from PipelinedBlock
Browse files Browse the repository at this point in the history
  • Loading branch information
bchocho committed Nov 14, 2024
1 parent 75ad439 commit ec78e1d
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 34 deletions.
29 changes: 8 additions & 21 deletions consensus/consensus-types/src/pipelined_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ pub struct PipelinedBlock {
block: Block,
/// A window of blocks that are needed for execution with the execution pool, excluding the current block
block_window: OrderedBlockWindow,
/// Input transactions in the order of execution
input_transactions: Vec<SignedTransaction>,
/// The state_compute_result is calculated for all the pending blocks prior to insertion to
/// the tree. The execution results are not persisted: they're recalculated again for the
/// pending blocks upon restart.
Expand All @@ -93,14 +91,15 @@ impl Serialize for PipelinedBlock {
struct SerializedBlock<'a> {
block: &'a Block,
block_window: &'a OrderedBlockWindow,
input_transactions: &'a Vec<SignedTransaction>,
// Removed, keeping for backwards compatibility
_input_transactions: &'a Vec<SignedTransaction>,
randomness: Option<&'a Randomness>,
}

let serialized = SerializedBlock {
block: &self.block,
block_window: &self.block_window,
input_transactions: &self.input_transactions,
_input_transactions: &vec![],
randomness: self.randomness.get(),
};
serialized.serialize(serializer)
Expand All @@ -117,14 +116,15 @@ impl<'de> Deserialize<'de> for PipelinedBlock {
struct SerializedBlock {
block: Block,
block_window: OrderedBlockWindow,
input_transactions: Vec<SignedTransaction>,
// Removed, keeping for backwards compatibility
_input_transactions: Vec<SignedTransaction>,
randomness: Option<Randomness>,
}

let SerializedBlock {
block,
block_window,
input_transactions,
_input_transactions: _,
randomness,
} = SerializedBlock::deserialize(deserializer)?;

Expand All @@ -137,7 +137,6 @@ impl<'de> Deserialize<'de> for PipelinedBlock {
let block = PipelinedBlock {
block,
block_window,
input_transactions,
state_compute_result: StateComputeResult::new_dummy(),
randomness: OnceCell::new(),
pipeline_insertion_time: OnceCell::new(),
Expand All @@ -158,14 +157,13 @@ impl PipelinedBlock {
pipeline_execution_result: PipelineExecutionResult,
) -> Self {
let PipelineExecutionResult {
input_txns,
input_txns: _,
result,
execution_time,
pre_commit_fut,
} = pipeline_execution_result;

self.state_compute_result = result;
self.input_transactions = input_txns;
self.pre_commit_fut = Arc::new(Mutex::new(Some(pre_commit_fut)));

let mut to_commit = 0;
Expand Down Expand Up @@ -252,11 +250,7 @@ impl Display for PipelinedBlock {
}

impl PipelinedBlock {
pub fn new(
block: Block,
input_transactions: Vec<SignedTransaction>,
state_compute_result: StateComputeResult,
) -> Self {
pub fn new(block: Block, state_compute_result: StateComputeResult) -> Self {
info!(
"New PipelinedBlock with block_id: {}, parent_id: {}, round: {}, epoch: {}, txns: {}",
block.id(),
Expand All @@ -269,7 +263,6 @@ impl PipelinedBlock {
Self {
block,
block_window: OrderedBlockWindow::new(vec![]),
input_transactions,
state_compute_result,
randomness: OnceCell::new(),
pipeline_insertion_time: OnceCell::new(),
Expand All @@ -291,7 +284,6 @@ impl PipelinedBlock {
Self {
block,
block_window: window,
input_transactions: vec![],
state_compute_result: StateComputeResult::new_dummy(),
randomness: OnceCell::new(),
pipeline_insertion_time: OnceCell::new(),
Expand All @@ -314,7 +306,6 @@ impl PipelinedBlock {
Self {
block,
block_window: OrderedBlockWindow::empty(),
input_transactions: vec![],
state_compute_result: StateComputeResult::new_dummy(),
randomness: OnceCell::new(),
pipeline_insertion_time: OnceCell::new(),
Expand All @@ -339,10 +330,6 @@ impl PipelinedBlock {
self.block().id()
}

pub fn input_transactions(&self) -> &Vec<SignedTransaction> {
&self.input_transactions
}

pub fn epoch(&self) -> u64 {
self.block.epoch()
}
Expand Down
1 change: 0 additions & 1 deletion consensus/src/block_storage/block_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ impl BlockStore {

let pipelined_root_block = PipelinedBlock::new(
*window_block,
vec![],
// Create a dummy state_compute_result with necessary fields filled in.
result,
);
Expand Down
1 change: 0 additions & 1 deletion consensus/src/dag/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ impl OrderedNotifier for OrderedNotifierAdapter {
parents_bitvec,
node_digests,
),
vec![],
StateComputeResult::new_dummy(),
);
let block_info = block.block_info();
Expand Down
1 change: 0 additions & 1 deletion consensus/src/pipeline/buffer_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,6 @@ mod test {
BlockData::dummy_with_validator_txns(vec![]),
None,
),
vec![],
StateComputeResult::new_dummy(),
)
}
Expand Down
7 changes: 1 addition & 6 deletions consensus/src/pipeline/tests/execution_phase_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,7 @@ fn add_execution_phase_test_cases(
// happy path
phase_tester.add_test_case(
ExecutionRequest {
ordered_blocks: vec![PipelinedBlock::new(
block,
vec![],
StateComputeResult::new_dummy(),
)],
ordered_blocks: vec![PipelinedBlock::new(block, StateComputeResult::new_dummy())],
lifetime_guard: dummy_guard(),
},
Box::new(move |resp| {
Expand Down Expand Up @@ -132,7 +128,6 @@ fn add_execution_phase_test_cases(
ExecutionRequest {
ordered_blocks: vec![PipelinedBlock::new(
bad_block,
vec![],
StateComputeResult::new_dummy(),
)],
lifetime_guard: dummy_guard(),
Expand Down
4 changes: 1 addition & 3 deletions consensus/src/pipeline/tests/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,7 @@ pub fn prepare_executed_blocks_with_ledger_info(

let executed_blocks: Vec<PipelinedBlock> = proposals
.iter()
.map(|proposal| {
PipelinedBlock::new(proposal.block().clone(), vec![], compute_result.clone())
})
.map(|proposal| PipelinedBlock::new(proposal.block().clone(), compute_result.clone()))
.collect();

(executed_blocks, li_sig, proposals)
Expand Down
1 change: 0 additions & 1 deletion consensus/src/rand/rand_gen/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ pub fn create_ordered_blocks(rounds: Vec<Round>) -> OrderedBlocks {
),
None,
),
vec![],
StateComputeResult::new_dummy(),
)
})
Expand Down

0 comments on commit ec78e1d

Please sign in to comment.