Skip to content

Commit

Permalink
use fixed latest blocknumber when undefined (#245)
Browse files Browse the repository at this point in the history
* use fixed latest blocknumber when undefined

* fix test

* fix test
  • Loading branch information
0xAWM authored Oct 10, 2023
1 parent 8f65555 commit 599c3d9
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 128 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,6 @@ ItyFuzz attempts to fetch storage from blockchain nodes when SLOAD is encountere
There are three ways of fetching:

- OneByOne: fetch one slot at a time. This is the default mode. It is slow but never fails.
- All: fetch all slots at once using custom API `eth_getStorageAll` on our nodes. This is the fastest mode, but it may fail if the contract is too large.
- Dump: dump storage using debug API `debug_storageRangeAt`. This only works for ETH (for now) and fails most of the time.


Expand Down
1 change: 0 additions & 1 deletion README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ ItyFuzz 将从 Etherscan 拉取合约的 ABI 并 fuzz 它。如果 ItyFuzz 遇
当遇到 SLOAD 与目标未初始化的时,ItyFuzz 尝试从区块链节点获取存储。有三种获取方式:

- OneByOne:一次获取一个 slot 。这是默认模式。它很慢,但不会失败。
- All:使用我们节点上的自定义 API `eth_getStorageAll` 一次性获取所有 slot 。这是最快的模式,但如果合约太大,可能会失败。
- Dump:使用 debug API `debug_storageRangeAt` 来转储存储。这只适用于 ETH(目前),并且很容易失败。

### 构造函数参数
Expand Down
20 changes: 10 additions & 10 deletions src/evm/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
use crate::evm::contract_utils::{ContractInfo, ContractLoader};
use crate::evm::onchain::endpoints::{OnChainConfig, PriceOracle};

use crate::evm::blaz::builder::BuildJob;
use crate::evm::blaz::offchain_artifacts::OffChainArtifact;
use crate::evm::blaz::offchain_config::OffchainConfig;
use crate::evm::oracles::erc20::IERC20OracleFlashloan;
use crate::evm::types::EVMAddress;
use crate::oracle::{Oracle, Producer};
use std::cell::RefCell;
use std::collections::HashSet;
use std::fmt::{self, Debug};
use std::fs::File;
use std::rc::Rc;
use std::fmt::{self, Debug};
use crate::evm::blaz::builder::BuildJob;
use crate::evm::blaz::offchain_artifacts::OffChainArtifact;
use crate::evm::blaz::offchain_config::OffchainConfig;
use crate::evm::types::EVMAddress;

pub enum FuzzerTypes {
CMP,
Expand All @@ -23,15 +23,13 @@ pub enum FuzzerTypes {
#[derive(Copy, Clone)]
pub enum StorageFetchingMode {
Dump,
All,
OneByOne,
}

impl StorageFetchingMode {
pub fn from_str(s: &str) -> Option<Self> {
match s {
"dump" => Some(StorageFetchingMode::Dump),
"all" => Some(StorageFetchingMode::All),
"onebyone" => Some(StorageFetchingMode::OneByOne),
_ => None,
}
Expand Down Expand Up @@ -82,10 +80,12 @@ pub struct Config<VS, Addr, Code, By, Loc, SlotTy, Out, I, S, CI> {
pub local_files_basedir_pattern: Option<String>,
}

impl<VS, Addr, Code, By, Loc, SlotTy, Out, I, S, CI> Debug for Config<VS, Addr, Code, By, Loc, SlotTy, Out, I, S, CI> {
impl<VS, Addr, Code, By, Loc, SlotTy, Out, I, S, CI> Debug
for Config<VS, Addr, Code, By, Loc, SlotTy, Out, I, S, CI>
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Config")
.field("onchain", &self.onchain)
.field("onchain", &self.onchain)
// .field("onchain_storage_fetching", &self.onchain_storage_fetching)
.field("flashloan", &self.flashloan)
.field("concolic", &self.concolic)
Expand All @@ -112,6 +112,6 @@ impl<VS, Addr, Code, By, Loc, SlotTy, Out, I, S, CI> Debug for Config<VS, Addr,
.field("typed_bug", &self.typed_bug)
.field("selfdestruct_bug", &self.selfdestruct_bug)
// .field("builder", &self.builder)
.finish()
.finish()
}
}
Loading

0 comments on commit 599c3d9

Please sign in to comment.