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

feat: Opengov #848

Open
wants to merge 85 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 73 commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
92e3e6f
add conviciton voting pallet
enthusiastmartin Jun 6, 2024
499c166
add hooks trait
enthusiastmartin Jun 6, 2024
0743e1d
integrate voting hooks
enthusiastmartin Jun 6, 2024
f3bfd35
integrate referenda and use concrete index type
enthusiastmartin Jun 7, 2024
7b9df52
implement get referenda status for pallet-referenda
enthusiastmartin Jun 7, 2024
6a678de
Add OpenGov dependencies
vgantchev Jun 8, 2024
577d457
Isolate old governance runtime config
vgantchev Jun 13, 2024
05deaef
flag origins to be replaced
vgantchev Jun 14, 2024
c1c0dc2
tracks and origins (temp)
vgantchev Jun 22, 2024
dda5b7d
hook up OpenGov into the Runtime
vgantchev Jun 22, 2024
ddbf69b
Merge branch 'master' into opengov
vgantchev Jun 22, 2024
c79549d
merge conflicts
vgantchev Jun 22, 2024
3d2a8e8
clippy
vgantchev Jun 22, 2024
898d2ba
bump runtime version
vgantchev Jun 22, 2024
f31f064
Merge branch 'master' into feat/opengov-staking
enthusiastmartin Jun 24, 2024
2c7bd2d
Merge branch 'opengov' into feat/opengov-staking
enthusiastmartin Jun 24, 2024
641ff79
integrate staking for referenda
enthusiastmartin Jun 24, 2024
dd16960
fix staking integration tests
Roznovjak Jun 27, 2024
6ad5e16
Opengov tracks and origins
vgantchev Jun 30, 2024
dafc638
replace origins
vgantchev Jun 30, 2024
6b302dd
fmt
vgantchev Jun 30, 2024
fe74c52
fix bench
vgantchev Jun 30, 2024
e3d0681
exclude referenda from CallFilter
vgantchev Jun 30, 2024
030da66
Merge branch 'master' into opengov
vgantchev Jul 1, 2024
3dcb70d
versions
vgantchev Jul 1, 2024
27bb10c
remove irrelevant tests
vgantchev Jul 1, 2024
a5a7358
fix integration tests
vgantchev Jul 1, 2024
8043a94
fix bench
vgantchev Jul 1, 2024
e6e1e8e
fix staking reward amount in integration test
enthusiastmartin Jul 3, 2024
3297e0a
clippy fix
enthusiastmartin Jul 4, 2024
9d53fd8
staking migration; conviction-voting benchmark update
enthusiastmartin Jul 4, 2024
cd12cff
Merge branch 'opengov' into feat/opengov-staking
enthusiastmartin Jul 4, 2024
49d1aaa
fix integration tests
enthusiastmartin Jul 4, 2024
0e220db
fix integration tests
enthusiastmartin Jul 4, 2024
8711d26
clippy fix
enthusiastmartin Jul 4, 2024
7309fc2
clippy fix
enthusiastmartin Jul 4, 2024
8d0cb14
Modify certain origins
vgantchev Jul 6, 2024
8dbb268
fix tests
vgantchev Jul 7, 2024
ed70664
tests and versions
vgantchev Jul 7, 2024
28cd88a
fix moar tests
vgantchev Jul 7, 2024
b8d2d03
tests
vgantchev Jul 7, 2024
242da67
clippy
vgantchev Jul 7, 2024
304719b
Merge branch 'opengov' into feat/opengov-staking
enthusiastmartin Jul 8, 2024
ceb70c5
conviction voting clippy
enthusiastmartin Jul 8, 2024
1bab689
review comments
enthusiastmartin Jul 8, 2024
6186499
formatting
enthusiastmartin Jul 8, 2024
e69897f
clippy fix
enthusiastmartin Jul 8, 2024
7c7f591
Merge pull request #836 from galacticcouncil/feat/opengov-staking
enthusiastmartin Jul 8, 2024
b710f3e
fix hooks benchmakrs
enthusiastmartin Jul 26, 2024
721cd36
set stking max votes to 512
enthusiastmartin Jul 26, 2024
aca9dec
allow general admin track to set techcom members
vgantchev Jul 12, 2024
c8d9982
rebenchmark
vgantchev Jul 30, 2024
f4e5329
Merge branch 'master' into opengov
vgantchev Jul 30, 2024
f44b7a9
merge conflicts
vgantchev Jul 30, 2024
0ada356
fix weights and versions
vgantchev Jul 30, 2024
ce07b74
lower votes
vgantchev Jul 31, 2024
e091149
maxvotes
vgantchev Jul 31, 2024
da06fe8
fix MaxVotes
vgantchev Jul 31, 2024
d828033
update conviction voting bench
vgantchev Jul 31, 2024
6675a0b
fix metadata-hash build
Roznovjak Jul 31, 2024
b61ef61
clippy
vgantchev Aug 6, 2024
75c1899
review comments
vgantchev Aug 13, 2024
12a276e
Circuit Breaker use UpdateLimitsOrigin
vgantchev Aug 13, 2024
b2728f3
Merge branch 'master' into opengov
vgantchev Aug 13, 2024
8cc2eea
fmt
vgantchev Aug 13, 2024
7fbcd63
versions
vgantchev Aug 13, 2024
b059b95
remove assertion from staking migration
enthusiastmartin Aug 14, 2024
c093a2b
remove democracy staking integration
enthusiastmartin Aug 14, 2024
5ad0717
fix staking democracy dependencies
enthusiastmartin Aug 15, 2024
066a518
use latest conviction voting pallet version
enthusiastmartin Sep 3, 2024
5d6cbbb
Merge branch 'master' into opengov
vgantchev Sep 4, 2024
3fe0aed
fix clippy issues in conviction voting
enthusiastmartin Sep 4, 2024
e54ef8e
fix clippy issues in conviction voting tests and benchmarks
enthusiastmartin Sep 4, 2024
b935a43
Merge branch 'master' into opengov
vgantchev Sep 9, 2024
7be744d
bump crates
vgantchev Sep 9, 2024
af64853
Merge branch 'master' into opengov
vgantchev Sep 18, 2024
7fa0af3
tweak tracks
vgantchev Sep 23, 2024
de2783f
Merge branch 'master' into opengov
vgantchev Sep 23, 2024
f7caa97
Update integration-tests/Cargo.toml
vgantchev Sep 27, 2024
7c476ea
Merge branch 'master' into opengov
vgantchev Sep 27, 2024
1ce194b
versions
vgantchev Sep 27, 2024
36acba5
tweaks
vgantchev Sep 27, 2024
4446e08
fix merge conflict
vgantchev Sep 27, 2024
947a79a
Merge branch 'master' into opengov
Oct 4, 2024
0f490ec
versions and clippy
Oct 4, 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
404 changes: 221 additions & 183 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 @@ -41,6 +41,7 @@ members = [
'pallets/evm-accounts',
'pallets/dynamic-evm-fee',
'pallets/xyk-liquidity-mining',
'pallets/conviction-voting',
'precompiles/call-permit',
'runtime-mock'
]
Expand Down Expand Up @@ -100,6 +101,7 @@ warehouse-liquidity-mining = { package = "pallet-liquidity-mining", path = "pall
pallet-bonds = { path = "pallets/bonds", default-features = false}
pallet-lbp = { path = "pallets/lbp", default-features = false}
pallet-xyk = { path = "pallets/xyk", default-features = false}
pallet-conviction-voting = { path = "pallets/conviction-voting", default-features = false}
pallet-xyk-liquidity-mining = { path = "pallets/xyk-liquidity-mining", default-features = false}
pallet-referrals = { path = "pallets/referrals", default-features = false}
pallet-evm-accounts = { path = "pallets/evm-accounts", default-features = false}
Expand Down Expand Up @@ -203,6 +205,7 @@ pallet-identity = { git = "https://github.com/paritytech/polkadot-sdk", branch =
pallet-multisig = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2", default-features = false }
pallet-preimage = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2", default-features = false }
pallet-proxy = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2", default-features = false }
pallet-referenda = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2", default-features = false }
pallet-scheduler = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2", default-features = false }
pallet-session = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2", default-features = false }
pallet-sudo = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2", default-features = false }
Expand All @@ -217,6 +220,7 @@ pallet-utility = { git = "https://github.com/paritytech/polkadot-sdk", branch =
pallet-im-online = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2", default-features = false }
pallet-message-queue = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2", default-features = false }
pallet-state-trie-migration = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2", default-features = false }
pallet-whitelist = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2", default-features = false }

substrate-build-script-utils = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2", default-features = false }
substrate-frame-rpc-system = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2", default-features = false }
Expand Down
4 changes: 3 additions & 1 deletion integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "runtime-integration-tests"
version = "1.23.2"
version = "1.23.3"
description = "Integration tests"
authors = ["GalacticCouncil"]
edition = "2021"
Expand Down Expand Up @@ -48,6 +48,8 @@ pallet-elections-phragmen = { workspace = true }
pallet-tips = { workspace = true }
pallet-xyk-liquidity-mining = { workspace = true }
pallet-transaction-pause = { workspace = true }
pallet-referenda = { workspace = true }
pallet-conviction-voting= { workspace = true }
vgantchev marked this conversation as resolved.
Show resolved Hide resolved
vgantchev marked this conversation as resolved.
Show resolved Hide resolved

# collator support
pallet-collator-selection = { workspace = true }
Expand Down
86 changes: 2 additions & 84 deletions integration-tests/src/asset_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

use crate::asset_registry::Junction::GeneralIndex;
use crate::polkadot_test_net::*;
use frame_support::{assert_noop, assert_ok};
use frame_support::assert_ok;
use frame_system::RawOrigin;
use hydradx_runtime::{AssetRegistry as Registry, TechnicalCollective};
use hydradx_runtime::AssetRegistry as Registry;
use polkadot_xcm::v3::{
Junction::{self, Parachain},
Junctions::X2,
Expand Down Expand Up @@ -38,88 +38,6 @@ fn root_should_update_decimals_when_it_was_already_set() {
});
}

#[test]
fn tech_comm_should_not_update_decimals_when_it_was_aleady_set() {
TestNet::reset();
Hydra::execute_with(|| {
let tech_comm = pallet_collective::RawOrigin::<AccountId, TechnicalCollective>::Members(1, 1);
let new_decimals = 53_u8;

assert_ne!(Registry::assets(HDX).unwrap().decimals.unwrap(), new_decimals);

assert_noop!(
Registry::update(
tech_comm.into(),
HDX,
None,
None,
None,
None,
None,
None,
Some(new_decimals),
None
),
pallet_asset_registry::Error::<hydradx_runtime::Runtime>::Forbidden
);
});
}

#[test]
fn tech_comm_should_update_decimals_when_it_wasnt_set_yet() {
TestNet::reset();
Hydra::execute_with(|| {
let tech_comm = pallet_collective::RawOrigin::<AccountId, TechnicalCollective>::Members(1, 1);
let new_decimals = 12_u8;

assert!(Registry::assets(LRNA).unwrap().decimals.is_none());

assert_ok!(Registry::update(
tech_comm.into(),
LRNA,
None,
None,
None,
None,
None,
None,
Some(new_decimals),
None
));

assert_eq!(Registry::assets(LRNA).unwrap().decimals.unwrap(), new_decimals);
});
}

#[test]
fn tech_comm_should_not_update_location_when_asset_exists() {
TestNet::reset();
Hydra::execute_with(|| {
let tech_comm = pallet_collective::RawOrigin::<AccountId, TechnicalCollective>::Members(1, 1);

assert!(Registry::locations(LRNA).is_none());

assert_noop!(
Registry::update(
tech_comm.into(),
LRNA,
None,
None,
None,
None,
None,
None,
None,
Some(hydradx_runtime::AssetLocation(MultiLocation::new(
1,
X2(Parachain(MOONBEAM_PARA_ID), GeneralIndex(0))
))),
),
pallet_asset_registry::Error::<hydradx_runtime::Runtime>::Forbidden
);
});
}

#[test]
fn root_should_update_location_when_asset_exists() {
TestNet::reset();
Expand Down
35 changes: 34 additions & 1 deletion integration-tests/src/call_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ use crate::polkadot_test_net::*;
use frame_support::{
assert_ok,
sp_runtime::{FixedU128, Permill},
traits::Contains,
traits::{Contains, StorePreimage},
weights::Weight,
};
use hydradx_runtime::{origins, Preimage};
use polkadot_xcm::v3::prelude::*;
use polkadot_xcm::VersionedXcm;
use primitives::constants::currency::UNITS;
use xcm_emulator::TestExt;

#[test]
Expand Down Expand Up @@ -305,3 +307,34 @@ fn create_contract_from_evm_pallet_should_be_filtered_by_call_filter() {
assert!(!hydradx_runtime::CallFilter::contains(&call));
});
}

#[test]
fn referenda_can_not_be_filtered() {
TestNet::reset();

Hydra::execute_with(|| {
// Arrange
// Try to pause transactions for Referenda/submit
assert_ok!(hydradx_runtime::TransactionPause::pause_transaction(
hydradx_runtime::RuntimeOrigin::root(),
b"Referenda".to_vec(),
b"submit".to_vec()
));

// Prepare a Referenda/submit call
let spend_call = hydradx_runtime::RuntimeCall::Treasury(pallet_treasury::Call::spend_local {
amount: 100 * UNITS,
beneficiary: ALICE.into(),
});
let preimage = <Preimage as StorePreimage>::bound(spend_call).unwrap();

// Act & Assert
let successful_call = hydradx_runtime::RuntimeCall::Referenda(pallet_referenda::Call::submit {
proposal_origin: Box::new(hydradx_runtime::OriginCaller::Origins(origins::Origin::Tipper)),
proposal: preimage,
enactment_moment: frame_support::traits::schedule::DispatchTime::After(100),
});

assert!(hydradx_runtime::CallFilter::contains(&successful_call));
});
}
12 changes: 6 additions & 6 deletions integration-tests/src/insufficient_assets_ed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use frame_support::{assert_noop, assert_ok, traits::Contains};
use frame_system::RawOrigin;
use hydradx_runtime::RuntimeOrigin as hydra_origin;
use hydradx_runtime::{
AssetRegistry as Registry, Currencies, DustRemovalWhitelist, InsufficientEDinHDX, MultiTransactionPayment,
NativeExistentialDeposit, RuntimeEvent, TechnicalCollective, Tokens, TreasuryAccount, SUFFICIENCY_LOCK,
origins::Origin, AssetRegistry as Registry, Currencies, DustRemovalWhitelist, InsufficientEDinHDX,
MultiTransactionPayment, NativeExistentialDeposit, RuntimeEvent, Tokens, TreasuryAccount, SUFFICIENCY_LOCK,
};
use hydradx_traits::NativePriceOracle;
use orml_traits::MultiCurrency;
Expand Down Expand Up @@ -1343,7 +1343,7 @@ fn tx_should_fail_with_unsupported_currency_error_when_fee_asset_price_was_not_p
fn banned_asset_should_not_create_new_account() {
TestNet::reset();
Hydra::execute_with(|| {
let tech_comm = pallet_collective::RawOrigin::<AccountId, TechnicalCollective>::Members(1, 1);
let update_origin = hydradx_runtime::OriginCaller::Origins(Origin::GeneralAdmin);
//Arrange
let sht1: AssetId = register_external_asset(0_u128);
assert_ok!(Tokens::set_balance(
Expand All @@ -1354,7 +1354,7 @@ fn banned_asset_should_not_create_new_account() {
0,
));

assert_ok!(Registry::ban_asset(tech_comm.into(), sht1));
assert_ok!(Registry::ban_asset(update_origin.into(), sht1));

assert_eq!(Currencies::free_balance(sht1, &ALICE.into()), 0);
assert_eq!(treasury_sufficiency_lock(), 0);
Expand All @@ -1371,7 +1371,7 @@ fn banned_asset_should_not_create_new_account() {
fn banned_asset_should_not_be_transferable_to_existing_account() {
TestNet::reset();
Hydra::execute_with(|| {
let tech_comm = pallet_collective::RawOrigin::<AccountId, TechnicalCollective>::Members(1, 1);
let update_origin = hydradx_runtime::OriginCaller::Origins(Origin::GeneralAdmin);
//Arrange
let sht1: AssetId = register_external_asset(0_u128);
assert_ok!(Tokens::set_balance(
Expand All @@ -1390,7 +1390,7 @@ fn banned_asset_should_not_be_transferable_to_existing_account() {
0,
));

assert_ok!(Registry::ban_asset(tech_comm.into(), sht1));
assert_ok!(Registry::ban_asset(update_origin.into(), sht1));

//Act & assert
assert_noop!(
Expand Down
1 change: 0 additions & 1 deletion integration-tests/src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1352,7 +1352,6 @@ mod omnipool_router_tests {
let extra_ed_charge = UNITS / 10;
assert_balance!(ALICE.into(), HDX, 1000 * UNITS - ed);

let amount_to_sell = amount_to_sell;
assert_ok!(Router::sell(
hydradx_runtime::RuntimeOrigin::signed(ALICE.into()),
insufficient_asset_1,
Expand Down
Loading
Loading