Skip to content

Commit

Permalink
restructure executor folder
Browse files Browse the repository at this point in the history
  • Loading branch information
msmouse committed Oct 22, 2024
1 parent 52112e7 commit fbef64e
Show file tree
Hide file tree
Showing 25 changed files with 71 additions and 79 deletions.
8 changes: 0 additions & 8 deletions execution/executor/proptest-regressions/tests/mod.txt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
mod test;

use crate::{
components::partial_state_compute_result::PartialStateComputeResult,
logging::{LogEntry, LogSchema},
types::partial_state_compute_result::PartialStateComputeResult,
};
use anyhow::{anyhow, ensure, Result};
use aptos_consensus_types::block::Block as ConsensusBlock;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// 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},
partial_state_compute_result::PartialStateComputeResult,
use crate::{
block_executor::block_tree::{epoch_genesis_block_id, BlockLookup, BlockTree},
types::partial_state_compute_result::PartialStateComputeResult,
};
use aptos_crypto::{hash::PRE_GENESIS_BLOCK_ID, HashValue};
use aptos_infallible::Mutex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
#![forbid(unsafe_code)]

use crate::{
components::{
block_tree::BlockTree, do_get_execution_output::DoGetExecutionOutput,
do_ledger_update::DoLedgerUpdate, do_state_checkpoint::DoStateCheckpoint,
partial_state_compute_result::PartialStateComputeResult,
},
logging::{LogEntry, LogSchema},
metrics::{
COMMIT_BLOCKS, CONCURRENCY_GAUGE, EXECUTE_BLOCK, OTHER_TIMERS, SAVE_TRANSACTIONS,
TRANSACTIONS_SAVED, UPDATE_LEDGER, VM_EXECUTE_BLOCK,
},
types::partial_state_compute_result::PartialStateComputeResult,
workflow::{
do_get_execution_output::DoGetExecutionOutput, do_ledger_update::DoLedgerUpdate,
do_state_checkpoint::DoStateCheckpoint,
},
};
use anyhow::Result;
use aptos_crypto::HashValue;
Expand All @@ -39,9 +39,12 @@ use aptos_types::{
state_store::{state_value::StateValue, StateViewId},
};
use aptos_vm::AptosVM;
use block_tree::BlockTree;
use fail::fail_point;
use std::{marker::PhantomData, sync::Arc};

pub mod block_tree;

pub trait TransactionBlockExecutor: Send + Sync {
fn execute_transaction_block(
transactions: ExecutableTransactions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

#![forbid(unsafe_code)]

use crate::components::{
chunk_result_verifier::ChunkResultVerifier, executed_chunk::ExecutedChunk,
partial_state_compute_result::PartialStateComputeResult,
use crate::{
chunk_executor::chunk_result_verifier::ChunkResultVerifier,
types::{
executed_chunk::ExecutedChunk, partial_state_compute_result::PartialStateComputeResult,
},
};
use anyhow::{anyhow, ensure, Result};
use aptos_executor_types::state_checkpoint_output::StateCheckpointOutput;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,15 @@
#![forbid(unsafe_code)]

use crate::{
components::{
chunk_commit_queue::{ChunkCommitQueue, ChunkToUpdateLedger},
chunk_result_verifier::{ChunkResultVerifier, ReplayChunkVerifier, StateSyncChunkVerifier},
do_get_execution_output::DoGetExecutionOutput,
do_ledger_update::DoLedgerUpdate,
do_state_checkpoint::DoStateCheckpoint,
executed_chunk::ExecutedChunk,
partial_state_compute_result::PartialStateComputeResult,
transaction_chunk::{ChunkToApply, ChunkToExecute, TransactionChunk},
},
logging::{LogEntry, LogSchema},
metrics::{APPLY_CHUNK, CHUNK_OTHER_TIMERS, COMMIT_CHUNK, CONCURRENCY_GAUGE, EXECUTE_CHUNK},
types::{
executed_chunk::ExecutedChunk, partial_state_compute_result::PartialStateComputeResult,
},
workflow::{
do_get_execution_output::DoGetExecutionOutput, do_ledger_update::DoLedgerUpdate,
do_state_checkpoint::DoStateCheckpoint,
},
};
use anyhow::{anyhow, ensure, Result};
use aptos_executor_types::{
Expand Down Expand Up @@ -44,6 +41,8 @@ use aptos_types::{
write_set::WriteSet,
};
use aptos_vm::VMExecutor;
use chunk_commit_queue::{ChunkCommitQueue, ChunkToUpdateLedger};
use chunk_result_verifier::{ChunkResultVerifier, ReplayChunkVerifier, StateSyncChunkVerifier};
use fail::fail_point;
use itertools::multizip;
use std::{
Expand All @@ -55,6 +54,11 @@ use std::{
},
time::Instant,
};
use transaction_chunk::{ChunkToApply, ChunkToExecute, TransactionChunk};

pub mod chunk_commit_queue;
pub mod chunk_result_verifier;
pub mod transaction_chunk;

pub struct ChunkExecutor<V> {
db: DbReaderWriter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// SPDX-License-Identifier: Apache-2.0

use crate::{
components::do_get_execution_output::DoGetExecutionOutput,
metrics::{CHUNK_OTHER_TIMERS, VM_EXECUTE_CHUNK},
workflow::do_get_execution_output::DoGetExecutionOutput,
};
use anyhow::Result;
use aptos_executor_types::execution_output::ExecutionOutput;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

#![forbid(unsafe_code)]

use crate::components::{
apply_chunk_output::ApplyChunkOutput, do_get_execution_output::DoGetExecutionOutput,
executed_chunk::ExecutedChunk,
use crate::{
types::executed_chunk::ExecutedChunk,
workflow::{do_get_execution_output::DoGetExecutionOutput, ApplyExecutionOutput},
};
use anyhow::{anyhow, ensure, format_err, Result};
use aptos_crypto::HashValue;
Expand Down Expand Up @@ -137,7 +137,7 @@ pub fn calculate_genesis<V: VMExecutor>(
BlockExecutorConfigFromOnchain::new_no_block_limit(),
)?;

let (output, _, _) = ApplyChunkOutput::apply_chunk(execution_output, &executed_trees, None)?;
let output = ApplyExecutionOutput::run(execution_output, &executed_trees, None)?;

ensure!(
output.expect_ledger_update_output().num_txns() != 0,
Expand Down
2 changes: 1 addition & 1 deletion execution/executor/src/fuzzing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use crate::{
block_executor::{BlockExecutor, TransactionBlockExecutor},
components::do_get_execution_output::DoGetExecutionOutput,
workflow::do_get_execution_output::DoGetExecutionOutput,
};
use anyhow::Result;
use aptos_crypto::{hash::SPARSE_MERKLE_PLACEHOLDER_HASH, HashValue};
Expand Down
5 changes: 2 additions & 3 deletions execution/executor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ pub mod fuzzing;
mod logging;
pub mod metrics;
#[cfg(test)]
mod mock_vm;
#[cfg(test)]
mod tests;

pub mod block_executor;
pub mod chunk_executor;
pub mod components;
pub mod db_bootstrapper;
pub mod types;
pub mod workflow;
6 changes: 4 additions & 2 deletions execution/executor/src/tests/chunk_executor_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ use crate::{
block_executor::BlockExecutor,
chunk_executor::ChunkExecutor,
db_bootstrapper::{generate_waypoint, maybe_bootstrap},
mock_vm::{encode_mint_transaction, MockVM},
tests::{self, create_blocks_and_chunks, create_transaction_chunks},
tests::{
self, create_blocks_and_chunks, create_transaction_chunks,
mock_vm::{encode_mint_transaction, MockVM},
},
};
use aptos_crypto::HashValue;
use aptos_db::AptosDB;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ mod mock_vm_test;

use crate::{
block_executor::TransactionBlockExecutor,
components::do_get_execution_output::DoGetExecutionOutput,
workflow::do_get_execution_output::DoGetExecutionOutput,
};
use anyhow::Result;
use aptos_crypto::{ed25519::Ed25519PrivateKey, PrivateKey, Uniform};
Expand Down
18 changes: 9 additions & 9 deletions execution/executor/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,8 @@

use crate::{
block_executor::BlockExecutor,
components::{
apply_chunk_output::ApplyChunkOutput, do_get_execution_output::DoGetExecutionOutput,
},
db_bootstrapper::{generate_waypoint, maybe_bootstrap},
mock_vm::{
encode_mint_transaction, encode_reconfiguration_transaction, encode_transfer_transaction,
MockVM, DISCARD_STATUS, KEEP_STATUS,
},
workflow::{do_get_execution_output::DoGetExecutionOutput, ApplyExecutionOutput},
};
use aptos_crypto::{ed25519::Ed25519PrivateKey, HashValue, PrivateKey, SigningKey, Uniform};
use aptos_db::AptosDB;
Expand Down Expand Up @@ -40,10 +34,16 @@ use aptos_types::{
write_set::{WriteOp, WriteSet, WriteSetMut},
};
use itertools::Itertools;
use mock_vm::{
encode_mint_transaction, encode_reconfiguration_transaction, encode_transfer_transaction,
MockVM, DISCARD_STATUS, KEEP_STATUS,
};
use proptest::prelude::*;
use std::{iter::once, sync::Arc};

mod chunk_executor_tests;
#[cfg(test)]
mod mock_vm;

fn execute_and_commit_block(
executor: &TestExecutor,
Expand Down Expand Up @@ -491,7 +491,7 @@ fn apply_transaction_by_writeset(
let chunk_output =
DoGetExecutionOutput::by_transaction_output(txns, txn_outs, state_view).unwrap();

let (output, _, _) = ApplyChunkOutput::apply_chunk(chunk_output, &ledger_view, None).unwrap();
let output = ApplyExecutionOutput::run(chunk_output, &ledger_view, None).unwrap();

db.writer
.save_transactions(
Expand Down Expand Up @@ -689,7 +689,7 @@ fn run_transactions_naive(
block_executor_onchain_config.clone(),
)
.unwrap();
let (output, _, _) = ApplyChunkOutput::apply_chunk(out, &ledger_view, None).unwrap();
let output = ApplyExecutionOutput::run(out, &ledger_view, None).unwrap();
db.writer
.save_transactions(
output.expect_complete_result().as_chunk_to_commit(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#![forbid(unsafe_code)]

use crate::components::partial_state_compute_result::PartialStateComputeResult;
use crate::types::partial_state_compute_result::PartialStateComputeResult;
use aptos_types::ledger_info::LedgerInfoWithSignatures;

#[derive(Debug)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,7 @@

#![forbid(unsafe_code)]

pub mod apply_chunk_output;
pub mod block_tree;
pub mod chunk_commit_queue;
pub mod in_memory_state_calculator_v2;

pub mod chunk_result_verifier;
pub mod do_get_execution_output;
pub mod do_ledger_update;
pub mod do_state_checkpoint;
pub mod executed_chunk;
pub mod partial_state_compute_result;
pub mod transaction_chunk;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

use crate::{
components::do_get_execution_output::update_counters_for_processed_chunk, metrics::OTHER_TIMERS,
metrics::OTHER_TIMERS, workflow::do_get_execution_output::update_counters_for_processed_chunk,
};
use anyhow::Result;
use aptos_crypto::{hash::CryptoHash, HashValue};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// SPDX-License-Identifier: Apache-2.0

use crate::{
components::in_memory_state_calculator_v2::InMemoryStateCalculatorV2,
metrics::{EXECUTOR_ERRORS, OTHER_TIMERS},
types::in_memory_state_calculator_v2::InMemoryStateCalculatorV2,
};
use aptos_crypto::HashValue;
use aptos_executor_types::{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,34 @@

#![forbid(unsafe_code)]

use crate::components::{
do_ledger_update::DoLedgerUpdate, do_state_checkpoint::DoStateCheckpoint,
partial_state_compute_result::PartialStateComputeResult,
};
use crate::types::partial_state_compute_result::PartialStateComputeResult;
use anyhow::Result;
use aptos_crypto::HashValue;
use aptos_executor_types::execution_output::ExecutionOutput;
use aptos_storage_interface::ExecutedTrees;
use aptos_types::transaction::Transaction;
use do_ledger_update::DoLedgerUpdate;
use do_state_checkpoint::DoStateCheckpoint;

pub struct ApplyChunkOutput;
pub mod do_get_execution_output;
pub mod do_ledger_update;
pub mod do_state_checkpoint;

impl ApplyChunkOutput {
pub fn apply_chunk(
pub struct ApplyExecutionOutput;

impl ApplyExecutionOutput {
pub fn run(
chunk_output: ExecutionOutput,
base_view: &ExecutedTrees,
known_state_checkpoint_hashes: Option<Vec<Option<HashValue>>>,
) -> Result<(
PartialStateComputeResult,
Vec<Transaction>,
Vec<Transaction>,
)> {
) -> Result<PartialStateComputeResult> {
let (result_state, next_epoch_state, state_checkpoint_output) = DoStateCheckpoint::run(
chunk_output,
base_view.state(),
None, // append_state_checkpoint_to_block
known_state_checkpoint_hashes,
/*is_block=*/ false,
)?;
let (ledger_update_output, to_discard, to_retry) =
let (ledger_update_output, _to_discard, _to_retry) =
DoLedgerUpdate::run(state_checkpoint_output, base_view.txn_accumulator().clone())?;
let output = PartialStateComputeResult::new(
base_view.state().clone(),
Expand All @@ -42,6 +40,6 @@ impl ApplyChunkOutput {
);
output.set_ledger_update_output(ledger_update_output);

Ok((output, to_discard, to_retry))
Ok(output)
}
}
2 changes: 1 addition & 1 deletion experimental/execution/ptx-executor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use crate::{
};
use aptos_executor::{
block_executor::TransactionBlockExecutor,
components::do_get_execution_output::DoGetExecutionOutput,
workflow::do_get_execution_output::DoGetExecutionOutput,
};
use aptos_executor_types::execution_output::ExecutionOutput;
use aptos_experimental_runtimes::thread_manager::THREAD_MANAGER;
Expand Down
2 changes: 1 addition & 1 deletion storage/aptosdb/src/state_store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ use aptos_db_indexer_schemas::{
metadata::{MetadataKey, MetadataValue, StateSnapshotProgress},
schema::indexer_metadata::InternalIndexerMetadataSchema,
};
use aptos_executor::components::in_memory_state_calculator_v2::InMemoryStateCalculatorV2;
use aptos_executor::types::in_memory_state_calculator_v2::InMemoryStateCalculatorV2;
use aptos_experimental_runtimes::thread_manager::THREAD_MANAGER;
use aptos_infallible::Mutex;
use aptos_jellyfish_merkle::iterator::JellyfishMerkleIterator;
Expand Down

0 comments on commit fbef64e

Please sign in to comment.