Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/master' into shawntabrizi-mel-1
Browse files Browse the repository at this point in the history
  • Loading branch information
KiChjang committed Jun 20, 2022
2 parents 91c5add + b66c051 commit e57c795
Show file tree
Hide file tree
Showing 201 changed files with 9,534 additions and 4,028 deletions.
483 changes: 324 additions & 159 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ members = [
"client/transaction-pool",
"client/transaction-pool/api",
"client/utils",
"frame/alliance",
"frame/assets",
"frame/atomic-swap",
"frame/aura",
Expand Down Expand Up @@ -114,6 +115,7 @@ members = [
"frame/proxy",
"frame/nomination-pools",
"frame/nomination-pools/benchmarking",
"frame/nomination-pools/test-staking",
"frame/randomness-collective-flip",
"frame/ranked-collective",
"frame/recovery",
Expand Down
2 changes: 1 addition & 1 deletion bin/node-template/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ frame-system = { version = "4.0.0-dev", path = "../../../frame/system" }
pallet-transaction-payment = { version = "4.0.0-dev", default-features = false, path = "../../../frame/transaction-payment" }

# These dependencies are used for the node template's RPCs
jsonrpsee = { version = "0.13.0", features = ["server"] }
jsonrpsee = { version = "0.14.0", features = ["server"] }
sc-rpc = { version = "4.0.0-dev", path = "../../../client/rpc" }
sp-api = { version = "4.0.0-dev", path = "../../../primitives/api" }
sc-rpc-api = { version = "0.10.0-dev", path = "../../../client/rpc-api" }
Expand Down
1 change: 1 addition & 0 deletions bin/node-template/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ impl pallet_balances::Config for Runtime {
}

impl pallet_transaction_payment::Config for Runtime {
type Event = Event;
type OnChargeTransaction = CurrencyAdapter<Balances, ()>;
type OperationalFeeMultiplier = ConstU8<5>;
type WeightToFee = IdentityFee<Balance>;
Expand Down
7 changes: 4 additions & 3 deletions bin/node/bench/src/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,10 @@ impl core::Benchmark for ImportBenchmark {
.inspect_state(|| {
match self.block_type {
BlockType::RandomTransfersKeepAlive => {
// should be 7 per signed extrinsic + 1 per unsigned
// should be 8 per signed extrinsic + 1 per unsigned
// we have 1 unsigned and the rest are signed in the block
// those 7 events per signed are:
// those 8 events per signed are:
// - transaction paid for the transaction payment
// - withdraw (Balances::Withdraw) for charging the transaction fee
// - new account (System::NewAccount) as we always transfer fund to
// non-existent account
Expand All @@ -148,7 +149,7 @@ impl core::Benchmark for ImportBenchmark {
// - extrinsic success
assert_eq!(
node_runtime::System::events().len(),
(self.block.extrinsics.len() - 1) * 7 + 1,
(self.block.extrinsics.len() - 1) * 8 + 1,
);
},
BlockType::Noop => {
Expand Down
4 changes: 2 additions & 2 deletions bin/node/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ crate-type = ["cdylib", "rlib"]
clap = { version = "3.1.18", features = ["derive"], optional = true }
codec = { package = "parity-scale-codec", version = "3.0.0" }
serde = { version = "1.0.136", features = ["derive"] }
jsonrpsee = { version = "0.13.0", features = ["server"] }
jsonrpsee = { version = "0.14.0", features = ["server"] }
futures = "0.3.21"
hex-literal = "0.3.4"
log = "0.4.17"
Expand Down Expand Up @@ -153,7 +153,7 @@ cli = [
"sc-cli",
"frame-benchmarking-cli",
"substrate-frame-cli",
"sc-service/db",
"sc-service/rocksdb",
"clap",
"clap_complete",
"substrate-build-script-utils",
Expand Down
13 changes: 10 additions & 3 deletions bin/node/cli/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ use hex_literal::hex;
use node_runtime::{
constants::currency::*, wasm_binary_unwrap, AuthorityDiscoveryConfig, BabeConfig,
BalancesConfig, Block, CouncilConfig, DemocracyConfig, ElectionsConfig, GrandpaConfig,
ImOnlineConfig, IndicesConfig, MaxNominations, SessionConfig, SessionKeys, SocietyConfig,
StakerStatus, StakingConfig, SudoConfig, SystemConfig, TechnicalCommitteeConfig,
ImOnlineConfig, IndicesConfig, MaxNominations, NominationPoolsConfig, SessionConfig,
SessionKeys, SocietyConfig, StakerStatus, StakingConfig, SudoConfig, SystemConfig,
TechnicalCommitteeConfig,
};
use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
use sc_chain_spec::ChainSpecExtension;
Expand Down Expand Up @@ -363,7 +364,13 @@ pub fn testnet_genesis(
gilt: Default::default(),
transaction_storage: Default::default(),
transaction_payment: Default::default(),
nomination_pools: Default::default(),
alliance: Default::default(),
alliance_motion: Default::default(),
nomination_pools: NominationPoolsConfig {
min_create_bond: 10 * DOLLARS,
min_join_bond: 1 * DOLLARS,
..Default::default()
},
}
}

Expand Down
1 change: 1 addition & 0 deletions bin/node/executor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pallet-contracts = { version = "4.0.0-dev", path = "../../../frame/contracts" }
pallet-im-online = { version = "4.0.0-dev", path = "../../../frame/im-online" }
pallet-timestamp = { version = "4.0.0-dev", path = "../../../frame/timestamp" }
pallet-treasury = { version = "4.0.0-dev", path = "../../../frame/treasury" }
pallet-transaction-payment = { version = "4.0.0-dev", path = "../../../frame/transaction-payment" }
sp-application-crypto = { version = "6.0.0", path = "../../../primitives/application-crypto" }
sp-consensus-babe = { version = "0.10.0-dev", path = "../../../primitives/consensus/babe" }
sp-externalities = { version = "0.12.0", path = "../../../primitives/externalities" }
Expand Down
33 changes: 33 additions & 0 deletions bin/node/executor/tests/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,17 @@ fn full_native_block_import_works() {
event: Event::Treasury(pallet_treasury::Event::Deposit { value: fees * 8 / 10 }),
topics: vec![],
},
EventRecord {
phase: Phase::ApplyExtrinsic(1),
event: Event::TransactionPayment(
pallet_transaction_payment::Event::TransactionFeePaid {
who: alice().into(),
actual_fee: fees,
tip: 0,
},
),
topics: vec![],
},
EventRecord {
phase: Phase::ApplyExtrinsic(1),
event: Event::System(frame_system::Event::ExtrinsicSuccess {
Expand Down Expand Up @@ -488,6 +499,17 @@ fn full_native_block_import_works() {
event: Event::Treasury(pallet_treasury::Event::Deposit { value: fees * 8 / 10 }),
topics: vec![],
},
EventRecord {
phase: Phase::ApplyExtrinsic(1),
event: Event::TransactionPayment(
pallet_transaction_payment::Event::TransactionFeePaid {
who: bob().into(),
actual_fee: fees,
tip: 0,
},
),
topics: vec![],
},
EventRecord {
phase: Phase::ApplyExtrinsic(1),
event: Event::System(frame_system::Event::ExtrinsicSuccess {
Expand Down Expand Up @@ -525,6 +547,17 @@ fn full_native_block_import_works() {
event: Event::Treasury(pallet_treasury::Event::Deposit { value: fees * 8 / 10 }),
topics: vec![],
},
EventRecord {
phase: Phase::ApplyExtrinsic(2),
event: Event::TransactionPayment(
pallet_transaction_payment::Event::TransactionFeePaid {
who: alice().into(),
actual_fee: fees,
tip: 0,
},
),
topics: vec![],
},
EventRecord {
phase: Phase::ApplyExtrinsic(2),
event: Event::System(frame_system::Event::ExtrinsicSuccess {
Expand Down
2 changes: 1 addition & 1 deletion bin/node/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repository = "https://github.com/paritytech/substrate/"
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
jsonrpsee = { version = "0.13.0", features = ["server"] }
jsonrpsee = { version = "0.14.0", features = ["server"] }
node-primitives = { version = "2.0.0", path = "../primitives" }
pallet-contracts-rpc = { version = "4.0.0-dev", path = "../../../frame/contracts/rpc/" }
pallet-mmr-rpc = { version = "3.0.0", path = "../../../frame/merkle-mountain-range/rpc/" }
Expand Down
4 changes: 4 additions & 0 deletions bin/node/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ frame-system-benchmarking = { version = "4.0.0-dev", default-features = false, p
frame-election-provider-support = { version = "4.0.0-dev", default-features = false, path = "../../../frame/election-provider-support" }
frame-system-rpc-runtime-api = { version = "4.0.0-dev", default-features = false, path = "../../../frame/system/rpc/runtime-api/" }
frame-try-runtime = { version = "0.10.0-dev", default-features = false, path = "../../../frame/try-runtime", optional = true }
pallet-alliance = { version = "4.0.0-dev", default-features = false, path = "../../../frame/alliance" }
pallet-assets = { version = "4.0.0-dev", default-features = false, path = "../../../frame/assets" }
pallet-authority-discovery = { version = "4.0.0-dev", default-features = false, path = "../../../frame/authority-discovery" }
pallet-authorship = { version = "4.0.0-dev", default-features = false, path = "../../../frame/authorship" }
Expand Down Expand Up @@ -187,12 +188,14 @@ std = [
"frame-try-runtime/std",
"sp-io/std",
"pallet-child-bounties/std",
"pallet-alliance/std",
]
runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"pallet-alliance/runtime-benchmarks",
"pallet-assets/runtime-benchmarks",
"pallet-babe/runtime-benchmarks",
"pallet-bags-list/runtime-benchmarks",
Expand Down Expand Up @@ -243,6 +246,7 @@ try-runtime = [
"frame-executive/try-runtime",
"frame-try-runtime",
"frame-system/try-runtime",
"pallet-alliance/try-runtime",
"pallet-assets/try-runtime",
"pallet-authority-discovery/try-runtime",
"pallet-authorship/try-runtime",
Expand Down
77 changes: 73 additions & 4 deletions bin/node/runtime/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,19 @@

//! Some configurable implementations as associated type for the substrate runtime.
use crate::{AccountId, Assets, Authorship, Balances, NegativeImbalance, Runtime};
use frame_support::traits::{
fungibles::{Balanced, CreditOf},
Currency, OnUnbalanced,
use crate::{
AccountId, AllianceMotion, Assets, Authorship, Balances, Call, Hash, NegativeImbalance, Runtime,
};
use frame_support::{
pallet_prelude::*,
traits::{
fungibles::{Balanced, CreditOf},
Currency, OnUnbalanced,
},
};
use pallet_alliance::{IdentityVerifier, ProposalIndex, ProposalProvider};
use pallet_asset_tx_payment::HandleCredit;
use sp_std::prelude::*;

pub struct Author;
impl OnUnbalanced<NegativeImbalance> for Author {
Expand All @@ -45,6 +52,68 @@ impl HandleCredit<AccountId, Assets> for CreditToBlockAuthor {
}
}

pub struct AllianceIdentityVerifier;
impl IdentityVerifier<AccountId> for AllianceIdentityVerifier {
fn has_identity(who: &AccountId, fields: u64) -> bool {
crate::Identity::has_identity(who, fields)
}

fn has_good_judgement(who: &AccountId) -> bool {
use pallet_identity::Judgement;
if let Some(judgements) =
crate::Identity::identity(who).map(|registration| registration.judgements)
{
judgements
.iter()
.any(|(_, j)| matches!(j, Judgement::KnownGood | Judgement::Reasonable))
} else {
false
}
}

fn super_account_id(who: &AccountId) -> Option<AccountId> {
crate::Identity::super_of(who).map(|parent| parent.0)
}
}

pub struct AllianceProposalProvider;
impl ProposalProvider<AccountId, Hash, Call> for AllianceProposalProvider {
fn propose_proposal(
who: AccountId,
threshold: u32,
proposal: Box<Call>,
length_bound: u32,
) -> Result<(u32, u32), DispatchError> {
AllianceMotion::do_propose_proposed(who, threshold, proposal, length_bound)
}

fn vote_proposal(
who: AccountId,
proposal: Hash,
index: ProposalIndex,
approve: bool,
) -> Result<bool, DispatchError> {
AllianceMotion::do_vote(who, proposal, index, approve)
}

fn veto_proposal(proposal_hash: Hash) -> u32 {
AllianceMotion::do_disapprove_proposal(proposal_hash)
}

fn close_proposal(
proposal_hash: Hash,
proposal_index: ProposalIndex,
proposal_weight_bound: Weight,
length_bound: u32,
) -> DispatchResultWithPostInfo {
AllianceMotion::do_close(proposal_hash, proposal_index, proposal_weight_bound, length_bound)
}

fn proposal_of(proposal_hash: Hash) -> Option<Call> {
AllianceMotion::proposal_of(proposal_hash)
}
}

#[cfg(test)]
mod multiplier_tests {
use pallet_transaction_payment::{Multiplier, TargetedFeeAdjustment};
Expand Down
Loading

0 comments on commit e57c795

Please sign in to comment.