evmole
evmole copied to clipboard
Can add detect function support payable ?
thanks
It's trivial (at least for Solidity). I'll add this to the backlog and implement it later.
It's trivial (at least for Solidity). I'll add this to the backlog and implement it later.
Maybe we can consider prioritizing this? This helps generate a somehow "full" abi.
prioritizing this
After https://github.com/cdump/evmole/issues/9, it will be easier to implement new features only in 1 language. I'm on 4'th step of TODO list
I can help implement this so that evmole can return a full Function
Do you want to return https://docs.rs/alloy-json-abi/0.8.0/alloy_json_abi/struct.Function.html ? If yes, what about outputs field, which is not Optional, we don't have this information. Using empty Vec there may mislead the users.
Oh, you are correct. My own code always ignores this field so I forget this. Maybe another standalone function to return if a selector is payable or not.
I've conducted some experiments in the state_mutability branch, the main idea is described here (typo: it's call_value=0 in 2.1.)
Using the largest1k dataset, I couldn't achieve more than a 53% success rate (counting view & pure from etherscan as payable, and only 33% if nonpayable (it's right)), which is far from satisfactory.
We need to explore alternative approaches.
P.S. In modern Vyper, we can extract this information from metadata, but let's focus on solving the Solidity issue first.
I've added normal benchmark to 'state_mutability' branch, current results:
'simple' always returns 'nonpayable'
strict cmp ('view' != 'nonpayable'):
dataset largest1k (1000 contracts, 24427 functions), evmole-rs:
bad: 20846 functions 85.34%
dataset largest1k (1000 contracts, 24427 functions), heimdall-rs:
bad: 13403 functions 54.87%
dataset largest1k (1000 contracts, 24427 functions), sevm:
bad: 14417 functions 59.02%
dataset largest1k (1000 contracts, 24427 functions), simple:
bad: 14864 functions 60.85%
non-strict cmp ('view' and 'pure' == 'nonpayable') - source
dataset largest1k (1000 contracts, 24427 functions), evmole-rs:
bad: 16177 functions 66.23%
dataset largest1k (1000 contracts, 24427 functions), heimdall-rs:
bad: 6201 functions 25.39%
dataset largest1k (1000 contracts, 24427 functions), sevm:
bad: 501 functions 2.05%
dataset largest1k (1000 contracts, 24427 functions), simple:
bad: 643 functions 2.63%
$ cd benchmarks/
$ DATASETS=largest1k PROVIDERS_MUTABILITY="simple evmole-rs sevm heimdall-rs" make benchmark-mutability
$ python3 ./compare.py --datasets largest1k --mode mutability
My two cents: to increase precision, we should firstly decode abi and ensure the call data conforms with abi?
Why the precision is just 60%? Your algorithm seems good and reasonable.
From: Maxim Andreev @.> Sent: Wednesday, August 28, 2024 5:05:57 PM To: cdump/evmole @.> Cc: lazymio @.>; Comment @.> Subject: Re: [cdump/evmole] Can add detect function support payable ? (Issue #6)
I've added normal benchmark to 'state_mutability' branch, current results:
'simple' always returns 'nonpayable'
strict cmp ('view' != 'nonpayable'):
dataset largest1k (1000 contracts, 24427 functions), evmole-rs: bad: 20846 functions 85.34%
dataset largest1k (1000 contracts, 24427 functions), heimdall-rs: bad: 13403 functions 54.87%
dataset largest1k (1000 contracts, 24427 functions), sevm: bad: 14417 functions 59.02%
dataset largest1k (1000 contracts, 24427 functions), simple: bad: 14864 functions 60.85%
non-strict cmp ('view' and 'pure' == 'nonpayable') - fda622a#diff-11f0a34f6da0d500562ceadaae6abfb4f9c2dd2ae5ff01ffd0e879e35ab70bdeR242https://github.com/cdump/evmole/commit/fda622a5e63ad2fb5f207f52ce246a90abd3e0a2#diff-11f0a34f6da0d500562ceadaae6abfb4f9c2dd2ae5ff01ffd0e879e35ab70bdeR242
dataset largest1k (1000 contracts, 24427 functions), evmole-rs: bad: 16177 functions 66.23%
dataset largest1k (1000 contracts, 24427 functions), heimdall-rs: bad: 6201 functions 25.39%
dataset largest1k (1000 contracts, 24427 functions), sevm: bad: 501 functions 2.05%
dataset largest1k (1000 contracts, 24427 functions), simple: bad: 643 functions 2.63%
$ cd benchmarks/ $ DATASETS=largest1k PROVIDERS_MUTABILITY="evmole-rs sevm heimdall-rs" make benchmark-mutability $ python3 ./compare.py --datasets largest1k --mode mutability
― Reply to this email directly, view it on GitHubhttps://github.com/cdump/evmole/issues/6#issuecomment-2314758195, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AHJULOZB25OC3YF3NWJRQCLZTWHHLAVCNFSM6AAAAABLX7YONKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMJUG42TQMJZGU. You are receiving this because you commented.Message ID: @.***>
I found a bug - we need to track reverts even inside 'skip_until_inside_function', because if all functions are not payable, then Solidity checks CALLVALUE at the beginning of the contract execution.
After the fix, we got:
bad: 59 functions 0.24% in non-strict mode and bad: 14,278 functions 58.45% in strict mode.
Now we need to improve strict mode.
Bug was about location of this check - at the begging of the whole contract or after checking for function selector - inside function body
Yes, I misunderstood.
From: Maxim Andreev @.> Sent: Wednesday, August 28, 2024 5:47:43 PM To: cdump/evmole @.> Cc: lazymio @.>; Comment @.> Subject: Re: [cdump/evmole] Can add detect function support payable ? (Issue #6)
Bug was about location of this check - at the begging of the whole contract or after checking for function selector - inside function body
― Reply to this email directly, view it on GitHubhttps://github.com/cdump/evmole/issues/6#issuecomment-2314849239, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AHJULO2V6XTEIYXQXEWKZYTZTWMD7AVCNFSM6AAAAABLX7YONKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMJUHA2DSMRTHE. You are receiving this because you commented.Message ID: @.***>
Now results are even better: https://github.com/cdump/evmole/tree/state_mutability?tab=readme-ov-file#function-state-mutability
Merged to the master, will make release soon