From 2a38c83c659f71ad79e5fe4d98f02a321c630ed2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Andr=C3=A9s=20Dorado=20Su=C3=A1rez?= Date: Wed, 14 May 2025 22:25:06 -0500 Subject: [PATCH 1/2] chore(Cargo): update dependencies --- Cargo.lock | 72 +++++++++++++++++++++++++++--------------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fe7b6e76..7d81cda8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -802,9 +802,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.9.0" +version = "2.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" +checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" [[package]] name = "bitvec" @@ -2369,7 +2369,7 @@ checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" [[package]] name = "fc-pallet-communities" version = "1.0.0" -source = "git+https://github.com/virto-network/frame-contrib#2e4ecbee97236e24175632381e9260ce66064d55" +source = "git+https://github.com/virto-network/frame-contrib#a5249d5abcb69e9103a233a1773be6b670a881ee" dependencies = [ "frame-benchmarking", "frame-contrib-traits", @@ -2386,7 +2386,7 @@ dependencies = [ [[package]] name = "fc-pallet-gas-transaction-payment" version = "1.0.0" -source = "git+https://github.com/virto-network/frame-contrib#2e4ecbee97236e24175632381e9260ce66064d55" +source = "git+https://github.com/virto-network/frame-contrib#a5249d5abcb69e9103a233a1773be6b670a881ee" dependencies = [ "frame-contrib-traits", "parity-scale-codec", @@ -2397,7 +2397,7 @@ dependencies = [ [[package]] name = "fc-pallet-listings" version = "1.0.0" -source = "git+https://github.com/virto-network/frame-contrib#2e4ecbee97236e24175632381e9260ce66064d55" +source = "git+https://github.com/virto-network/frame-contrib#a5249d5abcb69e9103a233a1773be6b670a881ee" dependencies = [ "fc-traits-listings", "frame-benchmarking", @@ -2415,7 +2415,7 @@ dependencies = [ [[package]] name = "fc-pallet-orders" version = "1.0.0" -source = "git+https://github.com/virto-network/frame-contrib#2e4ecbee97236e24175632381e9260ce66064d55" +source = "git+https://github.com/virto-network/frame-contrib#a5249d5abcb69e9103a233a1773be6b670a881ee" dependencies = [ "frame-benchmarking", "frame-contrib-traits", @@ -2431,7 +2431,7 @@ dependencies = [ [[package]] name = "fc-pallet-pass" version = "1.0.0" -source = "git+https://github.com/virto-network/frame-contrib#2e4ecbee97236e24175632381e9260ce66064d55" +source = "git+https://github.com/virto-network/frame-contrib#a5249d5abcb69e9103a233a1773be6b670a881ee" dependencies = [ "fc-traits-authn", "frame-benchmarking", @@ -2447,7 +2447,7 @@ dependencies = [ [[package]] name = "fc-pallet-payments" version = "0.1.0" -source = "git+https://github.com/virto-network/frame-contrib#2e4ecbee97236e24175632381e9260ce66064d55" +source = "git+https://github.com/virto-network/frame-contrib#a5249d5abcb69e9103a233a1773be6b670a881ee" dependencies = [ "fc-traits-payments", "frame-benchmarking", @@ -2464,7 +2464,7 @@ dependencies = [ [[package]] name = "fc-pallet-referenda-tracks" version = "1.0.0" -source = "git+https://github.com/virto-network/frame-contrib#2e4ecbee97236e24175632381e9260ce66064d55" +source = "git+https://github.com/virto-network/frame-contrib#a5249d5abcb69e9103a233a1773be6b670a881ee" dependencies = [ "fc-traits-tracks", "frame-benchmarking", @@ -2482,7 +2482,7 @@ dependencies = [ [[package]] name = "fc-traits-authn" version = "0.1.0" -source = "git+https://github.com/virto-network/frame-contrib#2e4ecbee97236e24175632381e9260ce66064d55" +source = "git+https://github.com/virto-network/frame-contrib#a5249d5abcb69e9103a233a1773be6b670a881ee" dependencies = [ "fc-traits-authn-proc", "frame-support", @@ -2494,7 +2494,7 @@ dependencies = [ [[package]] name = "fc-traits-authn-proc" version = "0.1.0" -source = "git+https://github.com/virto-network/frame-contrib#2e4ecbee97236e24175632381e9260ce66064d55" +source = "git+https://github.com/virto-network/frame-contrib#a5249d5abcb69e9103a233a1773be6b670a881ee" dependencies = [ "proc-macro-crate 3.3.0", "quote", @@ -2504,7 +2504,7 @@ dependencies = [ [[package]] name = "fc-traits-gas-tank" version = "0.1.0" -source = "git+https://github.com/virto-network/frame-contrib#2e4ecbee97236e24175632381e9260ce66064d55" +source = "git+https://github.com/virto-network/frame-contrib#a5249d5abcb69e9103a233a1773be6b670a881ee" dependencies = [ "fc-traits-nonfungibles-helpers", "frame-support", @@ -2516,7 +2516,7 @@ dependencies = [ [[package]] name = "fc-traits-listings" version = "0.1.0" -source = "git+https://github.com/virto-network/frame-contrib#2e4ecbee97236e24175632381e9260ce66064d55" +source = "git+https://github.com/virto-network/frame-contrib#a5249d5abcb69e9103a233a1773be6b670a881ee" dependencies = [ "frame-support", "frame-system", @@ -2527,7 +2527,7 @@ dependencies = [ [[package]] name = "fc-traits-memberships" version = "0.1.0" -source = "git+https://github.com/virto-network/frame-contrib#2e4ecbee97236e24175632381e9260ce66064d55" +source = "git+https://github.com/virto-network/frame-contrib#a5249d5abcb69e9103a233a1773be6b670a881ee" dependencies = [ "frame-support", "parity-scale-codec", @@ -2537,12 +2537,12 @@ dependencies = [ [[package]] name = "fc-traits-nonfungibles-helpers" version = "0.1.0" -source = "git+https://github.com/virto-network/frame-contrib#2e4ecbee97236e24175632381e9260ce66064d55" +source = "git+https://github.com/virto-network/frame-contrib#a5249d5abcb69e9103a233a1773be6b670a881ee" [[package]] name = "fc-traits-payments" version = "0.1.0" -source = "git+https://github.com/virto-network/frame-contrib#2e4ecbee97236e24175632381e9260ce66064d55" +source = "git+https://github.com/virto-network/frame-contrib#a5249d5abcb69e9103a233a1773be6b670a881ee" dependencies = [ "frame-support", "impl-trait-for-tuples", @@ -2553,7 +2553,7 @@ dependencies = [ [[package]] name = "fc-traits-tracks" version = "0.1.0" -source = "git+https://github.com/virto-network/frame-contrib#2e4ecbee97236e24175632381e9260ce66064d55" +source = "git+https://github.com/virto-network/frame-contrib#a5249d5abcb69e9103a233a1773be6b670a881ee" dependencies = [ "frame-support", "pallet-referenda", @@ -2706,7 +2706,7 @@ dependencies = [ [[package]] name = "frame-contrib-traits" version = "0.1.0" -source = "git+https://github.com/virto-network/frame-contrib#2e4ecbee97236e24175632381e9260ce66064d55" +source = "git+https://github.com/virto-network/frame-contrib#a5249d5abcb69e9103a233a1773be6b670a881ee" dependencies = [ "fc-traits-authn", "fc-traits-gas-tank", @@ -4750,7 +4750,7 @@ dependencies = [ "thiserror 1.0.69", "tracing", "yamux 0.12.1", - "yamux 0.13.4", + "yamux 0.13.5", ] [[package]] @@ -4759,7 +4759,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.9.1", "libc", "redox_syscall 0.5.12", ] @@ -4931,7 +4931,7 @@ dependencies = [ "url 2.5.4 (registry+https://github.com/rust-lang/crates.io-index)", "x25519-dalek", "x509-parser 0.17.0", - "yamux 0.13.4", + "yamux 0.13.5", "yasna", "zeroize", ] @@ -5135,7 +5135,7 @@ dependencies = [ [[package]] name = "mock-helpers" version = "0.1.0" -source = "git+https://github.com/virto-network/frame-contrib#2e4ecbee97236e24175632381e9260ce66064d55" +source = "git+https://github.com/virto-network/frame-contrib#a5249d5abcb69e9103a233a1773be6b670a881ee" dependencies = [ "fc-pallet-listings", "frame-support", @@ -6520,7 +6520,7 @@ checksum = "7924d1d0ad836f665c9065e26d016c673ece3993f30d340068b16f282afc1156" [[package]] name = "pass-webauthn" version = "0.1.0" -source = "git+https://github.com/virto-network/webauthn#0032805222dc77c23bfca1f2344d13b7b0f00ab8" +source = "git+https://github.com/virto-network/webauthn#de7c78c48b188741e396b2e2a12718416ba1305c" dependencies = [ "fc-traits-authn", "log", @@ -7501,7 +7501,7 @@ version = "0.5.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "928fca9cf2aa042393a8325b9ead81d2f0df4cb12e1e24cef072922ccd99c5af" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.9.1", ] [[package]] @@ -7606,9 +7606,9 @@ checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "resolv-conf" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc7c8f7f733062b66dc1c63f9db168ac0b97a9210e247fa90fdc9ad08f51b302" +checksum = "95325155c684b1c89f7765e30bc1c42e4a6da51ca513615660cb8a62ef9a88e3" [[package]] name = "rfc6979" @@ -7807,7 +7807,7 @@ version = "0.38.44" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.9.1", "errno", "libc", "linux-raw-sys 0.4.15", @@ -7820,7 +7820,7 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c71e83d6afe7ff64890ec6b71d6a69bb8a610ab78ce364b3352876bb4c801266" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.9.1", "errno", "libc", "linux-raw-sys 0.9.4", @@ -8426,7 +8426,7 @@ version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "271720403f46ca04f7ba6f55d438f8bd878d6b8ca0a1046e8228c4145bcbb316" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.9.1", "core-foundation 0.10.0", "core-foundation-sys", "libc", @@ -8633,7 +8633,7 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dee851d0e5e7af3721faea1843e8015e820a234f81fda3dea9247e15bac9a86a" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.9.1", ] [[package]] @@ -9735,7 +9735,7 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.9.1", "core-foundation 0.9.4", "system-configuration-sys", ] @@ -10332,7 +10332,7 @@ checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" [[package]] name = "verifier" version = "0.1.0" -source = "git+https://github.com/virto-network/webauthn#0032805222dc77c23bfca1f2344d13b7b0f00ab8" +source = "git+https://github.com/virto-network/webauthn#de7c78c48b188741e396b2e2a12718416ba1305c" dependencies = [ "log", "p256", @@ -11258,7 +11258,7 @@ version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.9.1", ] [[package]] @@ -11399,16 +11399,16 @@ dependencies = [ [[package]] name = "yamux" -version = "0.13.4" +version = "0.13.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17610762a1207ee816c6fadc29220904753648aba0a9ed61c7b8336e80a559c4" +checksum = "3da1acad1c2dc53f0dde419115a38bd8221d8c3e47ae9aeceaf453266d29307e" dependencies = [ "futures", "log", "nohash-hasher", "parking_lot 0.12.3", "pin-project", - "rand 0.8.5", + "rand 0.9.1", "static_assertions", "web-time", ] From 75f949809c7cc8c19280d5a272e6e3bbfc5de487 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Andr=C3=A9s=20Dorado=20Su=C3=A1rez?= Date: Wed, 14 May 2025 22:26:34 -0500 Subject: [PATCH 2/2] chore(kreivo-runtime): update `pallet-pass` config, and add `PassAuthenticate` tx extension --- runtime/kreivo/src/config/system.rs | 137 +++++++++++++++------- runtime/kreivo/src/lib.rs | 17 +-- runtime/kreivo/src/weights/pallet_pass.rs | 9 +- 3 files changed, 109 insertions(+), 54 deletions(-) diff --git a/runtime/kreivo/src/config/system.rs b/runtime/kreivo/src/config/system.rs index 3149ab4e..defc295a 100644 --- a/runtime/kreivo/src/config/system.rs +++ b/runtime/kreivo/src/config/system.rs @@ -2,16 +2,25 @@ use super::*; -use frame_support::{derive_impl, dispatch::DispatchClass, traits::EnsureOrigin, PalletId}; -use frame_system::{limits::BlockLength, EnsureRootWithSuccess}; -use sp_runtime::traits::{LookupError, StaticLookup}; - use cumulus_pallet_parachain_system::{DefaultCoreSelector, RelayNumberMonotonicallyIncreases}; -use parachains_common::{AVERAGE_ON_INITIALIZE_RATIO, NORMAL_DISPATCH_RATIO}; -use polkadot_runtime_common::BlockHashCount; - use frame_contrib_traits::authn::{composite_authenticator, util::AuthorityFromPalletId, Challenge, Challenger}; +use frame_support::traits::{AsEnsureOriginWithArg, LinearStoragePrice}; +use frame_support::{ + derive_impl, + dispatch::DispatchClass, + traits::{fungible::HoldConsideration, Consideration, Footprint}, + PalletId, +}; +use frame_system::{limits::BlockLength, EnsureRootWithSuccess, EnsureSigned}; use pallet_communities::origin::AsSignedByCommunity; +use pallet_pass::FirstItemIsFree; +use parachains_common::{AVERAGE_ON_INITIALIZE_RATIO, NORMAL_DISPATCH_RATIO}; +use polkadot_runtime_common::BlockHashCount; +use sp_core::ConstU128; +use sp_runtime::{ + traits::{AccountIdConversion, LookupError, StaticLookup}, + DispatchError, +}; // #[runtime::pallet_index(0)] // pub type System @@ -172,64 +181,102 @@ composite_authenticator!( } ); -/// Communities don't need to pay deposit fees to create a `pass` account -pub struct CommunitiesDontDeposit; +#[derive(Debug, Eq, PartialEq, Clone, Encode, Decode, DecodeWithMemTracking, MaxEncodedLen, TypeInfo)] +pub struct SkipConsideration(Option); + +const ACCOUNT_IS_ROOT: fn(&AccountId) -> bool = |acct| acct == &TreasuryAccount::get(); +const ACCOUNT_IS_COMMUNITY: fn(&AccountId) -> bool = |acct| { + PalletId::try_from_sub_account::(acct) + .is_some_and(|(id, _)| id == communities::CommunityPalletId::get()) +}; -impl EnsureOriginWithArg for CommunitiesDontDeposit +impl Consideration for SkipConsideration where - OuterOrigin: frame_support::traits::OriginTrait - + From> - + From> - + Clone - + Into, OuterOrigin>> - + Into, OuterOrigin>>, + C: Consideration, { - type Success = Option>; + fn new(who: &AccountId, new: Footprint) -> Result { + if ACCOUNT_IS_ROOT(who) || ACCOUNT_IS_COMMUNITY(who) { + Ok(Self(None)) + } else { + C::new(who, new).map(Some).map(Self) + } + } - fn try_origin(o: OuterOrigin, _: &HashedUserId) -> Result { - AsSignedByCommunity::::try_origin(o)?; - Ok(None) + fn update(self, who: &AccountId, new: Footprint) -> Result { + if let Some(c) = self.0 { + c.update(who, new).map(Some).map(Self) + } else { + Ok(self) + } + } + + fn drop(self, who: &AccountId) -> Result<(), DispatchError> { + if let Some(c) = self.0 { + c.drop(who) + } else { + Ok(()) + } } #[cfg(feature = "runtime-benchmarks")] - fn try_successful_origin(_: &HashedUserId) -> Result { - use pallet_communities::BenchmarkHelper; - let community_id = communities::CommunityBenchmarkHelper::community_id(); - Ok( - frame_system::RawOrigin::Signed(pallet_communities::Pallet::::community_account(&community_id)) - .into(), - ) + fn ensure_successful(who: &AccountId, new: Footprint) { + C::ensure_successful(who, new); } } +parameter_types! { + pub AccountRegistrationReason: RuntimeHoldReason = RuntimeHoldReason::Pass(pallet_pass::HoldReason::AccountRegistration); + pub AccountDevicesReason: RuntimeHoldReason = RuntimeHoldReason::Pass(pallet_pass::HoldReason::AccountDevices); + pub SessionKeysReason: RuntimeHoldReason = RuntimeHoldReason::Pass(pallet_pass::HoldReason::SessionKeys); +} impl pallet_pass::Config for Runtime { type RuntimeEvent = RuntimeEvent; + type PalletsOrigin = OriginCaller; type RuntimeCall = RuntimeCall; - type Currency = Balances; type WeightInfo = weights::pallet_pass::WeightInfo; + type RegisterOrigin = EitherOf< + // Root can create pass accounts. + EnsureRootWithSuccess, + EitherOf< + // Communities can create pass accounts. + AsEnsureOriginWithArg>, + // Anyone can create pass accounts. + AsEnsureOriginWithArg>, + >, + >; + type AddressGenerator = (); + type Balances = Balances; #[cfg(not(feature = "runtime-benchmarks"))] type Authenticator = PassAuthenticator; #[cfg(feature = "runtime-benchmarks")] type Authenticator = benchmarks::PassAuthenticator; - type PalletsOrigin = OriginCaller; - type PalletId = PassPalletId; - type MaxSessionDuration = ConstU32<{ 15 * MINUTES }>; - type RegisterOrigin = EitherOf< - // Root never pays - EnsureRootWithSuccess, - EitherOf< - // Communities never pay - CommunitiesDontDeposit, - // Signed users must deposit ED for creating a pass account - pallet_pass::EnsureSignedPays< - Runtime, - ::ExistentialDeposit, - TreasuryAccount, - >, + type Scheduler = Scheduler; + type RegistrarConsideration = SkipConsideration< + HoldConsideration< + AccountId, + Balances, + AccountRegistrationReason, + LinearStoragePrice, ConstU128, Balance>, >, >; - type Scheduler = Scheduler; - + type DeviceConsideration = FirstItemIsFree< + HoldConsideration< + AccountId, + Balances, + AccountDevicesReason, + LinearStoragePrice, ConstU128<{ MILLICENTS / 10 }>, Balance>, + >, + >; + type SessionKeyConsideration = FirstItemIsFree< + HoldConsideration< + AccountId, + Balances, + SessionKeysReason, + LinearStoragePrice, ConstU128<{ MILLICENTS / 10 }>, Balance>, + >, + >; + type PalletId = PassPalletId; + type MaxSessionDuration = ConstU32<{ 15 * MINUTES }>; #[cfg(feature = "runtime-benchmarks")] type BenchmarkHelper = benchmarks::PassBenchmarkHelper; } diff --git a/runtime/kreivo/src/lib.rs b/runtime/kreivo/src/lib.rs index 8f3b5f30..576d84ec 100644 --- a/runtime/kreivo/src/lib.rs +++ b/runtime/kreivo/src/lib.rs @@ -67,7 +67,7 @@ pub use weights::{BlockExecutionWeight, ExtrinsicBaseWeight}; use pallet_asset_tx_payment::ChargeAssetTxPayment; use pallet_gas_transaction_payment::ChargeTransactionPayment as ChargeGasTxPayment; -use pallet_pass::ChargeTransactionToPassAccount as ChargeTxToPassAccount; +use pallet_pass::PassAuthenticate; use pallet_skip_feeless_payment::SkipCheckIfFeeless; // XCM Imports @@ -93,25 +93,26 @@ pub type SignedBlock = generic::SignedBlock; pub type ChargeTransaction = ChargeGasTxPayment>; -/// The SignedExtension to the basic transaction logic. -pub type SignedExtra = ( +/// The TransactionExtensions to the basic transaction logic. +pub type TransactionExtensions = ( + PassAuthenticate, frame_system::CheckNonZeroSender, frame_system::CheckSpecVersion, frame_system::CheckTxVersion, frame_system::CheckGenesis, frame_system::CheckEra, - SkipCheckIfFeeless>, + frame_system::CheckNonce, frame_system::CheckWeight, - SkipCheckIfFeeless>, + SkipCheckIfFeeless, ); /// Unchecked extrinsic type as expected by this runtime. -pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; +pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; -pub type SignedPayload = generic::SignedPayload; +pub type SignedPayload = generic::SignedPayload; /// Extrinsic type that has already been checked. -pub type CheckedExtrinsic = generic::CheckedExtrinsic; +pub type CheckedExtrinsic = generic::CheckedExtrinsic; /// A list of migrations that need to undergo. pub type Migrations = ( diff --git a/runtime/kreivo/src/weights/pallet_pass.rs b/runtime/kreivo/src/weights/pallet_pass.rs index 032f7fe0..89514ee5 100644 --- a/runtime/kreivo/src/weights/pallet_pass.rs +++ b/runtime/kreivo/src/weights/pallet_pass.rs @@ -79,7 +79,14 @@ impl pallet_pass::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().writes(2)) } - fn dispatch() -> Weight { + fn remove_device() -> Weight { + Weight::from_parts(53_969_000, 0) + .saturating_add(Weight::from_parts(0, 3593)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(2)) + } + + fn add_session_key() -> Weight { Weight::from_parts(53_969_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(1))