Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve max code size error message #1269

Merged
merged 2 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading