From 276ef191dd4897bde780469e262b620820a89d42 Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Fri, 24 Nov 2023 09:12:25 +0100 Subject: [PATCH] Rename RentStructure to StorageScoreParameters in bindings (#1673) * Nodejs bindings * Python bindings * Fmt * Update bindings/nodejs/lib/utils/utils.ts Co-authored-by: Thoralf-M <46689931+Thoralf-M@users.noreply.github.com> --------- Co-authored-by: Thoralf-M <46689931+Thoralf-M@users.noreply.github.com> --- bindings/nodejs/lib/types/models/index.ts | 2 +- .../types/models/info/node-info-protocol.ts | 6 ++-- .../nodejs/lib/types/models/rent-structure.ts | 32 ----------------- .../nodejs/lib/types/models/storage-score.ts | 34 +++++++++++++++++++ .../nodejs/lib/types/utils/bridge/utils.ts | 4 +-- bindings/nodejs/lib/utils/utils.ts | 11 +++--- bindings/python/iota_sdk/types/node_info.py | 32 ++++++++--------- 7 files changed, 63 insertions(+), 58 deletions(-) delete mode 100644 bindings/nodejs/lib/types/models/rent-structure.ts create mode 100644 bindings/nodejs/lib/types/models/storage-score.ts diff --git a/bindings/nodejs/lib/types/models/index.ts b/bindings/nodejs/lib/types/models/index.ts index 62574467fb..8789189173 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-structure'; +export * from './storage-score'; export * from './state'; 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 592f7accaf..21cb9953a8 100644 --- a/bindings/nodejs/lib/types/models/info/node-info-protocol.ts +++ b/bindings/nodejs/lib/types/models/info/node-info-protocol.ts @@ -1,7 +1,7 @@ // Copyright 2023 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -import type { RentStructure } from '../rent-structure'; +import type { StorageScoreParameters } from '../storage-score'; import { EpochIndex } from '../../block/slot'; import { u64 } from '../../utils'; @@ -40,9 +40,9 @@ export interface ProtocolParameters { */ bech32Hrp: string; /** - * The rent structure according to TIP-19. + * The storage score parameters used by given node/network. */ - rentStructure: RentStructure; + storageScoreParameters: StorageScoreParameters; /** * Work Score Parameters lists the work score of each type, it is used to denote the computation costs of processing an object. */ diff --git a/bindings/nodejs/lib/types/models/rent-structure.ts b/bindings/nodejs/lib/types/models/rent-structure.ts deleted file mode 100644 index 14bb53eb99..0000000000 --- a/bindings/nodejs/lib/types/models/rent-structure.ts +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2023 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -/** - * Defines the parameters of rent cost calculations on objects which take node resources. - */ -export interface RentStructure { - /** - * Defines the rent of a single virtual byte denoted in IOTA token. - */ - vByteCost: number; - /** - * The factor to be used for data only fields. - */ - vByteFactorData: number; - /** - * The factor to be used for key/lookup generating fields. - */ - vByteFactorKey: number; - /** - * Defines the factor to be used for block issuer feature public keys. - */ - vByteFactorBlockIssuerKey: number; - /** - * Defines the factor to be used for staking feature. - */ - vByteFactorStakingFeature: number; - /** - * Defines the factor to be used for delegation output. - */ - vByteFactorDelegation: number; -} diff --git a/bindings/nodejs/lib/types/models/storage-score.ts b/bindings/nodejs/lib/types/models/storage-score.ts new file mode 100644 index 0000000000..ebfe1bb183 --- /dev/null +++ b/bindings/nodejs/lib/types/models/storage-score.ts @@ -0,0 +1,34 @@ +// Copyright 2023 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +import { u64 } from '../../utils'; + +/** + * Defines the parameters of storage score calculations on objects which take node resources. + */ +export interface StorageScoreParameters { + /** + * Defines the number of IOTA tokens required per unit of storage score. + */ + storageCost: u64; + /** + * Defines the factor to be used for data only fields. + */ + factorData: number; + /** + * Defines the offset to be applied to all outputs for the overhead of handling them in storage. + */ + offsetOutputOverhead: u64; + /** + * Defines the offset to be used for block issuer feature public keys. + */ + offsetEd25519BlockIssuerKey: u64; + /** + * Defines the offset to be used for staking feature. + */ + offsetStakingFeature: u64; + /** + * Defines the offset to be used for delegation output. + */ + offsetDelegation: u64; +} diff --git a/bindings/nodejs/lib/types/utils/bridge/utils.ts b/bindings/nodejs/lib/types/utils/bridge/utils.ts index 906ddfbb83..ea1ccd0a43 100644 --- a/bindings/nodejs/lib/types/utils/bridge/utils.ts +++ b/bindings/nodejs/lib/types/utils/bridge/utils.ts @@ -6,7 +6,7 @@ import { TransactionId, TokenSchemeType, Output, - RentStructure, + StorageScoreParameters, SignedBlock, ProtocolParameters, OutputId, @@ -62,7 +62,7 @@ export interface __ComputeStorageDepositMethod__ { name: 'computeStorageDeposit'; data: { output: Output; - rent: RentStructure; + storageScoreParameters: StorageScoreParameters; }; } diff --git a/bindings/nodejs/lib/utils/utils.ts b/bindings/nodejs/lib/utils/utils.ts index c4b23ad3ab..bcd94c41b3 100644 --- a/bindings/nodejs/lib/utils/utils.ts +++ b/bindings/nodejs/lib/utils/utils.ts @@ -11,7 +11,7 @@ import { TransactionId, TokenSchemeType, Output, - RentStructure, + StorageScoreParameters, OutputId, u64, SignedBlock, @@ -127,15 +127,18 @@ export class Utils { * Compute the required storage deposit of an output. * * @param output The output. - * @param rent Rent cost of objects which take node resources. + * @param storageScoreParameters Storage score of objects which take node resources. * @returns The required storage deposit. */ - static computeStorageDeposit(output: Output, rent: RentStructure): u64 { + static computeStorageDeposit( + output: Output, + storageScoreParameters: StorageScoreParameters, + ): u64 { const minStorageDepositAmount = callUtilsMethod({ name: 'computeStorageDeposit', data: { output, - rent, + storageScoreParameters, }, }); return BigInt(minStorageDepositAmount); diff --git a/bindings/python/iota_sdk/types/node_info.py b/bindings/python/iota_sdk/types/node_info.py index 2b6c184828..4f27e2488c 100644 --- a/bindings/python/iota_sdk/types/node_info.py +++ b/bindings/python/iota_sdk/types/node_info.py @@ -68,23 +68,23 @@ class NodeInfoMetrics: @json @dataclass -class RentStructure: - """Rent structure for the storage deposit. +class StorageScoreParameters: + """Defines the parameters of storage score calculations on objects which take node resources. Attributes: - v_byte_cost: Defines the rent of a single virtual byte denoted in IOTA tokens. - v_byte_factor_data: Defines the factor to be used for data only fields. - v_byte_factor_key: Defines the factor to be used for key/lookup generating fields. - v_byte_factor_block_issuer_key: Defines the factor to be used for block issuer feature public keys. - v_byte_factor_staking_feature: Defines the factor to be used for staking feature. - v_byte_factor_delegation: Defines the factor to be used for delegation output. + storage_cost: Defines the number of IOTA tokens required per unit of storage score. + factor_data: Defines the factor to be used for data only fields. + offset_output_overhead: Defines the offset to be applied to all outputs for the overhead of handling them in storage. + offset_ed25519_block_issuer_key: Defines the offset to be used for block issuer feature public keys. + offset_staking_feature: Defines the offset to be used for staking feature. + offset_delegation: Defines the offset to be used for delegation output. """ - v_byte_cost: int - v_byte_factor_data: int - v_byte_factor_key: int - v_byte_factor_block_issuer_key: int - v_byte_factor_staking_feature: int - v_byte_factor_delegation: int + storage_cost: int + factor_data: int + offset_output_overhead: int + offset_ed25519_block_issuer_key: int + offset_staking_feature: int + offset_delegation: int @json @@ -222,7 +222,7 @@ class ProtocolParameters: bech32_hrp: 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. - rent_structure: The rent structure used by a given node/network. + storage_score_parameters: The storage score parameters used by given node/network. work_score_parameters: Work Score Parameters lists the work score of each type, it is used to denote the computation costs of processing an object. token_supply: Current supply of the base token. Plain string encoded number. genesis_unix_timestamp: The genesis timestamp at which the slots start to count. @@ -244,7 +244,7 @@ class ProtocolParameters: version: int network_name: str bech32_hrp: str - rent_structure: RentStructure + storage_score_parameters: StorageScoreParameters work_score_parameters: WorkScoreParameters token_supply: int = field(metadata=config( encoder=str