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
2 changes: 1 addition & 1 deletion bins/revme/src/statetest/models/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl SpecName {
Self::Shanghai => SpecId::SHANGHAI,
Self::Cancun => SpecId::CANCUN,
Self::ByzantiumToConstantinopleAt5 | Self::Constantinople => {
panic!("Overriden with PETERSBURG")
panic!("Overridden with PETERSBURG")
}
Self::Unknown => panic!("Unknown spec"),
}
Expand Down
4 changes: 2 additions & 2 deletions bins/revme/src/statetest/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ pub fn execute_test_suite(
return Ok(());
}

// Test checks if nonce overflows. We are handling this correctly but we are not parsing exception in testsuite
// Test checks if nonce overflows. We are handling this correctly but we are not parsing exception in test suite
// There are more nonce overflow tests that are in internal call/create, and those tests are passing and are enabled.
if name == "CreateTransactionHighNonce.json" {
return Ok(());
Expand All @@ -90,7 +90,7 @@ pub fn execute_test_suite(
return Ok(());
}

// Skip test where basefee/accesslist/diffuculty is present but it shouldn't be supported in London/Berlin/TheMerge.
// Skip test where basefee/accesslist/difficulty is present but it shouldn't be supported in London/Berlin/TheMerge.
// https://github.com/ethereum/tests/blob/5b7e1ab3ffaf026d99d20b17bb30f533a2c80c8b/GeneralStateTests/stExample/eip1559.json#L130
// It is expected to not execute these tests.
if name == "accessListExample.json"
Expand Down
2 changes: 1 addition & 1 deletion crates/interpreter/src/instructions/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub fn push<const N: usize>(interpreter: &mut Interpreter, _host: &mut dyn Host)
gas!(interpreter, gas::VERYLOW);
let start = interpreter.instruction_pointer;
// Safety: In Analysis we appended needed bytes for bytecode so that we are safe to just add without
// checking if it is out of bound. This makes both of our unsafes block safe to do.
// checking if it is out of bound. This makes both of our unsafe blocks safe to do.
if let Some(ret) = interpreter
.stack
.push_slice::<N>(unsafe { core::slice::from_raw_parts(start, N) })
Expand Down
2 changes: 1 addition & 1 deletion crates/interpreter/src/interpreter/analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub fn to_analysed(bytecode: Bytecode) -> Bytecode {
}
}

/// Analyzs bytecode to build a jump map.
/// Analyze bytecode to build a jump map.
fn analyze(code: &[u8]) -> JumpMap {
let mut jumps: BitVec<u8> = bitvec![u8, Lsb0; 0; code.len()];

Expand Down
12 changes: 6 additions & 6 deletions crates/interpreter/src/interpreter/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use core::{
ops::{BitAnd, Not},
};

/// A sequencial memory. It uses Rust's `Vec` for internal
/// A sequential memory. It uses Rust's `Vec` for internal
/// representation.
#[derive(Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
Expand Down Expand Up @@ -58,13 +58,13 @@ impl Memory {
self.data.shrink_to_fit()
}

/// Resize the memory. asume that we already checked if
/// Resize the memory. Assume that we already checked if
/// we have enought gas to resize this vector and that we made new_size as multiply of 32
pub fn resize(&mut self, new_size: usize) {
self.data.resize(new_size, 0);
}

/// Get memory region at given offset. Dont check offset and size
/// Get memory region at given offset. Don't check offset and size
#[inline(always)]
pub fn get_slice(&self, offset: usize, size: usize) -> &[u8] {
&self.data[offset..offset + size]
Expand Down Expand Up @@ -93,11 +93,11 @@ impl Memory {
}

/// Set memory from data. Our memory offset+len is expected to be correct but we
/// are doing bound checks on data/data_offeset/len and zeroing parts that is not copied.
/// are doing bound checks on data/data_offset/len and zeroing parts that is not copied.
#[inline(always)]
pub fn set_data(&mut self, memory_offset: usize, data_offset: usize, len: usize, data: &[u8]) {
if data_offset >= data.len() {
// nulify all memory slots
// nullify all memory slots
for i in &mut self.data[memory_offset..memory_offset + len] {
*i = 0;
}
Expand All @@ -107,7 +107,7 @@ impl Memory {
let memory_data_end = memory_offset + (data_end - data_offset);
self.data[memory_offset..memory_data_end].copy_from_slice(&data[data_offset..data_end]);

// nulify rest of memory slots
// nullify rest of memory slots
// Safety: Memory is assumed to be valid. And it is commented where that assumption is made
for i in &mut self.data[memory_data_end..memory_offset + len] {
*i = 0;
Expand Down
2 changes: 1 addition & 1 deletion crates/interpreter/src/interpreter/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ impl Stack {
}

let slot;
// Safety: check above ensures us that we are okey in increment len.
// Safety: check above ensures us that we are okay in increment len.
unsafe {
self.data.set_len(new_len);
slot = self.data.get_unchecked_mut(new_len - 1);
Expand Down
2 changes: 1 addition & 1 deletion crates/precompile/src/bn128.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ fn run_mul(input: &[u8]) -> Result<Vec<u8>, Error> {

let mut fr_buf = [0u8; 32];
fr_buf.copy_from_slice(&input[64..96]);
// Fr::from_slice can only fail on incorect length, and this is not a case.
// Fr::from_slice can only fail on incorrect length, and this is not a case.
let fr = bn::Fr::from_slice(&fr_buf[..]).unwrap();

let mut out = [0u8; 64];
Expand Down
10 changes: 5 additions & 5 deletions crates/primitives/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ pub struct CfgEnv {
pub chain_id: U256,
pub spec_id: SpecId,
/// Bytecode that is created with CREATE/CREATE2 is by default analysed and jumptable is created.
/// This is very benefitial for testing and speeds up execution of that bytecode if called multiple times.
/// This is very beneficial for testing and speeds up execution of that bytecode if called multiple times.
///
/// Default: Analyse
pub perf_analyse_created_bytecodes: AnalysisKind,
/// If some it will effects EIP-170: Contract code size limit. Usefull to increase this because of tests.
/// If some it will effects EIP-170: Contract code size limit. Useful to increase this because of tests.
/// By default it is 0x6000 (~25kb).
pub limit_contract_code_size: Option<usize>,
/// A hard memory limit in bytes beyond which [Memory] cannot be resized.
Expand Down Expand Up @@ -260,7 +260,7 @@ impl Env {

/// Validate transaction data that is set inside ENV and return error if something is wrong.
///
/// Return inital spend gas (Gas needed to execute transaction).
/// Return initial spend gas (Gas needed to execute transaction).
#[inline]
pub fn validate_tx<SPEC: Spec>(&self) -> Result<(), InvalidTransaction> {
let gas_limit = self.tx.gas_limit;
Expand Down Expand Up @@ -315,9 +315,9 @@ impl Env {
Ok(())
}

/// Validate transaction agains state.
/// Validate transaction against state.
#[inline]
pub fn validate_tx_agains_state(&self, account: &Account) -> Result<(), InvalidTransaction> {
pub fn validate_tx_against_state(&self, account: &Account) -> Result<(), InvalidTransaction> {
// EIP-3607: Reject transactions from senders with deployed code
// This EIP is introduced after london but there was no collision in past
// so we can leave it enabled always
Expand Down
2 changes: 1 addition & 1 deletion crates/primitives/src/precompile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub type CustomPrecompileFn = fn(&[u8], u64) -> PrecompileResult;

#[derive(Clone, Debug, Eq, PartialEq)]
pub enum PrecompileError {
/// out of gas is the main error. Other are just here for completness
/// out of gas is the main error. Other are just here for completeness
OutOfGas,
// Blake2 erorr
Blake2WrongLength,
Expand Down
2 changes: 1 addition & 1 deletion crates/primitives/src/specification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ spec!(HOMESTEAD, HomesteadSpec);
spec!(TANGERINE, TangerineSpec);
spec!(SPURIOUS_DRAGON, SpuriousDragonSpec);
spec!(BYZANTIUM, ByzantiumSpec);
// CONSTANTINOPLE was overriden with PETERSBURG
// CONSTANTINOPLE was overridden with PETERSBURG
spec!(PETERSBURG, PetersburgSpec);
spec!(ISTANBUL, IstanbulSpec);
// MUIR_GLACIER no EVM spec change
Expand Down
2 changes: 1 addition & 1 deletion crates/revm/src/db/in_memory_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ impl From<AccountInfo> for DbAccount {
#[derive(Debug, Clone, Default, Eq, PartialEq)]
pub enum AccountState {
/// Before Spurious Dragon hardfork there was a difference between empty and not existing.
/// And we are flaging it here.
/// And we are flagging it here.
NotExisting,
/// EVM touched this account. For newer hardfork this means it can be cleared/removed from state.
Touched,
Expand Down
2 changes: 1 addition & 1 deletion crates/revm/src/db/states/account_status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub enum AccountStatus {
}

impl AccountStatus {
/// Account is not midified and just loaded from database.
/// Account is not modified and just loaded from database.
pub fn not_modified(&self) -> bool {
matches!(
self,
Expand Down
8 changes: 4 additions & 4 deletions crates/revm/src/db/states/bundle_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ use revm_precompile::HashMap;
pub struct BundleAccount {
pub info: Option<AccountInfo>,
pub original_info: Option<AccountInfo>,
/// Contain both original and present state.
/// Contains both original and present state.
/// When extracting changeset we compare if original value is different from present value.
/// If it is different we add it to changeset.
///
/// If Account was destroyed we ignore original value and comprate present state with U256::ZERO.
/// If Account was destroyed we ignore original value and compare present state with U256::ZERO.
pub storage: StorageWithOriginalValues,
/// Account status.
pub status: AccountStatus,
Expand Down Expand Up @@ -95,8 +95,8 @@ impl BundleAccount {
for (key, slot) in revert.storage {
match slot {
RevertToSlot::Some(value) => {
// Dont overwrite original values if present
// if storage is not present set original values as currect value.
// Don't overwrite original values if present
// if storage is not present set original values as current value.
self.storage
.entry(key)
.or_insert(StorageSlot::new_changed(value, U256::ZERO))
Expand Down
10 changes: 5 additions & 5 deletions crates/revm/src/db/states/bundle_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ impl BundleState {
}

/// Get account from state
pub fn account(&self, addres: &Address) -> Option<&BundleAccount> {
self.state.get(addres)
pub fn account(&self, address: &Address) -> Option<&BundleAccount> {
self.state.get(address)
}

/// Get bytecode from state
Expand Down Expand Up @@ -202,11 +202,11 @@ impl BundleState {

// append storage changes

// NOTE: Assumption is that revert is going to remova whole plain storage from
// NOTE: Assumption is that revert is going to remove whole plain storage from
// database so we can check if plain state was wiped or not.
let mut account_storage_changed = Vec::with_capacity(account.storage.len());
if was_destroyed {
// If storage was destroyed that means that storage was wipped.
// If storage was destroyed that means that storage was wiped.
// In that case we need to check if present storage value is different then ZERO.
for (key, slot) in account.storage {
if omit_changed_check || slot.present_value != U256::ZERO {
Expand Down Expand Up @@ -294,7 +294,7 @@ impl BundleState {
self.reverts.extend(other.reverts);
}

/// This will returnd detached lower part of reverts
/// This will return detached lower part of reverts
///
/// Note that plain state will stay the same and returned BundleState
/// will contain only reverts and will be considered broken.
Expand Down
12 changes: 6 additions & 6 deletions crates/revm/src/db/states/cache_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl CacheAccount {
self.account.as_ref().map(|a| a.info.clone())
}

/// Desolve account into components.
/// Dissolve account into components.
pub fn into_components(self) -> (Option<(AccountInfo, PlainStorage)>, AccountStatus) {
(self.account.map(|a| a.into_components()), self.status)
}
Expand Down Expand Up @@ -253,8 +253,8 @@ impl CacheAccount {
| AccountStatus::Loaded
| AccountStatus::Changed
| AccountStatus::InMemoryChange => {
// if account is loaded and not empty this means that account has some balance
// this does not mean that accoun't can be created.
// If account is loaded and not empty this means that account has some balance.
// This means that account cannot be created.
// We are assuming that EVM did necessary checks before allowing account to be created.
AccountStatus::InMemoryChange
}
Expand All @@ -277,7 +277,7 @@ impl CacheAccount {
/// Increment balance by `balance` amount. Assume that balance will not
/// overflow or be zero.
///
/// Note: to skip some edgecases we assume that additional balance is never zero.
/// Note: to skip some edge cases we assume that additional balance is never zero.
/// And as increment is always related to block fee/reward and withdrawals this is correct.
pub fn increment_balance(&mut self, balance: u128) -> TransitionAccount {
self.account_info_change(|info| {
Expand Down Expand Up @@ -384,7 +384,7 @@ impl CacheAccount {
}
AccountStatus::LoadedEmptyEIP161 => {
// Change on empty account, should transfer storage if there is any.
// There is posibility that there are storage inside db.
// There is possibility that there are storage inside db.
// That storage is used in merkle tree calculation before state clear EIP.
AccountStatus::InMemoryChange
}
Expand All @@ -395,7 +395,7 @@ impl CacheAccount {
}
AccountStatus::Destroyed | AccountStatus::DestroyedAgain => {
// If account is destroyed and then changed this means this is
// balance tranfer.
// balance transfer.
AccountStatus::DestroyedChanged
}
};
Expand Down
8 changes: 4 additions & 4 deletions crates/revm/src/db/states/changes.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use revm_interpreter::primitives::{AccountInfo, Address, Bytecode, B256, U256};

/// Sorted accounts/storages/contracts for inclusion into database.
/// Structure is made so it is easier to apply dirrectly to database
/// that mostly have saparate tables to store account/storage/contract data.
/// Structure is made so it is easier to apply directly to database
/// that mostly have separate tables to store account/storage/contract data.
#[derive(Clone, Debug, Default)]
pub struct StateChangeset {
/// Vector of account presorted by address, with removed contracts bytecode
pub accounts: Vec<(Address, Option<AccountInfo>)>,
/// Vector of storage presorted by address
/// First bool is indicatior if storage needs to be dropped.
/// First bool is indicator if storage needs to be dropped.
pub storage: StorageChangeset,
/// Vector of contracts presorted by bytecode hash
pub contracts: Vec<(B256, Bytecode)>,
Expand All @@ -19,7 +19,7 @@ pub type StorageChangeset = Vec<(Address, (bool, Vec<(U256, U256)>))>;

#[derive(Clone, Debug, Default)]
pub struct StateReverts {
/// Vector of account presorted by anddress, with removed cotracts bytecode
/// Vector of account presorted by address, with removed contracts bytecode
///
/// Note: AccountInfo None means that account needs to be removed.
pub accounts: Vec<Vec<(Address, Option<AccountInfo>)>>,
Expand Down
8 changes: 4 additions & 4 deletions crates/revm/src/db/states/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ use revm_interpreter::primitives::{
/// State clear flag is set inside CacheState and by default it is enabled.
/// If you want to disable it use `set_state_clear_flag` function.
pub struct State<'a, DBError> {
/// Cached state contains both changed from evm executiong and cached/loaded account/storages
/// Cached state contains both changed from evm execution and cached/loaded account/storages
/// from database. This allows us to have only one layer of cache where we can fetch data.
/// Additionaly we can introuduce some preloading of data from database.
/// Additionaly we can introduce some preloading of data from database.
pub cache: CacheState,
/// Optional database that we use to fetch data from. If database is not present, we will
/// return not existing account and storage.
Expand Down Expand Up @@ -194,8 +194,8 @@ impl<'a, DBError> Database for State<'a, DBError> {
.map(|account| match account.storage.entry(index) {
hash_map::Entry::Occupied(entry) => Ok(*entry.get()),
hash_map::Entry::Vacant(entry) => {
// if account was destroyed or account is newely build
// we return zero and dont ask detabase.
// if account was destroyed or account is newly built
// we return zero and don't ask database.
let value = if is_storage_known {
U256::ZERO
} else {
Expand Down
4 changes: 2 additions & 2 deletions crates/revm/src/db/states/state_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ impl<'a, DBError> StateBuilder<'a, DBError> {
}
}

/// Dont make transitions and dont update bundle state.
/// Don't make transitions and don't update bundle state.
///
/// This is good option if we dont care about creating reverts
/// This is good option if we don't care about creating reverts
/// or getting output of changed states.
pub fn without_bundle_update(self) -> Self {
Self {
Expand Down
10 changes: 5 additions & 5 deletions crates/revm/src/db/states/transition_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ use revm_interpreter::primitives::{hash_map, AccountInfo, Bytecode, B256};
pub struct TransitionAccount {
pub info: Option<AccountInfo>,
pub status: AccountStatus,
/// Previous account info is needed for account that got initialy loaded.
/// Initialy loaded account are not present inside bundle and are needed
/// Previous account info is needed for account that got initially loaded.
/// Initially loaded account are not present inside bundle and are needed
/// to generate Reverts.
pub previous_info: Option<AccountInfo>,
/// Mostly needed when previous status Loaded/LoadedEmpty.
pub previous_status: AccountStatus,
/// Storage contains both old and new account
pub storage: StorageWithOriginalValues,
/// If there is transition that clears the storage we shold mark it here and
/// If there is transition that clears the storage we should mark it here and
/// delete all storages in BundleState. This flag is needed if we have transition
/// between Destroyed states from DestroyedChanged-> DestroyedAgain-> DestroyedChanged
/// in the end transition that we would have would be `DestroyedChanged->DestroyedChanged`
/// and with only that info we coudn't decide what to do.
/// and with only that info we couldn't decide what to do.
pub storage_was_destroyed: bool,
}

Expand Down Expand Up @@ -53,7 +53,7 @@ impl TransitionAccount {
None
}

/// Update new values of transition. Dont override old values
/// Update new values of transition. Don't override old values
/// both account info and old storages need to be left intact.
pub fn update(&mut self, other: Self) {
self.info = other.info.clone();
Expand Down
2 changes: 1 addition & 1 deletion crates/revm/src/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use revm_precompile::Precompiles;
/// handling of struct you want.
/// * Database trait has mutable self in its functions. It is usefully if on get calls you want to modify
/// your cache or update some statistics. They enable `transact` and `inspect` functions
/// * DatabaseRef takes reference on object, this is useful if you only have reference on state and dont
/// * DatabaseRef takes reference on object, this is useful if you only have reference on state and don't
/// want to update anything on it. It enabled `transact_ref` and `inspect_ref` functions
/// * Database+DatabaseCommit allow directly committing changes of transaction. it enabled `transact_commit`
/// and `inspect_commit`
Expand Down
Loading