Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ math: true

- New transaction submission error [`StakePoolVrfKeyAlreadyRegistered`](https://ogmios.dev/mini-protocols/local-tx-submission#schema-3176/StakePoolVrfKeyAlreadyRegistered) (`code=3176`) when a stake pool registration or update uses a VRF key that another stake pool already uses. `data.stakePool.id` gives the pool and `data.vrfVerificationKeyHash` the VRF key hash. Before, Ogmios reported this failure as [`UnknownStakePool`](https://ogmios.dev/mini-protocols/local-tx-submission#schema-3140/UnknownStakePool) (`code=3140`), which pointed to the wrong cause.

- `queryNetwork/genesisConfiguration` accepts `"era": "dijkstra"`. It returns the initial values of the protocol parameters new in the Dijkstra era, read from the Dijkstra genesis file of the node configuration: reference-script limits and pricing, maximum pledge leverage, minimum pool margin, the PlutusV4 cost model, reference-input costs, and the Leios and Peras parameters.

#### Changed

- **⚠️ BREAKING-CHANGE ⚠️**: Ogmios now requires node-to-client version 23, which cardano-node 10.7.1 and later offer. A cardano-node that does not offer it is refused at the handshake. Ogmios then stops with an error that lists the node-to-client versions the cardano-node offers and the versions Ogmios supports, instead of a raw handshake protocol error.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
GenesisAlonzo,
GenesisByron,
GenesisConway,
GenesisDijkstra,
GenesisShelley,
GovernanceProposalReference,
Origin,
Expand Down Expand Up @@ -56,6 +57,7 @@ export interface LedgerStateQueryClient {
genesisConfiguration(era: 'shelley'): Promise<GenesisShelley>
genesisConfiguration(era: 'alonzo'): Promise<GenesisAlonzo>
genesisConfiguration(era: 'conway'): Promise<GenesisConway>
genesisConfiguration(era: 'dijkstra'): Promise<GenesisDijkstra>
ledgerTip(): ReturnType<typeof ledgerTip>
liveStakeDistribution(): ReturnType<typeof liveStakeDistribution>
networkBlockHeight(): ReturnType<typeof networkBlockHeight>
Expand Down Expand Up @@ -147,6 +149,8 @@ export async function createLedgerStateQueryClient (
return genesisConfiguration(context, era)
case 'conway':
return genesisConfiguration(context, era)
case 'dijkstra':
return genesisConfiguration(context, era)
default: {
// NOTE: This raises "Type 'string' is not assignable to type 'never'."
// whenever a branch of 'EraWithGenesis' isn't covered in the above
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
GenesisAlonzo,
GenesisByron,
GenesisConway,
GenesisDijkstra,
GenesisShelley,
EraWithGenesis
} from '@cardano-ogmios/schema'
Expand All @@ -21,11 +22,12 @@ export function genesisConfiguration(context: InteractionContext, era: 'byron'):
export function genesisConfiguration(context: InteractionContext, era: 'shelley'): Promise<GenesisShelley>
export function genesisConfiguration(context: InteractionContext, era: 'alonzo'): Promise<GenesisAlonzo>
export function genesisConfiguration(context: InteractionContext, era: 'conway'): Promise<GenesisConway>
export function genesisConfiguration(context: InteractionContext, era: 'dijkstra'): Promise<GenesisDijkstra>
export function genesisConfiguration (
context: InteractionContext,
era: EraWithGenesis
): Promise<GenesisByron | GenesisShelley | GenesisAlonzo | GenesisConway> {
return Method<Request, Response, GenesisByron | GenesisShelley | GenesisAlonzo | GenesisConway>(
): Promise<GenesisByron | GenesisShelley | GenesisAlonzo | GenesisConway | GenesisDijkstra> {
return Method<Request, Response, GenesisByron | GenesisShelley | GenesisAlonzo | GenesisConway | GenesisDijkstra>(
{
method: 'queryNetwork/genesisConfiguration',
params: { era }
Expand All @@ -40,6 +42,8 @@ export function genesisConfiguration (
resolve(response.result as GenesisAlonzo)
} else if (era === 'conway' && isQueryNetworkGenesisConfigurationConway(response)) {
resolve(response.result as GenesisConway)
} else if (era === 'dijkstra' && isQueryNetworkGenesisConfigurationDijkstra(response)) {
resolve(response.result as GenesisDijkstra)
} else {
reject(response)
}
Expand Down Expand Up @@ -75,3 +79,10 @@ export function isQueryNetworkGenesisConfigurationAlonzo (response: any): respon
export function isQueryNetworkGenesisConfigurationConway (response: any): response is GenesisConway {
return ((response as Response)?.result as GenesisConway)?.era === 'conway'
}

/**
* @internal
*/
export function isQueryNetworkGenesisConfigurationDijkstra (response: any): response is GenesisDijkstra {
return ((response as Response)?.result as GenesisDijkstra)?.era === 'dijkstra'
}
23 changes: 22 additions & 1 deletion clients/TypeScript/packages/client/test/DijkstraDevnet.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { dummyInteractionContext } from './helpers'
import { createChainSynchronizationClient } from '../src/ChainSynchronization'
import { networkTip, protocolParameters } from '../src/LedgerStateQuery'
import { genesisConfiguration, networkTip, protocolParameters } from '../src/LedgerStateQuery'
import { createMempoolMonitoringClient, MempoolMonitoringClient } from '../src/MempoolMonitoring'
import { submitTransaction } from '../src/TransactionSubmission'
import { ProtocolParameters, Transaction } from '@cardano-ogmios/schema'
Expand All @@ -14,6 +14,7 @@ const transactionId = process.env.DIJKSTRA_TX_ID
const subTransactionId = process.env.DIJKSTRA_SUB_TX_ID
const producerPid = process.env.DIJKSTRA_PRODUCER_PID
const protocolParametersFile = process.env.DIJKSTRA_PROTOCOL_PARAMETERS
const genesisFile = process.env.DIJKSTRA_GENESIS

// Pause a process with SIGSTOP, and wait until it is stopped.
const pause = async (pid: number) => {
Expand Down Expand Up @@ -243,4 +244,24 @@ describeOnDevnet('Dijkstra devnet', () => {
context.socket.close()
}
})

it('reads the same Dijkstra genesis configuration as the genesis file', async () => {
if (genesisFile === undefined) {
throw new Error('DIJKSTRA_GENESIS is not set: run this test through scripts/dijkstra-devnet-test.sh')
}
const fromFile = JSON.parse(readFileSync(genesisFile, 'utf8'))
const context = await dummyInteractionContext()
try {
const genesis = await genesisConfiguration(context, 'dijkstra')
// The genesis file uses the names of cardano-cli, and Ogmios gives the same fields as in the protocol parameters.
const parameters = genesis.updatableParameters as unknown as ProtocolParameters
const read = Object.fromEntries(Object.keys(fromFile).map(name => [
name,
name === 'plutusV4CostModel' ? parameters.plutusCostModels['plutus:v4'] : fromOgmios[name](parameters)
]))
expect(asNumbers(read)).toEqual(asNumbers(fromFile))
} finally {
context.socket.close()
}
})
})
59 changes: 57 additions & 2 deletions clients/TypeScript/packages/schema/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ export type RewardAccountSummaries = RewardAccountSummary[];
export type Delegator = {
[k: string]: unknown;
}[];
export type EraWithGenesis = "byron" | "shelley" | "alonzo" | "conway";
export type EraWithGenesis = "byron" | "shelley" | "alonzo" | "conway" | "dijkstra";
export type UtcTime = string;
/**
* A magic number for telling networks apart. (e.g. 764824073)
Expand Down Expand Up @@ -3378,7 +3378,9 @@ export interface QueryNetworkGenesisConfiguration {
export interface QueryNetworkGenesisConfigurationResponse {
jsonrpc: "2.0";
method: "queryNetwork/genesisConfiguration";
result: QueryNetworkInvalidGenesis | (GenesisByron | GenesisShelley | GenesisAlonzo | GenesisConway);
result:
| QueryNetworkInvalidGenesis
| (GenesisByron | GenesisShelley | GenesisAlonzo | GenesisConway | GenesisDijkstra);
id?: unknown;
}
export interface QueryNetworkInvalidGenesis {
Expand Down Expand Up @@ -3493,6 +3495,59 @@ export interface GenesisConway {
minFeeReferenceScripts: MinFeeReferenceScripts;
};
}
/**
* A Dijkstra genesis configuration, with the initial values of the protocol parameters new in the era. They are also updatable across the era.
*/
export interface GenesisDijkstra {
era: "dijkstra";
updatableParameters: {
minFeeReferenceScripts: {
range: UInt32;
/**
* The multiplier increasing the cost of each tier.
*/
multiplier: number;
};
maxReferenceScriptsSizePerBlock: {
bytes: UInt64;
};
maxReferenceScriptsSizePerTransaction: {
bytes: UInt64;
};
maxStakePoolPledgeLeverage: Ratio | null;
minStakePoolMargin: Ratio;
plutusCostModels: CostModels;
leiosAnnouncementPeriodLength: {
milliseconds: UInt64;
};
leiosVotePeriodLength: {
milliseconds: UInt64;
};
leiosDiffusionPeriodLength: {
milliseconds: UInt64;
};
leiosCommitteeSize: UInt16;
leiosQuorumStakeThreshold: Ratio;
maxEndorserBlockReferencesSize: {
bytes: UInt64;
};
maxEndorserBlockTransactionsSize: {
bytes: UInt64;
};
maxExecutionUnitsPerEndorserBlock: ExecutionUnits;
maxReferenceScriptsSizePerEndorserBlock: {
bytes: UInt64;
};
perasMinCandidateBlockAge: UInt32;
perasHealingFactor: Ratio;
perasCertificateBoost: UInt16;
perasTargetCommitteeSize: UInt16;
perasBootstrapRound: UInt32 | null;
perasQuorumThresholdSafetyMargin: Ratio;
referenceInputsCostPerMultiAssetPolicy: ValueAdaOnly;
referenceInputsCostPerDatumByte: UInt64;
};
}
/**
* Query the network start time.
*/
Expand Down
94 changes: 93 additions & 1 deletion docs/static/cardano.json
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,7 @@
, "EraWithGenesis":
{ "title": "EraWithGenesis"
, "type": "string"
, "enum": [ "byron", "shelley", "alonzo", "conway" ]
, "enum": [ "byron", "shelley", "alonzo", "conway", "dijkstra" ]
}

, "EraParameters":
Expand Down Expand Up @@ -1383,6 +1383,98 @@
}
}

, "Genesis<Dijkstra>":
{ "title": "Genesis<Dijkstra>"
, "type": "object"
, "description": "A Dijkstra genesis configuration, with the initial values of the protocol parameters new in the era. They are also updatable across the era."
, "additionalProperties": false
, "required":
[ "era"
, "updatableParameters"
]
, "properties":
{ "era":
{ "type": "string"
, "enum": [ "dijkstra" ]
}
, "updatableParameters":
{ "type": "object"
, "additionalProperties": false
, "required":
[ "minFeeReferenceScripts"
, "maxReferenceScriptsSizePerBlock"
, "maxReferenceScriptsSizePerTransaction"
, "maxStakePoolPledgeLeverage"
, "minStakePoolMargin"
, "plutusCostModels"
, "leiosAnnouncementPeriodLength"
, "leiosVotePeriodLength"
, "leiosDiffusionPeriodLength"
, "leiosCommitteeSize"
, "leiosQuorumStakeThreshold"
, "maxEndorserBlockReferencesSize"
, "maxEndorserBlockTransactionsSize"
, "maxExecutionUnitsPerEndorserBlock"
, "maxReferenceScriptsSizePerEndorserBlock"
, "perasMinCandidateBlockAge"
, "perasHealingFactor"
, "perasCertificateBoost"
, "perasTargetCommitteeSize"
, "perasBootstrapRound"
, "perasQuorumThresholdSafetyMargin"
, "referenceInputsCostPerMultiAssetPolicy"
, "referenceInputsCostPerDatumByte"
]
, "properties":
{ "minFeeReferenceScripts":
{ "type": "object"
, "additionalProperties": false
, "required": [ "range", "multiplier" ]
, "properties":
{ "range": { "$ref": "cardano.json#/definitions/UInt32" }
, "multiplier":
{ "type": "number"
, "description": "The multiplier increasing the cost of each tier."
}
}
}
, "maxReferenceScriptsSizePerBlock": { "$ref": "cardano.json#/definitions/NumberOfBytes" }
, "maxReferenceScriptsSizePerTransaction": { "$ref": "cardano.json#/definitions/NumberOfBytes" }
, "maxStakePoolPledgeLeverage":
{ "oneOf":
[ { "$ref": "cardano.json#/definitions/Ratio" }
, { "type": "null" }
]
}
, "minStakePoolMargin": { "$ref": "cardano.json#/definitions/Ratio" }
, "plutusCostModels": { "$ref": "cardano.json#/definitions/CostModels" }
, "leiosAnnouncementPeriodLength": { "$ref": "cardano.json#/definitions/NumberOfMilliseconds" }
, "leiosVotePeriodLength": { "$ref": "cardano.json#/definitions/NumberOfMilliseconds" }
, "leiosDiffusionPeriodLength": { "$ref": "cardano.json#/definitions/NumberOfMilliseconds" }
, "leiosCommitteeSize": { "$ref": "cardano.json#/definitions/UInt16" }
, "leiosQuorumStakeThreshold": { "$ref": "cardano.json#/definitions/Ratio" }
, "maxEndorserBlockReferencesSize": { "$ref": "cardano.json#/definitions/NumberOfBytes" }
, "maxEndorserBlockTransactionsSize": { "$ref": "cardano.json#/definitions/NumberOfBytes" }
, "maxExecutionUnitsPerEndorserBlock": { "$ref": "cardano.json#/definitions/ExecutionUnits" }
, "maxReferenceScriptsSizePerEndorserBlock": { "$ref": "cardano.json#/definitions/NumberOfBytes" }
, "perasMinCandidateBlockAge": { "$ref": "cardano.json#/definitions/UInt32" }
, "perasHealingFactor": { "$ref": "cardano.json#/definitions/Ratio" }
, "perasCertificateBoost": { "$ref": "cardano.json#/definitions/UInt16" }
, "perasTargetCommitteeSize": { "$ref": "cardano.json#/definitions/UInt16" }
, "perasBootstrapRound":
{ "oneOf":
[ { "$ref": "cardano.json#/definitions/UInt32" }
, { "type": "null" }
]
}
, "perasQuorumThresholdSafetyMargin": { "$ref": "cardano.json#/definitions/Ratio" }
, "referenceInputsCostPerMultiAssetPolicy": { "$ref": "cardano.json#/definitions/Value<AdaOnly>" }
, "referenceInputsCostPerDatumByte": { "$ref": "cardano.json#/definitions/UInt64" }
}
}
}
}

, "GenesisDelegate":
{ "title": "GenesisDelegate"
, "type": "object"
Expand Down
1 change: 1 addition & 0 deletions docs/static/ogmios.json
Original file line number Diff line number Diff line change
Expand Up @@ -2070,6 +2070,7 @@
, { "$ref": "cardano.json#/definitions/Genesis<Shelley>" }
, { "$ref": "cardano.json#/definitions/Genesis<Alonzo>"}
, { "$ref": "cardano.json#/definitions/Genesis<Conway>"}
, { "$ref": "cardano.json#/definitions/Genesis<Dijkstra>"}
]
}
]
Expand Down
6 changes: 4 additions & 2 deletions scripts/dijkstra-devnet-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
# DIJKSTRA_TX_ID and DIJKSTRA_SUB_TX_ID set to the ids of both, and
# DIJKSTRA_PRODUCER_PID set to the process id of the node that makes the
# blocks, and DIJKSTRA_PROTOCOL_PARAMETERS set to a file with the protocol
# parameters from cardano-cli. Ogmios is connected to the other node, a
# parameters from cardano-cli, and DIJKSTRA_GENESIS set to the Dijkstra
# genesis file of the devnet. Ogmios is connected to the other node, a
# relay.
# Everything started here stops when the script ends. The files of the
# devnet are removed, unless the script fails.
Expand Down Expand Up @@ -167,7 +168,8 @@ DIJKSTRA_TX_CBOR=$(jq -r .cborHex "$WORK/signed.json")
DIJKSTRA_PRODUCER_PID=$(cat "$WORK/env/logs/node1/node.pid")
DIJKSTRA_PROTOCOL_PARAMETERS="$WORK/protocol-parameters.json"
cli dijkstra query protocol-parameters --out-file "$DIJKSTRA_PROTOCOL_PARAMETERS"
export DIJKSTRA_SUB_TX_ID DIJKSTRA_TX_ID DIJKSTRA_TX_CBOR DIJKSTRA_PRODUCER_PID DIJKSTRA_PROTOCOL_PARAMETERS
DIJKSTRA_GENESIS="$WORK/env/dijkstra-genesis.json"
export DIJKSTRA_SUB_TX_ID DIJKSTRA_TX_ID DIJKSTRA_TX_CBOR DIJKSTRA_PRODUCER_PID DIJKSTRA_PROTOCOL_PARAMETERS DIJKSTRA_GENESIS
echo "Built transaction $DIJKSTRA_TX_ID with sub-transaction $DIJKSTRA_SUB_TX_ID."

"$@"
Loading
Loading