Skip to content

Commit e9e1155

Browse files
authored
Staking V3 (#1611)
* Staking V3 * Part.2 * Part.3 * Part.4 * Part.5 * Part.6 * Benchmark * Benchmark * Update tx pause * Re-cache * Fixes * Bump * Staking V3 review (#1617) * Account migration adaptation Signed-off-by: Xavier Lau <x@acg.box> * Limit tasks --------- Signed-off-by: Xavier Lau <x@acg.box> * Bench * Add migration * Fixes * Correct r/w count Signed-off-by: Xavier Lau <x@acg.box> --------- Signed-off-by: Xavier Lau <x@acg.box>
1 parent 9d30501 commit e9e1155

File tree

123 files changed

+2117
-6588
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+2117
-6588
lines changed

.maintain/zombienet.toml

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,18 @@ validator = true
1717
chain = "koi-genesis"
1818
force_decorator = "generic-evm"
1919
id = 2105
20-
[parachains.collator]
20+
[[parachains.collators]]
2121
args = ["--database=paritydb", "--force-authoring", "-lparachain=debug"]
2222
command = "tmp/darwinia"
23-
name = "C1"
23+
name = "c1"
2424
rpc_port = 10000
25-
26-
[[parachains]]
27-
chain = "koi-genesis"
28-
force_decorator = "generic-evm"
29-
id = 2105
30-
[parachains.collator]
25+
[[parachains.collators]]
3126
args = ["--database=paritydb", "--force-authoring", "-lparachain=debug"]
3227
command = "tmp/darwinia"
33-
name = "C2"
28+
name = "c2"
3429
rpc_port = 10001
35-
36-
[[parachains]]
37-
chain = "koi-genesis"
38-
force_decorator = "generic-evm"
39-
id = 2105
40-
[parachains.collator]
30+
[[parachains.collators]]
4131
args = ["--database=paritydb", "--force-authoring", "-lparachain=debug"]
4232
command = "tmp/darwinia"
43-
name = "C3"
33+
name = "c3"
4434
rpc_port = 10002

Cargo.lock

Lines changed: 0 additions & 64 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ members = [
66
"core/*",
77
"node",
88
"pallet/*",
9-
"pallet/*/traits",
109
"precompile/*",
1110
"runtime/*",
1211
]
@@ -40,12 +39,9 @@ darwinia-common-runtime = { path = "runtime/common", default-features
4039
darwinia-deposit = { path = "pallet/deposit", default-features = false }
4140
darwinia-ethtx-forwarder = { path = "pallet/ethtx-forwarder", default-features = false }
4241
darwinia-precompile-assets = { path = "precompile/assets", default-features = false }
43-
darwinia-precompile-deposit = { path = "precompile/deposit", default-features = false }
44-
darwinia-precompile-staking = { path = "precompile/staking", default-features = false }
4542
darwinia-precompile-state-storage = { path = "precompile/state-storage", default-features = false }
4643
darwinia-runtime = { path = "runtime/darwinia" }
4744
darwinia-staking = { path = "pallet/staking", default-features = false }
48-
darwinia-staking-traits = { path = "pallet/staking/traits", default-features = false }
4945
dc-inflation = { path = "core/inflation", default-features = false }
5046
dc-primitives = { path = "core/primitives", default-features = false }
5147
dc-types = { path = "core/types" }

Makefile.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
[config]
22
default_to_workspace = false
3-
# skip_core_tasks = true
4-
# skip_git_env_info = true
5-
# skip_rust_env_info = true
6-
# skip_crate_env_info = true
3+
skip_core_tasks = true
4+
skip_git_env_info = true
5+
skip_rust_env_info = true
6+
skip_crate_env_info = true
77

88
[env]
99
CHAIN = "all"
@@ -19,7 +19,7 @@ args = ["fmt"]
1919
[tasks.clippy]
2020
env = { "SKIP_WASM_BUILD" = "1" }
2121
command = "cargo"
22-
args = ["clippy"]
22+
args = ["clippy", "--all-features"]
2323

2424
[tasks.c]
2525
alias = "clippy"

core/inflation/Cargo.toml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ readme = "README.md"
77
version.workspace = true
88

99
[dependencies]
10-
# crates.io
11-
primitive-types = { version = "0.12", default-features = false }
12-
1310
# darwinia
1411
dc-types = { workspace = true }
1512

@@ -22,9 +19,6 @@ sp-arithmetic = { workspace = true, features = ["std"] }
2219
[features]
2320
default = ["std"]
2421
std = [
25-
# crates.io
26-
"primitive-types/std",
27-
2822
# github
2923
"substrate-fixed/std",
3024
]

core/inflation/src/lib.rs

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
#[cfg(test)]
2525
mod test;
2626

27-
// crates.io
28-
use primitive_types::U256;
2927
// darwinia
3028
use dc_types::{Balance, Moment};
3129
// github
@@ -148,33 +146,3 @@ pub fn issuing_in_period(period: Moment, elapsed: Moment) -> Option<Balance> {
148146

149147
Some(to_issue_per_millisecs.checked_mul(U94F34::checked_from_num(period)?)?.floor().to_num())
150148
}
151-
152-
/// Calculate the reward of a deposit.
153-
///
154-
/// Reference(s):
155-
/// - <https://github.com/evolutionlandorg/bank/blob/master/contracts/GringottsBank.sol#L280>
156-
pub fn deposit_interest(amount: Balance, months: u8) -> Balance {
157-
// The result of `((quot - 1) * precision + rem * precision / d)` is `197` when months is
158-
// `12`.
159-
//
160-
// The default interest is `1_000`.
161-
// So, we directly use `1_970_000` here instead `interest * 197 * 10^7`.
162-
fn f(amount: U256, precision: U256, quot: U256, rem: U256, d: U256) -> Option<Balance> {
163-
Some(
164-
(amount.checked_mul(
165-
precision.checked_mul(quot.checked_sub(1_u8.into())?)? + precision * rem / d,
166-
)? / 1_970_000_u32)
167-
.as_u128(),
168-
)
169-
}
170-
171-
let amount = U256::from(amount);
172-
let months = U256::from(months);
173-
let n = U256::from(67_u8).pow(months);
174-
let d = U256::from(66_u8).pow(months);
175-
let quot = n / d;
176-
let rem = n % d;
177-
let precision = U256::from(1_000_u16);
178-
179-
f(amount, precision, quot, rem, d).unwrap_or_default()
180-
}

core/inflation/src/test.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -81,23 +81,3 @@ fn issuing_map_should_work() {
8181
unissued -= issued;
8282
});
8383
}
84-
85-
#[test]
86-
fn deposit_interest_should_work() {
87-
let precision = 10_000_f64;
88-
89-
for (&expect_interest, months) in [
90-
0.0761_f64, 0.1522, 0.2335, 0.3096, 0.3959, 0.4771, 0.5634, 0.6446, 0.7309, 0.8223, 0.9086,
91-
1.0000, 1.0913, 1.1878, 1.2842, 1.3807, 1.4771, 1.5736, 1.6751, 1.7766, 1.8832, 1.9898,
92-
2.0964, 2.2030, 2.3147, 2.4263, 2.5380, 2.6548, 2.7715, 2.8934, 3.0101, 3.1370, 3.2588,
93-
3.3857, 3.5126, 3.6446,
94-
]
95-
.iter()
96-
.zip(1_u8..)
97-
{
98-
let interest = deposit_interest(10_000_u128 * UNIT, months) as f64 / UNIT as f64;
99-
let interest = (interest * precision).floor() / precision;
100-
101-
assert_eq!(interest, expect_interest);
102-
}
103-
}

node/src/chain_spec/crab.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,7 @@ pub fn development_config() -> ChainSpec {
6464
"darwiniaStaking": {
6565
"now": SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_millis(),
6666
"elapsedTime": 0,
67-
"rateLimit": 20_000_000 * UNIT,
68-
"collatorCount": collators.len(),
69-
"collators": collators.iter().map(|(a, _)| (a, UNIT)).collect::<Vec<_>>()
67+
"collatorCount": collators.len()
7068
},
7169
"session": {
7270
"keys": collators.into_iter().map(|(a, sks)| (a, a, sks)).collect::<Vec<_>>()
@@ -222,9 +220,7 @@ pub fn genesis_config() -> ChainSpec {
222220
"darwiniaStaking": {
223221
"now": SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_millis(),
224222
"elapsedTime": 0,
225-
"rateLimit": 20_000_000 * UNIT,
226-
"collatorCount": 6,
227-
"collators": collators.iter().map(|(a, _)| (a, 1_000 * UNIT)).collect::<Vec<_>>()
223+
"collatorCount": 6
228224
},
229225
"session": {
230226
"keys": collators.iter().map(|(a, sks)| (a, a, sks)).collect::<Vec<_>>()

node/src/chain_spec/darwinia.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,7 @@ pub fn development_config() -> ChainSpec {
6464
"darwiniaStaking": {
6565
"now": SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_millis(),
6666
"elapsedTime": 0,
67-
"rateLimit": 20_000_000 * UNIT,
68-
"collatorCount": collators.len(),
69-
"collators": collators.iter().map(|(a, _)| (a, UNIT)).collect::<Vec<_>>()
67+
"collatorCount": collators.len()
7068
},
7169
"session": {
7270
"keys": collators.into_iter().map(|(a, sks)| (a, a, sks)).collect::<Vec<_>>()
@@ -211,9 +209,7 @@ pub fn genesis_config() -> ChainSpec {
211209
"darwiniaStaking": {
212210
"now": SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_millis(),
213211
"elapsedTime": 0,
214-
"rateLimit": 20_000_000 * UNIT,
215-
"collatorCount": 5,
216-
"collators": collators.iter().map(|(a, _)| (a, 1_000 * UNIT)).collect::<Vec<_>>()
212+
"collatorCount": 5
217213
},
218214
"session": {
219215
"keys": collators.iter().map(|(a, sks)| (a, a, sks)).collect::<Vec<_>>()

node/src/chain_spec/koi.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,7 @@ pub fn development_config() -> ChainSpec {
6161
"darwiniaStaking": {
6262
"now": SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_millis(),
6363
"elapsedTime": 0,
64-
"rateLimit": 20_000_000 * UNIT,
65-
"collatorCount": collators.len(),
66-
"collators": collators.iter().map(|(a, _)| (a, UNIT)).collect::<Vec<_>>()
64+
"collatorCount": collators.len()
6765
},
6866
"session": {
6967
"keys": collators.into_iter().map(|(a, sks)| (a, a, sks)).collect::<Vec<_>>()
@@ -166,9 +164,7 @@ pub fn genesis_config() -> ChainSpec {
166164
"darwiniaStaking": {
167165
"now": SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_millis(),
168166
"elapsedTime": 0,
169-
"rateLimit": 20_000_000 * UNIT,
170-
"collatorCount": 3,
171-
"collators": collators.iter().map(|(a, _)| (a, UNIT)).collect::<Vec<_>>()
167+
"collatorCount": 3
172168
},
173169
"session": {
174170
"keys": collators.iter().map(|(a, sks)| (a, a, sks)).collect::<Vec<_>>()

0 commit comments

Comments
 (0)