nevillegrech / gigahorse-toolchain

A binary lifter and analysis framework for Ethereum smart contracts
Other
290 stars 59 forks source link

Increase stack limit from 50 to 70, increasing global analysis coverage #97

Closed sifislag closed 1 year ago

sifislag commented 1 year ago

Stumbled upon weird behavior when looking at this old issue. It seemed that we were doing a better job with the new shrinking context and the transfer() and transferFrom() methods were way more complete. However we had some code unreachable at the global level. Turned out the issue was caused by the stack limit of our global analysis being reached. Played around with it and found that 70 was the best value.

Benchmark results for 1300 contracts from popular protcols:

1291 contracts decompiled/analyzed by june23-shrinking50-pro-200 (1 exclusively)
1290 contracts decompiled/analyzed by june23-shrinking70-pro-200 (0 exclusively)

ANALYTIC: decomp_time
june23-shrinking50-pro-200 (common): 4526.124116182327
june23-shrinking70-pro-200 (common): 4754.998030662537 (+5.057%)

ANALYTIC: Analytics_JumpToMany
june23-shrinking50-pro-200 (common): 437 (+0.6912%)
june23-shrinking70-pro-200 (common): 434

ANALYTIC: Analytics_ReachableBlocks
june23-shrinking50-pro-200 (common): 536547 (-0.007455%)
june23-shrinking70-pro-200 (common): 536587

ANALYTIC: Analytics_UnreachableBlock
june23-shrinking50-pro-200 (common): 16225 (+0.2471%)
june23-shrinking70-pro-200 (common): 16185

ANALYTIC: Analytics_ReachableBlocksInTAC
june23-shrinking50-pro-200 (common): 536509 (-0.007269%)
june23-shrinking70-pro-200 (common): 536548

ANALYTIC: Analytics_BlockHasNoTACBlock
june23-shrinking50-pro-200 (common): 38
june23-shrinking70-pro-200 (common): 39 (+2.632%)

ANALYTIC: Analytics_DeadBlocks
june23-shrinking50-pro-200 (common): 1692
june23-shrinking70-pro-200 (common): 1702 (+0.591%)

ANALYTIC: Analytics_PolymorphicTargetSameCtx
june23-shrinking50-pro-200 (common): 66
june23-shrinking70-pro-200 (common): 67 (+1.515%)

ANALYTIC: Analytics_LocalBlockEdge
june23-shrinking50-pro-200 (common): 686568 (-0.0007283%)
june23-shrinking70-pro-200 (common): 686573

It can be noticed that in rare cases it does make a difference.

Results for 1022 viaIR contracts:

970 contracts decompiled/analyzed by june23-shrinking-200 (1 exclusively)
970 contracts decompiled/analyzed by june23-shrinking70-200 (1 exclusively)

ANALYTIC: decomp_time
june23-shrinking-200 (common): 6137.605167865753
june23-shrinking70-200 (common): 6262.067136526108 (+2.028%)

ANALYTIC: Analytics_JumpToMany
june23-shrinking-200 (common): 2532 (+0.1186%)
june23-shrinking70-200 (common): 2529

ANALYTIC: Analytics_ReachableBlocks
june23-shrinking-200 (common): 468372
june23-shrinking70-200 (common): 468372

ANALYTIC: Analytics_UnreachableBlock
june23-shrinking-200 (common): 18047
june23-shrinking70-200 (common): 18047

ANALYTIC: Analytics_ReachableBlocksInTAC
june23-shrinking-200 (common): 467762
june23-shrinking70-200 (common): 467762

ANALYTIC: Analytics_BlockHasNoTACBlock
june23-shrinking-200 (common): 610
june23-shrinking70-200 (common): 610

ANALYTIC: Analytics_DeadBlocks
june23-shrinking-200 (common): 5089
june23-shrinking70-200 (common): 5089

ANALYTIC: Analytics_PolymorphicTargetSameCtx
june23-shrinking-200 (common): 339
june23-shrinking70-200 (common): 339

ANALYTIC: Analytics_LocalBlockEdge
june23-shrinking-200 (common): 670505
june23-shrinking70-200 (common): 670493 (-0.00179%)

ANALYTIC: Analytics_Contexts
june23-shrinking-200 (common): 1596237
june23-shrinking70-200 (common): 1596612 (+0.02349%)

Not that affected.

github-actions[bot] commented 1 year ago

Test Results (Souffle 2.4)

42 tests  +1   42 :heavy_check_mark: +1   18m 16s :stopwatch: - 8m 56s   1 suites ±0     0 :zzz: ±0    1 files   ±0     0 :x: ±0 

Results for commit 72745448. ± Comparison against base commit cdd7571b.

github-actions[bot] commented 1 year ago

Test Results (Souffle 2.3)

42 tests  +1   42 :heavy_check_mark: +1   25m 8s :stopwatch: + 6m 3s   1 suites ±0     0 :zzz: ±0    1 files   ±0     0 :x: ±0 

Results for commit 72745448. ± Comparison against base commit cdd7571b.