Skip to content

Commit f45fcb7

Browse files
authored
Finalize v0.42.0 release (#307)
* Update rust version in rust-toolchain.toml * Enable CI in v0.x branch * Fix missing version bumps * Missing version bump in evm-fuzzer * Run cargo fmt on the codebase * Fix all clippy warnings * Add missing opcode flags
1 parent 75da09b commit f45fcb7

File tree

14 files changed

+64
-38
lines changed

14 files changed

+64
-38
lines changed

.github/workflows/rust.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@ name: Rust
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches:
6+
- master
7+
- v0.x
68
pull_request:
7-
branches: [ master ]
9+
branches:
10+
- master
11+
- v0.x
812

913
env:
1014
CARGO_TERM_COLOR: always

core/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ impl Machine {
103103
}
104104

105105
/// Copy and get the return value of the machine, if any.
106+
#[allow(clippy::slow_vector_initialization)]
107+
// Clippy complains about not using `no_std`. However, we need to support
108+
// `no_std` and we can't use that.
106109
pub fn return_value(&self) -> Vec<u8> {
107110
if self.return_range.start > U256::from(usize::MAX) {
108111
let mut ret = Vec::new();

core/src/memory.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,8 @@ impl Memory {
4848
&self.data
4949
}
5050

51-
/// Resize the memory, making it cover the memory region of `offset..(offset
52-
/// + len)`, with 32 bytes as the step. If the length is zero, this function
53-
/// does nothing.
51+
/// Resize the memory, making it cover the memory region of `offset..(offset + len)`,
52+
/// with 32 bytes as the step. If the length is zero, this function does nothing.
5453
pub fn resize_offset(&mut self, offset: U256, len: U256) -> Result<(), ExitError> {
5554
if len == U256::zero() {
5655
return Ok(());
@@ -79,6 +78,9 @@ impl Memory {
7978
///
8079
/// Value of `size` is considered trusted. If they're too large,
8180
/// the program can run out of memory, or it can overflow.
81+
#[allow(clippy::slow_vector_initialization)]
82+
// Clippy complains about not using `vec!`. However, we need to support
83+
// `no_std` and we can't use that.
8284
pub fn get(&self, offset: usize, size: usize) -> Vec<u8> {
8385
let mut ret = Vec::new();
8486
ret.resize(size, 0);

fuzzer/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ license = "Apache-2.0"
99
[dependencies]
1010
honggfuzz = "0.5"
1111

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

1414
[[bin]]
1515
name = "evm_fuzz"

gasometer/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ environmental = { version = "1.1.2", default-features = false, optional = true }
1313
log = { version = "0.4", optional = true }
1414
primitive-types = { version = "0.12", default-features = false }
1515

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

1919
[features]
2020
default = ["std"]

gasometer/src/lib.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,10 @@ pub fn dynamic_opcode_cost<H: Handler>(
586586
len: U256::from_big_endian(&stack.peek(3)?[..]),
587587
}
588588
}
589-
Opcode::CALLDATACOPY | Opcode::CODECOPY | Opcode::MCOPY => GasCost::VeryLowCopy {
589+
Opcode::CALLDATACOPY | Opcode::CODECOPY => GasCost::VeryLowCopy {
590+
len: U256::from_big_endian(&stack.peek(2)?[..]),
591+
},
592+
Opcode::MCOPY if config.has_mcopy => GasCost::VeryLowCopy {
590593
len: U256::from_big_endian(&stack.peek(2)?[..]),
591594
},
592595
Opcode::EXP => GasCost::Exp {
@@ -599,7 +602,7 @@ pub fn dynamic_opcode_cost<H: Handler>(
599602
target_is_cold: handler.is_cold(address, Some(index))?,
600603
}
601604
}
602-
Opcode::TLOAD => GasCost::TLoad,
605+
Opcode::TLOAD if config.has_tloadstore => GasCost::TLoad,
603606

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

781-
impl<'config> Inner<'config> {
784+
impl Inner<'_> {
782785
fn memory_gas(&self, memory: MemoryCost) -> Result<u64, ExitError> {
783786
let from = memory.offset;
784787
let len = memory.len;

runtime/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ environmental = { version = "1.1.2", default-features = false, optional = true }
1414
primitive-types = { version = "0.12", default-features = false }
1515
sha3 = { version = "0.10", default-features = false }
1616

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

1919
[features]
2020
default = ["std"]

runtime/src/handler.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,7 @@ pub trait Handler {
8181
/// Set storage value of address at index.
8282
fn set_storage(&mut self, address: H160, index: H256, value: H256) -> Result<(), ExitError>;
8383
/// Set transient storage value of address at index, transient storage gets discarded after every transaction. (see EIP-1153)
84-
fn set_transient_storage(
85-
&mut self,
86-
address: H160,
87-
index: H256,
88-
value: H256,
89-
);
84+
fn set_transient_storage(&mut self, address: H160, index: H256, value: H256);
9085
/// Create a log owned by address with given topics and data.
9186
fn log(&mut self, address: H160, topics: Vec<H256>, data: Vec<u8>) -> Result<(), ExitError>;
9287
/// Mark an address to be deleted, with funds transferred to target.

runtime/src/lib.rs

+24
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,10 @@ pub struct Config {
286286
pub has_base_fee: bool,
287287
/// Has PUSH0 opcode. See [EIP-3855](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-3855.md)
288288
pub has_push0: bool,
289+
/// Has TLOAD and TSTORE opcode.
290+
pub has_tloadstore: bool,
291+
/// Has MCOPY opcode.
292+
pub has_mcopy: bool,
289293
/// Whether the gasometer is running in estimate mode.
290294
pub estimate: bool,
291295
/// Has EIP-6780. See [EIP-6780](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-6780.md)
@@ -343,6 +347,8 @@ impl Config {
343347
has_ext_code_hash: false,
344348
has_base_fee: false,
345349
has_push0: false,
350+
has_tloadstore: false,
351+
has_mcopy: false,
346352
estimate: false,
347353
has_eip_6780: false,
348354
}
@@ -398,6 +404,8 @@ impl Config {
398404
has_ext_code_hash: true,
399405
has_base_fee: false,
400406
has_push0: false,
407+
has_tloadstore: false,
408+
has_mcopy: false,
401409
estimate: false,
402410
has_eip_6780: false,
403411
}
@@ -440,6 +448,8 @@ impl Config {
440448
warm_coinbase_address,
441449
max_initcode_size,
442450
has_eip_6780,
451+
has_tloadstore,
452+
has_mcopy,
443453
} = inputs;
444454

445455
// See https://eips.ethereum.org/EIPS/eip-2929
@@ -504,6 +514,8 @@ impl Config {
504514
has_push0,
505515
estimate: false,
506516
has_eip_6780,
517+
has_tloadstore,
518+
has_mcopy,
507519
}
508520
}
509521
}
@@ -521,6 +533,8 @@ struct DerivedConfigInputs {
521533
warm_coinbase_address: bool,
522534
max_initcode_size: Option<usize>,
523535
has_eip_6780: bool,
536+
has_tloadstore: bool,
537+
has_mcopy: bool,
524538
}
525539

526540
impl DerivedConfigInputs {
@@ -536,6 +550,8 @@ impl DerivedConfigInputs {
536550
warm_coinbase_address: false,
537551
max_initcode_size: None,
538552
has_eip_6780: false,
553+
has_tloadstore: false,
554+
has_mcopy: false,
539555
}
540556
}
541557

@@ -551,6 +567,8 @@ impl DerivedConfigInputs {
551567
warm_coinbase_address: false,
552568
max_initcode_size: None,
553569
has_eip_6780: false,
570+
has_tloadstore: false,
571+
has_mcopy: false,
554572
}
555573
}
556574

@@ -566,6 +584,8 @@ impl DerivedConfigInputs {
566584
warm_coinbase_address: false,
567585
max_initcode_size: None,
568586
has_eip_6780: false,
587+
has_tloadstore: false,
588+
has_mcopy: false,
569589
}
570590
}
571591

@@ -582,6 +602,8 @@ impl DerivedConfigInputs {
582602
// 2 * 24576 as per EIP-3860
583603
max_initcode_size: Some(0xC000),
584604
has_eip_6780: false,
605+
has_tloadstore: false,
606+
has_mcopy: false,
585607
}
586608
}
587609

@@ -598,6 +620,8 @@ impl DerivedConfigInputs {
598620
// 2 * 24576 as per EIP-3860
599621
max_initcode_size: Some(0xC000),
600622
has_eip_6780: true,
623+
has_tloadstore: true,
624+
has_mcopy: true,
601625
}
602626
}
603627
}

rust-toolchain.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[toolchain]
2-
channel = "1.69.0"
2+
channel = "1.84.0"
33
profile = "minimal"
44
components = [ "rustfmt", "clippy" ]

src/backend/memory.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl<'vicinity> MemoryBackend<'vicinity> {
8888
}
8989
}
9090

91-
impl<'vicinity> Backend for MemoryBackend<'vicinity> {
91+
impl Backend for MemoryBackend<'_> {
9292
fn gas_price(&self) -> U256 {
9393
self.vicinity.gas_price
9494
}
@@ -172,7 +172,7 @@ impl<'vicinity> Backend for MemoryBackend<'vicinity> {
172172
}
173173
}
174174

175-
impl<'vicinity> ApplyBackend for MemoryBackend<'vicinity> {
175+
impl ApplyBackend for MemoryBackend<'_> {
176176
fn apply<A, I, L>(&mut self, values: A, logs: L, delete_empty: bool)
177177
where
178178
A: IntoIterator<Item = Apply<I>>,
@@ -189,7 +189,7 @@ impl<'vicinity> ApplyBackend for MemoryBackend<'vicinity> {
189189
reset_storage,
190190
} => {
191191
let is_empty = {
192-
let account = self.state.entry(address).or_insert_with(Default::default);
192+
let account = self.state.entry(address).or_default();
193193
account.balance = basic.balance;
194194
account.nonce = basic.nonce;
195195
if let Some(code) = code {

src/executor/stack/executor.rs

+6-11
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ impl<'config, 'precompiles, S: StackState<'config>, P: PrecompileSet>
672672
let mut stream = rlp::RlpStream::new_list(2);
673673
stream.append(&caller);
674674
stream.append(&nonce);
675-
H256::from_slice(Keccak256::digest(&stream.out()).as_slice()).into()
675+
H256::from_slice(Keccak256::digest(stream.out()).as_slice()).into()
676676
}
677677
CreateScheme::Fixed(naddress) => naddress,
678678
}
@@ -1087,8 +1087,8 @@ impl<'config, 'precompiles, S: StackState<'config>, P: PrecompileSet>
10871087
pub struct StackExecutorCallInterrupt<'borrow>(TaggedRuntime<'borrow>);
10881088
pub struct StackExecutorCreateInterrupt<'borrow>(TaggedRuntime<'borrow>);
10891089

1090-
impl<'config, 'precompiles, S: StackState<'config>, P: PrecompileSet> Handler
1091-
for StackExecutor<'config, 'precompiles, S, P>
1090+
impl<'config, S: StackState<'config>, P: PrecompileSet> Handler
1091+
for StackExecutor<'config, '_, S, P>
10921092
{
10931093
type CreateInterrupt = StackExecutorCreateInterrupt<'static>;
10941094
type CreateFeedback = Infallible;
@@ -1210,12 +1210,7 @@ impl<'config, 'precompiles, S: StackState<'config>, P: PrecompileSet> Handler
12101210
Ok(())
12111211
}
12121212

1213-
fn set_transient_storage(
1214-
&mut self,
1215-
address: H160,
1216-
index: H256,
1217-
value: H256,
1218-
) {
1213+
fn set_transient_storage(&mut self, address: H160, index: H256, value: H256) {
12191214
self.state.set_transient_storage(address, index, value);
12201215
}
12211216

@@ -1402,8 +1397,8 @@ struct StackExecutorHandle<'inner, 'config, 'precompiles, S, P> {
14021397
is_static: bool,
14031398
}
14041399

1405-
impl<'inner, 'config, 'precompiles, S: StackState<'config>, P: PrecompileSet> PrecompileHandle
1406-
for StackExecutorHandle<'inner, 'config, 'precompiles, S, P>
1400+
impl<'config, S: StackState<'config>, P: PrecompileSet> PrecompileHandle
1401+
for StackExecutorHandle<'_, 'config, '_, S, P>
14071402
{
14081403
// Perform subcall in provided context.
14091404
/// Precompile specifies in which context the subcall is executed.

src/executor/stack/memory.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ pub struct MemoryStackState<'backend, 'config, B> {
441441
substate: MemoryStackSubstate<'config>,
442442
}
443443

444-
impl<'backend, 'config, B: Backend> Backend for MemoryStackState<'backend, 'config, B> {
444+
impl<B: Backend> Backend for MemoryStackState<'_, '_, B> {
445445
fn gas_price(&self) -> U256 {
446446
self.backend.gas_price()
447447
}
@@ -515,7 +515,7 @@ impl<'backend, 'config, B: Backend> Backend for MemoryStackState<'backend, 'conf
515515
}
516516
}
517517

518-
impl<'backend, 'config, B: Backend> StackState<'config> for MemoryStackState<'backend, 'config, B> {
518+
impl<'config, B: Backend> StackState<'config> for MemoryStackState<'_, 'config, B> {
519519
fn metadata(&self) -> &StackSubstateMetadata<'config> {
520520
self.substate.metadata()
521521
}

src/maybe_borrowed.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub enum MaybeBorrowed<'a, T> {
1313
Owned(T),
1414
}
1515

16-
impl<'a, T> core::ops::Deref for MaybeBorrowed<'a, T> {
16+
impl<T> core::ops::Deref for MaybeBorrowed<'_, T> {
1717
type Target = T;
1818

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

27-
impl<'a, T> core::ops::DerefMut for MaybeBorrowed<'a, T> {
27+
impl<T> core::ops::DerefMut for MaybeBorrowed<'_, T> {
2828
fn deref_mut(&mut self) -> &mut Self::Target {
2929
match self {
3030
Self::Borrowed(x) => x,

0 commit comments

Comments
 (0)