Giter Site home page Giter Site logo

Comments (9)

pcaversaccio avatar pcaversaccio commented on June 21, 2024 1

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.

ggrieco-tob avatar ggrieco-tob commented on June 21, 2024 1

Sounds like a plan!

from echidna.

ggrieco-tob avatar ggrieco-tob commented on June 21, 2024

Hey, this looks very cool. Do you know if the bug is related to hevm code or echidna?

from echidna.

pcaversaccio avatar pcaversaccio commented on June 21, 2024

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.

pcaversaccio avatar pcaversaccio commented on June 21, 2024

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.

elopez avatar elopez commented on June 21, 2024

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.

pcaversaccio avatar pcaversaccio commented on June 21, 2024

@elopez confirmed, this was the issue. Thanks a lot! Fixed via pcaversaccio/snekmate@0d6889f. Will close the issue accordingly.

from echidna.

ggrieco-tob avatar ggrieco-tob commented on June 21, 2024

Uhm, is there something we should recommend to hevm to avoid this decoding error?

from echidna.

pcaversaccio avatar pcaversaccio commented on June 21, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.