Comments (9)
I think I found partially the issue: Vyper adds the following signature to the init code which I use in the ffi command:
sig = b"\xa1\x65vyper\x83".hex()
See my comment here: vyperlang/vyper#2860 (comment). And \xa1
and \x83
are common decoding errors I see in that context. There might be some further method Ids that might not be decoded properly as well.
from echidna.
Sounds like a plan!
from echidna.
Hey, this looks very cool. Do you know if the bug is related to hevm code or echidna?
from echidna.
Hey, this looks very cool. Do you know if the bug is related to hevm code or echidna?
I'm really not sure tbh - didn't have time to investigate properly.
from echidna.
and btw the decode error is also in the CI https://github.com/pcaversaccio/snekmate/actions/runs/8803366873/job/24161302034#step:19:21
from echidna.
On an initial triage, it seems this happens due to Echidna calling VyperDeployer.deploy(....)
with non-utf8-valid strings. The config has allContracts: true
. valsArr
in hevm ends up having invalid utf8 which then fails to decode.
https://github.com/ethereum/hevm/blob/release/0.53.0/src/EVM.hs#L1564
Filtering the affected functions so echidna does not try to fuzz them seems to work around the issue:
filterFunctions: ["VyperDeployer.deployContract(string,string)", "VyperDeployer.deployContract(string,string,bytes)", "VyperDeployer.deployContract(string,string,bytes,string,bool)", "VyperDeployer.deployContract(string,string,string,bool)"]
This is a smaller repro of this issue:
interface Hevm {
function ffi(string[] calldata) external returns (bytes memory);
}
contract TestFFI {
address constant HEVM_ADDRESS = 0x7109709ECfa91a80626fF3989D68f67F5b1DD12D;
function foo() public {
bytes memory w = hex"c328"; // invalid utf-8
string[] memory inputs = new string[](2);
inputs[0] = "echo";
inputs[1] = string(w);
bytes memory res = Hevm(HEVM_ADDRESS).ffi(inputs);
}
}
$ echo allowFFI: true > config.yml
$ echidna foo.sol --test-mode assertion --format text --contract TestFFI --config config.yml
[2024-04-23 18:04:34.90] Compiling foo.sol... Done! (0.775142s)
Analyzing contract: .../foo.sol:TestFFI
[2024-04-23 18:04:35.70] Running slither on foo.sol... Done! (0.81568s)
[2024-04-23 18:04:36.52] [Worker 0] Crashed:
Cannot decode byte '\xc3': Data.Text.Encoding: Invalid UTF-8 stream
Please report it to https://github.com/crytic/echidna/issues
[2024-04-23 18:04:36.52] [status] tests: 0/2, fuzzing: 0/50000, values: [], cov: 481, corpus: 0
foo(): passing
AssertionFailed(..): passing
...
from echidna.
@elopez confirmed, this was the issue. Thanks a lot! Fixed via pcaversaccio/snekmate@0d6889f. Will close the issue accordingly.
from echidna.
Uhm, is there something we should recommend to hevm to avoid this decoding error?
from echidna.
Uhm, is there something we should recommend to hevm to avoid this decoding error?
maybe raise this issue to them at least and get their thoughts on it?
from echidna.
Related Issues (20)
- Feature Request: Support for logging in view functions like Foundry's `console2` HOT 1
- [Bug-Candidate]: HOT 5
- [Bug-Candidate]: Coverage report doesn't display fuzzing contract in html unless an assertion fails HOT 1
- [Bug-Candidate]: no fore color support for terminal xterm-256color HOT 4
- Improve error message on MaxInitCodeSizeExceeded issue HOT 3
- Improve error message if the function hashmap is not detected HOT 3
- [Bug-Candidate]: Internal Error: TODO: implement copySlice with a symbolically sized region HOT 4
- Feature Request: Add setting to consider reverted tests as failed in assertion mode HOT 1
- Shrinking multicore HOT 3
- update number of workers to a decent default
- warn when seqLen > 1 and there haven't been any SLOAD/SSTORE in target HOT 1
- Allow Configurable Verbosity HOT 1
- [Bug-Candidate]: Contract is "unknown contract" but should be able to be identified HOT 2
- Have multiple workers to speed up fetching slots HOT 3
- [Bug-Candidate]: A simple contract took onchain fuzzer extremely long time to run due to zero calls per second HOT 2
- add call sequence mutation that removes all reverting txs in the sequences HOT 1
- [Bug-Candidate]: echidna: thread blocked indefinitely in an MVar operation HOT 2
- Log shrinking status when running in detached mode
- Fine-tune shrinking behavior
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from echidna.