Skip to content

Commit

Permalink
[executor] trivial: use BlockExecutor directly instead of the alias
Browse files Browse the repository at this point in the history
  • Loading branch information
msmouse authored and bors-libra committed Dec 10, 2021
1 parent 42130aa commit 6c6644a
Show file tree
Hide file tree
Showing 15 changed files with 48 additions and 48 deletions.
5 changes: 3 additions & 2 deletions api/src/tests/test_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@ use diem_types::{
};
use diem_vm::DiemVM;
use diemdb::DiemDB;
use executor::{db_bootstrapper, Executor};
use executor::db_bootstrapper;
use executor_types::BlockExecutorTrait;
use hyper::Response;
use mempool_notifications::MempoolNotificationSender;
use storage_interface::DbReaderWriter;

use executor::block_executor::BlockExecutor;
use rand::{Rng, SeedableRng};
use serde_json::{json, Value};
use std::{boxed::Box, collections::BTreeMap, sync::Arc, time::SystemTime};
Expand Down Expand Up @@ -80,7 +81,7 @@ pub fn new_test_context() -> TestContext {
rng,
root_keys,
validator_owner,
Box::new(Executor::<DpnProto, DiemVM>::new(db_rw)),
Box::new(BlockExecutor::<DpnProto, DiemVM>::new(db_rw)),
mempool,
db,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use diem_global_constants::EXECUTION_KEY;
use diem_secure_storage::{CryptoStorage, Storage};
use diem_types::protocol_spec::DpnProto;
use diem_vm::DiemVM;
use executor::Executor;
use executor::block_executor::BlockExecutor;
use std::{convert::TryInto, net::SocketAddr, sync::Arc};
use storage_client::StorageClient;
use storage_interface::default_protocol::DbReaderWriter;
Expand Down Expand Up @@ -84,7 +84,7 @@ impl ExecutionCorrectnessManager {
}

pub fn new_local(db: DbReaderWriter, execution_prikey: Option<Ed25519PrivateKey>) -> Self {
let block_executor = Box::new(Executor::<DpnProto, DiemVM>::new(db));
let block_executor = Box::new(BlockExecutor::<DpnProto, DiemVM>::new(db));
Self {
internal_execution_correctness: ExecutionCorrectnessWrapper::Local(Arc::new(
LocalService::new(block_executor, execution_prikey),
Expand All @@ -104,7 +104,7 @@ impl ExecutionCorrectnessManager {
execution_prikey: Option<Ed25519PrivateKey>,
timeout: u64,
) -> Self {
let block_executor = Box::new(Executor::<DpnProto, DiemVM>::new(DbReaderWriter::new(
let block_executor = Box::new(BlockExecutor::<DpnProto, DiemVM>::new(DbReaderWriter::new(
StorageClient::new(&storage_address, timeout),
)));
let serializer_service = SerializerService::new(block_executor, execution_prikey);
Expand Down
4 changes: 2 additions & 2 deletions execution/execution-correctness/src/remote_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use diem_logger::warn;
use diem_secure_net::{NetworkClient, NetworkServer};
use diem_types::protocol_spec::DpnProto;
use diem_vm::DiemVM;
use executor::Executor;
use executor::block_executor::BlockExecutor;
use executor_types::Error;
use std::net::SocketAddr;
use storage_client::StorageClient;
Expand All @@ -34,7 +34,7 @@ pub fn execute(
prikey: Option<Ed25519PrivateKey>,
network_timeout: u64,
) {
let block_executor = Box::new(Executor::<DpnProto, DiemVM>::new(DbReaderWriter::new(
let block_executor = Box::new(BlockExecutor::<DpnProto, DiemVM>::new(DbReaderWriter::new(
StorageClient::new(&storage_addr, network_timeout),
)));
let serializer_service = SerializerService::new(block_executor, prikey);
Expand Down
4 changes: 2 additions & 2 deletions execution/executor-benchmark/src/db_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ use diemdb::{
metrics::DIEM_STORAGE_ROCKSDB_PROPERTIES, schema::JELLYFISH_MERKLE_NODE_CF_NAME, DiemDB,
};
use executor::{
block_executor::BlockExecutor,
db_bootstrapper::{generate_waypoint, maybe_bootstrap},
Executor,
};
use executor_types::BlockExecutorTrait;
use indicatif::{ProgressBar, ProgressStyle};
Expand Down Expand Up @@ -58,7 +58,7 @@ pub fn run(
let waypoint = generate_waypoint::<DiemVM>(&db_rw, get_genesis_txn(&config).unwrap()).unwrap();
maybe_bootstrap::<DiemVM>(&db_rw, get_genesis_txn(&config).unwrap(), waypoint).unwrap();

let executor = Arc::new(Executor::new(db_rw));
let executor = Arc::new(BlockExecutor::new(db_rw));
let genesis_block_id = executor.committed_block_id();
let (block_sender, block_receiver) = mpsc::sync_channel(50 /* bound */);

Expand Down
6 changes: 3 additions & 3 deletions execution/executor-benchmark/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use diem_logger::prelude::*;
use diem_types::protocol_spec::DpnProto;
use diem_vm::DiemVM;
use diemdb::DiemDB;
use executor::Executor;
use executor::block_executor::BlockExecutor;
use executor_types::BlockExecutorTrait;
use std::{
fs,
Expand All @@ -26,7 +26,7 @@ use storage_interface::{default_protocol::DbReaderWriter, DbReader};

pub fn init_db_and_executor(
config: &NodeConfig,
) -> (Arc<dyn DbReader<DpnProto>>, Executor<DpnProto, DiemVM>) {
) -> (Arc<dyn DbReader<DpnProto>>, BlockExecutor<DpnProto, DiemVM>) {
let (db, dbrw) = DbReaderWriter::wrap(
DiemDB::open(
&config.storage.dir(),
Expand All @@ -38,7 +38,7 @@ pub fn init_db_and_executor(
.expect("DB should open."),
);

let executor = Executor::new(dbrw);
let executor = BlockExecutor::new(dbrw);

(db, executor)
}
Expand Down
6 changes: 3 additions & 3 deletions execution/executor-benchmark/src/transaction_committer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ use diem_types::{
use diem_vm::DiemVM;
use diemdb::metrics::DIEM_STORAGE_API_LATENCY_SECONDS;
use executor::{
block_executor::BlockExecutor,
metrics::{
DIEM_EXECUTOR_COMMIT_BLOCKS_SECONDS, DIEM_EXECUTOR_EXECUTE_BLOCK_SECONDS,
DIEM_EXECUTOR_VM_EXECUTE_BLOCK_SECONDS,
},
Executor,
};
use executor_types::BlockExecutorTrait;
use std::{
Expand Down Expand Up @@ -45,14 +45,14 @@ pub(crate) fn gen_li_with_sigs(
}

pub struct TransactionCommitter {
executor: Arc<Executor<DpnProto, DiemVM>>,
executor: Arc<BlockExecutor<DpnProto, DiemVM>>,
version: Version,
block_receiver: mpsc::Receiver<(HashValue, HashValue, Instant, Instant, Duration, usize)>,
}

impl TransactionCommitter {
pub fn new(
executor: Arc<Executor<DpnProto, DiemVM>>,
executor: Arc<BlockExecutor<DpnProto, DiemVM>>,
version: Version,
block_receiver: mpsc::Receiver<(HashValue, HashValue, Instant, Instant, Duration, usize)>,
) -> Self {
Expand Down
6 changes: 3 additions & 3 deletions execution/executor-benchmark/src/transaction_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ use diem_types::{
transaction::{Transaction, Version},
};
use diem_vm::DiemVM;
use executor::Executor;
use executor::block_executor::BlockExecutor;
use executor_types::BlockExecutorTrait;
use std::{
sync::{mpsc, Arc},
time::{Duration, Instant},
};

pub struct TransactionExecutor {
executor: Arc<Executor<DpnProto, DiemVM>>,
executor: Arc<BlockExecutor<DpnProto, DiemVM>>,
parent_block_id: HashValue,
start_time: Instant,
version: Version,
Expand All @@ -25,7 +25,7 @@ pub struct TransactionExecutor {

impl TransactionExecutor {
pub fn new(
executor: Arc<Executor<DpnProto, DiemVM>>,
executor: Arc<BlockExecutor<DpnProto, DiemVM>>,
parent_block_id: HashValue,
version: Version,
commit_sender: Option<
Expand Down
6 changes: 3 additions & 3 deletions execution/executor-test-helpers/src/integration_test_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use diem_types::{
};
use diem_vm::DiemVM;
use diemdb::DiemDB;
use executor::Executor;
use executor::block_executor::BlockExecutor;
use executor_types::BlockExecutorTrait;
use rand::SeedableRng;
use std::{convert::TryFrom, sync::Arc};
Expand Down Expand Up @@ -517,12 +517,12 @@ pub fn create_db_and_executor<P: AsRef<std::path::Path>>(
) -> (
Arc<DiemDB>,
DbReaderWriter,
Executor<DpnProto, DiemVM>,
BlockExecutor<DpnProto, DiemVM>,
Waypoint,
) {
let (db, dbrw) = DbReaderWriter::wrap(DiemDB::new_for_test(&path));
let waypoint = bootstrap_genesis::<DiemVM>(&dbrw, genesis).unwrap();
let executor = Executor::new(dbrw.clone());
let executor = BlockExecutor::new(dbrw.clone());

(db, dbrw, executor, waypoint)
}
Expand Down
6 changes: 3 additions & 3 deletions execution/executor/src/fuzzing.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0

use crate::{chunk_executor::ChunkExecutor, Executor};
use crate::{block_executor::BlockExecutor, chunk_executor::ChunkExecutor};
use anyhow::Result;
use diem_crypto::{hash::SPARSE_MERKLE_PLACEHOLDER_HASH, HashValue};
use diem_state_view::StateView;
Expand All @@ -18,11 +18,11 @@ use diem_vm::VMExecutor;
use executor_types::{BlockExecutorTrait, ChunkExecutorTrait};
use storage_interface::{default_protocol::DbReaderWriter, DbReader, DbWriter, StartupInfo};

fn create_test_executor() -> Executor<DpnProto, FakeVM> {
fn create_test_executor() -> BlockExecutor<DpnProto, FakeVM> {
// setup fake db
let fake_db = FakeDb {};
let db_reader_writer = DbReaderWriter::new(fake_db);
Executor::<DpnProto, FakeVM>::new(db_reader_writer)
BlockExecutor::<DpnProto, FakeVM>::new(db_reader_writer)
}

pub fn fuzz_execute_and_commit_chunk(
Expand Down
2 changes: 0 additions & 2 deletions execution/executor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,3 @@ pub mod block_executor;
pub mod chunk_executor;
pub mod components;
pub mod db_bootstrapper;

pub use block_executor::BlockExecutor as Executor;
5 changes: 3 additions & 2 deletions execution/executor/src/tests/chunk_executor_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
#![forbid(unsafe_code)]

use crate::{
block_executor::BlockExecutor,
chunk_executor::ChunkExecutor,
db_bootstrapper::{generate_waypoint, maybe_bootstrap},
mock_vm::{encode_mint_transaction, MockVM},
tests, Executor,
tests,
};
use diem_crypto::HashValue;
use diem_types::{
Expand Down Expand Up @@ -247,7 +248,7 @@ fn test_executor_execute_and_commit_chunk_local_result_mismatch() {

// commit 5 txns first.
{
let executor = Executor::<DpnProto, MockVM>::new(db);
let executor = BlockExecutor::<DpnProto, MockVM>::new(db);
let parent_block_id = executor.committed_block_id();
let block_id = tests::gen_block_id(1);
let version = 5;
Expand Down
10 changes: 5 additions & 5 deletions execution/executor/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
// SPDX-License-Identifier: Apache-2.0

use crate::{
block_executor::BlockExecutor,
chunk_executor::ChunkExecutor,
db_bootstrapper::{generate_waypoint, maybe_bootstrap},
mock_vm::{
encode_mint_transaction, encode_reconfiguration_transaction, encode_transfer_transaction,
MockVM, DISCARD_STATUS, KEEP_STATUS,
},
Executor,
};
use diem_crypto::HashValue;
use diem_types::{
Expand Down Expand Up @@ -49,7 +49,7 @@ fn execute_and_commit_block(
struct TestExecutor {
_path: diem_temppath::TempPath,
db: DbReaderWriter,
executor: Executor<DpnProto, MockVM>,
executor: BlockExecutor<DpnProto, MockVM>,
}

impl TestExecutor {
Expand All @@ -60,7 +60,7 @@ impl TestExecutor {
let genesis = vm_genesis::test_genesis_transaction();
let waypoint = generate_waypoint::<MockVM>(&db, &genesis).unwrap();
maybe_bootstrap::<MockVM>(&db, &genesis, waypoint).unwrap();
let executor = Executor::new(db.clone());
let executor = BlockExecutor::new(db.clone());

TestExecutor {
_path: path,
Expand All @@ -71,7 +71,7 @@ impl TestExecutor {
}

impl std::ops::Deref for TestExecutor {
type Target = Executor<DpnProto, MockVM>;
type Target = BlockExecutor<DpnProto, MockVM>;

fn deref(&self) -> &Self::Target {
&self.executor
Expand Down Expand Up @@ -505,7 +505,7 @@ proptest! {

// Now we construct a new executor and run one more block.
{
let executor = Executor::<DpnProto, MockVM>::new(db);
let executor = BlockExecutor::<DpnProto, MockVM>::new(db);
let output_b = executor.execute_block((block_b.id, block_b.txns.clone()), parent_block_id).unwrap();
root_hash = output_b.root_hash();
let ledger_info = gen_ledger_info(
Expand Down
8 changes: 4 additions & 4 deletions execution/executor/tests/db_bootstrapper_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ use diem_types::{
use diem_vm::DiemVM;
use diemdb::{DiemDB, GetRestoreHandler};
use executor::{
block_executor::BlockExecutor,
db_bootstrapper::{generate_waypoint, maybe_bootstrap},
Executor,
};
use executor_test_helpers::{
bootstrap_genesis, gen_ledger_info_with_sigs, get_test_signed_transaction,
Expand All @@ -54,7 +54,7 @@ fn test_empty_db() {
let tmp_dir = TempPath::new();
let db_rw = DbReaderWriter::new(DiemDB::new_for_test(&tmp_dir));

// Executor won't be able to boot on empty db due to lack of StartupInfo.
// BlockExecutor won't be able to boot on empty db due to lack of StartupInfo.
assert!(db_rw.reader.get_startup_info().unwrap().is_none());

// Bootstrap empty DB.
Expand Down Expand Up @@ -94,7 +94,7 @@ fn execute_and_commit(txns: Vec<Transaction>, db: &DbReaderWriter, signer: &Vali
let version = li.ledger_info().version();
let epoch = li.ledger_info().next_block_epoch();
let target_version = version + txns.len() as u64;
let executor = Executor::<DpnProto, DiemVM>::new(db.clone());
let executor = BlockExecutor::<DpnProto, DiemVM>::new(db.clone());
let output = executor
.execute_block((block_id, txns), executor.committed_block_id())
.unwrap();
Expand Down Expand Up @@ -282,7 +282,7 @@ fn test_pre_genesis() {

// DB is not empty, `maybe_bootstrap()` will try to apply and fail the waypoint check.
assert!(maybe_bootstrap::<DiemVM>(&db_rw, &genesis_txn, waypoint).is_err());
// Nor is it able to boot Executor.
// Nor is it able to boot BlockExecutor.
assert!(db_rw.reader.get_startup_info().unwrap().is_none());

// New genesis transaction: set validator set and overwrite account1 balance
Expand Down
12 changes: 6 additions & 6 deletions secure/key-manager/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use diem_types::{
};
use diem_vm::DiemVM;
use diemdb::DiemDB;
use executor::Executor;
use executor::block_executor::BlockExecutor;
use executor_types::BlockExecutorTrait;
use futures::{channel::mpsc::channel, StreamExt};
use rand::{rngs::StdRng, SeedableRng};
Expand All @@ -49,15 +49,15 @@ use vm_validator::{
const TXN_EXPIRATION_SECS: u64 = 100;

struct Node<T: DiemInterface> {
executor: Executor<DpnProto, DiemVM>,
executor: BlockExecutor<DpnProto, DiemVM>,
diem: DiemInterfaceTestHarness<T>,
key_manager: KeyManager<DiemInterfaceTestHarness<T>, InMemoryStorage>,
time: MockTimeService,
}

impl<T: DiemInterface> Node<T> {
pub fn new(
executor: Executor<DpnProto, DiemVM>,
executor: BlockExecutor<DpnProto, DiemVM>,
diem: DiemInterfaceTestHarness<T>,
key_manager: KeyManager<DiemInterfaceTestHarness<T>, InMemoryStorage>,
time: MockTimeService,
Expand Down Expand Up @@ -317,7 +317,7 @@ fn setup_node_using_json_rpc() -> (Node<JsonRpcDiemInterface>, Runtime) {

let (storage, db_rw) = setup_diem_db(&node_config);
let (diem, server) = setup_diem_interface_and_json_server(storage);
let executor = Executor::new(db_rw);
let executor = BlockExecutor::new(db_rw);

(
setup_node(&node_config, &key_manager_config, executor, diem),
Expand All @@ -331,7 +331,7 @@ fn setup_node_using_test_mocks() -> Node<MockDiemInterface> {
let (node_config, key_manager_config) = get_test_configs();
let (storage, db_rw) = setup_diem_db(&node_config);
let diem = MockDiemInterface { storage };
let executor = Executor::new(db_rw);
let executor = BlockExecutor::new(db_rw);

setup_node(&node_config, &key_manager_config, executor, diem)
}
Expand All @@ -350,7 +350,7 @@ fn setup_diem_db(config: &NodeConfig) -> (Arc<DiemDB>, DbReaderWriter) {
fn setup_node<T: DiemInterface + Clone>(
node_config: &NodeConfig,
key_manager_config: &KeyManagerConfig,
executor: Executor<DpnProto, DiemVM>,
executor: BlockExecutor<DpnProto, DiemVM>,
diem: T,
) -> Node<T> {
let time = TimeService::mock();
Expand Down
Loading

0 comments on commit 6c6644a

Please sign in to comment.