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

Develop to staging #309

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
59cc931
build(deps): bump clap from 4.4.15 to 4.4.17
dependabot[bot] Jan 15, 2024
f57fcd1
Merge pull request #267 from jurteam/dependabot/cargo/clap-4.4.17
Polkaverse Jan 16, 2024
763c3e9
build(deps): bump clap from 4.4.17 to 4.4.18
dependabot[bot] Jan 16, 2024
c45b563
Update origin-server.crt
mtmsuhail Jan 19, 2024
68c53fa
Merge pull request #270 from jurteam/mtmsuhail-patch-1
mtmsuhail Jan 19, 2024
f8216d8
Merge pull request #268 from jurteam/dependabot/cargo/clap-4.4.18
Polkaverse Jan 19, 2024
e31dde1
build(deps): bump shlex from 1.2.0 to 1.3.0 (#274)
dependabot[bot] Jan 24, 2024
21eb41a
Fix/readme (#269)
mtmsuhail Jan 24, 2024
d82b756
build(deps): bump h2 from 0.3.22 to 0.3.24 (#273)
dependabot[bot] Jan 24, 2024
45269f7
Merge branch 'staging' into develop
mtmsuhail Jan 25, 2024
90131a2
build(deps): bump snow from 0.9.4 to 0.9.5 (#275)
dependabot[bot] Jan 25, 2024
7b0e45d
fix(LICENSE): Licence updated to GPL
mtmsuhail Jan 26, 2024
ccaae78
fix(LICENSE): Licence updated to GPL (#278)
mtmsuhail Jan 26, 2024
0d11879
Merge branch 'staging' into develop
mtmsuhail Jan 26, 2024
4084c0b
Enabling the management of validators. (#288)
0xmenna Feb 22, 2024
61885df
Merge branch 'staging' into develop
mtmsuhail Feb 22, 2024
0f678f5
Introduce OpenGov to Jur (#287)
Polkaverse Feb 28, 2024
52a723a
fixed compilation issue (#297)
Polkaverse Mar 4, 2024
9636332
updated dependencies (#298)
Polkaverse Mar 4, 2024
c50c844
added vesting pallet
Polkaverse Mar 5, 2024
de08d68
fixed formatting
Polkaverse Mar 5, 2024
29e30aa
Refactored code
Polkaverse Mar 5, 2024
12f4abe
Rebase with develop
Polkaverse Mar 5, 2024
653521d
Resolving compilation errors for session pallet runtime integration (…
0xmenna Mar 10, 2024
1e79a12
Merge pull request #302 from jurteam/integrating-vesting-pallet
Polkaverse Apr 3, 2024
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
940 changes: 540 additions & 400 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ members = [
"pallets/passport",
"pallets/proposal",
"pallets/token-swap",
"pallets/safelist",
"runtime",
]
[profile.release]
Expand Down
5 changes: 3 additions & 2 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ targets = ["x86_64-unknown-linux-gnu"]
name = "jur-node"

[dependencies]
clap = { version = "4.4.18", features = ["derive"] }
clap = { version = "4.5.1", features = ["derive"] }
hex-literal = '0.4.1'
serde = { version = "1.0.195", features = ["derive"] }
serde = { version = "1.0.197", features = ["derive"] }
futures = { version = "0.3.30", features = ["thread-pool"]}
sc-cli = { version = "0.10.0-dev", git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0" }
sp-core = { version = "21.0.0", git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0" }
Expand All @@ -42,6 +42,7 @@ sp-keyring = { version = "24.0.0", git = "https://github.com/paritytech/polkadot
frame-system = { version = "4.0.0-dev", git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0" }
sp-io = { version = "23.0.0", git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0" }
pallet-transaction-payment = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0" }
pallet-session = { version = "4.0.0-dev", git = "https://github.com/paritytech/polkadot-sdk.git", default-features = false, branch = "release-polkadot-v1.2.0", features = ["historical"] }

# These dependencies are used for the node template's RPCs
jsonrpsee = { version = "0.16.2", features = ["server"] }
Expand Down
41 changes: 28 additions & 13 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
use hex_literal::hex;
use jur_node_runtime::opaque::SessionKeys;
use jur_node_runtime::{
AccountId, AuraConfig, BalancesConfig, Block, GrandpaConfig, RuntimeGenesisConfig, Signature,
SudoConfig, SystemConfig, WASM_BINARY,
AccountId, AuraConfig, BalancesConfig, Block, GrandpaConfig, RuntimeGenesisConfig,
SessionConfig, Signature, SudoConfig, SystemConfig, WASM_BINARY,
};
use sc_chain_spec::ChainSpecExtension;
use sc_service::ChainType;
use sc_service::Properties;
use serde::{Deserialize, Serialize};
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
use sp_consensus_grandpa::AuthorityId as GrandpaId;
use sp_core::crypto::UncheckedInto;
use sp_core::crypto::{Ss58Codec, UncheckedInto};
use sp_core::{sr25519, Pair, Public};
use sp_runtime::traits::{IdentifyAccount, Verify};
use sp_runtime::AccountId32;
Expand Down Expand Up @@ -320,6 +321,25 @@ pub fn jur_mainnet_config() -> Result<ChainSpec, String> {
))
}

// To get a validator AccountId the aura key is just converted to ss58 encoding for simplicity.
// Note that this is not the best solution, and you can input a different ss58 encoding key.
fn chain_spec_session_authorities(
initial_authorities: Vec<(AuraId, GrandpaId)>,
) -> Vec<(AccountId, AccountId, SessionKeys)> {
initial_authorities
.iter()
.map(|auth| {
let account_id = AccountId::from_ss58check(&auth.0.to_ss58check()).unwrap();
let key = (
account_id.clone(),
account_id,
SessionKeys { aura: auth.0.clone(), grandpa: auth.1.clone() },
);
key
})
.collect()
}

/// Configure initial storage state for FRAME modules.
fn testnet_genesis(
wasm_binary: &[u8],
Expand All @@ -328,6 +348,7 @@ fn testnet_genesis(
endowed_accounts: Vec<AccountId>,
_enable_println: bool,
) -> RuntimeGenesisConfig {
let session_authorities = chain_spec_session_authorities(initial_authorities);
RuntimeGenesisConfig {
system: SystemConfig {
// Add Wasm runtime to storage.
Expand All @@ -342,22 +363,16 @@ fn testnet_genesis(
.map(|k| (k, 1 << 60))
.collect(),
},
aura: AuraConfig {
authorities: initial_authorities.iter().map(|x| (x.0.clone())).collect(),
},
grandpa: GrandpaConfig {
authorities: initial_authorities
.iter()
.map(|x| (x.1.clone(), 1))
.collect(),
..Default::default()
},
aura: AuraConfig { authorities: Default::default() },
grandpa: GrandpaConfig { authorities: Default::default(), ..Default::default() },
sudo: SudoConfig {
// Assign network admin rights.
key: Some(root_key),
},
transaction_payment: Default::default(),
assets: Default::default(),
treasury: Default::default(),
session: SessionConfig { keys: session_authorities },
vesting: Default::default(),
}
}
2 changes: 1 addition & 1 deletion pallets/bounties/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pallet-passport = { package = 'pallet-passport', path = '../passport', default-f
pallet-whitelist = { package = 'pallet-whitelist', path = '../whitelist', default-features = false }

[dev-dependencies]
serde = { version = "1.0.195" }
serde = { version = "1.0.196" }

# Substrate
sp-core = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.2.0" }
Expand Down
2 changes: 1 addition & 1 deletion pallets/community/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ sp-std = { git = "https://github.com/paritytech/polkadot-sdk", default-features
pallet-whitelist = { package = 'pallet-whitelist', path = '../whitelist', default-features = false }

[dev-dependencies]
serde = { version = "1.0.195" }
serde = { version = "1.0.196" }

# Substrate
sp-core = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.2.0" }
Expand Down
2 changes: 1 addition & 1 deletion pallets/event/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pallet-passport = { package = 'pallet-passport', path = '../passport', default-f
pallet-whitelist = { package = 'pallet-whitelist', path = '../whitelist', default-features = false }

[dev-dependencies]
serde = { version = "1.0.195" }
serde = { version = "1.0.196" }

# Substrate
sp-core = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.2.0" }
Expand Down
2 changes: 1 addition & 1 deletion pallets/passport/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pallet-community = { package = 'pallet-community', path = '../community', defaul
pallet-whitelist = { package = 'pallet-whitelist', path = '../whitelist', default-features = false }

[dev-dependencies]
serde = { version = "1.0.195" }
serde = { version = "1.0.196" }

# Substrate
sp-core = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.2.0" }
Expand Down
2 changes: 1 addition & 1 deletion pallets/proposal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pallet-community = { package = 'pallet-community', path = '../community', defaul
pallet-whitelist = { package = 'pallet-whitelist', path = '../whitelist', default-features = false }

[dev-dependencies]
serde = { version = "1.0.195" }
serde = { version = "1.0.196" }

# Substrate
sp-core = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.2.0" }
Expand Down
63 changes: 63 additions & 0 deletions pallets/safelist/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
[package]
name = "pallet-safelist"
version = "1.0.0"
description = "Jur safelist Pallet"
authors = ["Jur Team <https://github.com/jurteam>"]
homepage = "https://jur.io/"
edition = "2021"
license = "Apache-2.0"
publish = false
repository = "https://github.com/jurteam/jur-node/"


[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = ["derive", "max-encoded-len"] }
scale-info = { version = "2.9.0", default-features = false, features = ["derive"] }
frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, optional = true, branch = "release-polkadot-v1.2.0" }
frame-support = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.2.0" }
frame-system = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.2.0" }
sp-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0" }
sp-runtime = {git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.2.0" }
sp-std = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.2.0" }

[dev-dependencies]
pallet-balances = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0" }
pallet-preimage = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0" }
sp-core = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.2.0" }
sp-io = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.2.0" }

[features]
default = [ "std" ]
std = [
"codec/std",
"frame-benchmarking/std",
"frame-support/std",
"frame-system/std",
"pallet-balances/std",
"pallet-preimage/std",
"scale-info/std",
"sp-api/std",
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
"sp-std/std",
]
runtime-benchmarks = [
"frame-benchmarking",
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-preimage/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
]
try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"pallet-balances/try-runtime",
"pallet-preimage/try-runtime",
"sp-runtime/try-runtime",
]
126 changes: 126 additions & 0 deletions pallets/safelist/src/benchmarking.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
// This file is part of Substrate.

// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//! Whitelist pallet benchmarking.

#![cfg(feature = "runtime-benchmarks")]

use super::*;
use frame_benchmarking::v1::{benchmarks, BenchmarkError};
use frame_support::{ensure, traits::EnsureOrigin};

#[cfg(test)]
use crate::Pallet as Whitelist;

benchmarks! {
whitelist_call {
let origin =
T::WhitelistOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?;
let call_hash = Default::default();
}: _<T::RuntimeOrigin>(origin, call_hash)
verify {
ensure!(
WhitelistedCall::<T>::contains_key(call_hash),
"call not whitelisted"
);
ensure!(
T::Preimages::is_requested(&call_hash),
"preimage not requested"
);
}

remove_whitelisted_call {
let origin =
T::WhitelistOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?;
let call_hash = Default::default();
Pallet::<T>::whitelist_call(origin.clone(), call_hash)
.expect("whitelisting call must be successful");
}: _<T::RuntimeOrigin>(origin, call_hash)
verify {
ensure!(
!WhitelistedCall::<T>::contains_key(call_hash),
"whitelist not removed"
);
ensure!(
!T::Preimages::is_requested(&call_hash),
"preimage still requested"
);
}

// We benchmark with the maximum possible size for a call.
// If the resulting weight is too big, maybe it worth having a weight which depends
// on the size of the call, with a new witness in parameter.
#[pov_mode = MaxEncodedLen {
// Use measured PoV size for the Preimages since we pass in a length witness.
Preimage::PreimageFor: Measured
}]
dispatch_whitelisted_call {
// NOTE: we remove `10` because we need some bytes to encode the variants and vec length
let n in 1 .. T::Preimages::MAX_LENGTH as u32 - 10;

let origin = T::DispatchWhitelistedOrigin::try_successful_origin()
.map_err(|_| BenchmarkError::Weightless)?;
let remark = sp_std::vec![1u8; n as usize];
let call: <T as Config>::RuntimeCall = frame_system::Call::remark { remark }.into();
let call_weight = call.get_dispatch_info().weight;
let encoded_call = call.encode();
let call_encoded_len = encoded_call.len() as u32;
let call_hash = T::Hashing::hash_of(&call);

Pallet::<T>::whitelist_call(origin.clone(), call_hash)
.expect("whitelisting call must be successful");

T::Preimages::note(encoded_call.into()).unwrap();

}: _<T::RuntimeOrigin>(origin, call_hash, call_encoded_len, call_weight)
verify {
ensure!(
!WhitelistedCall::<T>::contains_key(call_hash),
"whitelist not removed"
);
ensure!(
!T::Preimages::is_requested(&call_hash),
"preimage still requested"
);
}

dispatch_whitelisted_call_with_preimage {
let n in 1 .. 10_000;

let origin = T::DispatchWhitelistedOrigin::try_successful_origin()
.map_err(|_| BenchmarkError::Weightless)?;
let remark = sp_std::vec![1u8; n as usize];

let call: <T as Config>::RuntimeCall = frame_system::Call::remark { remark }.into();
let call_hash = T::Hashing::hash_of(&call);

Pallet::<T>::whitelist_call(origin.clone(), call_hash)
.expect("whitelisting call must be successful");
}: _<T::RuntimeOrigin>(origin, Box::new(call))
verify {
ensure!(
!WhitelistedCall::<T>::contains_key(call_hash),
"whitelist not removed"
);
ensure!(
!T::Preimages::is_requested(&call_hash),
"preimage still requested"
);
}

impl_benchmark_test_suite!(Whitelist, crate::mock::new_test_ext(), crate::mock::Test);
}
Loading
Loading