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

Randomize initial nonce in Praos tests #2235

Closed
nfrisby opened this issue Jun 9, 2020 · 0 comments · Fixed by #2491
Closed

Randomize initial nonce in Praos tests #2235

nfrisby opened this issue Jun 9, 2020 · 0 comments · Fixed by #2491
Assignees
Labels
consensus issues related to ouroboros-consensus praos testing

Comments

@nfrisby
Copy link
Contributor

nfrisby commented Jun 9, 2020

In mock Praos and RealTPraos, the genesis block is currently initialized with the same fixed nonce every time. If I understand correctly, that means the leader schedule for the first epoch is similarly fixed. Especially once we start with statistical testing (eg for CG/CP violation rates), we'll want our samples to be more independent than that.

Thus this Issue is to have the tests' QuickCheck generators determine the initial nonce.

@mrBliss mrBliss added the consensus issues related to ouroboros-consensus label Jun 9, 2020
mrBliss added a commit that referenced this issue Jun 18, 2020
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` now take a `Maybe Nonce`
argument to allow overriding the default initial nonce for testing purposes,
as required for #2235.

When the nonce is not overridden, it defaults to `SL.NeutralNonce`, just like
before. However, in the future, we want to use the hash of the Shelley genesis
config as the default.

We don't expose the ability to override the initial nonce to `cardano-node`,
we just pick the default one (`Nothing`) in the `protocolInfo` function.

NOTE: we must be careful if we change the default from `SL.NeutralNonce` to
the Shelley genesis hash in `protocolInfoShelley`. This change would be
incompatible with already deployed testnets, which are using
`SL.NeutralNonce`, causing a fork.
mrBliss added a commit that referenced this issue Jun 26, 2020
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.
mrBliss added a commit that referenced this issue Jun 26, 2020
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.
mrBliss added a commit that referenced this issue Jun 26, 2020
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.
iohk-bors bot added a commit that referenced this issue Jun 26, 2020
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>
@mrBliss mrBliss added this to the S19 2020-08-13 milestone Jul 27, 2020
iohk-bors bot added a commit that referenced this issue Aug 10, 2020
2491: Vary initial nonce in mock Praos and pure Shelley ThreadNet tests r=nfrisby a=nfrisby

Fixes #2235.

Co-authored-by: Nicolas Frisby <nick.frisby@iohk.io>
Co-authored-by: iohk-bors[bot] <43231472+iohk-bors[bot]@users.noreply.github.com>
@iohk-bors iohk-bors bot closed this as completed in 3a83c64 Aug 10, 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 praos testing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants