Skip to content

Commit

Permalink
Rename WorkScoreStructure to WorkScoreParameters (#1507)
Browse files Browse the repository at this point in the history
* rename work score structure to parameters

* remove missing_parent and min_strong_parents_threshold
  • Loading branch information
Alex6323 authored Oct 25, 2023
1 parent 4a46228 commit f7252f6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 34 deletions.
16 changes: 4 additions & 12 deletions bindings/nodejs/lib/types/models/info/node-info-protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ export interface ProtocolParameters {
*/
rentStructure: RentStructure;
/**
* Work structure lists the Work Score of each type, it is used to denote the computation costs of processing an object.
* Work Score Parameters lists the work score of each type, it is used to denote the computation costs of processing an object.
*/
workScoreStructure: WorkScoreStructure;
workScoreParameters: WorkScoreParameters;
/**
* Current supply of base token.
*/
Expand Down Expand Up @@ -141,9 +141,9 @@ export interface RewardsParameters {
}

/**
* Work structure lists the Work Score of each type, it is used to denote the computation costs of processing an object.
* Work Score Parameters lists the work score of each type, it is used to denote the computation costs of processing an object.
*/
export interface WorkScoreStructure {
export interface WorkScoreParameters {
/**
* DataByte accounts for the network traffic per kibibyte.
*/
Expand All @@ -152,10 +152,6 @@ export interface WorkScoreStructure {
* 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.
*/
Expand Down Expand Up @@ -188,10 +184,6 @@ export interface WorkScoreStructure {
* 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;
}

/**
Expand Down
12 changes: 4 additions & 8 deletions bindings/python/iota_sdk/types/node_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,12 @@ class RentStructure:

@json
@dataclass
class WorkScoreStructure:
"""Work structure lists the Work Score of each type, it is used to denote the computation costs of processing an object.
class WorkScoreParameters:
"""Work Score Parameters lists the work score of each type, it is used to denote the computation costs of processing an object.
Attributes:
data_byte: Data_kibibyte accounts for the network traffic per kibibyte.
block: Block accounts for work done to process a block in the node software.
missing_parent: Missing_parent is used to multiply for each missing parent if there are not enough strong ones.
input: Input accounts for loading the UTXO from the database and performing the mana calculations.
context_input: Context_input accounts for loading and checking the context input.
output: Output accounts for storing the UTXO in the database.
Expand All @@ -104,11 +103,9 @@ class WorkScoreStructure:
block_issuer: BlockIssuer accounts for the existence of a block issuer feature in the output.
allotment: Allotment accounts for accessing the account-based ledger to transform the mana to block issuance credits.
signature_ed25519: SignatureEd25519 accounts for an Ed25519 signature check.
min_strong_parents_threshold: MinStrongParentsThreshold is the minimum amount of strong parents in a basic block, otherwise, the issuer gets slashed.
"""
data_byte: int
block: int
missing_parent: int
input: int
context_input: int
output: int
Expand All @@ -117,7 +114,6 @@ class WorkScoreStructure:
block_issuer: int
allotment: int
signature_ed25519: int
min_strong_parents_threshold: int


@json
Expand Down Expand Up @@ -227,7 +223,7 @@ class ProtocolParameters:
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.
work_score_structure: Work structure lists the Work Score of each type, it is used to denote the computation costs of processing an object.
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.
slot_duration_in_seconds: The duration of a slot, in seconds.
Expand All @@ -249,7 +245,7 @@ class ProtocolParameters:
network_name: str
bech32_hrp: str
rent_structure: RentStructure
work_score_structure: WorkScoreStructure
work_score_parameters: WorkScoreParameters
token_supply: int = field(metadata=config(
encoder=str
))
Expand Down
16 changes: 5 additions & 11 deletions sdk/src/types/block/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ pub struct ProtocolParameters {
pub(crate) bech32_hrp: Hrp,
/// The rent structure used by given node/network.
pub(crate) rent_structure: RentStructure,
/// The work score structure used by the node/network.
pub(crate) work_score_structure: WorkScoreStructure,
/// The work score parameters used by the node/network.
pub(crate) work_score_parameters: WorkScoreParameters,
/// TokenSupply defines the current token supply on the network.
#[cfg_attr(feature = "serde", serde(with = "crate::utils::serde::string"))]
pub(crate) token_supply: u64,
Expand Down Expand Up @@ -95,7 +95,7 @@ impl Default for ProtocolParameters {
network_name: String::from("iota-core-testnet").try_into().unwrap(),
bech32_hrp: Hrp::from_str_unchecked("smr"),
rent_structure: Default::default(),
work_score_structure: Default::default(),
work_score_parameters: Default::default(),
token_supply: 1_813_620_509_061_365,
genesis_unix_timestamp: 1582328545,
slot_duration_in_seconds: 10,
Expand Down Expand Up @@ -199,13 +199,11 @@ impl ProtocolParameters {
)]
#[packable(unpack_error = Error)]
#[getset(get_copy = "pub")]
pub struct WorkScoreStructure {
pub struct WorkScoreParameters {
/// Modifier for network traffic per byte.
data_byte: u32,
/// Modifier for work done to process a block.
block: u32,
/// Modifier for slashing when there are insufficient strong tips.
missing_parent: u32,
/// Modifier for loading UTXOs and performing mana calculations.
input: u32,
/// Modifier for loading and checking the context input.
Expand All @@ -222,16 +220,13 @@ pub struct WorkScoreStructure {
allotment: u32,
/// Modifier for the block signature check.
signature_ed25519: u32,
/// The minimum count of strong parents in a basic block.
min_strong_parents_threshold: u8,
}

impl Default for WorkScoreStructure {
impl Default for WorkScoreParameters {
fn default() -> Self {
Self {
data_byte: 0,
block: 100,
missing_parent: 500,
input: 20,
context_input: 20,
output: 20,
Expand All @@ -240,7 +235,6 @@ impl Default for WorkScoreStructure {
block_issuer: 100,
allotment: 100,
signature_ed25519: 200,
min_strong_parents_threshold: 4,
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions sdk/tests/types/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@
// "vByteFactorStakingFeature":0,
// "vByteFactorDelegation":0
// },
// "workScoreStructure":{
// "workScoreParameters":{
// "dataByte":0,
// "block":1,
// "missingParent":0,
// "input":0,
// "contextInput":0,
// "output":0,
Expand All @@ -34,7 +33,6 @@
// "blockIssuer":0,
// "allotment":0,
// "signatureEd25519":0,
// "minStrongParentsThreshold":0
// },
// "tokenSupply":"2779530283277761",
// "genesisUnixTimestamp":"1695275822",
Expand Down

0 comments on commit f7252f6

Please sign in to comment.