Skip to content

Commit 597e4e6

Browse files
authored
Fix/refact (#115)
* refact * fix * fmt * release json * fix
1 parent 326b0f8 commit 597e4e6

15 files changed

Lines changed: 209 additions & 331 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ For now, we only running our own private parachain(collator) node use aura algor
272272
```bash
273273
./jupiter --chain ./jupiter-westend-patract.json --execution wasm --wasm-execution=compiled --force-authoring --parachain-id=2000 --tmp \
274274
--chain ./westend-patract.json --no-beefy --execution wasm --wasm-execution=compiled --tmp \
275-
--bootnodes /dns/ws.patract-westend.patract.cn/tcp/30333/p2p/12D3KooWHfn9r5cLyVQRuLin1wsB3KUiVaMWPnnpFd7Hhff6rhUX
275+
--bootnodes /dns/ws.patract-westend.patract.cn/tcp/30333/p2p/12D3KooWFBrd6SrevJ4vLi3SY7KRYQEVbRSeoENmdDouAW7wGCvZ
276276
```
277277

278278
> Notice, currently we didn't make seed node into westend-patract.json, so you have to specify our private westend bootnode.

bin/node-prep/cli/src/chain_spec/jupiter.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ pub fn poa_development_config() -> Result<ChainSpec, String> {
120120
// Properties
121121
Some(
122122
json!({
123-
"ss58Format": jupiter_runtime::SS58Prefix::get(),
123+
"ss58Format": jupiter_runtime_common::SS58Prefix::get(),
124124
"tokenDecimals": 10,
125125
"tokenSymbol": "DOT"
126126
})
@@ -179,7 +179,7 @@ pub fn poa_local_config() -> Result<ChainSpec, String> {
179179
// Properties
180180
Some(
181181
json!({
182-
"ss58Format": jupiter_runtime::SS58Prefix::get(),
182+
"ss58Format": jupiter_runtime_common::SS58Prefix::get(),
183183
"tokenDecimals": 10,
184184
"tokenSymbol": "DOT"
185185
})
@@ -358,7 +358,7 @@ pub fn poa_staging_config() -> Result<ChainSpec, String> {
358358
// Properties
359359
Some(
360360
json!({
361-
"ss58Format": jupiter_runtime::SS58Prefix::get(),
361+
"ss58Format": jupiter_runtime_common::SS58Prefix::get(),
362362
"tokenDecimals": 10,
363363
"tokenSymbol": "DOT"
364364
})

bin/node/cli/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ polkadot-parachain = { git = "https://github.com/patractlabs/polkadot", branch =
7373
# Jupiter
7474
jupiter-io = { path = "../../../primitives/io" }
7575
jupiter-primitives = { path = "../../../primitives" }
76+
jupiter-runtime-common = { path = "../../../runtime/common" }
7677
jupiter-rpc = { path = "../../../rpc" }
7778
jupiter-runtime = { path = "../../../runtime/jupiter" }
7879

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0x0000000000000000000000000000000000000000000000000000000000000000006acfbd3b0bc197d7f3c3297ec192adce0962ea1418e422014a811bd7e1e7fde303170a2e7597b7b7e3d84c05391d139a62b157e78786d8c082f29dcf4c11131400
1+
0x000000000000000000000000000000000000000000000000000000000000000000b32a2c0f7322d2d841898ea2c89cca0866df8f200dbef73ac0a57b328fbceb0103170a2e7597b7b7e3d84c05391d139a62b157e78786d8c082f29dcf4c11131400

bin/node/cli/res/jupiter-westend-2000-wasm

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

bin/node/cli/res/jupiter-westend-patract.json

Lines changed: 39 additions & 42 deletions
Large diffs are not rendered by default.

bin/node/cli/src/chain_spec/jupiter.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ pub fn development_config(id: ParaId, relay_chain: &str) -> Result<ChainSpec, St
108108
// Properties
109109
Some(
110110
json!({
111-
"ss58Format": jupiter_runtime::SS58Prefix::get(),
111+
"ss58Format": jupiter_runtime_common::SS58Prefix::get(),
112112
"tokenDecimals": 10,
113113
"tokenSymbol": "DOT"
114114
})
@@ -164,7 +164,7 @@ pub fn staging_config(id: ParaId) -> Result<ChainSpec, String> {
164164
Some("jupiter_pc1_staging"),
165165
Some(
166166
json!({
167-
"ss58Format": jupiter_runtime::SS58Prefix::get(),
167+
"ss58Format": jupiter_runtime_common::SS58Prefix::get(),
168168
"tokenDecimals": 12,
169169
"tokenSymbol": "WND"
170170
})

runtime/common/src/constants.rs

Lines changed: 19 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
//! A set of constant values used in substrate runtime.
22
3+
/// Time.
4+
pub mod time {
5+
use jupiter_primitives::{BlockNumber, Moment};
6+
7+
pub const MILLISECS_PER_BLOCK: Moment = 6000;
8+
pub const SECS_PER_BLOCK: Moment = MILLISECS_PER_BLOCK / 1000;
9+
10+
pub const SLOT_DURATION: Moment = MILLISECS_PER_BLOCK;
11+
pub const EPOCH_DURATION_IN_BLOCKS: BlockNumber = 1 * HOURS;
12+
13+
// These time units are defined in number of blocks.
14+
pub const MINUTES: BlockNumber = 60 / (SECS_PER_BLOCK as BlockNumber);
15+
pub const HOURS: BlockNumber = MINUTES * 60;
16+
pub const DAYS: BlockNumber = HOURS * 24;
17+
18+
// 1 in 4 blocks (on average, not counting collisions) will be primary babe blocks.
19+
pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4);
20+
}
21+
322
/// Money matters.
423
pub mod jupiter_currency {
524
use super::jupiter_fee::{Weight2FeeNumerator, WeightToFee};
@@ -25,58 +44,6 @@ pub mod jupiter_currency {
2544
pub type JupiterWeight2Fee = WeightToFee<JupiterNumerator>;
2645
}
2746

28-
pub mod currency {
29-
use jupiter_primitives::Balance;
30-
31-
/// The existential deposit. Set to 1/10 of its parent Relay Chain.
32-
pub const EXISTENTIAL_DEPOSIT: Balance = 100 * MILLICENTS;
33-
34-
pub const UNITS: Balance = 1_000_000_000_000;
35-
pub const CENTS: Balance = UNITS / 100;
36-
pub const MILLICENTS: Balance = CENTS / 1_000;
37-
pub const GRAND: Balance = CENTS * 100_000;
38-
39-
pub const fn deposit(items: u32, bytes: u32) -> Balance {
40-
// 1/10 of Westend testnet
41-
(items as Balance * 100 * CENTS + (bytes as Balance) * 5 * MILLICENTS) / 10
42-
}
43-
}
44-
45-
/// Time.
46-
pub mod time {
47-
use jupiter_primitives::{BlockNumber, Moment};
48-
49-
pub const MILLISECS_PER_BLOCK: Moment = 6000;
50-
pub const SECS_PER_BLOCK: Moment = MILLISECS_PER_BLOCK / 1000;
51-
52-
pub const SLOT_DURATION: Moment = MILLISECS_PER_BLOCK;
53-
pub const EPOCH_DURATION_IN_BLOCKS: BlockNumber = 1 * HOURS;
54-
55-
// These time units are defined in number of blocks.
56-
pub const MINUTES: BlockNumber = 60 / (SECS_PER_BLOCK as BlockNumber);
57-
pub const HOURS: BlockNumber = MINUTES * 60;
58-
pub const DAYS: BlockNumber = HOURS * 24;
59-
60-
// 1 in 4 blocks (on average, not counting collisions) will be primary babe blocks.
61-
pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4);
62-
}
63-
64-
/// Common constants
65-
pub mod constants {
66-
use frame_support::weights::{constants::WEIGHT_PER_SECOND, Weight};
67-
use sp_runtime::Perbill;
68-
69-
/// We assume that ~5% of the block weight is consumed by `on_initialize` handlers. This is
70-
/// used to limit the maximal weight of a single extrinsic.
71-
pub const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(5);
72-
/// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used by
73-
/// Operational extrinsics.
74-
pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
75-
76-
/// We allow for 0.5 seconds of compute with a 6 second average block time.
77-
pub const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND / 2;
78-
}
79-
8047
/// Fee-related.
8148
pub mod jupiter_fee {
8249
use frame_support::weights::{
@@ -120,30 +87,3 @@ pub mod jupiter_fee {
12087
}
12188
}
12289
}
123-
124-
pub mod fee {
125-
use frame_support::weights::{
126-
constants::ExtrinsicBaseWeight, WeightToFeeCoefficient, WeightToFeeCoefficients,
127-
WeightToFeePolynomial,
128-
};
129-
use jupiter_primitives::Balance;
130-
use smallvec::smallvec;
131-
pub use sp_runtime::Perbill;
132-
133-
pub const TARGET_BLOCK_FULLNESS: Perbill = Perbill::from_percent(25);
134-
135-
pub struct WeightToFee;
136-
impl WeightToFeePolynomial for WeightToFee {
137-
type Balance = Balance;
138-
fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {
139-
let p = super::currency::CENTS;
140-
let q = 100 * Balance::from(ExtrinsicBaseWeight::get());
141-
smallvec![WeightToFeeCoefficient {
142-
degree: 1,
143-
negative: false,
144-
coeff_frac: Perbill::from_rational(p % q, q),
145-
coeff_integer: p / q,
146-
}]
147-
}
148-
}
149-
}

runtime/common/src/impls.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,12 @@ use frame_support::{
22
parameter_types,
33
traits::{Currency, Imbalance, OnUnbalanced},
44
};
5-
// use pallet_balances::NegativeImbalance;
5+
use pallet_balances::NegativeImbalance;
66
use pallet_transaction_payment::{Multiplier, TargetedFeeAdjustment};
77
use sp_runtime::{FixedPointNumber, Perquintill};
88

99
use jupiter_primitives::AccountId;
1010

11-
pub type NegativeImbalance<T> = <pallet_balances::Pallet<T> as Currency<
12-
<T as frame_system::Config>::AccountId,
13-
>>::NegativeImbalance;
14-
1511
pub struct ToAuthor<R>(sp_std::marker::PhantomData<R>);
1612
impl<R> OnUnbalanced<NegativeImbalance<R>> for ToAuthor<R>
1713
where

0 commit comments

Comments
 (0)