From d7888ea6d3e6d04d666d2af8092a58bc378f9e48 Mon Sep 17 00:00:00 2001 From: Jamie Bertram Date: Thu, 2 Nov 2023 11:24:33 -0400 Subject: [PATCH] Revert unnecessary changes --- .../Marlowe/Runtime/ChainIndexer/Store.hs | 8 ++--- .../src/Test/Integration/Marlowe/Local.hs | 2 +- marlowe-runtime/marlowe-runtime/Main.hs | 33 +++++-------------- 3 files changed, 13 insertions(+), 30 deletions(-) diff --git a/marlowe-chain-sync/chain-indexer/Language/Marlowe/Runtime/ChainIndexer/Store.hs b/marlowe-chain-sync/chain-indexer/Language/Marlowe/Runtime/ChainIndexer/Store.hs index a717ccf426..de9bff8a8a 100644 --- a/marlowe-chain-sync/chain-indexer/Language/Marlowe/Runtime/ChainIndexer/Store.hs +++ b/marlowe-chain-sync/chain-indexer/Language/Marlowe/Runtime/ChainIndexer/Store.hs @@ -9,7 +9,7 @@ module Language.Marlowe.Runtime.ChainIndexer.Store ( chainStore, ) where -import Colog (Message, WithLog, logInfo) +import Colog (Message, WithLog) import Control.Concurrent.Component import Control.Concurrent.STM (STM, newTVar, readTVar) import Control.Concurrent.STM.Delay (Delay, newDelay, waitDelay) @@ -77,9 +77,7 @@ chainStore = component "indexer-chain-store" \ChainStoreDependencies{..} -> do case mDbGenesisBlock of Just dbGenesisBlock -> unless (dbGenesisBlock == genesisBlock) do liftIO $ fail "Existing genesis block does not match computed genesis block" - Nothing -> do - logInfo "Saving Genesis block" - runCommitGenesisBlock commitGenesisBlock genesisBlock + Nothing -> runCommitGenesisBlock commitGenesisBlock genesisBlock atomically $ writeTVar readyVar True go Nothing where @@ -97,7 +95,7 @@ chainStore = component "indexer-chain-store" \ChainStoreDependencies{..} -> do computeDelay :: UTCTime -> IO (Maybe Delay) computeDelay lastWrite = runMaybeT do currentTime <- lift getCurrentTime - let nextWrite = addUTCTime 0 lastWrite + let nextWrite = addUTCTime rateLimit lastWrite guard $ nextWrite > currentTime let delay = nextWrite `diffUTCTime` currentTime let delayMicroseconds = floor $ 1_000_000 * nominalDiffTimeToSeconds delay diff --git a/marlowe-integration/src/Test/Integration/Marlowe/Local.hs b/marlowe-integration/src/Test/Integration/Marlowe/Local.hs index 8d67306244..6c9d828a3f 100644 --- a/marlowe-integration/src/Test/Integration/Marlowe/Local.hs +++ b/marlowe-integration/src/Test/Integration/Marlowe/Local.hs @@ -242,7 +242,7 @@ withLocalMarloweRuntime' MarloweRuntimeOptions{..} test = withRunInIO \runInIO - byronGenesisConfig shelleyGenesisConfig - chainIndexerDatabaseQueries = ChainIndexer.databaseQueries 10 pool genesisBlock + chainIndexerDatabaseQueries = ChainIndexer.databaseQueries pool genesisBlock chainSyncDatabaseQueries = ChainSync.databaseQueries pool localNodeNetworkId diff --git a/marlowe-runtime/marlowe-runtime/Main.hs b/marlowe-runtime/marlowe-runtime/Main.hs index 6325bfdaa0..99a3325c8b 100644 --- a/marlowe-runtime/marlowe-runtime/Main.hs +++ b/marlowe-runtime/marlowe-runtime/Main.hs @@ -9,10 +9,7 @@ module Main where import Cardano.Api ( - AnyCardanoEra (..), CardanoMode, - ConsensusMode (..), - ConsensusModeIsMultiEra (..), ConsensusModeParams (..), EpochSlots (..), EraInMode (..), @@ -26,7 +23,6 @@ import Cardano.Api ( QueryInShelleyBasedEra (..), ShelleyBasedEra (..), queryNodeLocalState, - toEraInMode, ) import qualified Cardano.Api as Cardano import Cardano.Api.Byron (toByronRequiresNetworkMagic) @@ -126,31 +122,13 @@ run Options{..} = bracket (Pool.acquire 100 (Just 5000000) (fromString databaseU } genesisBlock = computeGenesisBlock (abstractHashToBytes hash) genesisConfig shelleyGenesis - Right (AnyCardanoEra era) <- - queryNodeLocalState localNodeConnectInfo Nothing $ QueryCurrentEra CardanoModeIsMultiEra - eraInMode <- case toEraInMode era CardanoMode of - Nothing -> fail $ "cannot convert " <> show era <> " to era in mode" - Just eraInMode -> pure eraInMode - shelleyBasedEra <- case eraInMode of - ByronEraInCardanoMode -> fail "Cannot query shelley in byron era" - ShelleyEraInCardanoMode -> pure ShelleyBasedEraShelley - AllegraEraInCardanoMode -> pure ShelleyBasedEraAllegra - MaryEraInCardanoMode -> pure ShelleyBasedEraMary - AlonzoEraInCardanoMode -> pure ShelleyBasedEraAlonzo - BabbageEraInCardanoMode -> pure ShelleyBasedEraBabbage - ConwayEraInCardanoMode -> pure ShelleyBasedEraConway - Right (Right GenesisParameters{..}) <- - queryNodeLocalState localNodeConnectInfo Nothing $ - QueryInEra eraInMode $ - QueryInShelleyBasedEra shelleyBasedEra QueryGenesisParameters - let securityParameter = fromIntegral protocolParamSecurity scripts <- case ScriptRegistry.getScripts MarloweV1 of NESet.IsEmpty -> fail "No known marlowe scripts" NESet.IsNonEmpty scripts -> pure scripts runAppMTraced instrumentationLibrary (renderRootSelectorOTel dbName dbUser dbHost dbPort) do - let chainIndexerDatabaseQueries = ChainIndexerPostgres.databaseQueries securityParameter pool genesisBlock + let chainIndexerDatabaseQueries = ChainIndexerPostgres.databaseQueries pool genesisBlock runGetGenesisBlock (getGenesisBlock chainIndexerDatabaseQueries) >>= \case Just dbGenesisBlock -> unless (dbGenesisBlock == genesisBlock) do @@ -159,6 +137,13 @@ run Options{..} = bracket (Pool.acquire 100 (Just 5000000) (fromString databaseU contractStore <- traceContractStore inject <$> createContractStore ContractStoreOptions{..} + securityParameter <- + liftIO $ + (either (fail . show) (either (fail . show) $ pure . protocolParamSecurity) =<<) $ + queryNodeLocalState localNodeConnectInfo Nothing $ + QueryInEra BabbageEraInCardanoMode $ + QueryInShelleyBasedEra ShelleyBasedEraBabbage QueryGenesisParameters + flip runComponent_ () proc _ -> do MarloweRuntime{..} <- marloweRuntime @@ -176,7 +161,7 @@ run Options{..} = bracket (Pool.acquire 100 (Just 5000000) (fromString databaseU , contractStore , costModel , genesisBlock - , marloweIndexerDatabaseQueries = IndexerPostgreSQL.databaseQueries pool protocolParamSecurity + , marloweIndexerDatabaseQueries = IndexerPostgreSQL.databaseQueries pool securityParameter , maxCost , marloweScriptHashes = NESet.map ScriptRegistry.marloweScript scripts , payoutScriptHashes = NESet.map ScriptRegistry.payoutScript scripts