diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9aaad96a24..5b51370b02 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,8 +31,8 @@ jobs: - uses: Swatinem/rust-cache@v2 - run: cargo test --workspace ${{ matrix.flags }} - test-no-std: - name: test no_std ${{ matrix.features }} + check-no-std: + name: check no_std ${{ matrix.features }} runs-on: ubuntu-latest timeout-minutes: 30 strategy: @@ -56,9 +56,8 @@ jobs: features: ["", "serde", "std"] steps: - uses: actions/checkout@v4 - - run: | - cd crates/revm - cargo check --no-default-features --features=${{ matrix.features }} + - uses: dtolnay/rust-toolchain@stable + - run: cargo check --no-default-features -p revm --features=${{ matrix.features }} clippy: name: clippy diff --git a/crates/interpreter/src/instructions/contract.rs b/crates/interpreter/src/instructions/contract.rs index ea58ad4062..7266e28c4e 100644 --- a/crates/interpreter/src/instructions/contract.rs +++ b/crates/interpreter/src/instructions/contract.rs @@ -199,7 +199,7 @@ pub fn extcall(interpreter: &mut Interpreter, host require_eof!(interpreter); pop_address!(interpreter, target_address); - // TODO check if target is left paddded with zeroes. + // TODO check if target is left padded with zeroes. // input call let Some(input) = extcall_input(interpreter) else { @@ -271,7 +271,7 @@ pub fn extstaticcall(interpreter: &mut Interpreter, host: &mut require_eof!(interpreter); pop_address!(interpreter, target_address); - // TODO check if target is left paddded with zeroes. + // TODO check if target is left padded with zeroes. // input call let Some(input) = extcall_input(interpreter) else { diff --git a/crates/interpreter/src/instructions/macros.rs b/crates/interpreter/src/instructions/macros.rs index 6938eeada4..4df6f62d1a 100644 --- a/crates/interpreter/src/instructions/macros.rs +++ b/crates/interpreter/src/instructions/macros.rs @@ -37,8 +37,10 @@ macro_rules! require_init_eof { #[macro_export] macro_rules! check { ($interp:expr, $min:ident) => { - // TODO: Force const-eval on the condition with a `const {}` block once they are stable - if !::enabled($crate::primitives::SpecId::$min) { + if const { + !::SPEC_ID + .is_enabled_in($crate::primitives::SpecId::$min) + } { $interp.instruction_result = $crate::InstructionResult::NotActivated; return; } diff --git a/crates/interpreter/src/interpreter.rs b/crates/interpreter/src/interpreter.rs index 4fa5816505..07ab0439d9 100644 --- a/crates/interpreter/src/interpreter.rs +++ b/crates/interpreter/src/interpreter.rs @@ -469,13 +469,13 @@ mod tests { let mut interp = Interpreter::new(Contract::default(), u64::MAX, false); let mut host = crate::DummyHost::default(); - let table: InstructionTable = - crate::opcode::make_instruction_table::(); - let _ = interp.run(EMPTY_SHARED_MEMORY, &table, &mut host); + let table: &InstructionTable = + &crate::opcode::make_instruction_table::(); + let _ = interp.run(EMPTY_SHARED_MEMORY, table, &mut host); let host: &mut dyn Host = &mut host as &mut dyn Host; - let table: InstructionTable = - crate::opcode::make_instruction_table::(); - let _ = interp.run(EMPTY_SHARED_MEMORY, &table, host); + let table: &InstructionTable = + &crate::opcode::make_instruction_table::(); + let _ = interp.run(EMPTY_SHARED_MEMORY, table, host); } } diff --git a/crates/interpreter/src/opcode/tables.rs b/crates/interpreter/src/opcode/tables.rs index 48a1b6cca8..a2a66bc218 100644 --- a/crates/interpreter/src/opcode/tables.rs +++ b/crates/interpreter/src/opcode/tables.rs @@ -133,24 +133,15 @@ impl<'a, H: Host + ?Sized + 'a> InstructionTables<'a, H> { /// Make instruction table. #[inline] pub const fn make_instruction_table() -> InstructionTable { - // Force const-eval of the table creation, making this function trivial. - // TODO: Replace this with a `const {}` block once it is stable. - struct ConstTable { - _host: core::marker::PhantomData, - _spec: core::marker::PhantomData, - } - impl ConstTable { - const NEW: InstructionTable = { - let mut tables: InstructionTable = [control::unknown; 256]; - let mut i = 0; - while i < 256 { - tables[i] = instruction::(i as u8); - i += 1; - } - tables - }; + const { + let mut tables: InstructionTable = [control::unknown; 256]; + let mut i = 0; + while i < 256 { + tables[i] = instruction::(i as u8); + i += 1; + } + tables } - ConstTable::::NEW } /// Make boxed instruction table that calls `f` closure for every instruction. diff --git a/crates/revm/src/db/states/cache.rs b/crates/revm/src/db/states/cache.rs index 63c0160bab..5dd6770d49 100644 --- a/crates/revm/src/db/states/cache.rs +++ b/crates/revm/src/db/states/cache.rs @@ -14,10 +14,10 @@ use std::vec::Vec; /// It generates transitions that is used to build BundleState. #[derive(Clone, Debug, PartialEq, Eq)] pub struct CacheState { - /// Block state account with account state + /// Block state account with account state. pub accounts: HashMap, - /// created contracts - /// TODO add bytecode counter for number of bytecodes added/removed. + /// Created contracts. + // TODO add bytecode counter for number of bytecodes added/removed. pub contracts: HashMap, /// Has EIP-161 state clear enabled (Spurious Dragon hardfork). pub has_state_clear: bool, diff --git a/crates/revm/src/handler/mainnet/execution.rs b/crates/revm/src/handler/mainnet/execution.rs index 928d173508..89094d771e 100644 --- a/crates/revm/src/handler/mainnet/execution.rs +++ b/crates/revm/src/handler/mainnet/execution.rs @@ -231,7 +231,6 @@ mod tests { assert_eq!(gas.refunded(), 0); } - // TODO #[test] fn test_consume_gas_with_refund() { let mut return_gas = Gas::new(90);