Skip to content

cardano-testnet: Split CardanoTestnetOptions into EnvCreationOptions and RuntimeOptions #6459

@palas

Description

@palas

Problem

CardanoTestnetOptions is a single record used by both createTestnetEnv (step 1: environment creation) and cardanoTestnet (step 2: runtime). However, many fields are only used by one phase:

  • Step 1 only: cardanoNodeEra, cardanoMaxSupply, cardanoNumDReps
  • Step 2 only: cardanoEnableNewEpochStateLogging, cardanoEnableTxGenerator
  • Shared: cardanoNodes
  • Unused by either function: cardanoNodeLoggingFormat, cardanoOutputDir (used only in the parser layer)

This means create-env silently accepts and ignores runtime-only flags like --enable-new-epoch-state-logging, and step-2 code has access to step-1-only fields it should never read.

Proposed fix

Split CardanoTestnetOptions into two records:

data EnvCreationOptions = EnvCreationOptions
  { envNodes     :: NonEmpty NodeOption
  , envNodeEra   :: AnyShelleyBasedEra
  , envMaxSupply :: Word64
  , envNumDReps  :: NumDReps
  }

data RuntimeOptions = RuntimeOptions
  { rtNodes                      :: NonEmpty NodeOption
  , rtEnableNewEpochStateLogging :: Bool
  , rtEnableTxGenerator          :: TxGeneratorSupport
  }

Update createTestnetEnv to take EnvCreationOptions and cardanoTestnet to take RuntimeOptions. The compiler will enforce that each phase can only access its own fields.

Depends on

Type: Refactoring

Effort: Medium (~80 lines across Types.hs, Cardano.hs, Parsers/Cardano.hs, Parsers/Run.hs)

Risk: Low-medium (mechanical — compiler guides every call site update)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions