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

Fix #253: upgrade revm #257

Closed
wants to merge 5 commits into from
Closed
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ work_dir
combined.json
/**/build/
Move.lock
/w_**/
11 changes: 7 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,23 +76,26 @@ regex = "1"
typetag = "0.2.13"
lazy_static = "1.4.0"

revm = { git = "https://github.com/fuzzland/revm", rev = "60d409c17d9fff11d1063b985f05be3e3280fe80", features = [
revm = { git = "https://github.com/fuzzland/revm", branch = "v26-tuned-for-ityfuzz", package = "revm", features = [
"no_gas_measuring",
"serde",
"memory_limit",
] }
revm-primitives = { git = "https://github.com/fuzzland/revm", rev = "60d409c17d9fff11d1063b985f05be3e3280fe80", features = [
revm-primitives = { git = "https://github.com/fuzzland/revm", branch = "v26-tuned-for-ityfuzz", package = "revm-primitives", features = [
"no_gas_measuring",
"serde",
"memory_limit",
] }
revm-interpreter = { git = "https://github.com/fuzzland/revm", rev = "60d409c17d9fff11d1063b985f05be3e3280fe80", features = [
revm-interpreter = { git = "https://github.com/fuzzland/revm", branch = "v26-tuned-for-ityfuzz", package = "revm-interpreter", features = [
"no_gas_measuring",
"serde",
"memory_limit",
] }
# Primitive types shared by revm and foundry
alloy-primitives = { version = "0.4", features = ["default", "rand"] }

# external fuzzing-based abi decompiler
heimdall_core = { git = "https://github.com/fuzzland/heimdall-rs.git", package = "heimdall-core"}
heimdall_core = { git = "https://github.com/fuzzland/heimdall-rs.git", rev = "3d95f04146bbef2e0e88e6949a06519c938b47d7", package = "heimdall-core"}
# heimdall_core relies on an async runtime
tokio = {version = "1.0", features = ["full"]}

Expand Down
2 changes: 1 addition & 1 deletion integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def read_onchain_tests():
with open("onchain_tests.txt", "r") as file:
tests = file.read()

tests = tests.split("\n")
tests = tests.strip().split("\n")
tests = [test.split("\t") for test in tests]
return tests

Expand Down
4 changes: 2 additions & 2 deletions src/evm/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ where
dont_mutate: false,
})),
1 => BoxedABI::new(Box::new(A256 {
data: state.get_rand_address().0.into(),
data: state.get_rand_address().to_vec(),
is_address: true,
dont_mutate: false,
})),
Expand Down Expand Up @@ -1376,7 +1376,7 @@ mod tests {
fn test_null() {
let mut abi = get_abi_type_boxed(&String::from("(int256,int256,int256,uint256,address)[]"));
let mut test_state = FuzzState::new(0);
test_state.addresses_pool.push(EVMAddress::zero());
test_state.addresses_pool.push(EVMAddress::ZERO);
let mutation_result = abi
.mutate::<EVMAddress, EVMAddress, EVMState, EVMFuzzState, ConciseEVMInput>(
&mut test_state,
Expand Down
7 changes: 4 additions & 3 deletions src/evm/blaz/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::str::FromStr;
use std::thread::sleep;
use std::time::Duration;
use std::collections::hash_map::DefaultHasher;
use bytes::Bytes;
use revm_primitives::Bytes;
use itertools::Itertools;
use libafl_bolts::impl_serdeany;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -272,8 +272,9 @@ impl BuildJobResult {
.code
.get(addr)
.unwrap()
.clone()
.bytecode());
.0
.bytes()
.as_ref());
return _self.get_sourcemap(bytecode).get(&pc).cloned();
}

Expand Down
5 changes: 2 additions & 3 deletions src/evm/blaz/mod.rs

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions src/evm/blaz/offchain_artifacts.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::error::Error;
use bytes::Bytes;
use itertools::Itertools;
use revm_primitives::HashMap;
use revm_primitives::{HashMap, Bytes};
use serde_json::Value;
use crate::evm::blaz::{get_client, is_bytecode_similar_lax, is_bytecode_similar_strict_ranking};
use crate::evm::blaz::builder::BuildJobResult;
Expand Down Expand Up @@ -175,4 +174,4 @@ mod tests {
// let artifact = OffChainArtifact::from_json_url(url.to_string()).expect("get artifact failed");
// println!("{:?}", artifact);
// }
}
}
3 changes: 1 addition & 2 deletions src/evm/bytecode_analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ where
#[cfg(test)]
mod tests {
use super::*;
use bytes::Bytes;
use revm_primitives::Bytecode;
use revm_primitives::{Bytecode, Bytes};

#[test]
fn test_find_constants() {
Expand Down
5 changes: 2 additions & 3 deletions src/evm/concolic/concolic_host.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use bytes::Bytes;
use libafl::schedulers::Scheduler;

use crate::evm::abi::BoxedABI;
Expand All @@ -18,7 +17,7 @@ use libafl::prelude::{Corpus, HasMetadata, Input};
use libafl::state::{HasCorpus, State};

use revm_interpreter::{Interpreter, Host};
use revm_primitives::{Bytecode};
use revm_primitives::{Bytecode, Bytes};
use std::collections::{HashMap, HashSet};

use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -823,7 +822,7 @@ where
println!("[concolic] stack: {:?}", interp.stack);
println!("[concolic] symbolic_stack: {:?}", self.symbolic_stack);
for idx in 0..interp.stack.len() {
let real = interp.stack.data[idx].clone();
let real = interp.stack.data()[idx].clone();
let sym = self.symbolic_stack[idx].clone();
if sym.is_some() {
match sym.unwrap().op {
Expand Down
4 changes: 1 addition & 3 deletions src/evm/contract_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ use crate::evm::types::{
use core::panic;
/// Load contract from file system or remote
use glob::glob;
use revm::precompile::B160;
use serde_json::Value;
use std::collections::{HashMap, HashSet};
use std::fs::File;

use crate::state::FuzzState;
use bytes::Bytes;
use itertools::Itertools;
use std::io::Read;
use std::path::Path;
Expand All @@ -36,7 +34,7 @@ use hex::encode;
use regex::Regex;
use revm_interpreter::analysis::to_analysed;
use revm_interpreter::opcode::PUSH4;
use revm_primitives::Bytecode;
use revm_primitives::{Bytecode, Bytes};
use serde::{Deserialize, Serialize};

use super::types::ProjectSourceMapTy;
Expand Down
9 changes: 4 additions & 5 deletions src/evm/corpus_initializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use crate::generic_vm::vm_executor::GenericVM;

use crate::state::HasCaller;
use crate::state_input::StagedVMState;
use bytes::Bytes;
use libafl::corpus::{Corpus, Testcase};

use crate::dump_txn;
Expand All @@ -37,7 +36,7 @@ use libafl::prelude::HasMetadata;
use libafl::schedulers::Scheduler;
use libafl::state::HasCorpus;
use libafl_bolts::impl_serdeany;
use revm_primitives::Bytecode;
use revm_primitives::{Bytecode, Bytes};
use serde::{Deserialize, Serialize};
use std::cell::RefCell;
use std::collections::{HashMap, HashSet};
Expand Down Expand Up @@ -280,14 +279,14 @@ where
.address_to_abi
.insert(contract.deployed_address, contract.abi.clone());
let mut code = vec![];
if let Some(c) = self
if let Some((c, _)) = self
.executor
.host
.code
.clone()
.get(&contract.deployed_address)
.clone()
{
code.extend_from_slice(c.bytecode());
code.extend_from_slice(&c.bytes());
}
artifacts.address_to_bytecode.insert(
contract.deployed_address,
Expand Down
Loading