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

Snapshot changes #1435

Draft
wants to merge 17 commits into
base: shimmer-develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
180 changes: 84 additions & 96 deletions Cargo.lock

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ async fn info<B: StorageBackend>(Extension(args): Extension<ApiArgsFullNode<B>>)
bech32_hrp: args.bech32_hrp.clone(),
min_pow_score: args.protocol_config.minimum_pow_score(),
rent_structure: RentStructureResponse {
v_byte_cost: args.protocol_config.byte_cost().v_byte_cost,
v_byte_factor_key: args.protocol_config.byte_cost().v_byte_factor_key,
v_byte_factor_data: args.protocol_config.byte_cost().v_byte_factor_data,
v_byte_cost: args.protocol_config.rent().v_byte_cost,
v_byte_factor_key: args.protocol_config.rent().v_byte_factor_key,
v_byte_factor_data: args.protocol_config.rent().v_byte_factor_data,
},
token_supply: TOKEN_SUPPLY.to_string(),
},
Expand Down
6 changes: 3 additions & 3 deletions bee-api/bee-rest-api/src/types/responses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,11 @@ pub struct BaseTokenResponse {
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
pub struct RentStructureResponse {
#[serde(rename = "vByteCost")]
pub v_byte_cost: u64,
pub v_byte_cost: u32,
#[serde(rename = "vByteFactorKey")]
pub v_byte_factor_key: u64,
pub v_byte_factor_key: u8,
#[serde(rename = "vByteFactorData")]
pub v_byte_factor_data: u64,
pub v_byte_factor_data: u8,
}

/// Returned in [`InfoResponse`].
Expand Down
6 changes: 5 additions & 1 deletion bee-block/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2020-2021 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

use alloc::string::String;
use alloc::string::{FromUtf8Error, String};
use core::{convert::Infallible, fmt};

use crypto::Error as CryptoError;
Expand Down Expand Up @@ -56,6 +56,7 @@ pub enum Error {
InvalidInputKind(u8),
InvalidInputCount(<InputCount as TryFrom<usize>>::Error),
InvalidInputOutputIndex(<OutputIndex as TryFrom<u16>>::Error),
InvalidBech32Hrp(FromUtf8Error),
InvalidBlockLength(usize),
InvalidStateMetadataLength(<StateMetadataLength as TryFrom<usize>>::Error),
InvalidMetadataFeatureLength(<MetadataFeatureLength as TryFrom<usize>>::Error),
Expand All @@ -64,6 +65,7 @@ pub enum Error {
InvalidMilestoneOptionKind(u8),
InvalidMigratedFundsEntryAmount(<MigratedFundsAmount as TryFrom<u64>>::Error),
InvalidNativeTokenCount(<NativeTokenCount as TryFrom<usize>>::Error),
InvalidNetworkName(FromUtf8Error),
InvalidNftIndex(<UnlockIndex as TryFrom<u16>>::Error),
InvalidOutputAmount(<OutputAmount as TryFrom<u64>>::Error),
InvalidOutputCount(<OutputCount as TryFrom<usize>>::Error),
Expand Down Expand Up @@ -157,6 +159,7 @@ impl fmt::Display for Error {
Error::InvalidAddress => write!(f, "invalid address provided"),
Error::InvalidAddressKind(k) => write!(f, "invalid address kind: {}", k),
Error::InvalidAliasIndex(index) => write!(f, "invalid alias index: {}", index),
Error::InvalidBech32Hrp(err) => write!(f, "invalid bech32 hrp: {err}"),
Error::InvalidBinaryParametersLength(length) => {
write!(f, "invalid binary parameters length: {length}")
}
Expand Down Expand Up @@ -205,6 +208,7 @@ impl fmt::Display for Error {
write!(f, "invalid migrated funds entry amount: {amount}")
}
Error::InvalidNativeTokenCount(count) => write!(f, "invalid native token count: {}", count),
Error::InvalidNetworkName(err) => write!(f, "invalid network name: {err}"),
Error::InvalidNftIndex(index) => write!(f, "invalid nft index: {}", index),
Error::InvalidOutputAmount(amount) => write!(f, "invalid output amount: {}", amount),
Error::InvalidOutputCount(count) => write!(f, "invalid output count: {}", count),
Expand Down
2 changes: 2 additions & 0 deletions bee-block/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ pub mod output;
pub mod parent;
/// A module that provides types and syntactic validations of payloads.
pub mod payload;
/// A module that provides types and syntactic validations of protocol parameters.
pub mod protocol;
/// A module that provides types and rules for semantic validation.
pub mod semantic;
/// A module that provides types and syntactic validations of signatures.
Expand Down
27 changes: 12 additions & 15 deletions bee-block/src/output/alias.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ use crate::{
output::{
feature::{verify_allowed_features, Feature, FeatureFlags, Features},
unlock_condition::{verify_allowed_unlock_conditions, UnlockCondition, UnlockConditionFlags, UnlockConditions},
AliasId, ByteCost, ByteCostConfig, ChainId, NativeToken, NativeTokens, Output, OutputAmount,
OutputBuilderAmount, OutputId, StateTransitionError, StateTransitionVerifier,
AliasId, ChainId, NativeToken, NativeTokens, Output, OutputAmount, OutputBuilderAmount, OutputId, Rent,
RentStructure, StateTransitionError, StateTransitionVerifier,
},
semantic::{ConflictReason, ValidationContext},
unlock::Unlock,
Expand Down Expand Up @@ -52,10 +52,10 @@ impl AliasOutputBuilder {
/// Creates an [`AliasOutputBuilder`] with a provided byte cost config.
/// The amount will be set to the minimum storage deposit.
pub fn new_with_minimum_storage_deposit(
byte_cost_config: ByteCostConfig,
rent_structure: RentStructure,
alias_id: AliasId,
) -> Result<AliasOutputBuilder, Error> {
Self::new(OutputBuilderAmount::MinimumStorageDeposit(byte_cost_config), alias_id)
Self::new(OutputBuilderAmount::MinimumStorageDeposit(rent_structure), alias_id)
}

fn new(amount: OutputBuilderAmount, alias_id: AliasId) -> Result<AliasOutputBuilder, Error> {
Expand All @@ -81,8 +81,8 @@ impl AliasOutputBuilder {

/// Sets the amount to the minimum storage deposit.
#[inline(always)]
pub fn with_minimum_storage_deposit(mut self, byte_cost_config: ByteCostConfig) -> Self {
self.amount = OutputBuilderAmount::MinimumStorageDeposit(byte_cost_config);
pub fn with_minimum_storage_deposit(mut self, rent_structure: RentStructure) -> Self {
self.amount = OutputBuilderAmount::MinimumStorageDeposit(rent_structure);
self
}

Expand Down Expand Up @@ -244,8 +244,8 @@ impl AliasOutputBuilder {

output.amount = match self.amount {
OutputBuilderAmount::Amount(amount) => amount,
OutputBuilderAmount::MinimumStorageDeposit(byte_cost_config) => Output::Alias(output.clone())
.byte_cost(&byte_cost_config)
OutputBuilderAmount::MinimumStorageDeposit(rent_structure) => Output::Alias(output.clone())
.rent_cost(&rent_structure)
.try_into()
.map_err(Error::InvalidOutputAmount)?,
};
Expand Down Expand Up @@ -322,11 +322,8 @@ impl AliasOutput {
/// Creates a new [`AliasOutput`] with a provided byte cost config.
/// The amount will be set to the minimum storage deposit.
#[inline(always)]
pub fn new_with_minimum_storage_deposit(
byte_cost_config: ByteCostConfig,
alias_id: AliasId,
) -> Result<Self, Error> {
AliasOutputBuilder::new_with_minimum_storage_deposit(byte_cost_config, alias_id)?.finish()
pub fn new_with_minimum_storage_deposit(rent_structure: RentStructure, alias_id: AliasId) -> Result<Self, Error> {
AliasOutputBuilder::new_with_minimum_storage_deposit(rent_structure, alias_id)?.finish()
}

/// Creates a new [`AliasOutputBuilder`] with a provided amount.
Expand All @@ -339,10 +336,10 @@ impl AliasOutput {
/// The amount will be set to the minimum storage deposit.
#[inline(always)]
pub fn build_with_minimum_storage_deposit(
byte_cost_config: ByteCostConfig,
rent_structure: RentStructure,
alias_id: AliasId,
) -> Result<AliasOutputBuilder, Error> {
AliasOutputBuilder::new_with_minimum_storage_deposit(byte_cost_config, alias_id)
AliasOutputBuilder::new_with_minimum_storage_deposit(rent_structure, alias_id)
}

///
Expand Down
22 changes: 11 additions & 11 deletions bee-block/src/output/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::{
output::{
feature::{verify_allowed_features, Feature, FeatureFlags, Features},
unlock_condition::{verify_allowed_unlock_conditions, UnlockCondition, UnlockConditionFlags, UnlockConditions},
ByteCost, ByteCostConfig, NativeToken, NativeTokens, Output, OutputAmount, OutputBuilderAmount, OutputId,
NativeToken, NativeTokens, Output, OutputAmount, OutputBuilderAmount, OutputId, Rent, RentStructure,
},
semantic::{ConflictReason, ValidationContext},
unlock::Unlock,
Expand Down Expand Up @@ -39,8 +39,8 @@ impl BasicOutputBuilder {
/// Creates an [`BasicOutputBuilder`] with a provided byte cost config.
/// The amount will be set to the minimum storage deposit.
#[inline(always)]
pub fn new_with_minimum_storage_deposit(byte_cost_config: ByteCostConfig) -> Result<Self, Error> {
Self::new(OutputBuilderAmount::MinimumStorageDeposit(byte_cost_config))
pub fn new_with_minimum_storage_deposit(rent_structure: RentStructure) -> Result<Self, Error> {
Self::new(OutputBuilderAmount::MinimumStorageDeposit(rent_structure))
}

fn new(amount: OutputBuilderAmount) -> Result<Self, Error> {
Expand All @@ -61,8 +61,8 @@ impl BasicOutputBuilder {

/// Sets the amount to the minimum storage deposit.
#[inline(always)]
pub fn with_minimum_storage_deposit(mut self, byte_cost_config: ByteCostConfig) -> Self {
self.amount = OutputBuilderAmount::MinimumStorageDeposit(byte_cost_config);
pub fn with_minimum_storage_deposit(mut self, rent_structure: RentStructure) -> Self {
self.amount = OutputBuilderAmount::MinimumStorageDeposit(rent_structure);
self
}

Expand Down Expand Up @@ -149,8 +149,8 @@ impl BasicOutputBuilder {

output.amount = match self.amount {
OutputBuilderAmount::Amount(amount) => amount,
OutputBuilderAmount::MinimumStorageDeposit(byte_cost_config) => Output::Basic(output.clone())
.byte_cost(&byte_cost_config)
OutputBuilderAmount::MinimumStorageDeposit(rent_structure) => Output::Basic(output.clone())
.rent_cost(&rent_structure)
.try_into()
.map_err(Error::InvalidOutputAmount)?,
};
Expand Down Expand Up @@ -214,8 +214,8 @@ impl BasicOutput {
/// Creates a new [`BasicOutput`] with a provided byte cost config.
/// The amount will be set to the minimum storage deposit.
#[inline(always)]
pub fn new_with_minimum_storage_deposit(byte_cost_config: ByteCostConfig) -> Result<Self, Error> {
BasicOutputBuilder::new_with_minimum_storage_deposit(byte_cost_config)?.finish()
pub fn new_with_minimum_storage_deposit(rent_structure: RentStructure) -> Result<Self, Error> {
BasicOutputBuilder::new_with_minimum_storage_deposit(rent_structure)?.finish()
}

/// Creates a new [`BasicOutputBuilder`] with a provided amount.
Expand All @@ -227,8 +227,8 @@ impl BasicOutput {
/// Creates a new [`BasicOutputBuilder`] with a provided byte cost config.
/// The amount will be set to the minimum storage deposit.
#[inline(always)]
pub fn build_with_minimum_storage_deposit(byte_cost_config: ByteCostConfig) -> Result<BasicOutputBuilder, Error> {
BasicOutputBuilder::new_with_minimum_storage_deposit(byte_cost_config)
pub fn build_with_minimum_storage_deposit(rent_structure: RentStructure) -> Result<BasicOutputBuilder, Error> {
BasicOutputBuilder::new_with_minimum_storage_deposit(rent_structure)
}

///
Expand Down
105 changes: 0 additions & 105 deletions bee-block/src/output/byte_cost.rs

This file was deleted.

24 changes: 12 additions & 12 deletions bee-block/src/output/foundry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ use crate::{
output::{
feature::{verify_allowed_features, Feature, FeatureFlags, Features},
unlock_condition::{verify_allowed_unlock_conditions, UnlockCondition, UnlockConditionFlags, UnlockConditions},
ByteCost, ByteCostConfig, ChainId, FoundryId, NativeToken, NativeTokens, Output, OutputAmount,
OutputBuilderAmount, OutputId, StateTransitionError, StateTransitionVerifier, TokenId, TokenScheme,
ChainId, FoundryId, NativeToken, NativeTokens, Output, OutputAmount, OutputBuilderAmount, OutputId, Rent,
RentStructure, StateTransitionError, StateTransitionVerifier, TokenId, TokenScheme,
},
semantic::{ConflictReason, ValidationContext},
unlock::Unlock,
Expand Down Expand Up @@ -54,12 +54,12 @@ impl FoundryOutputBuilder {
/// Creates a [`FoundryOutputBuilder`] with a provided byte cost config.
/// The amount will be set to the minimum storage deposit.
pub fn new_with_minimum_storage_deposit(
byte_cost_config: ByteCostConfig,
rent_structure: RentStructure,
serial_number: u32,
token_scheme: TokenScheme,
) -> Result<FoundryOutputBuilder, Error> {
Self::new(
OutputBuilderAmount::MinimumStorageDeposit(byte_cost_config),
OutputBuilderAmount::MinimumStorageDeposit(rent_structure),
serial_number,
token_scheme,
)
Expand Down Expand Up @@ -90,8 +90,8 @@ impl FoundryOutputBuilder {

/// Sets the amount to the minimum storage deposit.
#[inline(always)]
pub fn with_minimum_storage_deposit(mut self, byte_cost_config: ByteCostConfig) -> Self {
self.amount = OutputBuilderAmount::MinimumStorageDeposit(byte_cost_config);
pub fn with_minimum_storage_deposit(mut self, rent_structure: RentStructure) -> Self {
self.amount = OutputBuilderAmount::MinimumStorageDeposit(rent_structure);
self
}

Expand Down Expand Up @@ -226,8 +226,8 @@ impl FoundryOutputBuilder {

output.amount = match self.amount {
OutputBuilderAmount::Amount(amount) => amount,
OutputBuilderAmount::MinimumStorageDeposit(byte_cost_config) => Output::Foundry(output.clone())
.byte_cost(&byte_cost_config)
OutputBuilderAmount::MinimumStorageDeposit(rent_structure) => Output::Foundry(output.clone())
.rent_cost(&rent_structure)
.try_into()
.map_err(Error::InvalidOutputAmount)?,
};
Expand Down Expand Up @@ -291,11 +291,11 @@ impl FoundryOutput {
/// The amount will be set to the minimum storage deposit.
#[inline(always)]
pub fn new_with_minimum_storage_deposit(
byte_cost_config: ByteCostConfig,
rent_structure: RentStructure,
serial_number: u32,
token_scheme: TokenScheme,
) -> Result<Self, Error> {
FoundryOutputBuilder::new_with_minimum_storage_deposit(byte_cost_config, serial_number, token_scheme)?.finish()
FoundryOutputBuilder::new_with_minimum_storage_deposit(rent_structure, serial_number, token_scheme)?.finish()
}

/// Creates a new [`FoundryOutputBuilder`] with a provided amount.
Expand All @@ -312,11 +312,11 @@ impl FoundryOutput {
/// The amount will be set to the minimum storage deposit.
#[inline(always)]
pub fn build_with_minimum_storage_deposit(
byte_cost_config: ByteCostConfig,
rent_structure: RentStructure,
serial_number: u32,
token_scheme: TokenScheme,
) -> Result<FoundryOutputBuilder, Error> {
FoundryOutputBuilder::new_with_minimum_storage_deposit(byte_cost_config, serial_number, token_scheme)
FoundryOutputBuilder::new_with_minimum_storage_deposit(rent_structure, serial_number, token_scheme)
}

///
Expand Down
Loading