Skip to content

Commit

Permalink
Merge branch '2.0' into 2.0-wasm
Browse files Browse the repository at this point in the history
  • Loading branch information
Thoralf-M authored Nov 16, 2023
2 parents 289ccfd + 967b45f commit d8bc188
Show file tree
Hide file tree
Showing 13 changed files with 24 additions and 49 deletions.
8 changes: 4 additions & 4 deletions .github/actions/private-tangle/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ runs:
# remove the last 5 lines and add docker compose with `-d` to run it in the background
sed -i -n -e :a -e '1,5!{P;N;D;};N;ba' run.sh
echo "docker compose -f \$DOCKER_COMPOSE_FILE up -d" >> run.sh
echo "docker compose -f docker-compose.yml up -d" >> run.sh
working-directory: iota-core/tools/docker-network

# Copied from https://github.com/iotaledger/iota-core/blob/926bf11b5fb6dc46b25482770e0ccf1e048b97c9/.github/workflows/unit-test.yml#L16-L19
- uses: actions/setup-go@v4
with:
go-version-file: 'iota-core/go.mod'
go-version-file: "iota-core/go.mod"
cache: false

- name: Setup private tangle
Expand All @@ -40,5 +40,5 @@ runs:
run: wget -qO- https://raw.githubusercontent.com/eficode/wait-for/v2.2.4/wait-for | sh -s -- -t 120 http://localhost:8080/health -- echo "Tangle is up"
# TODO enable, maybe need another URL
# - name: Wait for faucet to start
# shell: bash
# run: wget -qO- https://raw.githubusercontent.com/eficode/wait-for/v2.2.4/wait-for | sh -s -- -t 120 http://localhost:8081/api/info -- echo "Faucet is up"
# shell: bash
# run: wget -qO- https://raw.githubusercontent.com/eficode/wait-for/v2.2.4/wait-for | sh -s -- -t 120 http://localhost:8081/api/info -- echo "Faucet is up"
4 changes: 2 additions & 2 deletions sdk/src/types/api/plugins/participation/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use getset::Getters;
use hashbrown::HashMap;
use packable::PackableExt;

use crate::types::{api::plugins::participation::error::Error, block::impl_id};
use crate::types::api::plugins::participation::error::Error;

/// Participation tag.
pub const PARTICIPATION_TAG: &str = "PARTICIPATE";
Expand Down Expand Up @@ -51,7 +51,7 @@ pub struct ParticipationEvent {
pub data: ParticipationEventData,
}

impl_id!(
crate::impl_id!(
/// A participation event id.
pub ParticipationEventId {
pub const LENGTH: usize = 32;
Expand Down
2 changes: 0 additions & 2 deletions sdk/src/types/block/macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ macro_rules! impl_id {
)?
};
}
pub(crate) use impl_id;

/// Convenience macro to serialize types to string via serde.
#[cfg(feature = "serde")]
Expand Down Expand Up @@ -297,7 +296,6 @@ macro_rules! create_bitflags {
}
};
}
pub(crate) use create_bitflags;

#[macro_export]
macro_rules! impl_serde_typed_dto {
Expand Down
7 changes: 2 additions & 5 deletions sdk/src/types/block/output/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ use crate::types::block::{
output::{
feature::{verify_allowed_features, Feature, FeatureFlags, Features},
unlock_condition::{verify_allowed_unlock_conditions, UnlockCondition, UnlockConditionFlags, UnlockConditions},
verify_output_amount_packable, ChainId, MinimumOutputAmount, NativeToken, NativeTokens, Output,
OutputBuilderAmount, OutputId, StateTransitionError, StateTransitionVerifier, StorageScore,
StorageScoreParameters,
ChainId, MinimumOutputAmount, NativeToken, NativeTokens, Output, OutputBuilderAmount, OutputId,
StateTransitionError, StateTransitionVerifier, StorageScore, StorageScoreParameters,
},
payload::signed_transaction::TransactionCapabilityFlag,
protocol::ProtocolParameters,
Expand Down Expand Up @@ -555,8 +554,6 @@ impl Packable for AccountOutput {
) -> Result<Self, UnpackError<Self::UnpackError, U::Error>> {
let amount = u64::unpack::<_, VERIFY>(unpacker, &()).coerce()?;

verify_output_amount_packable::<VERIFY>(&amount, visitor).map_err(UnpackError::Packable)?;

let mana = u64::unpack::<_, VERIFY>(unpacker, &()).coerce()?;

let native_tokens = NativeTokens::unpack::<_, VERIFY>(unpacker, &())?;
Expand Down
7 changes: 2 additions & 5 deletions sdk/src/types/block/output/anchor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ use crate::types::block::{
output::{
feature::{verify_allowed_features, Feature, FeatureFlags, Features},
unlock_condition::{verify_allowed_unlock_conditions, UnlockCondition, UnlockConditionFlags, UnlockConditions},
verify_output_amount_packable, ChainId, MinimumOutputAmount, NativeToken, NativeTokens, Output,
OutputBuilderAmount, OutputId, StateTransitionError, StateTransitionVerifier, StorageScore,
StorageScoreParameters,
ChainId, MinimumOutputAmount, NativeToken, NativeTokens, Output, OutputBuilderAmount, OutputId,
StateTransitionError, StateTransitionVerifier, StorageScore, StorageScoreParameters,
},
payload::signed_transaction::TransactionCapabilityFlag,
protocol::ProtocolParameters,
Expand Down Expand Up @@ -622,8 +621,6 @@ impl Packable for AnchorOutput {
) -> Result<Self, UnpackError<Self::UnpackError, U::Error>> {
let amount = u64::unpack::<_, VERIFY>(unpacker, &()).coerce()?;

verify_output_amount_packable::<VERIFY>(&amount, visitor).map_err(UnpackError::Packable)?;

let mana = u64::unpack::<_, VERIFY>(unpacker, &()).coerce()?;

let native_tokens = NativeTokens::unpack::<_, VERIFY>(unpacker, &())?;
Expand Down
7 changes: 3 additions & 4 deletions sdk/src/types/block/output/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ use crate::types::block::{
verify_allowed_unlock_conditions, AddressUnlockCondition, StorageDepositReturnUnlockCondition,
UnlockCondition, UnlockConditionFlags, UnlockConditions,
},
verify_output_amount_packable, MinimumOutputAmount, NativeToken, NativeTokens, Output, OutputBuilderAmount,
OutputId, StorageScore, StorageScoreParameters,
MinimumOutputAmount, NativeToken, NativeTokens, Output, OutputBuilderAmount, OutputId, StorageScore,
StorageScoreParameters,
},
protocol::ProtocolParameters,
semantic::{SemanticValidationContext, TransactionFailureReason},
Expand Down Expand Up @@ -252,7 +252,6 @@ impl From<&BasicOutput> for BasicOutputBuilder {
#[packable(unpack_visitor = ProtocolParameters)]
pub struct BasicOutput {
/// Amount of IOTA coins to deposit with this output.
#[packable(verify_with = verify_output_amount_packable)]
amount: u64,
/// Amount of stored Mana held by this output.
mana: u64,
Expand All @@ -261,8 +260,8 @@ pub struct BasicOutput {
/// Define how the output can be unlocked in a transaction.
#[packable(verify_with = verify_unlock_conditions_packable)]
unlock_conditions: UnlockConditions,
#[packable(verify_with = verify_features_packable)]
/// Features of the output.
#[packable(verify_with = verify_features_packable)]
features: Features,
}

Expand Down
5 changes: 2 additions & 3 deletions sdk/src/types/block/output/delegation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use crate::types::block::{
output::{
chain_id::ChainId,
unlock_condition::{verify_allowed_unlock_conditions, UnlockCondition, UnlockConditionFlags, UnlockConditions},
verify_output_amount_packable, MinimumOutputAmount, Output, OutputBuilderAmount, OutputId,
StateTransitionError, StateTransitionVerifier, StorageScore, StorageScoreParameters,
MinimumOutputAmount, Output, OutputBuilderAmount, OutputId, StateTransitionError, StateTransitionVerifier,
StorageScore, StorageScoreParameters,
},
protocol::ProtocolParameters,
semantic::{SemanticValidationContext, TransactionFailureReason},
Expand Down Expand Up @@ -217,7 +217,6 @@ impl From<&DelegationOutput> for DelegationOutputBuilder {
#[packable(unpack_visitor = ProtocolParameters)]
pub struct DelegationOutput {
/// Amount of IOTA coins to deposit with this output.
#[packable(verify_with = verify_output_amount_packable)]
amount: u64,
/// Amount of delegated IOTA coins.
delegated_amount: u64,
Expand Down
3 changes: 1 addition & 2 deletions sdk/src/types/block/output/feature/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ pub use self::{
tag::TagFeature,
};
use crate::types::block::{
create_bitflags,
output::{StorageScore, StorageScoreParameters},
Error,
};
Expand Down Expand Up @@ -126,7 +125,7 @@ impl Feature {
crate::def_is_as_opt!(Feature: Sender, Issuer, Metadata, Tag, BlockIssuer, Staking);
}

create_bitflags!(
crate::create_bitflags!(
/// A bitflags-based representation of the set of active [`Feature`]s.
pub FeatureFlags,
u16,
Expand Down
7 changes: 2 additions & 5 deletions sdk/src/types/block/output/foundry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ use crate::types::block::{
account::AccountId,
feature::{verify_allowed_features, Feature, FeatureFlags, Features},
unlock_condition::{verify_allowed_unlock_conditions, UnlockCondition, UnlockConditionFlags, UnlockConditions},
verify_output_amount_packable, ChainId, MinimumOutputAmount, NativeToken, NativeTokens, Output,
OutputBuilderAmount, OutputId, StateTransitionError, StateTransitionVerifier, StorageScore,
StorageScoreParameters, TokenId, TokenScheme,
ChainId, MinimumOutputAmount, NativeToken, NativeTokens, Output, OutputBuilderAmount, OutputId,
StateTransitionError, StateTransitionVerifier, StorageScore, StorageScoreParameters, TokenId, TokenScheme,
},
payload::signed_transaction::{TransactionCapabilities, TransactionCapabilityFlag},
protocol::ProtocolParameters,
Expand Down Expand Up @@ -624,8 +623,6 @@ impl Packable for FoundryOutput {
) -> Result<Self, UnpackError<Self::UnpackError, U::Error>> {
let amount = u64::unpack::<_, VERIFY>(unpacker, &()).coerce()?;

verify_output_amount_packable::<VERIFY>(&amount, visitor).map_err(UnpackError::Packable)?;

let native_tokens = NativeTokens::unpack::<_, VERIFY>(unpacker, &())?;
let serial_number = u32::unpack::<_, VERIFY>(unpacker, &()).coerce()?;
let token_scheme = TokenScheme::unpack::<_, VERIFY>(unpacker, &())?;
Expand Down
10 changes: 0 additions & 10 deletions sdk/src/types/block/output/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,16 +460,6 @@ pub(crate) fn verify_output_amount(amount: u64, token_supply: u64) -> Result<(),
verify_output_amount_supply(amount, token_supply)
}

pub(crate) fn verify_output_amount_packable<const VERIFY: bool>(
amount: &u64,
protocol_parameters: &ProtocolParameters,
) -> Result<(), Error> {
if VERIFY {
verify_output_amount(*amount, protocol_parameters.token_supply())?;
}
Ok(())
}

/// A trait that is shared by all output types, which is used to calculate the minimum amount the output
/// must contain to satisfy its storage cost.
pub trait MinimumOutputAmount: StorageScore {
Expand Down
7 changes: 2 additions & 5 deletions sdk/src/types/block/output/nft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ use crate::types::block::{
verify_allowed_unlock_conditions, AddressUnlockCondition, StorageDepositReturnUnlockCondition,
UnlockCondition, UnlockConditionFlags, UnlockConditions,
},
verify_output_amount_packable, BasicOutputBuilder, ChainId, MinimumOutputAmount, NativeToken, NativeTokens,
Output, OutputBuilderAmount, OutputId, StateTransitionError, StateTransitionVerifier, StorageScore,
StorageScoreParameters,
BasicOutputBuilder, ChainId, MinimumOutputAmount, NativeToken, NativeTokens, Output, OutputBuilderAmount,
OutputId, StateTransitionError, StateTransitionVerifier, StorageScore, StorageScoreParameters,
},
payload::signed_transaction::TransactionCapabilityFlag,
protocol::ProtocolParameters,
Expand Down Expand Up @@ -541,8 +540,6 @@ impl Packable for NftOutput {
) -> Result<Self, UnpackError<Self::UnpackError, U::Error>> {
let amount = u64::unpack::<_, VERIFY>(unpacker, &()).coerce()?;

verify_output_amount_packable::<VERIFY>(&amount, visitor).map_err(UnpackError::Packable)?;

let mana = u64::unpack::<_, VERIFY>(unpacker, &()).coerce()?;

let native_tokens = NativeTokens::unpack::<_, VERIFY>(unpacker, &())?;
Expand Down
3 changes: 1 addition & 2 deletions sdk/src/types/block/output/unlock_condition/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ pub use self::{
};
use crate::types::block::{
address::Address,
create_bitflags,
output::{StorageScore, StorageScoreParameters},
protocol::ProtocolParameters,
slot::SlotIndex,
Expand Down Expand Up @@ -135,7 +134,7 @@ impl UnlockCondition {
);
}

create_bitflags!(
crate::create_bitflags!(
/// A bitflags-based representation of the set of active [`UnlockCondition`]s.
pub UnlockConditionFlags,
u16,
Expand Down
3 changes: 3 additions & 0 deletions sdk/src/types/block/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ pub struct ProtocolParameters {
/// TokenSupply defines the current token supply on the network.
#[cfg_attr(feature = "serde", serde(with = "crate::utils::serde::string"))]
pub(crate) token_supply: u64,
/// Defines the slot of the genesis.
pub(crate) genesis_slot: u32,
/// Genesis timestamp at which the slots start to count.
#[cfg_attr(feature = "serde", serde(with = "crate::utils::serde::string"))]
pub(crate) genesis_unix_timestamp: u64,
Expand Down Expand Up @@ -106,6 +108,7 @@ impl Default for ProtocolParameters {
storage_score_parameters: Default::default(),
work_score_parameters: Default::default(),
token_supply: 1_813_620_509_061_365,
genesis_slot: 0,
genesis_unix_timestamp: 1582328545,
slot_duration_in_seconds: 10,
epoch_nearing_threshold: 20,
Expand Down

0 comments on commit d8bc188

Please sign in to comment.