Skip to content

Commit

Permalink
trivial: move ExecutionOutput to internal of block_executor::block_tree
Browse files Browse the repository at this point in the history
  • Loading branch information
msmouse committed Oct 9, 2024
1 parent 990b027 commit 6ac4241
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 19 deletions.
1 change: 0 additions & 1 deletion execution/executor-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ use std::{

mod error;
mod executed_chunk;
pub mod execution_output;
mod ledger_update_output;
pub mod parsed_transaction_output;
pub mod state_checkpoint_output;
Expand Down
10 changes: 6 additions & 4 deletions execution/executor/src/block_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

use crate::{
components::{
apply_chunk_output::ApplyChunkOutput, block_tree::BlockTree, chunk_output::ChunkOutput,
apply_chunk_output::ApplyChunkOutput,
block_tree::{block_output::BlockOutput, BlockTree},
chunk_output::ChunkOutput,
},
logging::{LogEntry, LogSchema},
metrics::{
Expand All @@ -17,8 +19,8 @@ use crate::{
use anyhow::Result;
use aptos_crypto::HashValue;
use aptos_executor_types::{
execution_output::ExecutionOutput, state_checkpoint_output::StateCheckpointOutput,
BlockExecutorTrait, ExecutorError, ExecutorResult, StateComputeResult,
state_checkpoint_output::StateCheckpointOutput, BlockExecutorTrait, ExecutorError,
ExecutorResult, StateComputeResult,
};
use aptos_experimental_runtimes::thread_manager::THREAD_MANAGER;
use aptos_infallible::RwLock;
Expand Down Expand Up @@ -277,7 +279,7 @@ where
let _ = self.block_tree.add_block(
parent_block_id,
block_id,
ExecutionOutput::new(state, epoch_state),
BlockOutput::new(state, epoch_state),
)?;
Ok(state_checkpoint_output)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@

#![forbid(unsafe_code)]

use crate::LedgerUpdateOutput;
use aptos_executor_types::LedgerUpdateOutput;
use aptos_storage_interface::state_delta::StateDelta;
use aptos_types::epoch_state::EpochState;
use once_cell::sync::OnceCell;

pub struct ExecutionOutput {
pub struct BlockOutput {
state: StateDelta,
/// If set, this is the new epoch info that should be changed to if this is committed.
next_epoch_state: Option<EpochState>,
ledger_update_output: OnceCell<LedgerUpdateOutput>,
}

impl ExecutionOutput {
impl BlockOutput {
pub fn new(state: StateDelta, next_epoch_state: Option<EpochState>) -> Self {
Self {
state,
Expand Down
16 changes: 9 additions & 7 deletions execution/executor/src/components/block_tree/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#![forbid(unsafe_code)]

pub mod block_output;
#[cfg(test)]
mod test;

Expand All @@ -12,19 +13,20 @@ use anyhow::{anyhow, ensure, Result};
use aptos_consensus_types::block::Block as ConsensusBlock;
use aptos_crypto::HashValue;
use aptos_drop_helper::DEFAULT_DROPPER;
use aptos_executor_types::{execution_output::ExecutionOutput, ExecutorError, LedgerUpdateOutput};
use aptos_executor_types::{ExecutorError, LedgerUpdateOutput};
use aptos_infallible::Mutex;
use aptos_logger::{debug, info};
use aptos_storage_interface::DbReader;
use aptos_types::{ledger_info::LedgerInfo, proof::definition::LeafCount};
use block_output::BlockOutput;
use std::{
collections::{hash_map::Entry, HashMap},
sync::{mpsc::Receiver, Arc, Weak},
};

pub struct Block {
pub id: HashValue,
pub output: ExecutionOutput,
pub output: BlockOutput,
children: Mutex<Vec<Arc<Block>>>,
block_lookup: Arc<BlockLookup>,
}
Expand Down Expand Up @@ -92,7 +94,7 @@ impl BlockLookupInner {
fn fetch_or_add_block(
&mut self,
id: HashValue,
output: ExecutionOutput,
output: BlockOutput,
parent_id: Option<HashValue>,
block_lookup: &Arc<BlockLookup>,
) -> Result<(Arc<Block>, bool, Option<Arc<Block>>)> {
Expand Down Expand Up @@ -148,7 +150,7 @@ impl BlockLookup {
fn fetch_or_add_block(
self: &Arc<Self>,
id: HashValue,
output: ExecutionOutput,
output: BlockOutput,
parent_id: Option<HashValue>,
) -> Result<Arc<Block>> {
let (block, existing, parent_block) = self
Expand Down Expand Up @@ -224,7 +226,7 @@ impl BlockTree {
ledger_info.consensus_block_id()
};

let output = ExecutionOutput::new_with_ledger_update(
let output = BlockOutput::new_with_ledger_update(
ledger_view.state().clone(),
None,
LedgerUpdateOutput::new_empty(ledger_view.txn_accumulator().clone()),
Expand All @@ -250,7 +252,7 @@ impl BlockTree {
.original_reconfiguration_block_id(committed_block_id),
"Updated with a new root block as a virtual block of reconfiguration block"
);
let output = ExecutionOutput::new_with_ledger_update(
let output = BlockOutput::new_with_ledger_update(
last_committed_block.output.state().clone(),
None,
LedgerUpdateOutput::new_empty(
Expand Down Expand Up @@ -289,7 +291,7 @@ impl BlockTree {
&self,
parent_block_id: HashValue,
id: HashValue,
output: ExecutionOutput,
output: BlockOutput,
) -> Result<Arc<Block>> {
self.block_lookup
.fetch_or_add_block(id, output, Some(parent_block_id))
Expand Down
10 changes: 6 additions & 4 deletions execution/executor/src/components/block_tree/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
// Parts of the project are originally copyright © Meta Platforms, Inc.
// SPDX-License-Identifier: Apache-2.0

use crate::components::block_tree::{epoch_genesis_block_id, BlockLookup, BlockTree};
use crate::components::block_tree::{
block_output::BlockOutput, epoch_genesis_block_id, BlockLookup, BlockTree,
};
use aptos_crypto::{hash::PRE_GENESIS_BLOCK_ID, HashValue};
use aptos_executor_types::{execution_output::ExecutionOutput, LedgerUpdateOutput};
use aptos_executor_types::LedgerUpdateOutput;
use aptos_infallible::Mutex;
use aptos_storage_interface::ExecutedTrees;
use aptos_types::{block_info::BlockInfo, epoch_state::EpochState, ledger_info::LedgerInfo};
Expand Down Expand Up @@ -36,9 +38,9 @@ fn id(index: u64) -> HashValue {
HashValue::new(buf)
}

fn empty_block() -> ExecutionOutput {
fn empty_block() -> BlockOutput {
let result_view = ExecutedTrees::new_empty();
ExecutionOutput::new_with_ledger_update(
BlockOutput::new_with_ledger_update(
result_view.state().clone(),
None,
LedgerUpdateOutput::new_empty(ExecutedTrees::new_empty().txn_accumulator().clone()),
Expand Down

0 comments on commit 6ac4241

Please sign in to comment.