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

feat/node: Update protocol parameters #1294

Merged
merged 10 commits into from
Sep 26, 2023
2 changes: 1 addition & 1 deletion bindings/nodejs/lib/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ export class Client {
/**
* Get the token supply.
*/
async getTokenSupply(): Promise<string> {
async getTokenSupply(): Promise<u64> {
return (await this.getProtocolParameters()).tokenSupply;
}

Expand Down
119 changes: 73 additions & 46 deletions bindings/nodejs/lib/types/models/info/node-info-protocol.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright 2023 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

import { u64 } from '../../utils';
import type { RentStructure } from '../rent-structure';

/**
Expand All @@ -21,6 +22,10 @@ export interface ProtocolInfo {
* The Protocol Parameters.
*/
export interface ProtocolParameters {
/**
* Set to value 0 to denote a IOTA 2.0 protocol parameter.
*/
type: number;
/**
* Protocol version used by the network.
*/
Expand All @@ -42,13 +47,13 @@ export interface ProtocolParameters {
*/
workScoreStructure: WorkScoreStructure;
/**
* Current supply of base token. Plain string encoded number.
* Current supply of base token.
*/
tokenSupply: string;
tokenSupply: u64;
/**
* The genesis timestamp at which the slots start to count.
*/
genesisUnixTimestamp: string;
genesisUnixTimestamp: u64;
/**
* The duration of a slot, in seconds.
*/
Expand All @@ -58,59 +63,43 @@ export interface ProtocolParameters {
*/
slotsPerEpochExponent: number;
/**
* The number of bits used to represent Mana expressed as an exponent of 2.
*/
manaBitsExponent: 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.
* The parameters used by mana calculation.
*/
manaDecayFactorsExponent: number;
manaStructure: ManaStructure;
/**
* An integer approximation of the sum of decay over epochs.
* The unbonding period in epochs before an account can stop staking.
*/
manaDecayFactorEpochsSum: number;
stakingUnbondingPeriod: u64;
/**
* The scaling of ManaDecayFactorEpochsSum expressed as an exponent of 2.
* The number of validation blocks that each validator should issue each slot.
*/
manaDecayFactorEpochsSumExponent: number;
validationBlocksPerSlot: number;
/**
* The unbonding period in epochs before an account can stop staking.
* The number of epochs worth of Mana that a node is punished with for each additional validation block it issues.
*/
stakingUnbondingPeriod: string;
punishmentEpochs: u64;
/**
* Determine if a block is eligible by evaluating issuingTime and commitments in its pastcone to ATT and lastCommittedSlot respectively.
*/
livenessThreshold: string;
livenessThreshold: u64;
/**
* MinCommittableAge is the minimum age relative to the accepted tangle time slot index that a slot can be committed.
*/
minCommittableAge: string;
minCommittableAge: u64;
/**
* 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;
maxCommittableAge: u64;
/**
* Determine the slot that should trigger a new committee selection for the next and upcoming epoch.
*/
epochNearingThreshold: string;
epochNearingThreshold: u64;
/**
* Congestion Control Parameters defines the parameters used to calculate the Reference Mana Cost (RMC).
*/
congestionControlParameters: CongestionControlParameters;
/**
* The version signaling parameters.
* The parameters used by signaling protocol parameters upgrade.
*/
versionSignaling: VersionSignalingParameters;
}
Expand All @@ -120,9 +109,9 @@ export interface ProtocolParameters {
*/
export interface WorkScoreStructure {
/**
* DataKilobyte accounts for the network traffic per kilobyte.
* DataByte accounts for the network traffic per kibibyte.
*/
dataKilobyte: number;
dataByte: number;
/**
* Block accounts for work done to process a block in the node software.
*/
Expand Down Expand Up @@ -169,42 +158,80 @@ export interface WorkScoreStructure {
minStrongParentsThreshold: number;
}

/**
* Mana Structure defines the parameters used by mana calculation.
*/
export interface ManaStructure {
/**
* The number of bits used to represent Mana.
*/
bitsCount: number;
/**
* The amount of potential Mana generated by 1 IOTA in 1 slot.
*/
generationRate: number;
/**
* The scaling of ManaGenerationRate expressed as an exponent of 2.
*/
generationRateExponent: number;
/**
* A lookup table of epoch index diff to mana decay factor (slice index 0 = 1 epoch).
*/
decayFactors: number[];
abdulmth marked this conversation as resolved.
Show resolved Hide resolved
/**
* The scaling of ManaDecayFactors expressed as an exponent of 2.
*/
decayFactorsExponent: number;
/**
* An integer approximation of the sum of decay over epochs.
*/
decayFactorEpochsSum: number;
/**
* The scaling of ManaDecayFactorEpochsSum expressed as an exponent of 2.
*/
decayFactorEpochsSumExponent: 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.
* The minimum value of the reference Mana cost.
*/
rmcMin: string;
minReferenceManaCost: u64;
/**
* Increase is the increase step size of the reference Mana cost.
* The increase step size of the reference Mana cost.
*/
increase: string;
increase: u64;
/**
* Decrease is the decrease step size of the reference Mana cost.
* The decrease step size of the reference Mana cost.
*/
decrease: string;
decrease: u64;
/**
* IncreaseThreshold is the threshold for increasing the reference Mana cost.
* The threshold for increasing the reference Mana cost.
*/
increaseThreshold: number;
/**
* DecreaseThreshold is the threshold for decreasing the reference Mana cost.
* The threshold for decreasing the reference Mana cost.
*/
decreaseThreshold: number;
/**
* SchedulerRate is the rate at which the scheduler runs in workscore units per second.
* 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.
* The minimum amount of Mana that an account must have to have a block scheduled.
*/
minMana: string;
minMana: u64;
/**
* MaxBufferSize is the maximum size of the buffer.
* The maximum size of the buffer.
*/
maxBufferSize: number;
/**
* The maximum number of blocks in the validation buffer.
*/
maxValidationBufferSize: number;
}

/**
Expand Down
4 changes: 4 additions & 0 deletions bindings/nodejs/lib/types/models/rent-structure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,8 @@ export interface RentStructure {
* Defines the factor to be used for staking feature.
*/
vByteFactorStakingFeature: number;
/**
* Defines the factor to be used for delegation output.
*/
vByteFactorDelegation: number;
}