Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Use Polkadot Constants instead of Hardcoding #868

Merged
merged 25 commits into from
Jan 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
4723a51
added Polkadot constants
Doordashcon Dec 18, 2021
b5ca45b
remove hardcoded constants
Doordashcon Dec 18, 2021
86f05c6
cargo +nightly fmt
Doordashcon Dec 18, 2021
9e224c3
Merge branch 'paritytech:master' into ddc-PCH-T1
Doordashcon Dec 20, 2021
0809b5d
add const existential deposit
Doordashcon Dec 20, 2021
ccc5025
update
Doordashcon Dec 21, 2021
b8f51e5
cargo +nightly fmt
Doordashcon Dec 21, 2021
6aec623
Merge branch 'paritytech:master' into ddc-PCH-T1
Doordashcon Dec 21, 2021
50c31f1
Merge branch 'paritytech:master' into ddc-PCH-T1
Doordashcon Dec 21, 2021
f0aedab
Merge branch 'paritytech:master' into ddc-PCH-T1
Doordashcon Dec 22, 2021
6bde2c7
Merge branch 'paritytech:master' into ddc-PCH-T1
Doordashcon Dec 22, 2021
8d9febd
Merge branch 'paritytech:master' into ddc-PCH-T1
Doordashcon Dec 26, 2021
02d37b6
Merge branch 'paritytech:master' into ddc-PCH-T1
Doordashcon Dec 31, 2021
ea70ac7
Merge branch 'paritytech:master' into ddc-PCH-T1
Doordashcon Jan 4, 2022
27f357c
not pulling
Doordashcon Jan 6, 2022
88ece77
readd constants.rs modules
Doordashcon Jan 6, 2022
c8513f2
update
Doordashcon Jan 6, 2022
1f22d4f
Cargo.lock
Doordashcon Jan 6, 2022
0089db8
Merge branch 'paritytech:master' into ddc-PCH-T1
Doordashcon Jan 6, 2022
350ce65
update
Doordashcon Jan 6, 2022
cadd901
add balance constants
Doordashcon Jan 7, 2022
00aa8d4
Merge branch 'paritytech:master' into ddc-PCH-T1
Doordashcon Jan 11, 2022
9e0395e
Update polkadot-parachains/statemine/src/constants.rs
Doordashcon Jan 11, 2022
e0c16f4
cargo fmt
Doordashcon Jan 12, 2022
207a089
Merge branch 'paritytech:master' into ddc-PCH-T1
Doordashcon Jan 12, 2022
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 changes: 3 additions & 0 deletions Cargo.lock

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

5 changes: 3 additions & 2 deletions client/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ impl PurgeChainCmd {
relay_config: sc_service::Configuration,
) -> sc_cli::Result<()> {
let databases = match (self.parachain, self.relaychain) {
(true, true) | (false, false) =>
vec![("parachain", para_config.database), ("relaychain", relay_config.database)],
(true, true) | (false, false) => {
vec![("parachain", para_config.database), ("relaychain", relay_config.database)]
},
(true, false) => vec![("parachain", para_config.database)],
(false, true) => vec![("relaychain", relay_config.database)],
};
Expand Down
5 changes: 3 additions & 2 deletions parachain-template/node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ pub fn run() -> Result<()> {
You can enable it with `--features runtime-benchmarks`."
.into())
},
Some(Subcommand::TryRuntime(cmd)) =>
Some(Subcommand::TryRuntime(cmd)) => {
if cfg!(feature = "try-runtime") {
let runner = cli.create_runner(cmd)?;

Expand All @@ -256,7 +256,8 @@ pub fn run() -> Result<()> {
})
} else {
Err("Try-runtime must be enabled by `--features try-runtime`.".into())
},
}
},
None => {
let runner = cli.create_runner(&cli.run.normalize())?;

Expand Down
5 changes: 3 additions & 2 deletions polkadot-parachains/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ pub fn run() -> Result<()> {
You can enable it with `--features runtime-benchmarks`."
.into())
},
Some(Subcommand::TryRuntime(cmd)) =>
Some(Subcommand::TryRuntime(cmd)) => {
if cfg!(feature = "try-runtime") {
// grab the task manager.
let runner = cli.create_runner(cmd)?;
Expand Down Expand Up @@ -448,7 +448,8 @@ pub fn run() -> Result<()> {
}
} else {
Err("Try-runtime must be enabled by `--features try-runtime`.".into())
},
}
},
Some(Subcommand::Key(cmd)) => Ok(cmd.run(&cli)?),
None => {
let runner = cli.create_runner(&cli.run.normalize())?;
Expand Down
1 change: 1 addition & 0 deletions polkadot-parachains/statemine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ parachains-common = { path = "../parachains-common", default-features = false }
# Polkadot dependencies
polkadot-parachain = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
polkadot-runtime-common = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
kusama-runtime-constants = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
xcm-builder = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
xcm-executor = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
Expand Down
15 changes: 8 additions & 7 deletions polkadot-parachains/statemine/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,20 @@
// limitations under the License.

pub mod currency {
use kusama_runtime_constants as constants;
use node_primitives::Balance;

/// The existential deposit. Set to 1/10 of its parent Relay Chain (v9020).
pub const EXISTENTIAL_DEPOSIT: Balance = CENTS / 10;
/// The existential deposit. Set to 1/10 of its parent Relay Chain.
pub const EXISTENTIAL_DEPOSIT: Balance = constants::currency::EXISTENTIAL_DEPOSIT / 10;
gilescope marked this conversation as resolved.
Show resolved Hide resolved

pub const UNITS: Balance = 1_000_000_000_000;
pub const CENTS: Balance = UNITS / 30_000;
pub const GRAND: Balance = CENTS * 100_000;
pub const MILLICENTS: Balance = CENTS / 1_000;
pub const UNITS: Balance = constants::currency::UNITS;
pub const CENTS: Balance = constants::currency::CENTS;
pub const GRAND: Balance = constants::currency::GRAND;
pub const MILLICENTS: Balance = constants::currency::MILLICENTS;

pub const fn deposit(items: u32, bytes: u32) -> Balance {
// map to 1/10 of what the kusama relay chain charges (v9020)
apopiak marked this conversation as resolved.
Show resolved Hide resolved
(items as Balance * 2_000 * CENTS + (bytes as Balance) * 100 * MILLICENTS) / 10
constants::currency::deposit(items, bytes) / 10
}
}

Expand Down
1 change: 1 addition & 0 deletions polkadot-parachains/statemint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ parachains-common = { path = "../parachains-common", default-features = false }
# Polkadot dependencies
polkadot-parachain = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
polkadot-runtime-common = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
polkadot-runtime-constants = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
xcm-builder = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
xcm-executor = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
Expand Down
13 changes: 7 additions & 6 deletions polkadot-parachains/statemint/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,19 @@

pub mod currency {
use node_primitives::Balance;
use polkadot_runtime_constants as constants;

/// The existential deposit. Set to 1/10 of its parent Relay Chain (v9010).
pub const EXISTENTIAL_DEPOSIT: Balance = 10 * CENTS;
pub const EXISTENTIAL_DEPOSIT: Balance = constants::currency::EXISTENTIAL_DEPOSIT / 10;
KiChjang marked this conversation as resolved.
Show resolved Hide resolved

pub const UNITS: Balance = 10_000_000_000;
pub const DOLLARS: Balance = UNITS;
pub const CENTS: Balance = UNITS / 100; // 100_000_000
pub const MILLICENTS: Balance = CENTS / 1_000; // 100_000
pub const UNITS: Balance = constants::currency::UNITS;
pub const DOLLARS: Balance = constants::currency::DOLLARS;
pub const CENTS: Balance = constants::currency::CENTS;
pub const MILLICENTS: Balance = constants::currency::MILLICENTS;

pub const fn deposit(items: u32, bytes: u32) -> Balance {
// 1/10 of Polkadot v9010
(items as Balance * 20 * DOLLARS + (bytes as Balance) * 100 * MILLICENTS) / 10
constants::currency::deposit(items, bytes) / 10
}
}

Expand Down
1 change: 1 addition & 0 deletions polkadot-parachains/westmint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ parachains-common = { path = "../parachains-common", default-features = false }
# Polkadot dependencies
polkadot-parachain = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
polkadot-runtime-common = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
westend-runtime-constants = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
xcm-builder = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
xcm-executor = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
Expand Down
13 changes: 7 additions & 6 deletions polkadot-parachains/westmint/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,19 @@

pub mod currency {
use node_primitives::Balance;
use westend_runtime_constants as constants;

/// The existential deposit. Set to 1/10 of its parent Relay Chain.
pub const EXISTENTIAL_DEPOSIT: Balance = 100 * MILLICENTS;
pub const EXISTENTIAL_DEPOSIT: Balance = constants::currency::EXISTENTIAL_DEPOSIT / 10;
KiChjang marked this conversation as resolved.
Show resolved Hide resolved

pub const UNITS: Balance = 1_000_000_000_000;
pub const CENTS: Balance = UNITS / 100;
pub const MILLICENTS: Balance = CENTS / 1_000;
pub const GRAND: Balance = CENTS * 100_000;
pub const UNITS: Balance = constants::currency::UNITS;
pub const CENTS: Balance = constants::currency::CENTS;
pub const MILLICENTS: Balance = constants::currency::MILLICENTS;
pub const GRAND: Balance = constants::currency::GRAND;

pub const fn deposit(items: u32, bytes: u32) -> Balance {
// 1/10 of Westend testnet
(items as Balance * 100 * CENTS + (bytes as Balance) * 5 * MILLICENTS) / 10
constants::currency::deposit(items, bytes) / 10
}
}

Expand Down