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

[encointer] introduce democracy and community treasuries #456

Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

- Allow signed origins to send arbitrary XCMs from some system chains ([polkadot-fellows/runtimes#407](https://github.com/polkadot-fellows/runtimes/pull/407))
- Include the Core and Salary pallets into the Fellowship proxy ([polkadot-fellows/runtimes#454](https://github.com/polkadot-fellows/runtimes/pull/454))
- Add new community democracy and treasuries pallets to Encointer ([polkadot-fellows/runtimes#456](https://github.com/polkadot-fellows/runtimes/pull/456))

### Fixed

Expand Down
68 changes: 66 additions & 2 deletions Cargo.lock

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

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ emulated-integration-tests-common = { version = "11.0.0" }
encointer-balances-tx-payment = { version = "~13.1.0", default-features = false }
encointer-balances-tx-payment-rpc-runtime-api = { version = "~13.1.0", default-features = false }
encointer-kusama-runtime = { path = "system-parachains/encointer" }
encointer-primitives = { version = "~13.2.0", default-features = false }
encointer-primitives = { version = "~13.3.0", default-features = false }
enumflags2 = { version = "0.7.7" }
frame-benchmarking = { version = "36.0.0", default-features = false }
frame-election-provider-support = { version = "36.0.0", default-features = false }
Expand Down Expand Up @@ -114,9 +114,12 @@ pallet-encointer-ceremonies = { version = "~13.1.0", default-features = false }
pallet-encointer-ceremonies-rpc-runtime-api = { version = "~13.1.0", default-features = false }
pallet-encointer-communities = { version = "~13.1.0", default-features = false }
pallet-encointer-communities-rpc-runtime-api = { version = "~13.1.0", default-features = false }
pallet-encointer-democracy = { version = "~13.3.2", default-features = false }
pallet-encointer-faucet = { version = "~13.2.0", default-features = false }
pallet-encointer-reputation-commitments = { version = "~13.1.0", default-features = false }
pallet-encointer-scheduler = { version = "~13.1.0", default-features = false }
pallet-encointer-treasuries = { version = "~13.3.0", default-features = false }
pallet-encointer-treasuries-rpc-runtime-api = { version = "~13.3.0", default-features = false }
pallet-fast-unstake = { version = "35.0.0", default-features = false }
pallet-glutton = { version = "22.0.0", default-features = false }
pallet-grandpa = { version = "36.0.0", default-features = false }
Expand Down
10 changes: 10 additions & 0 deletions system-parachains/encointer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,12 @@ pallet-encointer-ceremonies = { workspace = true }
pallet-encointer-ceremonies-rpc-runtime-api = { workspace = true }
pallet-encointer-communities = { workspace = true }
pallet-encointer-communities-rpc-runtime-api = { workspace = true }
pallet-encointer-democracy = { workspace = true }
pallet-encointer-faucet = { workspace = true }
pallet-encointer-reputation-commitments = { workspace = true }
pallet-encointer-scheduler = { workspace = true }
pallet-encointer-treasuries = { workspace = true }
pallet-encointer-treasuries-rpc-runtime-api = { workspace = true }


# Substrate
Expand Down Expand Up @@ -132,9 +135,11 @@ runtime-benchmarks = [
"pallet-encointer-bazaar/runtime-benchmarks",
"pallet-encointer-ceremonies/runtime-benchmarks",
"pallet-encointer-communities/runtime-benchmarks",
"pallet-encointer-democracy/runtime-benchmarks",
"pallet-encointer-faucet/runtime-benchmarks",
"pallet-encointer-reputation-commitments/runtime-benchmarks",
"pallet-encointer-scheduler/runtime-benchmarks",
"pallet-encointer-treasuries/runtime-benchmarks",
"pallet-membership/runtime-benchmarks",
"pallet-message-queue/runtime-benchmarks",
"pallet-proxy/runtime-benchmarks",
Expand Down Expand Up @@ -188,9 +193,12 @@ std = [
"pallet-encointer-ceremonies/std",
"pallet-encointer-communities-rpc-runtime-api/std",
"pallet-encointer-communities/std",
"pallet-encointer-democracy/std",
"pallet-encointer-faucet/std",
"pallet-encointer-reputation-commitments/std",
"pallet-encointer-scheduler/std",
"pallet-encointer-treasuries-rpc-runtime-api/std",
"pallet-encointer-treasuries/std",
"pallet-insecure-randomness-collective-flip/std",
"pallet-membership/std",
"pallet-message-queue/std",
Expand Down Expand Up @@ -253,9 +261,11 @@ try-runtime = [
"pallet-encointer-bazaar/try-runtime",
"pallet-encointer-ceremonies/try-runtime",
"pallet-encointer-communities/try-runtime",
"pallet-encointer-democracy/try-runtime",
"pallet-encointer-faucet/try-runtime",
"pallet-encointer-reputation-commitments/try-runtime",
"pallet-encointer-scheduler/try-runtime",
"pallet-encointer-treasuries/try-runtime",
"pallet-insecure-randomness-collective-flip/try-runtime",
"pallet-membership/try-runtime",
"pallet-message-queue/try-runtime",
Expand Down
30 changes: 30 additions & 0 deletions system-parachains/encointer/src/genesis_config_presets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,36 @@ fn encointer_kusama_genesis(
"polkadotXcm": {
"safeXcmVersion": Some(SAFE_XCM_VERSION),
},
"encointerScheduler": {
"currentPhase": CeremonyPhaseType::Registering,
"currentCeremonyIndex": 1,
"phaseDurations": vec![
(CeremonyPhaseType::Registering, 604800000u64), // 7d
(CeremonyPhaseType::Assigning, 86400000u64), // 1d
(CeremonyPhaseType::Attesting, 172800000u64), // 2d
],
},
"encointerCeremonies": {
"ceremonyReward": BalanceType::from_num(1),
"timeTolerance": 600_000u64, // +-10min
"locationTolerance": 1_000, // [m]
"endorsementTicketsPerBootstrapper": 10,
"endorsementTicketsPerReputable": 5,
"reputationLifetime": 5,
"inactivityTimeout": 5, // idle ceremonies before purging community
"meetupTimeOffset": 0,
},
"encointerCommunities": {
"minSolarTripTimeS": 1, // [s]
"maxSpeedMps": 1, // [m/s] suggested would be 83m/s for security,
},
"encointerBalances": {
// for relative adjustment.
"feeConversionFactor": 7_143u32,
},
"encointerFaucet": {
"reserveAmount": 10_000_000_000_000u128,
},
// no need to pass anything to aura, in fact it will panic if we do. Session will take care
// of this. `aura: Default::default()`
})
Expand Down
37 changes: 35 additions & 2 deletions system-parachains/encointer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ use frame_support::{
traits::{
fungibles::{Balanced, Credit},
tokens::{imbalance::ResolveTo, ConversionToAssetBalance},
ConstBool, ConstU64, Contains, EitherOfDiverse, EqualPrivilegeOnly, InstanceFilter,
TransformOrigin,
ConstBool, ConstU128, ConstU64, Contains, EitherOfDiverse, EqualPrivilegeOnly,
InstanceFilter, TransformOrigin,
},
weights::{ConstantMultiplier, Weight, WeightToFee as _},
PalletId,
Expand Down Expand Up @@ -545,6 +545,29 @@ impl pallet_encointer_faucet::Config for Runtime {
type WeightInfo = weights::pallet_encointer_faucet::WeightInfo<Runtime>;
}

parameter_types! {
pub const ConfirmationPeriod: Moment = 2 * 24 * 3600 * 1000; // [ms]
pub const ProposalLifetime: Moment = 9 * 24 * 3600 * 1000; // [ms]
}

impl pallet_encointer_democracy::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type MaxReputationCount = ConstU32<64>;
type ConfirmationPeriod = ConfirmationPeriod;
type ProposalLifetime = ProposalLifetime;
type MinTurnout = ConstU128<50>; // perthousand of electorate: 1 = 0.1%, 50 = 5.0%
type WeightInfo = weights::pallet_encointer_democracy::WeightInfo<Runtime>;
}

parameter_types! {
pub const TreasuriesPalletId: PalletId = PalletId(*b"trsrysId");
}
impl pallet_encointer_treasuries::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Currency = pallet_balances::Pallet<Runtime>;
type PalletId = TreasuriesPalletId;
}

impl pallet_aura::Config for Runtime {
type AuthorityId = AuraId;
type DisabledValidators = ();
Expand Down Expand Up @@ -724,6 +747,8 @@ construct_runtime! {
EncointerBazaar: pallet_encointer_bazaar = 64,
EncointerReputationCommitments: pallet_encointer_reputation_commitments = 65,
EncointerFaucet: pallet_encointer_faucet = 66,
EncointerDemocracy: pallet_encointer_democracy = 67,
EncointerTreasuries: pallet_encointer_treasuries = 68,
}
}

Expand Down Expand Up @@ -788,6 +813,7 @@ mod benches {
[pallet_encointer_bazaar, EncointerBazaar]
[pallet_encointer_ceremonies, EncointerCeremonies]
[pallet_encointer_communities, EncointerCommunities]
[pallet_encointer_democracy, EncointerDemocracy]
brenzi marked this conversation as resolved.
Show resolved Hide resolved
[pallet_encointer_faucet, EncointerFaucet]
[pallet_encointer_reputation_commitments, EncointerReputationCommitments]
[pallet_encointer_scheduler, EncointerScheduler]
Expand Down Expand Up @@ -1031,6 +1057,13 @@ impl_runtime_apis! {
}
}

impl pallet_encointer_treasuries_rpc_runtime_api::TreasuriesApi<Block, AccountId> for Runtime {

fn get_community_treasury_account_unchecked(maybecid: &Option<CommunityIdentifier>) -> AccountId {
EncointerTreasuries::get_community_treasury_account_unchecked(*maybecid)
}
}

impl sp_genesis_builder::GenesisBuilder<Block> for Runtime {
fn build_state(config: Vec<u8>) -> sp_genesis_builder::Result {
build_state::<RuntimeGenesisConfig>(config)
Expand Down
1 change: 1 addition & 0 deletions system-parachains/encointer/src/weights/mod.rs

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

102 changes: 102 additions & 0 deletions system-parachains/encointer/src/weights/pallet_encointer_democracy.rs

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

Loading