From 6bfaf9e635842e88294206f3a7927f81ead61c8c Mon Sep 17 00:00:00 2001 From: "Alisher A. Khassanov" Date: Tue, 19 Dec 2023 17:37:03 +0600 Subject: [PATCH 1/3] chore: PR #204 is backported Related to https://github.com/Cerebellum-Network/blockchain-node/pull/200. Tested manually with a local node. --- node/service/chain-specs/example.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/node/service/chain-specs/example.json b/node/service/chain-specs/example.json index e61b43fbc..6014d0a00 100644 --- a/node/service/chain-specs/example.json +++ b/node/service/chain-specs/example.json @@ -189,7 +189,8 @@ ], "http_port": 8080, "grpc_port": 8081, - "p2p_port": 8082 + "p2p_port": 8082, + "mode": "Storage" } } ], From f8594748cb9f6327171c01c28e37646507a8d919 Mon Sep 17 00:00:00 2001 From: Raid5594 <52794079+Raid5594@users.noreply.github.com> Date: Tue, 19 Dec 2023 14:36:11 +0100 Subject: [PATCH 2/3] chore: PR #189 is backported --- Cargo.lock | 6 +++ runtime/cere-dev/Cargo.toml | 27 +++++++------ runtime/cere-dev/src/lib.rs | 8 ++-- runtime/cere/Cargo.toml | 30 +++++++++++--- runtime/cere/src/lib.rs | 80 ++++++++++++++++++++++++++++++++++++- 5 files changed, 126 insertions(+), 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e6b76c111..34672105c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -976,6 +976,7 @@ version = "4.8.1" dependencies = [ "cere-runtime-common", "cere-runtime-constants", + "ddc-traits", "frame-benchmarking", "frame-election-provider-support", "frame-executive", @@ -1000,7 +1001,12 @@ dependencies = [ "pallet-contracts", "pallet-contracts-primitives", "pallet-contracts-rpc-runtime-api", + "pallet-ddc-clusters", + "pallet-ddc-customers", "pallet-ddc-metrics-offchain-worker", + "pallet-ddc-nodes", + "pallet-ddc-payouts", + "pallet-ddc-staking", "pallet-democracy", "pallet-election-provider-multi-phase", "pallet-election-provider-support-benchmarking", diff --git a/runtime/cere-dev/Cargo.toml b/runtime/cere-dev/Cargo.toml index 87821e239..cc8fce2c6 100644 --- a/runtime/cere-dev/Cargo.toml +++ b/runtime/cere-dev/Cargo.toml @@ -37,9 +37,6 @@ sp-transaction-pool = { default-features = false, git = "https://github.com/pari sp-version = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" } # frame dependencies -cere-dev-runtime-constants = { path = "./constants", default-features = false } -cere-runtime-common = { path = "../common", default-features = false } -ddc-traits = { version = "0.1.0", default-features = false, path = "../../traits" } frame-benchmarking = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30", optional = true } frame-election-provider-support = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" } frame-executive = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" } @@ -54,25 +51,16 @@ pallet-babe = { default-features = false, git = "https://github.com/paritytech/s pallet-bags-list = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" } pallet-balances = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" } pallet-bounties = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" } -pallet-cere-ddc = { version = "4.8.1", default-features = false, path = "../../pallets/ddc" } pallet-chainbridge = { version = "4.8.1", default-features = false, path = "../../pallets/chainbridge" } pallet-child-bounties = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" } pallet-collective = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" } pallet-contracts = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" } pallet-contracts-primitives = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" } pallet-contracts-rpc-runtime-api = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" } -pallet-ddc-clusters = { version = "4.8.1", default-features = false, path = "../../pallets/ddc-clusters" } -pallet-ddc-customers = { version = "0.1.0", default-features = false, path = "../../pallets/ddc-customers" } -pallet-ddc-metrics-offchain-worker = { version = "4.8.1", default-features = false, path = "../../pallets/ddc-metrics-offchain-worker" } -pallet-ddc-nodes = { version = "4.8.1", default-features = false, path = "../../pallets/ddc-nodes" } -pallet-ddc-payouts = { version = "4.8.1", default-features = false, path = "../../pallets/ddc-payouts" } -pallet-ddc-staking = { version = "4.8.1", default-features = false, path = "../../pallets/ddc-staking" } pallet-democracy = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" } pallet-election-provider-multi-phase = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" } pallet-election-provider-support-benchmarking = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30", optional = true } pallet-elections-phragmen = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" } -pallet-erc20 = { version = "4.8.1", default-features = false, path = "../../pallets/erc20" } -pallet-erc721 = { version = "4.8.1", default-features = false, path = "../../pallets/erc721" } pallet-fast-unstake = { git = "https://github.com/paritytech/substrate.git", default-features = false, branch = "polkadot-v0.9.30" } pallet-grandpa = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" } pallet-identity = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" } @@ -103,6 +91,20 @@ pallet-treasury = { default-features = false, git = "https://github.com/parityte pallet-utility = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" } pallet-vesting = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" } +# cere dependencies +cere-dev-runtime-constants = { path = "./constants", default-features = false } +cere-runtime-common = { path = "../common", default-features = false } +ddc-traits = { version = "0.1.0", default-features = false, path = "../../traits" } +pallet-cere-ddc = { version = "4.8.1", default-features = false, path = "../../pallets/ddc" } +pallet-ddc-clusters = { version = "4.8.1", default-features = false, path = "../../pallets/ddc-clusters" } +pallet-ddc-customers = { version = "0.1.0", default-features = false, path = "../../pallets/ddc-customers" } +pallet-ddc-metrics-offchain-worker = { version = "4.8.1", default-features = false, path = "../../pallets/ddc-metrics-offchain-worker" } +pallet-ddc-nodes = { version = "4.8.1", default-features = false, path = "../../pallets/ddc-nodes" } +pallet-ddc-payouts = { version = "4.8.1", default-features = false, path = "../../pallets/ddc-payouts" } +pallet-ddc-staking = { version = "4.8.1", default-features = false, path = "../../pallets/ddc-staking" } +pallet-erc20 = { version = "4.8.1", default-features = false, path = "../../pallets/erc20" } +pallet-erc721 = { version = "4.8.1", default-features = false, path = "../../pallets/erc721" } + [build-dependencies] substrate-wasm-builder = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" } @@ -182,7 +184,6 @@ std = [ "cere-runtime-common/std", "cere-dev-runtime-constants/std", "pallet-ddc-customers/std", - "pallet-ddc-nodes/std", "pallet-ddc-clusters/std", "pallet-ddc-payouts/std", ] diff --git a/runtime/cere-dev/src/lib.rs b/runtime/cere-dev/src/lib.rs index 9b70d24a7..b9266c403 100644 --- a/runtime/cere-dev/src/lib.rs +++ b/runtime/cere-dev/src/lib.rs @@ -1330,7 +1330,7 @@ impl pallet_ddc_staking::Config for Runtime { parameter_types! { pub const DdcCustomersPalletId: PalletId = PalletId(*b"accounts"); // DDC maintainer's stake - pub const UnlockingDelay: BlockNumber = 5256000u32; // 1 hour * 24 * 365 = 1 day; (1 hour is 600 blocks) + pub const UnlockingDelay: BlockNumber = 100800_u32; // 1 hour * 24 * 7 = 7 days; (1 hour is 600 blocks) } impl pallet_ddc_customers::Config for Runtime { @@ -1362,8 +1362,8 @@ parameter_types! { pub const PayoutsPalletId: PalletId = PalletId(*b"payouts_"); } -pub struct TreasureWrapper; -impl PalletVisitor for TreasureWrapper { +pub struct TreasuryWrapper; +impl PalletVisitor for TreasuryWrapper { fn get_account_id() -> T::AccountId { TreasuryPalletId::get().into_account_truncating() } @@ -1376,7 +1376,7 @@ impl pallet_ddc_payouts::Config for Runtime { type CustomerCharger = DdcCustomers; type CustomerDepositor = DdcCustomers; type ClusterVisitor = DdcClusters; - type TreasuryVisitor = TreasureWrapper; + type TreasuryVisitor = TreasuryWrapper; type ValidatorList = pallet_staking::UseValidatorsMap; type ClusterCreator = DdcClusters; type WeightInfo = pallet_ddc_payouts::weights::SubstrateWeight; diff --git a/runtime/cere/Cargo.toml b/runtime/cere/Cargo.toml index 2ce9a430f..9984b8d7e 100644 --- a/runtime/cere/Cargo.toml +++ b/runtime/cere/Cargo.toml @@ -37,8 +37,6 @@ sp-transaction-pool = { default-features = false, git = "https://github.com/pari sp-version = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" } # frame dependencies -cere-runtime-common = { path = "../common", default-features = false } -cere-runtime-constants = { path = "./constants", default-features = false } frame-benchmarking = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30", optional = true } frame-election-provider-support = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" } frame-executive = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" } @@ -53,20 +51,16 @@ pallet-babe = { default-features = false, git = "https://github.com/paritytech/s pallet-bags-list = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" } pallet-balances = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" } pallet-bounties = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" } -pallet-cere-ddc = { version = "4.8.1", default-features = false, path = "../../pallets/ddc" } pallet-chainbridge = { version = "4.8.1", default-features = false, path = "../../pallets/chainbridge" } pallet-child-bounties = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" } pallet-collective = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" } pallet-contracts = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" } pallet-contracts-primitives = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" } pallet-contracts-rpc-runtime-api = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" } -pallet-ddc-metrics-offchain-worker = { version = "4.8.1", default-features = false, path = "../../pallets/ddc-metrics-offchain-worker" } pallet-democracy = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" } pallet-election-provider-multi-phase = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" } pallet-election-provider-support-benchmarking = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30", optional = true } pallet-elections-phragmen = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" } -pallet-erc20 = { version = "4.8.1", default-features = false, path = "../../pallets/erc20" } -pallet-erc721 = { version = "4.8.1", default-features = false, path = "../../pallets/erc721" } pallet-fast-unstake = { git = "https://github.com/paritytech/substrate.git", default-features = false, branch = "polkadot-v0.9.30" } pallet-grandpa = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" } pallet-identity = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" } @@ -97,6 +91,20 @@ pallet-treasury = { default-features = false, git = "https://github.com/parityte pallet-utility = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" } pallet-vesting = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" } +# cere dependencies +cere-runtime-common = { path = "../common", default-features = false } +cere-runtime-constants = { path = "./constants", default-features = false } +ddc-traits = { version = "0.1.0", default-features = false, path = "../../traits" } +pallet-cere-ddc = { version = "4.8.1", default-features = false, path = "../../pallets/ddc" } +pallet-ddc-clusters = { version = "4.8.1", default-features = false, path = "../../pallets/ddc-clusters" } +pallet-ddc-customers = { version = "0.1.0", default-features = false, path = "../../pallets/ddc-customers" } +pallet-ddc-metrics-offchain-worker = { version = "4.8.1", default-features = false, path = "../../pallets/ddc-metrics-offchain-worker" } +pallet-ddc-nodes = { version = "4.8.1", default-features = false, path = "../../pallets/ddc-nodes" } +pallet-ddc-payouts = { version = "4.8.1", default-features = false, path = "../../pallets/ddc-payouts" } +pallet-ddc-staking = { version = "4.8.1", default-features = false, path = "../../pallets/ddc-staking" } +pallet-erc20 = { version = "4.8.1", default-features = false, path = "../../pallets/erc20" } +pallet-erc721 = { version = "4.8.1", default-features = false, path = "../../pallets/erc721" } + [build-dependencies] substrate-wasm-builder = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" } @@ -172,6 +180,11 @@ std = [ "sp-io/std", "pallet-child-bounties/std", "pallet-ddc-metrics-offchain-worker/std", + "pallet-ddc-clusters/std", + "pallet-ddc-customers/std", + "pallet-ddc-nodes/std", + "pallet-ddc-payouts/std", + "pallet-ddc-staking/std", "cere-runtime-common/std", "cere-runtime-constants/std", ] @@ -187,6 +200,11 @@ runtime-benchmarks = [ "pallet-child-bounties/runtime-benchmarks", "pallet-collective/runtime-benchmarks", "pallet-contracts/runtime-benchmarks", + "pallet-ddc-customers/runtime-benchmarks", + "pallet-ddc-clusters/runtime-benchmarks", + "pallet-ddc-nodes/runtime-benchmarks", + "pallet-ddc-staking/runtime-benchmarks", + "pallet-ddc-payouts/runtime-benchmarks", "pallet-democracy/runtime-benchmarks", "pallet-election-provider-multi-phase/runtime-benchmarks", "pallet-election-provider-support-benchmarking/runtime-benchmarks", diff --git a/runtime/cere/src/lib.rs b/runtime/cere/src/lib.rs index f7eef4df6..eb818d333 100644 --- a/runtime/cere/src/lib.rs +++ b/runtime/cere/src/lib.rs @@ -23,6 +23,7 @@ #![recursion_limit = "256"] use codec::{Decode, Encode, MaxEncodedLen}; +use ddc_traits::pallet::PalletVisitor; use frame_election_provider_support::{onchain, BalancingConfig, SequentialPhragmen, VoteWeight}; use frame_support::{ construct_runtime, @@ -67,8 +68,8 @@ use sp_runtime::{ curve::PiecewiseLinear, generic, impl_opaque_keys, traits::{ - self, BlakeTwo256, Block as BlockT, ConvertInto, NumberFor, OpaqueKeys, - SaturatedConversion, StaticLookup, + self, AccountIdConversion, BlakeTwo256, Block as BlockT, ConvertInto, NumberFor, + OpaqueKeys, SaturatedConversion, StaticLookup, }, transaction_validity::{TransactionPriority, TransactionSource, TransactionValidity}, ApplyExtrinsicResult, FixedPointNumber, FixedU128, Perbill, Percent, Permill, Perquintill, @@ -1312,6 +1313,71 @@ impl pallet_ddc_metrics_offchain_worker::Config for Runtime { type RuntimeCall = RuntimeCall; } +parameter_types! { + pub const DdcCustomersPalletId: PalletId = PalletId(*b"accounts"); // DDC maintainer's stake + pub const UnlockingDelay: BlockNumber = 100800_u32; // 1 hour * 24 * 7 = 7 days; (1 hour is 600 blocks) +} + +impl pallet_ddc_customers::Config for Runtime { + type UnlockingDelay = UnlockingDelay; + type Currency = Balances; + type PalletId = DdcCustomersPalletId; + type RuntimeEvent = RuntimeEvent; + type ClusterVisitor = pallet_ddc_clusters::Pallet; + type ClusterCreator = pallet_ddc_clusters::Pallet; + type WeightInfo = pallet_ddc_customers::weights::SubstrateWeight; +} + +impl pallet_ddc_clusters::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type NodeRepository = pallet_ddc_nodes::Pallet; + type StakingVisitor = pallet_ddc_staking::Pallet; + type StakerCreator = pallet_ddc_staking::Pallet; + type Currency = Balances; + type WeightInfo = pallet_ddc_clusters::weights::SubstrateWeight; +} + +impl pallet_ddc_nodes::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type StakingVisitor = pallet_ddc_staking::Pallet; + type WeightInfo = pallet_ddc_nodes::weights::SubstrateWeight; +} + +parameter_types! { + pub const PayoutsPalletId: PalletId = PalletId(*b"payouts_"); +} + +pub struct TreasuryWrapper; +impl PalletVisitor for TreasuryWrapper { + fn get_account_id() -> T::AccountId { + TreasuryPalletId::get().into_account_truncating() + } +} + +impl pallet_ddc_payouts::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type PalletId = PayoutsPalletId; + type Currency = Balances; + type CustomerCharger = DdcCustomers; + type CustomerDepositor = DdcCustomers; + type ClusterVisitor = DdcClusters; + type TreasuryVisitor = TreasuryWrapper; + type ValidatorList = pallet_staking::UseValidatorsMap; + type ClusterCreator = DdcClusters; + type WeightInfo = pallet_ddc_payouts::weights::SubstrateWeight; +} + +impl pallet_ddc_staking::Config for Runtime { + type Currency = Balances; + type RuntimeEvent = RuntimeEvent; + type WeightInfo = pallet_ddc_staking::weights::SubstrateWeight; + type ClusterVisitor = pallet_ddc_clusters::Pallet; + type ClusterCreator = pallet_ddc_clusters::Pallet; + type ClusterManager = pallet_ddc_clusters::Pallet; + type NodeVisitor = pallet_ddc_nodes::Pallet; + type NodeCreator = pallet_ddc_nodes::Pallet; +} + construct_runtime!( pub enum Runtime where Block = Block, @@ -1363,6 +1429,11 @@ construct_runtime!( Erc721: pallet_erc721::{Pallet, Call, Storage, Event}, Erc20: pallet_erc20::{Pallet, Call, Storage, Event}, DdcMetricsOffchainWorker: pallet_ddc_metrics_offchain_worker::{Pallet, Call, Storage, Event}, + DdcStaking: pallet_ddc_staking, + DdcCustomers: pallet_ddc_customers, + DdcNodes: pallet_ddc_nodes, + DdcClusters: pallet_ddc_clusters, + DdcPayouts: pallet_ddc_payouts } ); @@ -1439,6 +1510,11 @@ mod benches { [pallet_child_bounties, ChildBounties] [pallet_collective, Council] [pallet_contracts, Contracts] + [pallet_ddc_customers, DdcCustomers] + [pallet_ddc_clusters, DdcClusters] + [pallet_ddc_staking, DdcStaking] + [pallet_ddc_nodes, DdcNodes] + [pallet_ddc_payouts, DdcPayouts] [pallet_democracy, Democracy] [pallet_election_provider_multi_phase, ElectionProviderMultiPhase] [pallet_election_provider_support_benchmarking, EPSBench::] From 36617426fa6713b15c8b634690156c54745bb322 Mon Sep 17 00:00:00 2001 From: yahortsaryk Date: Tue, 19 Dec 2023 16:10:42 +0100 Subject: [PATCH 3/3] fix: 'pallet-ddc-nodes' is included to 'cere_dev' std feature --- runtime/cere-dev/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/runtime/cere-dev/Cargo.toml b/runtime/cere-dev/Cargo.toml index cc8fce2c6..38c924efa 100644 --- a/runtime/cere-dev/Cargo.toml +++ b/runtime/cere-dev/Cargo.toml @@ -184,6 +184,7 @@ std = [ "cere-runtime-common/std", "cere-dev-runtime-constants/std", "pallet-ddc-customers/std", + "pallet-ddc-nodes/std", "pallet-ddc-clusters/std", "pallet-ddc-payouts/std", ]