Skip to content
Merged
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
11 changes: 11 additions & 0 deletions crates/context/src/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use context_interface::{
},
};
use core::fmt::Debug;
use database_interface::{BENCH_CALLER, BENCH_TARGET};
use primitives::{Address, Bytes, TxKind, B256, U256};
use std::{vec, vec::Vec};

Expand Down Expand Up @@ -113,6 +114,16 @@ pub enum DeriveTxTypeError {
}

impl TxEnv {
/// Creates a new TxEnv with benchmark-specific values.
pub fn new_bench() -> Self {
Self {
caller: BENCH_CALLER,
kind: TxKind::Call(BENCH_TARGET),
gas_limit: 1_000_000_000,
..Default::default()
}
}

/// Derives tx type from transaction fields and sets it to `tx_type`.
/// Returns error in case some fields were not set correctly.
pub fn derive_tx_type(&mut self) -> Result<(), DeriveTxTypeError> {
Expand Down
11 changes: 10 additions & 1 deletion crates/database/interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,19 @@ use core::convert::Infallible;

use auto_impl::auto_impl;
use core::error::Error;
use primitives::{Address, HashMap, StorageKey, StorageValue, B256};
use primitives::{address, Address, HashMap, StorageKey, StorageValue, B256, U256};
use state::{Account, AccountInfo, Bytecode};
use std::string::String;

// BYTECODE address
pub const FFADDRESS: Address = address!("0xffffffffffffffffffffffffffffffffffffffff");
pub const BENCH_TARGET: Address = FFADDRESS;
pub const BENCH_TARGET_BALANCE: U256 = U256::from_limbs([10_000_000_000_000_000, 0, 0, 0]);
/// CALLER address
pub const EEADDRESS: Address = address!("0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");
pub const BENCH_CALLER: Address = EEADDRESS;
pub const BENCH_CALLER_BALANCE: U256 = U256::from_limbs([10_000_000_000_000_000, 0, 0, 0]);

#[cfg(feature = "asyncdb")]
pub mod async_db;
pub mod empty_db;
Expand Down
17 changes: 5 additions & 12 deletions crates/database/src/in_memory_db.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use core::convert::Infallible;
use database_interface::{Database, DatabaseCommit, DatabaseRef, EmptyDB};
use database_interface::{
Database, DatabaseCommit, DatabaseRef, EmptyDB, BENCH_CALLER, BENCH_CALLER_BALANCE,
BENCH_TARGET, BENCH_TARGET_BALANCE,
};
use primitives::{
address, hash_map::Entry, Address, HashMap, Log, StorageKey, StorageValue, B256, KECCAK_EMPTY,
U256,
hash_map::Entry, Address, HashMap, Log, StorageKey, StorageValue, B256, KECCAK_EMPTY, U256,
};
use state::{Account, AccountInfo, Bytecode};
use std::vec::Vec;
Expand Down Expand Up @@ -434,15 +436,6 @@ impl BenchmarkDB {
}
}

/// BYTECODE address
pub const FFADDRESS: Address = address!("0xffffffffffffffffffffffffffffffffffffffff");
pub const BENCH_TARGET: Address = FFADDRESS;
pub const BENCH_TARGET_BALANCE: U256 = U256::from_limbs([10_000_000_000_000_000, 0, 0, 0]);
/// CALLER address
pub const EEADDRESS: Address = address!("0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");
pub const BENCH_CALLER: Address = EEADDRESS;
pub const BENCH_CALLER_BALANCE: U256 = U256::from_limbs([10_000_000_000_000_000, 0, 0, 0]);

impl Database for BenchmarkDB {
type Error = Infallible;
/// Get basic account information.
Expand Down
Loading