Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
19 changes: 8 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ jobs:
- uses: Swatinem/rust-cache@v2
- run: cargo test --workspace ${{ matrix.flags }}

test-no-std:
name: test no_std
check-no-std:
name: check no_std
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
Expand All @@ -48,29 +48,26 @@ jobs:
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- run: |
cd crates/revm
cargo check --no-default-features
- uses: dtolnay/rust-toolchain@stable
- run: cargo check --no-default-features -p revm

check-serde:
name: check serde
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- run: |
cd crates/revm
cargo check --no-default-features --features serde
- uses: dtolnay/rust-toolchain@stable
- run: cargo check --no-default-features --features serde -p revm

check-std:
name: check std
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- run: |
cd crates/revm
cargo check --no-default-features --features std
- uses: dtolnay/rust-toolchain@stable
- run: cargo check --no-default-features --features std -p revm

clippy:
name: clippy
Expand Down
4 changes: 2 additions & 2 deletions crates/interpreter/src/instructions/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ pub fn extcall<H: Host + ?Sized, SPEC: Spec>(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 {
Expand Down Expand Up @@ -264,7 +264,7 @@ pub fn extstaticcall<H: Host + ?Sized>(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 {
Expand Down
6 changes: 4 additions & 2 deletions crates/interpreter/src/instructions/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 !<SPEC as $crate::primitives::Spec>::enabled($crate::primitives::SpecId::$min) {
if const {
!<SPEC as $crate::primitives::Spec>::SPEC_ID
.is_enabled_in($crate::primitives::SpecId::$min)
} {
$interp.instruction_result = $crate::InstructionResult::NotActivated;
return;
}
Expand Down
12 changes: 6 additions & 6 deletions crates/interpreter/src/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,13 +467,13 @@ mod tests {
let mut interp = Interpreter::new(Contract::default(), u64::MAX, false);

let mut host = crate::DummyHost::default();
let table: InstructionTable<DummyHost> =
crate::opcode::make_instruction_table::<DummyHost, CancunSpec>();
let _ = interp.run(EMPTY_SHARED_MEMORY, &table, &mut host);
let table: &InstructionTable<DummyHost> =
&crate::opcode::make_instruction_table::<DummyHost, CancunSpec>();
let _ = interp.run(EMPTY_SHARED_MEMORY, table, &mut host);

let host: &mut dyn Host = &mut host as &mut dyn Host;
let table: InstructionTable<dyn Host> =
crate::opcode::make_instruction_table::<dyn Host, CancunSpec>();
let _ = interp.run(EMPTY_SHARED_MEMORY, &table, host);
let table: &InstructionTable<dyn Host> =
&crate::opcode::make_instruction_table::<dyn Host, CancunSpec>();
let _ = interp.run(EMPTY_SHARED_MEMORY, table, host);
}
}
25 changes: 8 additions & 17 deletions crates/interpreter/src/opcode/tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,24 +133,15 @@ impl<'a, H: Host + ?Sized + 'a> InstructionTables<'a, H> {
/// Make instruction table.
#[inline]
pub const fn make_instruction_table<H: Host + ?Sized, SPEC: Spec>() -> InstructionTable<H> {
// Force const-eval of the table creation, making this function trivial.
// TODO: Replace this with a `const {}` block once it is stable.
struct ConstTable<H: Host + ?Sized, SPEC: Spec> {
_host: core::marker::PhantomData<H>,
_spec: core::marker::PhantomData<SPEC>,
}
impl<H: Host + ?Sized, SPEC: Spec> ConstTable<H, SPEC> {
const NEW: InstructionTable<H> = {
let mut tables: InstructionTable<H> = [control::unknown; 256];
let mut i = 0;
while i < 256 {
tables[i] = instruction::<H, SPEC>(i as u8);
i += 1;
}
tables
};
const {
let mut tables: InstructionTable<H> = [control::unknown; 256];
let mut i = 0;
while i < 256 {
tables[i] = instruction::<H, SPEC>(i as u8);
i += 1;
}
tables
}
ConstTable::<H, SPEC>::NEW
}

/// Make boxed instruction table that calls `f` closure for every instruction.
Expand Down
6 changes: 3 additions & 3 deletions crates/revm/src/db/states/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Address, CacheAccount>,
/// 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<B256, Bytecode>,
/// Has EIP-161 state clear enabled (Spurious Dragon hardfork).
pub has_state_clear: bool,
Expand Down
1 change: 0 additions & 1 deletion crates/revm/src/handler/mainnet/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down