Skip to content

Commit

Permalink
Improve max code size error message (#1269)
Browse files Browse the repository at this point in the history
* Improve max code size error message

* Change codeSize default to 0xffffffff
  • Loading branch information
arcz committed Jun 6, 2024
1 parent 5a366d2 commit 8347ad9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/Echidna/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ instance FromJSON EConfigWithUsage where
<*> v ..:? "sender" ..!= Set.fromList [0x10000, 0x20000, defaultDeployerAddr]
<*> v ..:? "balanceAddr" ..!= 0xffffffff
<*> v ..:? "balanceContract" ..!= 0
<*> v ..:? "codeSize" ..!= 0x6000 -- 24576 (EIP-170)
<*> v ..:? "codeSize" ..!= 0xffffffff
<*> v ..:? "prefix" ..!= "echidna_"
<*> v ..:? "cryticArgs" ..!= []
<*> v ..:? "solcArgs" ..!= ""
Expand Down
15 changes: 12 additions & 3 deletions lib/Echidna/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,18 @@ import EVM.Types
data ExecException = IllegalExec EvmError | UnknownFailure EvmError

instance Show ExecException where
show (IllegalExec e) = "VM attempted an illegal operation: " ++ show e
show (UnknownFailure e) = "VM failed for unhandled reason, " ++ show e
++ ". This shouldn't happen. Please file a ticket with this error message and steps to reproduce!"
show = \case
IllegalExec e -> "VM attempted an illegal operation: " ++ show e
UnknownFailure (MaxCodeSizeExceeded limit actual) ->
"Max code size exceeded. " ++ codeSizeErrorDetails limit actual
UnknownFailure (MaxInitCodeSizeExceeded limit actual) ->
"Max init code size exceeded. " ++ codeSizeErrorDetails limit actual
UnknownFailure e -> "VM failed for unhandled reason, " ++ show e
++ ". This shouldn't happen. Please file a ticket with this error message and steps to reproduce!"
where
codeSizeErrorDetails limit actual =
"Configured limit: " ++ show limit ++ ", actual: " ++ show actual
++ ". Set 'codeSize: 0xffffffff' in the config file to increase the limit."

instance Exception ExecException

Expand Down
2 changes: 1 addition & 1 deletion lib/Echidna/Types/Solidity.hs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ data SolConf = SolConf
, sender :: Set Addr -- ^ Sender addresses to use
, balanceAddr :: Integer -- ^ Initial balance of deployer and senders
, balanceContract :: Integer -- ^ Initial balance of contract to test
, codeSize :: Integer -- ^ Max code size for deployed contratcs (default 24576, per EIP-170)
, codeSize :: Integer -- ^ Max code size for deployed contratcs (default 0xffffffff)
, prefix :: Text -- ^ Function name prefix used to denote tests
, cryticArgs :: [String] -- ^ Args to pass to crytic
, solcArgs :: String -- ^ Args to pass to @solc@
Expand Down
4 changes: 2 additions & 2 deletions tests/solidity/basic/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ sender: ["0x10000", "0x20000", "0x30000"]
balanceAddr: 0xffffffff
#balanceContract overrides balanceAddr for the contract address
balanceContract: 0
#codeSize max code size for deployed contratcs (default 24576, per EIP-170)
codeSize: 0x6000
#codeSize max code size for deployed contratcs (default 0xffffffff)
codeSize: 0xffffffff
#solcArgs allows special args to solc
solcArgs: ""
#solcLibs is solc libraries
Expand Down

0 comments on commit 8347ad9

Please sign in to comment.