IntersectMBO / ouroboros-network

Specifications of network protocols and implementations of components running these protocols which support a family of Ouroboros Consesus protocols; the diffusion layer of the Cardano Node.
https://ouroboros-network.cardano.intersectmbo.org
Apache License 2.0
276 stars 86 forks source link

Block-specific arguments for db-analyser and db-validator #2460

Closed mrBliss closed 4 years ago

mrBliss commented 4 years ago

The ProtocolInfo for Byron, Shelley, and Cardano hard-code some parameters:

    protocolInfoShelley
      genesis
      NeutralNonce -- TODO -- <-
      2000
      (SL.ProtVer 0 0) -- <-
      Nothing

In particular: (Just $ PBftSignatureThreshold 0.22) for Byron, which is different from the value used on mainnet_candidate (0.9), making it impossible to use these tools for mainnet_candidate or any other nets that use different parameters than mainnet.

We already have two Byron-specific arguments:

  , requiresNetworkMagic :: w ::: Bool            <?> "Expecto patronum?"
  , genesisHash          :: w ::: Hash CB.Raw     <?> "Expected genesis hash"

We shouldn't keep adding all arguments in one place, we should start making such arguments specific to the block type. We can use optparse-applicative commands for this.

Additionally: there is quite a bit of code duplicated between the two, e.g., the protocolMagicId business, BlockType, the parser for block-specific configuration arguments, etc. Common parts should become library code shared between the two executables.

kderme commented 4 years ago

Maybe related to the hard-coded params, I sometimes get errors like

TraceInitChainSelEvent (InitChainSelValidation (InvalidBlock (ExtValidationErrorHeader (HeaderProtocolError 
(HardForkValidationErrFromEra S (Z (WrapValidationErr {unwrapValidationErr = ChainTransitionError [OverlayFailure (VRFKeyBadNonce (Nonce "81e47a19e6b29b0a65b9591762ce5143ed30d0261e5d24a3201752506b20f15c") (SlotNo {unSlotNo 
= 4492800}) (Nonce "81e47a19e6b29b0a65b9591762ce5143ed30d0261e5d24a3201752506b20f15c") (CertifiedVRF 
{certifiedOutput = OutputVRF {getOutputVRFBytes = 
"6\236Sx\209\245\EOT\SUBY\235\141\150\230\GS\233o\tP\251A\180\159\245\DC1\247\188\DEL\209\t\212\&8>\GS$\190p4\23
0t\156f\DC2p\r\213\206\176\198ew\184\138\EM\174(k\DC3!\209[\206\SUB\183\&6"}, certifiedProof = CertPraosVRF 
"@Z\163p\255\NUL\149D\162\190J\165\188R\196Ec3\244\249\182W\GSf\197Y\r.V)\208\139:6\t\244\189\ENQ\STX\237]\v\225\1
71\219\DEL*\183j\174\174G\254\DC1\ESC\ETX5\164\228\222\246F\147\SYN'\148\184\211\193\202qP\SI\SYN\177\226DrL\ETX
"}))]}))))) (RealPoint (SlotNo {unSlotNo = 4492800}) 
aa83acbf5904c0edfe4d79b3689d3d00fcfc553cf360fd2229b98d464c28e9de)))

TraceInitChainSelEvent (InitChainSelValidation (ValidCandidate (AnchoredFragment {anchor = Anchor (SlotNo {unSlotNo = 
4492799}) f8084c61b6a238acec985b59310b6ecec49c0ab8352249afd7268da5cff2a457 (BlockNo {unBlockNo = 4490510}), 
unanchorFragment = ChainFragment (SFT (fromList []))})))

when I validate post hard-fork.

mrBliss commented 4 years ago

That error is exactly because that NeutralNonce should be replaced with a nonce based on the hash of the Shelley genesis file (i.e. https://github.com/input-output-hk/cardano-node/blob/46ec7473cc7ecf1f9fc6ee5e87f592371dd3dadd/cardano-node/src/Cardano/Node/Protocol/Cardano.hs#L169), which should be one of the Shelley/Cardano-specific arguments. (Idea: could we define the Cardano-specific arguments as the combination of Byron- and Shelley-specific arguments, and some extra arguments? I.e., by reusing them, not copy-pasting them)