Skip to content

Commit

Permalink
feat: fix remaining bugs, pass all state tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes committed Jul 18, 2024
1 parent c0502eb commit e4c1493
Show file tree
Hide file tree
Showing 13 changed files with 212 additions and 135 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/revmc-builtins/src/ir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ builtins! {
ReturnContract = __revmc_builtin_return_contract(@[ecx] ptr, @[sp] ptr, usize) Some(u8),
Create = __revmc_builtin_create(@[ecx] ptr, @[sp_dyn] ptr, u8, u8) Some(u8),
Call = __revmc_builtin_call(@[ecx] ptr, @[sp_dyn] ptr, u8, u8) Some(u8),
ExtCall = __revmc_builtin_ext_call(@[ecx] ptr, @[sp_dyn] ptr, u8) Some(u8),
ExtCall = __revmc_builtin_ext_call(@[ecx] ptr, @[sp_dyn] ptr, u8, u8) Some(u8),
DoReturn = __revmc_builtin_do_return(@[ecx] ptr, @[sp] ptr, u8) Some(u8),
SelfDestruct = __revmc_builtin_selfdestruct(@[ecx] ptr, @[sp] ptr, u8) Some(u8),

Expand Down
10 changes: 7 additions & 3 deletions crates/revmc-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use clap::{Parser, ValueEnum};
use color_eyre::{eyre::eyre, Result};
use revm_interpreter::{opcode::make_instruction_table, SharedMemory};
use revm_primitives::{address, spec_to_generic, Env, SpecId};
use revm_primitives::{address, spec_to_generic, Env, SpecId, TransactTo};
use revmc::{eyre::ensure, EvmCompiler, EvmContext, EvmLlvmBackend, OptimizationLevel};
use revmc_cli::{get_benches, read_code, Bench};
use std::{
Expand Down Expand Up @@ -63,6 +63,9 @@ struct Cli {
opt_level: OptimizationLevel,
#[arg(long, value_enum, default_value = "cancun")]
spec_id: SpecIdValueEnum,
/// Short-hand for `--spec-id pragueeof`.
#[arg(long, conflicts_with = "spec_id")]
eof: bool,
#[arg(long)]
debug_assertions: bool,
#[arg(long)]
Expand Down Expand Up @@ -135,7 +138,8 @@ fn main() -> Result<()> {
let gas_limit = cli.gas_limit;

let mut env = Env::default();
env.tx.caller = address!("1000000000000000000000000000000000000001");
env.tx.caller = address!("0000000000000000000000000000000000000001");
env.tx.transact_to = TransactTo::Call(address!("0000000000000000000000000000000000000002"));
env.tx.data = calldata;
env.tx.gas_limit = gas_limit;

Expand All @@ -147,7 +151,7 @@ fn main() -> Result<()> {

let bytecode = contract.bytecode.original_byte_slice();

let spec_id = cli.spec_id.into();
let spec_id = if cli.eof { SpecId::PRAGUE_EOF } else { cli.spec_id.into() };
if !stack_input.is_empty() {
compiler.inspect_stack_length(true);
}
Expand Down
2 changes: 1 addition & 1 deletion crates/revmc-context/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ pub type RawEvmCompilerFn = unsafe extern "C" fn(
) -> InstructionResult;

/// An EVM bytecode function.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct EvmCompilerFn(RawEvmCompilerFn);

impl From<RawEvmCompilerFn> for EvmCompilerFn {
Expand Down
2 changes: 1 addition & 1 deletion crates/revmc-llvm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,10 +366,10 @@ impl<'ctx> Backend for EvmLlvmBackend<'ctx> {
}

unsafe fn free_all_functions(&mut self) -> Result<()> {
self.clear_module();
if let Some(exec_engine) = &self.exec_engine {
exec_engine.remove_module(&self.module).map_err(|e| Error::msg(e.to_string()))?;
}
self.clear_module();
self.module = create_module(self.cx, &self.machine)?;
if self.exec_engine.is_some() {
self.exec_engine =
Expand Down
1 change: 1 addition & 0 deletions crates/revmc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ revm-primitives.workspace = true

bitflags = "2.5"
bitvec = "1.0"
either = "1.13"
rustc-hash.workspace = true
tracing.workspace = true

Expand Down
Loading

0 comments on commit e4c1493

Please sign in to comment.