diff --git a/bindings/nodejs/lib/client/client.ts b/bindings/nodejs/lib/client/client.ts index 037209a53b..a4c04c767d 100644 --- a/bindings/nodejs/lib/client/client.ts +++ b/bindings/nodejs/lib/client/client.ts @@ -38,11 +38,11 @@ import { HexEncodedString } from '../utils'; import { IBlockMetadata, INodeInfo, - INodeInfoProtocol, IPeer, UTXOInput, Response, OutputId, + ProtocolParameters, } from '../types'; import { OutputResponse, IOutputsResponse } from '../types/models/api'; @@ -328,7 +328,7 @@ export class Client { /** * Get the protocol parameters. */ - async getProtocolParameters(): Promise { + async getProtocolParameters(): Promise { const response = await this.methodHandler.callMethod({ name: 'getProtocolParameters', }); diff --git a/bindings/nodejs/lib/types/client/network.ts b/bindings/nodejs/lib/types/client/network.ts index deb17e34e9..ceca01624e 100644 --- a/bindings/nodejs/lib/types/client/network.ts +++ b/bindings/nodejs/lib/types/client/network.ts @@ -1,7 +1,7 @@ // Copyright 2021-2023 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -import { INodeInfoProtocol } from '../models/info'; +import { ProtocolParameters } from '../models/info'; /** * Network types. @@ -56,5 +56,5 @@ export interface INode { */ export interface INetworkInfo { /** Protocol parameters */ - protocolParameters: INodeInfoProtocol; + protocolParameters: ProtocolParameters; } diff --git a/bindings/nodejs/lib/types/models/index.ts b/bindings/nodejs/lib/types/models/index.ts index 7c6985db7a..3dd2565dc0 100644 --- a/bindings/nodejs/lib/types/models/index.ts +++ b/bindings/nodejs/lib/types/models/index.ts @@ -10,5 +10,5 @@ export * from './gossip-metrics'; export * from './gossip-heartbeat'; export * from './native-token'; export * from './peer'; -export * from './rent'; +export * from './rent-structure'; export * from './ledger-inclusion-state'; diff --git a/bindings/nodejs/lib/types/models/info/node-info-base-token.ts b/bindings/nodejs/lib/types/models/info/node-info-base-token.ts index 35bc330ec9..daf6c721c1 100644 --- a/bindings/nodejs/lib/types/models/info/node-info-base-token.ts +++ b/bindings/nodejs/lib/types/models/info/node-info-base-token.ts @@ -17,14 +17,14 @@ export interface INodeInfoBaseToken { * The base token unit. */ unit: string; - /** - * The base token sub-unit. - */ - subunit?: string; /** * The base token decimals. */ decimals: number; + /** + * The base token sub-unit. + */ + subunit?: string; /** * The use metric prefix flag. */ diff --git a/bindings/nodejs/lib/types/models/info/node-info-metrics.ts b/bindings/nodejs/lib/types/models/info/node-info-metrics.ts index d8e4fc01c0..4a1cf74b5e 100644 --- a/bindings/nodejs/lib/types/models/info/node-info-metrics.ts +++ b/bindings/nodejs/lib/types/models/info/node-info-metrics.ts @@ -6,15 +6,15 @@ */ export interface INodeInfoMetrics { /** - * Blocks per second. + * The current rate of new blocks per second. */ - blocksPerSecond: number; + blocksPerSecond: string; /** - * Referenced blocks per second. + * The current rate of confirmed blocks per second. */ - referencedBlocksPerSecond: number; + confirmedBlocksPerSecond: string; /** - * The rate at which rates are being referenced. + * The ratio of confirmed blocks to new blocks of the last confirmed slot. */ - referencedRate: number; + confirmationRate: string; } diff --git a/bindings/nodejs/lib/types/models/info/node-info-protocol.ts b/bindings/nodejs/lib/types/models/info/node-info-protocol.ts index a5f4115e12..30a21dffa0 100644 --- a/bindings/nodejs/lib/types/models/info/node-info-protocol.ts +++ b/bindings/nodejs/lib/types/models/info/node-info-protocol.ts @@ -1,29 +1,222 @@ // Copyright 2023 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -import type { IRent } from '../rent'; +import type { RentStructure } from '../rent-structure'; + /** * The Protocol Info. */ -export interface INodeInfoProtocol { +export interface ProtocolInfo { + /** + * The start epoch of the set of protocol parameters. + */ + startEpoch: string; + /** + * The protocol parameters. + */ + parameters: ProtocolParameters[]; +} + +/** + * The Protocol Parameters. + */ +export interface ProtocolParameters { + /** + * Protocol version used by the network. + */ + version: number; /** * The human friendly name of the network on which the node operates on. */ networkName: string; /** - * The human readable part of bech32 addresses. + * Tells whether the node supports mainnet or testnet addresses. Value `iota` indicates that the node supports mainnet addresses. Value `atoi` indicates that the node supports testnet addresses. */ bech32Hrp: string; /** - * The token supply. + * The rent structure according to TIP-19. + */ + rentStructure: RentStructure; + /** + * Work structure lists the Work Score of each type, it is used to denote the computation costs of processing an object. + */ + workScoreStructure: WorkScoreStructure; + /** + * Current supply of base token. Plain string encoded number. */ tokenSupply: string; /** - * The protocol version. + * The genesis timestamp at which the slots start to count. */ - version: number; + genesisUnixTimestamp: string; + /** + * The duration of a slot, in seconds. + */ + slotDurationInSeconds: number; + /** + * The number of slots in an epoch expressed as an exponent of 2. + */ + slotsPerEpochExponent: number; + /** + * The amount of potential Mana generated by 1 IOTA in 1 slot. + */ + manaGenerationRate: number; + /** + * The scaling of ManaGenerationRate expressed as an exponent of 2. + */ + manaGenerationRateExponent: number; + /** + * A lookup table of epoch index diff to mana decay factor (slice index 0 = 1 epoch). + */ + manaDecayFactors: number[]; + /** + * The scaling of ManaDecayFactors expressed as an exponent of 2. + */ + manaDecayFactorsExponent: number; + /** + * An integer approximation of the sum of decay over epochs. + */ + manaDecayFactorEpochsSum: number; + /** + * The scaling of ManaDecayFactorEpochsSum expressed as an exponent of 2. + */ + manaDecayFactorEpochsSumExponent: number; + /** + * The unbonding period in epochs before an account can stop staking. + */ + stakingUnbondingPeriod: string; + /** + * Determine if a block is eligible by evaluating issuingTime and commitments in its pastcone to ATT and lastCommittedSlot respectively. + */ + livenessThreshold: string; + /** + * MinCommittableAge is the minimum age relative to the accepted tangle time slot index that a slot can be committed. + */ + minCommittableAge: string; + /** + * MaxCommittableAge is the maximum age for a slot commitment to be included in a block relative to the slot index of the block issuing time. + */ + maxCommittableAge: string; + /** + * Determine the slot that should trigger a new committee selection for the next and upcoming epoch. + */ + epochNearingThreshold: string; + /** + * Congestion Control Parameters defines the parameters used to calculate the Reference Mana Cost (RMC). + */ + congestionControlParameters: CongestionControlParameters; + /** + * The version signaling parameters. + */ + versionSignaling: VersionSignalingParameters; +} + +/** + * Work structure lists the Work Score of each type, it is used to denote the computation costs of processing an object. + */ +export interface WorkScoreStructure { + /** + * DataKilobyte accounts for the network traffic per kilobyte. + */ + dataKilobyte: number; + /** + * Block accounts for work done to process a block in the node software. + */ + block: number; + /** + * MissingParent is used for slashing if there are not enough strong tips. + */ + missingParent: number; + /** + * Input accounts for loading the UTXO from the database and performing the mana calculations. + */ + input: number; + /** + * ContextInput accounts for loading and checking the context input. + */ + contextInput: number; + /** + * Output accounts for storing the UTXO in the database. + */ + output: number; + /** + * NativeToken accounts for calculations done with native tokens. + */ + nativeToken: number; + /** + * Staking accounts for the existence of a staking feature in the output. + */ + staking: number; + /** + * BlockIssuer accounts for the existence of a block issuer feature in the output. + */ + blockIssuer: number; + /** + * Allotment accounts for accessing the account based ledger to transform the mana to block issuance credits. + */ + allotment: number; + /** + * SignatureEd25519 accounts for an Ed25519 signature check. + */ + signatureEd25519: number; + /** + * MinStrongParentsThreshold is the minimum amount of strong parents in a basic block, otherwise the issuer gets slashed. + */ + minStrongParentsThreshold: number; +} + +/** + * Congestion Control Parameters defines the parameters used to calculate the Reference Mana Cost (RMC). + */ +export interface CongestionControlParameters { + /** + * RMCMin is the minimum value of the reference Mana cost. + */ + rmcMin: string; + /** + * Increase is the increase step size of the reference Mana cost. + */ + increase: string; + /** + * Decrease is the decrease step size of the reference Mana cost. + */ + decrease: string; + /** + * IncreaseThreshold is the threshold for increasing the reference Mana cost. + */ + increaseThreshold: number; + /** + * DecreaseThreshold is the threshold for decreasing the reference Mana cost. + */ + decreaseThreshold: number; + /** + * SchedulerRate is the rate at which the scheduler runs in workscore units per second. + */ + schedulerRate: number; + /** + * MinMana is the minimum amount of Mana that an account must have to have a block scheduled. + */ + minMana: string; + /** + * MaxBufferSize is the maximum size of the buffer. + */ + maxBufferSize: number; +} + +/** + * The version signaling parameters. + */ +export interface VersionSignalingParameters { + /** + * The size of the window in epochs to find which version of protocol parameters was most signaled, from currentEpoch - windowSize to currentEpoch. + */ + windowSize: number; + /** + * The target number of supporters for a version to win in a windowSize. + */ + windowTargetRatio: number; /** - * The rent structure used by given node/network. + * The offset in epochs to activate the new version of protocol parameters. */ - rentStructure: IRent; + activationOffset: number; } diff --git a/bindings/nodejs/lib/types/models/info/node-info-status.ts b/bindings/nodejs/lib/types/models/info/node-info-status.ts index 34915b0351..51f0854dd9 100644 --- a/bindings/nodejs/lib/types/models/info/node-info-status.ts +++ b/bindings/nodejs/lib/types/models/info/node-info-status.ts @@ -6,11 +6,43 @@ */ export interface INodeInfoStatus { /** - * Is the node healthy. + * Tells whether the node is healthy or not. */ isHealthy: boolean; /** - * The pruning index. + * A notion of time that is anchored to the latest accepted block. */ - pruningIndex: number; + acceptedTangleTime?: string; + /** + * The Accepted Tangle Time after it has advanced with the system clock. + */ + relativeAcceptedTangleTime?: string; + /** + * A notion of time that is anchored to the latest confirmed block. + */ + confirmedTangleTime?: string; + /** + * The Confirmed Tangle Time after it has advanced with the system clock. + */ + relativeConfirmedTangleTime?: string; + /** + * The latest slot that the node has committed to. + */ + latestCommitmentId: string; + /** + * The index of latest finalized slot. + */ + latestFinalizedSlot: string; + /** + * The slot index of the latest accepted block. + */ + latestAcceptedBlockSlot?: string; + /** + * The slot index of the latest confirmed block. + */ + latestConfirmedBlockSlot?: string; + /** + * The index of the slot before which the tangle history is pruned. + */ + pruningSlot: string; } diff --git a/bindings/nodejs/lib/types/models/info/node-info.ts b/bindings/nodejs/lib/types/models/info/node-info.ts index 35de07878a..3c520d9fb5 100644 --- a/bindings/nodejs/lib/types/models/info/node-info.ts +++ b/bindings/nodejs/lib/types/models/info/node-info.ts @@ -3,7 +3,7 @@ import type { INodeInfoBaseToken } from './node-info-base-token'; import type { INodeInfoMetrics } from './node-info-metrics'; -import type { INodeInfoProtocol } from './node-info-protocol'; +import type { ProtocolInfo } from './node-info-protocol'; import type { INodeInfoStatus } from './node-info-status'; /** * Response from the /info endpoint. @@ -14,7 +14,7 @@ export interface INodeInfo { */ name: string; /** - * The version of node. + * The semantic version of the node. */ version: string; /** @@ -26,13 +26,9 @@ export interface INodeInfo { */ metrics: INodeInfoMetrics; /** - * The supported protocol versions. + * The protocol parameters. */ - supportedProtocolVersions: number[]; - /** - * The protocol info of the node. - */ - protocol: INodeInfoProtocol; + protocolParameters: ProtocolInfo[]; /** * The base token info of the node. */ diff --git a/bindings/nodejs/lib/types/models/rent.ts b/bindings/nodejs/lib/types/models/rent-structure.ts similarity index 64% rename from bindings/nodejs/lib/types/models/rent.ts rename to bindings/nodejs/lib/types/models/rent-structure.ts index 90abb99990..82cc434ed1 100644 --- a/bindings/nodejs/lib/types/models/rent.ts +++ b/bindings/nodejs/lib/types/models/rent-structure.ts @@ -4,7 +4,7 @@ /** * Defines the parameters of rent cost calculations on objects which take node resources. */ -export interface IRent { +export interface RentStructure { /** * Defines the rent of a single virtual byte denoted in IOTA token. */ @@ -17,4 +17,12 @@ export interface IRent { * The factor to be used for key/lookup generating fields. */ vByteFactorKey: number; + /** + * Defines the factor to be used for block issuer feature public keys. + */ + vByteFactorIssuerKeys: number; + /** + * Defines the factor to be used for staking feature. + */ + vByteFactorStakingFeature: number; } diff --git a/bindings/nodejs/lib/types/utils/bridge/utils.ts b/bindings/nodejs/lib/types/utils/bridge/utils.ts index e29179dbd4..451c2f93f5 100644 --- a/bindings/nodejs/lib/types/utils/bridge/utils.ts +++ b/bindings/nodejs/lib/types/utils/bridge/utils.ts @@ -7,7 +7,7 @@ import { TransactionId, TokenSchemeType, Output, - IRent, + RentStructure, } from '../../'; import { AccountId } from '../../block/id'; import { SlotCommitment } from '../../block/slot'; @@ -65,7 +65,7 @@ export interface __ComputeStorageDepositMethod__ { name: 'computeStorageDeposit'; data: { output: Output; - rent: IRent; + rent: RentStructure; }; } diff --git a/bindings/nodejs/lib/utils/utils.ts b/bindings/nodejs/lib/utils/utils.ts index 43fd5ca4d1..014975a1e2 100644 --- a/bindings/nodejs/lib/utils/utils.ts +++ b/bindings/nodejs/lib/utils/utils.ts @@ -12,7 +12,7 @@ import { TransactionId, TokenSchemeType, Output, - IRent, + RentStructure, OutputId, u64, } from '../types'; @@ -143,7 +143,7 @@ export class Utils { * @param rent Rent cost of objects which take node resources. * @returns The required storage deposit. */ - static computeStorageDeposit(output: Output, rent: IRent): u64 { + static computeStorageDeposit(output: Output, rent: RentStructure): u64 { const minStorageDepositAmount = callUtilsMethod({ name: 'computeStorageDeposit', data: {