diff --git a/plutus-pab-executables/tx-inject/config.yaml b/plutus-pab-executables/tx-inject/config.yaml index dd60530d17..b9ddcad6bf 100644 --- a/plutus-pab-executables/tx-inject/config.yaml +++ b/plutus-pab-executables/tx-inject/config.yaml @@ -13,18 +13,18 @@ walletServerConfig: baseUrl: http://localhost:9081 nodeServerConfig: - mscBaseUrl: http://localhost:9082 - mscSocketPath: /tmp/node-server.sock - mscKeptBlocks: 100000 - mscNetworkId: "1097911063" - mscSlotConfig: + pscBaseUrl: http://localhost:9082 + pscSocketPath: /tmp/node-server.sock + pscKeptBlocks: 100000 + pscNetworkId: "1097911063" + pscSlotConfig: scSlotZeroTime: 1596059091000 # Wednesday, July 29, 2020 21:44:51 - shelley launch time in milliseconds scSlotLength: 1000 # In milliseconds - mscFeeConfig: + pscFeeConfig: fcConstantFee: getLovelace: 10 # Constant fee per transaction in lovelace fcScriptsFeeFactor: 1.0 # Factor by which to multiply size-dependent scripts fee in lovelace - mscInitialTxWallets: + pscInitialTxWallets: - getWallet: 1 - getWallet: 2 - getWallet: 3 @@ -35,7 +35,7 @@ nodeServerConfig: - getWallet: 8 - getWallet: 9 - getWallet: 10 - mscNodeMode: AlonzoNode + pscNodeMode: AlonzoNode chainIndexConfig: ciBaseUrl: http://localhost:9083 diff --git a/plutus-pab/src/Cardano/Node/Client.hs b/plutus-pab/src/Cardano/Node/Client.hs index 7ed579df84..8219fc7d88 100644 --- a/plutus-pab/src/Cardano/Node/Client.hs +++ b/plutus-pab/src/Cardano/Node/Client.hs @@ -1,6 +1,7 @@ {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE GADTs #-} +{-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeOperators #-} @@ -15,8 +16,9 @@ import Ledger.TimeSlot (SlotConfig) import Servant (NoContent, (:<|>) (..)) import Servant.Client (ClientM, client) +import Cardano.Api.NetworkId.Extra (NetworkIdWrapper (..)) import Cardano.Node.API (API) -import Cardano.Node.Types (ChainSyncHandle, PABServerConfig, PABServerLogMsg) +import Cardano.Node.Types (ChainSyncHandle, NodeMode (..), PABServerConfig (..), PABServerLogMsg) import Cardano.Protocol.Socket.Client qualified as Client import Cardano.Protocol.Socket.Mock.Client qualified as MockClient import Control.Monad.Freer.Extras.Log (LogMessage) @@ -51,8 +53,22 @@ handleNodeClientClient slotCfg e = do either (liftIO . MockClient.getCurrentSlot) (liftIO . Client.getCurrentSlot) chainSyncHandle GetClientSlotConfig -> pure slotCfg +-- | This does not seem to support resuming so it means that the slot tick will +-- be behind everything else. This is due to having 2 connections to the node +-- one for chainSync/block transfer and one for chainSync/currentSlot information. +-- TODO: Think about merging the two functionalities, or keep them in sync. runChainSyncWithCfg :: PABServerConfig -> IO ChainSyncHandle -runChainSyncWithCfg = undefined - +runChainSyncWithCfg PABServerConfig { pscSocketPath + , pscNodeMode + , pscNetworkId + , pscSlotConfig } = + case pscNodeMode of + AlonzoNode -> + Right <$> Client.runChainSync' pscSocketPath + pscSlotConfig + (unNetworkIdWrapper pscNetworkId) + [] + MockNode -> + Left <$> MockClient.runChainSync' pscSocketPath pscSlotConfig diff --git a/plutus-pab/src/Plutus/PAB/App.hs b/plutus-pab/src/Plutus/PAB/App.hs index bf87015a74..2c631ea7fa 100644 --- a/plutus-pab/src/Plutus/PAB/App.hs +++ b/plutus-pab/src/Plutus/PAB/App.hs @@ -33,7 +33,7 @@ import Cardano.Api.ProtocolParameters () import Cardano.Api.Shelley (ProtocolParameters) import Cardano.BM.Trace (Trace, logDebug) import Cardano.ChainIndex.Types qualified as ChainIndex -import Cardano.Node.Client (handleNodeClientClient) +import Cardano.Node.Client (handleNodeClientClient, runChainSyncWithCfg) import Cardano.Node.Types (ChainSyncHandle, NodeMode (AlonzoNode, MockNode), PABServerConfig (PABServerConfig, pscBaseUrl, pscNetworkId, pscNodeMode, pscProtocolParametersJsonPath, pscSlotConfig, pscSocketPath)) import Cardano.Protocol.Socket.Mock.Client qualified as MockClient @@ -250,7 +250,7 @@ data StorageBackend = BeamSqliteBackend | InMemoryBackend mkEnv :: Trace IO (PABLogMsg (Builtin a)) -> Config -> IO (AppEnv a) mkEnv appTrace appConfig@Config { dbConfig - , nodeServerConfig = PABServerConfig{pscBaseUrl, pscSocketPath, pscSlotConfig, pscProtocolParametersJsonPath} + , nodeServerConfig = PABServerConfig{pscBaseUrl, pscSocketPath, pscProtocolParametersJsonPath} , walletServerConfig , chainIndexConfig } = do @@ -260,7 +260,7 @@ mkEnv appTrace appConfig@Config { dbConfig dbConnection <- dbConnect appTrace dbConfig txSendHandle <- liftIO $ MockClient.runTxSender pscSocketPath -- This is for access to the slot number in the interpreter - chainSyncHandle <- Left <$> (liftIO $ MockClient.runChainSync' pscSocketPath pscSlotConfig) + chainSyncHandle <- runChainSyncWithCfg $ nodeServerConfig appConfig appInMemContractStore <- liftIO initialInMemInstances protocolParameters <- maybe (pure def) readPP pscProtocolParametersJsonPath pure AppEnv {..}