From ddd32047b14713c8b058d71ed13740a02b0a271e Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Tue, 28 Nov 2023 11:52:24 +0100 Subject: [PATCH 1/9] ImplicitAccount transition semantic validation --- sdk/src/types/block/output/account.rs | 34 +++++++++++++++++++++++++-- sdk/src/types/block/output/mod.rs | 9 ++++--- sdk/src/types/block/semantic.rs | 15 +++++++++++- 3 files changed, 50 insertions(+), 8 deletions(-) diff --git a/sdk/src/types/block/output/account.rs b/sdk/src/types/block/output/account.rs index 7ed6167793..5a49438a0c 100644 --- a/sdk/src/types/block/output/account.rs +++ b/sdk/src/types/block/output/account.rs @@ -16,7 +16,7 @@ use crate::types::block::{ output::{ feature::{verify_allowed_features, Feature, FeatureFlags, Features}, unlock_condition::{verify_allowed_unlock_conditions, UnlockCondition, UnlockConditionFlags, UnlockConditions}, - ChainId, MinimumOutputAmount, Output, OutputBuilderAmount, OutputId, StateTransitionError, + BasicOutput, ChainId, MinimumOutputAmount, Output, OutputBuilderAmount, OutputId, StateTransitionError, StateTransitionVerifier, StorageScore, StorageScoreParameters, }, payload::signed_transaction::TransactionCapabilityFlag, @@ -42,7 +42,11 @@ impl From<&OutputId> for AccountId { impl AccountId { /// pub fn or_from_output_id(self, output_id: &OutputId) -> Self { - if self.is_null() { Self::from(output_id) } else { self } + if self.is_null() { + Self::from(output_id) + } else { + self + } } } @@ -453,6 +457,32 @@ impl AccountOutput { Ok(()) } + + pub(crate) fn implicit_transition( + current_state: &BasicOutput, + next_state: &Self, + ) -> Result<(), StateTransitionError> { + if next_state.account_id.is_null() { + // TODO + return Err(StateTransitionError::NonZeroCreatedId); + } + + if let Some(block_issuer) = next_state.features().block_issuer() { + // - The `Account` must have a Block Issuer Feature and it must pass semantic validation as if the implicit account + // contained a Block Issuer Feature with its `Expiry Slot` set to the maximum value of slot indices and the feature + // was transitioned. + } else { + // TODO + } + + // if let Some(issuer) = next_state.immutable_features().issuer() { + // if !context.unlocked_addresses.contains(issuer.address()) { + // return Err(StateTransitionError::IssuerNotUnlocked); + // } + // } + + Ok(()) + } } impl StateTransitionVerifier for AccountOutput { diff --git a/sdk/src/types/block/output/mod.rs b/sdk/src/types/block/output/mod.rs index 7249ba2393..9ef0228a51 100644 --- a/sdk/src/types/block/output/mod.rs +++ b/sdk/src/types/block/output/mod.rs @@ -324,12 +324,11 @@ impl Output { (None, Some(Self::Delegation(next_state))) => DelegationOutput::creation(next_state, context), // Transitions. - (Some(Self::Basic(current_state)), Some(Self::Account(_next_state))) => { - if !current_state.is_implicit_account() { - Err(StateTransitionError::UnsupportedStateTransition) + (Some(Self::Basic(current_state)), Some(Self::Account(next_state))) => { + if current_state.is_implicit_account() { + AccountOutput::implicit_transition(current_state, next_state) } else { - // TODO https://github.com/iotaledger/iota-sdk/issues/1664 - Ok(()) + Err(StateTransitionError::UnsupportedStateTransition) } } (Some(Self::Account(current_state)), Some(Self::Account(next_state))) => { diff --git a/sdk/src/types/block/semantic.rs b/sdk/src/types/block/semantic.rs index b43ebbaab6..cc5c4a3882 100644 --- a/sdk/src/types/block/semantic.rs +++ b/sdk/src/types/block/semantic.rs @@ -8,7 +8,7 @@ use hashbrown::{HashMap, HashSet}; use primitive_types::U256; use crate::types::block::{ - address::{Address, AddressCapabilityFlag}, + address::{Address, AddressCapabilityFlag, ImplicitAccountCreationAddress}, output::{ AccountId, AnchorOutput, ChainId, FoundryId, NativeTokens, Output, OutputId, StateTransitionError, TokenId, UnlockCondition, @@ -264,6 +264,8 @@ impl<'a> SemanticValidationContext<'a> { /// pub fn validate(mut self) -> Result, Error> { // Validation of inputs. + let mut has_implicit_account_creation_address = false; + for ((output_id, consumed_output), unlock) in self.inputs.iter().zip(self.unlocks.iter()) { let (conflict, amount, mana, consumed_native_token, unlock_conditions) = match consumed_output { Output::Basic(output) => ( @@ -308,6 +310,17 @@ impl<'a> SemanticValidationContext<'a> { return Ok(Some(conflict)); } + if unlock_conditions + .address() + .map_or(false, |uc| uc.address().is_implicit_account_creation()) + { + if has_implicit_account_creation_address { + //TODO + } else { + has_implicit_account_creation_address = true; + } + } + if unlock_conditions.is_time_locked(self.transaction.creation_slot()) { return Ok(Some(TransactionFailureReason::TimelockNotExpired)); } From 13816d94082ad31e113ea0c77c87631b34420f38 Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Thu, 18 Jan 2024 11:29:28 +0100 Subject: [PATCH 2/9] nits --- sdk/src/types/block/semantic/mod.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/sdk/src/types/block/semantic/mod.rs b/sdk/src/types/block/semantic/mod.rs index 16454e98d4..7cdabfe7ab 100644 --- a/sdk/src/types/block/semantic/mod.rs +++ b/sdk/src/types/block/semantic/mod.rs @@ -102,6 +102,7 @@ impl<'a> SemanticValidationContext<'a> { pub fn validate(mut self) -> Result, Error> { // Validation of inputs. let mut has_implicit_account_creation_address = false; + for (index, (output_id, consumed_output)) in self.inputs.iter().enumerate() { let (amount, consumed_native_token, unlock_conditions) = match consumed_output { Output::Basic(output) => (output.amount(), output.native_token(), output.unlock_conditions()), @@ -112,12 +113,9 @@ impl<'a> SemanticValidationContext<'a> { Output::Delegation(output) => (output.amount(), None, output.unlock_conditions()), }; - if unlock_conditions - .address() - .map_or(false, |uc| uc.address().is_implicit_account_creation()) - { + if unlock_conditions.addresses().any(Address::is_implicit_account_creation) { if has_implicit_account_creation_address { - // TODO + // TODO which error? } else { has_implicit_account_creation_address = true; } From fc9a4624c16a172a3919fa8ba42648a613b790a4 Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Thu, 18 Jan 2024 11:53:03 +0100 Subject: [PATCH 3/9] move to semantic module --- sdk/src/types/block/output/account.rs | 30 +--------------- .../types/block/semantic/state_transition.rs | 34 +++++++++++++++++-- 2 files changed, 33 insertions(+), 31 deletions(-) diff --git a/sdk/src/types/block/output/account.rs b/sdk/src/types/block/output/account.rs index e22fc4d111..e2792c4362 100644 --- a/sdk/src/types/block/output/account.rs +++ b/sdk/src/types/block/output/account.rs @@ -19,8 +19,7 @@ use crate::types::block::{ verify_allowed_unlock_conditions, verify_restricted_addresses, UnlockCondition, UnlockConditionFlags, UnlockConditions, }, - BasicOutput, ChainId, MinimumOutputAmount, Output, OutputBuilderAmount, OutputId, StorageScore, - StorageScoreParameters, + ChainId, MinimumOutputAmount, Output, OutputBuilderAmount, OutputId, StorageScore, StorageScoreParameters, }, protocol::{ProtocolParameters, WorkScore, WorkScoreParameters}, semantic::StateTransitionError, @@ -438,33 +437,6 @@ impl AccountOutput { Ok(()) } - - pub(crate) fn implicit_transition( - current_state: &BasicOutput, - next_state: &Self, - ) -> Result<(), StateTransitionError> { - if next_state.account_id.is_null() { - // TODO - return Err(StateTransitionError::NonZeroCreatedId); - } - - if let Some(block_issuer) = next_state.features().block_issuer() { - // - The `Account` must have a Block Issuer Feature and it must pass semantic validation as if the implicit - // account - // contained a Block Issuer Feature with its `Expiry Slot` set to the maximum value of slot indices and the - // feature was transitioned. - } else { - // TODO - } - - // if let Some(issuer) = next_state.immutable_features().issuer() { - // if !context.unlocked_addresses.contains(issuer.address()) { - // return Err(StateTransitionError::IssuerNotUnlocked); - // } - // } - - Ok(()) - } } impl StorageScore for AccountOutput { diff --git a/sdk/src/types/block/semantic/state_transition.rs b/sdk/src/types/block/semantic/state_transition.rs index 446ec957ca..a9bb6a20da 100644 --- a/sdk/src/types/block/semantic/state_transition.rs +++ b/sdk/src/types/block/semantic/state_transition.rs @@ -2,7 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 use crate::types::block::{ - output::{AccountOutput, AnchorOutput, ChainId, DelegationOutput, FoundryOutput, NftOutput, Output, TokenScheme}, + output::{ + AccountOutput, AnchorOutput, BasicOutput, ChainId, DelegationOutput, FoundryOutput, NftOutput, Output, + TokenScheme, + }, payload::signed_transaction::TransactionCapabilityFlag, semantic::{SemanticValidationContext, TransactionFailureReason}, }; @@ -74,7 +77,7 @@ impl SemanticValidationContext<'_> { // Transitions. (Some(Output::Basic(current_state)), Some(Output::Account(next_state))) => { if current_state.is_implicit_account() { - AccountOutput::implicit_transition(current_state, next_state) + AccountOutput::implicit_account_transition(current_state, next_state) } else { Err(StateTransitionError::UnsupportedStateTransition) } @@ -102,6 +105,33 @@ impl SemanticValidationContext<'_> { _ => Err(StateTransitionError::UnsupportedStateTransition), } } + + pub(crate) fn implicit_account_transition( + &self, + _current_state: &BasicOutput, + next_state: &AccountOutput, + ) -> Result<(), StateTransitionError> { + if next_state.account_id().is_null() { + // TODO + return Err(StateTransitionError::NonZeroCreatedId); + } + + if let Some(block_issuer) = next_state.features().block_issuer() { + // The Account must have a Block Issuer Feature and it must pass semantic validation as if the implicit + // account contained a Block Issuer Feature with its Expiry Slot set to the maximum value of + // slot indices and the feature was transitioned. + } else { + // TODO + } + + if let Some(issuer) = next_state.immutable_features().issuer() { + if !self.unlocked_addresses.contains(issuer.address()) { + return Err(StateTransitionError::IssuerNotUnlocked); + } + } + + Ok(()) + } } impl StateTransitionVerifier for AccountOutput { From 7b9ab312a4731261ab8fa5ed897de0ec12ca0528 Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Thu, 18 Jan 2024 11:55:35 +0100 Subject: [PATCH 4/9] Add link to PR --- sdk/src/types/block/semantic/state_transition.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/src/types/block/semantic/state_transition.rs b/sdk/src/types/block/semantic/state_transition.rs index a9bb6a20da..aaaafd8320 100644 --- a/sdk/src/types/block/semantic/state_transition.rs +++ b/sdk/src/types/block/semantic/state_transition.rs @@ -117,6 +117,7 @@ impl SemanticValidationContext<'_> { } if let Some(block_issuer) = next_state.features().block_issuer() { + // TODO https://github.com/iotaledger/iota-sdk/issues/1853 // The Account must have a Block Issuer Feature and it must pass semantic validation as if the implicit // account contained a Block Issuer Feature with its Expiry Slot set to the maximum value of // slot indices and the feature was transitioned. From 4b50172a708085853208035a2b610e4fa3845e8d Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Thu, 18 Jan 2024 12:01:17 +0100 Subject: [PATCH 5/9] move to BasicOutput impl --- sdk/src/types/block/semantic/state_transition.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sdk/src/types/block/semantic/state_transition.rs b/sdk/src/types/block/semantic/state_transition.rs index aaaafd8320..e1e53bb1e6 100644 --- a/sdk/src/types/block/semantic/state_transition.rs +++ b/sdk/src/types/block/semantic/state_transition.rs @@ -77,7 +77,7 @@ impl SemanticValidationContext<'_> { // Transitions. (Some(Output::Basic(current_state)), Some(Output::Account(next_state))) => { if current_state.is_implicit_account() { - AccountOutput::implicit_account_transition(current_state, next_state) + BasicOutput::implicit_account_transition(current_state, next_state, self) } else { Err(StateTransitionError::UnsupportedStateTransition) } @@ -105,11 +105,13 @@ impl SemanticValidationContext<'_> { _ => Err(StateTransitionError::UnsupportedStateTransition), } } +} +impl BasicOutput { pub(crate) fn implicit_account_transition( - &self, _current_state: &BasicOutput, next_state: &AccountOutput, + context: &SemanticValidationContext<'_>, ) -> Result<(), StateTransitionError> { if next_state.account_id().is_null() { // TODO @@ -126,7 +128,7 @@ impl SemanticValidationContext<'_> { } if let Some(issuer) = next_state.immutable_features().issuer() { - if !self.unlocked_addresses.contains(issuer.address()) { + if !context.unlocked_addresses.contains(issuer.address()) { return Err(StateTransitionError::IssuerNotUnlocked); } } From ba4d9115fc23f4b92e3f9d8acf8d0e2cb9c8821f Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Thu, 18 Jan 2024 12:09:22 +0100 Subject: [PATCH 6/9] Return SemanticValidationFailed --- sdk/src/types/block/semantic/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/src/types/block/semantic/mod.rs b/sdk/src/types/block/semantic/mod.rs index 7cdabfe7ab..9a201c64e8 100644 --- a/sdk/src/types/block/semantic/mod.rs +++ b/sdk/src/types/block/semantic/mod.rs @@ -115,7 +115,7 @@ impl<'a> SemanticValidationContext<'a> { if unlock_conditions.addresses().any(Address::is_implicit_account_creation) { if has_implicit_account_creation_address { - // TODO which error? + return Ok(Some(TransactionFailureReason::SemanticValidationFailed)); } else { has_implicit_account_creation_address = true; } From 2b15672703f3a3ed4aef9222289d637acbd3586a Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Thu, 18 Jan 2024 12:11:46 +0100 Subject: [PATCH 7/9] Cargo audit --- Cargo.lock | 192 ++++++++++++++++++----------------------------------- 1 file changed, 63 insertions(+), 129 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2a6072b294..7147a9f64b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -81,9 +81,9 @@ checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" [[package]] name = "anstream" -version = "0.6.5" +version = "0.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d664a92ecae85fd0a7392615844904654d1d5f5514837f471ddef4a057aba1b6" +checksum = "3fde6067df7359f2d6335ec1a50c1f8f825801687d10da0cc4c6b08e3f6afd15" dependencies = [ "anstyle", "anstyle-parse", @@ -225,9 +225,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.5" +version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" [[package]] name = "base64ct" @@ -279,9 +279,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.1" +version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" [[package]] name = "bitvec" @@ -456,9 +456,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.13" +version = "4.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52bdc885e4cacc7f7c9eedc1ef6da641603180c783c41a15c264944deeaab642" +checksum = "1e578d6ec4194633722ccf9544794b71b1385c3c027efe0c55db226fc880865c" dependencies = [ "clap_builder", "clap_derive", @@ -466,9 +466,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.12" +version = "4.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb7fb5e4e979aec3be7791562fcba452f94ad85e954da024396433e0e25a79e9" +checksum = "4df4df40ec50c46000231c914968278b1eb05098cf8f1b3a518a95030e71d1c7" dependencies = [ "anstream", "anstyle", @@ -554,15 +554,15 @@ dependencies = [ [[package]] name = "console" -version = "0.15.7" +version = "0.15.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c926e00cc70edefdc64d3a5ff31cc65bb97a3460097762bd23afb4d8145fccf8" +checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb" dependencies = [ "encode_unicode", "lazy_static", "libc", "unicode-width", - "windows-sys 0.45.0", + "windows-sys 0.52.0", ] [[package]] @@ -1215,9 +1215,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" +checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" dependencies = [ "cfg-if", "js-sys", @@ -1313,9 +1313,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.22" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d6250322ef6e60f93f9a2162799302cd6f68f79f6e5d85c8c16f14d1d958178" +checksum = "bb2c4422095b67ee78da96fbb51a4cc413b3b25883c7717ff7ca1ab31022c9c9" dependencies = [ "bytes", "fnv", @@ -1349,9 +1349,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" +checksum = "5d3d0e0f38255e7fa3cf31335b3a56f05febd18025f4db5ef7a0cfb4f8da651f" [[package]] name = "hex" @@ -1555,15 +1555,15 @@ dependencies = [ [[package]] name = "iota-crypto" -version = "0.23.0" +version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5d5a986d972c3a703d48ced24fdc0bf16fb2d02959ff4b152fa77b9132f6fb0" +checksum = "a5db0e2d85e258d6d0db66f4a6bf1e8bdf5b10c3353aa87d98b168778d13fdc1" dependencies = [ "aead", "aes", "aes-gcm", "autocfg", - "base64 0.21.5", + "base64 0.21.7", "blake2", "chacha20poly1305", "cipher", @@ -1609,7 +1609,7 @@ dependencies = [ "anymap", "async-trait", "bech32", - "bitflags 2.4.1", + "bitflags 2.4.2", "bs58", "derive_more", "derive_setters", @@ -1778,18 +1778,18 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.66" +version = "0.3.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cee9c64da59eae3b50095c18d3e74f8b73c0b86d2792824ff01bbce68ba229ca" +checksum = "9a1d36f1235bc969acba30b7f5990b864423a6068a10f7c90ae8f0112e3a59d1" dependencies = [ "wasm-bindgen", ] [[package]] name = "k256" -version = "0.13.2" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f01b677d82ef7a676aa37e099defd83a28e15687112cafdd112d60236b6115b" +checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" dependencies = [ "cfg-if", "ecdsa", @@ -1833,7 +1833,7 @@ version = "0.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "libc", "redox_syscall", ] @@ -1867,9 +1867,9 @@ dependencies = [ [[package]] name = "libz-sys" -version = "1.1.13" +version = "1.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f526fdd09d99e19742883e43de41e1aa9e36db0c7ab7f935165d611c5cccc66" +checksum = "295c17e837573c8c821dbaeb3cceb3d745ad082f7572191409e69cbc1b3fd050" dependencies = [ "cc", "pkg-config", @@ -1878,9 +1878,9 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.4.12" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" +checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" [[package]] name = "lock_api" @@ -1973,7 +1973,7 @@ version = "2.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2fc1cb00cde484640da9f01a124edbb013576a6ae9843b23857c940936b76d91" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "ctor", "napi-derive", "napi-sys", @@ -2049,7 +2049,7 @@ version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "cfg-if", "libc", ] @@ -2265,9 +2265,9 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69d3587f8a9e599cc7ec2c00e331f71c4e69a5f9a4b8a6efd5b07466b9736f9a" +checksum = "2900ede94e305130c13ddd391e0ab7cbaeb783945ae07a279c268cb05109c6cb" [[package]] name = "platforms" @@ -2583,7 +2583,7 @@ version = "0.11.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37b1ae8d9ac08420c66222fb9096fc5de435c3c48542bc5336c51892cffafb41" dependencies = [ - "base64 0.21.5", + "base64 0.21.7", "bytes", "encoding_rs", "futures-core", @@ -2713,11 +2713,11 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.28" +version = "0.38.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316" +checksum = "322394588aaf33c24007e8bb3238ee3e4c5c09c084ab32bc73890b99ff326bca" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "errno", "libc", "linux-raw-sys", @@ -2754,7 +2754,7 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" dependencies = [ - "base64 0.21.5", + "base64 0.21.7", ] [[package]] @@ -2773,7 +2773,7 @@ version = "13.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "02a2d683a4ac90aeef5b1013933f6d977bd37d51ff3f4dad829d4931a7e6be86" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "cfg-if", "clipboard-win", "fd-lock", @@ -3024,9 +3024,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.2" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" +checksum = "2593d31f82ead8df961d8bd23a64c2ccf2eb5dd34b0a34bfb4dd54011c72009e" [[package]] name = "socket2" @@ -3435,9 +3435,9 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.14" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f2528f27a9eb2b21e69c95319b30bd0efd85d09c379741b0f78ea1d86be2416" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" [[package]] name = "unicode-ident" @@ -3551,9 +3551,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e" +checksum = "b1223296a201415c7fad14792dbefaace9bd52b62d33453ade1c5b5f07555406" dependencies = [ "cfg-if", "serde", @@ -3563,9 +3563,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826" +checksum = "fcdc935b63408d58a32f8cc9738a0bffd8f05cc7c002086c6ef20b7312ad9dcd" dependencies = [ "bumpalo", "log", @@ -3578,9 +3578,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.39" +version = "0.4.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac36a15a220124ac510204aec1c3e5db8a22ab06fd6706d881dc6149f8ed9a12" +checksum = "bde2032aeb86bdfaecc8b261eef3cba735cc426c1f3a3416d1e0791be95fc461" dependencies = [ "cfg-if", "js-sys", @@ -3590,9 +3590,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2" +checksum = "3e4c238561b2d428924c49815533a8b9121c664599558a5d9ec51f8a1740a999" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3600,9 +3600,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" +checksum = "bae1abb6806dc1ad9e560ed242107c0f6c84335f1749dd4e8ddb012ebd5e25a7" dependencies = [ "proc-macro2", "quote", @@ -3613,9 +3613,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f" +checksum = "4d91413b1c31d7539ba5ef2451af3f0b833a005eb27a631cec32bc0635a8602b" [[package]] name = "wasm-logger" @@ -3630,9 +3630,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.66" +version = "0.3.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50c24a44ec86bb68fbecd1b3efed7e85ea5621b39b35ef2766b66cd984f8010f" +checksum = "58cd2333b6e0be7a39605f0e255892fd7418a682d8da8fe042fe25128794d2ed" dependencies = [ "js-sys", "wasm-bindgen", @@ -3706,15 +3706,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets 0.42.2", -] - [[package]] name = "windows-sys" version = "0.48.0" @@ -3733,21 +3724,6 @@ dependencies = [ "windows-targets 0.52.0", ] -[[package]] -name = "windows-targets" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" -dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", -] - [[package]] name = "windows-targets" version = "0.48.5" @@ -3778,12 +3754,6 @@ dependencies = [ "windows_x86_64_msvc 0.52.0", ] -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" - [[package]] name = "windows_aarch64_gnullvm" version = "0.48.5" @@ -3802,12 +3772,6 @@ version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" -[[package]] -name = "windows_aarch64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" - [[package]] name = "windows_aarch64_msvc" version = "0.48.5" @@ -3826,12 +3790,6 @@ version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" -[[package]] -name = "windows_i686_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" - [[package]] name = "windows_i686_gnu" version = "0.48.5" @@ -3850,12 +3808,6 @@ version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" -[[package]] -name = "windows_i686_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" - [[package]] name = "windows_i686_msvc" version = "0.48.5" @@ -3874,12 +3826,6 @@ version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" -[[package]] -name = "windows_x86_64_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" - [[package]] name = "windows_x86_64_gnu" version = "0.48.5" @@ -3892,12 +3838,6 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" - [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" @@ -3916,12 +3856,6 @@ version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" -[[package]] -name = "windows_x86_64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" - [[package]] name = "windows_x86_64_msvc" version = "0.48.5" @@ -3936,9 +3870,9 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] name = "winnow" -version = "0.5.33" +version = "0.5.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7520bbdec7211caa7c4e682eb1fbe07abe20cee6756b6e00f537c82c11816aa" +checksum = "b7cf47b659b318dccbd69cc4797a39ae128f533dce7902a1096044d1967b9c16" dependencies = [ "memchr", ] @@ -3961,7 +3895,7 @@ checksum = "e283cc794a890f5bdc01e358ad7c34535025f79ba83c1b5c7e01e5d6c60b336d" dependencies = [ "async-tungstenite", "async_io_stream", - "bitflags 2.4.1", + "bitflags 2.4.2", "futures-core", "futures-io", "futures-sink", From c166f0b8b5c2b5e116d585d59539afabc3ff8a16 Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Thu, 18 Jan 2024 16:55:11 +0100 Subject: [PATCH 8/9] Clippy --- sdk/src/types/block/semantic/state_transition.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/src/types/block/semantic/state_transition.rs b/sdk/src/types/block/semantic/state_transition.rs index e1e53bb1e6..bb61052e43 100644 --- a/sdk/src/types/block/semantic/state_transition.rs +++ b/sdk/src/types/block/semantic/state_transition.rs @@ -109,7 +109,7 @@ impl SemanticValidationContext<'_> { impl BasicOutput { pub(crate) fn implicit_account_transition( - _current_state: &BasicOutput, + _current_state: &Self, next_state: &AccountOutput, context: &SemanticValidationContext<'_>, ) -> Result<(), StateTransitionError> { @@ -118,7 +118,7 @@ impl BasicOutput { return Err(StateTransitionError::NonZeroCreatedId); } - if let Some(block_issuer) = next_state.features().block_issuer() { + if let Some(_block_issuer) = next_state.features().block_issuer() { // TODO https://github.com/iotaledger/iota-sdk/issues/1853 // The Account must have a Block Issuer Feature and it must pass semantic validation as if the implicit // account contained a Block Issuer Feature with its Expiry Slot set to the maximum value of From 6d08dc9c67cc2c43ade587867511219ae07afbc2 Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Thu, 18 Jan 2024 16:59:21 +0100 Subject: [PATCH 9/9] Better errors --- sdk/src/types/block/semantic/state_transition.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sdk/src/types/block/semantic/state_transition.rs b/sdk/src/types/block/semantic/state_transition.rs index bb61052e43..8ab3364e03 100644 --- a/sdk/src/types/block/semantic/state_transition.rs +++ b/sdk/src/types/block/semantic/state_transition.rs @@ -22,6 +22,7 @@ pub enum StateTransitionError { InconsistentNativeTokensTransition, InconsistentNativeTokensMeltBurn, InvalidDelegatedAmount, + InvalidBlockIssuerTransition, IssuerNotUnlocked, MissingAccountForFoundry, MutatedFieldWithoutRights, @@ -36,6 +37,7 @@ pub enum StateTransitionError { UnsupportedStateIndexOperation { current_state: u32, next_state: u32 }, UnsupportedStateTransition, TransactionFailure(TransactionFailureReason), + ZeroCreatedId, } impl From for StateTransitionError { @@ -114,8 +116,7 @@ impl BasicOutput { context: &SemanticValidationContext<'_>, ) -> Result<(), StateTransitionError> { if next_state.account_id().is_null() { - // TODO - return Err(StateTransitionError::NonZeroCreatedId); + return Err(StateTransitionError::ZeroCreatedId); } if let Some(_block_issuer) = next_state.features().block_issuer() { @@ -124,7 +125,7 @@ impl BasicOutput { // account contained a Block Issuer Feature with its Expiry Slot set to the maximum value of // slot indices and the feature was transitioned. } else { - // TODO + return Err(StateTransitionError::InvalidBlockIssuerTransition); } if let Some(issuer) = next_state.immutable_features().issuer() {