Allow to bypass EIP-170 and set up a custom max code size (#544)

pull/562/head
ßingen 4 years ago committed by GitHub
parent 4af9a3dfe9
commit ecfebe112c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      examples/solidity/basic/default.yaml
  2. 2006
      examples/solidity/basic/eip-170.sol
  3. 3
      examples/solidity/basic/eip-170.yaml
  4. 1
      lib/Echidna/Config.hs
  5. 5
      lib/Echidna/Solidity.hs
  6. 2
      src/test/Tests/Compile.hs
  7. 2
      src/test/Tests/Integration.hs

@ -33,6 +33,8 @@ sender: ["0x10000", "0x20000", "0x00a329c0648769a73afac7f9381e08fb43dbea70"]
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
#solcArgs allows special args to solc
solcArgs: ""
#solcLibs is solc libraries

File diff suppressed because it is too large Load Diff

@ -0,0 +1,3 @@
codeSize: 28000
testLimit: 1
seqLen: 1

@ -141,6 +141,7 @@ instance FromJSON EConfigWithUsage where
<*> v ..:? "sender" ..!= (0x10000 NE.:| [0x20000, defaultDeployer])
<*> v ..:? "balanceAddr" ..!= 0xffffffff
<*> v ..:? "balanceContract" ..!= 0
<*> v ..:? "codeSize" ..!= 0x6000 -- 24576 (EIP-170)
<*> v ..:? "prefix" ..!= "echidna_"
<*> v ..:? "cryticArgs" ..!= []
<*> v ..:? "solcArgs" ..!= ""

@ -92,6 +92,7 @@ data SolConf = SolConf { _contractAddr :: Addr -- ^ Contract addr
, _sender :: NE.NonEmpty 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)
, _prefix :: Text -- ^ Function name prefix used to denote tests
, _cryticArgs :: [String] -- ^ Args to pass to crytic
, _solcArgs :: String -- ^ Args to pass to @solc@
@ -193,7 +194,7 @@ loadSpecified name cs = do
unless q . putStrLn $ "Analyzing contract: " <> c ^. contractName . unpacked
-- Local variables
SolConf ca d ads bala balc pref _ _ libs _ fp ma ch bm fs <- view hasLens
SolConf ca d ads bala balc mcs pref _ _ libs _ fp ma ch bm fs <- view hasLens
-- generate the complete abi mapping
let bc = c ^. creationCode
@ -212,7 +213,7 @@ loadSpecified name cs = do
-- Set up initial VM, either with chosen contract or Etheno initialization file
-- need to use snd to add to ABI dict
blank' <- maybe (pure initialVM)
blank' <- maybe (pure (initialVM & block . maxCodeSize .~ w256 (fromInteger mcs)))
(loadEthenoBatch $ fst <$> tests)
fp
let blank = populateAddresses (NE.toList ads |> d) bala blank'

@ -32,6 +32,8 @@ compilationTests = testGroup "Compilation and loading tests"
pmatch _ConstructorArgs
, loadFails "bad/revert.sol" Nothing "failed to warn on a failed deployment" $
pmatch _DeploymentFailed
, loadFails "basic/eip-170.sol" Nothing "failed to warn on a failed deployment" $
pmatch _DeploymentFailed
]
loadFails :: FilePath -> Maybe Text -> String -> (SolException -> Bool) -> TestTree

@ -153,4 +153,6 @@ integrationTests = testGroup "Solidity Integration Testing"
[ ("echidna_still_alive failed", solved "echidna_still_alive") ]
, checkConstructorConditions "basic/codesize.sol"
"invalid codesize"
, testContract "basic/eip-170.sol" (Just "basic/eip-170.yaml")
[ ("echidna_test passed", passed "echidna_test") ]
]

Loading…
Cancel
Save