Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How about adding Erwin, a random Solidity program generator, into CI/CD workflow? #15680

Open
haoyang9804 opened this issue Dec 27, 2024 · 0 comments
Labels

Comments

@haoyang9804
Copy link
Contributor

Hi developers! I have been working on developing a random Solidity program generator, named Erwin, for a while, and it's almost done. This work is inspired by both a Solidity compiler bug study and the community's previous effort on using libprotobuf-mutator to generate test cases.

Erwin complies with Solidity's grammar and can thus generate valid test programs. Besides, Erwin can generate diverse test programs by tuning exposed flags to adjust the probability table. With these two features, Erwin's generated programs can pass the front-end parsing and go deep into the optimization and codegen components and uncover hidden bugs.

Erwin has found more than 20 bugs in both Solidity compilers and Slither, and it's still on the way to find more!

Until now, Erwin can generate complicated Solidity programs, including basic types, arrays, mappings, structs, and functions, and it can explore the interplay of various types, visibilities, and state mutabilities. It's still under development, and I plan to add contract inheritance and bytes to it. Supporting inline assembly is also on the schedule.

You can find the doc here, and the published npm package here

Just let me know if you are interested in this project and I'd like to help to enable Erwin in CI/CD.

Below is an example generated by Erwin. Welcome to play with Erwin!

contract contract0 {
  error error1();

  int128 internal var2;
  string internal var3;

  modifier modifier4(string memory var5) {
    (var2) % var2;
    _;
  }

  modifier modifier6(int128 var7) {
    revert contract0.error1();
    _;
  }

  constructor(int128 var8) modifier4(var3) {
    if (var2 > var2) {
      (var2 >>= 88);
    } else {}
  }

  function func9() internal modifier6(var2) {
    (~(var2));
  }
}

contract contract10 {
  event event11(string var12);

  int128 internal var13;

  modifier modifier14(int128 var15) {
    -var13;
    _;
  }

  function func16() internal modifier14(int128(-7797888714132780440)) {
    bool var17;
    while ((var17 = true)) {
      string memory var18;
      var18 = var18;
      emit contract10.event11(var18);
    }
    return ();
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants
@haoyang9804 and others