From 62b10b0f5402cda04162c3f4ed34fc40c01cf866 Mon Sep 17 00:00:00 2001 From: Ben Siraphob Date: Fri, 2 Jun 2023 16:10:57 +0700 Subject: [PATCH 1/2] Make continuous fuzzing default Fixes #477 --- lib/Echidna/Campaign.hs | 6 +++--- lib/Echidna/Config.hs | 2 +- lib/Echidna/Types/Campaign.hs | 5 +---- lib/Echidna/UI.hs | 6 ++++-- lib/Echidna/UI/Widgets.hs | 4 ++-- src/Main.hs | 4 ++-- src/test/Common.hs | 2 +- src/test/Tests/Seed.hs | 2 +- tests/solidity/research/ilf_crowdsale.yaml | 1 + 9 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/Echidna/Campaign.hs b/lib/Echidna/Campaign.hs index 67b3f6b3e..df2dc0021 100644 --- a/lib/Echidna/Campaign.hs +++ b/lib/Echidna/Campaign.hs @@ -91,7 +91,7 @@ runWorker -> Int -- ^ Worker id starting from 0 -> [(FilePath, [Tx])] -- ^ Initial corpus of transactions - -> Int -- ^ Test limit for this worker + -> Maybe Int -- ^ Test limit for this worker -> m (WorkerStopReason, WorkerState) runWorker callback vm world dict workerId initialCorpus testLimit = do let @@ -136,10 +136,10 @@ runWorker callback vm world dict workerId initialCorpus testLimit = do if | stopOnFail && any final tests -> lift callback >> pure FastFailed - | (null tests || any isOpen tests) && ncalls < testLimit -> + | (null tests || any isOpen tests) && maybe True (ncalls <) testLimit -> fuzz >> continue - | ncalls >= testLimit && any (\t -> isOpen t && isOptimizationTest t) tests -> do + | maybe False (ncalls >=) testLimit && any (\t -> isOpen t && isOptimizationTest t) tests -> do liftIO $ atomicModifyIORef' testsRef $ \sharedTests -> (closeOptimizationTest <$> sharedTests, ()) continue diff --git a/lib/Echidna/Config.hs b/lib/Echidna/Config.hs index ce76b1c99..6cd3248a9 100644 --- a/lib/Echidna/Config.hs +++ b/lib/Echidna/Config.hs @@ -84,7 +84,7 @@ instance FromJSON EConfigWithUsage where pure $ TestConf classify (const psender) campaignConfParser = CampaignConf - <$> v ..:? "testLimit" ..!= defaultTestLimit + <$> v ..:? "testLimit" <*> v ..:? "stopOnFail" ..!= False <*> v ..:? "estimateGas" ..!= False <*> v ..:? "seqLen" ..!= defaultSequenceLength diff --git a/lib/Echidna/Types/Campaign.hs b/lib/Echidna/Types/Campaign.hs index 240eeae32..6f1d4a48f 100644 --- a/lib/Echidna/Types/Campaign.hs +++ b/lib/Echidna/Types/Campaign.hs @@ -14,7 +14,7 @@ import Echidna.Types.Tx (Tx) -- | Configuration for running an Echidna 'Campaign'. data CampaignConf = CampaignConf - { testLimit :: Int + { testLimit :: Maybe Int -- ^ Maximum number of function calls to execute while fuzzing , stopOnFail :: Bool -- ^ Whether to stop the campaign immediately if any property fails @@ -148,9 +148,6 @@ initialWorkerState = , ncalls = 0 } -defaultTestLimit :: Int -defaultTestLimit = 50000 - defaultSequenceLength :: Int defaultSequenceLength = 100 diff --git a/lib/Echidna/UI.hs b/lib/Echidna/UI.hs index 257aaee9e..35b5163ba 100644 --- a/lib/Echidna/UI.hs +++ b/lib/Echidna/UI.hs @@ -77,8 +77,10 @@ ui vm world dict initialCorpus = do -- Distribute over all workers, could be slightly bigger overall due to -- ceiling but this doesn't matter - perWorkerTestLimit = ceiling - (fromIntegral conf.campaignConf.testLimit / fromIntegral nworkers :: Double) + perWorkerTestLimit = + case conf.campaignConf.testLimit of + Nothing -> Nothing + Just t -> Just $ ceiling (fromIntegral t / fromIntegral nworkers :: Double) chunkSize = ceiling (fromIntegral (length initialCorpus) / fromIntegral nworkers :: Double) diff --git a/lib/Echidna/UI/Widgets.hs b/lib/Echidna/UI/Widgets.hs index d648b01c9..0841026d2 100644 --- a/lib/Echidna/UI/Widgets.hs +++ b/lib/Echidna/UI/Widgets.hs @@ -169,8 +169,8 @@ summaryWidget env uiState = <=> perfWidget uiState <=> - str ("Total calls: " <> progress (sum $ (.ncalls) <$> uiState.campaigns) - env.cfg.campaignConf.testLimit) + str ("Total calls: " <> maybe (show totalCalls) (progress totalCalls) env.cfg.campaignConf.testLimit) + totalCalls = (sum $ (.ncalls) <$> uiState.campaigns) middle = padLeft (Pad 1) $ str ("Unique instructions: " <> show uiState.coverage) diff --git a/src/Main.hs b/src/Main.hs index 5f5d12935..60b9b1f86 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -175,7 +175,7 @@ options = Options <> help "Timeout given in seconds.") <*> optional (option auto $ long "test-limit" <> metavar "INTEGER" - <> help ("Number of sequences of transactions to generate during testing. Default is " ++ show defaultTestLimit)) + <> help "Number of sequences of transactions to generate during testing. Default is unbounded.") <*> optional (option auto $ long "rpc-block" <> metavar "BLOCK" <> help "Block number to use when fetching over RPC.") @@ -239,7 +239,7 @@ overrideConfig config Options{..} = do overrideCampaignConf campaignConf = campaignConf { corpusDir = cliCorpusDir <|> campaignConf.corpusDir - , testLimit = fromMaybe campaignConf.testLimit cliTestLimit + , testLimit = cliTestLimit <|> campaignConf.testLimit , shrinkLimit = fromMaybe campaignConf.shrinkLimit cliShrinkLimit , seqLen = fromMaybe campaignConf.seqLen cliSeqLen , seed = cliSeed <|> campaignConf.seed diff --git a/src/test/Common.hs b/src/test/Common.hs index 5e240953b..8b4072925 100644 --- a/src/test/Common.hs +++ b/src/test/Common.hs @@ -60,7 +60,7 @@ overrideQuiet conf = overrideLimits :: EConfig -> EConfig overrideLimits conf = - conf { campaignConf = conf.campaignConf { testLimit = 10000 + conf { campaignConf = conf.campaignConf { testLimit = Just 10000 , shrinkLimit = 4000 }} type SolcVersion = Version diff --git a/src/test/Tests/Seed.hs b/src/test/Tests/Seed.hs index b609174fc..92976f01c 100644 --- a/src/test/Tests/Seed.hs +++ b/src/test/Tests/Seed.hs @@ -22,7 +22,7 @@ seedTests = where cfg s = defaultConfig { campaignConf = CampaignConf - { testLimit = 600 + { testLimit = Just 600 , stopOnFail = False , estimateGas = False , seqLen = 20 diff --git a/tests/solidity/research/ilf_crowdsale.yaml b/tests/solidity/research/ilf_crowdsale.yaml index 8ef313b27..b7a36a820 100644 --- a/tests/solidity/research/ilf_crowdsale.yaml +++ b/tests/solidity/research/ilf_crowdsale.yaml @@ -1,2 +1,3 @@ maxValue: 10000000000000000000000000 testMode: assertion +testLimit: 50000 From 75ef5aaada3f4399ab395147bbc2edf6ae7b87b8 Mon Sep 17 00:00:00 2001 From: Sam Alws Date: Thu, 14 Mar 2024 10:58:15 -0400 Subject: [PATCH 2/2] making a commit to see if CI fails in the same way as last time --- asdf | 1 + 1 file changed, 1 insertion(+) create mode 100644 asdf diff --git a/asdf b/asdf new file mode 100644 index 000000000..8bd6648ed --- /dev/null +++ b/asdf @@ -0,0 +1 @@ +asdf