Skip to content

Commit

Permalink
Chore: Move constants to runtime-common (#251)
Browse files Browse the repository at this point in the history
### Description
<!-- Describe what change this PR is implementing -->

1. Constants in both runtimes are identiical. 
2. There is no need for them to have their own separate crates.
3. We introduce `constants.rs` per runtime if some runtime-specific
constants need to be defined.

### Types of Changes
<!--- What types of changes does your code introduce? -->
- [x] Tech Debt (Code improvements)
- [ ] 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
<!--- All boxes need to be checked. Follow this checklist before
requiring PR review -->
- [ ] Change has been tested locally.
- [ ] Change adds / updates tests.
- [ ] Changelog doc updated.
  • Loading branch information
rakanalh authored Jan 26, 2024
1 parent 2c731a3 commit 5ad4210
Show file tree
Hide file tree
Showing 12 changed files with 9 additions and 134 deletions.
19 changes: 1 addition & 18 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions node/service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ sp-trie = { git = "https://github.com/paritytech/substrate", branch = "polkadot-

# Local
cere-client = { path = "../client", default-features = false, optional = true }
cere-dev-runtime-constants = { path = "../../runtime/cere-dev/constants", optional = true }
cere-rpc = { path = "../../rpc" }
cere-runtime-common = { path = "../../runtime/common", optional = true }

cere-dev-runtime = { path = "../../runtime/cere-dev", optional = true }
cere-runtime = { path = "../../runtime/cere", optional = true }

[features]
default = ["cere-native"]
cere-native = ["cere-runtime", "cere-client/cere"]
cere-dev-native = ["cere-dev-runtime", "cere-dev-runtime-constants", "cere-client/cere-dev"]
cere-dev-native = ["cere-dev-runtime", "cere-runtime-common", "cere-client/cere-dev"]

runtime-benchmarks = [
"cere-runtime/runtime-benchmarks",
Expand Down
4 changes: 2 additions & 2 deletions node/service/src/chain_spec.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#[cfg(feature = "cere-dev-native")]
use cere_dev_runtime as cere_dev;
#[cfg(feature = "cere-dev-native")]
use cere_dev_runtime_constants::currency::DOLLARS as TEST_UNITS;
#[cfg(feature = "cere-native")]
use cere_runtime as cere;
#[cfg(feature = "cere-dev-native")]
use cere_runtime_common::constants::currency::DOLLARS as TEST_UNITS;
use jsonrpsee::core::__reexports::serde_json;
pub use node_primitives::{AccountId, Balance, Block, Signature};
use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
Expand Down
2 changes: 0 additions & 2 deletions runtime/cere-dev/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ pallet-utility = { default-features = false, git = "https://github.com/paritytec
pallet-vesting = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }

# cere dependencies
cere-dev-runtime-constants = { path = "./constants", default-features = false }
cere-runtime-common = { path = "../common", default-features = false }
ddc-primitives = { path = "../../primitives", default-features = false }
pallet-ddc-clusters = { version = "4.8.8", default-features = false, path = "../../pallets/ddc-clusters" }
Expand Down Expand Up @@ -181,7 +180,6 @@ std = [
"pallet-ddc-nodes/std",
"pallet-ddc-staking/std",
"cere-runtime-common/std",
"cere-dev-runtime-constants/std",
"pallet-ddc-customers/std",
"pallet-ddc-clusters/std",
"pallet-ddc-payouts/std",
Expand Down
15 changes: 0 additions & 15 deletions runtime/cere-dev/constants/Cargo.toml

This file was deleted.

2 changes: 1 addition & 1 deletion runtime/cere-dev/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ use static_assertions::const_assert;
/// Implementations of some helper traits passed into runtime modules as associated types.
pub mod impls;
/// Constant values used within the runtime.
use cere_dev_runtime_constants::{currency::*, time::*};
use cere_runtime_common::constants::{currency::*, time::*};
use impls::Author;
use sp_runtime::generic::Era;

Expand Down
2 changes: 0 additions & 2 deletions runtime/cere/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ pallet-vesting = { default-features = false, git = "https://github.com/paritytec

# cere dependencies
cere-runtime-common = { path = "../common", default-features = false }
cere-runtime-constants = { path = "./constants", default-features = false }
ddc-primitives = { path = "../../primitives", default-features = false }
pallet-ddc-clusters = { version = "4.8.8", default-features = false, path = "../../pallets/ddc-clusters" }
pallet-ddc-customers = { version = "4.8.8", default-features = false, path = "../../pallets/ddc-customers" }
Expand Down Expand Up @@ -182,7 +181,6 @@ std = [
"pallet-ddc-payouts/std",
"pallet-ddc-staking/std",
"cere-runtime-common/std",
"cere-runtime-constants/std",
]
runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
Expand Down
14 changes: 0 additions & 14 deletions runtime/cere/constants/Cargo.toml

This file was deleted.

77 changes: 0 additions & 77 deletions runtime/cere/constants/src/lib.rs

This file was deleted.

2 changes: 1 addition & 1 deletion runtime/cere/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ use static_assertions::const_assert;
/// Implementations of some helper traits passed into runtime modules as associated types.
pub mod impls;
/// Constant values used within the runtime.
use cere_runtime_constants::{currency::*, time::*};
use cere_runtime_common::constants::{currency::*, time::*};
use impls::Author;
use sp_runtime::generic::Era;

Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions runtime/common/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#![cfg_attr(not(feature = "std"), no_std)]

pub mod constants;

use node_primitives::Balance;

/// Convert a balance to an unsigned 256-bit number, use in nomination pools.
Expand Down

0 comments on commit 5ad4210

Please sign in to comment.