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

Polimec runtime upgrade 0.7.0 #274

Merged
merged 6 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
5 changes: 5 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions polimec-common/test-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

use frame_support::{sp_runtime::app_crypto::sp_core::bytes::to_hex, traits::ConstU32, BoundedVec, Parameter};
use jwt_compact::{alg::Ed25519, AlgorithmExt, Header};
use parity_scale_codec::alloc::string::ToString;
use polimec_common::credentials::{Did, InvestorType, SampleClaims, UntrustedToken};

/// Fetches a JWT from a dummy Polimec JWT producer that will return a JWT with the specified investor type
Expand Down
23 changes: 21 additions & 2 deletions runtimes/polimec/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@ scale-info = { workspace= true, default-features = false, features = [
sp-debug-derive = { workspace = true, features = ["force-debug"]}


# Local
pallet-parachain-staking.workspace = true
# Polimec specific
pallet-dispenser.workspace = true
pallet-funding.workspace = true
pallet-oracle-ocw.workspace = true
pallet-linear-release.workspace = true
shared-configuration.workspace = true
polimec-common.workspace = true
pallet-parachain-staking.workspace = true

# Substrate
frame-benchmarking = { workspace = true, optional = true }
Expand All @@ -47,6 +51,7 @@ pallet-collective.workspace = true
pallet-democracy.workspace = true
pallet-elections-phragmen.workspace = true
pallet-identity.workspace = true
pallet-insecure-randomness-collective-flip.workspace = true
pallet-membership.workspace = true
pallet-message-queue.workspace = true
pallet-multisig.workspace = true
Expand Down Expand Up @@ -128,8 +133,12 @@ std = [
"pallet-balances/std",
"pallet-collective/std",
"pallet-democracy/std",
"pallet-dispenser/std",
"pallet-elections-phragmen/std",
"pallet-funding/std",
"pallet-identity/std",
"pallet-insecure-randomness-collective-flip/std",
"pallet-linear-release/std",
"pallet-membership/std",
"pallet-message-queue/std",
"pallet-multisig/std",
Expand All @@ -149,6 +158,7 @@ std = [
"parachain-info/std",
"parachains-common/std",
"parity-scale-codec/std",
"polimec-common/std",
"polimec-xcm-executor/std",
"polkadot-parachain-primitives/std",
"polkadot-runtime-common/std",
Expand Down Expand Up @@ -186,8 +196,11 @@ runtime-benchmarks = [
"pallet-balances/runtime-benchmarks",
"pallet-collective/runtime-benchmarks",
"pallet-democracy/runtime-benchmarks",
"pallet-dispenser/runtime-benchmarks",
"pallet-elections-phragmen/runtime-benchmarks",
"pallet-funding/runtime-benchmarks",
"pallet-identity/runtime-benchmarks",
"pallet-linear-release/runtime-benchmarks",
"pallet-membership/runtime-benchmarks",
"pallet-message-queue/runtime-benchmarks",
"pallet-multisig/runtime-benchmarks",
Expand All @@ -202,6 +215,7 @@ runtime-benchmarks = [
"pallet-vesting/runtime-benchmarks",
"pallet-xcm/runtime-benchmarks",
"parachains-common/runtime-benchmarks",
"polimec-common/runtime-benchmarks",
"polimec-xcm-executor/runtime-benchmarks",
"polkadot-parachain-primitives/runtime-benchmarks",
"polkadot-runtime-common/runtime-benchmarks",
Expand All @@ -227,8 +241,12 @@ try-runtime = [
"pallet-balances/try-runtime",
"pallet-collective/try-runtime",
"pallet-democracy/try-runtime",
"pallet-dispenser/try-runtime",
"pallet-elections-phragmen/try-runtime",
"pallet-funding/try-runtime",
"pallet-identity/try-runtime",
"pallet-insecure-randomness-collective-flip/try-runtime",
"pallet-linear-release/try-runtime",
"pallet-membership/try-runtime",
"pallet-message-queue/try-runtime",
"pallet-multisig/try-runtime",
Expand All @@ -245,6 +263,7 @@ try-runtime = [
"pallet-vesting/try-runtime",
"pallet-xcm/try-runtime",
"parachain-info/try-runtime",
"polimec-common/try-runtime",
"polimec-xcm-executor/try-runtime",
"polkadot-runtime-common/try-runtime",
"shared-configuration/try-runtime",
Expand Down
35 changes: 35 additions & 0 deletions runtimes/polimec/src/benchmarks/helpers.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
use crate::{Oracle, Runtime, RuntimeOrigin};
pub use frame_support::BoundedVec;
pub use pallet_funding::{traits::SetPrices, AcceptedFundingAsset};
use scale_info::prelude::vec;
pub use sp_runtime::FixedU128;
pub struct SetOraclePrices;
impl SetPrices for SetOraclePrices {
fn set_prices() {
let dot = (AcceptedFundingAsset::DOT.to_assethub_id(), FixedU128::from_rational(69, 1));
let usdc = (AcceptedFundingAsset::USDT.to_assethub_id(), FixedU128::from_rational(1, 1));
let usdt = (AcceptedFundingAsset::USDT.to_assethub_id(), FixedU128::from_rational(1, 1));
let plmc = (pallet_funding::PLMC_FOREIGN_ID, FixedU128::from_rational(840, 100));

let values: BoundedVec<(u32, FixedU128), <Runtime as orml_oracle::Config>::MaxFeedValues> =
vec![dot, usdc, usdt, plmc].try_into().expect("benchmarks can panic");
let alice: [u8; 32] = [
212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, 76, 205,
227, 154, 86, 132, 231, 165, 109, 162, 125,
];
let bob: [u8; 32] = [
142, 175, 4, 21, 22, 135, 115, 99, 38, 201, 254, 161, 126, 37, 252, 82, 135, 97, 54, 147, 201, 18, 144,
156, 178, 38, 170, 71, 148, 242, 106, 72,
];
let charlie: [u8; 32] = [
144, 181, 171, 32, 92, 105, 116, 201, 234, 132, 27, 230, 136, 134, 70, 51, 220, 156, 168, 163, 87, 132, 62,
234, 207, 35, 20, 100, 153, 101, 254, 34,
];

frame_support::assert_ok!(Oracle::feed_values(RuntimeOrigin::signed(alice.clone().into()), values.clone()));

frame_support::assert_ok!(Oracle::feed_values(RuntimeOrigin::signed(bob.clone().into()), values.clone()));

frame_support::assert_ok!(Oracle::feed_values(RuntimeOrigin::signed(charlie.clone().into()), values.clone()));
}
}
2 changes: 2 additions & 0 deletions runtimes/polimec/src/benchmarks/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#[cfg(any(feature = "runtime-benchmarks", feature = "std"))]
pub mod helpers;
Loading