From e025cb64cd86de3973fb27fc2ec67bda1b59ff77 Mon Sep 17 00:00:00 2001 From: Leonardo Razovic <4128940+lrazovic@users.noreply.github.com> Date: Wed, 27 Mar 2024 11:44:11 +0100 Subject: [PATCH 1/5] feat: expose the `VerifierPublicKey` as constant --- pallets/funding/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index 1545b18c2..85a9dffc6 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -436,6 +436,7 @@ pub mod pallet { type ContributionTreasury: Get>; /// The Ed25519 Verifier Public Key of credential JWTs + #[pallet::constant] type VerifierPublicKey: Get<[u8; 32]>; /// The type used for vesting From ae895bcbfdf79af57139873c9aaeb28df304e12f Mon Sep 17 00:00:00 2001 From: Leonardo Razovic <4128940+lrazovic@users.noreply.github.com> Date: Wed, 27 Mar 2024 11:44:28 +0100 Subject: [PATCH 2/5] feat: extract the time in milliseconds --- polimec-common/common/src/credentials/mod.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/polimec-common/common/src/credentials/mod.rs b/polimec-common/common/src/credentials/mod.rs index 35b408964..2ba5e3a97 100644 --- a/polimec-common/common/src/credentials/mod.rs +++ b/polimec-common/common/src/credentials/mod.rs @@ -80,11 +80,12 @@ where let Some(who) = origin.clone().into_signer() else { return Err(origin) }; let Ok(token) = Self::verify_token(token, verifying_key) else { return Err(origin) }; let Ok(claims) = Self::extract_claims(&token) else { return Err(origin) }; + // Get the current timestamp from the pallet_timestamp. It is in milliseconds. let Ok(now) = Now::::get().try_into() else { return Err(origin) }; let Some(date_time) = claims.expiration else { return Err(origin) }; - if claims.custom.subject == who && (date_time.timestamp() as u64) >= now { - return Ok((who, claims.custom.did.clone(), claims.custom.investor_type.clone())); + if claims.custom.subject == who && (date_time.timestamp_millis() as u64) >= now { + return Ok((who, claims.custom.did.clone(), claims.custom.investor_type.clone())); } Err(origin) From 142be66532d30e9bf7f68bb059a2e10b52a94a6d Mon Sep 17 00:00:00 2001 From: Leonardo Razovic <4128940+lrazovic@users.noreply.github.com> Date: Wed, 27 Mar 2024 11:44:54 +0100 Subject: [PATCH 3/5] feat: use a fresh set of relay/para nodes --- scripts/zombienet/native/local-testnet.toml | 48 +++++++++++++-------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/scripts/zombienet/native/local-testnet.toml b/scripts/zombienet/native/local-testnet.toml index 5f0a26da4..2dca06982 100644 --- a/scripts/zombienet/native/local-testnet.toml +++ b/scripts/zombienet/native/local-testnet.toml @@ -2,31 +2,41 @@ timeout = 1000 provider = "native" +# Using Rococo 1.7.0 as relay. [relaychain] -default_command = "polkadot" +default_command = "../polkadot-sdk/target/release/polkadot" chain = "rococo-local" - [[relaychain.nodes]] - name = "eve" +[[relaychain.nodes]] +name = "eve" - [[relaychain.nodes]] - name = "ferdie" +[[relaychain.nodes]] +name = "ferdie" - [[relaychain.nodes]] - name = "charlie" +[[relaychain.nodes]] +name = "charlie" - [[relaychain.nodes]] - name = "dave" +[[relaychain.nodes]] +name = "dave" [[parachains]] id = 3344 -chain = "polimec-rococo-local" - - [[parachains.collators]] - name = "alice" - command = "polimec" - ws_port = 8080 - - [[parachains.collators]] - name = "bob" - command = "polimec" +chain = "politest-local" + +[[parachains.collators]] +name = "alice" +command = "./target/release/polimec-node" +args = [ + "-lcredentials::try_origin", + "-lcredentials::ensure_origin" +] +ws_port = 8080 + +[[parachains.collators]] +name = "bob" +command = "./target/release/polimec-node" +args = [ + "-lcredentials::try_origin", + "-lcredentials::ensure_origin" +] +ws_port = 8081 From 2372b38c24f97ee739543083a79dc146a6302136 Mon Sep 17 00:00:00 2001 From: Leonardo Razovic <4128940+lrazovic@users.noreply.github.com> Date: Wed, 27 Mar 2024 11:47:11 +0100 Subject: [PATCH 4/5] chore: fmt --- polimec-common/common/src/credentials/mod.rs | 2 +- runtimes/politest/src/lib.rs | 2 +- runtimes/shared-configuration/src/currency.rs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/polimec-common/common/src/credentials/mod.rs b/polimec-common/common/src/credentials/mod.rs index 2ba5e3a97..d765bb98b 100644 --- a/polimec-common/common/src/credentials/mod.rs +++ b/polimec-common/common/src/credentials/mod.rs @@ -85,7 +85,7 @@ where let Some(date_time) = claims.expiration else { return Err(origin) }; if claims.custom.subject == who && (date_time.timestamp_millis() as u64) >= now { - return Ok((who, claims.custom.did.clone(), claims.custom.investor_type.clone())); + return Ok((who, claims.custom.did.clone(), claims.custom.investor_type.clone())); } Err(origin) diff --git a/runtimes/politest/src/lib.rs b/runtimes/politest/src/lib.rs index fd927756b..b25de295a 100644 --- a/runtimes/politest/src/lib.rs +++ b/runtimes/politest/src/lib.rs @@ -37,7 +37,7 @@ use frame_support::{ }; use frame_system::{EnsureNever, EnsureRoot, EnsureRootWithSuccess, EnsureSigned}; use pallet_democracy::GetElectorate; -use pallet_funding::{DaysToBlocks}; +use pallet_funding::DaysToBlocks; use parachains_common::{ message_queue::{NarrowOriginToSibling, ParaIdToSibling}, diff --git a/runtimes/shared-configuration/src/currency.rs b/runtimes/shared-configuration/src/currency.rs index a305124df..190bbb0d7 100644 --- a/runtimes/shared-configuration/src/currency.rs +++ b/runtimes/shared-configuration/src/currency.rs @@ -16,10 +16,10 @@ use crate::Balance; use frame_support::parameter_types; -use parachains_common::AssetIdForTrustBackedAssets as AssetId; use pallet_funding::AcceptedFundingAsset; -use sp_runtime::{traits::Convert, FixedU128}; use pallet_oracle_ocw::types::AssetName; +use parachains_common::AssetIdForTrustBackedAssets as AssetId; +use sp_runtime::{traits::Convert, FixedU128}; /// One PLMC pub const PLMC: Balance = 10u128.pow(10); From 82f9d3f56dc25fd0654950924e97c6563cd4ea98 Mon Sep 17 00:00:00 2001 From: Leonardo Razovic <4128940+lrazovic@users.noreply.github.com> Date: Wed, 3 Apr 2024 12:19:02 +0200 Subject: [PATCH 5/5] Update local-testnet.toml --- scripts/zombienet/native/local-testnet.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/zombienet/native/local-testnet.toml b/scripts/zombienet/native/local-testnet.toml index 2dca06982..772d7dc5a 100644 --- a/scripts/zombienet/native/local-testnet.toml +++ b/scripts/zombienet/native/local-testnet.toml @@ -4,7 +4,7 @@ provider = "native" # Using Rococo 1.7.0 as relay. [relaychain] -default_command = "../polkadot-sdk/target/release/polkadot" +default_command = "./bin/polkadot" chain = "rococo-local" [[relaychain.nodes]]