From c0cd14dfa18f03af8348cfce09c98f0238dcc634 Mon Sep 17 00:00:00 2001 From: NZT48 Date: Sat, 3 Dec 2022 14:05:52 +0000 Subject: [PATCH 01/13] Change EVM chain ID to 20430 --- Cargo.lock | 2 +- runtime/src/lib.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 93d813a..c734873 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5307,7 +5307,7 @@ dependencies = [ [[package]] name = "origintrail-parachain-node" -version = "1.0.5" +version = "1.1.0" dependencies = [ "clap", "cumulus-client-cli", diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index eb5e7c1..7164e55 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -249,7 +249,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("origintrail-parachain"), impl_name: create_runtime_str!("origintrail-parachain"), authoring_version: 1, - spec_version: 105, + spec_version: 107, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1, @@ -789,7 +789,7 @@ impl> FindAuthor for FindAuthorTruncated { } parameter_types! { - pub const ChainId: u64 = 2043; + pub const ChainId: u64 = 20430; pub BlockGasLimit: U256 = U256::from(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT / WEIGHT_PER_GAS); pub PrecompilesValue: FrontierPrecompiles = FrontierPrecompiles::<_>::new(); } From 1ee218a0819d7cfa823c91fe891e9f24e3c42627 Mon Sep 17 00:00:00 2001 From: NZT48 Date: Sun, 2 Jul 2023 17:20:21 +0200 Subject: [PATCH 02/13] Revert "Merge pull request #51 from OriginTrail/release/testnet" This reverts commit cca6940a3f6e51c301a2c214a88897809b1edb63, reversing changes made to 8d56ceb11807c3aa8f468840fbf4f18fb05d6254. --- runtime/src/lib.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 5714b3d..3125ec7 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -774,9 +774,8 @@ impl> FindAuthor for FindAuthorTruncated { } parameter_types! { + pub const ChainId: u64 = 2043; pub BlockGasLimit: U256 = U256::from(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT.ref_time() / WEIGHT_PER_GAS); - pub const ChainId: u64 = 20430; - pub BlockGasLimit: U256 = U256::from(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT / WEIGHT_PER_GAS); pub PrecompilesValue: FrontierPrecompiles = FrontierPrecompiles::<_>::new(); pub WeightPerGas: Weight = Weight::from_parts(WEIGHT_PER_GAS, 0); } From a967e9aa2253724659611b4e46c48bec197fc8ef Mon Sep 17 00:00:00 2001 From: Nikola Todorovic Date: Sun, 2 Jul 2023 17:24:35 +0200 Subject: [PATCH 03/13] Fix whitepaper link in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 707e24d..e72972e 100644 --- a/README.md +++ b/README.md @@ -116,4 +116,4 @@ docker run -it -p 30333:30333 -p 9933:9933 -p 9944:9944 -p 9615:9615 -v /data:/d - More about expanding the multi-chain OriginTrail with Polkadot and OriginTrail Parachain development roadmap you can find on [parachain.origintrail.io](https://parachain.origintrail.io/) -- More about OriginTrail Parachain and Decentralized Knowledge Graph read in [whitepaper](https://parachain.origintrail.io/whitepaper) +- More about OriginTrail Parachain and Decentralized Knowledge Graph read in [whitepaper](https://origintrail.io/ecosystem/whitepaper) From 37cd3a2c3c2953965f2ce066b7afa4dd8e2c34fc Mon Sep 17 00:00:00 2001 From: NZT48 Date: Tue, 11 Jul 2023 22:50:14 +0000 Subject: [PATCH 04/13] Add preimage pallet --- Cargo.lock | 2 +- runtime/Cargo.toml | 12 ++++++------ runtime/src/lib.rs | 24 ++++++++++++++++-------- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6ec6672..44a45df 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6050,10 +6050,10 @@ dependencies = [ "pallet-evm-precompile-modexp", "pallet-evm-precompile-sha3fips", "pallet-evm-precompile-simple", + "pallet-preimage", "pallet-scheduler", "pallet-session", "pallet-sudo", - "pallet-template", "pallet-timestamp", "pallet-transaction-payment", "pallet-transaction-payment-rpc-runtime-api", diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 72fffce..bdd1fba 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -25,9 +25,6 @@ scale-info = { version = "2.3.1", default-features = false, features = [ ] } smallvec = "1.10.0" -# Local -pallet-template = { path = "../pallets/template", default-features = false } - # Substrate frame-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true, branch = "polkadot-v0.9.40" } frame-executive = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } @@ -40,6 +37,7 @@ pallet-assets = { git = "https://github.com/paritytech/substrate", default-featu pallet-aura = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } pallet-authorship = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +pallet-preimage = { git = "https://github.com/paritytech/substrate.git", default-features = false, branch = "polkadot-v0.9.40" } pallet-scheduler = { git = "https://github.com/paritytech/substrate.git", default-features = false, branch = "polkadot-v0.9.40" } pallet-session = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } pallet-sudo = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } @@ -126,10 +124,10 @@ std = [ "pallet-evm-precompile-simple/std", "pallet-evm-precompile-sha3fips/std", "pallet-ethereum/std", + "pallet-preimage/std", "pallet-scheduler/std", "pallet-session/std", "pallet-sudo/std", - "pallet-template/std", "pallet-timestamp/std", "pallet-transaction-payment-rpc-runtime-api/std", "pallet-transaction-payment/std", @@ -167,7 +165,8 @@ runtime-benchmarks = [ "pallet-collator-selection/runtime-benchmarks", "pallet-evm/runtime-benchmarks", "pallet-ethereum/runtime-benchmarks", - "pallet-template/runtime-benchmarks", + "pallet-preimage/runtime-benchmarks", + "pallet-scheduler/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", "pallet-treasury/runtime-benchmarks", "pallet-vesting/runtime-benchmarks", @@ -192,9 +191,10 @@ try-runtime = [ "pallet-authorship/try-runtime", "pallet-balances/try-runtime", "pallet-collator-selection/try-runtime", + "pallet-preimage/try-runtime", + "pallet-scheduler/try-runtime", "pallet-session/try-runtime", "pallet-sudo/try-runtime", - "pallet-template/try-runtime", "pallet-timestamp/try-runtime", "pallet-transaction-payment/try-runtime", "pallet-xcm/try-runtime", diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 3125ec7..9027fc6 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -80,9 +80,6 @@ use pallet_evm_precompile_assets_erc20::AddressToAssetId; mod precompiles; use precompiles::{FrontierPrecompiles, ASSET_PRECOMPILE_ADDRESS_PREFIX}; -/// Import the template pallet. -pub use pallet_template; - /// Alias to 512-bit hash when used in the context of a transaction signature on the chain. pub type Signature = MultiSignature; @@ -895,9 +892,19 @@ impl pallet_xc_asset_config::Config for Runtime { type WeightInfo = weights::pallet_xc_asset_config::WeightInfo; } -/// Configure the pallet template in pallets/template. -impl pallet_template::Config for Runtime { - type RuntimeEvent = RuntimeEvent; +parameter_types! { + pub const PreimageMaxSize: u32 = 4096 * 1024; + pub const PreimageBaseDeposit: Balance = 1 * OTP; + pub const PreimageByteDeposit: Balance = 1 * MILLIOTP; +} + +impl pallet_preimage::Config for Runtime { + type WeightInfo = pallet_preimage::weights::SubstrateWeight; + type RuntimeEvent = RuntimeEvent; + type Currency = Balances; + type ManagerOrigin = EnsureRoot; + type BaseDeposit = PreimageBaseDeposit; + type ByteDeposit = PreimageByteDeposit; } // Create the runtime by composing the FRAME pallets that were previously configured. @@ -936,8 +943,8 @@ construct_runtime!( CumulusXcm: cumulus_pallet_xcm::{Pallet, Event, Origin} = 32, DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event} = 33, - // Template. - TemplatePallet: pallet_template::{Pallet, Call, Storage, Event} = 40, + // Governance. + Preimage: pallet_preimage = 40, // Frontier EVM: pallet_evm::{Pallet, Config, Call, Storage, Event} = 50, @@ -962,6 +969,7 @@ mod benches { frame_benchmarking::define_benchmarks!( [frame_system, SystemBench::] [pallet_balances, Balances] + [pallet_preimage, Preimage] [pallet_session, SessionBench::] [pallet_timestamp, Timestamp] [pallet_collator_selection, CollatorSelection] From b52fb0c2aab08971df6de8aa1110ef5e22e1dada Mon Sep 17 00:00:00 2001 From: NZT48 Date: Tue, 11 Jul 2023 23:37:40 +0000 Subject: [PATCH 05/13] Add utlity pallet --- Cargo.lock | 1 + runtime/Cargo.toml | 9 ++++++++- runtime/src/lib.rs | 9 +++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 44a45df..ad0308a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6058,6 +6058,7 @@ dependencies = [ "pallet-transaction-payment", "pallet-transaction-payment-rpc-runtime-api", "pallet-treasury", + "pallet-utility", "pallet-vesting", "pallet-xc-asset-config", "pallet-xcm", diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index bdd1fba..f190496 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -37,7 +37,6 @@ pallet-assets = { git = "https://github.com/paritytech/substrate", default-featu pallet-aura = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } pallet-authorship = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -pallet-preimage = { git = "https://github.com/paritytech/substrate.git", default-features = false, branch = "polkadot-v0.9.40" } pallet-scheduler = { git = "https://github.com/paritytech/substrate.git", default-features = false, branch = "polkadot-v0.9.40" } pallet-session = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } pallet-sudo = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } @@ -45,6 +44,7 @@ pallet-timestamp = { git = "https://github.com/paritytech/substrate", default-fe pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } pallet-treasury = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +pallet-utility = { git = "https://github.com/paritytech/substrate.git", default-features = false, branch = "polkadot-v0.9.40" } pallet-vesting = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } pallet-xc-asset-config = { path = "../pallets/xc-asset-config", default-features = false } sp-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } @@ -92,6 +92,9 @@ pallet-ethereum = { git = "https://github.com/OriginTrail/frontier", default-fea fp-rpc = { git = "https://github.com/OriginTrail/frontier", default-features = false, branch = "polkadot-v0.9.40" } fp-self-contained = { git = "https://github.com/OriginTrail/frontier", default-features = false, branch = "polkadot-v0.9.40" } +# Governance +pallet-preimage = { git = "https://github.com/paritytech/substrate.git", default-features = false, branch = "polkadot-v0.9.40" } + [features] default = ["std"] std = [ @@ -132,6 +135,7 @@ std = [ "pallet-transaction-payment-rpc-runtime-api/std", "pallet-transaction-payment/std", "pallet-treasury/std", + "pallet-utility/std", "pallet-vesting/std", "pallet-xc-asset-config/std", "pallet-xcm/std", @@ -169,6 +173,7 @@ runtime-benchmarks = [ "pallet-scheduler/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", "pallet-treasury/runtime-benchmarks", + "pallet-utility/runtime-benchmarks", "pallet-vesting/runtime-benchmarks", "pallet-xc-asset-config/runtime-benchmarks", "pallet-xcm/runtime-benchmarks", @@ -195,6 +200,8 @@ try-runtime = [ "pallet-scheduler/try-runtime", "pallet-session/try-runtime", "pallet-sudo/try-runtime", + "pallet-utility/try-runtime", + "pallet-vesting/try-runtime", "pallet-timestamp/try-runtime", "pallet-transaction-payment/try-runtime", "pallet-xcm/try-runtime", diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 9027fc6..abdb09d 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -907,6 +907,13 @@ impl pallet_preimage::Config for Runtime { type ByteDeposit = PreimageByteDeposit; } +impl pallet_utility::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type RuntimeCall = RuntimeCall; + type PalletsOrigin = OriginCaller; + type WeightInfo = pallet_utility::weights::SubstrateWeight; +} + // Create the runtime by composing the FRAME pallets that were previously configured. construct_runtime!( pub enum Runtime where @@ -921,6 +928,7 @@ construct_runtime!( } = 1, Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 2, ParachainInfo: parachain_info::{Pallet, Storage, Config} = 3, + Utility: pallet_utility = 4, // Monetary stuff. Balances: pallet_balances::{Pallet, Call, Storage, Config, Event} = 10, @@ -974,6 +982,7 @@ mod benches { [pallet_timestamp, Timestamp] [pallet_collator_selection, CollatorSelection] [cumulus_pallet_xcmp_queue, XcmpQueue] + [pallet_utility, Utility] ); } From 48d4efb9aaa709193eea0d8fc1bfa57d07b4c324 Mon Sep 17 00:00:00 2001 From: NZT48 Date: Wed, 12 Jul 2023 00:04:00 +0000 Subject: [PATCH 06/13] Add council implementation --- Cargo.lock | 1 + node/src/chain_spec.rs | 1 + runtime/Cargo.toml | 4 ++++ runtime/src/lib.rs | 27 +++++++++++++++++++++++---- 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ad0308a..95cd4dd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6043,6 +6043,7 @@ dependencies = [ "pallet-balances", "pallet-base-fee", "pallet-collator-selection", + "pallet-collective", "pallet-ethereum", "pallet-evm", "pallet-evm-accounts", diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index 710cd26..5eb3a04 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -262,5 +262,6 @@ fn testnet_genesis( }, ethereum: EthereumConfig {}, base_fee: Default::default(), + council: Default::default(), } } diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index f190496..ee7a4ec 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -94,6 +94,7 @@ fp-self-contained = { git = "https://github.com/OriginTrail/frontier", default-f # Governance pallet-preimage = { git = "https://github.com/paritytech/substrate.git", default-features = false, branch = "polkadot-v0.9.40" } +pallet-collective = { git = "https://github.com/paritytech/substrate.git", default-features = false, branch = "polkadot-v0.9.40" } [features] default = ["std"] @@ -121,6 +122,7 @@ std = [ "pallet-balances/std", "pallet-base-fee/std", "pallet-collator-selection/std", + "pallet-collective/std", "pallet-evm/std", "pallet-evm-accounts/std", "pallet-evm-precompile-assets-erc20/std", @@ -167,6 +169,7 @@ runtime-benchmarks = [ "pallet-assets/runtime-benchmarks", "pallet-balances/runtime-benchmarks", "pallet-collator-selection/runtime-benchmarks", + "pallet-collective/runtime-benchmarks", "pallet-evm/runtime-benchmarks", "pallet-ethereum/runtime-benchmarks", "pallet-preimage/runtime-benchmarks", @@ -196,6 +199,7 @@ try-runtime = [ "pallet-authorship/try-runtime", "pallet-balances/try-runtime", "pallet-collator-selection/try-runtime", + "pallet-collective/try-runtime", "pallet-preimage/try-runtime", "pallet-scheduler/try-runtime", "pallet-session/try-runtime", diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index abdb09d..5034272 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -914,6 +914,25 @@ impl pallet_utility::Config for Runtime { type WeightInfo = pallet_utility::weights::SubstrateWeight; } +parameter_types! { + pub const CouncilMotionDuration: BlockNumber = 28 * DAYS; + pub const CouncilMaxProposals: u32 = 100; + pub const CouncilMaxMembers: u32 = 100; +} + +type CouncilCollective = pallet_collective::Instance1; +impl pallet_collective::Config for Runtime { + type RuntimeOrigin = RuntimeOrigin; + type Proposal = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type MotionDuration = CouncilMotionDuration; + type MaxProposals = CouncilMaxProposals; + type MaxMembers = CouncilMaxMembers; + type DefaultVote = pallet_collective::PrimeDefaultVote; + type WeightInfo = pallet_collective::weights::SubstrateWeight; + type SetMembersOrigin = EnsureRoot; +} + // Create the runtime by composing the FRAME pallets that were previously configured. construct_runtime!( pub enum Runtime where @@ -951,17 +970,16 @@ construct_runtime!( CumulusXcm: cumulus_pallet_xcm::{Pallet, Event, Origin} = 32, DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event} = 33, - // Governance. - Preimage: pallet_preimage = 40, - // Frontier EVM: pallet_evm::{Pallet, Config, Call, Storage, Event} = 50, Ethereum: pallet_ethereum::{Pallet, Call, Storage, Event, Config, Origin} = 51, EvmAccounts: pallet_evm_accounts::{Pallet, Call, Storage, Event} = 52, BaseFee: pallet_base_fee::{Pallet, Call, Storage, Config, Event} = 53, - // Governance stuff. + // Governance Scheduler: pallet_scheduler::{Pallet, Storage, Event, Call} = 60, + Preimage: pallet_preimage = 61, + Council: pallet_collective:: = 62, // Temporary. Sudo: pallet_sudo = 255, @@ -977,6 +995,7 @@ mod benches { frame_benchmarking::define_benchmarks!( [frame_system, SystemBench::] [pallet_balances, Balances] + [pallet_collective, CouncilCollective] [pallet_preimage, Preimage] [pallet_session, SessionBench::] [pallet_timestamp, Timestamp] From 771dc8dddd791a23cbb5f6e88bd0669e014c6cec Mon Sep 17 00:00:00 2001 From: NZT48 Date: Wed, 12 Jul 2023 00:49:50 +0000 Subject: [PATCH 07/13] Add democracy and identity pallets, tune up governance parameters --- Cargo.lock | 2 + node/src/chain_spec.rs | 1 + runtime/Cargo.toml | 10 +++- runtime/src/lib.rs | 109 +++++++++++++++++++++++++++++++++++++++-- 4 files changed, 116 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 95cd4dd..3cc7dbf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6044,6 +6044,7 @@ dependencies = [ "pallet-base-fee", "pallet-collator-selection", "pallet-collective", + "pallet-democracy", "pallet-ethereum", "pallet-evm", "pallet-evm-accounts", @@ -6051,6 +6052,7 @@ dependencies = [ "pallet-evm-precompile-modexp", "pallet-evm-precompile-sha3fips", "pallet-evm-precompile-simple", + "pallet-identity", "pallet-preimage", "pallet-scheduler", "pallet-session", diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index 5eb3a04..f91d248 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -263,5 +263,6 @@ fn testnet_genesis( ethereum: EthereumConfig {}, base_fee: Default::default(), council: Default::default(), + democracy: Default::default(), } } diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index ee7a4ec..2fa0db6 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -93,8 +93,10 @@ fp-rpc = { git = "https://github.com/OriginTrail/frontier", default-features = f fp-self-contained = { git = "https://github.com/OriginTrail/frontier", default-features = false, branch = "polkadot-v0.9.40" } # Governance -pallet-preimage = { git = "https://github.com/paritytech/substrate.git", default-features = false, branch = "polkadot-v0.9.40" } pallet-collective = { git = "https://github.com/paritytech/substrate.git", default-features = false, branch = "polkadot-v0.9.40" } +pallet-democracy = { git = "https://github.com/paritytech/substrate.git", default-features = false, branch = "polkadot-v0.9.40" } +pallet-identity = { git = "https://github.com/paritytech/substrate.git", default-features = false, branch = "polkadot-v0.9.40" } +pallet-preimage = { git = "https://github.com/paritytech/substrate.git", default-features = false, branch = "polkadot-v0.9.40" } [features] default = ["std"] @@ -123,12 +125,14 @@ std = [ "pallet-base-fee/std", "pallet-collator-selection/std", "pallet-collective/std", + "pallet-democracy/std", "pallet-evm/std", "pallet-evm-accounts/std", "pallet-evm-precompile-assets-erc20/std", "pallet-evm-precompile-simple/std", "pallet-evm-precompile-sha3fips/std", "pallet-ethereum/std", + "pallet-identity/std", "pallet-preimage/std", "pallet-scheduler/std", "pallet-session/std", @@ -170,8 +174,10 @@ runtime-benchmarks = [ "pallet-balances/runtime-benchmarks", "pallet-collator-selection/runtime-benchmarks", "pallet-collective/runtime-benchmarks", + "pallet-democracy/runtime-benchmarks", "pallet-evm/runtime-benchmarks", "pallet-ethereum/runtime-benchmarks", + "pallet-identity/runtime-benchmarks", "pallet-preimage/runtime-benchmarks", "pallet-scheduler/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", @@ -200,6 +206,8 @@ try-runtime = [ "pallet-balances/try-runtime", "pallet-collator-selection/try-runtime", "pallet-collective/try-runtime", + "pallet-democracy/runtime-benchmarks", + "pallet-identity/runtime-benchmarks", "pallet-preimage/try-runtime", "pallet-scheduler/try-runtime", "pallet-session/try-runtime", diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 5034272..fe41efe 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -36,7 +36,7 @@ pub use frame_support::traits::EqualPrivilegeOnly; use frame_support::{ construct_runtime, parameter_types, transactional, traits::{ - AsEnsureOriginWithArg, Currency as PalletCurrency, Everything, FindAuthor, + AsEnsureOriginWithArg, Currency as PalletCurrency, EitherOfDiverse, Everything, FindAuthor, ReservableCurrency, Imbalance, OnUnbalanced, ConstU128, ConstU32, ConstU64, ConstU8, WithdrawReasons }, @@ -296,6 +296,10 @@ const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts( cumulus_primitives_core::relay_chain::MAX_POV_SIZE as u64, ); +pub const fn deposit(items: u32, bytes: u32) -> Balance { + items as Balance * 15 * MILLIOTP + (bytes as Balance) * 6 * MILLIOTP +} + /// The version information used to identify this runtime when compiled natively. #[cfg(feature = "std")] pub fn native_version() -> NativeVersion { @@ -894,7 +898,7 @@ impl pallet_xc_asset_config::Config for Runtime { parameter_types! { pub const PreimageMaxSize: u32 = 4096 * 1024; - pub const PreimageBaseDeposit: Balance = 1 * OTP; + pub const PreimageBaseDeposit: Balance = deposit(2, 64); pub const PreimageByteDeposit: Balance = 1 * MILLIOTP; } @@ -915,9 +919,9 @@ impl pallet_utility::Config for Runtime { } parameter_types! { - pub const CouncilMotionDuration: BlockNumber = 28 * DAYS; + pub const CouncilMotionDuration: BlockNumber = 3 * DAYS; pub const CouncilMaxProposals: u32 = 100; - pub const CouncilMaxMembers: u32 = 100; + pub const CouncilMaxMembers: u32 = 5; } type CouncilCollective = pallet_collective::Instance1; @@ -928,11 +932,102 @@ impl pallet_collective::Config for Runtime { type MotionDuration = CouncilMotionDuration; type MaxProposals = CouncilMaxProposals; type MaxMembers = CouncilMaxMembers; - type DefaultVote = pallet_collective::PrimeDefaultVote; + type DefaultVote = pallet_collective::MoreThanMajorityThenPrimeDefaultVote; type WeightInfo = pallet_collective::weights::SubstrateWeight; type SetMembersOrigin = EnsureRoot; } +parameter_types! { + pub const LaunchPeriod: BlockNumber = 5 * DAYS; + pub const VotingPeriod: BlockNumber = 5 * DAYS; + pub const VotingLockingPeriod: BlockNumber = 1 * DAYS; + pub const FastTrackVotingPeriod: BlockNumber = 3 * HOURS; + pub const MinimumDeposit: Balance = 1000 * OTP; + pub const EnactmentPeriod: BlockNumber = 2 * DAYS; + pub const CooloffPeriod: BlockNumber = 7 * DAYS; + pub const MaxProposals: u32 = 100; +} + +type EnsureRootOrTwoFiftsOfCouncil = EitherOfDiverse< + EnsureRoot, + pallet_collective::EnsureProportionMoreThan, +>; +type EnsureRootOrThreeFiftsOfCouncil = EitherOfDiverse< + EnsureRoot, + pallet_collective::EnsureProportionMoreThan, +>; +type EnsureRootOrFourFiftsOfCouncil = EitherOfDiverse< + EnsureRoot, + pallet_collective::EnsureProportionMoreThan, +>; + +impl pallet_democracy::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Currency = Balances; + type EnactmentPeriod = EnactmentPeriod; + type LaunchPeriod = LaunchPeriod; + type VotingPeriod = VotingPeriod; + type VoteLockingPeriod = VotingLockingPeriod; // Same as EnactmentPeriod + type MinimumDeposit = MinimumDeposit; + /// A straight majority of the council can decide what their next motion is. + type ExternalOrigin = EnsureRootOrTwoFiftsOfCouncil; + /// A super-majority can have the next scheduled referendum be a straight majority-carries vote. + type ExternalMajorityOrigin = EnsureRootOrThreeFiftsOfCouncil; + /// A unanimous council can have the next scheduled referendum be a straight default-carries + /// (NTB) vote. + type ExternalDefaultOrigin = EnsureRootOrThreeFiftsOfCouncil; + type SubmitOrigin = EnsureSigned; + /// Two thirds of the technical committee can have an ExternalMajority/ExternalDefault vote + /// be tabled immediately and with a shorter voting/enactment period. + type FastTrackOrigin = EnsureRootOrThreeFiftsOfCouncil; + type InstantOrigin = EnsureRootOrFourFiftsOfCouncil; + type InstantAllowed = frame_support::traits::ConstBool; + type FastTrackVotingPeriod = FastTrackVotingPeriod; + // To cancel a proposal which has been passed, 3/5 of the council must agree to it. + type CancellationOrigin = EnsureRootOrThreeFiftsOfCouncil; + // To cancel a proposal before it has been passed, the technical committee must be unanimous or + // Root must agree. + type CancelProposalOrigin = EnsureRootOrThreeFiftsOfCouncil; + type BlacklistOrigin = EnsureRoot; + // Any single technical committee member may veto a coming council proposal, however they can + // only do it once and it lasts only for the cool-off period. + type VetoOrigin = pallet_collective::EnsureMember; + type CooloffPeriod = CooloffPeriod; + type Slash = Treasury; + type Scheduler = Scheduler; + type PalletsOrigin = OriginCaller; + type MaxVotes = ConstU32<100>; + type WeightInfo = pallet_democracy::weights::SubstrateWeight; + type MaxProposals = MaxProposals; + type Preimages = Preimage; + type MaxDeposits = ConstU32<100>; + type MaxBlacklisted = ConstU32<100>; +} + +parameter_types! { + pub const BasicDeposit: Balance = deposit(1, 258); // 258 bytes on-chain + pub const FieldDeposit: Balance = deposit(1, 66); // 66 bytes on-chain + pub const SubAccountDeposit: Balance = deposit(1, 53); // 53 bytes on-chain + pub const MaxSubAccounts: u32 = 100; + pub const MaxAdditionalFields: u32 = 100; + pub const MaxRegistrars: u32 = 20; +} + +impl pallet_identity::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Currency = Balances; + type BasicDeposit = BasicDeposit; + type FieldDeposit = FieldDeposit; + type SubAccountDeposit = SubAccountDeposit; + type MaxSubAccounts = MaxSubAccounts; + type MaxAdditionalFields = MaxAdditionalFields; + type MaxRegistrars = MaxRegistrars; + type Slashed = Treasury; + type ForceOrigin = EnsureRootOrThreeFiftsOfCouncil; + type RegistrarOrigin = EnsureRootOrThreeFiftsOfCouncil; + type WeightInfo = pallet_identity::weights::SubstrateWeight; +} + // Create the runtime by composing the FRAME pallets that were previously configured. construct_runtime!( pub enum Runtime where @@ -980,6 +1075,8 @@ construct_runtime!( Scheduler: pallet_scheduler::{Pallet, Storage, Event, Call} = 60, Preimage: pallet_preimage = 61, Council: pallet_collective:: = 62, + Democracy: pallet_democracy = 63, + Identity: pallet_identity = 64, // Temporary. Sudo: pallet_sudo = 255, @@ -996,6 +1093,8 @@ mod benches { [frame_system, SystemBench::] [pallet_balances, Balances] [pallet_collective, CouncilCollective] + [pallet_democracy, Democracy] + [pallet_identity, Identity] [pallet_preimage, Preimage] [pallet_session, SessionBench::] [pallet_timestamp, Timestamp] From d0d7cc3c4a43ced41ce9fb0ec5d554b38aba9a61 Mon Sep 17 00:00:00 2001 From: NZT48 Date: Fri, 14 Jul 2023 00:26:07 +0000 Subject: [PATCH 08/13] Handle fees from evm transactions --- runtime/src/lib.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index fe41efe..841e6b9 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -459,6 +459,7 @@ type NegativeImbalance = >::NegativeImbala pub struct DealWithFees; impl OnUnbalanced for DealWithFees { + // this is called for substrate-based transactions fn on_unbalanceds(mut fees_then_tips: impl Iterator) { if let Some(mut fees) = fees_then_tips.next() { if let Some(tips) = fees_then_tips.next() { @@ -479,6 +480,20 @@ impl OnUnbalanced for DealWithFees { >::on_unbalanced(dkg_incentives_fees); } } + + // this is called from pallet_evm for Ethereum-based transactions + // (technically, it calls on_unbalanced, which calls this when non-zero) + fn on_nonzero_unbalanced(amount: NegativeImbalance) { + let split = amount.ration(60, 40); + let (dkg_incentives_fees, collators_incentives_fees) = split.0.ration(50, 50); + let (future_auctions_fees, treasury_fees) = split.1.ration(75, 25); + + Treasury::on_unbalanced(treasury_fees); + >::on_unbalanced(collators_incentives_fees); + >::on_unbalanced(future_auctions_fees); + >::on_unbalanced(dkg_incentives_fees); + } + } parameter_types! { @@ -611,6 +626,11 @@ impl pallet_sudo::Config for Runtime { type RuntimeCall = RuntimeCall; } +impl pallet_sudo::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type RuntimeCall = RuntimeCall; +} + parameter_types! { pub const MinVestedTransfer: Balance = 15 * OTP; pub UnvestedFundsAllowedWithdrawReasons: WithdrawReasons = From cf1ecc782b007258b30ae56b93c4651b6fb7a81c Mon Sep 17 00:00:00 2001 From: NZT48 Date: Fri, 14 Jul 2023 00:30:08 +0000 Subject: [PATCH 09/13] Bump spec version, on slash for treasury pallet --- runtime/src/lib.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 841e6b9..6d7d7da 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -250,7 +250,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("origintrail-parachain"), impl_name: create_runtime_str!("origintrail-parachain"), authoring_version: 1, - spec_version: 111, + spec_version: 112, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1, @@ -493,7 +493,6 @@ impl OnUnbalanced for DealWithFees { >::on_unbalanced(future_auctions_fees); >::on_unbalanced(dkg_incentives_fees); } - } parameter_types! { @@ -663,7 +662,7 @@ impl pallet_treasury::Config for Runtime { type ApproveOrigin = EnsureRoot; type RejectOrigin = EnsureRoot; type RuntimeEvent = RuntimeEvent; - type OnSlash = (); + type OnSlash = Treasury; type ProposalBond = ProposalBond; type ProposalBondMinimum = ProposalBondMinimum; type ProposalBondMaximum = ProposalBondMaximum; From 254f49de77873bfe75c94c89f9944765a5a6bca1 Mon Sep 17 00:00:00 2001 From: NZT48 Date: Fri, 14 Jul 2023 00:31:11 +0000 Subject: [PATCH 10/13] Remove duplice sudo pallet --- runtime/src/lib.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 6d7d7da..82787ad 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -625,11 +625,6 @@ impl pallet_sudo::Config for Runtime { type RuntimeCall = RuntimeCall; } -impl pallet_sudo::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type RuntimeCall = RuntimeCall; -} - parameter_types! { pub const MinVestedTransfer: Balance = 15 * OTP; pub UnvestedFundsAllowedWithdrawReasons: WithdrawReasons = From 50eca0558cb66532f14cdc961be9453182ddb8c4 Mon Sep 17 00:00:00 2001 From: NZT48 Date: Fri, 14 Jul 2023 10:18:20 +0000 Subject: [PATCH 11/13] Connect preimage and scheduler pallet --- runtime/Cargo.toml | 2 +- runtime/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 2fa0db6..98cfb22 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "origintrail-parachain-runtime" -version = "1.1.1" +version = "1.1.2" authors = ["TraceLabs"] description = "OriginTrail Parachain Runtime - Cumulus FRAME-based Substrate Runtime" license = "GPL-3.0-only" diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 82787ad..9c31ead 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -616,7 +616,7 @@ impl pallet_scheduler::Config for Runtime { type ScheduleOrigin = frame_system::EnsureRoot; type MaxScheduledPerBlock = MaxScheduledPerBlock; type WeightInfo = (); - type Preimages = (); + type Preimages = Preimage; type OriginPrivilegeCmp = EqualPrivilegeOnly; } From ca651eed6adcd27cbeeeb1843c0cbd7045c24d1c Mon Sep 17 00:00:00 2001 From: NZT48 Date: Wed, 19 Jul 2023 00:34:20 +0000 Subject: [PATCH 12/13] Set ensure type to take AtLeast for Council members --- Cargo.lock | 2 +- runtime/src/lib.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3cc7dbf..14e04a9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6015,7 +6015,7 @@ dependencies = [ [[package]] name = "origintrail-parachain-runtime" -version = "1.1.1" +version = "1.1.2" dependencies = [ "cumulus-pallet-aura-ext", "cumulus-pallet-dmp-queue", diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 9c31ead..3e893c5 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -964,15 +964,15 @@ parameter_types! { type EnsureRootOrTwoFiftsOfCouncil = EitherOfDiverse< EnsureRoot, - pallet_collective::EnsureProportionMoreThan, + pallet_collective::EnsureProportionAtLeast, >; type EnsureRootOrThreeFiftsOfCouncil = EitherOfDiverse< EnsureRoot, - pallet_collective::EnsureProportionMoreThan, + pallet_collective::EnsureProportionAtLeast, >; type EnsureRootOrFourFiftsOfCouncil = EitherOfDiverse< EnsureRoot, - pallet_collective::EnsureProportionMoreThan, + pallet_collective::EnsureProportionAtLeast, >; impl pallet_democracy::Config for Runtime { From e1d3d867dd4b64d6f24197e2ecbe8fdb0faf8ab7 Mon Sep 17 00:00:00 2001 From: NZT48 Date: Wed, 19 Jul 2023 01:13:28 +0000 Subject: [PATCH 13/13] Code formatting --- runtime/src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 3e893c5..ff7a159 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -917,12 +917,12 @@ parameter_types! { } impl pallet_preimage::Config for Runtime { - type WeightInfo = pallet_preimage::weights::SubstrateWeight; type RuntimeEvent = RuntimeEvent; type Currency = Balances; type ManagerOrigin = EnsureRoot; type BaseDeposit = PreimageBaseDeposit; type ByteDeposit = PreimageByteDeposit; + type WeightInfo = pallet_preimage::weights::SubstrateWeight; } impl pallet_utility::Config for Runtime { @@ -947,8 +947,8 @@ impl pallet_collective::Config for Runtime { type MaxProposals = CouncilMaxProposals; type MaxMembers = CouncilMaxMembers; type DefaultVote = pallet_collective::MoreThanMajorityThenPrimeDefaultVote; - type WeightInfo = pallet_collective::weights::SubstrateWeight; - type SetMembersOrigin = EnsureRoot; + type SetMembersOrigin = EnsureRoot; + type WeightInfo = pallet_collective::weights::SubstrateWeight; } parameter_types! { @@ -1011,11 +1011,11 @@ impl pallet_democracy::Config for Runtime { type Scheduler = Scheduler; type PalletsOrigin = OriginCaller; type MaxVotes = ConstU32<100>; - type WeightInfo = pallet_democracy::weights::SubstrateWeight; type MaxProposals = MaxProposals; type Preimages = Preimage; type MaxDeposits = ConstU32<100>; type MaxBlacklisted = ConstU32<100>; + type WeightInfo = pallet_democracy::weights::SubstrateWeight; } parameter_types! {