Skip to content

Commit

Permalink
Fix 439 forge test error (#443)
Browse files Browse the repository at this point in the history
* update foundry, ethers, rust, libafl

* add assert vm_calls

* fix: revm panic when stack.pop
  • Loading branch information
jacob-chia authored Mar 29, 2024
1 parent 4fcd183 commit de09cc9
Show file tree
Hide file tree
Showing 15 changed files with 1,886 additions and 96 deletions.
28 changes: 14 additions & 14 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ default = [
"print_txn_corpus",
"full_trace",
"force_cache",
"real_balance"
"real_balance",
]
evm = []
cmp = []
Expand Down Expand Up @@ -55,12 +55,12 @@ serde_cbor = "0.11.2"
clap = { version = "4.4.4", features = ["derive"] }
sentry = "0.32.1"
rlp = "0.5.2"
ethers = "2.0.7"
ethers = "2.0.14"

hex = "0.4"
primitive-types = { version = "0.12.1", features = ["rlp", "serde"] }
libafl = "=0.11.1"
libafl_bolts = "=0.11.1"
libafl = "=0.11.2"
libafl_bolts = "=0.11.2"
rand = "0.8.5"
nix = "0.27.1"
serde = "1.0.147"
Expand All @@ -80,17 +80,17 @@ typetag = "0.2.13"
lazy_static = "1.4.0"
num_cpus = "1.0"

revm = { git = "https://github.com/fuzzland/revm", rev = "572aae6b352d3b0b3000d9aa42154498233514e8", features = [
revm = { git = "https://github.com/fuzzland/revm", rev = "33b46b9", features = [
"no_gas_measuring",
"serde",
"memory_limit",
] }
revm-primitives = { git = "https://github.com/fuzzland/revm", rev = "572aae6b352d3b0b3000d9aa42154498233514e8", features = [
revm-primitives = { git = "https://github.com/fuzzland/revm", rev = "33b46b9", features = [
"no_gas_measuring",
"serde",
"memory_limit",
] }
revm-interpreter = { git = "https://github.com/fuzzland/revm", rev = "572aae6b352d3b0b3000d9aa42154498233514e8", features = [
revm-interpreter = { git = "https://github.com/fuzzland/revm", rev = "33b46b9", features = [
"no_gas_measuring",
"serde",
"memory_limit",
Expand Down Expand Up @@ -118,16 +118,16 @@ sui-types = { git = "https://github.com/fuzzland/ityfuzz-sui-fork.git", optional
handlebars = "4.4"

# for cheatcode middleware
foundry-cheatcodes = { git = "https://github.com/foundry-rs/foundry.git", rev = "dee41819c6e6bd1ea5419c613d226498ed7a2c59" }
foundry-abi = { git = "https://github.com/foundry-rs/foundry.git", rev = "dee41819c6e6bd1ea5419c613d226498ed7a2c59" }
alloy-sol-types = "0.4"
alloy-dyn-abi = { version = "0.4", features = ["arbitrary", "eip712"] }
alloy-primitives = "0.4"
alloy-json-abi = "0.4"
foundry-cheatcodes = { git = "https://github.com/foundry-rs/foundry.git", rev = "617dfc28" }
alloy-sol-types = "0.6"
alloy-dyn-abi = { version = "0.6", features = ["arbitrary", "eip712"] }
alloy-primitives = "0.6"
alloy-json-abi = "0.6"
# error handling
anyhow = "1.0"
thiserror = "1.0"
# logging
tracing = "0.1"
tracing-subscriber = "0.3"
colored = "2.0"
evmole = "0.3.2"
evmole = "0.3.2"
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[toolchain]
channel = "nightly-2023-11-01"
channel = "nightly-2024-01-01"
6 changes: 3 additions & 3 deletions src/evm/concolic/concolic_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use libafl::{
executors::ExitKind,
feedbacks::Feedback,
inputs::Input,
prelude::{CorpusId, HasClientPerfMonitor, HasMetadata, ObserversTuple, Stage, UsesInput},
state::{HasCorpus, UsesState},
prelude::{CorpusId, HasMetadata, ObserversTuple, Stage, UsesInput},
state::{HasCorpus, State, UsesState},
Error,
Evaluator,
};
Expand Down Expand Up @@ -224,7 +224,7 @@ impl<I, S, F> Feedback<S> for ConcolicFeedbackWrapper<F>
where
I: Input,
F: Feedback<S> + Named + Debug,
S: HasClientPerfMonitor + HasMetadata + HasCorpus + UsesInput<Input = I>,
S: State + HasMetadata + HasCorpus + UsesInput<Input = I>,
{
fn is_interesting<EM, OT>(
&mut self,
Expand Down
18 changes: 18 additions & 0 deletions src/evm/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ where
pub expected_emits: VecDeque<ExpectedEmit>,
/// Expected calls
pub expected_calls: ExpectedCallTracker,
/// Assert failed message for the cheatcode
pub assert_msg: Option<String>,
}

impl<SC> Debug for FuzzHost<SC>
Expand Down Expand Up @@ -306,6 +308,7 @@ where
expected_emits: self.expected_emits.clone(),
expected_revert: self.expected_revert.clone(),
expected_calls: self.expected_calls.clone(),
assert_msg: self.assert_msg.clone(),
}
}
}
Expand Down Expand Up @@ -366,6 +369,7 @@ where
expected_revert: None,
expected_emits: VecDeque::new(),
expected_calls: ExpectedCallTracker::new(),
assert_msg: None,
}
}

Expand Down Expand Up @@ -815,6 +819,12 @@ where
call: &CallInputs,
res: (InstructionResult, Gas, Bytes),
) -> (InstructionResult, Gas, Bytes) {
// Check assert result
let res = self.check_assert_result(res);
if res.0 == Revert {
return res;
}

// Check expected reverts
let res = self.check_expected_revert(res);
if res.0 == Revert {
Expand All @@ -829,6 +839,14 @@ where
self.check_expected_calls(res)
}

fn check_assert_result(&mut self, res: (InstructionResult, Gas, Bytes)) -> (InstructionResult, Gas, Bytes) {
if let Some(ref msg) = self.assert_msg {
return (InstructionResult::Revert, res.1, msg.abi_encode().into());
}

res
}

/// Check expected reverts
fn check_expected_revert(&mut self, res: (InstructionResult, Gas, Bytes)) -> (InstructionResult, Gas, Bytes) {
// Check if we should check for reverts
Expand Down
Loading

0 comments on commit de09cc9

Please sign in to comment.