Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Staking Substrate Tests #351

Merged
merged 82 commits into from
Mar 21, 2020
Merged
Show file tree
Hide file tree
Changes from 78 commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
7bb5a11
fix: avoid using substrate native name
AurevoirXavier Mar 12, 2020
d6b90c3
update: adjust RING/DOT ratio
AurevoirXavier Mar 12, 2020
ebf5893
update: better error info
AurevoirXavier Mar 12, 2020
89375fe
update: sign prefix
AurevoirXavier Mar 12, 2020
8dc960f
update: accuracy
AurevoirXavier Mar 12, 2020
e36a869
update: claims list
AurevoirXavier Mar 13, 2020
9c78515
remove: migration tests
AurevoirXavier Mar 14, 2020
1a8ce42
add: session
AurevoirXavier Mar 14, 2020
6c89ce0
fix: tests
AurevoirXavier Mar 14, 2020
f358a7b
fix: RING/DOT ratio
AurevoirXavier Mar 14, 2020
3df4aac
add: session
AurevoirXavier Mar 14, 2020
75c1df5
update: lazy payout
AurevoirXavier Mar 14, 2020
15b78bf
update: deps
AurevoirXavier Mar 14, 2020
f49f759
Merge remote-tracking branch 'upstream/develop' into lazy-payout
AurevoirXavier Mar 14, 2020
43a82e8
todo: tests
AurevoirXavier Mar 14, 2020
64dc46d
update: resolve deps, #347
AurevoirXavier Mar 14, 2020
dcb57be
update: deps
AurevoirXavier Mar 14, 2020
e534f25
fix: substrate_tests in staking pallet
clearloop Mar 14, 2020
5cfe91f
patch: docs for staking tests
clearloop Mar 14, 2020
983d354
fix: darwinia_tests in staking pallet
clearloop Mar 15, 2020
f9b1163
fix: patch docs for staking
clearloop Mar 15, 2020
d14b18d
update: mock
AurevoirXavier Mar 16, 2020
1c60710
update: tests
AurevoirXavier Mar 16, 2020
d21098d
Merge remote-tracking branch 'upstream/develop' into staking-tests
AurevoirXavier Mar 18, 2020
c19ee84
add: substrate tests
AurevoirXavier Mar 18, 2020
d8a9910
fix: `basic_setup_works`
AurevoirXavier Mar 18, 2020
ffa5482
fix: `change_controller_works`
AurevoirXavier Mar 18, 2020
9b446e1
fix: #340
AurevoirXavier Mar 18, 2020
f513c7e
fix: `rewards_should_work`
AurevoirXavier Mar 18, 2020
d71a829
fix: `staking_should_work`
AurevoirXavier Mar 18, 2020
0a85d6c
update: move error types to mock
AurevoirXavier Mar 18, 2020
1e64c11
update: format
AurevoirXavier Mar 18, 2020
76c78e4
fix: `nominating_and_rewards_should_work`
AurevoirXavier Mar 18, 2020
473e656
fix: `nominators_also_get_slashed`
AurevoirXavier Mar 18, 2020
98e5258
update: format
AurevoirXavier Mar 18, 2020
1336778
fix: `cannot_transfer_staked_balance`
AurevoirXavier Mar 18, 2020
341b6a1
fix: `cannot_transfer_staked_balance_2`
AurevoirXavier Mar 18, 2020
e1b4409
update: format
AurevoirXavier Mar 18, 2020
014397f
update: chain spec
AurevoirXavier Mar 18, 2020
271d908
fix: `reward_destination_works`
AurevoirXavier Mar 18, 2020
f973ad6
update: `<Module<Test>>` to `Staking`
AurevoirXavier Mar 18, 2020
602b77c
fix: `validator_payment_prefs_work`
AurevoirXavier Mar 19, 2020
1324e2e
fix: #362, #363
AurevoirXavier Mar 19, 2020
4b8c929
fix: `bond_extra_works`
AurevoirXavier Mar 19, 2020
b5ab699
update: mark `bond_extra_and_withdraw_unbonded_works` as deprecated
AurevoirXavier Mar 19, 2020
ff4b3c7
update: simple error type
AurevoirXavier Mar 19, 2020
fc32c48
add: east-testing feature
AurevoirXavier Mar 19, 2020
557fd2c
fix: #365
AurevoirXavier Mar 19, 2020
cb046a5
fix: `bond_with_no_staked_value`
AurevoirXavier Mar 19, 2020
cb0d701
fix: `too_many_unbond_calls_should_not_work`
AurevoirXavier Mar 19, 2020
c7fc742
fix: `reward_to_stake_works`
AurevoirXavier Mar 19, 2020
b835285
update: use `Default::default()` to avoid unused code
AurevoirXavier Mar 19, 2020
b6b9397
fix: `on_free_balance_zero_stash_removes_validator`
AurevoirXavier Mar 20, 2020
715baad
fix: `on_free_balance_zero_stash_removes_nominator`
AurevoirXavier Mar 20, 2020
def30c8
fix: `switching_roles`
AurevoirXavier Mar 20, 2020
9c4eb15
fix: `bond_with_little_staked_value_bounded_by_slot_stake`
AurevoirXavier Mar 20, 2020
40756a2
fix: `phragmen_should_not_overflow_nominators`
AurevoirXavier Mar 20, 2020
3b412da
fix: `phragmen_should_not_overflow`
AurevoirXavier Mar 20, 2020
0344e15
fix: `reward_validator_slashing_validator_doesnt_overflow`
AurevoirXavier Mar 20, 2020
003578f
add: `unbonded_balance_is_not_slashable`
AurevoirXavier Mar 20, 2020
2bb6303
update: `offence_forces_new_era`, `offence_ensures_new_era_without_cl…
AurevoirXavier Mar 20, 2020
2be54f0
fix: `offence_deselects_validator_when_slash_is_zero`
AurevoirXavier Mar 20, 2020
d84ce6b
fix: `slashing_performed_according_exposure`
AurevoirXavier Mar 20, 2020
656e1d6
fix: `slash_in_old_span_does_not_deselect`
AurevoirXavier Mar 20, 2020
af1dfaf
remove: `ensure_storage_upgraded`
AurevoirXavier Mar 20, 2020
67e0d46
fix: #373
AurevoirXavier Mar 20, 2020
689d279
fix: #374, #375
AurevoirXavier Mar 20, 2020
576c722
fix: `subsequent_reports_in_same_span_pay_out_less`
AurevoirXavier Mar 20, 2020
978d2b6
add: `invulnerables_are_not_slashed`
AurevoirXavier Mar 20, 2020
14e86a5
fix: use `free_balance`
AurevoirXavier Mar 20, 2020
8c77c92
update: use `free_balance`
AurevoirXavier Mar 20, 2020
2e3befd
fix: `remove_multi_deferred`
AurevoirXavier Mar 20, 2020
ec32264
add: `claim_reward_at_the_last_era_and_no_double_claim_and_invalid_cl…
AurevoirXavier Mar 20, 2020
8adfde3
add: `six_session_delay`
AurevoirXavier Mar 20, 2020
b0e8ff1
add: `test_max_nominator_rewarded_per_validator_and_cant_steal_someon…
AurevoirXavier Mar 20, 2020
924d242
add: `set_history_depth_works`
AurevoirXavier Mar 20, 2020
7db1f28
add: `slashing_nominators_by_span_max`
AurevoirXavier Mar 20, 2020
d143013
add: `slashes_are_summed_across_spans`
AurevoirXavier Mar 20, 2020
a5832af
fix: squash problem
AurevoirXavier Mar 21, 2020
e99bd08
update: chain spec
AurevoirXavier Mar 21, 2020
985d9a9
Merge remote-tracking branch 'upstream/develop' into staking-tests
AurevoirXavier Mar 21, 2020
272d1e2
fix: merge problem
AurevoirXavier Mar 21, 2020
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
33 changes: 1 addition & 32 deletions .maintain/types/types.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@
"MomentT": "Moment",
"Power": "u32",
"DepositId": "U256",

"StakingBalanceT": "StakingBalance",
"StakingBalance": {
"_enum": {
"All": null,
"RingBalance": "Balance",
"KtonBalance": "Balance"
}
},

"StakingLedgerT": "StakingLedger",
"StakingLedger": {
"stash": "AccountId",
Expand All @@ -27,92 +24,77 @@
"active": "Compact<Balance>",
"unlocking": "Vec<UnlockChunk>"
},

"TimeDepositItem": {
"value": "Compact<Balance>",
"start_time": "Compact<Moment>",
"expire_time": "Compact<Moment>"
},

"RewardDestination": {
"_enum": {
"Staked": "Staked",
"Stash": null,
"Controller": null
}
},

"Staked": {
"promise_month": "Moment"
},

"Exposure": {
"own_ring_balance": "Compact<Balance>",
"own_kton_balance": "Compact<Balance>",
"own_power": "Power",
"total_power": "Power",
"others": "Vec<IndividualExposure>"
},

"IndividualExposure": {
"who": "AccountId",
"ring_balance": "Compact<Balance>",
"kton_balance": "Compact<Balance>",
"power": "Power"
},

"ValidatorReward": {
"who": "AccountId",
"amount": "Compact<Balance>",
"nominators_reward": "Vec<NominatorReward>"
},

"NominatorReward": {
"who": "AccountId",
"amount": "Compact<Balance>"
},

"RKT": "RK",
"RK": {
"r": "Balance",
"k": "Balance"
},

"BalanceLock": {
"id": "LockIdentifier",
"lock_for": "LockFor",
"lock_reasons": "LockReasons"
},

"LockFor": {
"_enum": {
"Common": "Common",
"Staking": "StakingLock"
}
},

"Common": {
"amount": "Balance"
},

"StakingLock": {
"staking_amount": "Balance",
"unbondings": "Vec<Unbonding>"
},

"LockReasons":{
"LockReasons": {
"_enum": {
"Fee": null,
"Misc": null,
"All": null
}
},

"Unbonding": {
"amount": "Balance",
"moment": "BlockNumber"
},

"AccountData": {
"free_ring": "Balance",
"free_kton": "Balance",
Expand All @@ -123,18 +105,14 @@
"misc_frozen": "Balance",
"fee_frozen": "Balance"
},

"EthBlockNumber": "u64",
"EthAddress": "H160",

"EthTransactionIndex": "(H256, u64)",

"HeaderInfo": {
"total_difficulty": "U256",
"parent_hash": "H256",
"number": "EthBlockNumber"
},

"EthHeader": {
"parent_hash": "H256",
"timestamp": "u64",
Expand All @@ -152,57 +130,48 @@
"seal": "Vec<Bytes>",
"hash": "Option<H256>"
},

"Bloom": {
"_struct": "[u8; 256]"
},

"Receipt": {
"gas_used": "U256",
"log_bloom": "Bloom",
"logs": "Vec<LogEntry>",
"outcome": "TransactionOutcome"
},

"EthReceiptProof": {
"index": "u64",
"proof": "Bytes",
"header_hash": "H256"
},

"RedeemFor": {
"_enum": {
"Ring": "EthReceiptProof",
"Kton": "EthReceiptProof",
"Deposit": "EthReceiptProof"
}
},

"AddressT": "[u8; 20]",

"EthereumAddress": {
"_struct": "AddressT"
},
"TronAddress": {
"_struct": "AddressT"
},

"OtherSignature": {
"_enum": {
"Dot": "EcdsaSignature",
"Eth": "EcdsaSignature",
"Tron": "EcdsaSignature"
}
},

"OtherAddress": {
"_enum": {
"Dot": "EthereumAddress",
"Eth": "EthereumAddress",
"Tron": "EthereumAddress"
}
},

"EcdsaSignature": {
"_struct": "[u8; 65]"
}
Expand Down
1 change: 0 additions & 1 deletion .maintain/types/types.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ title = "Darwinia Node Runtime Types"

[staking.complex]
StakingBalanceT = "StakingBalance"
StakingBalance._enum.All = ""
StakingBalance._enum.RingBalance = "Balance"
StakingBalance._enum.KtonBalance = "Balance"

Expand Down
13,171 changes: 6,585 additions & 6,586 deletions bin/node/cli/res/crab.json

Large diffs are not rendered by default.

8 changes: 1 addition & 7 deletions bin/node/cli/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@
pub use node_primitives::{AccountId, Balance, Signature};
pub use node_runtime::GenesisConfig;

use std::{
env,
fs::File,
path::Path,
time::{SystemTime, UNIX_EPOCH},
};
use std::{env, fs::File, path::Path};

use grandpa_primitives::AuthorityId as GrandpaId;
use hex_literal::hex;
Expand Down Expand Up @@ -302,7 +297,6 @@ pub fn darwinia_genesis(
invulnerables: initial_authorities.iter().map(|x| x.0.clone()).collect(),
slash_reward_fraction: Perbill::from_percent(10),
// --- custom ---
genesis_time: SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_millis() as _,
payout_fraction: Perbill::from_percent(50),
..Default::default()
}),
Expand Down
51 changes: 51 additions & 0 deletions frame/authority-discovery/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
[package]
name = "pallet-authority-discovery"
version = "0.5.0"
authors = ["Darwinia Network <[email protected]>"]
description = "FRAME pallet for authority discovery"
edition = "2018"
license = "GPL-3.0"
homepage = "https://darwinia.network/"
repository = "https://github.com/darwinia-network/darwinia/"

[dependencies]
# crates.io
codec = { package = "parity-scale-codec", version = "1.2.0", default-features = false, features = ["derive"] }
serde = { version = "1.0.101", optional = true }

# github.com
frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-alpha.3" }
AurevoirXavier marked this conversation as resolved.
Show resolved Hide resolved
frame-system = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-alpha.3" }

# TODO https://github.com/darwinia-network/darwinia/issues/347
pallet-session = { default-features = false, features = ["historical" ], path = "../session" }

sp-application-crypto = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-alpha.3" }
sp-authority-discovery = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-alpha.3" }
sp-core = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-alpha.3" }
sp-io = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-alpha.3" }
sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-alpha.3" }
sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-alpha.3" }

[dev-dependencies]
# TODO https://github.com/darwinia-network/darwinia/issues/347
sp-staking = { default-features = false, path = "../../primitives/staking" }

[features]
default = ["std"]
std = [
"codec/std",
"serde",

"frame-support/std",
"frame-system/std",

"pallet-session/std",

"sp-application-crypto/std",
"sp-authority-discovery/std",
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
"sp-std/std",
]
Loading