Skip to content

Commit

Permalink
Support ProtocolInfo with forging credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
kderme committed Nov 28, 2021
1 parent 569e25d commit 97205b4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cardano-db-sync/src/Cardano/DbSync/Api.hs
Expand Up @@ -122,7 +122,7 @@ mkSyncEnvFromConfig trce backend syncOptions dir genCfg =
, " /= ", DB.textShow (Shelley.sgSystemStart $ scConfig sCfg)
]
| otherwise ->
Right <$> mkSyncEnv trce backend syncOptions (mkProtocolInfoCardano genCfg) (Shelley.sgNetworkId $ scConfig sCfg)
Right <$> mkSyncEnv trce backend syncOptions (mkProtocolInfoCardano genCfg []) (Shelley.sgNetworkId $ scConfig sCfg)
(NetworkMagic . unProtocolMagicId $ Byron.configProtocolMagicId bCfg)
(SystemStart .Byron.gdStartTime $ Byron.configGenesisData bCfg)
dir (calculateStableEpochSlot $ scConfig sCfg)
Expand Down
12 changes: 7 additions & 5 deletions cardano-db-sync/src/Cardano/DbSync/Config/Cardano.hs
Expand Up @@ -37,7 +37,7 @@ import Ouroboros.Consensus.Ledger.Basics (LedgerConfig)
import qualified Ouroboros.Consensus.Mempool.TxLimits as TxLimits
import Ouroboros.Consensus.Node.ProtocolInfo (ProtocolInfo)
import qualified Ouroboros.Consensus.Node.ProtocolInfo as Consensus
import Ouroboros.Consensus.Shelley.Eras (StandardShelley)
import Ouroboros.Consensus.Shelley.Eras (StandardShelley, StandardCrypto)
import Ouroboros.Consensus.Shelley.Node (ShelleyGenesis (..))


Expand Down Expand Up @@ -69,15 +69,17 @@ cardanoLedgerConfig :: GenesisConfig -> LedgerConfig CardanoBlock
cardanoLedgerConfig = topLevelConfigLedger . mkTopLevelConfig

mkTopLevelConfig :: GenesisConfig -> TopLevelConfig CardanoBlock
mkTopLevelConfig = Consensus.pInfoConfig . mkProtocolInfoCardano
mkTopLevelConfig cfg = Consensus.pInfoConfig $ mkProtocolInfoCardano cfg []

-- Need a concrete type for 'm' ('IO') to make the type checker happy.
-- | The vast majority of the following struct fields are *COMPLETELY IRRELEVANT* to the
-- operation of db-sync, but I have no idea at all what happens of any of these are
-- wrong. This really needs to be a done a different way.
-- mkProtocolCardano :: GenesisConfig -> Protocol m CardanoBlock CardanoProtocol
mkProtocolInfoCardano :: GenesisConfig -> ProtocolInfo IO CardanoBlock
mkProtocolInfoCardano ge =
mkProtocolInfoCardano :: GenesisConfig
-> [Consensus.TPraosLeaderCredentials StandardCrypto] -- this is not empty only in tests
-> ProtocolInfo IO CardanoBlock
mkProtocolInfoCardano ge shelleyCred =
case ge of
GenesisCardano dnc byronGenesis shelleyGenesis alonzoGenesis ->
Consensus.protocolInfoCardano
Expand All @@ -92,7 +94,7 @@ mkProtocolInfoCardano ge =
Consensus.ProtocolParamsShelleyBased
{ Consensus.shelleyBasedGenesis = scConfig shelleyGenesis
, Consensus.shelleyBasedInitialNonce = shelleyPraosNonce shelleyGenesis
, Consensus.shelleyBasedLeaderCredentials = []
, Consensus.shelleyBasedLeaderCredentials = shelleyCred
}
Consensus.ProtocolParamsShelley
{ Consensus.shelleyProtVer = shelleyProtVer dnc
Expand Down

0 comments on commit 97205b4

Please sign in to comment.