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

Local/Shibuya v1 governance integration #1260

Merged
merged 31 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
c218080
v1 governance integration
Dinonard Jun 7, 2024
49af40b
Separate register & unregister origins for dApp staking
Dinonard Jun 12, 2024
78b43b6
Init treasury integration
Dinonard Jun 12, 2024
21a6831
Treasury
Dinonard Jun 13, 2024
94e8123
Community council
Dinonard Jun 13, 2024
0ebf987
Community treasury
Dinonard Jun 13, 2024
b76e588
Remove redundant function
Dinonard Jun 14, 2024
21e8896
Community proxy attempt
Dinonard Jun 14, 2024
379117a
Rename
Dinonard Jun 20, 2024
60687e0
Missing box dep
Dinonard Jun 20, 2024
2cea07a
Dummy weights
Dinonard Jun 20, 2024
d23e37a
Tests
Dinonard Jun 20, 2024
973e331
Fixes
Dinonard Jun 20, 2024
122d8fc
Shibuya governance
Dinonard Jun 25, 2024
f5824e2
Merge remote-tracking branch 'origin/master' into feat/governance-shi…
Dinonard Jun 26, 2024
fc4005b
Cargo
Dinonard Jun 26, 2024
a5bfa0c
Zepter
Dinonard Jun 26, 2024
5861b92
dApp staking improvements
Dinonard Jun 26, 2024
cc64799
Align local
Dinonard Jun 26, 2024
89fc2aa
Remove TODOs
Dinonard Jun 26, 2024
771d47d
Extra UT
Dinonard Jun 26, 2024
5599b30
Formating
Dinonard Jun 26, 2024
e1c70c2
Benchmarks
Dinonard Jun 26, 2024
6905fa4
clippy
Dinonard Jun 26, 2024
a5198d9
fix tests
Dinonard Jun 26, 2024
0498ddf
Integration tests setup
Dinonard Jun 27, 2024
1217806
Basic governance integration tests
Dinonard Jun 27, 2024
4d21b40
Finish integration tests
Dinonard Jun 27, 2024
57a0913
Review comment
Dinonard Jun 28, 2024
463b29d
Review comments
Dinonard Jul 2, 2024
3710a35
Benchmarks
Dinonard Jul 2, 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
3,980 changes: 1,675 additions & 2,305 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ pallet-scheduler = { git = "https://github.com/paritytech/polkadot-sdk", branch
pallet-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false }
pallet-message-queue = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false }
pallet-membership = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false }
pallet-collective = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false }
pallet-democracy = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false }
pallet-treasury = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false }

# EVM & Ethereum
# (wasm)
Expand Down Expand Up @@ -290,6 +293,7 @@ pallet-unified-accounts = { path = "./pallets/unified-accounts", default-feature
astar-xcm-benchmarks = { path = "./pallets/astar-xcm-benchmarks", default-features = false }
pallet-static-price-provider = { path = "./pallets/static-price-provider", default-features = false }
pallet-price-aggregator = { path = "./pallets/price-aggregator", default-features = false }
pallet-collective-proxy = { path = "./pallets/collective-proxy", default-features = false }

# Get rid of this once orml-oracle has been updated with benchmarks
oracle-benchmarks = { path = "./pallets/oracle-benchmarks", default-features = false }
Expand Down
43 changes: 39 additions & 4 deletions bin/collator/src/local/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@
//! Chain specifications.

use local_runtime::{
wasm_binary_unwrap, AccountId, AuraConfig, AuraId, BalancesConfig, DappStakingConfig,
EVMConfig, GrandpaConfig, GrandpaId, InflationConfig, InflationParameters, Precompiles,
RuntimeGenesisConfig, Signature, SudoConfig, SystemConfig, TierThreshold, VestingConfig, AST,
wasm_binary_unwrap, AccountId, AuraConfig, AuraId, BalancesConfig,
CommunityCouncilMembershipConfig, CommunityTreasuryPalletId, CouncilMembershipConfig,
DappStakingConfig, EVMConfig, GrandpaConfig, GrandpaId, InflationConfig, InflationParameters,
Precompiles, RuntimeGenesisConfig, Signature, SudoConfig, SystemConfig,
TechnicalCommitteeMembershipConfig, TierThreshold, TreasuryPalletId, VestingConfig, AST,
};
use sc_service::ChainType;
use sp_core::{crypto::Ss58Codec, sr25519, Pair, Public};
use sp_runtime::{
traits::{IdentifyAccount, Verify},
traits::{AccountIdConversion, IdentifyAccount, Verify},
Permill,
};

Expand Down Expand Up @@ -75,6 +77,8 @@ pub fn development_config() -> ChainSpec {
get_account_id_from_seed::<sr25519::Public>("Charlie"),
get_account_id_from_seed::<sr25519::Public>("Eve"),
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
TreasuryPalletId::get().into_account_truncating(),
CommunityTreasuryPalletId::get().into_account_truncating(),
// Arrakis.TEST account in MetaMask
// Import known test account with private key
// 0x01ab6e801c06e59ca97a14fc0a1978b27fa366fc87450e0b65459dd3515b7391
Expand All @@ -98,6 +102,11 @@ fn testnet_genesis(
root_key: AccountId,
endowed_accounts: Vec<AccountId>,
) -> RuntimeGenesisConfig {
let accounts: Vec<AccountId> = vec!["Alice", "Bob", "Charlie", "Dave", "Eve"]
.iter()
.map(|s| get_account_id_from_seed::<sr25519::Public>(s))
.collect();

// This is supposed the be the simplest bytecode to revert without returning any data.
// We will pre-deploy it under all of our precompiles to ensure they can be called from
// within contracts.
Expand Down Expand Up @@ -186,6 +195,32 @@ fn testnet_genesis(
params: InflationParameters::default(),
..Default::default()
},
council_membership: CouncilMembershipConfig {
members: accounts
.clone()
.try_into()
.expect("Should support at least 5 members."),
phantom: Default::default(),
},
technical_committee_membership: TechnicalCommitteeMembershipConfig {
members: accounts[..3]
.to_vec()
.try_into()
.expect("Should support at least 3 members."),
phantom: Default::default(),
},
community_council_membership: CommunityCouncilMembershipConfig {
members: accounts
.try_into()
.expect("Should support at least 5 members."),
phantom: Default::default(),
},
council: Default::default(),
technical_committee: Default::default(),
community_council: Default::default(),
democracy: Default::default(),
treasury: Default::default(),
community_treasury: Default::default(),
}
}

Expand Down
39 changes: 35 additions & 4 deletions bin/collator/src/parachain/chain_spec/shibuya.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ use cumulus_primitives_core::ParaId;
use sc_service::ChainType;
use shibuya_runtime::{
wasm_binary_unwrap, AccountId, AuraConfig, AuraId, Balance, BalancesConfig,
CollatorSelectionConfig, DappStakingConfig, EVMChainIdConfig, EVMConfig, InflationConfig,
InflationParameters, OracleMembershipConfig, ParachainInfoConfig, Precompiles,
PriceAggregatorConfig, RuntimeGenesisConfig, SessionConfig, SessionKeys, Signature, SudoConfig,
SystemConfig, TierThreshold, VestingConfig, SBY,
CollatorSelectionConfig, CommunityCouncilMembershipConfig, CouncilMembershipConfig,
DappStakingConfig, EVMChainIdConfig, EVMConfig, InflationConfig, InflationParameters,
OracleMembershipConfig, ParachainInfoConfig, Precompiles, PriceAggregatorConfig,
RuntimeGenesisConfig, SessionConfig, SessionKeys, Signature, SudoConfig, SystemConfig,
TechnicalCommitteeMembershipConfig, TierThreshold, VestingConfig, SBY,
};
use sp_core::{sr25519, Pair, Public};

Expand Down Expand Up @@ -99,6 +100,10 @@ fn make_genesis(
get_from_seed::<AuraId>("Bob"),
),
];
let accounts: Vec<AccountId> = vec!["Alice", "Bob", "Charlie", "Dave", "Eve"]
.iter()
.map(|s| get_account_id_from_seed::<sr25519::Public>(s))
.collect();

// This is supposed the be the simplest bytecode to revert without returning any data.
// We will pre-deploy it under all of our precompiles to ensure they can be called from
Expand Down Expand Up @@ -212,6 +217,32 @@ fn make_genesis(
.try_into()
.expect("Must work since buffer should have at least a single value."),
},
council_membership: CouncilMembershipConfig {
members: accounts
.clone()
.try_into()
.expect("Should support at least 5 members."),
phantom: Default::default(),
},
technical_committee_membership: TechnicalCommitteeMembershipConfig {
members: accounts[..3]
.to_vec()
.try_into()
.expect("Should support at least 3 members."),
phantom: Default::default(),
},
community_council_membership: CommunityCouncilMembershipConfig {
members: accounts
.try_into()
.expect("Should support at least 5 members."),
phantom: Default::default(),
},
council: Default::default(),
technical_committee: Default::default(),
community_council: Default::default(),
democracy: Default::default(),
treasury: Default::default(),
community_treasury: Default::default(),
}
}

Expand Down
62 changes: 62 additions & 0 deletions pallets/collective-proxy/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
[package]
name = "pallet-collective-proxy"
version = "0.1.0"
description = "Proxy for collective calls."
authors.workspace = true
edition.workspace = true
homepage.workspace = true
repository.workspace = true

[dependencies]
frame-support = { workspace = true }
frame-system = { workspace = true }
log = { workspace = true }
num-traits = { workspace = true }
parity-scale-codec = { workspace = true }

scale-info = { workspace = true }
serde = { workspace = true }
sp-core = { workspace = true }
sp-io = { workspace = true }
sp-runtime = { workspace = true }
sp-std = { workspace = true }

astar-primitives = { workspace = true }

frame-benchmarking = { workspace = true, optional = true }

[dev-dependencies]
pallet-balances = { workspace = true }

[features]
default = ["std"]
std = [
"serde/std",
"log/std",
"parity-scale-codec/std",
"astar-primitives/std",
"scale-info/std",
"num-traits/std",
"sp-core/std",
"sp-runtime/std",
"sp-io/std",
"sp-std/std",
"frame-support/std",
"frame-system/std",
"pallet-balances/std",
"frame-benchmarking/std",
]
runtime-benchmarks = [
"frame-benchmarking",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"astar-primitives/runtime-benchmarks",
"frame-benchmarking/runtime-benchmarks",
]
try-runtime = [
"frame-support/try-runtime",
"astar-primitives/try-runtime",
"frame-system/try-runtime",
"sp-runtime/try-runtime",
]
62 changes: 62 additions & 0 deletions pallets/collective-proxy/src/benchmarking.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// This file is part of Astar.

// Copyright (C) Stake Technologies Pte.Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later

// Astar is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Astar is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Astar. If not, see <http://www.gnu.org/licenses/>.

use super::*;

use frame_benchmarking::v2::*;

/// Assert that the last event equals the provided one.
pub(super) fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
frame_system::Pallet::<T>::assert_last_event(generic_event.into());
}

#[benchmarks()]
mod benchmarks {
use super::*;

#[benchmark]
fn execute_call() {
let origin = T::CollectiveProxy::try_successful_origin()
.expect("Must succeed in order to run benchmarks.");

// A bit dirty, but runtime should ensure to allow the `remark` call.
let call: <T as Config>::RuntimeCall =
frame_system::Call::<T>::remark { remark: vec![] }.into();

#[extrinsic_call]
_(origin as T::RuntimeOrigin, Box::new(call));

assert_last_event::<T>(Event::<T>::CollectiveProxyExecuted { result: Ok(()) }.into());
}

impl_benchmark_test_suite!(
Pallet,
crate::benchmarking::tests::new_test_ext(),
crate::mock::Test,
);
}

#[cfg(test)]
mod tests {
use crate::mock;
use sp_io::TestExternalities;

pub fn new_test_ext() -> TestExternalities {
mock::ExtBuilder::build()
}
}
Loading
Loading