Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finalize v0.42.0 release #307

Merged
merged 7 commits into from
Jan 14, 2025
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
8 changes: 6 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ name: Rust

on:
push:
branches: [ master ]
branches:
- master
- v0.x
pull_request:
branches: [ master ]
branches:
- master
- v0.x

env:
CARGO_TERM_COLOR: always
Expand Down
3 changes: 3 additions & 0 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ impl Machine {
}

/// Copy and get the return value of the machine, if any.
#[allow(clippy::slow_vector_initialization)]
// Clippy complains about not using `no_std`. However, we need to support
// `no_std` and we can't use that.
pub fn return_value(&self) -> Vec<u8> {
if self.return_range.start > U256::from(usize::MAX) {
let mut ret = Vec::new();
Expand Down
8 changes: 5 additions & 3 deletions core/src/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@ impl Memory {
&self.data
}

/// Resize the memory, making it cover the memory region of `offset..(offset
/// + len)`, with 32 bytes as the step. If the length is zero, this function
/// does nothing.
/// Resize the memory, making it cover the memory region of `offset..(offset + len)`,
/// with 32 bytes as the step. If the length is zero, this function does nothing.
pub fn resize_offset(&mut self, offset: U256, len: U256) -> Result<(), ExitError> {
if len == U256::zero() {
return Ok(());
Expand Down Expand Up @@ -79,6 +78,9 @@ impl Memory {
///
/// Value of `size` is considered trusted. If they're too large,
/// the program can run out of memory, or it can overflow.
#[allow(clippy::slow_vector_initialization)]
// Clippy complains about not using `vec!`. However, we need to support
// `no_std` and we can't use that.
pub fn get(&self, offset: usize, size: usize) -> Vec<u8> {
let mut ret = Vec::new();
ret.resize(size, 0);
Expand Down
2 changes: 1 addition & 1 deletion fuzzer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ license = "Apache-2.0"
[dependencies]
honggfuzz = "0.5"

evm-core = { version = "0.41", path = "../core" }
evm-core = { version = "0.42", path = "../core" }

[[bin]]
name = "evm_fuzz"
Expand Down
4 changes: 2 additions & 2 deletions gasometer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ environmental = { version = "1.1.2", default-features = false, optional = true }
log = { version = "0.4", optional = true }
primitive-types = { version = "0.12", default-features = false }

evm-core = { version = "0.41", path = "../core", default-features = false }
evm-runtime = { version = "0.41", path = "../runtime", default-features = false }
evm-core = { version = "0.42", path = "../core", default-features = false }
evm-runtime = { version = "0.42", path = "../runtime", default-features = false }

[features]
default = ["std"]
Expand Down
11 changes: 7 additions & 4 deletions gasometer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,10 @@ pub fn dynamic_opcode_cost<H: Handler>(
len: U256::from_big_endian(&stack.peek(3)?[..]),
}
}
Opcode::CALLDATACOPY | Opcode::CODECOPY | Opcode::MCOPY => GasCost::VeryLowCopy {
Opcode::CALLDATACOPY | Opcode::CODECOPY => GasCost::VeryLowCopy {
len: U256::from_big_endian(&stack.peek(2)?[..]),
},
Opcode::MCOPY if config.has_mcopy => GasCost::VeryLowCopy {
len: U256::from_big_endian(&stack.peek(2)?[..]),
},
Opcode::EXP => GasCost::Exp {
Expand All @@ -599,7 +602,7 @@ pub fn dynamic_opcode_cost<H: Handler>(
target_is_cold: handler.is_cold(address, Some(index))?,
}
}
Opcode::TLOAD => GasCost::TLoad,
Opcode::TLOAD if config.has_tloadstore => GasCost::TLoad,

Opcode::DELEGATECALL if config.has_delegate_call => {
let target = stack.peek(1)?.into();
Expand Down Expand Up @@ -633,7 +636,7 @@ pub fn dynamic_opcode_cost<H: Handler>(
target_is_cold: handler.is_cold(address, Some(index))?,
}
}
Opcode::TSTORE if !is_static => GasCost::TStore,
Opcode::TSTORE if config.has_tloadstore && !is_static => GasCost::TStore,
Opcode::LOG0 if !is_static => GasCost::Log {
n: 0,
len: U256::from_big_endian(&stack.peek(1)?[..]),
Expand Down Expand Up @@ -778,7 +781,7 @@ struct Inner<'config> {
config: &'config Config,
}

impl<'config> Inner<'config> {
impl Inner<'_> {
fn memory_gas(&self, memory: MemoryCost) -> Result<u64, ExitError> {
let from = memory.offset;
let len = memory.len;
Expand Down
2 changes: 1 addition & 1 deletion runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ environmental = { version = "1.1.2", default-features = false, optional = true }
primitive-types = { version = "0.12", default-features = false }
sha3 = { version = "0.10", default-features = false }

evm-core = { version = "0.41", path = "../core", default-features = false }
evm-core = { version = "0.42", path = "../core", default-features = false }

[features]
default = ["std"]
Expand Down
7 changes: 1 addition & 6 deletions runtime/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,7 @@ pub trait Handler {
/// Set storage value of address at index.
fn set_storage(&mut self, address: H160, index: H256, value: H256) -> Result<(), ExitError>;
/// Set transient storage value of address at index, transient storage gets discarded after every transaction. (see EIP-1153)
fn set_transient_storage(
&mut self,
address: H160,
index: H256,
value: H256,
);
fn set_transient_storage(&mut self, address: H160, index: H256, value: H256);
/// Create a log owned by address with given topics and data.
fn log(&mut self, address: H160, topics: Vec<H256>, data: Vec<u8>) -> Result<(), ExitError>;
/// Mark an address to be deleted, with funds transferred to target.
Expand Down
24 changes: 24 additions & 0 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,10 @@ pub struct Config {
pub has_base_fee: bool,
/// Has PUSH0 opcode. See [EIP-3855](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-3855.md)
pub has_push0: bool,
/// Has TLOAD and TSTORE opcode.
pub has_tloadstore: bool,
/// Has MCOPY opcode.
pub has_mcopy: bool,
/// Whether the gasometer is running in estimate mode.
pub estimate: bool,
/// Has EIP-6780. See [EIP-6780](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-6780.md)
Expand Down Expand Up @@ -343,6 +347,8 @@ impl Config {
has_ext_code_hash: false,
has_base_fee: false,
has_push0: false,
has_tloadstore: false,
has_mcopy: false,
estimate: false,
has_eip_6780: false,
}
Expand Down Expand Up @@ -398,6 +404,8 @@ impl Config {
has_ext_code_hash: true,
has_base_fee: false,
has_push0: false,
has_tloadstore: false,
has_mcopy: false,
estimate: false,
has_eip_6780: false,
}
Expand Down Expand Up @@ -440,6 +448,8 @@ impl Config {
warm_coinbase_address,
max_initcode_size,
has_eip_6780,
has_tloadstore,
has_mcopy,
} = inputs;

// See https://eips.ethereum.org/EIPS/eip-2929
Expand Down Expand Up @@ -504,6 +514,8 @@ impl Config {
has_push0,
estimate: false,
has_eip_6780,
has_tloadstore,
has_mcopy,
}
}
}
Expand All @@ -521,6 +533,8 @@ struct DerivedConfigInputs {
warm_coinbase_address: bool,
max_initcode_size: Option<usize>,
has_eip_6780: bool,
has_tloadstore: bool,
has_mcopy: bool,
}

impl DerivedConfigInputs {
Expand All @@ -536,6 +550,8 @@ impl DerivedConfigInputs {
warm_coinbase_address: false,
max_initcode_size: None,
has_eip_6780: false,
has_tloadstore: false,
has_mcopy: false,
}
}

Expand All @@ -551,6 +567,8 @@ impl DerivedConfigInputs {
warm_coinbase_address: false,
max_initcode_size: None,
has_eip_6780: false,
has_tloadstore: false,
has_mcopy: false,
}
}

Expand All @@ -566,6 +584,8 @@ impl DerivedConfigInputs {
warm_coinbase_address: false,
max_initcode_size: None,
has_eip_6780: false,
has_tloadstore: false,
has_mcopy: false,
}
}

Expand All @@ -582,6 +602,8 @@ impl DerivedConfigInputs {
// 2 * 24576 as per EIP-3860
max_initcode_size: Some(0xC000),
has_eip_6780: false,
has_tloadstore: false,
has_mcopy: false,
}
}

Expand All @@ -598,6 +620,8 @@ impl DerivedConfigInputs {
// 2 * 24576 as per EIP-3860
max_initcode_size: Some(0xC000),
has_eip_6780: true,
has_tloadstore: true,
has_mcopy: true,
}
}
}
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "1.69.0"
channel = "1.84.0"
profile = "minimal"
components = [ "rustfmt", "clippy" ]
6 changes: 3 additions & 3 deletions src/backend/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ impl<'vicinity> MemoryBackend<'vicinity> {
}
}

impl<'vicinity> Backend for MemoryBackend<'vicinity> {
impl Backend for MemoryBackend<'_> {
fn gas_price(&self) -> U256 {
self.vicinity.gas_price
}
Expand Down Expand Up @@ -172,7 +172,7 @@ impl<'vicinity> Backend for MemoryBackend<'vicinity> {
}
}

impl<'vicinity> ApplyBackend for MemoryBackend<'vicinity> {
impl ApplyBackend for MemoryBackend<'_> {
fn apply<A, I, L>(&mut self, values: A, logs: L, delete_empty: bool)
where
A: IntoIterator<Item = Apply<I>>,
Expand All @@ -189,7 +189,7 @@ impl<'vicinity> ApplyBackend for MemoryBackend<'vicinity> {
reset_storage,
} => {
let is_empty = {
let account = self.state.entry(address).or_insert_with(Default::default);
let account = self.state.entry(address).or_default();
account.balance = basic.balance;
account.nonce = basic.nonce;
if let Some(code) = code {
Expand Down
17 changes: 6 additions & 11 deletions src/executor/stack/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ impl<'config, 'precompiles, S: StackState<'config>, P: PrecompileSet>
let mut stream = rlp::RlpStream::new_list(2);
stream.append(&caller);
stream.append(&nonce);
H256::from_slice(Keccak256::digest(&stream.out()).as_slice()).into()
H256::from_slice(Keccak256::digest(stream.out()).as_slice()).into()
}
CreateScheme::Fixed(naddress) => naddress,
}
Expand Down Expand Up @@ -1087,8 +1087,8 @@ impl<'config, 'precompiles, S: StackState<'config>, P: PrecompileSet>
pub struct StackExecutorCallInterrupt<'borrow>(TaggedRuntime<'borrow>);
pub struct StackExecutorCreateInterrupt<'borrow>(TaggedRuntime<'borrow>);

impl<'config, 'precompiles, S: StackState<'config>, P: PrecompileSet> Handler
for StackExecutor<'config, 'precompiles, S, P>
impl<'config, S: StackState<'config>, P: PrecompileSet> Handler
for StackExecutor<'config, '_, S, P>
{
type CreateInterrupt = StackExecutorCreateInterrupt<'static>;
type CreateFeedback = Infallible;
Expand Down Expand Up @@ -1210,12 +1210,7 @@ impl<'config, 'precompiles, S: StackState<'config>, P: PrecompileSet> Handler
Ok(())
}

fn set_transient_storage(
&mut self,
address: H160,
index: H256,
value: H256,
) {
fn set_transient_storage(&mut self, address: H160, index: H256, value: H256) {
self.state.set_transient_storage(address, index, value);
}

Expand Down Expand Up @@ -1402,8 +1397,8 @@ struct StackExecutorHandle<'inner, 'config, 'precompiles, S, P> {
is_static: bool,
}

impl<'inner, 'config, 'precompiles, S: StackState<'config>, P: PrecompileSet> PrecompileHandle
for StackExecutorHandle<'inner, 'config, 'precompiles, S, P>
impl<'config, S: StackState<'config>, P: PrecompileSet> PrecompileHandle
for StackExecutorHandle<'_, 'config, '_, S, P>
{
// Perform subcall in provided context.
/// Precompile specifies in which context the subcall is executed.
Expand Down
4 changes: 2 additions & 2 deletions src/executor/stack/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ pub struct MemoryStackState<'backend, 'config, B> {
substate: MemoryStackSubstate<'config>,
}

impl<'backend, 'config, B: Backend> Backend for MemoryStackState<'backend, 'config, B> {
impl<B: Backend> Backend for MemoryStackState<'_, '_, B> {
fn gas_price(&self) -> U256 {
self.backend.gas_price()
}
Expand Down Expand Up @@ -515,7 +515,7 @@ impl<'backend, 'config, B: Backend> Backend for MemoryStackState<'backend, 'conf
}
}

impl<'backend, 'config, B: Backend> StackState<'config> for MemoryStackState<'backend, 'config, B> {
impl<'config, B: Backend> StackState<'config> for MemoryStackState<'_, 'config, B> {
fn metadata(&self) -> &StackSubstateMetadata<'config> {
self.substate.metadata()
}
Expand Down
4 changes: 2 additions & 2 deletions src/maybe_borrowed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub enum MaybeBorrowed<'a, T> {
Owned(T),
}

impl<'a, T> core::ops::Deref for MaybeBorrowed<'a, T> {
impl<T> core::ops::Deref for MaybeBorrowed<'_, T> {
type Target = T;

fn deref(&self) -> &Self::Target {
Expand All @@ -24,7 +24,7 @@ impl<'a, T> core::ops::Deref for MaybeBorrowed<'a, T> {
}
}

impl<'a, T> core::ops::DerefMut for MaybeBorrowed<'a, T> {
impl<T> core::ops::DerefMut for MaybeBorrowed<'_, T> {
fn deref_mut(&mut self) -> &mut Self::Target {
match self {
Self::Borrowed(x) => x,
Expand Down
Loading