You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am doing a debug_trace_call in order to debug an ETH call of a balanceOf on an ERC20.
The goal is to get a storage slot at the end (then I can use the storage slot to set an ERC20 token balance in anvil).
The issue that I encounter is that, there is no storage slot at all that gets accessed when I do debug_trace_call on a balanceOf call which shouldn't happen as this call must access storage at some point.
use std::env;use alloy_primitives::{address,Address,Bytes,B256};use alloy_provider::{ext::DebugApi,ProviderBuilder};use alloy_rpc_types::{
trace::geth::{GethDebugTracerConfig,GethDebugTracingCallOptions,GethDebugTracingOptions,GethDefaultTracingOptions,GethTrace,},BlockId,TransactionRequest,};use alloy_sol_types::{sol,SolCall};use dotenv::dotenv;use eyre::Result;// WETH token addressconstWETH:Address = address!("C02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2");// The address of titan builder (just a random address to get the balance from)constTITAN_BUILDER:Address = address!("4838B106FCe9647Bdf1E7877BF73cE8B0BAD5f97");sol!(
#[sol(rpc)]IErc20,
"src/erc20_abi.json");#[tokio::main]asyncfnmain() -> Result<()>{dotenv().ok();let provider = ProviderBuilder::new().on_http(
env::var("HTTP_RPC").expect("Missing HTTP_RPC environment variable").parse().expect("HTTP_RPC must be a valid HTTP RPC url"),);let debug_trace = provider
.debug_trace_call(TransactionRequest::default().to(WETH).input(Bytes::from(IErc20::balanceOfCall{_owner:TITAN_BUILDER,}.abi_encode(),).into(),),BlockId::latest(),GethDebugTracingCallOptions{tracing_options:GethDebugTracingOptions{config:GethDefaultTracingOptions{enable_memory:Some(true),disable_memory:None,disable_stack:Some(false),disable_storage:Some(false),enable_return_data:Some(true),disable_return_data:None,debug:Some(true),limit:Some(0),},tracer:None,tracer_config:GethDebugTracerConfig::default(),timeout:None,},state_overrides:None,block_overrides:None,},).await?;ifletGethTrace::Default(default_trace) = debug_trace {letmut ret:Option<B256> = None;for struct_log in default_trace.struct_logs{if !struct_log.storage.is_none(){let storage = struct_log.storage.unwrap();letmut keys = storage.keys();whileletSome(key) = keys.next(){
ret = Some(*key);}}}if ret.is_none(){panic!("balanceOfCall didn't gave us any right storage slot for token {WETH:?} and wallet {TITAN_BUILDER:?}");}else{println!("Storage slot is: {}", ret.unwrap());}}else{panic!("Trace should be default, got {debug_trace:#?}");}Ok(())}
Cargo.toml
[package]
name = "debug-trace-bug"version = "0.1.0"edition = "2021"
[dependencies]
tokio = { version = "1.39", features = ["full"] }
dotenv = "0.15"eyre = "0.6"alloy-primitives = { version = "0.8" }
alloy-sol-types = { version = "0.8", features = ["json"] }
alloy-contract = "0.3"alloy-provider = { version = "0.3", features = [
"debug-api",
] }
alloy-rpc-types = { version = "0.3", features = ["trace"] }
Minimal example output
Here is the actual output:
thread 'main' panicked at src/main.rs:84:13:
balanceOfCall didn't gave us any right storage slot for token 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 and wallet 0x4838b106fce9647bdf1e7877bf73ce8b0bad5f97
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
It didn't gave me any storage.
I have also tried to print all operators and got these:
Which at no point show an SLOAD operation. Which is very weird since balanceOf should always access storage at least once.
Additional details
I also would like to point out that this code is actually few month old, and few month ago, it was working fine and giving me the storage slot, today I tried to run my test again and they are no longer passing.
Component
provider, pubsub, rpc
What version of Alloy are you on?
alloy: v0.3.6 | alloy-core: v0.8.3
Operating System
Linux
Describe the bug
The issue
I am doing a debug_trace_call in order to debug an ETH call of a balanceOf on an ERC20.
The goal is to get a storage slot at the end (then I can use the storage slot to set an ERC20 token balance in anvil).
The issue that I encounter is that, there is no storage slot at all that gets accessed when I do
debug_trace_call
on a balanceOf call which shouldn't happen as this call must access storage at some point.Minimal example to reproduce
Here is a minimal repo reproducing this bug.
Additionally here is the code:
main.rs
Cargo.toml
Minimal example output
Here is the actual output:
It didn't gave me any storage.
I have also tried to print all operators and got these:
Operators
Which at no point show an
SLOAD
operation. Which is very weird sincebalanceOf
should always access storage at least once.Additional details
I also would like to point out that this code is actually few month old, and few month ago, it was working fine and giving me the storage slot, today I tried to run my test again and they are no longer passing.
Node version (HTTP_RPC):
Lighthouse version:
The text was updated successfully, but these errors were encountered: