eth-sri / ilf

AI based fuzzer based on imitation learning
Apache License 2.0
149 stars 32 forks source link

Error locked to thread - #2

Closed saarshah closed 4 years ago

saarshah commented 4 years ago

Hi i have build your project manually in WSL. it works well on your example contract. Now I have add my simple contract into a example folder i.e. myproject (which is init/generated/compiled/migrated through truffle). I could also generate its transactions.js file. But when i run training data python3 -m ilf --proj ./example/myproject/ --contract MyContract --limit 2000 --fuzzer symbolic --dataset_dump_path ./train_data/MyContract.data, then i got this error.

/home/saarshah/.local/lib/python3.6/site-packages/sklearn/externals/joblib/__init__.py:15: FutureWarning: sklearn.externals.joblib is deprecated in 0.21 and will be removed in 0.23. Please import this functionality directly from joblib, which can be installed with: pip install joblib. If this warning is raised when loading pickled models, you may need to re-serialize those models with scikit-learn 0.21+.
  warnings.warn(msg, category=FutureWarning)
[2020-01-12 13:43:29,435][1578807809.435980][__main__][INFO] fuzzing start
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x7f2ea3ca6769]

goroutine 17 [running, locked to thread]:
ilf/execution.convertAndSign(0xc42014d0e0, 0xc4201678f0, 0x900)
        /home/saarshah/go/src/ilf/execution/transaction.go:104 +0x259
ilf/execution.ReadTransactions(0xc42018cf60, 0x26, 0xc4201678f0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
        /home/saarshah/go/src/ilf/execution/transaction.go:47 +0x381
ilf/execution.(*Backend).DeployContracts(0xc4200208c0, 0xc4200208c0, 0x0, 0x0)
        /home/saarshah/go/src/ilf/execution/backend.go:93 +0x171
ilf/execution.NewBackend(0xc4201438e0, 0x14, 0x14, 0x7f2ea3cbe17e, 0xc, 0x17)
        /home/saarshah/go/src/ilf/execution/backend.go:77 +0x314
main.SetBackend(0x7f2ea42f2248, 0x7f2ea4096288)
        /home/saarshah/go/src/ilf/export/execution.go:17 +0x4c
main._cgoexpwrap_962cb359037a_SetBackend(0x7f2ea42f2248, 0x0)
        _cgo_gotypes.go:71 +0x5c
Aborted (core dumped)

I just want to know to test/fuzz any new contract what procedures should i followed to get results ?

UPDATED: here is my contract

pragma solidity ^0.5.0;

contract MyContract {

    uint256 public  totalSupply ; 
    mapping( address => uint256) public  balances ;
    address public owner;

    constructor() public payable {
        totalSupply = 6;
        owner = 0xD87d41Bbd765C488664725443260C0EE58E86941;
    }

    function () external payable{
        buyToken();
    }

    function buyToken() public payable {
        require(totalSupply >= (msg.value/1000000000000000000)*2);
        balances[msg.sender] += (msg.value/1000000000000000000)*2;
        totalSupply -=(msg.value/1000000000000000000)*2;

    }
    function getTotalSupply()public view returns  (uint256 ){
        // require(caller==owner)
        return totalSupply;
    }
       function setTotalSupply(uint256 newSupply) public {
        totalSupply = newSupply;

    }

}

I have followed this procedure

  1. make a truffle project in example folder
  2. copy paste above contract
  3. truffle compile
  4. truffle migrate
  5. python3 script/extract.py --proj example/myproject/ --port 8545
  6. python3 -m ilf --proj ./example/myproject/ --contract MyContract--limit 2000 --fuzzer symbolic --dataset_dump_path ./train_data/mycontract.data
LostBenjamin commented 4 years ago

Did you run script/extract.py, as explained in the README?

saarshah commented 4 years ago

yes, i have run this python3 script/extract.py --proj example/myproject/ --port 8545 and it generate transactions.json.. Please enlist procedure for new contract (from scratch to end, especially for newbies , like me )

LostBenjamin commented 4 years ago

Is it possible for you to share your project with me, so that I can investigate?

I think one only needs to run script/extract.py before running ILF on new contracts. This is clearly written in README, so no need to enlist more.

saarshah commented 4 years ago

ok i am now going to update my issue, see it in shortly ..

saarshah commented 4 years ago

Anything else is needed ? let me know

saarshah commented 4 years ago

I have figured it out... unfortunately, i was running ganache-cli , separately . When I closed that , my problem solved. Sorry for inconvenience.