-
Notifications
You must be signed in to change notification settings - Fork 86
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
Shelley: choose the right initial nonce #2005
Comments
I think the easiest thing to do for this is to seed the nonce with some randomness we can insert in |
@JaredCorduan With all these discussions about nonces, I don't know what the final decisions were 😕. Let me go over the places in consensus where we currently pick a nonce so we can check whether we make the right choice. A fresh Shelley chainWhen starting a Shelley chain from scratch, like in the F&F testnet, we call Looking at Question 1: Is this correct? The alternative is to create a nonce from the hash of the Shelley genesis config file and pass that to The Byron-to-Shelley hard forkWhen transitioning from Byron to Shelley, we have to translate the Byron protocol state to the Shelley protocol state ( Question 2: Is this correct? The alternative is again to create a nonce from the hash of the Shelley genesis config file and use that for all four nonces, or just the first three (so not the "Prev epoch hash nonce"). Note that we don't have access to the last Byron hash as we don't track it in the |
Thank you for such a clear and organized question @mrBliss ! We can do the same thing for both a fresh Shelley chain and a chain from Byron. We should set "Current epoch nonce", "Evolving nonce", and "Candidate nonce" to the same value X, and the "Prev epoch hash nonce" to the For a bit of explanation: At the start of an epoch, the "Current epoch nonce", "Evolving nonce", and "Candidate nonce" will always be the same value (equal to each other, not the same value between epochs :) ). The "Prev epoch hash nonce" does not matter at the start of the epoch, we just store this value so that when a new epoch begins we can use the hash of the last block in the previous epoch to create the next Current epoch nonce. In other words, the "Prev epoch hash nonce" will just be immediately overridden on the next block. So |
Thank you for the clear answer! I'll start implementing this now (I can backtrack if the cryptographers disagree).
I see. The last part I remembered. Crystal clear now 👍 |
I'm not sure if this is already supported by the above discussion, but the tests should be able to twiddle the initial Shelley nonce independently for the sake of statistical testing and similar. So it'd be good to parameterize the initial nonce selection at least out to the interface that testing should use. |
I'm still awaiting a decision on how to compute the genesis hash in IntersectMBO/cardano-ledger#1558 (comment). However, I can already parameterise the code ( |
Fixes #2005. This nonce will be used to construct Shelley's initial `PrtclState`, both when starting a fresh Shelley chain and when forking from Byron to Shelley (when translating the Byron `ConsensusState` to the Shelley one). We store the initial nonce in the `TPraosParams`, which is part of the `ConsensusConfig` for `TPraos`. We need it here, at run-time, because we need it when translating the Byron `ConsensusState` to the Shelley one. `protocolInfoShelley` and `protocolInfoCardano` (as well as `ProtocolReadTPraos` and `ProtocolCardano`) now take a `Nonce` argument that will be used as the initial nonce. Typically the `Nonce` passed to these functions (constructors) should be derived from the hash of the Shelley Genesis config JSON file. Moreover, this allows us to choose a different initial nonce for testing purposes, as required for #2235. NOTE: up until now we have used `SL.NeutralNonce` as the initial nonce for Shelley. When a different nonce is picked in `cardano-node`, i.e., one derived from the hash of the Shelley Genesis config JSON file, it would cause a hard fork.
Quoting from IntersectMBO/cardano-ledger#1531 (comment):
|
Fixes #2005. This nonce will be used to construct Shelley's initial `PrtclState`, both when starting a fresh Shelley chain and when forking from Byron to Shelley (when translating the Byron `ChainDepState` to the Shelley one). We store the initial nonce in the `TPraosParams`, which is part of the `ConsensusConfig` for `TPraos`. We need it here, at run-time, because we need it when translating the Byron `ChainDepState` to the Shelley one. `protocolInfoShelley` and `protocolInfoCardano` (as well as `ProtocolRealTPraos` and `ProtocolCardano`) now take a `Nonce` argument that will be used as the initial nonce. Typically the `Nonce` passed to these functions (constructors) should be derived from the hash of the Shelley Genesis config JSON file. Moreover, this allows us to choose a different initial nonce for testing purposes, as required for #2235. NOTE: up until now we have used `SL.NeutralNonce` as the initial nonce for Shelley. When a different nonce is picked in `cardano-node`, i.e., one derived from the hash of the Shelley Genesis config JSON file, it would cause a hard fork.
2289: Shelley/Cardano: take the initial nonce as a parameter r=mrBliss a=mrBliss Fixes #2005. This nonce will be used to construct Shelley's initial `PrtclState`, both when starting a fresh Shelley chain and when forking from Byron to Shelley (when translating the Byron `ChainDepState` to the Shelley one). We store the initial nonce in the `TPraosParams`, which is part of the `ConsensusConfig` for `TPraos`. We need it here, at run-time, because we need it when translating the Byron `ChainDepState` to the Shelley one. `protocolInfoShelley` and `protocolInfoCardano` (as well as `ProtocolRealTPraos` and `ProtocolCardano`) now take a `Nonce` argument that will be used as the initial nonce. Typically the `Nonce` passed to these functions (constructors) should be derived from the hash of the Shelley Genesis config JSON file. Moreover, this allows us to choose a different initial nonce for testing purposes, as required for #2235. NOTE: up until now we have used `SL.NeutralNonce` as the initial nonce for Shelley. When a different nonce is picked in `cardano-node`, i.e., one derived from the hash of the Shelley Genesis config JSON file, it would cause a hard fork. Co-authored-by: Thomas Winant <thomas@well-typed.com>
Fix this TODO:
https://github.com/input-output-hk/ouroboros-network/blob/eec4a136bb51d882ab4cf4de552f1ce978459f56/ouroboros-consensus-shelley/src/Ouroboros/Consensus/Shelley/Node.hs#L209
The text was updated successfully, but these errors were encountered: