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

cardano-testnet | configurable SPO and relays count, enable parallel execution of the test suite #6007

Merged

Conversation

carbolymer
Copy link
Contributor

@carbolymer carbolymer commented Oct 10, 2024

Description

This PR changes default testnet configuration to start with 1 SPO and 2 Relay nodes. This PR also makes the testnet nodes count and role (SPO/relay) configurable.

It also reenables previously disabled tests, and runs them in parallel, reducing test suite execution time.

Things still not working yet:

  • tests requiring more than SPO

Related:

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated. These may include:
    • golden tests
    • property tests
    • roundtrip tests
    • integration tests
      See Runnings tests for more details
  • Any changes are noted in the CHANGELOG.md for affected package
  • The version bounds in .cabal files are updated
  • CI passes. See note on CI. The following CI checks are required:
    • Code is linted with hlint. See .github/workflows/check-hlint.yml to get the hlint version
    • Code is formatted with stylish-haskell. See .github/workflows/stylish-haskell.yml to get the stylish-haskell version
    • Code builds on Linux, MacOS and Windows for ghc-8.10.7 and ghc-9.2.7
  • Self-reviewed the diff

Note on CI

If your PR is from a fork, the necessary CI jobs won't trigger automatically for security reasons.
You will need to get someone with write privileges. Please contact IOG node developers to do this
for you.

@carbolymer carbolymer changed the title Mgalazyn/feature/enable configurable testnet topology cardano-testnet | configurable SPO and relays count Oct 10, 2024
@carbolymer carbolymer changed the title cardano-testnet | configurable SPO and relays count cardano-testnet | configurable SPO and relays count, enable parallel execution of the test suite Oct 10, 2024
@carbolymer carbolymer force-pushed the mgalazyn/feature/enable-configurable-testnet-topology branch 3 times, most recently from bc21882 to f6be47e Compare October 10, 2024 13:42
@carbolymer carbolymer marked this pull request as ready for review October 10, 2024 14:01
@carbolymer carbolymer requested a review from a team as a code owner October 10, 2024 14:01
Copy link
Contributor

@Jimbo4350 Jimbo4350 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments. Please break this PR up into smaller commits with informative commit messages.

<> OA.showDefault
<> OA.value 1)
where
defaultSpoOptions = TestnetNodeOptions TestnetNodeRoleSpo Nothing []

_pSpo :: Parser TestnetNodeOptions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can delete this in a follow up PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI the removal is done in #6008

cardano-testnet/src/Testnet/Defaults.hs Outdated Show resolved Hide resolved
cardano-testnet/src/Testnet/Start/Cardano.hs Outdated Show resolved Hide resolved
. encode $ Defaults.defaultByronProtocolParamsJsonValue

-- Because in Conway the overlay schedule and decentralization parameter
-- are deprecated, we must use the "create-staked" cli command to create
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove this comment in a follow up PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed in: #6008

let paymentAddrFile = tmpAbsPath </> "utxo-keys" </> "utxo" <> show idx </> "utxo.addr"

execCli_
[ "address", "build"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will cause failures in the 9.3 release branch if merged to master. address was removed from the top level however we are going to reintroduce it as it is era agnostic 🫠 .

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I'll keep an eye on it.

cardano-testnet/src/Testnet/Start/Types.hs Outdated Show resolved Hide resolved
@carbolymer carbolymer force-pushed the mgalazyn/feature/enable-configurable-testnet-topology branch 10 times, most recently from 11db08a to 130551d Compare October 11, 2024 09:23
@smelc
Copy link
Contributor

smelc commented Oct 11, 2024

FYI I'll merge #6008 after this one. The two are highly conflictual.

Copy link
Contributor

@Jimbo4350 Jimbo4350 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

-- > ├── delegate-keys
-- > │   ├── delegate{1,2,3}
-- > │   │   ├── kes.{skey,vkey}
-- > │   │   ├── key.{skey,vkey}
-- > │   │   ├── opcert.{cert,counter}
-- > │   │   ── vrf.{skey,vkey}
-- > │   │   ── vrf.{skey,vkey}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

-- > │   │   ├── staking.{skey,vkey}
-- > ├── utxo-keys
-- > │   ├── utxo{1,2,3}
-- > │   │   ├── utxo.{addr,skey,vkey}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you manually update these changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I did.

@smelc any tips how to make this less error-prone?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@carbolymer> I ran tree on the content of a sandbox created by running the tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did the same, but the de-duplication part is what's annoying and error-prone.

_ <- createSPOGenesisAndFiles nPools nDReps maxSupply asbe shelleyGenesis alonzoGenesis conwayGenesis (TmpAbsolutePath tmpAbsPath)

-- TODO: This should come from the configuration!
let makePathsAbsolute :: (Element a ~ FilePath, MonoFunctor a) => a -> a
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. How did you come across MonoFunctor?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remember now. I think I saw a presentation mentioning it some time ago.

, poolKeys :: PoolNodeKeys
data TestnetNode = TestnetNode
{ testnetNodeRuntime :: !NodeRuntime
, poolKeys :: Maybe SpoNodeKeys -- ^ Keys are only present for SPO nodes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should move poolKeys into NodeRuntime if possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't sure about that. NodeRuntime is more about the system process itself like sockets, system handles etc. TestnetNode is rather for describing logical layer, like keys here.

With the amount of information we have now it can be one datatype I guess.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@carbolymer carbolymer force-pushed the mgalazyn/feature/enable-configurable-testnet-topology branch from 130551d to 8ec596d Compare October 14, 2024 06:38
@carbolymer carbolymer force-pushed the mgalazyn/feature/enable-configurable-testnet-topology branch from 8ec596d to c4d12d1 Compare October 14, 2024 08:04
-- > │   └── drep.{skey,vkey}
-- > ├── genesis.{alonzo,conway}.spec.json
-- > │   ├── drep{1,2,3}
-- > │   │   └── drep.{skey,drep.vkey}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
-- > │   │   └── drep.{skey,drep.vkey}
-- > │   │   └── drep.{skey,vkey}

The drep.{skey,vkey} notation actually means drep.skey, drep.vkey; when you unfold the brackets (as would bash do).

Copy link
Contributor Author

@carbolymer carbolymer Oct 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right, sorry. A typo got in where I was doing those changes without thinking much.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed in: #6008

Comment on lines +23 to +24
, isSpoNodeOptions
, isRelayNodeOptions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I am not a big fan of exporting small helper functions like this. Users could just pattern match on the constructors, instead of using those functions.

Optional.

Copy link
Contributor Author

@carbolymer carbolymer Oct 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those functions are more readable than pattern matching on the constructor. This is more readable to me

when (isSpoNodeOptions nodeOptions) $ do
  ...     

rather than more noisy case:

case nodeOptions of
  RelayNodeOptions{} -> pure ()
  SpoNodeOptions{} -> do
    ...

Additionally, if you have a dedicated function, you can compose it.

Comment on lines +67 to +71
, cardanoNodes =
[ SpoNodeOptions Nothing []
, SpoNodeOptions Nothing []
, SpoNodeOptions Nothing []
]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
, cardanoNodes =
[ SpoNodeOptions Nothing []
, SpoNodeOptions Nothing []
, SpoNodeOptions Nothing []
]
, cardanoNodes = repeat 3 $ SpoNodeOptions Nothing []

@@ -79,6 +85,13 @@ data KeyPair k = KeyPair
, signingKey :: forall dir. (File (SKey k) dir)
}

type instance Element (KeyPair k) = FilePath
instance MonoFunctor (KeyPair k) where
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL MonoFunctor 😉 (it's nice!)

-- replicate votes requested number of times
mkVotes :: [(Int, String)] -- ^ [(count, vote)]
-> [(String, Int)] -- ^ [(vote, ordering number)]
mkVotes votes = zip (concatMap (uncurry replicate) votes) [1..]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice change 👍

Comment on lines +59 to +63
, cardanoNodes =
[ SpoNodeOptions Nothing []
, SpoNodeOptions Nothing []
, SpoNodeOptions Nothing []
]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
, cardanoNodes =
[ SpoNodeOptions Nothing []
, SpoNodeOptions Nothing []
, SpoNodeOptions Nothing []
]
, cardanoNodes = repeat 3 $ SpoNodeOptions Nothing []

@carbolymer carbolymer added this pull request to the merge queue Oct 14, 2024
Merged via the queue into master with commit 6beea61 Oct 14, 2024
23 of 26 checks passed
@carbolymer carbolymer deleted the mgalazyn/feature/enable-configurable-testnet-topology branch October 14, 2024 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants