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

Update nodejs InfoResponse #1108

Merged
merged 7 commits into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 2 additions & 2 deletions bindings/nodejs/lib/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -328,7 +328,7 @@ export class Client {
/**
* Get the protocol parameters.
*/
async getProtocolParameters(): Promise<INodeInfoProtocol> {
async getProtocolParameters(): Promise<ProtocolParameters> {
const response = await this.methodHandler.callMethod({
name: 'getProtocolParameters',
});
Expand Down
4 changes: 2 additions & 2 deletions bindings/nodejs/lib/types/client/network.ts
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -56,5 +56,5 @@ export interface INode {
*/
export interface INetworkInfo {
/** Protocol parameters */
protocolParameters: INodeInfoProtocol;
protocolParameters: ProtocolParameters;
}
2 changes: 1 addition & 1 deletion bindings/nodejs/lib/types/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
8 changes: 4 additions & 4 deletions bindings/nodejs/lib/types/models/info/node-info-base-token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
thibault-martinez marked this conversation as resolved.
Show resolved Hide resolved
/**
* The use metric prefix flag.
*/
Expand Down
12 changes: 6 additions & 6 deletions bindings/nodejs/lib/types/models/info/node-info-metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 in relation to new blocks of the last confirmed slot.
Thoralf-M marked this conversation as resolved.
Show resolved Hide resolved
*/
referencedRate: number;
confirmationRate: string;
}
209 changes: 201 additions & 8 deletions bindings/nodejs/lib/types/models/info/node-info-protocol.ts
Original file line number Diff line number Diff line change
@@ -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: number;
thibault-martinez marked this conversation as resolved.
Show resolved Hide resolved
/**
* 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: number;
thibault-martinez marked this conversation as resolved.
Show resolved Hide resolved
/**
* 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: string;
thibault-martinez marked this conversation as resolved.
Show resolved Hide resolved
/**
* The rent structure used by given node/network.
* The offset in epochs to activate the new version of protocol parameters.
*/
rentStructure: IRent;
activationOffset: string;
thibault-martinez marked this conversation as resolved.
Show resolved Hide resolved
}
38 changes: 35 additions & 3 deletions bindings/nodejs/lib/types/models/info/node-info-status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,43 @@
*/
export interface INodeInfoStatus {
/**
* Is the node healthy.
* Tells whether the node is healthy or not.
*/
isHealthy: boolean;
thibault-martinez marked this conversation as resolved.
Show resolved Hide resolved
/**
* 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;
thibault-martinez marked this conversation as resolved.
Show resolved Hide resolved
/**
* 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;
}
12 changes: 4 additions & 8 deletions bindings/nodejs/lib/types/models/info/node-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -14,7 +14,7 @@ export interface INodeInfo {
*/
name: string;
/**
* The version of node.
* The semantic version of the node.
*/
version: string;
/**
Expand All @@ -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.
*/
Expand Down
Loading