Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

passing a singletonSlotLengths to realBlockchainTime is almost certainly incorrect if an adopted update proposal ever changed the slot duration protocol parameter #1725

Closed
nfrisby opened this issue Feb 28, 2020 · 2 comments
Labels
consensus issues related to ouroboros-consensus wontfix This will not be worked on

Comments

@nfrisby
Copy link
Contributor

nfrisby commented Feb 28, 2020

While preparing for #1514 (add update proposals to RealPBFT tests), I noticed two things.

First, the slot duration is one of the protocol parameters that an update proposal can change -- see ppuSlotDuration in the cardano-ledger repo.

Second, the current Byron implementation via ouroboros-consensus and ouroboros-consensus-byron implicitly assume that no update has ever changed the slot duration.

Node.run includes

    realBlockchainTime ...
        (nodeStartTime (Proxy @blk) cfg)
        (focusSlotLengths (knownSlotLengths (configBlock cfg)))

but knownSlotLengths ignores any adopted update proposals, whether they be in the anticipatable future (see Issue #1637) or in the known past (this Issue).

instance LedgerDerivedInfo ByronBlock where
  knownSlotLengths =
        singletonSlotLengths
      . slotLengthFromMillisec
      . (fromIntegral :: Natural -> Integer)
      . CC.ppSlotDuration
      . Gen.configProtocolParameters
      . byronGenesisConfig

I suppose the above could possibly achieve the correct behavior if the nodeStartTime were somewhat abused and referred to the time at which that latest slot length was adopted, but that's not what's currently happening (unless I'm taking the name GenesisData too literally; it is data from the genesis block, right?).

  nodeStartTime             = const
                            $ SystemStart
                            . Genesis.gdStartTime
                            . Genesis.configGenesisData
                            . byronGenesisConfig
                            . configBlock

Therefore, unless no update proposal will ever change the slot duration, we likely need some changes. Two more notable observations.

  • In order for knownSlotLengths to be fully correct, it would need an up-to-date immutable database and to read the entire history therein of updates to the slot duration protocol parameter. (If a node realizes it started with a partial history, then it may need to restart again after syncing more.)

  • The slot duration seems to be the only updatable parameters that, in the current implementation, requires a node restart in order to adopt a new value. (Edit:) Also, the max block size insomuch as it affects the max size of the mempool, requires a restarts (what else is there?). For all other parameters, I've only seen their values read from the latest ChainValidationState as needed (they're used in cardano-ledger when validating various things).

If we alter the node so that it need not restart on changes to slot duration, would update proposals that only change protocol parameters (and not software version) then never require the node to restart? (Edit: No. I've found at least one more value that's cached on start-up: the mempool's max size may depend on the current value of ppMaxBlockSize.)

@nfrisby nfrisby added the consensus issues related to ouroboros-consensus label Feb 28, 2020
@nfrisby
Copy link
Contributor Author

nfrisby commented Feb 29, 2020

Ah. I have now found IntersectMBO/cardano-ledger#642

However, it's not quite clear to me what the ultimately intended correct behavior is. For example, has the parameter ever changed in the mainnet history? Should it ever be able to change in the future? In the remaining Byron era? In the Shelley era? Etc.

@edsko
Copy link
Contributor

edsko commented Mar 2, 2020

Closing this as WONTFIX, as this value is not actually updatable through the update system. You are nonetheless correct that passing singletonSlotLengths is incorrect, as the slot lengths can change as part of hard forks (and will: going down from 20secs in Byron to 2 or even 1 in Shelley), but it's not otherwise updatable. The same goes for the epoch length. I am addressing both of those things in my work on the hard fork combinator however, and will only become relevant for the Shelley mainnet release.

@edsko edsko closed this as completed Mar 2, 2020
@edsko edsko added the wontfix This will not be worked on label Mar 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
consensus issues related to ouroboros-consensus wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants