Erwin is an academic attempt on introducing bounded exhaustive instantiation
in random program generator to mitigate opportunism.
Different from Csmith-family tools that generate a test program in one go, Erwin separates the generation process into two sub-steps: 1) randomly generate a type/loc/vis-agnostic IR (i.e., a program without type, storage location, and visibility), and 2) conducts bounded exhaustive instantiation to instantiate the IR into a swarm of real-word test programs.
By masking out bug-related langauge features, such as type, storage location, and visibility in the IR, Erwin shrinks the search space into a highly bug-related subspace. This way, Erwin reduce opportunism in random program generations.
Erwin is still under development, any suggestion and collaboration is welcomed.
The simplest way is npm install @__haoyang__/erwin
it and npx erwin generate
with different generation flags. npx erwin generate
is the trivial generation, in which Erwin will not explore the search space of the IR, but perform just like Csmith, generate a test program in one go.
To utilize Erwin's features in program generation, you can use -m
to specify the bug-related features you want to mask in the IR, and use -max
to specify the maximum test programs you want to instantiation from the generated IR.
To directly use Erwin to fuzz the Solidity compiler, you can invoke --enable_test
.
Below is an example command to fuzz the Solidity compiler:
npx erwin generate -m type -d --enable_test --compiler_path=../solidity/build/solc/solc --refresh_folder --generation_rounds 10000 -max 100
For more flags, please refer to npx erwin generation -h
.
Besides bugs, Erwin only plays a role of examining the design of language features. Until now, Erwin has found the following features that may be confusing to Solidity users.
int_const
, int
, and uint
. Many intuitive operations on int literals and (u)int variables are forbidden. int8 var21;
false ? var21 : 62;
The second line raises an type error: TypeError: True expression's type int8 does not match false expression's type uint8.
.