A basic implementation of "DAppFL: Just-in-Time Fault Localization for Decentralized Applications in Web3", ISSTA 2024.
Please ensure that your Python version is above 3.9 :) And use following commands to install the dependency of DAppFL:
pip install -r requirements.txt
npm install
Let's try to locate the SushiSwap fault. Perform fault localization with DAppFL using the following command:
$ python locate.py \
--net=Ethereum \
--fault_txhash=0x90fb0c9976361f537330a5617a404045ffb3fef5972cf67b531386014eeae7a9 \
--faultless_txhash=0x7df39084b561ee2e7809e690f11e8e258dc65b6128399acbacf1f2433308de6a,0xddd734c1f3e097d3d1cdd7d4c0ffae166b39992a1d055008bf6660b8c0b7582e,0x5c1d151599bbacc19a09dfee888d3be2ccf3e2fa781679b9e0970e18b3300e44
Params description
net
: indicate the blockchain network where dapp is deployed, supportingEthereum
andBNBChain
fault_txhash
: transaction hash that results in the fault, please,
for join multiple hash if availablefaultless_txhash
: transaction hash that has NOT resulting in the fault, please,
for join multiple hash if available
You can get the output like this (where Top-0 is the true fault location):
loading model params...
collecting transaction executing data...
The following code snippets are most likely to cause faults, and the ranking is in descending order of faulty suspiciousness:
Top-0: fault function at contracts/SushiMaker.sol -> 0xe11fc0b43ab98eb91e9836129d1ee7c3bc95df50, offset is 1689:185
Top-1: fault function at contracts/SushiMaker.sol -> 0xe11fc0b43ab98eb91e9836129d1ee7c3bc95df50, offset is 3574:738
Top-2: fault function at contracts/SushiMaker.sol -> 0xe11fc0b43ab98eb91e9836129d1ee7c3bc95df50, offset is 4426:2288
Top-3: fault function at contracts/SushiMaker.sol -> 0xe11fc0b43ab98eb91e9836129d1ee7c3bc95df50, offset is 7944:173
Top-4: fault function at contracts/SushiMaker.sol -> 0xe11fc0b43ab98eb91e9836129d1ee7c3bc95df50, offset is 2988:109
algos
: Contains some simple algorithms, such as graph diffusion.compiler
: Contains various versions of the Solc compiler.daos
: The data access object, for data processing.data
: The contributed dataset.dataset
: The code for data modelling.downloader
: Crawl data from the blockchain clients.misc
: Necessary JavaScript files, such as scripts for injecting RPC interfaces.models
: The Graph neural network model.utils
: Some small tools used in the project.main.py
: The main file for starting and evaluating our method, and we save the output to file namedmain_output
.
You can use main.py
to train your DAppFL.
There are some parameters for main.py
:
--data_path
: a path for the dataset.--hidden_channels
: the number of neurons for each layer of HGT, default is32
.--num_layers
: the number of layers for HGT, default is4
.--num_heads
: the number of attention heads for HGT, default is1
.--gpu
: Enable GPU for training, default isFalse
.--k_folds
: Number of repeated experiments, default is5
.--epoch
: Number of training rounds, default is10
.--batch_size
: Batch size during training, default is4
.--lr
: Learning rate of optimizer, default is0.001
.--weight_decay
: Weight decay of optimizer, default is5e-4
.--p_norm
: The Power of Graph Diffusion, default is6
.