Skip to content

Commit

Permalink
Release 5.3.1 (#357)
Browse files Browse the repository at this point in the history
## Description
<!-- Describe what change this PR is implementing -->
Forwarding #351 to the Testnet

## Types of Changes
Please select the branch type you are merging and fill in the relevant
template.
<!--- Check the following box with an x if the following applies: -->
- [ ] Hotfix
- [ ] Release
- [x] Fix or Feature

## Fix or Feature
<!--- Check the following box with an x if the following applies: -->

### Types of Changes
<!--- What types of changes does your code introduce? -->
- [ ] Tech Debt (Code improvements)
- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] Dependency upgrade (A change in substrate or any 3rd party crate
version)

### Migrations and Hooks
<!--- Check the following box with an x if the following applies: -->
- [ ] This change requires a runtime migration.
- [ ] Modifies `on_initialize`
- [ ] Modifies `on_finalize`

### Checklist for Fix or Feature
<!--- All boxes need to be checked. Follow this checklist before
requiring PR review -->
- [x] Change has been tested locally.
- [ ] Change adds / updates tests if applicable.
- [x] Changelog doc updated.
- [x] `spec_version` has been incremented.
- [ ] `network-relayer`'s
[events](https://github.com/Cerebellum-Network/network-relayer/blob/dev-cere/shared/substrate/events.go)
have been updated according to the blockchain events if applicable.
- [ ] All CI checks have been passed successfully

## Checklist for Hotfix
<!--- All boxes need to be checked. Follow this checklist before
requiring PR review -->
- [ ] Changelog has been updated.
- [ ] Crate version has been updated.
- [ ] `spec_version` has been incremented.
- [ ] Transaction version has been updated if required.
- [ ] Pull Request to `dev` has been created.
- [ ] Pull Request to `staging` has been created.
- [ ] `network-relayer`'s
[events](https://github.com/Cerebellum-Network/network-relayer/blob/dev-cere/shared/substrate/events.go)
have been updated according to the blockchain events if applicable.
- [ ] All CI checks have been passed successfully

## Checklist for Release
<!--- All boxes need to be checked. Follow this checklist before
requiring PR review -->
- [ ] Change has been deployed to Devnet.
- [ ] Change has been tested in Devnet.
- [ ] Change has been deployed to Qanet.
- [ ] Change has been tested in Qanet.
- [ ] Change has been deployed to Testnet.
- [ ] Change has been tested in Testnet.
- [ ] Changelog has been updated.
- [ ] Crate version has been updated.
- [ ] Spec version has been updated.
- [ ] Transaction version has been updated if required.
- [ ] All CI checks have been passed successfully

---------

Co-authored-by: rakanalh <[email protected]>
Co-authored-by: Maksim Ramanenkau <[email protected]>
Co-authored-by: Ayush Mishra <[email protected]>
Co-authored-by: Pavel <[email protected]>
  • Loading branch information
5 people authored Jun 6, 2024
1 parent c47fbe4 commit b94a96a
Show file tree
Hide file tree
Showing 8 changed files with 133 additions and 25 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [D] Changes is `Cere Dev` Runtime


## [5.3.1]

### Changed

- [C,D] `WhitelistOrigin` is set to the Technical Committee Collective Body

## [5.3.0]

### Changed
Expand Down
32 changes: 16 additions & 16 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace.package]
version = "5.3.0"
version = "5.3.1"
authors = ["Cerebellum-Network"]
edition = "2021"
homepage = "https://cere.network/"
Expand Down
8 changes: 8 additions & 0 deletions node/service/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,14 @@ pub fn cere_dev_genesis(
ddc_clusters: Default::default(),
ddc_nodes: Default::default(),
ddc_payouts: Default::default(),
tech_comm: cere_dev::TechCommConfig {
members: endowed_accounts
.iter()
.take((endowed_accounts.len() + 1) / 2)
.cloned()
.collect(),
phantom: Default::default(),
},
}
}

Expand Down
7 changes: 5 additions & 2 deletions runtime/cere-dev/src/governance/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,11 @@ impl pallet_whitelist::Config for Runtime {
type WeightInfo = pallet_whitelist::weights::SubstrateWeight<Runtime>;
type RuntimeCall = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type WhitelistOrigin = EnsureRoot<Self::AccountId>;
type DispatchWhitelistedOrigin = EitherOf<EnsureRoot<Self::AccountId>, WhitelistedCaller>;
type WhitelistOrigin = EitherOfDiverse<
EnsureRoot<AccountId>,
pallet_collective::EnsureMembers<AccountId, TechCommCollective, 2>,
>;
type DispatchWhitelistedOrigin = EitherOf<EnsureRoot<AccountId>, WhitelistedCaller>;
type Preimages = Preimage;
}

Expand Down
24 changes: 23 additions & 1 deletion runtime/cere-dev/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
// and set impl_version to 0. If only runtime
// implementation changes and behavior does not, then leave spec_version as
// is and increment impl_version.
spec_version: 53003,
spec_version: 53100,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 17,
Expand Down Expand Up @@ -1180,6 +1180,26 @@ impl pallet_ddc_payouts::Config for Runtime {
type VoteScoreToU64 = IdentityConvert; // used for UseNominatorsAndValidatorsMap
}

parameter_types! {
pub const TechnicalMotionDuration: BlockNumber = 5 * DAYS;
pub const TechnicalMaxProposals: u32 = 100;
pub const TechnicalMaxMembers: u32 = 100;
}

type TechCommCollective = pallet_collective::Instance3;
impl pallet_collective::Config<TechCommCollective> for Runtime {
type RuntimeOrigin = RuntimeOrigin;
type Proposal = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type MotionDuration = TechnicalMotionDuration;
type MaxProposals = TechnicalMaxProposals;
type MaxMembers = TechnicalMaxMembers;
type SetMembersOrigin = EnsureRoot<AccountId>;
type DefaultVote = pallet_collective::PrimeDefaultVote;
type WeightInfo = pallet_collective::weights::SubstrateWeight<Runtime>;
type MaxProposalWeight = MaxCollectivesProposalWeight;
}

construct_runtime!(
pub struct Runtime
{
Expand Down Expand Up @@ -1231,6 +1251,7 @@ construct_runtime!(
Origins: pallet_custom_origins::{Origin},
Whitelist: pallet_whitelist::{Pallet, Call, Storage, Event<T>},
// End OpenGov.
TechComm: pallet_collective::<Instance3>,
}
);

Expand Down Expand Up @@ -1403,6 +1424,7 @@ mod benches {
[pallet_conviction_voting, ConvictionVoting]
[pallet_referenda, Referenda]
[pallet_whitelist, Whitelist]
[pallet_collective, TechComm]
);
}

Expand Down
7 changes: 5 additions & 2 deletions runtime/cere/src/governance/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,11 @@ impl pallet_whitelist::Config for Runtime {
type WeightInfo = pallet_whitelist::weights::SubstrateWeight<Runtime>;
type RuntimeCall = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type WhitelistOrigin = EnsureRoot<Self::AccountId>;
type DispatchWhitelistedOrigin = EitherOf<EnsureRoot<Self::AccountId>, WhitelistedCaller>;
type WhitelistOrigin = EitherOfDiverse<
EnsureRoot<AccountId>,
pallet_collective::EnsureMembers<AccountId, TechCommCollective, 3>,
>;
type DispatchWhitelistedOrigin = EitherOf<EnsureRoot<AccountId>, WhitelistedCaller>;
type Preimages = Preimage;
}

Expand Down
72 changes: 69 additions & 3 deletions runtime/cere/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ use frame_support::{
parameter_types,
traits::{
ConstBool, ConstU128, ConstU16, ConstU32, Currency, EitherOf, EitherOfDiverse,
EqualPrivilegeOnly, Everything, Imbalance, InstanceFilter, KeyOwnerProofSystem, Nothing,
OnUnbalanced, WithdrawReasons,
EqualPrivilegeOnly, Everything, GetStorageVersion, Imbalance, InstanceFilter,
KeyOwnerProofSystem, Nothing, OnRuntimeUpgrade, OnUnbalanced, StorageVersion,
WithdrawReasons,
},
weights::{
constants::{
Expand Down Expand Up @@ -134,7 +135,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
// and set impl_version to 0. If only runtime
// implementation changes and behavior does not, then leave spec_version as
// is and increment impl_version.
spec_version: 53003,
spec_version: 53101,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 17,
Expand Down Expand Up @@ -1182,6 +1183,26 @@ impl pallet_ddc_staking::Config for Runtime {
type NodeCreator = pallet_ddc_nodes::Pallet<Runtime>;
}

parameter_types! {
pub const TechnicalMotionDuration: BlockNumber = 5 * DAYS;
pub const TechnicalMaxProposals: u32 = 100;
pub const TechnicalMaxMembers: u32 = 100;
}

type TechCommCollective = pallet_collective::Instance3;
impl pallet_collective::Config<TechCommCollective> for Runtime {
type RuntimeOrigin = RuntimeOrigin;
type Proposal = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type MotionDuration = TechnicalMotionDuration;
type MaxProposals = TechnicalMaxProposals;
type MaxMembers = TechnicalMaxMembers;
type SetMembersOrigin = EnsureRoot<AccountId>;
type DefaultVote = pallet_collective::PrimeDefaultVote;
type WeightInfo = pallet_collective::weights::SubstrateWeight<Runtime>;
type MaxProposalWeight = MaxCollectivesProposalWeight;
}

construct_runtime!(
pub struct Runtime
{
Expand Down Expand Up @@ -1233,6 +1254,7 @@ construct_runtime!(
Origins: pallet_custom_origins::{Origin},
Whitelist: pallet_whitelist::{Pallet, Call, Storage, Event<T>},
// End OpenGov.
TechComm: pallet_collective::<Instance3>,
}
);

Expand Down Expand Up @@ -1278,6 +1300,8 @@ type Migrations = migrations::Unreleased;
pub mod migrations {
use frame_support::traits::LockIdentifier;
use frame_system::pallet_prelude::BlockNumberFor;
#[cfg(feature = "try-runtime")]
use sp_runtime::DispatchError;

use super::*;

Expand Down Expand Up @@ -1348,7 +1372,48 @@ pub mod migrations {
<Runtime as frame_system::Config>::DbWeight>,
frame_support::migrations::RemovePallet<TipsPalletName,
<Runtime as frame_system::Config>::DbWeight>,
TechCommSetV4Storage
);

pub struct TechCommSetV4Storage;
impl OnRuntimeUpgrade for TechCommSetV4Storage {
fn on_runtime_upgrade() -> frame_support::weights::Weight {
let log_target = "tech-comm-v4-migration";
let on_chain_storage_version =
<TechComm as GetStorageVersion>::on_chain_storage_version();
if on_chain_storage_version == 0 {
log::info!(
target: log_target,
"Upgrading storage version to v4",
);
StorageVersion::new(4).put::<TechComm>();
<Runtime as frame_system::Config>::DbWeight::get().reads_writes(1, 1)
} else {
log::warn!(
target: log_target,
"Attempted to apply migration to v4 but failed because storage version is {:?}",
on_chain_storage_version,
);
<Runtime as frame_system::Config>::DbWeight::get().reads(1)
}
}

#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<Vec<u8>, DispatchError> {
let on_chain_storage_version =
<TechComm as GetStorageVersion>::on_chain_storage_version();
assert_eq!(on_chain_storage_version, 0, "Tech Comm version is not v0");
Ok(Vec::new())
}

#[cfg(feature = "try-runtime")]
fn post_upgrade(_prev_state: Vec<u8>) -> Result<(), DispatchError> {
let on_chain_storage_version =
<TechComm as GetStorageVersion>::on_chain_storage_version();
assert_eq!(on_chain_storage_version, 4, "Tech Comm version is not v4");
Ok(())
}
}
}

/// Executive: handles dispatch to the various modules.
Expand Down Expand Up @@ -1405,6 +1470,7 @@ mod benches {
[pallet_conviction_voting, ConvictionVoting]
[pallet_referenda, Referenda]
[pallet_whitelist, Whitelist]
[pallet_collective, TechComm]
);
}

Expand Down

0 comments on commit b94a96a

Please sign in to comment.