Erwin is an academic attempt on introducing bounded exhaustive instantiation
in random program generator to mitigate opportunism. This effort is inspired by .
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/scope-agnostic IR (i.e., a program without type, storage location, and scope), 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 scope 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.
npm install @__haoyang__/erwin
git install [email protected]:haoyang9804/Erwin.git
cd Erwin
npm install
npm run build
If you install Erwin through NPM, the erwin
executable is in node_modules/.bin
, add it to your PATH, and directly call erwin
.
If you install Erwin through Git, go into the folder and type npx erwin
.
Erwin support various flags to tune the probability distribution of all language features (e.g., literal_prob
), control the program size (e.g., function_body_stmt_cnt_upper_limit
), change the generation mode (e.g, -m
), regulate the upperlimit of the amount of the test programs generated from the IR (e.g., -max
), etc.
npx erwin generate
is the trivial generation that generates a test program in a generation round, just like Csmith.
To enable the bounded exhaustive instantiation
feature, use -m
to specify the a class of language features you want to exhausitively instantiate from the IR, including type
, loc
ation, and scope
. -max
helps control the upperlimit of the instantiation.
Since different compilers (Solidity, Solang, Solar) define slightly different Solidity grammar, you can use --target
to specify the "accent" of Solidity you want to generate. It defaults to solidity.
Below is an example for generating Solidity programs of solang "accent".
npx erwin generate -m type -max 100 --target solang
The generated programs are stored in generated_programs
, you can change it by -o
.
Erwin integrates four distinct automated testing workflows, each designed to target a specific software tool: the Solidity, Solang, Solar, and Slither. The first three are compilers for Solidity programs while the last is a static analyzer of Solidity.
Below is an example for enable the testing workflow for Solidity.
npx erwin generate --target solc -m scope --enable_test --compiler_path solc --refresh_folder --generation_rounds 1000 -max 100
Misbehavior-triggering test programs will be moved to test_results
.
- ethereum/solidity#14719 (medium impact, confirmed, fixed, type) ✅
- ethereum/solidity#14720 (duplicate of 14719) 🤡
- ethereum/solidity#15223 (error handling) ✅
- ethereum/solidity#15236 (a probable duplicate, confirmed, fixed, type) ✅🤡
- ethereum/solidity#15219 (low effort, low impact, confirmed) ✅
- ethereum/solidity#15468 (low effort, low impact, confirmed, a probable duplicate) ✅🤡
- ethereum/solidity#15469 (smt) ✅
- ethereum/solidity#15469 (smt, two bugs in a thread) ✅
- ethereum/solidity#15483
- ethereum/solidity#15525 (documentation error) ✅
- ethereum/solidity#15483 (documentation error) ✅
- ethereum/solidity#15565 (error handling)
- ethereum/solidity#15564 (error handling)
- ethereum/solidity#15567 (error handling)
- ethereum/solidity#15566 (documentation error)
- ethereum/solidity#15583 (error handling,low effort low impact must have eventually should report better error) ✅
- ethereum/solidity#15645 (ICE, duplicate) 🤡
- ethereum/solidity#15646 (error handling) ✅
- ethereum/solidity#15647 (ICE, smt) ✅
- ethereum/solidity#15649 (ICE)
- ethereum/solidity#15651 (ICE)
- crytic/slither#2619 (hang)
- hyperledger-solang/solang#1687 (ICE)
- hyperledger-solang/solang#1688 (error handling)
- hyperledger-solang/solang#1689 (ICE)
- hyperledger-solang/solang#1690 (ICE)
- 🔨 Support Solar testing workflow
- 🔨 Support fixed
- 🔨 Support .push .pop for arrays
- 🔨 Support byte
- 🔨 Support type definition (for instance,
type T is bool;
) - 🔨 Support enum type
- 🔨 Support assertion
- 🔨 Support using for
- 🔨 Support inherent keywords, such as
msg.sender
,abi.encode
, etc - 🔨 Support bytes
- 🔨 Support contract inheritance
- 🔨 Support global constant variable, functions, and structs
- 🔨 Support variable shallowing
- 🔨 Support function type
- 🔨 Support inline assembly
- 🔨 Support try catch
- 🔨 Mutate Solidity programs