From 8347ad91c3fd5bc2d322c40f117799b558eab660 Mon Sep 17 00:00:00 2001 From: Artur Cygan Date: Thu, 6 Jun 2024 14:36:39 +0200 Subject: [PATCH] Improve max code size error message (#1269) * Improve max code size error message * Change codeSize default to 0xffffffff --- lib/Echidna/Config.hs | 2 +- lib/Echidna/Types.hs | 15 ++++++++++++--- lib/Echidna/Types/Solidity.hs | 2 +- tests/solidity/basic/default.yaml | 4 ++-- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/lib/Echidna/Config.hs b/lib/Echidna/Config.hs index cbe6ca17e..ed7796014 100644 --- a/lib/Echidna/Config.hs +++ b/lib/Echidna/Config.hs @@ -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" ..!= "" diff --git a/lib/Echidna/Types.hs b/lib/Echidna/Types.hs index e2eccf62a..316d49e83 100644 --- a/lib/Echidna/Types.hs +++ b/lib/Echidna/Types.hs @@ -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 diff --git a/lib/Echidna/Types/Solidity.hs b/lib/Echidna/Types/Solidity.hs index 792c1b269..f17e81697 100644 --- a/lib/Echidna/Types/Solidity.hs +++ b/lib/Echidna/Types/Solidity.hs @@ -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@ diff --git a/tests/solidity/basic/default.yaml b/tests/solidity/basic/default.yaml index 1a9458bd9..36428ac49 100644 --- a/tests/solidity/basic/default.yaml +++ b/tests/solidity/basic/default.yaml @@ -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