Skip to content

Commit

Permalink
bollocks 2
Browse files Browse the repository at this point in the history
  • Loading branch information
carbolymer committed Jul 3, 2024
1 parent f7d91b4 commit 3868745
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
3 changes: 2 additions & 1 deletion cardano-api/internal/Cardano/Api/Genesis.hs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ import qualified PlutusLedgerApi.V2 as V2
import Control.Monad.Trans.Fail.String (errorFail)
import qualified Data.Aeson as A
import Data.ByteString (ByteString)
import qualified Data.ByteString.Lazy as LBS
import qualified Data.Default.Class as DefaultClass
import Data.Functor.Identity (Identity)
import Data.Int (Int64)
Expand Down Expand Up @@ -223,7 +224,7 @@ decodeAlonzoGenesis :: forall era t m. MonadTransError String t m
-> ByteString
-> t m AlonzoGenesis
decodeAlonzoGenesis aeo genesisBs = modifyError ("Cannot decode Alonzo genesis: " <>) $ do
genesisValue :: A.Value <- liftEither $ A.eitherDecode (BS.fromStrict genesisBs)
genesisValue :: A.Value <- liftEither $ A.eitherDecode (LBS.fromStrict genesisBs)
-- Making a fixup of a costmodel is easier before JSON deserialization. This also saves us from building
-- plutus' EvaluationContext one more time after cost model update.
genesisValue' <- (AL.key "costModels" . AL.key "PlutusV2" . AL._Value) setCostModelDefaultValues genesisValue
Expand Down
18 changes: 10 additions & 8 deletions cardano-api/internal/Cardano/Api/LedgerState.hs
Original file line number Diff line number Diff line change
Expand Up @@ -384,10 +384,11 @@ data FoldStatus
-- | Monadic fold over all blocks and ledger states. Stopping @k@ blocks before
-- the node's tip where @k@ is the security parameter.
foldBlocks
:: forall a t m. ()
:: forall a t m era. ()
=> Show a
=> MonadIOTransError FoldBlocksError t m
=> NodeConfigFile 'In
=> AlonzoEraOnwards era
-> NodeConfigFile 'In
-- ^ Path to the cardano-node config file (e.g. <path to cardano-node project>/configuration/cardano/mainnet-config.json)
-> SocketPath
-- ^ Path to local cardano-node socket. This is the path specified by the @--socket-path@ command line option when running the node.
Expand Down Expand Up @@ -415,13 +416,13 @@ foldBlocks
-- truncating the last k blocks before the node's tip.
-> t m a
-- ^ The final state
foldBlocks nodeConfigFilePath socketPath validationMode state0 accumulate = handleExceptions $ do
foldBlocks aeo nodeConfigFilePath socketPath validationMode state0 accumulate = handleExceptions $ do
-- NOTE this was originally implemented with a non-pipelined client then
-- changed to a pipelined client for a modest speedup:
-- * Non-pipelined: 1h 0m 19s
-- * Pipelined: 46m 23s

(env, ledgerState) <- modifyError FoldBlocksInitialLedgerStateError $ initialLedgerState nodeConfigFilePath
(env, ledgerState) <- modifyError FoldBlocksInitialLedgerStateError $ initialLedgerState aeo nodeConfigFilePath

-- Place to store the accumulated state
-- This is a bit ugly, but easy.
Expand Down Expand Up @@ -1822,8 +1823,9 @@ instance Show AnyNewEpochState where
-- function only terminates if the condition is met or we have reached the termination epoch. We need to
-- provide a termination epoch otherwise blocks would be applied indefinitely.
foldEpochState
:: forall t m s. MonadIOTransError FoldBlocksError t m
=> NodeConfigFile 'In
:: forall t m s era. MonadIOTransError FoldBlocksError t m
=> AlonzoEraOnwards era
-> NodeConfigFile 'In
-- ^ Path to the cardano-node config file (e.g. <path to cardano-node project>/configuration/cardano/mainnet-config.json)
-> SocketPath
-- ^ Path to local cardano-node socket. This is the path specified by the @--socket-path@ command line option when running the node.
Expand All @@ -1850,14 +1852,14 @@ foldEpochState
-- truncating the last k blocks before the node's tip.
-> t m (ConditionResult, s)
-- ^ The final state
foldEpochState nodeConfigFilePath socketPath validationMode terminationEpoch initialResult checkCondition = handleExceptions $ do
foldEpochState aeo nodeConfigFilePath socketPath validationMode terminationEpoch initialResult checkCondition = handleExceptions $ do
-- NOTE this was originally implemented with a non-pipelined client then
-- changed to a pipelined client for a modest speedup:
-- * Non-pipelined: 1h 0m 19s
-- * Pipelined: 46m 23s

(env, ledgerState) <- modifyError FoldBlocksInitialLedgerStateError
$ initialLedgerState nodeConfigFilePath
$ initialLedgerState aeo nodeConfigFilePath

-- Place to store the accumulated state
-- This is a bit ugly, but easy.
Expand Down

0 comments on commit 3868745

Please sign in to comment.