diff --git a/.maintain/monitoring/alerting-rules/alerting-rules.yaml b/.maintain/monitoring/alerting-rules/alerting-rules.yaml index d6ec1f5f54..b5d58b7281 100644 --- a/.maintain/monitoring/alerting-rules/alerting-rules.yaml +++ b/.maintain/monitoring/alerting-rules/alerting-rules.yaml @@ -135,7 +135,7 @@ groups: - alert: ContinuousTaskEnded expr: '(polkadot_tasks_spawned_total{task_name != "basic-authorship-proposer"} == 1) - - on(instance, task_name) (polkadot_tasks_ended_total == 1)' + - on(instance, task_name) group_left() (polkadot_tasks_ended_total == 1)' for: 5m labels: severity: warning diff --git a/Cargo.lock b/Cargo.lock index c1fa8447df..d3db8a61fe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1365,6 +1365,7 @@ dependencies = [ "darwinia-support", "ethabi", "ethereum-primitives", + "frame-election-provider-support", "frame-support", "frame-system", "log", @@ -1375,7 +1376,6 @@ dependencies = [ "serde", "serde_json", "sp-core", - "sp-election-providers", "sp-io", "sp-runtime", "sp-staking", @@ -1693,6 +1693,7 @@ dependencies = [ "darwinia-balances", "darwinia-staking-rpc-runtime-api", "darwinia-support", + "frame-election-provider-support", "frame-support", "frame-system", "log", @@ -1700,11 +1701,11 @@ dependencies = [ "pallet-session", "pallet-timestamp", "parity-scale-codec", - "rand_chacha 0.2.2", + "paste 1.0.5", + "rand_chacha 0.3.0", "serde", "sp-arithmetic", "sp-core", - "sp-election-providers", "sp-io", "sp-npos-elections", "sp-runtime", @@ -2632,7 +2633,7 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "fork-tree" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "parity-scale-codec", ] @@ -2650,7 +2651,7 @@ dependencies = [ [[package]] name = "frame-benchmarking" version = "3.1.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "frame-support", "frame-system", @@ -2666,10 +2667,23 @@ dependencies = [ "sp-storage", ] +[[package]] +name = "frame-election-provider-support" +version = "3.0.0" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" +dependencies = [ + "frame-support", + "frame-system", + "parity-scale-codec", + "sp-arithmetic", + "sp-npos-elections", + "sp-std", +] + [[package]] name = "frame-executive" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "frame-support", "frame-system", @@ -2685,7 +2699,7 @@ dependencies = [ [[package]] name = "frame-metadata" version = "13.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "parity-scale-codec", "serde", @@ -2696,7 +2710,7 @@ dependencies = [ [[package]] name = "frame-support" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "bitflags", "frame-metadata", @@ -2722,7 +2736,7 @@ dependencies = [ [[package]] name = "frame-support-procedural" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "Inflector", "frame-support-procedural-tools", @@ -2734,10 +2748,10 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "frame-support-procedural-tools-derive", - "proc-macro-crate", + "proc-macro-crate 1.0.0", "proc-macro2", "quote", "syn", @@ -2746,7 +2760,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "proc-macro2", "quote", @@ -2756,7 +2770,7 @@ dependencies = [ [[package]] name = "frame-system" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "frame-support", "impl-trait-for-tuples", @@ -2773,7 +2787,7 @@ dependencies = [ [[package]] name = "frame-system-rpc-runtime-api" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "parity-scale-codec", "sp-api", @@ -2782,7 +2796,7 @@ dependencies = [ [[package]] name = "frame-try-runtime" version = "0.9.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "frame-support", "parity-scale-codec", @@ -3635,7 +3649,7 @@ version = "15.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99a847f9ec7bb52149b2786a17c9cb260d6effc6b8eeb8c16b343a487a7563a3" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 0.1.5", "proc-macro2", "quote", "syn", @@ -4673,7 +4687,7 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85ee3c48cb9d9b275ad967a0e96715badc13c6029adb92f34fa17b9ff28fd81f" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 0.1.5", "proc-macro-error", "proc-macro2", "quote", @@ -4952,7 +4966,7 @@ dependencies = [ [[package]] name = "pallet-authority-discovery" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "frame-support", "frame-system", @@ -4968,7 +4982,7 @@ dependencies = [ [[package]] name = "pallet-authorship" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "frame-support", "frame-system", @@ -4983,7 +4997,7 @@ dependencies = [ [[package]] name = "pallet-babe" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "frame-benchmarking", "frame-support", @@ -5002,13 +5016,12 @@ dependencies = [ "sp-session", "sp-staking", "sp-std", - "sp-timestamp", ] [[package]] name = "pallet-balances" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "frame-benchmarking", "frame-support", @@ -5023,7 +5036,7 @@ dependencies = [ [[package]] name = "pallet-collective" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "frame-support", "frame-system", @@ -5039,15 +5052,15 @@ dependencies = [ [[package]] name = "pallet-election-provider-multi-phase" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ + "frame-election-provider-support", "frame-support", "frame-system", "log", "parity-scale-codec", "serde", "sp-arithmetic", - "sp-election-providers", "sp-io", "sp-npos-elections", "sp-runtime", @@ -5058,7 +5071,7 @@ dependencies = [ [[package]] name = "pallet-grandpa" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "frame-benchmarking", "frame-support", @@ -5080,7 +5093,7 @@ dependencies = [ [[package]] name = "pallet-identity" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "enumflags2", "frame-benchmarking", @@ -5096,7 +5109,7 @@ dependencies = [ [[package]] name = "pallet-im-online" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "frame-support", "frame-system", @@ -5115,7 +5128,7 @@ dependencies = [ [[package]] name = "pallet-membership" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "frame-support", "frame-system", @@ -5129,7 +5142,7 @@ dependencies = [ [[package]] name = "pallet-multisig" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "frame-support", "frame-system", @@ -5144,7 +5157,7 @@ dependencies = [ [[package]] name = "pallet-offences" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "frame-support", "frame-system", @@ -5160,7 +5173,7 @@ dependencies = [ [[package]] name = "pallet-proxy" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "frame-support", "frame-system", @@ -5175,7 +5188,7 @@ dependencies = [ [[package]] name = "pallet-randomness-collective-flip" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "frame-support", "frame-system", @@ -5188,7 +5201,7 @@ dependencies = [ [[package]] name = "pallet-recovery" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "enumflags2", "frame-support", @@ -5203,7 +5216,7 @@ dependencies = [ [[package]] name = "pallet-scheduler" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "frame-benchmarking", "frame-support", @@ -5219,7 +5232,7 @@ dependencies = [ [[package]] name = "pallet-session" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "frame-support", "frame-system", @@ -5239,7 +5252,7 @@ dependencies = [ [[package]] name = "pallet-society" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "frame-support", "frame-system", @@ -5253,7 +5266,7 @@ dependencies = [ [[package]] name = "pallet-sudo" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "frame-support", "frame-system", @@ -5267,7 +5280,7 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "frame-benchmarking", "frame-support", @@ -5285,7 +5298,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "frame-support", "frame-system", @@ -5301,7 +5314,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "jsonrpc-core", "jsonrpc-core-client", @@ -5318,7 +5331,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc-runtime-api" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "pallet-transaction-payment", "parity-scale-codec", @@ -5329,7 +5342,7 @@ dependencies = [ [[package]] name = "pallet-utility" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "frame-support", "frame-system", @@ -5475,7 +5488,7 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa04976a81fde04924b40cc4036c4d12841e8bb04325a5cf2ada75731a150a7d" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 0.1.5", "proc-macro2", "quote", "syn", @@ -5894,6 +5907,16 @@ dependencies = [ "toml", ] +[[package]] +name = "proc-macro-crate" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41fdbd1df62156fbc5945f4762632564d7d038153091c3fcf1067f6aef7cff92" +dependencies = [ + "thiserror", + "toml", +] + [[package]] name = "proc-macro-error" version = "1.0.4" @@ -6367,7 +6390,7 @@ dependencies = [ [[package]] name = "remote-externalities" version = "0.9.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "env_logger 0.8.3", "hex-literal", @@ -6378,6 +6401,7 @@ dependencies = [ "parity-scale-codec", "sp-core", "sp-io", + "sp-runtime", ] [[package]] @@ -6586,7 +6610,7 @@ dependencies = [ [[package]] name = "sc-authority-discovery" version = "0.9.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "async-trait", "derive_more", @@ -6614,7 +6638,7 @@ dependencies = [ [[package]] name = "sc-basic-authorship" version = "0.9.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "futures 0.3.13", "futures-timer 3.0.2", @@ -6637,7 +6661,7 @@ dependencies = [ [[package]] name = "sc-block-builder" version = "0.9.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "parity-scale-codec", "sc-client-api", @@ -6653,7 +6677,7 @@ dependencies = [ [[package]] name = "sc-chain-spec" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", @@ -6674,9 +6698,9 @@ dependencies = [ [[package]] name = "sc-chain-spec-derive" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 1.0.0", "proc-macro2", "quote", "syn", @@ -6685,7 +6709,7 @@ dependencies = [ [[package]] name = "sc-cli" version = "0.9.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "chrono", "fdlimit", @@ -6723,7 +6747,7 @@ dependencies = [ [[package]] name = "sc-client-api" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "derive_more", "fnv", @@ -6757,7 +6781,7 @@ dependencies = [ [[package]] name = "sc-client-db" version = "0.9.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "blake2-rfc", "hash-db", @@ -6787,7 +6811,7 @@ dependencies = [ [[package]] name = "sc-consensus" version = "0.9.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "sc-client-api", "sp-blockchain", @@ -6798,7 +6822,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe" version = "0.9.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "derive_more", "fork-tree", @@ -6844,7 +6868,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe-rpc" version = "0.9.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "derive_more", "futures 0.3.13", @@ -6868,7 +6892,7 @@ dependencies = [ [[package]] name = "sc-consensus-epochs" version = "0.9.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "fork-tree", "parity-scale-codec", @@ -6881,7 +6905,7 @@ dependencies = [ [[package]] name = "sc-consensus-slots" version = "0.9.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "futures 0.3.13", "futures-timer 3.0.2", @@ -6900,6 +6924,7 @@ dependencies = [ "sp-inherents", "sp-runtime", "sp-state-machine", + "sp-timestamp", "sp-trie", "thiserror", ] @@ -6907,7 +6932,7 @@ dependencies = [ [[package]] name = "sc-consensus-uncles" version = "0.9.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "log", "sc-client-api", @@ -6921,7 +6946,7 @@ dependencies = [ [[package]] name = "sc-executor" version = "0.9.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "derive_more", "lazy_static", @@ -6950,7 +6975,7 @@ dependencies = [ [[package]] name = "sc-executor-common" version = "0.9.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "derive_more", "parity-scale-codec", @@ -6966,7 +6991,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmi" version = "0.9.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "log", "parity-scale-codec", @@ -6981,7 +7006,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmtime" version = "0.9.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "log", "parity-scale-codec", @@ -6999,7 +7024,7 @@ dependencies = [ [[package]] name = "sc-finality-grandpa" version = "0.9.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "derive_more", "dyn-clone", @@ -7038,7 +7063,7 @@ dependencies = [ [[package]] name = "sc-finality-grandpa-rpc" version = "0.9.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "derive_more", "finality-grandpa", @@ -7062,7 +7087,7 @@ dependencies = [ [[package]] name = "sc-finality-grandpa-warp-sync" version = "0.9.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "derive_more", "futures 0.3.13", @@ -7083,7 +7108,7 @@ dependencies = [ [[package]] name = "sc-informant" version = "0.9.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "ansi_term 0.12.1", "futures 0.3.13", @@ -7101,7 +7126,7 @@ dependencies = [ [[package]] name = "sc-keystore" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "async-trait", "derive_more", @@ -7121,7 +7146,7 @@ dependencies = [ [[package]] name = "sc-light" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "hash-db", "lazy_static", @@ -7140,7 +7165,7 @@ dependencies = [ [[package]] name = "sc-network" version = "0.9.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "async-std", "async-trait", @@ -7193,7 +7218,7 @@ dependencies = [ [[package]] name = "sc-network-gossip" version = "0.9.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "futures 0.3.13", "futures-timer 3.0.2", @@ -7203,18 +7228,20 @@ dependencies = [ "sc-network", "sp-runtime", "substrate-prometheus-endpoint", + "tracing", "wasm-timer", ] [[package]] name = "sc-offchain" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "bytes 0.5.6", "fnv", "futures 0.3.13", "futures-timer 3.0.2", + "hex", "hyper 0.13.10", "hyper-rustls", "log", @@ -7236,7 +7263,7 @@ dependencies = [ [[package]] name = "sc-peerset" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "futures 0.3.13", "libp2p", @@ -7249,7 +7276,7 @@ dependencies = [ [[package]] name = "sc-proposer-metrics" version = "0.9.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "log", "substrate-prometheus-endpoint", @@ -7258,7 +7285,7 @@ dependencies = [ [[package]] name = "sc-rpc" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "futures 0.3.13", "hash-db", @@ -7292,7 +7319,7 @@ dependencies = [ [[package]] name = "sc-rpc-api" version = "0.9.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "derive_more", "futures 0.3.13", @@ -7316,7 +7343,7 @@ dependencies = [ [[package]] name = "sc-rpc-server" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "futures 0.1.31", "jsonrpc-core", @@ -7334,7 +7361,7 @@ dependencies = [ [[package]] name = "sc-service" version = "0.9.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "directories", "exit-future", @@ -7397,7 +7424,7 @@ dependencies = [ [[package]] name = "sc-state-db" version = "0.9.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "log", "parity-scale-codec", @@ -7412,7 +7439,7 @@ dependencies = [ [[package]] name = "sc-sync-state-rpc" version = "0.9.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "jsonrpc-core", "jsonrpc-core-client", @@ -7432,7 +7459,7 @@ dependencies = [ [[package]] name = "sc-telemetry" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "chrono", "futures 0.3.13", @@ -7443,10 +7470,8 @@ dependencies = [ "rand 0.7.3", "serde", "serde_json", - "sp-utils", "take_mut", - "tracing", - "tracing-subscriber", + "thiserror", "void", "wasm-timer", ] @@ -7454,7 +7479,7 @@ dependencies = [ [[package]] name = "sc-tracing" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "ansi_term 0.12.1", "atty", @@ -7465,7 +7490,6 @@ dependencies = [ "parking_lot 0.11.1", "regex", "rustc-hash", - "sc-telemetry", "sc-tracing-proc-macro", "serde", "serde_json", @@ -7482,9 +7506,9 @@ dependencies = [ [[package]] name = "sc-tracing-proc-macro" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 1.0.0", "proc-macro2", "quote", "syn", @@ -7493,7 +7517,7 @@ dependencies = [ [[package]] name = "sc-transaction-graph" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "derive_more", "futures 0.3.13", @@ -7515,7 +7539,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "futures 0.3.13", "futures-diagnose", @@ -7921,7 +7945,7 @@ dependencies = [ [[package]] name = "sp-allocator" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "log", "sp-core", @@ -7933,7 +7957,7 @@ dependencies = [ [[package]] name = "sp-api" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "hash-db", "log", @@ -7950,10 +7974,10 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "blake2-rfc", - "proc-macro-crate", + "proc-macro-crate 1.0.0", "proc-macro2", "quote", "syn", @@ -7962,7 +7986,7 @@ dependencies = [ [[package]] name = "sp-application-crypto" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "parity-scale-codec", "serde", @@ -7974,7 +7998,7 @@ dependencies = [ [[package]] name = "sp-arithmetic" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "integer-sqrt", "num-traits", @@ -7987,7 +8011,7 @@ dependencies = [ [[package]] name = "sp-authority-discovery" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "parity-scale-codec", "sp-api", @@ -7999,7 +8023,7 @@ dependencies = [ [[package]] name = "sp-authorship" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "parity-scale-codec", "sp-inherents", @@ -8010,7 +8034,7 @@ dependencies = [ [[package]] name = "sp-block-builder" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "parity-scale-codec", "sp-api", @@ -8022,7 +8046,7 @@ dependencies = [ [[package]] name = "sp-blockchain" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "futures 0.3.13", "log", @@ -8040,7 +8064,7 @@ dependencies = [ [[package]] name = "sp-chain-spec" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "serde", "serde_json", @@ -8049,7 +8073,7 @@ dependencies = [ [[package]] name = "sp-consensus" version = "0.9.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "futures 0.3.13", "futures-timer 3.0.2", @@ -8075,10 +8099,11 @@ dependencies = [ [[package]] name = "sp-consensus-babe" version = "0.9.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "merlin", "parity-scale-codec", + "serde", "sp-api", "sp-application-crypto", "sp-consensus", @@ -8095,7 +8120,7 @@ dependencies = [ [[package]] name = "sp-consensus-slots" version = "0.9.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "parity-scale-codec", "sp-arithmetic", @@ -8105,7 +8130,7 @@ dependencies = [ [[package]] name = "sp-consensus-vrf" version = "0.9.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "parity-scale-codec", "schnorrkel", @@ -8117,7 +8142,7 @@ dependencies = [ [[package]] name = "sp-core" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "base58", "blake2-rfc", @@ -8161,7 +8186,7 @@ dependencies = [ [[package]] name = "sp-database" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "kvdb", "parking_lot 0.11.1", @@ -8170,28 +8195,17 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "proc-macro2", "quote", "syn", ] -[[package]] -name = "sp-election-providers" -version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" -dependencies = [ - "parity-scale-codec", - "sp-arithmetic", - "sp-npos-elections", - "sp-std", -] - [[package]] name = "sp-externalities" version = "0.9.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "environmental", "parity-scale-codec", @@ -8202,7 +8216,7 @@ dependencies = [ [[package]] name = "sp-finality-grandpa" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "finality-grandpa", "log", @@ -8219,7 +8233,7 @@ dependencies = [ [[package]] name = "sp-inherents" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "parity-scale-codec", "parking_lot 0.11.1", @@ -8231,7 +8245,7 @@ dependencies = [ [[package]] name = "sp-io" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "futures 0.3.13", "hash-db", @@ -8255,7 +8269,7 @@ dependencies = [ [[package]] name = "sp-keyring" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "lazy_static", "sp-core", @@ -8266,7 +8280,7 @@ dependencies = [ [[package]] name = "sp-keystore" version = "0.9.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "async-trait", "derive_more", @@ -8283,7 +8297,7 @@ dependencies = [ [[package]] name = "sp-npos-elections" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "parity-scale-codec", "serde", @@ -8296,9 +8310,9 @@ dependencies = [ [[package]] name = "sp-npos-elections-compact" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 1.0.0", "proc-macro2", "quote", "syn", @@ -8307,7 +8321,7 @@ dependencies = [ [[package]] name = "sp-offchain" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "sp-api", "sp-core", @@ -8317,7 +8331,7 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "backtrace", ] @@ -8325,7 +8339,7 @@ dependencies = [ [[package]] name = "sp-rpc" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "serde", "sp-core", @@ -8334,7 +8348,7 @@ dependencies = [ [[package]] name = "sp-runtime" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "either", "hash256-std-hasher", @@ -8355,7 +8369,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", @@ -8372,10 +8386,10 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "Inflector", - "proc-macro-crate", + "proc-macro-crate 1.0.0", "proc-macro2", "quote", "syn", @@ -8384,7 +8398,7 @@ dependencies = [ [[package]] name = "sp-serializer" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "serde", "serde_json", @@ -8393,7 +8407,7 @@ dependencies = [ [[package]] name = "sp-session" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "parity-scale-codec", "sp-api", @@ -8406,7 +8420,7 @@ dependencies = [ [[package]] name = "sp-staking" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "parity-scale-codec", "sp-runtime", @@ -8416,7 +8430,7 @@ dependencies = [ [[package]] name = "sp-state-machine" version = "0.9.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "hash-db", "log", @@ -8438,12 +8452,12 @@ dependencies = [ [[package]] name = "sp-std" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" [[package]] name = "sp-storage" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "impl-serde", "parity-scale-codec", @@ -8456,7 +8470,7 @@ dependencies = [ [[package]] name = "sp-tasks" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "log", "sp-core", @@ -8469,9 +8483,8 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ - "impl-trait-for-tuples", "parity-scale-codec", "sp-api", "sp-inherents", @@ -8483,7 +8496,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "log", "parity-scale-codec", @@ -8496,7 +8509,7 @@ dependencies = [ [[package]] name = "sp-transaction-pool" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "derive_more", "futures 0.3.13", @@ -8512,7 +8525,7 @@ dependencies = [ [[package]] name = "sp-trie" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "hash-db", "memory-db", @@ -8526,7 +8539,7 @@ dependencies = [ [[package]] name = "sp-utils" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "futures 0.3.13", "futures-core", @@ -8538,7 +8551,7 @@ dependencies = [ [[package]] name = "sp-version" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "impl-serde", "parity-scale-codec", @@ -8550,7 +8563,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", @@ -8684,7 +8697,7 @@ dependencies = [ [[package]] name = "substrate-build-script-utils" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "platforms", ] @@ -8701,7 +8714,7 @@ dependencies = [ [[package]] name = "substrate-frame-rpc-system" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "frame-system-rpc-runtime-api", "futures 0.3.13", @@ -8724,7 +8737,7 @@ dependencies = [ [[package]] name = "substrate-prometheus-endpoint" version = "0.9.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "async-std", "derive_more", @@ -8738,7 +8751,7 @@ dependencies = [ [[package]] name = "substrate-test-utils" version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "futures 0.3.13", "substrate-test-utils-derive", @@ -8748,9 +8761,9 @@ dependencies = [ [[package]] name = "substrate-test-utils-derive" version = "0.9.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 1.0.0", "quote", "syn", ] @@ -8758,7 +8771,7 @@ dependencies = [ [[package]] name = "substrate-wasm-builder" version = "4.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "ansi_term 0.12.1", "atty", @@ -9385,7 +9398,7 @@ checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" [[package]] name = "try-runtime-cli" version = "0.9.0" -source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.1#645299e8b23ec5fa52935b1a6edbf36886e80141" +source = "git+https://github.com/darwinia-network/substrate.git?tag=rococo-v1.2#1404f2af4cbe90d35b4c8a1405a9452feb789adc" dependencies = [ "frame-try-runtime", "log", diff --git a/bin/node/cli/Cargo.toml b/bin/node/cli/Cargo.toml index a12fbc1bf5..f8cb4a35ea 100644 --- a/bin/node/cli/Cargo.toml +++ b/bin/node/cli/Cargo.toml @@ -47,53 +47,53 @@ dvm-ethereum = { path = "../../../frame/dvm" } dvm-rpc-runtime-api = { path = "../../../frame/dvm/rpc/runtime-api" } pangolin-runtime = { path = "../runtime/pangolin" } # substrate -frame-system-rpc-runtime-api = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -pallet-im-online = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -pallet-transaction-payment-rpc = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sc-authority-discovery = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sc-basic-authorship = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sc-chain-spec = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sc-cli = { optional = true, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sc-client-api = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sc-consensus = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sc-consensus-babe = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sc-consensus-babe-rpc = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sc-consensus-epochs = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sc-consensus-slots = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sc-executor = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sc-finality-grandpa = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sc-finality-grandpa-rpc = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sc-finality-grandpa-warp-sync = { optional = true, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sc-keystore = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sc-network = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sc-rpc = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sc-service = { optional = true, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sc-sync-state-rpc = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sc-telemetry = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sc-transaction-pool = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-api = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-authority-discovery = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-block-builder = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-blockchain = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-consensus = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-consensus-babe = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-core = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-finality-grandpa = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-inherents = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-keystore = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-offchain = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-runtime = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-session = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-transaction-pool = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-trie = { features = ["memory-tracker"], git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -substrate-frame-rpc-system = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -substrate-prometheus-endpoint = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -try-runtime-cli = { optional = true, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +frame-system-rpc-runtime-api = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +pallet-im-online = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +pallet-transaction-payment-rpc = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sc-authority-discovery = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sc-basic-authorship = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sc-chain-spec = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sc-cli = { optional = true, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sc-client-api = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sc-consensus = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sc-consensus-babe = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sc-consensus-babe-rpc = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sc-consensus-epochs = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sc-consensus-slots = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sc-executor = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sc-finality-grandpa = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sc-finality-grandpa-rpc = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sc-finality-grandpa-warp-sync = { optional = true, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sc-keystore = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sc-network = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sc-rpc = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sc-service = { optional = true, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sc-sync-state-rpc = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sc-telemetry = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sc-transaction-pool = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-api = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-authority-discovery = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-block-builder = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-blockchain = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-consensus = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-consensus-babe = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-core = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-finality-grandpa = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-inherents = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-keystore = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-offchain = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-runtime = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-session = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-transaction-pool = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-trie = { features = ["memory-tracker"], git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +substrate-frame-rpc-system = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +substrate-prometheus-endpoint = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +try-runtime-cli = { optional = true, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [build-dependencies] # substrate -substrate-build-script-utils = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +substrate-build-script-utils = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [features] default = [ diff --git a/bin/node/cli/src/chain_spec.rs b/bin/node/cli/src/chain_spec.rs index a960e800b3..eca0c81423 100644 --- a/bin/node/cli/src/chain_spec.rs +++ b/bin/node/cli/src/chain_spec.rs @@ -244,7 +244,10 @@ fn pangolin_build_spec_genesis() -> pangolin_runtime::GenesisConfig { code: pangolin_runtime::wasm_binary_unwrap().to_vec(), changes_trie_config: Default::default(), }, - pallet_babe: Default::default(), + pallet_babe: pangolin_runtime::BabeConfig { + authorities: vec![], + epoch_config: Some(pangolin_runtime::BABE_GENESIS_EPOCH_CONFIG) + }, darwinia_balances_Instance0: pangolin_runtime::BalancesConfig { balances: vec![ (root.clone(), BUNCH_OF_COINS), @@ -413,7 +416,10 @@ fn pangolin_development_genesis() -> pangolin_runtime::GenesisConfig { code: pangolin_runtime::wasm_binary_unwrap().to_vec(), changes_trie_config: Default::default(), }, - pallet_babe: Default::default(), + pallet_babe: pangolin_runtime::BabeConfig { + authorities: vec![], + epoch_config: Some(pangolin_runtime::BABE_GENESIS_EPOCH_CONFIG) + }, darwinia_balances_Instance0: pangolin_runtime::BalancesConfig { balances: endowed_accounts .clone() diff --git a/bin/node/cli/src/command.rs b/bin/node/cli/src/command.rs index c7172c47cc..d8ee8ac77c 100644 --- a/bin/node/cli/src/command.rs +++ b/bin/node/cli/src/command.rs @@ -116,7 +116,7 @@ pub fn run() -> sc_cli::Result<()> { runner.run_node_until_exit(|config| async move { match config.role { Role::Light => { - service::drml_new_light(config).map(|(task_manager, _, _)| task_manager) + service::drml_new_light(config).map(|(task_manager, _)| task_manager) } _ => service::drml_new_full(config, authority_discovery_disabled) .map(|(task_manager, _, _)| task_manager), diff --git a/bin/node/cli/src/service.rs b/bin/node/cli/src/service.rs index ae975e5bc6..5b7f1d3efb 100644 --- a/bin/node/cli/src/service.rs +++ b/bin/node/cli/src/service.rs @@ -36,7 +36,9 @@ use sc_basic_authorship::ProposerFactory; use sc_cli::SubstrateCli; use sc_client_api::{BlockchainEvents, ExecutorProvider, RemoteBackend, StateBackendFor}; use sc_consensus::LongestChain; -use sc_consensus_babe::{BabeBlockImport, BabeLink, BabeParams, Config as BabeConfig}; +use sc_consensus_babe::{ + BabeBlockImport, BabeLink, BabeParams, Config as BabeConfig, SlotProportion, +}; use sc_executor::{native_executor_instance, NativeExecutionDispatch}; use sc_finality_grandpa::{ Config as GrandpaConfig, FinalityProofProvider as GrandpaFinalityProofProvider, GrandpaParams, @@ -50,7 +52,7 @@ use sc_service::{ BasePath, BuildNetworkParams, Configuration, Error as ServiceError, NoopRpcExtensionBuilder, PartialComponents, RpcHandlers, SpawnTasksParams, TaskManager, }; -use sc_telemetry::{TelemetryConnectionNotifier, TelemetrySpan}; +use sc_telemetry::{Telemetry, TelemetryWorker}; use sc_transaction_pool::{BasicPool, FullPool}; use sp_api::ConstructRuntimeApi; use sp_consensus::{ @@ -222,6 +224,7 @@ fn new_partial( BabeLink, ), GrandpaSharedVoterState, + Option, PendingTransactions, Arc>, Option, @@ -245,8 +248,25 @@ where set_prometheus_registry(config)?; let inherent_data_providers = InherentDataProviders::new(); + let telemetry = config + .telemetry_endpoints + .clone() + .filter(|x| !x.is_empty()) + .map(|endpoints| -> Result<_, sc_telemetry::Error> { + let worker = TelemetryWorker::new(16)?; + let telemetry = worker.handle().new_telemetry(endpoints); + Ok((worker, telemetry)) + }) + .transpose()?; let (client, backend, keystore_container, task_manager) = - sc_service::new_full_parts::(&config)?; + sc_service::new_full_parts::( + &config, + telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()), + )?; + let telemetry = telemetry.map(|(worker, telemetry)| { + task_manager.spawn_handle().spawn("telemetry", worker.run()); + telemetry + }); let client = Arc::new(client); let select_chain = LongestChain::new(backend.clone()); let transaction_pool = BasicPool::new_full( @@ -264,6 +284,7 @@ where &(client.clone() as Arc<_>), select_chain.clone(), grandpa_hard_forks, + telemetry.as_ref().map(|x| x.handle()), )?; let justification_import = grandpa_block_import.clone(); let frontier_block_import = FrontierBlockImport::new( @@ -286,6 +307,7 @@ where &task_manager.spawn_essential_handle(), config.prometheus_registry(), CanAuthorWithNativeVersion::new(client.executor().clone()), + telemetry.as_ref().map(|x| x.handle()), )?; let justification_stream = grandpa_link.justification_stream(); let shared_authority_set = grandpa_link.shared_authority_set().clone(); @@ -354,6 +376,7 @@ where rpc_extensions_builder, import_setup, rpc_setup, + telemetry, pending_transactions, frontier_backend, filter_pool, @@ -408,6 +431,7 @@ where rpc_extensions_builder, import_setup, rpc_setup, + mut telemetry, pending_transactions, frontier_backend, filter_pool, @@ -458,46 +482,42 @@ where if config.offchain_worker.enabled { sc_service::build_offchain_workers( &config, - backend.clone(), task_manager.spawn_handle(), client.clone(), network.clone(), ); } - let telemetry_span = TelemetrySpan::new(); - let _telemetry_span_entered = telemetry_span.enter(); - let (rpc_handlers, telemetry_connection_notifier) = - sc_service::spawn_tasks(SpawnTasksParams { - config, - backend: backend.clone(), - client: client.clone(), - keystore: keystore_container.sync_keystore(), - network: network.clone(), - rpc_extensions_builder: { - let wrap_rpc_extensions_builder = { - let network = network.clone(); - - move |deny_unsafe, subscription_executor| -> RpcExtension { - rpc_extensions_builder( - deny_unsafe, - is_authority, - network.clone(), - subscription_executor, - ) - } - }; + let rpc_handlers = sc_service::spawn_tasks(SpawnTasksParams { + config, + backend: backend.clone(), + client: client.clone(), + keystore: keystore_container.sync_keystore(), + network: network.clone(), + rpc_extensions_builder: { + let wrap_rpc_extensions_builder = { + let network = network.clone(); + + move |deny_unsafe, subscription_executor| -> RpcExtension { + rpc_extensions_builder( + deny_unsafe, + is_authority, + network.clone(), + subscription_executor, + ) + } + }; - Box::new(wrap_rpc_extensions_builder) - }, - transaction_pool: transaction_pool.clone(), - task_manager: &mut task_manager, - on_demand: None, - remote_blockchain: None, - network_status_sinks, - system_rpc_tx, - telemetry_span: Some(telemetry_span.clone()), - })?; + Box::new(wrap_rpc_extensions_builder) + }, + transaction_pool: transaction_pool.clone(), + task_manager: &mut task_manager, + on_demand: None, + remote_blockchain: None, + network_status_sinks, + system_rpc_tx, + telemetry: telemetry.as_mut(), + })?; let (block_import, link_half, babe_link) = import_setup; @@ -508,6 +528,7 @@ where client.clone(), transaction_pool, prometheus_registry.as_ref(), + telemetry.as_ref().map(|x| x.handle()), ); let babe_config = BabeParams { keystore: keystore_container.sync_keystore(), @@ -521,6 +542,8 @@ where backoff_authoring_blocks, babe_link, can_author_with, + block_proposal_slot_portion: SlotProportion::new(0.5), + telemetry: telemetry.as_ref().map(|x| x.handle()), }; let babe = sc_consensus_babe::start_babe(babe_config)?; @@ -542,6 +565,7 @@ where observer_enabled: false, keystore, is_authority: role.is_authority(), + telemetry: telemetry.as_ref().map(|x| x.handle()), }; let enable_grandpa = !disable_grandpa; @@ -550,7 +574,7 @@ where config: grandpa_config, link: link_half, network: network.clone(), - telemetry_on_connect: telemetry_connection_notifier.map(|x| x.on_connect_stream()), + telemetry: telemetry.as_ref().map(|x| x.handle()), voting_rule: GrandpaVotingRulesBuilder::default().build(), prometheus_registry: prometheus_registry.clone(), shared_voter_state, @@ -632,14 +656,7 @@ where fn new_light( mut config: Configuration, -) -> Result< - ( - TaskManager, - RpcHandlers, - Option, - ), - ServiceError, -> +) -> Result<(TaskManager, RpcHandlers), ServiceError> where Executor: 'static + NativeExecutionDispatch, RuntimeApi: @@ -649,8 +666,32 @@ where { set_prometheus_registry(&mut config)?; + let telemetry = config + .telemetry_endpoints + .clone() + .filter(|x| !x.is_empty()) + .map(|endpoints| -> Result<_, sc_telemetry::Error> { + #[cfg(feature = "browser")] + let transport = Some(sc_telemetry::ExtTransport::new( + libp2p_wasm_ext::ffi::websocket_transport(), + )); + #[cfg(not(feature = "browser"))] + let transport = None; + + let worker = TelemetryWorker::with_transport(16, transport)?; + let telemetry = worker.handle().new_telemetry(endpoints); + Ok((worker, telemetry)) + }) + .transpose()?; let (client, backend, keystore_container, mut task_manager, on_demand) = - sc_service::new_light_parts::(&config)?; + sc_service::new_light_parts::( + &config, + telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()), + )?; + let mut telemetry = telemetry.map(|(worker, telemetry)| { + task_manager.spawn_handle().spawn("telemetry", worker.run()); + telemetry + }); config .network @@ -669,6 +710,7 @@ where client.clone(), &(client.clone() as Arc<_>), select_chain.clone(), + telemetry.as_ref().map(|x| x.handle()), )?; let justification_import = grandpa_block_import.clone(); let (babe_block_import, babe_link) = sc_consensus_babe::block_import( @@ -688,6 +730,7 @@ where &task_manager.spawn_essential_handle(), config.prometheus_registry(), NeverCanAuthor, + telemetry.as_ref().map(|x| x.handle()), )?; let (network, network_status_sinks, system_rpc_tx, network_starter) = sc_service::build_network(BuildNetworkParams { @@ -703,7 +746,6 @@ where if config.offchain_worker.enabled { sc_service::build_offchain_workers( &config, - backend.clone(), task_manager.spawn_handle(), client.clone(), network.clone(), @@ -717,28 +759,25 @@ where pool: transaction_pool.clone(), }; let rpc_extension = rpc::create_light(light_deps); - let telemetry_span = TelemetrySpan::new(); - let _telemetry_span_entered = telemetry_span.enter(); - let (rpc_handlers, telemetry_connection_notifier) = - sc_service::spawn_tasks(SpawnTasksParams { - on_demand: Some(on_demand), - remote_blockchain: Some(backend.remote_blockchain()), - rpc_extensions_builder: Box::new(NoopRpcExtensionBuilder(rpc_extension)), - task_manager: &mut task_manager, - config, - keystore: keystore_container.sync_keystore(), - backend, - transaction_pool, - client, - network, - network_status_sinks, - system_rpc_tx, - telemetry_span: Some(telemetry_span.clone()), - })?; + let rpc_handlers = sc_service::spawn_tasks(SpawnTasksParams { + on_demand: Some(on_demand), + remote_blockchain: Some(backend.remote_blockchain()), + rpc_extensions_builder: Box::new(NoopRpcExtensionBuilder(rpc_extension)), + task_manager: &mut task_manager, + config, + keystore: keystore_container.sync_keystore(), + backend, + transaction_pool, + client, + network, + network_status_sinks, + system_rpc_tx, + telemetry: telemetry.as_mut(), + })?; network_starter.start_network(); - Ok((task_manager, rpc_handlers, telemetry_connection_notifier)) + Ok((task_manager, rpc_handlers)) } /// Builds a new object suitable for chain operations. @@ -794,15 +833,6 @@ pub fn drml_new_full( } /// Create a new DRML service for a light client. -pub fn drml_new_light( - config: Configuration, -) -> Result< - ( - TaskManager, - RpcHandlers, - Option, - ), - ServiceError, -> { +pub fn drml_new_light(config: Configuration) -> Result<(TaskManager, RpcHandlers), ServiceError> { new_light::(config) } diff --git a/bin/node/primitives/Cargo.toml b/bin/node/primitives/Cargo.toml index 3b690a3271..f0d3ceeeec 100644 --- a/bin/node/primitives/Cargo.toml +++ b/bin/node/primitives/Cargo.toml @@ -11,8 +11,8 @@ version = "2.1.0" [dependencies] # substrate -sp-core = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +sp-core = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [features] default = ["std"] diff --git a/bin/node/runtime/pangolin/Cargo.toml b/bin/node/runtime/pangolin/Cargo.toml index e6710939db..9587d3ec9c 100644 --- a/bin/node/runtime/pangolin/Cargo.toml +++ b/bin/node/runtime/pangolin/Cargo.toml @@ -44,52 +44,52 @@ dvm-ethereum = { default-features = false, path = "../../ dvm-rpc-runtime-api = { default-features = false, path = "../../../../frame/dvm/rpc/runtime-api" } ethereum-primitives = { default-features = false, path = "../../../../primitives/ethereum-primitives" } # substrate -frame-executive = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -frame-system = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -frame-system-rpc-runtime-api = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -frame-try-runtime = { optional = true, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -pallet-authority-discovery = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -pallet-authorship = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -pallet-babe = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -pallet-collective = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -pallet-election-provider-multi-phase = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -pallet-grandpa = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -pallet-identity = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -pallet-im-online = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -pallet-membership = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -pallet-multisig = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -pallet-offences = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -pallet-proxy = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -pallet-randomness-collective-flip = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -pallet-recovery = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -pallet-scheduler = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -pallet-session = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -pallet-society = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -pallet-sudo = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -pallet-timestamp = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -pallet-transaction-payment = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -pallet-transaction-payment-rpc-runtime-api = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -pallet-utility = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-api = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-application-crypto = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-authority-discovery = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-block-builder = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-consensus-babe = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-core = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-inherents = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-io = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-offchain = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-session = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-staking = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-transaction-pool = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-version = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +frame-executive = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +frame-system = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +frame-system-rpc-runtime-api = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +frame-try-runtime = { optional = true, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +pallet-authority-discovery = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +pallet-authorship = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +pallet-babe = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +pallet-collective = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +pallet-election-provider-multi-phase = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +pallet-grandpa = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +pallet-identity = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +pallet-im-online = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +pallet-membership = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +pallet-multisig = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +pallet-offences = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +pallet-proxy = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +pallet-randomness-collective-flip = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +pallet-recovery = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +pallet-scheduler = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +pallet-session = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +pallet-society = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +pallet-sudo = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +pallet-timestamp = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +pallet-transaction-payment = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +pallet-transaction-payment-rpc-runtime-api = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +pallet-utility = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-api = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-application-crypto = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-authority-discovery = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-block-builder = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-consensus-babe = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-core = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-inherents = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-io = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-offchain = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-session = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-staking = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-transaction-pool = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-version = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [build-dependencies] # substrate -substrate-wasm-builder = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +substrate-wasm-builder = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [features] default = ["std"] diff --git a/bin/node/runtime/pangolin/polkadot-compatible-types.json b/bin/node/runtime/pangolin/polkadot-compatible-types.json index 5bc8f68b2e..a57032e421 100644 --- a/bin/node/runtime/pangolin/polkadot-compatible-types.json +++ b/bin/node/runtime/pangolin/polkadot-compatible-types.json @@ -84,11 +84,6 @@ "power": "Power", "value": "Compact" }, - "ElectionResultT": { - "elected_stashes": "Vec", - "exposures": "Vec<(AccountId, ExposureT)>", - "compute": "ElectionCompute" - }, "RKT": { "r": "Balance", "k": "Balance" diff --git a/bin/node/runtime/pangolin/src/balances.rs b/bin/node/runtime/pangolin/src/balances.rs index e68d0f293b..f1a64d37d3 100644 --- a/bin/node/runtime/pangolin/src/balances.rs +++ b/bin/node/runtime/pangolin/src/balances.rs @@ -6,9 +6,9 @@ use frame_support::traits::Currency; use frame_system::Config as SystemConfig; // --- darwinia --- use crate::*; -use darwinia_balances::{weights::SubstrateWeight, Config, Module}; +use darwinia_balances::{weights::SubstrateWeight, Config, Pallet}; -pub type NegativeImbalance = as Currency< +pub type NegativeImbalance = as Currency< ::AccountId, >>::NegativeImbalance; diff --git a/bin/node/runtime/pangolin/src/election_provider_multi_phase.rs b/bin/node/runtime/pangolin/src/election_provider_multi_phase.rs index 4111819696..a0b6d260e8 100644 --- a/bin/node/runtime/pangolin/src/election_provider_multi_phase.rs +++ b/bin/node/runtime/pangolin/src/election_provider_multi_phase.rs @@ -13,11 +13,12 @@ frame_support::parameter_types! { // fallback: no need to do on-chain phragmen initially. pub const Fallback: pallet_election_provider_multi_phase::FallbackStrategy = - pallet_election_provider_multi_phase::FallbackStrategy::Nothing; + pallet_election_provider_multi_phase::FallbackStrategy::OnChain; - pub SolutionImprovementThreshold: Perbill = Perbill::from_rational_approximation(1u32, 10_000); + pub SolutionImprovementThreshold: Perbill = Perbill::from_rational(1u32, 10_000); // miner configs + pub const StakingUnsignedPriority: TransactionPriority = TransactionPriority::max_value() / 2; pub const MultiPhaseUnsignedPriority: TransactionPriority = StakingUnsignedPriority::get() - 1u64; pub const MinerMaxIterations: u32 = 10; pub MinerMaxWeight: Weight = RuntimeBlockWeights::get() @@ -31,7 +32,7 @@ impl Config for Runtime { type Currency = Balances; type SignedPhase = SignedPhase; type UnsignedPhase = UnsignedPhase; - type SolutionImprovementThreshold = MinSolutionScoreBump; + type SolutionImprovementThreshold = SolutionImprovementThreshold; type MinerMaxIterations = MinerMaxIterations; type MinerMaxWeight = MinerMaxWeight; type MinerTxPriority = MultiPhaseUnsignedPriority; diff --git a/bin/node/runtime/pangolin/src/im_online.rs b/bin/node/runtime/pangolin/src/im_online.rs index 72202983de..5b9801340d 100644 --- a/bin/node/runtime/pangolin/src/im_online.rs +++ b/bin/node/runtime/pangolin/src/im_online.rs @@ -5,14 +5,13 @@ use sp_runtime::transaction_validity::TransactionPriority; use crate::*; frame_support::parameter_types! { - pub const SessionDuration: BlockNumber = BLOCKS_PER_SESSION as _; pub const ImOnlineUnsignedPriority: TransactionPriority = TransactionPriority::max_value(); } impl Config for Runtime { type AuthorityId = AuthorityId; type Event = Event; + type NextSessionRotation = Babe; type ValidatorSet = Historical; - type SessionDuration = SessionDuration; type ReportUnresponsiveness = Offences; type UnsignedPriority = ImOnlineUnsignedPriority; type WeightInfo = SubstrateWeight; diff --git a/bin/node/runtime/pangolin/src/lib.rs b/bin/node/runtime/pangolin/src/lib.rs index af4db8201a..f9cfdff850 100644 --- a/bin/node/runtime/pangolin/src/lib.rs +++ b/bin/node/runtime/pangolin/src/lib.rs @@ -172,7 +172,7 @@ pub mod impls { smallvec![WeightToFeeCoefficient { degree: 1, negative: false, - coeff_frac: Perbill::from_rational_approximation(p % q, q), + coeff_frac: Perbill::from_rational(p % q, q), coeff_integer: p / q, }] } @@ -340,6 +340,7 @@ use pallet_transaction_payment::FeeDetails; use pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo as TransactionPaymentRuntimeDispatchInfo; use sp_api::impl_runtime_apis; use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; +use sp_consensus_babe::{AllowedSlots, BabeEpochConfiguration}; use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H160, H256, U256}; use sp_runtime::{ create_runtime_str, generic, @@ -383,7 +384,7 @@ type Executive = frame_executive::Executive< Block, frame_system::ChainContext, Runtime, - AllModules, + AllPallets, // (), // CustomOnRuntimeUpgrade, >; @@ -404,6 +405,12 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { transaction_version: 1, }; +/// The BABE epoch configuration at genesis. +pub const BABE_GENESIS_EPOCH_CONFIG: BabeEpochConfiguration = BabeEpochConfiguration { + c: PRIMARY_PROBABILITY, + allowed_slots: AllowedSlots::PrimaryAndSecondaryPlainSlots, +}; + /// The version information used to identify this runtime when compiled natively. #[cfg(feature = "std")] pub fn native_version() -> NativeVersion { @@ -421,78 +428,78 @@ frame_support::construct_runtime! { UncheckedExtrinsic = UncheckedExtrinsic { // Basic stuff; balances is uncallable initially. - System: frame_system::{Module, Call, Storage, Config, Event} = 0, - RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage} = 1, + System: frame_system::{Pallet, Call, Storage, Config, Event} = 0, + RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Call, Storage} = 1, // Must be before session. - Babe: pallet_babe::{Module, Call, Storage, Config, ValidateUnsigned} = 2, + Babe: pallet_babe::{Pallet, Call, Storage, Config, ValidateUnsigned} = 2, - Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent} = 3, - Balances: darwinia_balances::::{Module, Call, Storage, Config, Event} = 4, - Kton: darwinia_balances::::{Module, Call, Storage, Config, Event} = 5, - TransactionPayment: pallet_transaction_payment::{Module, Storage} = 6, + Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 3, + Balances: darwinia_balances::::{Pallet, Call, Storage, Config, Event} = 4, + Kton: darwinia_balances::::{Pallet, Call, Storage, Config, Event} = 5, + TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 6, // Consensus support. - Authorship: pallet_authorship::{Module, Call, Storage, Inherent} = 7, - ElectionProviderMultiPhase: pallet_election_provider_multi_phase::{Module, Call, Storage, Event, ValidateUnsigned} = 8, - Staking: darwinia_staking::{Module, Call, Storage, Config, Event, ValidateUnsigned} = 9, - Offences: pallet_offences::{Module, Call, Storage, Event} = 10, - Historical: pallet_session_historical::{Module} = 11, - Session: pallet_session::{Module, Call, Storage, Config, Event} = 12, - Grandpa: pallet_grandpa::{Module, Call, Storage, Config, Event, ValidateUnsigned} = 13, - ImOnline: pallet_im_online::{Module, Call, Storage, Config, Event, ValidateUnsigned} = 14, - AuthorityDiscovery: pallet_authority_discovery::{Module, Call, Config} = 15, - HeaderMMR: darwinia_header_mmr::{Module, Call, Storage} = 16, + Authorship: pallet_authorship::{Pallet, Call, Storage, Inherent} = 7, + ElectionProviderMultiPhase: pallet_election_provider_multi_phase::{Pallet, Call, Storage, Event, ValidateUnsigned} = 8, + Staking: darwinia_staking::{Pallet, Call, Storage, Config, Event} = 9, + Offences: pallet_offences::{Pallet, Call, Storage, Event} = 10, + Historical: pallet_session_historical::{Pallet} = 11, + Session: pallet_session::{Pallet, Call, Storage, Config, Event} = 12, + Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event, ValidateUnsigned} = 13, + ImOnline: pallet_im_online::{Pallet, Call, Storage, Config, Event, ValidateUnsigned} = 14, + AuthorityDiscovery: pallet_authority_discovery::{Pallet, Call, Config} = 15, + HeaderMMR: darwinia_header_mmr::{Pallet, Call, Storage} = 16, // Governance stuff; uncallable initially. - Democracy: darwinia_democracy::{Module, Call, Storage, Config, Event} = 17, - Council: pallet_collective::::{Module, Call, Storage, Origin, Config, Event} = 18, - TechnicalCommittee: pallet_collective::::{Module, Call, Storage, Origin, Config, Event} = 19, - ElectionsPhragmen: darwinia_elections_phragmen::{Module, Call, Storage, Config, Event} = 20, - TechnicalMembership: pallet_membership::::{Module, Call, Storage, Config, Event} = 21, - Treasury: darwinia_treasury::{Module, Call, Storage, Event} = 22, + Democracy: darwinia_democracy::{Pallet, Call, Storage, Config, Event} = 17, + Council: pallet_collective::::{Pallet, Call, Storage, Origin, Config, Event} = 18, + TechnicalCommittee: pallet_collective::::{Pallet, Call, Storage, Origin, Config, Event} = 19, + ElectionsPhragmen: darwinia_elections_phragmen::{Pallet, Call, Storage, Config, Event} = 20, + TechnicalMembership: pallet_membership::::{Pallet, Call, Storage, Config, Event} = 21, + Treasury: darwinia_treasury::{Pallet, Call, Storage, Event} = 22, - Sudo: pallet_sudo::{Module, Call, Storage, Config, Event} = 23, + Sudo: pallet_sudo::{Pallet, Call, Storage, Config, Event} = 23, // Claims. Usable initially. - Claims: darwinia_claims::{Module, Call, Storage, Config, Event, ValidateUnsigned} = 24, + Claims: darwinia_claims::{Pallet, Call, Storage, Config, Event, ValidateUnsigned} = 24, // Vesting. Usable initially, but removed once all vesting is finished. - Vesting: darwinia_vesting::{Module, Call, Storage, Event, Config} = 25, + Vesting: darwinia_vesting::{Pallet, Call, Storage, Event, Config} = 25, // Utility module. - Utility: pallet_utility::{Module, Call, Event} = 26, + Utility: pallet_utility::{Pallet, Call, Event} = 26, // Less simple identity module. - Identity: pallet_identity::{Module, Call, Storage, Event} = 27, + Identity: pallet_identity::{Pallet, Call, Storage, Event} = 27, // Society module. - Society: pallet_society::{Module, Call, Storage, Event} = 28, + Society: pallet_society::{Pallet, Call, Storage, Event} = 28, // Social recovery module. - Recovery: pallet_recovery::{Module, Call, Storage, Event} = 29, + Recovery: pallet_recovery::{Pallet, Call, Storage, Event} = 29, // System scheduler. - Scheduler: pallet_scheduler::{Module, Call, Storage, Event} = 30, + Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event} = 30, // Proxy module. Late addition. - Proxy: pallet_proxy::{Module, Call, Storage, Event} = 31, + Proxy: pallet_proxy::{Pallet, Call, Storage, Event} = 31, // Multisig module. Late addition. - Multisig: pallet_multisig::{Module, Call, Storage, Event} = 32, + Multisig: pallet_multisig::{Pallet, Call, Storage, Event} = 32, - CrabIssuing: darwinia_crab_issuing::{Module, Call, Storage, Config, Event} = 33, - CrabBacking: darwinia_crab_backing::{Module, Storage, Config} = 34, + CrabIssuing: darwinia_crab_issuing::{Pallet, Call, Storage, Config, Event} = 33, + CrabBacking: darwinia_crab_backing::{Pallet, Storage, Config} = 34, - EthereumRelay: darwinia_ethereum_relay::{Module, Call, Storage, Config, Event} = 35, - EthereumBacking: darwinia_ethereum_backing::{Module, Call, Storage, Config, Event} = 36, - EthereumRelayerGame: darwinia_relayer_game::::{Module, Storage} = 37, - EthereumRelayAuthorities: darwinia_relay_authorities::::{Module, Call, Storage, Config, Event} = 38, + EthereumRelay: darwinia_ethereum_relay::{Pallet, Call, Storage, Config, Event} = 35, + EthereumBacking: darwinia_ethereum_backing::{Pallet, Call, Storage, Config, Event} = 36, + EthereumRelayerGame: darwinia_relayer_game::::{Pallet, Storage} = 37, + EthereumRelayAuthorities: darwinia_relay_authorities::::{Pallet, Call, Storage, Config, Event} = 38, - TronBacking: darwinia_tron_backing::{Module, Storage, Config} = 39, + TronBacking: darwinia_tron_backing::{Pallet, Storage, Config} = 39, - EVM: darwinia_evm::{Module, Call, Storage, Config, Event} = 40, - Ethereum: dvm_ethereum::{Module, Call, Storage, Config, Event, ValidateUnsigned} = 41, + EVM: darwinia_evm::{Pallet, Call, Storage, Config, Event} = 40, + Ethereum: dvm_ethereum::{Pallet, Call, Storage, Config, Event, ValidateUnsigned} = 41, } } @@ -597,7 +604,7 @@ impl_runtime_apis! { } fn random_seed() -> ::Hash { - RandomnessCollectiveFlip::random_seed() + pallet_babe::RandomnessFromOneEpochAgo::::random_seed().0 } } @@ -656,10 +663,10 @@ impl_runtime_apis! { sp_consensus_babe::BabeGenesisConfiguration { slot_duration: Babe::slot_duration(), epoch_length: EpochDuration::get(), - c: PRIMARY_PROBABILITY, + c: BABE_GENESIS_EPOCH_CONFIG.c, genesis_authorities: Babe::authorities(), randomness: Babe::randomness(), - allowed_slots: sp_consensus_babe::AllowedSlots::PrimaryAndSecondaryPlainSlots, + allowed_slots: BABE_GENESIS_EPOCH_CONFIG.allowed_slots, } } diff --git a/bin/node/runtime/pangolin/src/staking.rs b/bin/node/runtime/pangolin/src/staking.rs index 89f9035790..1529ca765f 100644 --- a/bin/node/runtime/pangolin/src/staking.rs +++ b/bin/node/runtime/pangolin/src/staking.rs @@ -1,6 +1,5 @@ // --- substrate --- -use frame_support::weights::{constants::BlockExecutionWeight, DispatchClass, Weight}; -use sp_runtime::{transaction_validity::TransactionPriority, ModuleId, Perbill}; +use sp_runtime::ModuleId; use sp_staking::SessionIndex; // --- darwinia --- use crate::*; @@ -12,16 +11,7 @@ frame_support::parameter_types! { pub const BondingDurationInEra: EraIndex = 2; pub const BondingDurationInBlockNumber: BlockNumber = 2 * BLOCKS_PER_SESSION * SESSIONS_PER_ERA; pub const SlashDeferDuration: EraIndex = 1; - // quarter of the last session will be for election. - pub const ElectionLookahead: BlockNumber = BLOCKS_PER_SESSION / 2; - pub const MaxIterations: u32 = 5; - pub MinSolutionScoreBump: Perbill = Perbill::from_rational_approximation(5u32, 10_000); pub const MaxNominatorRewardedPerValidator: u32 = 128; - pub const StakingUnsignedPriority: TransactionPriority = TransactionPriority::max_value() / 2; - pub OffchainSolutionWeightLimit: Weight = RuntimeBlockWeights::get() - .get(DispatchClass::Normal) - .max_extrinsic.expect("Normal extrinsics have a weight limit configured; qed") - .saturating_sub(BlockExecutionWeight::get()); pub const Cap: Balance = CAP; pub const TotalPower: Power = TOTAL_POWER; } @@ -37,15 +27,7 @@ impl Config for Runtime { type SlashCancelOrigin = EnsureRootOrHalfCouncil; type SessionInterface = Self; type NextNewSession = Session; - type ElectionLookahead = ElectionLookahead; - type Call = Call; - type MaxIterations = MaxIterations; - type MinSolutionScoreBump = MinSolutionScoreBump; type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator; - type UnsignedPriority = StakingUnsignedPriority; - // The unsigned solution weight targeted by the OCW. We set it to the maximum possible value of - // a single extrinsic. - type OffchainSolutionWeightLimit = OffchainSolutionWeightLimit; type ElectionProvider = ElectionProviderMultiPhase; type RingCurrency = Ring; type RingRewardRemainder = Treasury; diff --git a/bin/node/runtime/pangolin/types.json b/bin/node/runtime/pangolin/types.json index 6aabe8627e..e5a3381a62 100644 --- a/bin/node/runtime/pangolin/types.json +++ b/bin/node/runtime/pangolin/types.json @@ -76,11 +76,6 @@ "kton_balance": "Compact", "power": "Power" }, - "ElectionResultT": { - "elected_stashes": "Vec", - "exposures": "Vec<(AccountId, ExposureT)>", - "compute": "ElectionCompute" - }, "RKT": { "r": "Balance", "k": "Balance" diff --git a/client/cli/Cargo.toml b/client/cli/Cargo.toml index 95dcc73c80..0f07ae036d 100644 --- a/client/cli/Cargo.toml +++ b/client/cli/Cargo.toml @@ -14,7 +14,7 @@ version = "2.1.0" serde = { version = "1.0.124", features = ["derive"] } toml = { version = "0.5.7" } # substrate -sc-cli = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sc-client-api = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sc-service = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sc-tracing = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +sc-cli = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sc-client-api = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sc-service = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sc-tracing = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } diff --git a/client/cli/src/lib.rs b/client/cli/src/lib.rs index 3b7ed1c22a..c0bffe6211 100644 --- a/client/cli/src/lib.rs +++ b/client/cli/src/lib.rs @@ -796,13 +796,11 @@ impl Into for ExecutionStrategy { #[serde(rename_all = "PascalCase")] enum TracingReceiver { Log, - Telemetry, } impl Into for TracingReceiver { fn into(self) -> sc_tracing::TracingReceiver { match self { TracingReceiver::Log => sc_tracing::TracingReceiver::Log, - TracingReceiver::Telemetry => sc_tracing::TracingReceiver::Telemetry, } } } diff --git a/client/dvm/consensus/Cargo.toml b/client/dvm/consensus/Cargo.toml index d0c1e87009..5ae6525a66 100644 --- a/client/dvm/consensus/Cargo.toml +++ b/client/dvm/consensus/Cargo.toml @@ -20,13 +20,13 @@ log = { version = "0.4.14" } dp_consensus = { path = "../../../primitives/consensus/" } dvm-rpc-runtime-api = { path = "../../../frame/dvm/rpc/runtime-api" } # substrate -prometheus-endpoint = { package = "substrate-prometheus-endpoint", git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sc-client-api = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-api = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-block-builder = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-blockchain = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-consensus = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-core = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-inherents = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-runtime = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-timestamp = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +prometheus-endpoint = { package = "substrate-prometheus-endpoint", git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sc-client-api = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-api = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-block-builder = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-blockchain = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-consensus = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-core = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-inherents = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-runtime = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-timestamp = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } diff --git a/client/dvm/db/Cargo.toml b/client/dvm/db/Cargo.toml index e8d5d3c5e0..93c4b26055 100644 --- a/client/dvm/db/Cargo.toml +++ b/client/dvm/db/Cargo.toml @@ -16,6 +16,6 @@ kvdb = { version = "0.9.0" } kvdb-rocksdb = { version = "0.11.0" } parking_lot = { version = "0.11.1" } # substrate -sp-core = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-database = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-runtime = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +sp-core = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-database = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-runtime = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } diff --git a/client/dvm/mapping-sync/Cargo.toml b/client/dvm/mapping-sync/Cargo.toml index fc2329d516..6c4efcef7e 100644 --- a/client/dvm/mapping-sync/Cargo.toml +++ b/client/dvm/mapping-sync/Cargo.toml @@ -11,10 +11,10 @@ version = "2.1.0" [dependencies] # substrate -sp-api = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-blockchain = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sc-client-api = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-runtime = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +sp-api = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-blockchain = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sc-client-api = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-runtime = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } # darwinia dc-consensus = { path = "../consensus" } dc-db = { path = "../db" } diff --git a/client/dvm/rpc/Cargo.toml b/client/dvm/rpc/Cargo.toml index 9a10585867..fda5ac9a40 100644 --- a/client/dvm/rpc/Cargo.toml +++ b/client/dvm/rpc/Cargo.toml @@ -36,16 +36,16 @@ dvm-ethereum = { path = "../../../frame/dvm" } dvm-rpc-core = { path = "../../../frame/dvm/rpc" } dvm-rpc-runtime-api = { path = "../../../frame/dvm/rpc/runtime-api" } # substrate -sc-client-api = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sc-network = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sc-rpc = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sc-service = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-api = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-blockchain = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-io = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-runtime = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-storage = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-transaction-pool = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +sc-client-api = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sc-network = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sc-rpc = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sc-service = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-api = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-blockchain = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-io = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-runtime = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-storage = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-transaction-pool = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [features] rpc_binary_search_estimate = [] diff --git a/frame/balances/Cargo.toml b/frame/balances/Cargo.toml index 355d89a927..08f9fef069 100644 --- a/frame/balances/Cargo.toml +++ b/frame/balances/Cargo.toml @@ -18,16 +18,16 @@ serde = { version = "1.0.124", optional = true } darwinia-balances-rpc-runtime-api = { default-features = false, path = "./rpc/runtime-api" } darwinia-support = { default-features = false, path = "../support" } # substrate -frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -frame-system = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +frame-system = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [dev-dependencies] # substrate -pallet-transaction-payment = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-core = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-io = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +pallet-transaction-payment = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-core = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-io = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [features] default = ["std"] diff --git a/frame/balances/rpc/Cargo.toml b/frame/balances/rpc/Cargo.toml index d04dbf02f0..0afe3d7a35 100644 --- a/frame/balances/rpc/Cargo.toml +++ b/frame/balances/rpc/Cargo.toml @@ -18,6 +18,6 @@ jsonrpc-derive = { version = "15.1.0" } # darwinia darwinia-balances-rpc-runtime-api = { path = "./runtime-api" } # substrate -sp-api = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-blockchain = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-runtime = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +sp-api = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-blockchain = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-runtime = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } diff --git a/frame/balances/rpc/runtime-api/Cargo.toml b/frame/balances/rpc/runtime-api/Cargo.toml index d58d77f718..267c974c48 100644 --- a/frame/balances/rpc/runtime-api/Cargo.toml +++ b/frame/balances/rpc/runtime-api/Cargo.toml @@ -16,8 +16,8 @@ serde = { version = "1.0.124", optional = true, features = ["derive"] } # darwinia darwinia-support = { default-features = false, path = "../../../support" } # substrate -sp-api = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +sp-api = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [features] default = ["std"] diff --git a/frame/balances/src/lib.rs b/frame/balances/src/lib.rs index a91c0242f8..2705e98897 100644 --- a/frame/balances/src/lib.rs +++ b/frame/balances/src/lib.rs @@ -534,7 +534,7 @@ impl, I: Instance> Module { /// Get the frozen balance of an account. fn frozen_balance(who: impl Borrow) -> FrozenBalance { - let now = >::block_number(); + let now = >::block_number(); let mut frozen_balance = >::zero(); for lock in Self::locks(who.borrow()).iter() { let locked_amount = match &lock.lock_for { @@ -658,12 +658,12 @@ impl, I: Instance> Module { if existed { // TODO: use Locks::::hashed_key // https://github.com/paritytech/substrate/issues/4969 - >::dec_consumers(who); + >::dec_consumers(who); } } else { Locks::::insert(who, locks); if !existed { - if >::inc_consumers(who).is_err() { + if >::inc_consumers(who).is_err() { // No providers for the locks. This is impossible under normal circumstances // since the funds that are under the lock will themselves be stored in the // account and therefore will need a reference. @@ -967,7 +967,7 @@ where // may not even be a provider. let allow_death = existence_requirement == ExistenceRequirement::AllowDeath; let allow_death = - allow_death && !>::is_provider_required(transactor); + allow_death && !>::is_provider_required(transactor); ensure!( allow_death @@ -1414,7 +1414,7 @@ where if match &lock_for { LockFor::Common { amount } => *amount, LockFor::Staking(staking_lock) => { - staking_lock.locked_amount(>::block_number()) + staking_lock.locked_amount(>::block_number()) } } .is_zero() || reasons.is_empty() @@ -1540,7 +1540,7 @@ impl, I: Instance> DustCollector for Module { if !dropped.is_zero() { T::DustRemoval::on_unbalanced(NegativeImbalance::new(dropped)); - if let Err(e) = >::dec_providers(who) { + if let Err(e) = >::dec_providers(who) { log::error!("Logic error: Unexpected {:?}", e); } Self::deposit_event(RawEvent::DustLost(who.clone(), dropped)); diff --git a/frame/balances/src/tests.rs b/frame/balances/src/tests.rs index a8ae16fa90..ed51fbf416 100644 --- a/frame/balances/src/tests.rs +++ b/frame/balances/src/tests.rs @@ -52,7 +52,7 @@ macro_rules! decl_tests { } fn last_event() -> Event { - frame_system::Module::::events().pop().expect("Event expected").event + >::events().pop().expect("Event expected").event } #[test] diff --git a/frame/balances/src/tests_local.rs b/frame/balances/src/tests_local.rs index c51221f9f3..8af440876b 100644 --- a/frame/balances/src/tests_local.rs +++ b/frame/balances/src/tests_local.rs @@ -126,9 +126,9 @@ frame_support::construct_runtime! { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic { - System: frame_system::{Module, Call, Storage, Config, Event}, - Ring: darwinia_balances::::{Module, Call, Storage, Config, Event}, - Kton: darwinia_balances::::{Module, Call, Storage, Config, Event}, + System: frame_system::{Pallet, Call, Storage, Config, Event}, + Ring: darwinia_balances::::{Pallet, Call, Storage, Config, Event}, + Kton: darwinia_balances::::{Pallet, Call, Storage, Config, Event}, } } diff --git a/frame/bridge/crab/backing/Cargo.toml b/frame/bridge/crab/backing/Cargo.toml index f94878cd6e..ff1718e939 100644 --- a/frame/bridge/crab/backing/Cargo.toml +++ b/frame/bridge/crab/backing/Cargo.toml @@ -14,9 +14,9 @@ version = "2.1.0" codec = { package = "parity-scale-codec", version = "2.0.1", default-features = false } serde = { version = "1.0.124", optional = true } # substrate -frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -frame-system = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +frame-system = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [features] default = ["std"] diff --git a/frame/bridge/crab/issuing/Cargo.toml b/frame/bridge/crab/issuing/Cargo.toml index 5427431398..b6bc52087f 100644 --- a/frame/bridge/crab/issuing/Cargo.toml +++ b/frame/bridge/crab/issuing/Cargo.toml @@ -15,15 +15,15 @@ codec = { package = "parity-scale-codec", version = "2.0.1", default-featur serde = { version = "1.0.124", optional = true } serde_json = { version = "1.0.62", optional = true } # substrate -frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -frame-system = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +frame-system = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } # darwinia darwinia-support = { optional = true, path = "../../../support" } [dev-dependencies] # substrate -sp-io = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +sp-io = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } # darwinia darwinia-balances = { path = "../../../balances" } darwinia-support = { path = "../../../support" } diff --git a/frame/bridge/crab/issuing/src/mock.rs b/frame/bridge/crab/issuing/src/mock.rs index 56211f4d06..1571a76f3e 100644 --- a/frame/bridge/crab/issuing/src/mock.rs +++ b/frame/bridge/crab/issuing/src/mock.rs @@ -98,9 +98,9 @@ frame_support::construct_runtime! { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic { - System: frame_system::{Module, Call, Storage, Config, Event}, - Ring: darwinia_balances::::{Module, Call, Storage, Config, Event}, - CrabIssuing: darwinia_crab_issuing::{Module, Call, Storage, Config, Event}, + System: frame_system::{Pallet, Call, Storage, Config, Event}, + Ring: darwinia_balances::::{Pallet, Call, Storage, Config, Event}, + CrabIssuing: darwinia_crab_issuing::{Pallet, Call, Storage, Config, Event}, } } diff --git a/frame/bridge/ethereum/backing/Cargo.toml b/frame/bridge/ethereum/backing/Cargo.toml index 97c6d07b32..6f572c5f6f 100644 --- a/frame/bridge/ethereum/backing/Cargo.toml +++ b/frame/bridge/ethereum/backing/Cargo.toml @@ -23,11 +23,11 @@ ethereum-primitives = { default-features = false, path = "../../../../prim # github ethabi = { default-features = false, git = "https://github.com/darwinia-network/ethabi.git", branch = "xavier-no-std" } # substrate -frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -frame-system = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-io = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +frame-system = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-io = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [dev-dependencies] # darwinia @@ -41,11 +41,11 @@ ethereum-primitives = { features = ["deserialize"], path = "../../../ # github rlp = { version = "0.5.0" } # substrate -pallet-session = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -pallet-timestamp = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-core = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-election-providers = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-staking = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +frame-election-provider-support = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +pallet-session = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +pallet-timestamp = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-core = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-staking = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [features] default = ["std"] diff --git a/frame/bridge/ethereum/backing/src/lib.rs b/frame/bridge/ethereum/backing/src/lib.rs index f1b950fa33..375e5924fd 100644 --- a/frame/bridge/ethereum/backing/src/lib.rs +++ b/frame/bridge/ethereum/backing/src/lib.rs @@ -326,7 +326,7 @@ decl_module! { if locked { T::EcdsaAuthorities::schedule_mmr_root(( - >::block_number().saturated_into::() + >::block_number().saturated_into::() / 10 * 10 + 10 ).saturated_into()); } diff --git a/frame/bridge/ethereum/backing/src/mock.rs b/frame/bridge/ethereum/backing/src/mock.rs index 5a874e7234..a6346a4915 100644 --- a/frame/bridge/ethereum/backing/src/mock.rs +++ b/frame/bridge/ethereum/backing/src/mock.rs @@ -22,6 +22,7 @@ macro_rules! decl_tests { ($($pallet:tt)*) => { // --- substrate --- + use frame_election_provider_support::onchain; use frame_support::weights::Weight; use frame_system::mocking::*; use sp_core::crypto::key_types; @@ -30,7 +31,6 @@ macro_rules! decl_tests { traits::{IdentifyAccount, IdentityLookup, OpaqueKeys, Verify}, ModuleId, {KeyTypeId, MultiSignature, Perbill}, }; - use sp_election_providers::onchain; // --- darwinia --- use crate as darwinia_ethereum_backing; use darwinia_staking::{EraIndex, Exposure, ExposureOf}; @@ -144,6 +144,7 @@ macro_rules! decl_tests { impl onchain::Config for Test { type AccountId = AccountId; type BlockNumber = BlockNumber; + type BlockWeights = (); type Accuracy = Perbill; type DataProvider = Staking; } @@ -162,13 +163,7 @@ macro_rules! decl_tests { type SlashCancelOrigin = frame_system::EnsureRoot; type SessionInterface = Self; type NextNewSession = Session; - type ElectionLookahead = (); - type Call = Call; - type MaxIterations = (); - type MinSolutionScoreBump = (); type MaxNominatorRewardedPerValidator = (); - type UnsignedPriority = (); - type OffchainSolutionWeightLimit = (); type ElectionProvider = onchain::OnChainSequentialPhragmen; type RingCurrency = Ring; type RingRewardRemainder = (); @@ -235,13 +230,13 @@ macro_rules! decl_tests { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic { - System: frame_system::{Module, Call, Storage, Config}, - Timestamp: pallet_timestamp::{Module, Call, Storage}, - Ring: darwinia_balances::::{Module, Call, Storage}, - Kton: darwinia_balances::::{Module, Call, Storage}, - Staking: darwinia_staking::{Module, Call, Storage}, - Session: pallet_session::{Module, Call, Storage}, - EthereumBacking: darwinia_ethereum_backing::{Module, Call, Storage, Config}, + System: frame_system::{Pallet, Call, Storage, Config}, + Timestamp: pallet_timestamp::{Pallet, Call, Storage}, + Ring: darwinia_balances::::{Pallet, Call, Storage}, + Kton: darwinia_balances::::{Pallet, Call, Storage}, + Staking: darwinia_staking::{Pallet, Call, Storage}, + Session: pallet_session::{Pallet, Call, Storage}, + EthereumBacking: darwinia_ethereum_backing::{Pallet, Call, Storage, Config}, $($pallet)*, } } diff --git a/frame/bridge/ethereum/backing/src/test_with_linear_relay.rs b/frame/bridge/ethereum/backing/src/test_with_linear_relay.rs index c1b783b9bb..278b2ec473 100644 --- a/frame/bridge/ethereum/backing/src/test_with_linear_relay.rs +++ b/frame/bridge/ethereum/backing/src/test_with_linear_relay.rs @@ -30,7 +30,7 @@ use ethereum_primitives::{ header::EthereumHeader, receipt::EthereumReceiptProof, EthereumNetworkType, }; -decl_tests!(EthereumRelay: darwinia_ethereum_linear_relay::{Module, Call, Storage}); +decl_tests!(EthereumRelay: darwinia_ethereum_linear_relay::{Pallet, Call, Storage}); frame_support::parameter_types! { pub const EthereumLinearRelayModuleId: ModuleId = ModuleId(*b"da/ethli"); diff --git a/frame/bridge/ethereum/backing/src/test_with_relay.rs b/frame/bridge/ethereum/backing/src/test_with_relay.rs index c4db9dcc22..fd3b15927a 100644 --- a/frame/bridge/ethereum/backing/src/test_with_relay.rs +++ b/frame/bridge/ethereum/backing/src/test_with_relay.rs @@ -32,7 +32,7 @@ use ethereum_primitives::{ header::EthereumHeader, receipt::EthereumReceiptProof, EthereumBlockNumber, EthereumNetworkType, }; -decl_tests!(EthereumRelay: darwinia_ethereum_relay::{Module, Call, Storage}); +decl_tests!(EthereumRelay: darwinia_ethereum_relay::{Pallet, Call, Storage}); pub struct UnusedTechnicalMembership; impl Contains for UnusedTechnicalMembership { diff --git a/frame/bridge/ethereum/linear-relay/Cargo.toml b/frame/bridge/ethereum/linear-relay/Cargo.toml index 04ab9181b5..119e1a7c21 100644 --- a/frame/bridge/ethereum/linear-relay/Cargo.toml +++ b/frame/bridge/ethereum/linear-relay/Cargo.toml @@ -22,10 +22,10 @@ serde_json = { version = "1.0.62", optional = true } darwinia-support = { default-features = false, path = "../../../support" } ethereum-primitives = { default-features = false, path = "../../../../primitives/ethereum-primitives" } # substrate -frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -frame-system = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +frame-system = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [dev-dependencies] # crates @@ -34,8 +34,8 @@ array-bytes = { version = "1.1.0" } darwinia-balances = { path = "../../../../frame/balances" } ethereum-primitives = { features = ["deserialize"], path = "../../../../primitives/ethereum-primitives" } # substrate -sp-core = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-io = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +sp-core = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-io = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [features] default = ["std"] diff --git a/frame/bridge/ethereum/linear-relay/src/mock.rs b/frame/bridge/ethereum/linear-relay/src/mock.rs index 5ad5b991a0..e28dc90dc6 100644 --- a/frame/bridge/ethereum/linear-relay/src/mock.rs +++ b/frame/bridge/ethereum/linear-relay/src/mock.rs @@ -97,9 +97,9 @@ frame_support::construct_runtime! { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic { - System: frame_system::{Module, Call, Storage, Config}, - Ring: darwinia_balances::::{Module, Call, Storage, Config}, - EthereumRelay: darwinia_ethereum_linear_relay::{Module, Call, Storage, Config}, + System: frame_system::{Pallet, Call, Storage, Config}, + Ring: darwinia_balances::::{Pallet, Call, Storage, Config}, + EthereumRelay: darwinia_ethereum_linear_relay::{Pallet, Call, Storage, Config}, } } diff --git a/frame/bridge/ethereum/relay/Cargo.toml b/frame/bridge/ethereum/relay/Cargo.toml index 9e04de7283..2ced73cb20 100644 --- a/frame/bridge/ethereum/relay/Cargo.toml +++ b/frame/bridge/ethereum/relay/Cargo.toml @@ -27,19 +27,19 @@ ckb-merkle-mountain-range = { default-features = false, git = "https://github.co ethereum-types = { version = "0.11.0", default-features = false } rlp = { version = "0.5.0", default-features = false } # substrate -frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -frame-system = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-core = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +frame-system = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-core = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [dev-dependencies] # darwinia darwinia-balances = { path = "../../../../frame/balances" } ethereum-primitives = { features = ["deserialize"], path = "../../../../primitives/ethereum-primitives" } # substrate -sp-core = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-io = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +sp-core = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-io = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [features] default = ["std"] diff --git a/frame/bridge/ethereum/relay/src/lib.rs b/frame/bridge/ethereum/relay/src/lib.rs index 2fff92788c..540bde1376 100644 --- a/frame/bridge/ethereum/relay/src/lib.rs +++ b/frame/bridge/ethereum/relay/src/lib.rs @@ -422,9 +422,9 @@ decl_module! { let reject = nays.len() as u32; let total = T::TechnicalMembership::count() as u32; let approve_threashold = - Perbill::from_rational_approximation(approve, total); + Perbill::from_rational(approve, total); let reject_threashold = - Perbill::from_rational_approximation(reject, total); + Perbill::from_rational(reject, total); if approve_threashold >= T::ApproveThreshold::get() { Self::confirm_relay_header_parcel_with_reason( @@ -871,7 +871,7 @@ impl Relayable for Module { ); } else { >::append(( - >::block_number() + confirm_period, + >::block_number() + confirm_period, relay_header_parcel, RelayVotingState::default(), )); diff --git a/frame/bridge/ethereum/relay/src/mock.rs b/frame/bridge/ethereum/relay/src/mock.rs index 888c80cef8..899a3591e9 100644 --- a/frame/bridge/ethereum/relay/src/mock.rs +++ b/frame/bridge/ethereum/relay/src/mock.rs @@ -107,9 +107,9 @@ frame_support::construct_runtime! { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic { - System: frame_system::{Module, Call, Storage, Config}, - Ring: darwinia_balances::::{Module, Call, Storage}, - EthereumRelay: darwinia_ethereum_relay::{Module, Call, Storage, Config}, + System: frame_system::{Pallet, Call, Storage, Config}, + Ring: darwinia_balances::::{Pallet, Call, Storage}, + EthereumRelay: darwinia_ethereum_relay::{Pallet, Call, Storage, Config}, } } diff --git a/frame/bridge/relay-authorities/Cargo.toml b/frame/bridge/relay-authorities/Cargo.toml index c49881de62..142b0c45f0 100644 --- a/frame/bridge/relay-authorities/Cargo.toml +++ b/frame/bridge/relay-authorities/Cargo.toml @@ -17,10 +17,10 @@ serde = { version = "1.0.124", optional = true } darwinia-relay-primitives = { default-features = false, path = "../../../primitives/relay" } darwinia-support = { default-features = false, path = "../../support" } # substrate -frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -frame-system = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +frame-system = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [dev-dependencies] # crates @@ -29,8 +29,8 @@ array-bytes = { version = "1.1.0" } darwinia-balances = { path = "../../balances" } darwinia-support = { path = "../../support" } # substrate -sp-core = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-io = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +sp-core = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-io = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [features] default = ["std"] diff --git a/frame/bridge/relay-authorities/src/lib.rs b/frame/bridge/relay-authorities/src/lib.rs index 800a17d597..499e3cb1cc 100644 --- a/frame/bridge/relay-authorities/src/lib.rs +++ b/frame/bridge/relay-authorities/src/lib.rs @@ -223,7 +223,7 @@ decl_storage! { account_id: account_id.to_owned(), signer: signer.to_owned(), stake: *stake, - term: >::block_number() + T::TermDuration::get() + term: >::block_number() + T::TermDuration::get() }); } @@ -379,7 +379,7 @@ decl_module! { for account_id in account_ids { let mut authority = Self::remove_candidate_by_id_with(&account_id, || ())?; - authority.term = >::block_number() + T::TermDuration::get(); + authority.term = >::block_number() + T::TermDuration::get(); authorities.push(authority); } @@ -405,7 +405,7 @@ decl_module! { let next_authorities = Self::remove_authority_by_ids_with( vec![account_id], - |authority| if authority.term >= >::block_number() { + |authority| if authority.term >= >::block_number() { Some(>::AuthorityIT) } else { None @@ -500,7 +500,7 @@ decl_module! { signatures.push((authority, signature)); - if Perbill::from_rational_approximation(signatures.len() as u32, authorities.len() as _) + if Perbill::from_rational(signatures.len() as u32, authorities.len() as _) >= T::SignThreshold::get() { // TODO: clean the mmr root which was contains in this mmr root? @@ -554,7 +554,7 @@ decl_module! { signatures.push((authority, signature)); - if Perbill::from_rational_approximation(signatures.len() as u32, authorities.len() as _) + if Perbill::from_rational(signatures.len() as u32, authorities.len() as _) >= T::SignThreshold::get() { Self::apply_authorities_change()?; @@ -588,7 +588,7 @@ decl_module! { { >::remove_all(); let schedule = ( - >::block_number().saturated_into::() / 10 * 10 + 10 + >::block_number().saturated_into::() / 10 * 10 + 10 ).saturated_into(); >::mutate(|schedules| *schedules = vec![schedule]); Self::schedule_mmr_root(schedule); @@ -716,7 +716,7 @@ where >::put(ScheduledAuthoritiesChange { next_authorities, - deadline: >::block_number() + submit_duration, + deadline: >::block_number() + submit_duration, }); >::mutate(|submit_duration_| *submit_duration_ += submit_duration); diff --git a/frame/bridge/relay-authorities/src/mock.rs b/frame/bridge/relay-authorities/src/mock.rs index abc4f2c7b5..2e02957a95 100644 --- a/frame/bridge/relay-authorities/src/mock.rs +++ b/frame/bridge/relay-authorities/src/mock.rs @@ -140,9 +140,9 @@ frame_support::construct_runtime! { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic { - System: frame_system::{Module, Call, Storage, Config, Event}, - Ring: darwinia_balances::::{Module, Call, Storage, Config, Event}, - RelayAuthorities: darwinia_relay_authorities::{Module, Call, Storage, Config, Event} + System: frame_system::{Pallet, Call, Storage, Config, Event}, + Ring: darwinia_balances::::{Pallet, Call, Storage, Config, Event}, + RelayAuthorities: darwinia_relay_authorities::{Pallet, Call, Storage, Config, Event} } } diff --git a/frame/bridge/relayer-game/Cargo.toml b/frame/bridge/relayer-game/Cargo.toml index a6438e7a3d..5fd92023d7 100644 --- a/frame/bridge/relayer-game/Cargo.toml +++ b/frame/bridge/relayer-game/Cargo.toml @@ -18,10 +18,10 @@ serde = { version = "1.0.124", optional = true } darwinia-relay-primitives = { default-features = false, path = "../../../primitives/relay" } darwinia-support = { default-features = false, path = "../../support" } # substrate -frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -frame-system = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +frame-system = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [dev-dependencies] # crates @@ -29,8 +29,8 @@ env_logger = { version = "0.8.3" } # darwinia darwinia-balances = { path = "../../balances" } # substrate -sp-core = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-io = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +sp-core = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-io = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [features] default = ["std"] diff --git a/frame/bridge/relayer-game/src/lib.rs b/frame/bridge/relayer-game/src/lib.rs index b28be075a5..4f1f92d3bd 100644 --- a/frame/bridge/relayer-game/src/lib.rs +++ b/frame/bridge/relayer-game/src/lib.rs @@ -685,7 +685,7 @@ impl, I: Instance> Module { } pub fn update_games(game_ids: Vec>) -> DispatchResult { - let now = >::block_number(); + let now = >::block_number(); let mut relay_header_parcels = vec![]; for game_id in game_ids { @@ -827,7 +827,7 @@ impl, I: Instance> RelayerGameProtocol for Module { >::RoundMis ); - let now = >::block_number(); + let now = >::block_number(); let proposed_relay_header_parcels = vec![relay_header_parcel]; // Check if it is a new game @@ -904,7 +904,7 @@ impl, I: Instance> RelayerGameProtocol for Module { >::RelayParcelAR ); - let now = >::block_number(); + let now = >::block_number(); ensure!( Self::is_game_open_at(&game_id, now, 0), @@ -1026,7 +1026,7 @@ impl, I: Instance> RelayerGameProtocol for Module { let round = previous_round + 1; ensure!( - Self::is_game_open_at(&game_id, >::block_number(), round), + Self::is_game_open_at(&game_id, >::block_number(), round), >::GameAtThisRoundC ); diff --git a/frame/bridge/relayer-game/src/mock.rs b/frame/bridge/relayer-game/src/mock.rs index 718a213a71..361eac50ae 100644 --- a/frame/bridge/relayer-game/src/mock.rs +++ b/frame/bridge/relayer-game/src/mock.rs @@ -348,10 +348,10 @@ frame_support::construct_runtime! { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic { - System: frame_system::{Module, Call, Storage, Config}, - Ring: darwinia_balances::::{Module, Call, Storage, Config}, - Relay: mock_relay::{Module, Storage}, - RelayerGame: darwinia_relayer_game::{Module, Storage}, + System: frame_system::{Pallet, Call, Storage, Config}, + Ring: darwinia_balances::::{Pallet, Call, Storage, Config}, + Relay: mock_relay::{Pallet, Storage}, + RelayerGame: darwinia_relayer_game::{Pallet, Storage}, } } diff --git a/frame/bridge/tron/backing/Cargo.toml b/frame/bridge/tron/backing/Cargo.toml index 42d174df84..90c0ad119d 100644 --- a/frame/bridge/tron/backing/Cargo.toml +++ b/frame/bridge/tron/backing/Cargo.toml @@ -14,9 +14,9 @@ version = "2.1.0" codec = { package = "parity-scale-codec", version = "2.0.1", default-features = false } serde = { version = "1.0.124", optional = true } # substrate -frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -frame-system = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +frame-system = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [features] default = ["std"] diff --git a/frame/claims/Cargo.toml b/frame/claims/Cargo.toml index 05eee5a4d1..f76a5a51f9 100644 --- a/frame/claims/Cargo.toml +++ b/frame/claims/Cargo.toml @@ -19,11 +19,11 @@ serde_json = { version = "1.0.62", optional = true } # darwinia darwinia-support = { default-features = false, path = "../support" } # substrate -frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -frame-system = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-io = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +frame-system = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-io = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [dev-dependencies] # crates @@ -31,7 +31,7 @@ libsecp256k1 = { version = "0.3.5" } # darwinia darwinia-balances = { path = "../balances" } # substrate -sp-core = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +sp-core = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [features] default = ["std"] diff --git a/frame/claims/src/lib.rs b/frame/claims/src/lib.rs index 0383b429cc..f89c6e662e 100644 --- a/frame/claims/src/lib.rs +++ b/frame/claims/src/lib.rs @@ -548,7 +548,7 @@ mod secp_utils { what: &[u8], signed_message: &[u8], ) -> EcdsaSignature { - let msg = keccak_256(&>::eth_signable_message( + let msg = keccak_256(&>::eth_signable_message( &to_ascii_hex(what)[..], signed_message, )); @@ -564,7 +564,7 @@ mod secp_utils { what: &[u8], signed_message: &[u8], ) -> EcdsaSignature { - let msg = keccak_256(&>::tron_signable_message( + let msg = keccak_256(&>::tron_signable_message( &to_ascii_hex(what)[..], signed_message, )); @@ -666,9 +666,9 @@ mod tests { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic { - System: frame_system::{Module, Call, Storage, Config}, - Ring: darwinia_balances::::{Module, Call, Storage, Config}, - Claims: darwinia_claims::{Module, Call, Storage, Config} + System: frame_system::{Pallet, Call, Storage, Config}, + Ring: darwinia_balances::::{Pallet, Call, Storage, Config}, + Claims: darwinia_claims::{Pallet, Call, Storage, Config} } } diff --git a/frame/democracy/Cargo.toml b/frame/democracy/Cargo.toml index bde3fd0d7c..bf953d9376 100644 --- a/frame/democracy/Cargo.toml +++ b/frame/democracy/Cargo.toml @@ -16,11 +16,11 @@ serde = { version = "1.0.124", optional = true, features = ["derive"] } # darwinia darwinia-support = { default-features = false, path = "../support" } # substrate -frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -frame-system = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-io = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +frame-system = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-io = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [dev-dependencies] # crates @@ -29,10 +29,10 @@ hex-literal = "0.3.1" darwinia-balances = { path = "../balances" } darwinia-support = { features = ["easy-testing"], path = "../support" } # substrate -pallet-scheduler = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-core = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-storage = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -substrate-test-utils = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +pallet-scheduler = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-core = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-storage = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +substrate-test-utils = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [features] default = ["std"] diff --git a/frame/democracy/src/lib.rs b/frame/democracy/src/lib.rs index 63cc41073f..8725246a25 100644 --- a/frame/democracy/src/lib.rs +++ b/frame/democracy/src/lib.rs @@ -584,7 +584,7 @@ decl_module! { if let Some((until, _)) = >::get(proposal_hash) { ensure!( - >::block_number() >= until, + >::block_number() >= until, Error::::ProposalBlacklisted, ); } @@ -676,7 +676,7 @@ decl_module! { ensure!(!>::exists(), Error::::DuplicateProposal); if let Some((until, _)) = >::get(proposal_hash) { ensure!( - >::block_number() >= until, + >::block_number() >= until, Error::::ProposalBlacklisted, ); } @@ -764,7 +764,7 @@ decl_module! { ensure!(proposal_hash == e_proposal_hash, Error::::InvalidHash); >::kill(); - let now = >::block_number(); + let now = >::block_number(); Self::inject_referendum(now + voting_period, proposal_hash, threshold, delay); } @@ -794,7 +794,7 @@ decl_module! { .err().ok_or(Error::::AlreadyVetoed)?; existing_vetoers.insert(insert_position, who.clone()); - let until = >::block_number() + T::CooloffPeriod::get(); + let until = >::block_number() + T::CooloffPeriod::get(); >::insert(&proposal_hash, (until, existing_vetoers)); Self::deposit_event(RawEvent::Vetoed(who, proposal_hash, until)); @@ -992,7 +992,7 @@ decl_module! { _ => None, }).ok_or(Error::::PreimageMissing)?; - let now = >::block_number(); + let now = >::block_number(); let (voting, enactment) = (T::VotingPeriod::get(), T::EnactmentPeriod::get()); let additional = if who == provider { Zero::zero() } else { enactment }; ensure!(now >= since + voting + additional, Error::::TooEarly); @@ -1204,7 +1204,7 @@ impl Module { delay: T::BlockNumber, ) -> ReferendumIndex { >::inject_referendum( - >::block_number() + T::VotingPeriod::get(), + >::block_number() + T::VotingPeriod::get(), proposal_hash, threshold, delay, @@ -1329,7 +1329,7 @@ impl Module { Some(ReferendumInfo::Finished { end, approved }) => { if let Some((lock_periods, balance)) = votes[i].1.locked_if(approved) { let unlock_at = end + T::EnactmentPeriod::get() * lock_periods.into(); - let now = system::Module::::block_number(); + let now = >::block_number(); if now < unlock_at { ensure!( matches!(scope, UnvoteScope::Any), @@ -1474,7 +1474,7 @@ impl Module { // remove any delegation votes to our current target. let votes = Self::reduce_upstream_delegation(&target, conviction.votes(balance)); - let now = system::Module::::block_number(); + let now = >::block_number(); let lock_periods = conviction.lock_periods().into(); prior.accumulate(now + T::EnactmentPeriod::get() * lock_periods, balance); voting.set_common(delegations, prior); @@ -1492,7 +1492,7 @@ impl Module { /// a security hole) but may be reduced from what they are currently. fn update_lock(who: &T::AccountId) { let lock_needed = VotingOf::::mutate(who, |voting| { - voting.rejig(system::Module::::block_number()); + voting.rejig(>::block_number()); voting.locked_balance() }); if lock_needed.is_zero() { @@ -1787,7 +1787,7 @@ impl Module { .saturating_mul(T::PreimageByteDeposit::get()); T::Currency::reserve(&who, deposit)?; - let now = >::block_number(); + let now = >::block_number(); let a = PreimageStatus::Available { data: encoded_proposal, provider: who.clone(), @@ -1814,7 +1814,7 @@ impl Module { .to_missing_expiry() .ok_or(Error::::DuplicatePreimage)?; - let now = >::block_number(); + let now = >::block_number(); let free = >::zero(); let a = PreimageStatus::Available { data: encoded_proposal, diff --git a/frame/democracy/src/tests.rs b/frame/democracy/src/tests.rs index af3e66fef1..77e84f982f 100644 --- a/frame/democracy/src/tests.rs +++ b/frame/democracy/src/tests.rs @@ -187,10 +187,10 @@ frame_support::construct_runtime! { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - Balances: darwinia_balances::::{Module, Call, Storage, Config, Event}, - Scheduler: pallet_scheduler::{Module, Call, Storage, Config, Event}, - Democracy: darwinia_democracy::{Module, Call, Storage, Config, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Balances: darwinia_balances::::{Pallet, Call, Storage, Config, Event}, + Scheduler: pallet_scheduler::{Pallet, Call, Storage, Config, Event}, + Democracy: darwinia_democracy::{Pallet, Call, Storage, Config, Event}, } } diff --git a/frame/dvm-dynamic-fee/Cargo.toml b/frame/dvm-dynamic-fee/Cargo.toml index 502dd22090..26e6f831ce 100644 --- a/frame/dvm-dynamic-fee/Cargo.toml +++ b/frame/dvm-dynamic-fee/Cargo.toml @@ -14,12 +14,12 @@ version = "2.1.0" codec = { package = "parity-scale-codec", version = "2.0.1", default-features = false } serde = { version = "1.0.123", default-features = false, features = ["derive"], optional = true } -frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -frame-system = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-core = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-inherents = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +frame-system = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-core = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-inherents = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [features] default = ["std"] diff --git a/frame/dvm/Cargo.toml b/frame/dvm/Cargo.toml index 4ec2476e8b..907cf90ccc 100644 --- a/frame/dvm/Cargo.toml +++ b/frame/dvm/Cargo.toml @@ -28,13 +28,13 @@ dp-storage = { default-features = false, path = "../../primitives/stora dp_consensus = { default-features = false, path = "../../primitives/consensus" } dvm-rpc-runtime-api = { default-features = false, path = "./rpc/runtime-api" } # substrate -frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -frame-system = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -pallet-timestamp = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-core = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-io = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +frame-system = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +pallet-timestamp = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-core = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-io = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [dev-dependencies] # darwinia diff --git a/frame/dvm/rpc/Cargo.toml b/frame/dvm/rpc/Cargo.toml index a95ae994dd..5f3b018477 100644 --- a/frame/dvm/rpc/Cargo.toml +++ b/frame/dvm/rpc/Cargo.toml @@ -23,10 +23,10 @@ darwinia-evm = { default-features = false, path = "../../evm" } dp-evm = { default-features = false, path = "../../../primitives/evm" } dp-rpc = { default-features = false, path = "../../../primitives/rpc" } # substrate -sp-api = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-core = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +sp-api = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-core = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [features] default = ["std"] diff --git a/frame/dvm/rpc/runtime-api/Cargo.toml b/frame/dvm/rpc/runtime-api/Cargo.toml index 903dcbee97..102155d2e1 100644 --- a/frame/dvm/rpc/runtime-api/Cargo.toml +++ b/frame/dvm/rpc/runtime-api/Cargo.toml @@ -18,11 +18,11 @@ ethereum-types = { version = "0.11.0", default-features = false } darwinia-evm = { default-features = false, path = "../../../evm" } dp-evm = { default-features = false, path = "../../../../primitives/evm" } # substrate -sp-api = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-core = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-io = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +sp-api = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-core = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-io = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [features] default = ["std"] diff --git a/frame/dvm/src/account_basic.rs b/frame/dvm/src/account_basic.rs index d4fca2dc0c..6b1dbdeeb4 100644 --- a/frame/dvm/src/account_basic.rs +++ b/frame/dvm/src/account_basic.rs @@ -10,7 +10,7 @@ impl AccountBasicMapping for DVMAccountBasicMapping { /// Get the account basic in EVM format. fn account_basic(address: &H160) -> EVMAccount { let account_id = ::AddressMapping::into_account_id(*address); - let nonce = frame_system::Module::::account_nonce(&account_id); + let nonce = >::account_nonce(&account_id); let helper = U256::from(10) .checked_pow(U256::from(9)) .unwrap_or(U256::from(0)); diff --git a/frame/dvm/src/lib.rs b/frame/dvm/src/lib.rs index b5926714ea..600638a0fb 100644 --- a/frame/dvm/src/lib.rs +++ b/frame/dvm/src/lib.rs @@ -167,13 +167,13 @@ decl_module! { fn on_finalize(_block_number: T::BlockNumber) { >::store_block( - dp_consensus::find_pre_log(&frame_system::Module::::digest()).is_err(), + dp_consensus::find_pre_log(&>::digest()).is_err(), ); } fn on_initialize(_block_number: T::BlockNumber) -> Weight { Pending::kill(); - if let Ok(log) = dp_consensus::find_pre_log(&frame_system::Module::::digest()) { + if let Ok(log) = dp_consensus::find_pre_log(&>::digest()) { let PreLog::Block(block) = log; for transaction in block.transactions { @@ -283,7 +283,7 @@ impl Module { logs_bloom, difficulty: U256::zero(), number: U256::from(UniqueSaturatedInto::::unique_saturated_into( - frame_system::Module::::block_number(), + >::block_number(), )), gas_limit: T::BlockGasLimit::get(), gas_used: receipts @@ -291,7 +291,7 @@ impl Module { .into_iter() .fold(U256::zero(), |acc, r| acc + r.used_gas), timestamp: UniqueSaturatedInto::::unique_saturated_into( - pallet_timestamp::Module::::get(), + >::get(), ), extra_data: Vec::new(), mix_hash: H256::default(), @@ -309,7 +309,7 @@ impl Module { FRONTIER_ENGINE_ID, PostLog::Hashes(dp_consensus::Hashes::from_block(block)).encode(), ); - frame_system::Module::::deposit_log(digest.into()); + >::deposit_log(digest.into()); } } @@ -353,7 +353,7 @@ impl Module { fn do_transact(transaction: ethereum::Transaction) -> DispatchResultWithPostInfo { ensure!( - dp_consensus::find_pre_log(&frame_system::Module::::digest()).is_err(), + dp_consensus::find_pre_log(&>::digest()).is_err(), Error::::PreLogExists, ); let source = @@ -439,7 +439,7 @@ impl Module { /// Get the author using the FindAuthor trait. pub fn find_author() -> H160 { - let digest = >::digest(); + let digest = >::digest(); let pre_runtime_digests = digest.logs.iter().filter_map(|d| d.as_pre_runtime()); T::FindAuthor::find_author(pre_runtime_digests).unwrap_or_default() diff --git a/frame/dvm/src/mock.rs b/frame/dvm/src/mock.rs index ab21d1732a..a1d4ce1b89 100644 --- a/frame/dvm/src/mock.rs +++ b/frame/dvm/src/mock.rs @@ -177,12 +177,12 @@ frame_support::construct_runtime! { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage}, - Timestamp: pallet_timestamp::{Module, Call, Storage}, - Ring: darwinia_balances::::{Module, Call, Storage, Config}, - Kton: darwinia_balances::::{Module, Call, Storage}, - EVM: darwinia_evm::{Module, Call, Storage}, - Ethereum: dvm_ethereum::{Module, Call, Storage}, + System: frame_system::{Pallet, Call, Config, Storage}, + Timestamp: pallet_timestamp::{Pallet, Call, Storage}, + Ring: darwinia_balances::::{Pallet, Call, Storage, Config}, + Kton: darwinia_balances::::{Pallet, Call, Storage}, + EVM: darwinia_evm::{Pallet, Call, Storage}, + Ethereum: dvm_ethereum::{Pallet, Call, Storage}, } } diff --git a/frame/elections-phragmen/Cargo.toml b/frame/elections-phragmen/Cargo.toml index d6b866ff64..71e0ee4e29 100644 --- a/frame/elections-phragmen/Cargo.toml +++ b/frame/elections-phragmen/Cargo.toml @@ -17,11 +17,11 @@ serde = { version = "1.0.124", optional = true } # darwinia darwinia-support = { default-features = false, path = "../support" } # substrate -frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -frame-system = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-npos-elections = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +frame-system = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-npos-elections = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [dev-dependencies] # crates @@ -30,9 +30,9 @@ hex-literal = { version = "0.3.1" } darwinia-balances = { path = "../balances" } darwinia-support = { path = "../support", features = ["easy-testing"] } # substrate -sp-core = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-io = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -substrate-test-utils = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +sp-core = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-io = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +substrate-test-utils = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [features] default = ["std"] diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index 79887ec682..e2fdfa3553 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -1209,9 +1209,9 @@ mod tests { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic { - System: frame_system::{Module, Call, Event}, - Balances: darwinia_balances::::{Module, Call, Event, Config}, - Elections: elections_phragmen::{Module, Call, Event, Config}, + System: frame_system::{Pallet, Call, Event}, + Balances: darwinia_balances::::{Pallet, Call, Event, Config}, + Elections: elections_phragmen::{Pallet, Call, Event, Config}, } } diff --git a/frame/evm/Cargo.toml b/frame/evm/Cargo.toml index abf72d4867..5cb99746ab 100644 --- a/frame/evm/Cargo.toml +++ b/frame/evm/Cargo.toml @@ -24,13 +24,13 @@ sha3 = { version = "0.8", default-features = false } darwinia-balances = { default-features = false, path = "../balances" } dp-evm = { default-features = false, path = "../../primitives/evm" } # substrate -frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -frame-system = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -pallet-timestamp = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-core = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-io = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +frame-system = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +pallet-timestamp = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-core = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-io = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [dev-dependencies] darwinia-support = { features = ["easy-testing"], path = "../support" } diff --git a/frame/evm/precompile/contracts/blake2/Cargo.toml b/frame/evm/precompile/contracts/blake2/Cargo.toml index 4c1bee7b50..9cb84a69ef 100644 --- a/frame/evm/precompile/contracts/blake2/Cargo.toml +++ b/frame/evm/precompile/contracts/blake2/Cargo.toml @@ -15,8 +15,8 @@ version = "2.1.0" dp-evm = { default-features = false, path = "../../../../../primitives/evm" } evm = { version = "0.24.0", default-features = false, features = ["with-codec"] } # substrate -sp-core = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-io = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +sp-core = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-io = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [features] default = ["std"] diff --git a/frame/evm/precompile/contracts/bn128/Cargo.toml b/frame/evm/precompile/contracts/bn128/Cargo.toml index e6692292f0..9a95125a7a 100644 --- a/frame/evm/precompile/contracts/bn128/Cargo.toml +++ b/frame/evm/precompile/contracts/bn128/Cargo.toml @@ -16,8 +16,8 @@ bn = { package = "substrate-bn", version = "0.5", default-features = false } dp-evm = { default-features = false, path = "../../../../../primitives/evm" } evm = { version = "0.24.0", default-features = false, features = ["with-codec"] } # substrate -sp-core = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-io = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +sp-core = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-io = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [features] default = ["std"] diff --git a/frame/evm/precompile/contracts/dispatch/Cargo.toml b/frame/evm/precompile/contracts/dispatch/Cargo.toml index 1d055cfab9..55d62ebc03 100644 --- a/frame/evm/precompile/contracts/dispatch/Cargo.toml +++ b/frame/evm/precompile/contracts/dispatch/Cargo.toml @@ -17,9 +17,9 @@ darwinia-evm = { default-features = false, path = "../../../../evm" } dp-evm = { default-features = false, path = "../../../../../primitives/evm" } evm = { version = "0.24.0", default-features = false, features = ["with-codec"] } # substrate -frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-core = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-io = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-core = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-io = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [features] default = ["std"] diff --git a/frame/evm/precompile/contracts/ed25519/Cargo.toml b/frame/evm/precompile/contracts/ed25519/Cargo.toml index 80b3a55965..c9bfd05fd4 100644 --- a/frame/evm/precompile/contracts/ed25519/Cargo.toml +++ b/frame/evm/precompile/contracts/ed25519/Cargo.toml @@ -15,8 +15,8 @@ dp-evm = { default-features = false, path = "../../../../../primitives/ev ed25519-dalek = { version = "1.0.0", default-features = false, features = ["alloc", "u64_backend"] } evm = { version = "0.24.0", default-features = false, features = ["with-codec"] } # substrate -sp-core = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-io = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +sp-core = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-io = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [features] default = ["std"] diff --git a/frame/evm/precompile/contracts/kton/Cargo.toml b/frame/evm/precompile/contracts/kton/Cargo.toml index c12e8873b3..9cc48d5e41 100644 --- a/frame/evm/precompile/contracts/kton/Cargo.toml +++ b/frame/evm/precompile/contracts/kton/Cargo.toml @@ -23,13 +23,13 @@ darwinia-evm = { default-features = false, path = "../../../" } dp-evm = { default-features = false, path = "../../../../../primitives/evm" } ethabi = { default-features = false, git = "https://github.com/darwinia-network/ethabi.git", branch = "xavier-no-std" } # substrate -frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -frame-system = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -pallet-timestamp = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-core = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-io = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +frame-system = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +pallet-timestamp = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-core = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-io = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [features] default = ["std"] diff --git a/frame/evm/precompile/contracts/modexp/Cargo.toml b/frame/evm/precompile/contracts/modexp/Cargo.toml index 1e52ff4cbb..e6421126c6 100644 --- a/frame/evm/precompile/contracts/modexp/Cargo.toml +++ b/frame/evm/precompile/contracts/modexp/Cargo.toml @@ -16,8 +16,8 @@ dp-evm = { default-features = false, path = "../../../../../primitives/evm" } evm = { version = "0.24.0", default-features = false, features = ["with-codec"] } num = { version = "0.3", default-features = false, features = ["alloc"] } # substrate -sp-core = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-io = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +sp-core = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-io = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [dev-dependencies] hex = "0.4.0" diff --git a/frame/evm/precompile/contracts/sha3fips/Cargo.toml b/frame/evm/precompile/contracts/sha3fips/Cargo.toml index 4f08290671..a631ed22ec 100644 --- a/frame/evm/precompile/contracts/sha3fips/Cargo.toml +++ b/frame/evm/precompile/contracts/sha3fips/Cargo.toml @@ -17,8 +17,8 @@ evm = { version = "0.24.0", default-features = false, features = ["with-codec" tiny-keccak = { version = "2.0", features = ["fips202"] } # substrate -sp-core = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-io = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +sp-core = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-io = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [features] default = ["std"] diff --git a/frame/evm/precompile/contracts/simple/Cargo.toml b/frame/evm/precompile/contracts/simple/Cargo.toml index cc2e3347be..bbae1c6939 100644 --- a/frame/evm/precompile/contracts/simple/Cargo.toml +++ b/frame/evm/precompile/contracts/simple/Cargo.toml @@ -15,8 +15,8 @@ dp-evm = { default-features = false, path = "../../../../../primitives/evm" } evm = { version = "0.24.0", default-features = false, features = ["with-codec"] } ripemd160 = { version = "0.9", default-features = false } # substrate -sp-core = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-io = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +sp-core = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-io = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [features] default = ["std"] diff --git a/frame/evm/precompile/contracts/withdraw/Cargo.toml b/frame/evm/precompile/contracts/withdraw/Cargo.toml index 827f0e072a..0835c8c390 100644 --- a/frame/evm/precompile/contracts/withdraw/Cargo.toml +++ b/frame/evm/precompile/contracts/withdraw/Cargo.toml @@ -18,13 +18,13 @@ ripemd160 = { version = "0.9", default-features = false } darwinia-evm = { default-features = false, path = "../../../" } dp-evm = { default-features = false, path = "../../../../../primitives/evm" } # substrate -frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -frame-system = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -pallet-timestamp = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-core = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-io = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +frame-system = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +pallet-timestamp = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-core = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-io = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [features] default = ["std"] diff --git a/frame/evm/src/lib.rs b/frame/evm/src/lib.rs index 87b8e8fcb8..8326cbe293 100644 --- a/frame/evm/src/lib.rs +++ b/frame/evm/src/lib.rs @@ -209,7 +209,7 @@ impl AccountBasicMapping for RawAccountBasicMapping { fn account_basic(address: &H160) -> Account { let account_id = T::AddressMapping::into_account_id(*address); - let nonce = frame_system::Module::::account_nonce(&account_id); + let nonce = >::account_nonce(&account_id); let balance = T::RingCurrency::free_balance(&account_id); Account { @@ -226,7 +226,7 @@ impl AccountBasicMapping for RawAccountBasicMapping { // ASSUME: in one single EVM transaction, the nonce will not increase more than // `u128::max_value()`. for _ in 0..(new.nonce - current.nonce).low_u128() { - frame_system::Module::::inc_account_nonce(&account_id); + >::inc_account_nonce(&account_id); } } @@ -515,7 +515,7 @@ impl Module { fn remove_account(address: &H160) { if AccountCodes::contains_key(address) { let account_id = T::AddressMapping::into_account_id(*address); - let _ = frame_system::Module::::dec_consumers(&account_id); + let _ = >::dec_consumers(&account_id); } AccountCodes::remove(address); @@ -530,7 +530,7 @@ impl Module { if !AccountCodes::contains_key(&address) { let account_id = T::AddressMapping::into_account_id(address); - let _ = frame_system::Module::::inc_consumers(&account_id); + let _ = >::inc_consumers(&account_id); } AccountCodes::insert(address, code); diff --git a/frame/evm/src/runner/stack.rs b/frame/evm/src/runner/stack.rs index 4b8e6e0362..9bf35f067d 100644 --- a/frame/evm/src/runner/stack.rs +++ b/frame/evm/src/runner/stack.rs @@ -356,12 +356,12 @@ impl<'vicinity, 'config, T: Config> BackendT for SubstrateStackState<'vicinity, H256::default() } else { let number = T::BlockNumber::from(number.as_u32()); - H256::from_slice(frame_system::Module::::block_hash(number).as_ref()) + H256::from_slice(>::block_hash(number).as_ref()) } } fn block_number(&self) -> U256 { - let number: u128 = frame_system::Module::::block_number().unique_saturated_into(); + let number: u128 = >::block_number().unique_saturated_into(); U256::from(number) } @@ -370,7 +370,7 @@ impl<'vicinity, 'config, T: Config> BackendT for SubstrateStackState<'vicinity, } fn block_timestamp(&self) -> U256 { - let now: u128 = pallet_timestamp::Module::::get().unique_saturated_into(); + let now: u128 = >::get().unique_saturated_into(); U256::from(now / 1000) } @@ -449,7 +449,7 @@ impl<'vicinity, 'config, T: Config> StackStateT<'config> fn inc_nonce(&mut self, address: H160) { let account_id = T::AddressMapping::into_account_id(address); - frame_system::Module::::inc_account_nonce(&account_id); + >::inc_account_nonce(&account_id); } fn set_storage(&mut self, address: H160, index: H256, value: H256) { diff --git a/frame/evm/src/tests.rs b/frame/evm/src/tests.rs index f17b0af27a..a1b665b58f 100644 --- a/frame/evm/src/tests.rs +++ b/frame/evm/src/tests.rs @@ -111,11 +111,11 @@ frame_support::construct_runtime! { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - Timestamp: pallet_timestamp::{Module, Call, Storage}, - Ring: darwinia_balances::::{Module, Call, Storage, Config, Event}, - Kton: darwinia_balances::::{Module, Call, Storage, Config, Event}, - EVM: darwinia_evm::{Module, Call, Storage, Config, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Timestamp: pallet_timestamp::{Pallet, Call, Storage}, + Ring: darwinia_balances::::{Pallet, Call, Storage, Config, Event}, + Kton: darwinia_balances::::{Pallet, Call, Storage, Config, Event}, + EVM: darwinia_evm::{Pallet, Call, Storage, Config, Event}, } } diff --git a/frame/header-mmr/Cargo.toml b/frame/header-mmr/Cargo.toml index cd3325a67c..c7aa11e272 100644 --- a/frame/header-mmr/Cargo.toml +++ b/frame/header-mmr/Cargo.toml @@ -21,18 +21,18 @@ darwinia-support = { default-features = false, path = "../sup # github merkle-mountain-range = { package = "ckb-merkle-mountain-range", default-features = false, git = "https://github.com/darwinia-network/merkle-mountain-range.git" } # substrate -frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -frame-system = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +frame-system = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [dev-dependencies] # crates array-bytes = { version = "1.1.0" } serde_json = { version = "1.0.62" } # substrate -sp-core = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-io = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +sp-core = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-io = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [features] default = ["std"] diff --git a/frame/header-mmr/rpc/Cargo.toml b/frame/header-mmr/rpc/Cargo.toml index 1b28fc01f9..206c9e3c8c 100644 --- a/frame/header-mmr/rpc/Cargo.toml +++ b/frame/header-mmr/rpc/Cargo.toml @@ -18,6 +18,6 @@ jsonrpc-derive = { version = "15.1.0" } # darwinia darwinia-header-mmr-rpc-runtime-api = { path = "./runtime-api" } # substrate -sp-api = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-blockchain = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-runtime = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +sp-api = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-blockchain = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-runtime = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } diff --git a/frame/header-mmr/rpc/runtime-api/Cargo.toml b/frame/header-mmr/rpc/runtime-api/Cargo.toml index 5cea48caf4..7ffd4cc64e 100644 --- a/frame/header-mmr/rpc/runtime-api/Cargo.toml +++ b/frame/header-mmr/rpc/runtime-api/Cargo.toml @@ -16,9 +16,9 @@ serde = { version = "1.0.124", optional = true, features = ["derive"] } # darwinia darwinia-support = { default-features = false, path = "../../../support" } # substrate -sp-api = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +sp-api = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [features] default = ["std"] diff --git a/frame/header-mmr/src/lib.rs b/frame/header-mmr/src/lib.rs index 7bc8104609..12602d9d94 100644 --- a/frame/header-mmr/src/lib.rs +++ b/frame/header-mmr/src/lib.rs @@ -110,7 +110,7 @@ decl_module! { { fn on_finalize(_block_number: T::BlockNumber) { let store = >::default(); - let parent_hash = >::parent_hash(); + let parent_hash = >::parent_hash(); let mut mmr = , _>>::new(MMRCounter::get(), store); // Update MMR and add mmr root to digest of block header @@ -124,7 +124,7 @@ decl_module! { }; let mmr_item = DigestItem::Other(mmr_root_log.encode()); - >::deposit_log(mmr_item.into()); + >::deposit_log(mmr_item.into()); } else { log::error!("[darwinia-header-mmr] FAILED to Commit MMR"); } diff --git a/frame/header-mmr/src/mock.rs b/frame/header-mmr/src/mock.rs index 6e24b2c833..0d53fdf680 100644 --- a/frame/header-mmr/src/mock.rs +++ b/frame/header-mmr/src/mock.rs @@ -70,8 +70,8 @@ frame_support::construct_runtime! { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Storage, Config}, - HeaderMMR: darwinia_header_mmr::{Module, Call, Storage}, + System: frame_system::{Pallet, Call, Storage, Config}, + HeaderMMR: darwinia_header_mmr::{Pallet, Call, Storage}, } } diff --git a/frame/staking/Cargo.toml b/frame/staking/Cargo.toml index 8393c046ba..02bf1229fb 100644 --- a/frame/staking/Cargo.toml +++ b/frame/staking/Cargo.toml @@ -13,7 +13,7 @@ version = "2.1.0" # crates codec = { package = "parity-scale-codec", version = "2.0.1", default-features = false, features = ["derive"] } log = { version = "0.4.14" } -rand_chacha = { version = "0.2", default-features = false, optional = true } +paste = { version = "1.0.5" } serde = { version = "1.0.124", optional = true } static_assertions = { version = "1.1.0" } # darwinia @@ -22,31 +22,30 @@ darwinia-support = { default-features = false, path = "../suppor # github substrate-fixed = { default-features = false, git = "https://github.com/encointer/substrate-fixed", branch = "master" } # substrate -frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -frame-system = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -pallet-authorship = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -pallet-session = { default-features = false, features = ["historical"], git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-arithmetic = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-core = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-election-providers = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-io = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -# TWO_PHASE_NOTE:: ideally we should be able to get rid of this. -sp-npos-elections = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-staking = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +frame-election-provider-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +frame-system = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +pallet-authorship = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +pallet-session = { default-features = false, features = ["historical"], git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-arithmetic = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-core = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-io = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-npos-elections = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-staking = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [dev-dependencies] # crates -rand_chacha = { version = "0.2" } +rand_chacha = { version = "0.3.0" } # darwinia darwinia-balances = { path = "../../frame/balances" } darwinia-support = { features = ["easy-testing"], path = "../support" } # substrate -pallet-timestamp = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-storage = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-tracing = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -substrate-test-utils = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +pallet-timestamp = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-storage = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-tracing = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +substrate-test-utils = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [features] default = ["std"] @@ -68,13 +67,13 @@ darwinia-std = [ ] github-std = ["substrate-fixed/std"] substrate-std = [ + "frame-election-provider-support/std", "frame-support/std", "frame-system/std", "pallet-authorship/std", "pallet-session/std", "sp-arithmetic/std", "sp-core/std", - "sp-election-providers/std", "sp-io/std", "sp-npos-elections/std", "sp-runtime/std", diff --git a/frame/staking/rpc/Cargo.toml b/frame/staking/rpc/Cargo.toml index 325542655e..fbe7ce2423 100644 --- a/frame/staking/rpc/Cargo.toml +++ b/frame/staking/rpc/Cargo.toml @@ -18,6 +18,6 @@ jsonrpc-derive = { version = "15.1.0" } # darwinia darwinia-staking-rpc-runtime-api = { path = "./runtime-api" } # substrate -sp-api = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-blockchain = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-runtime = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +sp-api = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-blockchain = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-runtime = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } diff --git a/frame/staking/rpc/runtime-api/Cargo.toml b/frame/staking/rpc/runtime-api/Cargo.toml index 1364d5d508..06244073f2 100644 --- a/frame/staking/rpc/runtime-api/Cargo.toml +++ b/frame/staking/rpc/runtime-api/Cargo.toml @@ -16,8 +16,8 @@ serde = { version = "1.0.124", optional = true, features = ["derive"] } # darwinia darwinia-support = { default-features = false, path = "../../../support" } # substrate -sp-api = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +sp-api = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [features] default = ["std"] diff --git a/frame/staking/src/lib.rs b/frame/staking/src/lib.rs index 1dfee78bef..fba647647e 100644 --- a/frame/staking/src/lib.rs +++ b/frame/staking/src/lib.rs @@ -162,7 +162,7 @@ //! #[weight = 0] //! pub fn reward_myself(origin) -> dispatch::DispatchResult { //! let reported = ensure_signed(origin)?; -//! >::reward_by_ids(vec![(reported, 10)]); +//! >::reward_by_ids(vec![(reported, 10)]); //! Ok(()) //! } //! } @@ -269,9 +269,6 @@ #![feature(drain_filter)] #![recursion_limit = "128"] -// TODO: offchain phragmen test https://github.com/darwinia-network/darwinia-common/issues/97 -// #[cfg(features = "testing-utils")] -// pub mod testing_utils; #[cfg(test)] mod darwinia_tests; #[cfg(test)] @@ -286,9 +283,83 @@ pub mod weights; pub use weights::WeightInfo; pub mod inflation; -pub mod offchain_election; pub mod slashing; +pub mod migrations { + use super::*; + + pub mod v6 { + use super::*; + use frame_support::{pallet_prelude::*, traits::Get, weights::Weight}; + + macro_rules! generate_storage_types { + ($name:ident => Value<$value:ty>) => { + paste::paste! { + struct [<$name Instance>]; + impl frame_support::traits::StorageInstance for [<$name Instance>] { + fn pallet_prefix() -> &'static str { + "DarwiniaStaking" + } + const STORAGE_PREFIX: &'static str = stringify!($name); + } + type $name = StorageValue<[<$name Instance>], $value, ValueQuery>; + } + }; + } + + // NOTE: value type doesn't matter, we just set it to () here. + generate_storage_types!(SnapshotValidators => Value<()>); + generate_storage_types!(SnapshotNominators => Value<()>); + generate_storage_types!(QueuedElected => Value<()>); + generate_storage_types!(QueuedScore => Value<()>); + generate_storage_types!(EraElectionStatus => Value<()>); + generate_storage_types!(IsCurrentSessionFinal => Value<()>); + + /// check to execute prior to migration. + pub fn pre_migrate() -> Result<(), &'static str> { + // these may or may not exist. + log!( + info, + "SnapshotValidators.exits()? {:?}", + SnapshotValidators::exists() + ); + log!( + info, + "SnapshotNominators.exits()? {:?}", + SnapshotNominators::exists() + ); + log!(info, "QueuedElected.exits()? {:?}", QueuedElected::exists()); + log!(info, "QueuedScore.exits()? {:?}", QueuedScore::exists()); + // these must exist. + assert!( + IsCurrentSessionFinal::exists(), + "IsCurrentSessionFinal storage item not found!" + ); + assert!( + EraElectionStatus::exists(), + "EraElectionStatus storage item not found!" + ); + Ok(()) + } + + /// Migrate storage to v6. + pub fn migrate() -> Weight { + log!(info, "Migrating staking to Releases::V6_0_0"); + + SnapshotValidators::kill(); + SnapshotNominators::kill(); + QueuedElected::kill(); + QueuedScore::kill(); + EraElectionStatus::kill(); + IsCurrentSessionFinal::kill(); + + StorageVersion::put(Releases::V6_0_0); + log!(info, "Done."); + T::DbWeight::get().writes(6 + 1) + } + } +} + mod types { // --- darwinia --- use crate::*; @@ -309,12 +380,10 @@ mod types { static_assertions::const_assert!(size_of::() <= size_of::()); // Note: Maximum nomination limit is set here -- 16. - generate_solution_type!( + sp_npos_elections::generate_solution_type!( #[compact] pub struct CompactAssignments::(16) ); - /// Accuracy used for on-chain election. - pub type ChainAccuracy = Perbill; /// Accuracy used for off-chain election. This better be small. pub type OffchainAccuracy = PerU16; @@ -349,7 +418,6 @@ mod types { pub type StakingBalanceT = StakingBalance, KtonBalance>; pub type ExposureT = Exposure, RingBalance, KtonBalance>; - pub type ElectionResultT = ElectionResult, RingBalance, KtonBalance>; type RingCurrency = ::RingCurrency; type KtonCurrency = ::KtonCurrency; @@ -361,36 +429,30 @@ pub use types::{CompactAssignments, EraIndex}; // --- crates --- use codec::{Decode, Encode, HasCompact}; // --- substrate --- +use frame_election_provider_support::{ + data_provider, ElectionDataProvider, ElectionProvider, VoteWeight, +}; use frame_support::{ decl_error, decl_event, decl_module, decl_storage, - dispatch::{DispatchErrorWithPostInfo, DispatchResultWithPostInfo, WithPostDispatchInfo}, + dispatch::DispatchResultWithPostInfo, ensure, storage::IterableStorageMap, traits::{ Currency, EnsureOrigin, EstimateNextNewSession, ExistenceRequirement::KeepAlive, Get, - Imbalance, IsSubType, OnUnbalanced, UnixTime, + Imbalance, OnUnbalanced, UnixTime, }, weights::{ constants::{WEIGHT_PER_MICROS, WEIGHT_PER_NANOS}, Weight, }, }; -use frame_system::{ensure_none, ensure_root, ensure_signed, offchain::SendTransactionTypes}; -use sp_election_providers::ElectionProvider; -use sp_npos_elections::{ - generate_solution_type, is_score_better, seq_phragmen, to_supports, Assignment, - CompactSolution, ElectionResult as PrimitiveElectionResult, ElectionScore, EvaluateSupport, - ExtendedBalance, PerThing128, Supports, VoteWeight, -}; +use frame_system::{ensure_root, ensure_signed, offchain::SendTransactionTypes}; +use sp_npos_elections::{CompactSolution, Supports}; use sp_runtime::{ - helpers_128bit::multiply_by_rational, + helpers_128bit, traits::{ - AccountIdConversion, AtLeast32BitUnsigned, CheckedSub, Convert, Dispatchable, - SaturatedConversion, Saturating, StaticLookup, Zero, - }, - transaction_validity::{ - InvalidTransaction, TransactionPriority, TransactionSource, TransactionValidity, - TransactionValidityError, ValidTransaction, + AccountIdConversion, AtLeast32BitUnsigned, CheckedSub, Convert, SaturatedConversion, + Saturating, StaticLookup, Zero, }, DispatchError, DispatchResult, ModuleId, PerU16, Perbill, Percent, Perquintill, RuntimeDebug, }; @@ -423,18 +485,15 @@ macro_rules! log { ($level:tt, $patter:expr $(, $values:expr)* $(,)?) => { log::$level!( target: crate::LOG_TARGET, - concat!("💸 ", $patter) $(, $values)* + concat!("[{:?}] 💸 ", $patter), >::block_number() $(, $values)* ) }; } +/// Maximum number of stakers that can be stored in a snapshot. pub const MAX_NOMINATIONS: usize = ::LIMIT; pub const MAX_UNLOCKING_CHUNKS: usize = 32; -/// Maximum number of stakers that can be stored in a snapshot. -pub(crate) const MAX_VALIDATORS: usize = ValidatorIndex::max_value() as usize; -pub(crate) const MAX_NOMINATORS: usize = NominatorIndex::max_value() as usize; - const MONTH_IN_MINUTES: TsInMs = 30 * 24 * 60; const MONTH_IN_MILLISECONDS: TsInMs = MONTH_IN_MINUTES * 60 * 1000; const STAKING_ID: LockIdentifier = *b"da/staki"; @@ -452,7 +511,7 @@ pub trait Config: frame_system::Config + SendTransactionTypes> { type UnixTime: UnixTime; /// Something that provides the election functionality. - type ElectionProvider: sp_election_providers::ElectionProvider< + type ElectionProvider: ElectionProvider< Self::AccountId, Self::BlockNumber, // we only accept an election provider that has staking as data provider. @@ -482,45 +541,12 @@ pub trait Config: frame_system::Config + SendTransactionTypes> { /// Something that can estimate the next session change, accurately or as a best effort guess. type NextNewSession: EstimateNextNewSession; - /// The number of blocks before the end of the era from which election submissions are allowed. - /// - /// Setting this to zero will disable the offchain compute and only on-chain seq-phragmen will - /// be used. - /// - /// This is bounded by being within the last session. Hence, setting it to a value more than the - /// length of a session will be pointless. - type ElectionLookahead: Get; - - /// The overarching call type. - type Call: Dispatchable + From> + IsSubType> + Clone; - - /// Maximum number of balancing iterations to run in the offchain submission. - /// - /// If set to 0, balance_solution will not be executed at all. - type MaxIterations: Get; - - /// The threshold of improvement that should be provided for a new solution to be accepted. - type MinSolutionScoreBump: Get; - /// The maximum number of nominators rewarded for each validator. /// /// For each validator only the `$MaxNominatorRewardedPerValidator` biggest stakers can claim /// their reward. This used to limit the i/o cost for the nominator payout. type MaxNominatorRewardedPerValidator: Get; - /// A configuration for base priority of unsigned transactions. - /// - /// This is exposed so that it can be tuned for particular runtime, when - /// multiple pallets send unsigned transactions. - type UnsignedPriority: Get; - - /// Maximum weight that the unsigned transaction can have. - /// - /// Chose this value with care. On one hand, it should be as high as possible, so the solution - /// can contain as many nominators/validators as possible. On the other hand, it should be small - /// enough to fit in the block. - type OffchainSolutionWeightLimit: Get; - /// The *RING* currency. type RingCurrency: LockableCurrency; /// Tokens have been minted and are unused for validator-reward. @@ -575,15 +601,15 @@ where T::ValidatorIdOf: Convert, Option>>, { fn disable_validator(validator: &AccountId) -> Result { - >::disable(validator) + >::disable(validator) } fn validators() -> Vec> { - >::validators() + >::validators() } fn prune_historical_up_to(up_to: SessionIndex) { - >::prune_up_to(up_to); + >::prune_up_to(up_to); } } @@ -610,11 +636,8 @@ decl_event!( /// not be processed. [session_index] OldSlashingReportDiscarded(SessionIndex), - /// A new set of stakers was elected with the given [compute]. - StakingElection(ElectionCompute), - - /// A new solution for the upcoming election has been stored. [compute] - SolutionStored(ElectionCompute), + /// A new set of stakers was elected. + StakingElection, /// An account has bonded this amount. [amount, start, end] /// @@ -675,37 +698,6 @@ decl_error! { NotSortedAndUnique, /// Rewards for this era have already been claimed for this validator. AlreadyClaimed, - /// The submitted result is received out of the open window. - OffchainElectionEarlySubmission, - /// The submitted result is not as good as the one stored on chain. - OffchainElectionWeakSubmission, - /// The snapshot data of the current window is missing. - SnapshotUnavailable, - /// Incorrect number of winners were presented. - OffchainElectionBogusWinnerCount, - /// One of the submitted winners is not an active candidate on chain (index is out of range - /// in snapshot). - OffchainElectionBogusWinner, - /// Error while building the assignment type from the compact. This can happen if an index - /// is invalid, or if the weights _overflow_. - OffchainElectionBogusCompact, - /// One of the submitted nominators is not an active nominator on chain. - OffchainElectionBogusNominator, - /// One of the submitted nominators has an edge to which they have not voted on chain. - OffchainElectionBogusNomination, - /// One of the submitted nominators has an edge which is submitted before the last non-zero - /// slash of the target. - OffchainElectionSlashedNomination, - /// A self vote must only be originated from a validator to ONLY themselves. - OffchainElectionBogusSelfVote, - /// The submitted result has unknown edges that are not among the presented winners. - OffchainElectionBogusEdge, - /// The claimed score does not match with the one computed from the data. - OffchainElectionBogusScore, - /// The election size is invalid. - OffchainElectionBogusElectionSize, - /// The call is not allowed at the given time due to restrictions of election period. - CallNotAllowed, /// Incorrect previous history depth input provided. IncorrectHistoryDepth, /// Incorrect number of slashing spans provided. @@ -892,44 +884,8 @@ decl_storage! { /// This is basically in sync with the call to [`SessionManager::new_session`]. pub CurrentPlannedSession get(fn current_planned_session): SessionIndex; - /// Snapshot of validators at the beginning of the current election window. This should only - /// have a value when [`EraElectionStatus`] == `ElectionStatus::Open(_)`. - /// - /// TWO_PHASE_NOTE: should be removed once we switch to multi-phase. - pub SnapshotValidators get(fn snapshot_validators): Option>; - - /// Snapshot of nominators at the beginning of the current election window. This should only - /// have a value when [`EraElectionStatus`] == `ElectionStatus::Open(_)`. - /// - /// TWO_PHASE_NOTE: should be removed once we switch to multi-phase. - pub SnapshotNominators get(fn snapshot_nominators): Option>; - - /// The next validator set. At the end of an era, if this is available (potentially from the - /// result of an offchain worker), it is immediately used. Otherwise, the on-chain election - /// is executed. - /// - /// TWO_PHASE_NOTE: should be removed once we switch to multi-phase. - pub QueuedElected get(fn queued_elected): Option>; - - /// The score of the current [`QueuedElected`]. - /// - /// TWO_PHASE_NOTE: should be removed once we switch to multi-phase. - pub QueuedScore get(fn queued_score): Option; - - /// Flag to control the execution of the offchain election. When `Open(_)`, we accept - /// solutions to be submitted. - /// - /// TWO_PHASE_NOTE: should be removed once we switch to multi-phase. - pub EraElectionStatus get(fn era_election_status): ElectionStatus; - - /// True if the current **planned** session is final. Note that this does not take era - /// forcing into account. - /// - /// TWO_PHASE_NOTE: should be removed once we switch to multi-phase. - pub IsCurrentSessionFinal get(fn is_current_session_final): bool = false; - - /// This is set to v5.0.0 for new networks. - StorageVersion build(|_: &GenesisConfig| Releases::V5_0_0): Releases; + /// This is set to v6.0.0 for new networks. + StorageVersion build(|_: &GenesisConfig| Releases::V6_0_0): Releases; /// The chain's running time form genesis in milliseconds, /// use for calculate darwinia era payout @@ -1009,23 +965,6 @@ decl_module! { /// intervention. const SlashDeferDuration: EraIndex = T::SlashDeferDuration::get(); - /// The number of blocks before the end of the era from which election submissions are allowed. - /// - /// Setting this to zero will disable the offchain compute and only on-chain seq-phragmen will - /// be used. - /// - /// This is bounded by being within the last session. Hence, setting it to a value more than the - /// length of a session will be pointless. - const ElectionLookahead: T::BlockNumber = T::ElectionLookahead::get(); - - /// Maximum number of balancing iterations to run in the offchain submission. - /// - /// If set to 0, balance_solution will not be executed at all. - const MaxIterations: u32 = T::MaxIterations::get(); - - /// The threshold of improvement that should be provided for a new solution to be accepted. - const MinSolutionScoreBump: Perbill = T::MinSolutionScoreBump::get(); - /// The maximum number of nominators rewarded for each validator. /// /// For each validator only the `$MaxNominatorRewardedPerValidator` biggest stakers can claim @@ -1040,73 +979,11 @@ decl_module! { fn deposit_event() = default; - /// sets `ElectionStatus` to `Open(now)` where `now` is the block number at which the - /// election window has opened, if we are at the last session and less blocks than - /// `T::ElectionLookahead` is remaining until the next new session schedule. The offchain - /// worker, if applicable, will execute at the end of the current block, and solutions may - /// be submitted. - fn on_initialize(now: T::BlockNumber) -> Weight { - let mut consumed_weight = 0; - let mut add_weight = |reads, writes, weight| { - consumed_weight += T::DbWeight::get().reads_writes(reads, writes); - consumed_weight += weight; - }; - if - // if we don't have any ongoing offchain compute. - Self::era_election_status().is_closed() && - // either current session final based on the plan, or we're forcing. - (Self::is_current_session_final() || Self::will_era_be_forced()) - { - if let Some(next_session_change) = T::NextNewSession::estimate_next_new_session(now) { - if let Some(remaining) = next_session_change.checked_sub(&now) { - if remaining <= T::ElectionLookahead::get() && !remaining.is_zero() { - // create snapshot. - let (did_snapshot, snapshot_weight) = Self::create_stakers_snapshot(); - add_weight(0, 0, snapshot_weight); - if did_snapshot { - // Set the flag to make sure we don't waste any compute here in the same era - // after we have triggered the offline compute. - >::put( - ElectionStatus::::Open(now) - ); - add_weight(0, 1, 0); - log!(info, "Election window is Open({:?}). Snapshot created", now); - } else { - log!(warn, "Failed to create snapshot at {:?}.", now); - } - } - } - } else { - log!(warn, "Estimating next session change failed."); - } - add_weight(0, 0, T::NextNewSession::weight(now)) - } - - // For `era_election_status`, `is_current_session_final`, `will_era_be_forced` - add_weight(3, 0, 0); - // Additional read from `on_finalize` - add_weight(1, 0, 0); - consumed_weight - } - - /// Check if the current block number is the one at which the election window has been set - /// to open. If so, it runs the offchain worker code. - fn offchain_worker(now: T::BlockNumber) { - // --- darwinia --- - use offchain_election::{set_check_offchain_execution_status, compute_offchain_election}; - - if Self::era_election_status().is_open_at(now) { - let offchain_status = set_check_offchain_execution_status::(now); - if let Err(why) = offchain_status { - log!(warn, "skipping offchain worker in open election window due to [{}]", why); - } else { - if let Err(e) = compute_offchain_election::() { - log!(error, "Error in election offchain worker: {:?}", e); - } else { - log!(debug, "Executed offchain worker thread without errors."); - } - } - + fn on_runtime_upgrade() -> Weight { + if StorageVersion::get() == Releases::V5_0_0 { + migrations::v6::migrate::() + } else { + T::DbWeight::get().reads(1) } } @@ -1137,17 +1014,7 @@ decl_module! { ); use sp_runtime::UpperOf; - // see the documentation of `Assignment::try_normalize`. Now we can ensure that this - // will always return `Ok`. - // 1. Maximum sum of Vec must fit into `UpperOf`. - assert!( - >>::try_into(MAX_NOMINATIONS) - .unwrap() - .checked_mul(::one().deconstruct().try_into().unwrap()) - .is_some() - ); - - // 2. Maximum sum of Vec must fit into `UpperOf`. + // 1. Maximum sum of Vec must fit into `UpperOf`. assert!( >>::try_into(MAX_NOMINATIONS) .unwrap() @@ -1207,7 +1074,7 @@ decl_module! { } } - >::inc_consumers(&stash).map_err(|_| Error::::BadState)?; + >::inc_consumers(&stash).map_err(|_| Error::::BadState)?; // You're auto-bonded forever, here. We might improve this by only bonding when // you actually validate/nominate and remove once you unbond __everything__. @@ -1272,8 +1139,6 @@ decl_module! { /// # #[weight = T::WeightInfo::bond_extra()] fn bond_extra(origin, max_additional: StakingBalanceT, promise_month: u8) { - ensure!(Self::era_election_status().is_closed(), >::CallNotAllowed); - let stash = ensure_signed(origin)?; let controller = Self::bonded(&stash).ok_or(>::NotStash)?; let ledger = Self::ledger(&controller).ok_or(>::NotController)?; @@ -1284,7 +1149,7 @@ decl_module! { let stash_balance = T::RingCurrency::free_balance(&stash); if let Some(extra) = stash_balance.checked_sub( - &ledger.ring_locked_amount_at(>::block_number()) + &ledger.ring_locked_amount_at(>::block_number()) ) { let extra = extra.min(max_additional); let (start_time, expire_time) = Self::bond_ring( @@ -1302,7 +1167,7 @@ decl_module! { let stash_balance = T::KtonCurrency::free_balance(&stash); if let Some(extra) = stash_balance.checked_sub( - &ledger.kton_locked_amount_at(>::block_number()) + &ledger.kton_locked_amount_at(>::block_number()) ) { let extra = extra.min(max_additional); @@ -1402,8 +1267,6 @@ decl_module! { /// #[weight = T::WeightInfo::unbond()] fn unbond(origin, value: StakingBalanceT) { - ensure!(Self::era_election_status().is_closed(), >::CallNotAllowed); - let controller = ensure_signed(origin)?; let mut ledger = Self::clear_mature_deposits( Self::ledger(&controller).ok_or(>::NotController)? @@ -1416,7 +1279,7 @@ decl_module! { kton_staking_lock, .. } = &mut ledger; - let now = >::block_number(); + let now = >::block_number(); ring_staking_lock.update(now); kton_staking_lock.update(now); @@ -1679,8 +1542,6 @@ decl_module! { /// # #[weight = T::WeightInfo::validate()] fn validate(origin, prefs: ValidatorPrefs) { - ensure!(Self::era_election_status().is_closed(), >::CallNotAllowed); - let controller = ensure_signed(origin)?; let ledger = Self::ledger(&controller).ok_or(>::NotController)?; let stash = &ledger.stash; @@ -1710,8 +1571,6 @@ decl_module! { /// # #[weight = T::WeightInfo::nominate(targets.len() as u32)] fn nominate(origin, targets: Vec<::Source>) { - ensure!(Self::era_election_status().is_closed(), >::CallNotAllowed); - let controller = ensure_signed(origin)?; let ledger = Self::ledger(&controller).ok_or(>::NotController)?; let stash = &ledger.stash; @@ -1759,8 +1618,6 @@ decl_module! { /// # #[weight = T::WeightInfo::chill()] fn chill(origin) { - ensure!(Self::era_election_status().is_closed(), >::CallNotAllowed); - let controller = ensure_signed(origin)?; let ledger = Self::ledger(&controller).ok_or(>::NotController)?; @@ -2009,8 +1866,6 @@ decl_module! { /// # #[weight = T::WeightInfo::payout_stakers_alive_staked(T::MaxNominatorRewardedPerValidator::get())] fn payout_stakers(origin, validator_stash: T::AccountId, era: EraIndex) -> DispatchResult { - ensure!(Self::era_election_status().is_closed(), >::CallNotAllowed); - ensure_signed(origin)?; Self::do_payout_stakers(validator_stash, era) } @@ -2035,11 +1890,9 @@ decl_module! { #[compact] plan_to_rebond_ring: RingBalance, #[compact] plan_to_rebond_kton: KtonBalance ) -> DispatchResultWithPostInfo { - ensure!(Self::era_election_status().is_closed(), >::CallNotAllowed); - let controller = ensure_signed(origin)?; let mut ledger = Self::ledger(&controller).ok_or(>::NotController)?; - let now = >::block_number(); + let now = >::block_number(); ledger.ring_staking_lock.update(now); ledger.kton_staking_lock.update(now); @@ -2164,121 +2017,6 @@ decl_module! { T::KtonCurrency::remove_lock(STAKING_ID, &stash); } - /// Submit an election result to the chain. If the solution: - /// - /// 1. is valid. - /// 2. has a better score than a potentially existing solution on chain. - /// - /// then, it will be _put_ on chain. - /// - /// A solution consists of two pieces of data: - /// - /// 1. `winners`: a flat vector of all the winners of the round. - /// 2. `assignments`: the compact version of an assignment vector that encodes the edge - /// weights. - /// - /// Both of which may be computed using _phragmen_, or any other algorithm. - /// - /// Additionally, the submitter must provide: - /// - /// - The `score` that they claim their solution has. - /// - /// Both validators and nominators will be represented by indices in the solution. The - /// indices should respect the corresponding types ([`ValidatorIndex`] and - /// [`NominatorIndex`]). Moreover, they should be valid when used to index into - /// [`SnapshotValidators`] and [`SnapshotNominators`]. Any invalid index will cause the - /// solution to be rejected. These two storage items are set during the election window and - /// may be used to determine the indices. - /// - /// A solution is valid if: - /// - /// 0. It is submitted when [`EraElectionStatus`] is `Open`. - /// 1. Its claimed score is equal to the score computed on-chain. - /// 2. Presents the correct number of winners. - /// 3. All indexes must be value according to the snapshot vectors. All edge values must - /// also be correct and should not overflow the granularity of the ratio type (i.e. 256 - /// or billion). - /// 4. For each edge, all targets are actually nominated by the voter. - /// 5. Has correct self-votes. - /// - /// A solutions score is consisted of 3 parameters: - /// - /// 1. `min { support.total }` for each support of a winner. This value should be maximized. - /// 2. `sum { support.total }` for each support of a winner. This value should be minimized. - /// 3. `sum { support.total^2 }` for each support of a winner. This value should be - /// minimized (to ensure less variance) - /// - /// # - /// The transaction is assumed to be the longest path, a better solution. - /// - Initial solution is almost the same. - /// - Worse solution is retraced in pre-dispatch-checks which sets its own weight. - /// # - #[weight = T::WeightInfo::submit_solution_better( - size.validators.into(), - size.nominators.into(), - compact.voter_count() as u32, - winners.len() as u32, - )] - pub fn submit_election_solution( - origin, - winners: Vec, - compact: CompactAssignments, - score: ElectionScore, - era: EraIndex, - size: ElectionSize, - ) -> DispatchResultWithPostInfo { - let _who = ensure_signed(origin)?; - Self::check_and_replace_solution( - winners, - compact, - ElectionCompute::Signed, - score, - era, - size, - ) - } - - /// Unsigned version of `submit_election_solution`. - /// - /// Note that this must pass the [`ValidateUnsigned`] check which only allows transactions - /// from the local node to be included. In other words, only the block author can include a - /// transaction in the block. - /// - /// # - /// See [`submit_election_solution`]. - /// # - #[weight = T::WeightInfo::submit_solution_better( - size.validators.into(), - size.nominators.into(), - compact.voter_count() as u32, - winners.len() as u32, - )] - pub fn submit_election_solution_unsigned( - origin, - winners: Vec, - compact: CompactAssignments, - score: ElectionScore, - era: EraIndex, - size: ElectionSize, - ) -> DispatchResultWithPostInfo { - ensure_none(origin)?; - let adjustments = Self::check_and_replace_solution( - winners, - compact, - ElectionCompute::Unsigned, - score, - era, - size, - ).expect( - "An unsigned solution can only be submitted by validators; A validator should \ - always produce correct solutions, else this block should not be imported, thus \ - effectively depriving the validators from their authoring reward. Hence, this panic - is expected." - ); - - Ok(adjustments) - } - /// Remove the given nominations from the calling validator. /// /// Effects will be felt at the beginning of the next era. @@ -2295,7 +2033,6 @@ decl_module! { #[weight = T::WeightInfo::kick(who.len() as u32)] pub fn kick(origin, who: Vec<::Source>) -> DispatchResult { let controller = ensure_signed(origin)?; - ensure!(Self::era_election_status().is_closed(), >::CallNotAllowed); let ledger = Self::ledger(&controller).ok_or(>::NotController)?; let stash = &ledger.stash; @@ -2425,7 +2162,7 @@ impl Module { // For *RING* power = ring_ratio * POWER_COUNT / 2 // For *KTON* power = kton_ratio * POWER_COUNT / 2 pub fn currency_to_power>(active: S, pool: S) -> Power { - (Perquintill::from_rational_approximation( + (Perquintill::from_rational( active.saturated_into::(), pool.saturated_into::().max(1), ) * (T::TotalPower::get() as Balance / 2)) as _ @@ -2459,51 +2196,6 @@ impl Module { .unwrap_or_default() } - /// Dump the list of validators and nominators into vectors and keep them on-chain. - /// - /// This data is used to efficiently evaluate election results. returns `true` if the operation - /// is successful. - pub fn create_stakers_snapshot() -> (bool, Weight) { - let mut consumed_weight = 0; - let mut add_db_reads_writes = |reads, writes| { - consumed_weight += T::DbWeight::get().reads_writes(reads, writes); - }; - let validators = >::iter().map(|(v, _)| v).collect::>(); - let mut nominators = >::iter().map(|(n, _)| n).collect::>(); - - let num_validators = validators.len(); - let num_nominators = nominators.len(); - add_db_reads_writes((num_validators + num_nominators) as Weight, 0); - - if num_validators > MAX_VALIDATORS - || num_nominators.saturating_add(num_validators) > MAX_NOMINATORS - { - log!( - warn, - "Snapshot size too big [{} <> {}][{} <> {}].", - num_validators, - MAX_VALIDATORS, - num_nominators, - MAX_NOMINATORS, - ); - (false, consumed_weight) - } else { - // all validators nominate themselves; - nominators.extend(validators.clone()); - - >::put(validators); - >::put(nominators); - add_db_reads_writes(0, 2); - (true, consumed_weight) - } - } - - /// Clears both snapshots of stakers. - fn kill_stakers_snapshot() { - >::kill(); - >::kill(); - } - fn do_payout_stakers(validator_stash: T::AccountId, era: EraIndex) -> DispatchResult { // Validate input data let current_era = CurrentEra::get().ok_or(>::InvalidEraToReward)?; @@ -2559,7 +2251,7 @@ impl Module { // This is the fraction of the total reward that the validator and the // nominators will get. let validator_total_reward_part = - Perbill::from_rational_approximation(validator_reward_points, total_reward_points); + Perbill::from_rational(validator_reward_points, total_reward_points); // This is how much validator + nominators are entitled to. let validator_total_payout = validator_total_reward_part * era_payout; @@ -2579,7 +2271,7 @@ impl Module { let validator_leftover_payout = validator_total_payout - validator_commission_payout; // Now let's calculate how this is split to the validator. let validator_exposure_part = - Perbill::from_rational_approximation(exposure.own_power, exposure.total_power); + Perbill::from_rational(exposure.own_power, exposure.total_power); let validator_staking_payout = validator_exposure_part * validator_leftover_payout; // Due to the `payout * percent` there might be some losses @@ -2601,7 +2293,7 @@ impl Module { // Reward only the clipped exposures. Note this is not necessarily sorted. for nominator in exposure.others.iter() { let nominator_exposure_part = - Perbill::from_rational_approximation(nominator.power, exposure.total_power); + Perbill::from_rational(nominator.power, exposure.total_power); let nominator_reward: RingBalance = nominator_exposure_part * validator_leftover_payout; @@ -2719,6 +2411,7 @@ impl Module { RewardDestination::Account(dest_account) => { Some(T::RingCurrency::deposit_creating(&dest_account, amount)) } + RewardDestination::None => None, } } @@ -2738,18 +2431,15 @@ impl Module { .unwrap_or(0); // Must never happen. match ForceEra::get() { + // Will set to default again, which is `NotForcing`. Forcing::ForceNew => ForceEra::kill(), + // Short circuit to `new_era`. Forcing::ForceAlways => (), + // Only go to `new_era` if deadline reached. Forcing::NotForcing if era_length >= T::SessionsPerEra::get() => (), _ => { - // Either `ForceNone`, or `NotForcing && era_length < T::SessionsPerEra::get()`. - if era_length + 1 == T::SessionsPerEra::get() { - IsCurrentSessionFinal::put(true); - } else if era_length >= T::SessionsPerEra::get() { - // Should only happen when we are ready to trigger an era but we have ForceNone, - // otherwise previous arm would short circuit. - Self::close_election_window(); - } + // either `Forcing::ForceNone`, + // or `Forcing::NotForcing if era_length >= T::SessionsPerEra::get()`. return None; } } @@ -2758,237 +2448,11 @@ impl Module { Self::new_era(session_index) } else { // Set initial era + log!(debug, "Starting the first era."); Self::new_era(session_index) } } - /// Basic and cheap checks that we perform in validate unsigned, and in the execution. - /// - /// State reads: ElectionState, CurrentEr, QueuedScore. - /// - /// This function does weight refund in case of errors, which is based upon the fact that it is - /// called at the very beginning of the call site's function. - pub fn pre_dispatch_checks(score: ElectionScore, era: EraIndex) -> DispatchResultWithPostInfo { - // discard solutions that are not in-time - // check window open - ensure!( - Self::era_election_status().is_open(), - >::OffchainElectionEarlySubmission.with_weight(T::DbWeight::get().reads(1)), - ); - - // check current era. - if let Some(current_era) = Self::current_era() { - ensure!( - current_era == era, - >::OffchainElectionEarlySubmission - .with_weight(T::DbWeight::get().reads(2)), - ) - } - - // assume the given score is valid. Is it better than what we have on-chain, if we have any? - if let Some(queued_score) = Self::queued_score() { - ensure!( - is_score_better(score, queued_score, T::MinSolutionScoreBump::get()), - >::OffchainElectionWeakSubmission.with_weight(T::DbWeight::get().reads(3)), - ) - } - - Ok(None.into()) - } - - /// Checks a given solution and if correct and improved, writes it on chain as the queued result - /// of the next round. This may be called by both a signed and an unsigned transaction. - pub fn check_and_replace_solution( - winners: Vec, - compact_assignments: CompactAssignments, - compute: ElectionCompute, - claimed_score: ElectionScore, - era: EraIndex, - election_size: ElectionSize, - ) -> DispatchResultWithPostInfo { - // Do the basic checks. era, claimed score and window open. - let _ = Self::pre_dispatch_checks(claimed_score, era)?; - - // before we read any further state, we check that the unique targets in compact is same as - // compact. is a all in-memory check and easy to do. Moreover, it ensures that the solution - // is not full of bogus edges that can cause lots of reads to SlashingSpans. Thus, we can - // assume that the storage access of this function is always O(|winners|), not - // O(|compact.edge_count()|). - ensure!( - compact_assignments.unique_targets().len() == winners.len(), - >::OffchainElectionBogusWinnerCount, - ); - - // Check that the number of presented winners is sane. Most often we have more candidates - // than we need. Then it should be `Self::validator_count()`. Else it should be all the - // candidates. - let snapshot_validators_length = >::decode_len() - .map(|l| l as u32) - .ok_or_else(|| >::SnapshotUnavailable)?; - - // size of the solution must be correct. - ensure!( - snapshot_validators_length == u32::from(election_size.validators), - >::OffchainElectionBogusElectionSize, - ); - - // check the winner length only here and when we know the length of the snapshot validators - // length. - let desired_winners = Self::validator_count().min(snapshot_validators_length); - ensure!( - winners.len() as u32 == desired_winners, - >::OffchainElectionBogusWinnerCount - ); - - let snapshot_nominators_len = >::decode_len() - .map(|l| l as u32) - .ok_or_else(|| >::SnapshotUnavailable)?; - - // rest of the size of the solution must be correct. - ensure!( - snapshot_nominators_len == election_size.nominators, - >::OffchainElectionBogusElectionSize, - ); - - // decode snapshot validators. - let snapshot_validators = - Self::snapshot_validators().ok_or(>::SnapshotUnavailable)?; - - // check if all winners were legit; this is rather cheap. Replace with accountId. - let winners = winners - .into_iter() - .map(|widx| { - // NOTE: at the moment, since staking is explicitly blocking any offence until election - // is closed, we don't check here if the account id at `snapshot_validators[widx]` is - // actually a validator. If this ever changes, this loop needs to also check this. - snapshot_validators - .get(widx as usize) - .cloned() - .ok_or(>::OffchainElectionBogusWinner) - }) - .collect::, Error>>()?; - - // decode the rest of the snapshot. - let snapshot_nominators = - Self::snapshot_nominators().ok_or(>::SnapshotUnavailable)?; - - // helpers - let nominator_at = |i: NominatorIndex| -> Option { - snapshot_nominators.get(i as usize).cloned() - }; - let validator_at = |i: ValidatorIndex| -> Option { - snapshot_validators.get(i as usize).cloned() - }; - - // un-compact. - let assignments = compact_assignments - .into_assignment(nominator_at, validator_at) - .map_err(|e| { - // log the error since it is not propagated into the runtime error. - log!(warn, "un-compacting solution failed due to {:?}", e); - >::OffchainElectionBogusCompact - })?; - - // check all nominators actually including the claimed vote. Also check correct self votes. - // Note that we assume all validators and nominators in `assignments` are properly bonded, - // because they are coming from the snapshot via a given index. - for Assignment { who, distribution } in assignments.iter() { - let is_validator = >::contains_key(&who); - let maybe_nomination = Self::nominators(&who); - - if !(maybe_nomination.is_some() ^ is_validator) { - // all of the indices must map to either a validator or a nominator. If this is ever - // not the case, then the locking system of staking is most likely faulty, or we - // have bigger problems. - log!( - error, - "detected an error in the staking locking and snapshot." - ); - // abort. - return Err(>::OffchainElectionBogusNominator.into()); - } - - if !is_validator { - // a normal vote - let nomination = maybe_nomination.expect( - "exactly one of `maybe_validator` and `maybe_nomination.is_some` is true. \ - is_validator is false; maybe_nomination is some; qed", - ); - - // NOTE: we don't really have to check here if the sum of all edges are the - // nominator correct. Un-compacting assures this by definition. - - for (t, _) in distribution { - // each target in the provided distribution must be actually nominated by the - // nominator after the last non-zero slash. - if nomination.targets.iter().find(|&tt| tt == t).is_none() { - return Err(>::OffchainElectionBogusNomination.into()); - } - - if ::SlashingSpans::get(&t).map_or(false, |spans| { - nomination.submitted_in < spans.last_nonzero_slash() - }) { - return Err(>::OffchainElectionSlashedNomination.into()); - } - } - } else { - // a self vote - ensure!( - distribution.len() == 1, - >::OffchainElectionBogusSelfVote - ); - ensure!( - distribution[0].0 == *who, - >::OffchainElectionBogusSelfVote - ); - // defensive only. A compact assignment of length one does NOT encode the weight and - // it is always created to be 100%. - ensure!( - distribution[0].1 == OffchainAccuracy::one(), - >::OffchainElectionBogusSelfVote, - ); - } - } - - // convert into staked assignments. - let staked_assignments = - sp_npos_elections::assignment_ratio_to_staked(assignments, |s| Self::power_of(s) as _); - - // build the support map thereof in order to evaluate. - let supports = to_supports(&winners, &staked_assignments) - .map_err(|_| >::OffchainElectionBogusEdge)?; - - // Check if the score is the same as the claimed one. - let submitted_score = (&supports).evaluate(); - ensure!( - submitted_score == claimed_score, - >::OffchainElectionBogusScore - ); - - // At last, alles Ok. Exposures and store the result. - let exposures = Self::collect_exposures(supports); - log!( - info, - "A better solution (with compute {:?} and score {:?}) has been validated and stored \ - on chain.", - compute, - submitted_score, - ); - - // write new results. - >::put(ElectionResult { - elected_stashes: winners, - compute, - exposures, - }); - QueuedScore::put(submitted_score); - - // emit event. - Self::deposit_event(RawEvent::SolutionStored(compute)); - - Ok(None.into()) - } - /// Start a session potentially starting an era. fn start_session(start_session: SessionIndex) { let next_active_era = Self::active_era().map(|e| e.index + 1).unwrap_or(0); @@ -3112,298 +2576,25 @@ impl Module { Self::clear_era_information(old_era); } - // Set staking information for new era. - let maybe_new_validators = Self::select_and_update_validators(current_era); - // TWO_PHASE_NOTE: use this later on. - let _unused_new_validators = Self::enact_election(current_era); + let maybe_new_validators = Self::enact_election(current_era); maybe_new_validators } - /// Remove all the storage items associated with the election. - fn close_election_window() { - // Close window. - >::put(ElectionStatus::Closed); - // Kill snapshots. - Self::kill_stakers_snapshot(); - // Don't track final session. - IsCurrentSessionFinal::put(false); - } - - /// Select the new validator set at the end of the era. - /// - /// Runs [`try_do_phragmen`] and updates the following storage items: - /// - [`EraElectionStatus`]: with `None`. - /// - [`ErasStakers`]: with the new staker set. - /// - [`ErasStakersClipped`]. - /// - [`ErasValidatorPrefs`]. - /// - [`ErasTotalStake`]: with the new total stake. - /// - [`SnapshotValidators`] and [`SnapshotNominators`] are both removed. - /// - /// Internally, [`QueuedElected`], snapshots and [`QueuedScore`] are also consumed. - /// - /// If the election has been successful, It passes the new set upwards. - /// - /// This should only be called at the end of an era. - fn select_and_update_validators(current_era: EraIndex) -> Option> { - if let Some(ElectionResultT:: { - elected_stashes, - exposures, - compute, - }) = Self::try_do_election() - { - // Totally close the election round and data. - Self::close_election_window(); - - // Populate Stakers and write slot stake. - let mut total_stake = 0; - exposures.into_iter().for_each(|(stash, exposure)| { - // Total `Power` is `1_000_000_000`, never get overflow; qed - total_stake += exposure.total_power; - >::insert(current_era, &stash, &exposure); - - let mut exposure_clipped = exposure; - let clipped_max_len = T::MaxNominatorRewardedPerValidator::get() as usize; - if exposure_clipped.others.len() > clipped_max_len { - exposure_clipped - .others - .sort_by(|a, b| a.power.cmp(&b.power).reverse()); - exposure_clipped.others.truncate(clipped_max_len); - } - >::insert(¤t_era, &stash, exposure_clipped); - }); - // Insert current era staking information - ErasTotalStake::insert(¤t_era, total_stake); - - // collect the pref of all winners - for stash in &elected_stashes { - let pref = Self::validators(stash); - >::insert(¤t_era, stash, pref); - } - - // emit event - Self::deposit_event(RawEvent::StakingElection(compute)); - - log!( - info, - "new validator set of size {:?} has been elected via {:?} for staring era {:?}", - elected_stashes.len(), - compute, - current_era, - ); - - Some(elected_stashes) - } else { - None - } - } - - /// Select a new validator set from the assembled stakers and their role preferences. It tries - /// first to peek into [`QueuedElected`]. Otherwise, it runs a new on-chain phragmen election. - /// - /// If [`QueuedElected`] and [`QueuedScore`] exists, they are both removed. No further storage - /// is updated. - fn try_do_election() -> Option> { - // an election result from either a stored submission or locally executed one. - let next_result = >::take().or_else(|| Self::do_on_chain_phragmen()); - - // either way, kill this. We remove it here to make sure it always has the exact same - // lifetime as `QueuedElected`. - QueuedScore::kill(); - - next_result - } - - /// Execute election and return the new results. The edge weights are processed into support - /// values. - /// - /// This is basically a wrapper around [`do_phragmen`] which translates - /// `PrimitiveElectionResult` into `ElectionResult`. + /// Enact and process the election using the `ElectionProvider` type. /// - /// No storage item is updated. - fn do_on_chain_phragmen() -> Option> { - if let Some(phragmen_result) = Self::do_phragmen::(0) { - let elected_stashes = phragmen_result - .winners - .iter() - .map(|(s, _)| s.clone()) - .collect::>(); - let assignments = phragmen_result.assignments; - - let staked_assignments = - sp_npos_elections::assignment_ratio_to_staked(assignments, |s| { - Self::power_of(s) as _ - }); - - let supports = to_supports(&elected_stashes, &staked_assignments) - .map_err(|_| { - log!( - error, - "on-chain phragmen is failing due to a problem in the result. This must be a bug." - ) - }) - .ok()?; - - // collect exposures - let exposures = Self::collect_exposures(supports); - - // In order to keep the property required by `on_session_ending` that we must return the - // new validator set even if it's the same as the old, as long as any underlying - // economic conditions have changed, we don't attempt to do any optimization where we - // compare against the prior set. - Some(ElectionResultT:: { - elected_stashes, - exposures, - compute: ElectionCompute::OnChain, + /// This will also process the election, as noted in [`process_election`]. + fn enact_election(current_era: EraIndex) -> Option> { + T::ElectionProvider::elect() + .map_err(|e| log!(warn, "election provider failed due to {:?}", e)) + .and_then(|(res, weight)| { + >::register_extra_weight_unchecked( + weight, + frame_support::weights::DispatchClass::Mandatory, + ); + Self::process_election(res, current_era) }) - } else { - // There were not enough candidates for even our minimal level of functionality. This is - // bad. We should probably disable all functionality except for block production and let - // the chain keep producing blocks until we can decide on a sufficiently substantial - // set. TODO: #2494 - None - } - } - - /// Execute phragmen election and return the new results. No post-processing is applied and the - /// raw edge weights are returned. - /// - /// Self votes are added and nominations before the most recent slashing span are ignored. - /// - /// No storage item is updated. - pub fn do_phragmen( - iterations: usize, - ) -> Option> { - let mut all_nominators: Vec<(T::AccountId, VoteWeight, Vec)> = vec![]; - let mut all_validators = vec![]; - for (validator, _) in >::iter() { - // append self vote - let self_vote = ( - validator.clone(), - Self::power_of(&validator) as _, - vec![validator.clone()], - ); - all_nominators.push(self_vote); - all_validators.push(validator); - } - - let nominator_votes = >::iter().map(|(nominator, nominations)| { - let Nominations { - submitted_in, - mut targets, - suppressed: _, - } = nominations; - - // Filter out nomination targets which were nominated before the most recent - // slashing span. - targets.retain(|stash| { - ::SlashingSpans::get(&stash) - .map_or(true, |spans| submitted_in >= spans.last_nonzero_slash()) - }); - - (nominator, targets) - }); - all_nominators.extend(nominator_votes.map(|(n, ns)| { - let s = Self::power_of(&n) as _; - (n, s, ns) - })); - - if all_validators.len() < Self::minimum_validator_count().max(1) as usize { - // If we don't have enough candidates, nothing to do. - log!( - error, - "chain does not have enough staking candidates to operate. Era {:?}.", - Self::current_era() - ); - None - } else { - seq_phragmen::<_, Accuracy>( - Self::validator_count() as usize, - all_validators, - all_nominators, - Some((iterations, 0)), // exactly run `iterations` rounds. - ) - .map_err(|err| log!(error, "Call to seq-phragmen failed due to {:?}", err)) .ok() - } - } - - /// Consume a set of [`Supports`] from [`sp_npos_elections`] and collect them into a - /// [`Exposure`]. - fn collect_exposures(supports: Supports) -> Vec<(T::AccountId, ExposureT)> { - supports - .into_iter() - .map(|(validator, support)| { - // build `struct exposure` from `support` - let mut own_ring_balance: RingBalance = Zero::zero(); - let mut own_kton_balance: KtonBalance = Zero::zero(); - let mut own_power = 0; - let mut total_power = 0; - let mut others = Vec::with_capacity(support.voters.len()); - support.voters.into_iter().for_each(|(nominator, weight)| { - let origin_weight = Self::power_of(&nominator) as ExtendedBalance; - let (origin_ring_balance, origin_kton_balance) = Self::stake_of(&nominator); - - let ring_balance = if let Ok(ring_balance) = multiply_by_rational( - origin_ring_balance.saturated_into(), - weight, - origin_weight, - ) { - ring_balance.saturated_into() - } else { - log!( - error, - "[staking] Origin RING: {:?}, Weight: {:?}, Origin Weight: {:?}", - origin_ring_balance, - weight, - origin_weight - ); - Zero::zero() - }; - let kton_balance = if let Ok(kton_balance) = multiply_by_rational( - origin_kton_balance.saturated_into(), - weight, - origin_weight, - ) { - kton_balance.saturated_into() - } else { - log!( - error, - "[staking] Origin KTON: {:?}, Weight: {:?}, Origin Weight: {:?}", - origin_kton_balance, - weight, - origin_weight - ); - Zero::zero() - }; - let power = weight as Power; - - if nominator == validator { - own_ring_balance = own_ring_balance.saturating_add(ring_balance); - own_kton_balance = own_kton_balance.saturating_add(kton_balance); - own_power = own_power.saturating_add(power); - } else { - others.push(IndividualExposure { - who: nominator, - ring_balance, - kton_balance, - power, - }); - } - total_power = total_power.saturating_add(power); - }); - - let exposure = Exposure { - own_ring_balance, - own_kton_balance, - own_power, - total_power, - others, - }; - - (validator, exposure) - }) - .collect::)>>() } /// Process the output of the election. @@ -3413,10 +2604,8 @@ impl Module { /// /// Returns `Err(())` if less than [`MinimumValidatorCount`] validators have been elected, `Ok` /// otherwise. - // TWO_PHASE_NOTE: remove the dead code. - #[allow(dead_code)] pub fn process_election( - flat_supports: sp_npos_elections::Supports, + flat_supports: Supports, current_era: EraIndex, ) -> Result, ()> { let exposures = Self::collect_exposures(flat_supports); @@ -3426,16 +2615,21 @@ impl Module { .map(|(x, _)| x) .collect::>(); - if (elected_stashes.len() as u32) <= Self::minimum_validator_count() { - log!( - warn, - "chain does not have enough staking candidates to operate for era {:?}", - current_era, - ); + if (elected_stashes.len() as u32) < Self::minimum_validator_count().max(1) { + // Session will panic if we ever return an empty validator set, thus max(1) ^^. + if current_era > 0 { + log!( + warn, + "chain does not have enough staking candidates to operate for era {:?} ({} elected, minimum is {})", + current_era, + elected_stashes.len(), + Self::minimum_validator_count(), + ); + } return Err(()); } - // Populate Stakers and write slot stake. + // Populate stakers, exposures, and the snapshot of validator prefs. let mut total_stake = 0; exposures.into_iter().for_each(|(stash, exposure)| { total_stake = total_stake.saturating_add(exposure.total_power); @@ -3461,33 +2655,104 @@ impl Module { >::insert(¤t_era, stash, pref); } - // emit event - // TWO_PHASE_NOTE: remove the inner value. - Self::deposit_event(RawEvent::StakingElection(ElectionCompute::Signed)); + Self::deposit_event(RawEvent::StakingElection); - log!( - info, - "new validator set of size {:?} has been processed for era {:?}", - elected_stashes.len(), - current_era, - ); + if current_era > 0 { + log!( + info, + "new validator set of size {:?} has been processed for era {:?}", + elected_stashes.len(), + current_era, + ); + } Ok(elected_stashes) } - /// Enact and process the election using the `ElectionProvider` type. - /// - /// This will also process the election, as noted in [`process_election`]. - fn enact_election(_current_era: EraIndex) -> Option> { - let _outcome = T::ElectionProvider::elect().map(|_| ()); - log!( - debug, - "Experimental election provider outputted {:?}", - _outcome - ); - // TWO_PHASE_NOTE: This code path shall not return anything for now. Later on, redirect the - // results to `process_election`. - None + /// Consume a set of [`Supports`] from [`sp_npos_elections`] and collect them into a + /// [`Exposure`]. + fn collect_exposures(supports: Supports) -> Vec<(T::AccountId, ExposureT)> { + supports + .into_iter() + .map(|(validator, support)| { + // build `struct exposure` from `support` + let mut own_ring_balance: RingBalance = Zero::zero(); + let mut own_kton_balance: KtonBalance = Zero::zero(); + let mut own_power = 0; + let mut total_power = 0; + let mut others = Vec::with_capacity(support.voters.len()); + + support + .voters + .into_iter() + .for_each(|(nominator, power_u128)| { + // `T::TotalPower::get() == 1_000_000_000_u32`, will never overflow or get truncated; qed + let power = power_u128 as _; + let origin_power = Self::power_of(&nominator); + let origin_power_u128 = origin_power as _; + + let (origin_ring_balance, origin_kton_balance) = Self::stake_of(&nominator); + let ring_balance = if let Ok(ring_balance) = + helpers_128bit::multiply_by_rational( + origin_ring_balance.saturated_into(), + power_u128, + origin_power_u128, + ) { + ring_balance.saturated_into() + } else { + log!( + error, + "[staking] Origin RING: {:?}, Weight: {:?}, Origin Weight: {:?}", + origin_ring_balance, + power_u128, + origin_power_u128 + ); + Zero::zero() + }; + let kton_balance = if let Ok(kton_balance) = + helpers_128bit::multiply_by_rational( + origin_kton_balance.saturated_into(), + power_u128, + origin_power_u128, + ) { + kton_balance.saturated_into() + } else { + log!( + error, + "[staking] Origin KTON: {:?}, Weight: {:?}, Origin Weight: {:?}", + origin_kton_balance, + power_u128, + origin_power_u128 + ); + Zero::zero() + }; + + if nominator == validator { + own_ring_balance = own_ring_balance.saturating_add(ring_balance); + own_kton_balance = own_kton_balance.saturating_add(kton_balance); + own_power = own_power.saturating_add(power); + } else { + others.push(IndividualExposure { + who: nominator, + ring_balance, + kton_balance, + power, + }); + } + total_power = total_power.saturating_add(power); + }); + + let exposure = Exposure { + own_ring_balance, + own_kton_balance, + own_power, + total_power, + others, + }; + + (validator, exposure) + }) + .collect() } /// Remove all associated data of a stash account from the staking system. @@ -3509,7 +2774,7 @@ impl Module { >::remove(stash); >::remove(stash); - >::dec_consumers(stash); + >::dec_consumers(stash); Ok(()) } @@ -3574,13 +2839,6 @@ impl Module { } } - fn will_era_be_forced() -> bool { - match ForceEra::get() { - Forcing::ForceAlways | Forcing::ForceNew => true, - Forcing::ForceNone | Forcing::NotForcing => false, - } - } - #[cfg(feature = "runtime-benchmarks")] pub fn add_era_stakers( current_era: EraIndex, @@ -3590,11 +2848,6 @@ impl Module { >::insert(¤t_era, &controller, &exposure); } - #[cfg(feature = "runtime-benchmarks")] - pub fn put_election_status(status: ElectionStatus) { - >::put(status); - } - #[cfg(feature = "runtime-benchmarks")] pub fn set_slash_reward_fraction(fraction: Perbill) { SlashRewardFraction::put(fraction); @@ -3625,6 +2878,9 @@ impl Module { all_voters.push(self_vote); } + // collect all slashing spans into a BTreeMap for further queries. + let slashing_spans = >::iter().collect::>(); + for (nominator, nominations) in >::iter() { let Nominations { submitted_in, @@ -3635,7 +2891,8 @@ impl Module { // Filter out nomination targets which were nominated before the most recent // slashing span. targets.retain(|stash| { - Self::slashing_spans(&stash) + slashing_spans + .get(stash) .map_or(true, |spans| submitted_in >= spans.last_nonzero_slash()) }); @@ -3651,19 +2908,46 @@ impl Module { } } -impl sp_election_providers::ElectionDataProvider - for Module -{ - fn desired_targets() -> u32 { - Self::validator_count() +impl ElectionDataProvider for Module { + fn desired_targets() -> data_provider::Result<(u32, Weight)> { + Ok(( + Self::validator_count(), + ::DbWeight::get().reads(1), + )) + } + + fn voters( + maybe_max_len: Option, + ) -> data_provider::Result<(Vec<(T::AccountId, VoteWeight, Vec)>, Weight)> { + // NOTE: reading these counts already needs to iterate a lot of storage keys, but they get + // cached. This is okay for the case of `Ok(_)`, but bad for `Err(_)`, as the trait does not + // report weight in failures. + let nominator_count = >::iter().count(); + let validator_count = >::iter().count(); + let voter_count = nominator_count.saturating_add(validator_count); + + if maybe_max_len.map_or(false, |max_len| voter_count > max_len) { + return Err("Voter snapshot too big"); + } + + let slashing_span_count = >::iter().count(); + let weight = T::WeightInfo::get_npos_voters( + nominator_count as u32, + validator_count as u32, + slashing_span_count as u32, + ); + Ok((Self::get_npos_voters(), weight)) } - fn voters() -> Vec<(T::AccountId, VoteWeight, Vec)> { - Self::get_npos_voters() - } + fn targets(maybe_max_len: Option) -> data_provider::Result<(Vec, Weight)> { + let target_count = >::iter().count(); + + if maybe_max_len.map_or(false, |max_len| target_count > max_len) { + return Err("Target snapshot too big"); + } - fn targets() -> Vec { - Self::get_npos_targets() + let weight = ::DbWeight::get().reads(target_count as u64); + Ok((Self::get_npos_targets(), weight)) } fn next_election_prediction(now: T::BlockNumber) -> T::BlockNumber { @@ -3678,6 +2962,7 @@ impl sp_election_providers::ElectionDataProvider sp_election_providers::ElectionDataProvider)>, targets: Vec, + target_stake: Option, ) { + use sp_std::convert::TryFrom; targets.into_iter().for_each(|v| { + let stake: BalanceOf = target_stake + .and_then(|w| >::try_from(w).ok()) + .unwrap_or(T::Currency::minimum_balance() * 100u32.into()); + >::insert(v.clone(), v.clone()); + >::insert( + v.clone(), + StakingLedger { + stash: v.clone(), + active: stake, + total: stake, + unlocking: vec![], + claimed_rewards: vec![], + }, + ); >::insert( v, ValidatorPrefs { @@ -3707,7 +3008,21 @@ impl sp_election_providers::ElectionDataProvider>::try_from(s).unwrap_or_else(|_| { + panic!("cannot convert a VoteWeight into BalanceOf, benchmark needs reconfiguring.") + }); + >::insert(v.clone(), v.clone()); + >::insert( + v.clone(), + StakingLedger { + stash: v.clone(), + active: stake, + total: stake, + unlocking: vec![], + claimed_rewards: vec![], + }, + ); >::insert( v, Nominations { @@ -3722,31 +3037,16 @@ impl sp_election_providers::ElectionDataProvider pallet_session::SessionManager for Module { fn new_session(new_index: SessionIndex) -> Option> { - log!( - trace, - "[{:?}] planning new_session({})", - >::block_number(), - new_index, - ); + log!(trace, "planning new_session({})", new_index); CurrentPlannedSession::put(new_index); Self::new_session(new_index) } fn end_session(end_index: SessionIndex) { - log!( - trace, - "[{:?}] ending end_session({})", - >::block_number(), - end_index, - ); + log!(trace, "ending end_session({})", end_index); Self::end_session(end_index) } fn start_session(start_index: SessionIndex) { - log!( - trace, - "[{:?}] starting start_session({})", - >::block_number(), - start_index, - ); + log!(trace, "starting start_session({})", start_index); Self::start_session(start_index) } } @@ -3917,8 +3217,8 @@ where } fn can_report() -> bool { - // TWO_PHASE_NOTE: we can get rid of this API - Self::era_election_status().is_closed() + // TODO: https://github.com/paritytech/substrate/issues/8343 + true } } @@ -3975,7 +3275,7 @@ impl OnDepositRedeem> for Module { >::insert(&stash, controller); >::insert(&stash, RewardDestination::Stash); - >::inc_consumers(&stash).map_err(|_| Error::::BadState)?; + >::inc_consumers(&stash).map_err(|_| Error::::BadState)?; let mut ledger = StakingLedger { stash: stash.clone(), @@ -4003,85 +3303,6 @@ impl OnDepositRedeem> for Module { } } -#[allow(deprecated)] -impl frame_support::unsigned::ValidateUnsigned for Module { - type Call = Call; - fn validate_unsigned(source: TransactionSource, call: &Self::Call) -> TransactionValidity { - if let Call::submit_election_solution_unsigned(_, _, score, era, _) = call { - // --- substrate --- - use offchain_election::DEFAULT_LONGEVITY; - - // discard solution not coming from the local OCW. - match source { - TransactionSource::Local | TransactionSource::InBlock => { /* allowed */ } - _ => { - log!( - debug, - "rejecting unsigned transaction because it is not local/in-block." - ); - return InvalidTransaction::Call.into(); - } - } - - if let Err(error_with_post_info) = Self::pre_dispatch_checks(*score, *era) { - let invalid = to_invalid(error_with_post_info); - log!( - debug, - "validate unsigned pre dispatch checks failed due to error #{:?}.", - invalid, - ); - return invalid.into(); - } - - log!( - debug, - "validateUnsigned succeeded for a solution at era {}.", - era - ); - - ValidTransaction::with_tag_prefix("StakingOffchain") - // The higher the score[0], the better a solution is. - .priority(T::UnsignedPriority::get().saturating_add(score[0].saturated_into())) - // Defensive only. A single solution can exist in the pool per era. Each validator - // will run OCW at most once per era, hence there should never exist more than one - // transaction anyhow. - .and_provides(era) - // Note: this can be more accurate in the future. We do something like - // `era_end_block - current_block` but that is not needed now as we eagerly run - // offchain workers now and the above should be same as `T::ElectionLookahead` - // without the need to query more storage in the validation phase. If we randomize - // offchain worker, then we might re-consider this. - .longevity( - TryInto::::try_into(T::ElectionLookahead::get()) - .unwrap_or(DEFAULT_LONGEVITY), - ) - // We don't propagate this. This can never the validated at a remote node. - .propagate(false) - .build() - } else { - InvalidTransaction::Call.into() - } - } - - fn pre_dispatch(call: &Self::Call) -> Result<(), TransactionValidityError> { - if let Call::submit_election_solution_unsigned(_, _, score, era, _) = call { - // IMPORTANT NOTE: These checks are performed in the dispatch call itself, yet we need - // to duplicate them here to prevent a block producer from putting a previously - // validated, yet no longer valid solution on chain. - // OPTIMISATION NOTE: we could skip this in the `submit_election_solution_unsigned` - // since we already do it here. The signed version needs it though. Yer for now we keep - // this duplicate check here so both signed and unsigned can use a singular - // `check_and_replace_solution`. - Self::pre_dispatch_checks(*score, *era) - .map(|_| ()) - .map_err(to_invalid) - .map_err(Into::into) - } else { - Err(InvalidTransaction::Call.into()) - } - } -} - /// Add reward points to block authors: /// * 20 points to the block producer for producing a (non-uncle) block in the relay chain, /// * 2 points to the block producer for each reference to a previously unreferenced uncle, and @@ -4095,12 +3316,17 @@ where } fn note_uncle(author: T::AccountId, _age: T::BlockNumber) { Self::reward_by_ids(vec![ - (>::author(), 2), + (>::author(), 2), (author, 1), ]); } } +/// Check that list is sorted and has no duplicates. +fn is_sorted_and_unique(list: &Vec) -> bool { + list.windows(2).all(|w| w[0] < w[1]) +} + /// A `Convert` implementation that finds the stash of the given controller account, /// if any. pub struct StashOf(PhantomData); @@ -4168,11 +3394,12 @@ enum Releases { V2_0_0, V3_0_0, V4_0_0, - V5_0_0, + V5_0_0, // blockable validators. + V6_0_0, // removal of all storage associated with offchain phragmen. } impl Default for Releases { fn default() -> Self { - Releases::V5_0_0 + Releases::V6_0_0 } } @@ -4199,6 +3426,8 @@ pub enum RewardDestination { Controller, /// Pay into a specified account. Account(AccountId), + /// Receive no reward. + None, } impl Default for RewardDestination { fn default() -> Self { @@ -4225,48 +3454,6 @@ impl Default for Forcing { } } -/// Indicate how an election round was computed. -#[derive(PartialEq, Eq, Clone, Copy, Encode, Decode, RuntimeDebug)] -pub enum ElectionCompute { - /// Result was forcefully computed on chain at the end of the session. - OnChain, - /// Result was submitted and accepted to the chain via a signed transaction. - Signed, - /// Result was submitted and accepted to the chain via an unsigned transaction (by an - /// authority). - Unsigned, -} - -/// The status of the upcoming (offchain) election. -#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug)] -pub enum ElectionStatus { - /// Nothing has and will happen for now. submission window is not open. - Closed, - /// The submission window has been open since the contained block number. - Open(BlockNumber), -} -impl ElectionStatus { - pub fn is_open_at(&self, n: BlockNumber) -> bool { - *self == Self::Open(n) - } - - pub fn is_closed(&self) -> bool { - match self { - Self::Closed => true, - _ => false, - } - } - - pub fn is_open(&self) -> bool { - !self.is_closed() - } -} -impl Default for ElectionStatus { - fn default() -> Self { - Self::Closed - } -} - /// To unify *RING* and *KTON* balances. #[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug)] pub enum StakingBalance @@ -4635,46 +3822,3 @@ pub struct UnappliedSlash { /// The amount of payout. payout: slashing::RK, } - -/// Some indications about the size of the election. This must be submitted with the solution. -/// -/// Note that these values must reflect the __total__ number, not only those that are present in the -/// solution. In short, these should be the same size as the size of the values dumped in -/// `SnapshotValidators` and `SnapshotNominators`. -#[derive(PartialEq, Eq, Clone, Copy, Encode, Decode, RuntimeDebug, Default)] -pub struct ElectionSize { - /// Number of validators in the snapshot of the current election round. - #[codec(compact)] - pub validators: ValidatorIndex, - /// Number of nominators in the snapshot of the current election round. - #[codec(compact)] - pub nominators: NominatorIndex, -} - -/// The result of an election round. -#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug)] -pub struct ElectionResult { - /// Flat list of validators who have been elected. - elected_stashes: Vec, - /// Flat list of new exposures, to be updated in the [`Exposure`] storage. - exposures: Vec<(AccountId, Exposure)>, - /// Type of the result. This is kept on chain only to track and report the best score's - /// submission type. An optimisation could remove this. - compute: ElectionCompute, -} - -/// Check that list is sorted and has no duplicates. -fn is_sorted_and_unique(list: &Vec) -> bool { - list.windows(2).all(|w| w[0] < w[1]) -} - -/// convert a DispatchErrorWithPostInfo to a custom InvalidTransaction with the inner code being the -/// error number. -fn to_invalid(error_with_post_info: DispatchErrorWithPostInfo) -> InvalidTransaction { - let error = error_with_post_info.error; - let error_number = match error { - DispatchError::Module { error, .. } => error, - _ => 0, - }; - InvalidTransaction::Custom(error_number) -} diff --git a/frame/staking/src/mock.rs b/frame/staking/src/mock.rs index 6bff5d4cef..259665dc1e 100644 --- a/frame/staking/src/mock.rs +++ b/frame/staking/src/mock.rs @@ -23,17 +23,16 @@ // --- std --- use std::{cell::RefCell, collections::HashSet}; // --- substrate --- +use frame_election_provider_support::onchain; use frame_support::{ assert_ok, parameter_types, storage::IterableStorageMap, traits::{Currency, FindAuthor, Get, OnFinalize, OnInitialize, OneSessionHandler}, - weights::{constants::RocksDbWeight, Weight}, + weights::constants::RocksDbWeight, StorageValue, }; use frame_system::mocking::*; use sp_core::H256; -use sp_election_providers::onchain; -use sp_npos_elections::{reduce, StakedAssignment}; use sp_runtime::{ testing::{Header, TestXt, UintAuthorityId}, traits::IdentityLookup, @@ -217,6 +216,7 @@ impl darwinia_balances::Config for Test { impl onchain::Config for Test { type AccountId = AccountId; type BlockNumber = BlockNumber; + type BlockWeights = BlockWeights; type Accuracy = Perbill; type DataProvider = Staking; } @@ -225,17 +225,12 @@ parameter_types! { pub const StakingModuleId: ModuleId = ModuleId(*b"da/staki"); pub const BondingDurationInEra: EraIndex = 3; pub const MaxNominatorRewardedPerValidator: u32 = 64; - pub const UnsignedPriority: u64 = 1 << 20; - pub const MinSolutionScoreBump: Perbill = Perbill::zero(); - pub OffchainSolutionWeightLimit: Weight = BlockWeights::get().max_block; pub const Cap: Balance = CAP; pub const TotalPower: Power = TOTAL_POWER; pub static SessionsPerEra: SessionIndex = 3; pub static BondingDurationInBlockNumber: BlockNumber = bonding_duration_in_blocks(); pub static ExistentialDeposit: Balance = 1; pub static SlashDeferDuration: EraIndex = 0; - pub static ElectionLookahead: BlockNumber = 0; - pub static MaxIterations: u32 = 0; pub static SessionValidators: (Vec, HashSet) = Default::default(); pub static RingRewardRemainderUnbalanced: Balance = 0; } @@ -250,13 +245,7 @@ impl Config for Test { type SlashCancelOrigin = frame_system::EnsureRoot; type SessionInterface = Self; type NextNewSession = Session; - type ElectionLookahead = ElectionLookahead; - type Call = Call; - type MaxIterations = MaxIterations; - type MinSolutionScoreBump = MinSolutionScoreBump; type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator; - type UnsignedPriority = UnsignedPriority; - type OffchainSolutionWeightLimit = OffchainSolutionWeightLimit; type ElectionProvider = onchain::OnChainSequentialPhragmen; type RingCurrency = Ring; type RingRewardRemainder = RingRewardRemainderMock; @@ -285,12 +274,12 @@ frame_support::construct_runtime! { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Storage, Config, Event}, - Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent}, - Ring: darwinia_balances::::{Module, Call, Storage, Config, Event}, - Kton: darwinia_balances::::{Module, Call, Storage, Config, Event}, - Staking: darwinia_staking::{Module, Call, Storage, Config, Event, ValidateUnsigned}, - Session: pallet_session::{Module, Call, Storage, Event, Config}, + System: frame_system::{Pallet, Call, Storage, Config, Event}, + Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, + Ring: darwinia_balances::::{Pallet, Call, Storage, Config, Event}, + Kton: darwinia_balances::::{Pallet, Call, Storage, Config, Event}, + Staking: darwinia_staking::{Pallet, Call, Storage, Config, Event}, + Session: pallet_session::{Pallet, Call, Storage, Event, Config}, } } @@ -311,10 +300,6 @@ impl ExtBuilder { SESSIONS_PER_ERA.with(|v| *v.borrow_mut() = length); self } - pub fn election_lookahead(self, look: BlockNumber) -> Self { - ELECTION_LOOKAHEAD.with(|v| *v.borrow_mut() = look); - self - } pub fn period(self, length: BlockNumber) -> Self { PERIOD.with(|v| *v.borrow_mut() = length); self @@ -359,17 +344,10 @@ impl ExtBuilder { self.has_stakers = has; self } - pub fn max_offchain_iterations(self, iterations: u32) -> Self { - MAX_ITERATIONS.with(|v| *v.borrow_mut() = iterations); - self - } pub fn init_kton(mut self, init: bool) -> Self { self.init_kton = init; self } - pub fn offchain_election_ext(self) -> Self { - self.sessions_per_era(4).period(5).election_lookahead(3) - } pub fn initialize_first_session(mut self, init: bool) -> Self { self.initialize_first_session = init; self @@ -898,211 +876,6 @@ pub(crate) fn add_slash(who: &AccountId) { ); } -// winners will be chosen by simply their unweighted total backing stake. Nominator stake is -// distributed evenly. -pub(crate) fn horrible_npos_solution( - do_reduce: bool, -) -> (CompactAssignments, Vec, ElectionScore) { - let mut backing_stake_of: BTreeMap = BTreeMap::new(); - - // self stake - >::iter().for_each(|(who, _p)| { - *backing_stake_of.entry(who).or_insert(0) += Staking::power_of(&who) as Balance - }); - - // add nominator stuff - >::iter().for_each(|(who, nomination)| { - nomination.targets.iter().for_each(|v| { - *backing_stake_of.entry(*v).or_insert(0) += Staking::power_of(&who) as Balance - }) - }); - - // elect winners - let mut sorted: Vec = backing_stake_of.keys().cloned().collect(); - sorted.sort_by_key(|x| backing_stake_of.get(x).unwrap()); - let winners: Vec = sorted - .iter() - .cloned() - .take(Staking::validator_count() as usize) - .collect(); - - // create assignments - let mut staked_assignment: Vec> = Vec::new(); - >::iter().for_each(|(who, nomination)| { - let mut dist: Vec<(AccountId, ExtendedBalance)> = Vec::new(); - nomination.targets.iter().for_each(|v| { - if winners.iter().find(|w| *w == v).is_some() { - dist.push((*v, ExtendedBalance::zero())); - } - }); - - if dist.len() == 0 { - return; - } - - // assign real stakes. just split the stake. - let stake = Staking::power_of(&who) as ExtendedBalance; - let mut sum: ExtendedBalance = Zero::zero(); - let dist_len = dist.len(); - { - dist.iter_mut().for_each(|(_, w)| { - let partial = stake / (dist_len as ExtendedBalance); - *w = partial; - sum += partial; - }); - } - - // assign the leftover to last. - { - let leftover = stake - sum; - let last = dist.last_mut().unwrap(); - last.1 += leftover; - } - - staked_assignment.push(StakedAssignment { - who, - distribution: dist, - }); - }); - - // Ensure that this result is worse than seq-phragmen. Otherwise, it should not have been used - // for testing. - let score = { - let (_, _, better_score) = prepare_submission_with(true, true, 0, |_| {}); - - let support = to_supports::(&winners, &staked_assignment).unwrap(); - let score = support.evaluate(); - - assert!(sp_npos_elections::is_score_better::( - better_score, - score, - MinSolutionScoreBump::get(), - )); - - score - }; - - if do_reduce { - reduce(&mut staked_assignment); - } - - let snapshot_validators = Staking::snapshot_validators().unwrap(); - let snapshot_nominators = Staking::snapshot_nominators().unwrap(); - let nominator_index = |a: &AccountId| -> Option { - snapshot_nominators - .iter() - .position(|x| x == a) - .map(|i| i as NominatorIndex) - }; - let validator_index = |a: &AccountId| -> Option { - snapshot_validators - .iter() - .position(|x| x == a) - .map(|i| i as ValidatorIndex) - }; - - // convert back to ratio assignment. This takes less space. - let assignments_reduced = sp_npos_elections::assignment_staked_to_ratio::< - AccountId, - OffchainAccuracy, - >(staked_assignment); - - let compact = - CompactAssignments::from_assignment(assignments_reduced, nominator_index, validator_index) - .unwrap(); - - // winner ids to index - let winners = winners - .into_iter() - .map(|w| validator_index(&w).unwrap()) - .collect::>(); - - (compact, winners, score) -} - -/// Note: this should always logically reproduce [`offchain_election::prepare_submission`], yet we -/// cannot do it since we want to have `tweak` injected into the process. -/// -/// If the input is being tweaked in a way that the score cannot be compute accurately, -/// `compute_real_score` can be set to true. In this case a `Default` score is returned. -pub(crate) fn prepare_submission_with( - compute_real_score: bool, - do_reduce: bool, - iterations: usize, - tweak: impl FnOnce(&mut Vec>), -) -> (CompactAssignments, Vec, ElectionScore) { - // run election on the default stuff. - let sp_npos_elections::ElectionResult { - winners, - assignments, - } = Staking::do_phragmen::(iterations).unwrap(); - let winners = sp_npos_elections::to_without_backing(winners); - - let mut staked = sp_npos_elections::assignment_ratio_to_staked(assignments, |stash| { - Staking::power_of(stash) as _ - }); - - // apply custom tweaks. awesome for testing. - tweak(&mut staked); - - if do_reduce { - reduce(&mut staked); - } - - // convert back to ratio assignment. This takes less space. - let snapshot_validators = Staking::snapshot_validators().expect("snapshot not created."); - let snapshot_nominators = Staking::snapshot_nominators().expect("snapshot not created."); - let nominator_index = |a: &AccountId| -> Option { - snapshot_nominators.iter().position(|x| x == a).map_or_else( - || { - println!("unable to find nominator index for {:?}", a); - None - }, - |i| Some(i as NominatorIndex), - ) - }; - let validator_index = |a: &AccountId| -> Option { - snapshot_validators.iter().position(|x| x == a).map_or_else( - || { - println!("unable to find validator index for {:?}", a); - None - }, - |i| Some(i as ValidatorIndex), - ) - }; - - let assignments_reduced = sp_npos_elections::assignment_staked_to_ratio(staked); - - // re-compute score by converting, yet again, into staked type - let score = if compute_real_score { - let staked = - sp_npos_elections::assignment_ratio_to_staked(assignments_reduced.clone(), |stash| { - Staking::power_of(stash) as _ - }); - - let support_map = to_supports(winners.as_slice(), staked.as_slice()).unwrap(); - support_map.evaluate() - } else { - Default::default() - }; - - let compact = - CompactAssignments::from_assignment(assignments_reduced, nominator_index, validator_index) - .map_err(|e| { - println!("error in compact: {:?}", e); - e - }) - .expect("Failed to create compact"); - - // winner ids to index - let winners = winners - .into_iter() - .map(|w| validator_index(&w).unwrap()) - .collect::>(); - - (compact, winners, score) -} - /// Make all validator and nominator request their payment pub(crate) fn make_all_reward_payment(era: EraIndex) { let validators_with_reward = >::get(era) @@ -1144,6 +917,10 @@ pub(crate) fn kton_balances(who: &AccountId) -> (Balance, Balance) { (Kton::free_balance(who), Kton::reserved_balance(who)) } +pub(crate) fn ring_power(stake: Balance) -> Power { + Staking::currency_to_power(stake, Staking::ring_pool()) +} + #[macro_export] macro_rules! assert_session_era { ($session:expr, $era:expr) => { diff --git a/frame/staking/src/offchain_election.rs b/frame/staking/src/offchain_election.rs deleted file mode 100644 index 84c6070bab..0000000000 --- a/frame/staking/src/offchain_election.rs +++ /dev/null @@ -1,592 +0,0 @@ -// This file is part of Darwinia. -// -// Copyright (C) 2018-2021 Darwinia Network -// SPDX-License-Identifier: GPL-3.0 -// -// Darwinia is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Darwinia is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Darwinia. If not, see . - -//! Helpers for offchain worker election. - -// --- crates --- -use codec::Decode; -// --- substrate --- -use frame_support::{traits::Get, weights::Weight, IterableStorageMap}; -use frame_system::offchain::SubmitTransaction; -use sp_npos_elections::{ - reduce, to_supports, Assignment, CompactSolution, ElectionResult, ElectionScore, - EvaluateSupport, ExtendedBalance, -}; -use sp_runtime::{offchain::storage::StorageValueRef, traits::TrailingZeroInput, RuntimeDebug}; -use sp_std::{convert::TryInto, prelude::*}; -// --- darwinia --- -use crate::{ - Call, CompactAssignments, Config, ElectionSize, Module, NominatorIndex, Nominators, - OffchainAccuracy, ValidatorIndex, WeightInfo, -}; - -/// Error types related to the offchain election machinery. -#[derive(RuntimeDebug)] -pub enum OffchainElectionError { - /// election returned None. This means less candidate that minimum number of needed - /// validators were present. The chain is in trouble and not much that we can do about it. - ElectionFailed, - /// Submission to the transaction pool failed. - PoolSubmissionFailed, - /// The snapshot data is not available. - SnapshotUnavailable, - /// Error from npos-election crate. This usually relates to compact operation. - InternalElectionError(sp_npos_elections::Error), - /// One of the computed winners is invalid. - InvalidWinner, - /// A nominator is not available in the snapshot. - NominatorSnapshotCorrupt, -} - -impl From for OffchainElectionError { - fn from(e: sp_npos_elections::Error) -> Self { - Self::InternalElectionError(e) - } -} - -/// Storage key used to store the persistent offchain worker status. -pub(crate) const OFFCHAIN_HEAD_DB: &[u8] = b"parity/staking-election/"; -/// The repeat threshold of the offchain worker. This means we won't run the offchain worker twice -/// within a window of 5 blocks. -pub(crate) const OFFCHAIN_REPEAT: u32 = 5; -/// Default number of blocks for which the unsigned transaction should stay in the pool -pub(crate) const DEFAULT_LONGEVITY: u64 = 25; - -/// Checks if an execution of the offchain worker is permitted at the given block number, or not. -/// -/// This essentially makes sure that we don't run on previous blocks in case of a re-org, and we -/// don't run twice within a window of length [`OFFCHAIN_REPEAT`]. -/// -/// Returns `Ok(())` if offchain worker should happen, `Err(reason)` otherwise. -pub(crate) fn set_check_offchain_execution_status( - now: T::BlockNumber, -) -> Result<(), &'static str> { - let storage = StorageValueRef::persistent(&OFFCHAIN_HEAD_DB); - let threshold = T::BlockNumber::from(OFFCHAIN_REPEAT); - - let mutate_stat = - storage.mutate::<_, &'static str, _>(|maybe_head: Option>| { - match maybe_head { - Some(Some(head)) if now < head => Err("fork."), - Some(Some(head)) if now >= head && now <= head + threshold => { - Err("recently executed.") - } - Some(Some(head)) if now > head + threshold => { - // we can run again now. Write the new head. - Ok(now) - } - _ => { - // value doesn't exists. Probably this node just booted up. Write, and run - Ok(now) - } - } - }); - - match mutate_stat { - // all good - Ok(Ok(_)) => Ok(()), - // failed to write. - Ok(Err(_)) => Err("failed to write to offchain db."), - // fork etc. - Err(why) => Err(why), - } -} - -/// The internal logic of the offchain worker of this module. This runs the phragmen election, -/// compacts and reduces the solution, computes the score and submits it back to the chain as an -/// unsigned transaction, without any signature. -pub(crate) fn compute_offchain_election() -> Result<(), OffchainElectionError> { - let iters = get_balancing_iters::(); - // compute raw solution. Note that we use `OffchainAccuracy`. - let ElectionResult { - winners, - assignments, - } = >::do_phragmen::(iters) - .ok_or(OffchainElectionError::ElectionFailed)?; - - // process and prepare it for submission. - let (winners, compact, score, size) = prepare_submission::( - assignments, - winners, - true, - T::OffchainSolutionWeightLimit::get(), - )?; - - crate::log!( - info, - "prepared a seq-phragmen solution with {} balancing iterations and score {:?}", - iters, - score, - ); - - // defensive-only: current era can never be none except genesis. - let current_era = >::current_era().unwrap_or_default(); - - // send it. - let call = - Call::submit_election_solution_unsigned(winners, compact, score, current_era, size).into(); - - >>::submit_unsigned_transaction(call) - .map_err(|_| OffchainElectionError::PoolSubmissionFailed) -} - -/// Get a random number of iterations to run the balancing. -/// -/// Uses the offchain seed to generate a random number. -pub fn get_balancing_iters() -> usize { - match T::MaxIterations::get() { - 0 => 0, - max @ _ => { - let seed = sp_io::offchain::random_seed(); - let random = ::decode(&mut TrailingZeroInput::new(seed.as_ref())) - .expect("input is padded with zeroes; qed") - % max.saturating_add(1); - random as usize - } - } -} - -/// Find the maximum `len` that a compact can have in order to fit into the block weight. -/// -/// This only returns a value between zero and `size.nominators`. -pub fn maximum_compact_len( - winners_len: u32, - size: ElectionSize, - max_weight: Weight, -) -> u32 { - use sp_std::cmp::Ordering; - - if size.nominators < 1 { - return size.nominators; - } - - let max_voters = size.nominators.max(1); - let mut voters = max_voters; - - // helper closures. - let weight_with = |voters: u32| -> Weight { - W::submit_solution_better( - size.validators.into(), - size.nominators.into(), - voters, - winners_len, - ) - }; - - let next_voters = |current_weight: Weight, voters: u32, step: u32| -> Result { - match current_weight.cmp(&max_weight) { - Ordering::Less => { - let next_voters = voters.checked_add(step); - match next_voters { - Some(voters) if voters < max_voters => Ok(voters), - _ => Err(()), - } - } - Ordering::Greater => voters.checked_sub(step).ok_or(()), - Ordering::Equal => Ok(voters), - } - }; - - // First binary-search the right amount of voters - let mut step = voters / 2; - let mut current_weight = weight_with(voters); - while step > 0 { - match next_voters(current_weight, voters, step) { - // proceed with the binary search - Ok(next) if next != voters => { - voters = next; - } - // we are out of bounds, break out of the loop. - Err(()) => { - break; - } - // we found the right value - early exit the function. - Ok(next) => return next, - } - step = step / 2; - current_weight = weight_with(voters); - } - - // Time to finish. - // We might have reduced less than expected due to rounding error. Increase one last time if we - // have any room left, the reduce until we are sure we are below limit. - while voters + 1 <= max_voters && weight_with(voters + 1) < max_weight { - voters += 1; - } - while voters.checked_sub(1).is_some() && weight_with(voters) > max_weight { - voters -= 1; - } - - debug_assert!( - weight_with(voters.min(size.nominators)) <= max_weight, - "weight_with({}) <= {}", - voters.min(size.nominators), - max_weight, - ); - voters.min(size.nominators) -} - -/// Greedily reduce the size of the a solution to fit into the block, w.r.t. weight. -/// -/// The weight of the solution is foremost a function of the number of voters (i.e. -/// `compact.len()`). Aside from this, the other components of the weight are invariant. The number -/// of winners shall not be changed (otherwise the solution is invalid) and the `ElectionSize` is -/// merely a representation of the total number of stakers. -/// -/// Thus, we reside to stripping away some voters. This means only changing the `compact` struct. -/// -/// Note that the solution is already computed, and the winners are elected based on the merit of -/// teh entire stake in the system. Nonetheless, some of the voters will be removed further down the -/// line. -/// -/// Indeed, the score must be computed **after** this step. If this step reduces the score too much, -/// then the solution will be discarded. -pub fn trim_to_weight( - maximum_allowed_voters: u32, - mut compact: CompactAssignments, - nominator_index: FN, -) -> Result -where - for<'r> FN: Fn(&'r T::AccountId) -> Option, -{ - match compact - .voter_count() - .checked_sub(maximum_allowed_voters as usize) - { - Some(to_remove) if to_remove > 0 => { - // grab all voters and sort them by least stake. - let mut voters_sorted = >::iter() - .map(|(who, _)| (who.clone(), >::power_of(&who))) - .collect::>(); - voters_sorted.sort_by_key(|(_, y)| *y); - - // start removing from the least stake. Iterate until we know enough have been removed. - let mut removed = 0; - for (maybe_index, _stake) in voters_sorted - .iter() - .map(|(who, stake)| (nominator_index(&who), stake)) - { - let index = maybe_index.ok_or(OffchainElectionError::NominatorSnapshotCorrupt)?; - if compact.remove_voter(index) { - crate::log!( - trace, - "removed a voter at index {} with stake {:?} from compact to reduce the size", - index, - _stake, - ); - removed += 1 - } - - if removed >= to_remove { - break; - } - } - - crate::log!( - warn, - "{} nominators out of {} had to be removed from compact solution due to size \ - limits.", - removed, - compact.voter_count() + removed, - ); - Ok(compact) - } - _ => { - // nada, return as-is - crate::log!( - info, - "Compact solution did not get trimmed due to block weight limits.", - ); - Ok(compact) - } - } -} - -/// Takes an election result and spits out some data that can be submitted to the chain. -/// -/// This does a lot of stuff; read the inline comments. -pub fn prepare_submission( - assignments: Vec>, - winners: Vec<(T::AccountId, ExtendedBalance)>, - do_reduce: bool, - maximum_weight: Weight, -) -> Result< - ( - Vec, - CompactAssignments, - ElectionScore, - ElectionSize, - ), - OffchainElectionError, -> { - // make sure that the snapshot is available. - let snapshot_validators = - >::snapshot_validators().ok_or(OffchainElectionError::SnapshotUnavailable)?; - let snapshot_nominators = - >::snapshot_nominators().ok_or(OffchainElectionError::SnapshotUnavailable)?; - - // all helper closures that we'd ever need. - let nominator_index = |a: &T::AccountId| -> Option { - snapshot_nominators - .iter() - .position(|x| x == a) - .and_then(|i| >::try_into(i).ok()) - }; - let validator_index = |a: &T::AccountId| -> Option { - snapshot_validators - .iter() - .position(|x| x == a) - .and_then(|i| >::try_into(i).ok()) - }; - let nominator_at = |i: NominatorIndex| -> Option { - snapshot_nominators.get(i as usize).cloned() - }; - - let validator_at = |i: ValidatorIndex| -> Option { - snapshot_validators.get(i as usize).cloned() - }; - - // both conversions are safe; snapshots are not created if they exceed. - let size = ElectionSize { - validators: snapshot_validators.len() as ValidatorIndex, - nominators: snapshot_nominators.len() as NominatorIndex, - }; - - // Clean winners. - let winners = sp_npos_elections::to_without_backing(winners); - - // convert into absolute value and to obtain the reduced version. - let mut staked = sp_npos_elections::assignment_ratio_to_staked(assignments, |s| { - >::power_of(s) as _ - }); - - // reduce - if do_reduce { - reduce(&mut staked); - } - - // Convert back to ratio assignment. This takes less space. - let low_accuracy_assignment = sp_npos_elections::assignment_staked_to_ratio_normalized(staked) - .map_err(|e| OffchainElectionError::from(e))?; - - // compact encode the assignment. - let compact = CompactAssignments::from_assignment( - low_accuracy_assignment, - nominator_index, - validator_index, - ) - .map_err(|e| OffchainElectionError::from(e))?; - - // potentially reduce the size of the compact to fit weight. - let maximum_allowed_voters = - maximum_compact_len::(winners.len() as u32, size, maximum_weight); - - crate::log!( - debug, - "Maximum weight = {:?} // current weight = {:?} // maximum voters = {:?} // current votes \ - = {:?}", - maximum_weight, - T::WeightInfo::submit_solution_better( - size.validators.into(), - size.nominators.into(), - compact.voter_count() as u32, - winners.len() as u32, - ), - maximum_allowed_voters, - compact.voter_count(), - ); - - let compact = trim_to_weight::(maximum_allowed_voters, compact, &nominator_index)?; - - // re-compute the score. We re-create what the chain will do. This is a bit verbose and wastes - // CPU time, but it is necessary to ensure that the score that we claim is the same as the one - // calculated by the chain. - let score = { - let compact = compact.clone(); - let assignments = compact.into_assignment(nominator_at, validator_at).unwrap(); - let staked = sp_npos_elections::assignment_ratio_to_staked(assignments, |s| { - >::power_of(s) as _ - }); - - let support_map = to_supports::(&winners, &staked) - .map_err(|_| OffchainElectionError::ElectionFailed)?; - support_map.evaluate() - }; - - // winners to index. Use a simple for loop for a more expressive early exit in case of error. - let mut winners_indexed: Vec = Vec::with_capacity(winners.len()); - for w in winners { - if let Some(idx) = snapshot_validators.iter().position(|v| *v == w) { - let compact_index: ValidatorIndex = idx - .try_into() - .map_err(|_| OffchainElectionError::InvalidWinner)?; - winners_indexed.push(compact_index); - } else { - return Err(OffchainElectionError::InvalidWinner); - } - } - - Ok((winners_indexed, compact, score, size)) -} - -#[cfg(test)] -mod test { - #![allow(unused_variables)] - use super::*; - use crate::ElectionSize; - - struct Staking; - - impl crate::WeightInfo for Staking { - fn bond() -> Weight { - unimplemented!() - } - fn bond_extra() -> Weight { - unimplemented!() - } - fn deposit_extra() -> Weight { - unimplemented!() - } - fn unbond() -> Weight { - unimplemented!() - } - fn validate() -> Weight { - unimplemented!() - } - fn nominate(n: u32) -> Weight { - unimplemented!() - } - fn chill() -> Weight { - unimplemented!() - } - fn set_payee() -> Weight { - unimplemented!() - } - fn set_controller() -> Weight { - unimplemented!() - } - fn set_validator_count() -> Weight { - unimplemented!() - } - fn force_no_eras() -> Weight { - unimplemented!() - } - fn force_new_era() -> Weight { - unimplemented!() - } - fn force_new_era_always() -> Weight { - unimplemented!() - } - fn set_invulnerables(v: u32) -> Weight { - unimplemented!() - } - fn force_unstake(s: u32) -> Weight { - unimplemented!() - } - fn cancel_deferred_slash(s: u32) -> Weight { - unimplemented!() - } - fn payout_stakers_dead_controller(n: u32) -> Weight { - unimplemented!() - } - fn payout_stakers_alive_staked(n: u32) -> Weight { - unimplemented!() - } - fn rebond(l: u32) -> Weight { - unimplemented!() - } - fn set_history_depth(e: u32) -> Weight { - unimplemented!() - } - fn reap_stash(s: u32) -> Weight { - unimplemented!() - } - fn new_era(v: u32, n: u32) -> Weight { - unimplemented!() - } - fn submit_solution_better(v: u32, n: u32, a: u32, w: u32) -> Weight { - (0 * v + 0 * n + 1000 * a + 0 * w) as Weight - } - fn kick(w: u32) -> Weight { - unimplemented!() - } - } - - #[test] - fn find_max_voter_binary_search_works() { - let size = ElectionSize { - validators: 0, - nominators: 10, - }; - - assert_eq!(maximum_compact_len::(0, size, 0), 0); - assert_eq!(maximum_compact_len::(0, size, 1), 0); - assert_eq!(maximum_compact_len::(0, size, 999), 0); - assert_eq!(maximum_compact_len::(0, size, 1000), 1); - assert_eq!(maximum_compact_len::(0, size, 1001), 1); - assert_eq!(maximum_compact_len::(0, size, 1990), 1); - assert_eq!(maximum_compact_len::(0, size, 1999), 1); - assert_eq!(maximum_compact_len::(0, size, 2000), 2); - assert_eq!(maximum_compact_len::(0, size, 2001), 2); - assert_eq!(maximum_compact_len::(0, size, 2010), 2); - assert_eq!(maximum_compact_len::(0, size, 2990), 2); - assert_eq!(maximum_compact_len::(0, size, 2999), 2); - assert_eq!(maximum_compact_len::(0, size, 3000), 3); - assert_eq!(maximum_compact_len::(0, size, 3333), 3); - assert_eq!(maximum_compact_len::(0, size, 5500), 5); - assert_eq!(maximum_compact_len::(0, size, 7777), 7); - assert_eq!(maximum_compact_len::(0, size, 9999), 9); - assert_eq!(maximum_compact_len::(0, size, 10_000), 10); - assert_eq!(maximum_compact_len::(0, size, 10_999), 10); - assert_eq!(maximum_compact_len::(0, size, 11_000), 10); - assert_eq!(maximum_compact_len::(0, size, 22_000), 10); - - let size = ElectionSize { - validators: 0, - nominators: 1, - }; - - assert_eq!(maximum_compact_len::(0, size, 0), 0); - assert_eq!(maximum_compact_len::(0, size, 1), 0); - assert_eq!(maximum_compact_len::(0, size, 999), 0); - assert_eq!(maximum_compact_len::(0, size, 1000), 1); - assert_eq!(maximum_compact_len::(0, size, 1001), 1); - assert_eq!(maximum_compact_len::(0, size, 1990), 1); - assert_eq!(maximum_compact_len::(0, size, 1999), 1); - assert_eq!(maximum_compact_len::(0, size, 2000), 1); - assert_eq!(maximum_compact_len::(0, size, 2001), 1); - assert_eq!(maximum_compact_len::(0, size, 2010), 1); - assert_eq!(maximum_compact_len::(0, size, 3333), 1); - - let size = ElectionSize { - validators: 0, - nominators: 2, - }; - - assert_eq!(maximum_compact_len::(0, size, 0), 0); - assert_eq!(maximum_compact_len::(0, size, 1), 0); - assert_eq!(maximum_compact_len::(0, size, 999), 0); - assert_eq!(maximum_compact_len::(0, size, 1000), 1); - assert_eq!(maximum_compact_len::(0, size, 1001), 1); - assert_eq!(maximum_compact_len::(0, size, 1999), 1); - assert_eq!(maximum_compact_len::(0, size, 2000), 2); - assert_eq!(maximum_compact_len::(0, size, 2001), 2); - assert_eq!(maximum_compact_len::(0, size, 2010), 2); - assert_eq!(maximum_compact_len::(0, size, 3333), 2); - } -} diff --git a/frame/staking/src/slashing.rs b/frame/staking/src/slashing.rs index 9bacb89771..f0d0242e8f 100644 --- a/frame/staking/src/slashing.rs +++ b/frame/staking/src/slashing.rs @@ -724,7 +724,7 @@ pub fn do_slash( let (slash_ring, slash_kton) = ledger.slash( value.r, value.k, - >::block_number(), + >::block_number(), T::UnixTime::now().as_millis().saturated_into::(), ); let mut slashed = false; diff --git a/frame/staking/src/substrate_tests.rs b/frame/staking/src/substrate_tests.rs index 4b44a536fe..35ddcb3922 100644 --- a/frame/staking/src/substrate_tests.rs +++ b/frame/staking/src/substrate_tests.rs @@ -28,62 +28,11 @@ //! + If you want to delete some functions, please left some comments //! explaining why you delete them. -mod offchain_election { - // --- darwinia --- - use crate::{mock::*, *}; - - /// setup a new set of validators and nominator storage items independent of the parent mock - /// file. This produces a edge graph that can be reduced. - pub fn build_offchain_election_test_ext() { - for i in (10..=40).step_by(10) { - // Note: we respect the convention of the mock (10, 11 pairs etc.) since these accounts - // have corresponding keys in session which makes everything more ergonomic and - // realistic. - bond_validator(i + 1, i, StakingBalance::RingBalance(100)); - } - - let mut voter = 1; - bond_nominator( - voter, - 1000 + voter, - StakingBalance::RingBalance(100), - vec![11], - ); - voter = 2; - bond_nominator( - voter, - 1000 + voter, - StakingBalance::RingBalance(100), - vec![11, 11], - ); - voter = 3; - bond_nominator( - voter, - 1000 + voter, - StakingBalance::RingBalance(100), - vec![21, 41], - ); - voter = 4; - bond_nominator( - voter, - 1000 + voter, - StakingBalance::RingBalance(100), - vec![21, 31, 41], - ); - voter = 5; - bond_nominator( - voter, - 1000 + voter, - StakingBalance::RingBalance(100), - vec![21, 31, 41], - ); - } -} - // --- substrate --- +use frame_election_provider_support::Support; use frame_support::{ assert_noop, assert_ok, - traits::{Currency, OnFinalize, OnInitialize, ReservableCurrency}, + traits::{Currency, OnInitialize, ReservableCurrency}, StorageMap, }; use sp_runtime::{assert_eq_error_rate, traits::BadOrigin}; @@ -216,15 +165,13 @@ fn basic_setup_works() { own_kton_balance: 0, own_power: Staking::power_of(&11), // Allow error rate 1 - total_power: Staking::power_of(&11) - + Staking::currency_to_power(125, Staking::ring_pool()) - + 1, + total_power: Staking::power_of(&11) + ring_power(125) + 1, others: vec![IndividualExposure { who: 101, ring_balance: 125, kton_balance: 0, // Allow error rate 1 - power: Staking::currency_to_power(125, Staking::ring_pool()) + 1, + power: ring_power(125) + 1, }] } ); @@ -236,16 +183,14 @@ fn basic_setup_works() { own_kton_balance: 0, own_power: Staking::power_of(&21), // Allow error rate 1 - total_power: Staking::power_of(&21) - + Staking::currency_to_power(375, Staking::ring_pool()) - - 1, + total_power: Staking::power_of(&21) + ring_power(375) - 1, others: vec![IndividualExposure { who: 101, // Allow error rate 1 ring_balance: 375 - 1, kton_balance: 0, // Allow error rate 1 - power: Staking::currency_to_power(375, Staking::ring_pool()) - 1, + power: ring_power(375) - 1, }] } ); @@ -341,10 +286,10 @@ fn rewards_should_work() { individual: vec![(11, 100), (21, 50)].into_iter().collect(), } ); - let part_for_10 = Perbill::from_rational_approximation::(1000, 1125); - let part_for_20 = Perbill::from_rational_approximation::(1000, 1375); - let part_for_100_from_10 = Perbill::from_rational_approximation::(125, 1125); - let part_for_100_from_20 = Perbill::from_rational_approximation::(375, 1375); + let part_for_10 = Perbill::from_rational::(1000, 1125); + let part_for_20 = Perbill::from_rational::(1000, 1375); + let part_for_100_from_10 = Perbill::from_rational::(125, 1125); + let part_for_100_from_20 = Perbill::from_rational::(375, 1375); start_session(2); start_session(3); @@ -682,21 +627,20 @@ fn nominating_and_rewards_should_work() { Exposure { own_ring_balance: 1000, own_kton_balance: 0, - own_power: Staking::currency_to_power(1000, Staking::ring_pool()), - total_power: Staking::currency_to_power(1000, Staking::ring_pool()) - + Staking::currency_to_power(800, Staking::ring_pool()), + own_power: ring_power(1000), + total_power: ring_power(1000) + ring_power(800), others: vec![ IndividualExposure { who: 3, ring_balance: 400, kton_balance: 0, - power: Staking::currency_to_power(400, Staking::ring_pool()), + power: ring_power(400), }, IndividualExposure { who: 1, ring_balance: 400, kton_balance: 0, - power: Staking::currency_to_power(400, Staking::ring_pool()), + power: ring_power(400), }, ], }, @@ -706,23 +650,22 @@ fn nominating_and_rewards_should_work() { Exposure { own_ring_balance: 1000, own_kton_balance: 0, - own_power: Staking::currency_to_power(1000, Staking::ring_pool()), - total_power: Staking::currency_to_power(1000, Staking::ring_pool()) - + Staking::currency_to_power(1200, Staking::ring_pool()), + own_power: ring_power(1000), + total_power: ring_power(1000) + ring_power(1200), others: vec![ IndividualExposure { who: 3, // expect 600, error rate 1 ring_balance: 599, kton_balance: 0, - power: Staking::currency_to_power(600, Staking::ring_pool()), + power: ring_power(600), }, IndividualExposure { who: 1, // expect 600, error rate 1 ring_balance: 599, kton_balance: 0, - power: Staking::currency_to_power(600, Staking::ring_pool()), + power: ring_power(600), }, ], }, @@ -802,9 +745,9 @@ fn nominators_also_get_slashed_pro_rata() { let slash_amount = slash_percent * exposed_stake; let validator_share = - Perbill::from_rational_approximation(exposed_validator, exposed_stake) * slash_amount; + Perbill::from_rational(exposed_validator, exposed_stake) * slash_amount; let nominator_share = - Perbill::from_rational_approximation(exposed_nominator, exposed_stake) * slash_amount; + Perbill::from_rational(exposed_nominator, exposed_stake) * slash_amount; // both slash amounts need to be positive for the test to make sense. assert!(validator_share > 0); @@ -812,9 +755,9 @@ fn nominators_also_get_slashed_pro_rata() { // both stakes must have been decreased pro-rata. let nominator_share = - Perbill::from_rational_approximation(nominator_share, exposed_stake) * nominator_stake; + Perbill::from_rational(nominator_share, exposed_stake) * nominator_stake; let validator_share = - Perbill::from_rational_approximation(validator_share, exposed_stake) * validator_stake; + Perbill::from_rational(validator_share, exposed_stake) * validator_stake; assert_eq_error_rate!( Staking::ledger(100).unwrap().active_ring, @@ -1780,8 +1723,8 @@ fn reward_to_stake_works() { Exposure { own_ring_balance: 69, own_kton_balance: 0, - total_power: Staking::currency_to_power(69, Staking::ring_pool()), - own_power: Staking::currency_to_power(69, Staking::ring_pool()), + total_power: ring_power(69), + own_power: ring_power(69), others: vec![], }, ); @@ -2219,7 +2162,7 @@ fn bond_with_little_staked_value_bounded() { } #[test] -fn bond_with_duplicate_vote_should_be_ignored_by_npos_election() { +fn bond_with_duplicate_vote_should_be_ignored_by_election_provider() { ExtBuilder::default() .validator_count(2) .nominate(false) @@ -2234,13 +2177,14 @@ fn bond_with_duplicate_vote_should_be_ignored_by_npos_election() { StakingBalance::RingBalance(999), 0 )); - + // ensure all have equal stake. assert_eq!( >::iter() - .map(|(v, _)| (v, Staking::ledger(v - 1).unwrap().active_ring)) + .map(|(v, _)| (v, Staking::power_of(&v))) .collect::>(), - vec![(31, 1000), (21, 1000), (11, 1000)], + vec![(31, 111111111), (21, 111111111), (11, 111111111)], ); + // no nominators shall exist. assert!(>::iter() .map(|(n, _)| n) .collect::>() @@ -2259,10 +2203,9 @@ fn bond_with_duplicate_vote_should_be_ignored_by_npos_election() { RewardDestination::Controller, 0 )); - // 11 should not be elected. All of these count as ONE vote. assert_ok!(Staking::nominate( Origin::signed(2), - vec![11, 11, 11, 21, 31,] + vec![11, 11, 11, 21, 31] )); assert_ok!(Staking::bond( @@ -2274,29 +2217,42 @@ fn bond_with_duplicate_vote_should_be_ignored_by_npos_election() { )); assert_ok!(Staking::nominate(Origin::signed(4), vec![21, 31])); - // winners should be 21 and 31. Otherwise this election is taking duplicates into account. - let sp_npos_elections::ElectionResult { - winners, - assignments, - } = Staking::do_phragmen::(0).unwrap(); - let winners = sp_npos_elections::to_without_backing(winners); - - assert_eq!(winners, vec![31, 21]); - // only distribution to 21 and 31. + // winners should be 21 and 31. Otherwise this election is taking duplicates into + // account. + let supports = ::ElectionProvider::elect().unwrap().0; assert_eq!( - assignments - .iter() - .find(|a| a.who == 1) - .unwrap() - .distribution - .len(), - 2 + supports, + vec![ + ( + 21, + Support { + // error rate 1 + total: (ring_power(1800) + 1) as _, + voters: vec![ + (21, ring_power(1000) as _), + (3, ring_power(400) as _), + (1, ring_power(400) as _) + ] + } + ), + ( + 31, + Support { + total: ring_power(2200) as _, + voters: vec![ + (31, ring_power(1000) as _), + (3, ring_power(600) as _), + (1, ring_power(600) as _) + ] + } + ) + ], ); }); } #[test] -fn bond_with_duplicate_vote_should_be_ignored_by_npos_election_elected() { +fn bond_with_duplicate_vote_should_be_ignored_by_election_provider_elected() { // same as above but ensures that even when the duple is being elected, everything is sane. ExtBuilder::default() .validator_count(2) @@ -2306,19 +2262,20 @@ fn bond_with_duplicate_vote_should_be_ignored_by_npos_election_elected() { .execute_with(|| { // disable the nominator assert_ok!(Staking::chill(Origin::signed(100))); - // make stakes equal. + // 31/30 will have less stake assert_ok!(Staking::bond_extra( Origin::signed(31), StakingBalance::RingBalance(99), 0 )); - + // ensure all have equal stake. assert_eq!( >::iter() .map(|(v, _)| (v, Staking::ledger(v - 1).unwrap().active_ring)) .collect::>(), vec![(31, 100), (21, 1000), (11, 1000)], ); + // no nominators shall exist. assert!(>::iter() .map(|(n, _)| n) .collect::>() @@ -2339,7 +2296,7 @@ fn bond_with_duplicate_vote_should_be_ignored_by_npos_election_elected() { )); assert_ok!(Staking::nominate( Origin::signed(2), - vec![11, 11, 11, 21, 31,] + vec![11, 11, 11, 21, 31] )); assert_ok!(Staking::bond( @@ -2351,24 +2308,31 @@ fn bond_with_duplicate_vote_should_be_ignored_by_npos_election_elected() { )); assert_ok!(Staking::nominate(Origin::signed(4), vec![21, 31])); - // winners should be 21 and 31. Otherwise this election is taking duplicates into account. - - let sp_npos_elections::ElectionResult { - winners, - assignments, - } = Staking::do_phragmen::(0).unwrap(); - - let winners = sp_npos_elections::to_without_backing(winners); - assert_eq!(winners, vec![21, 11]); - // only distribution to 21 and 31. + // winners should be 21 and 11. + let supports = ::ElectionProvider::elect().unwrap().0; assert_eq!( - assignments - .iter() - .find(|a| a.who == 1) - .unwrap() - .distribution - .len(), - 2 + supports, + vec![ + ( + 11, + Support { + total: ring_power(1500) as _, + voters: vec![(11, ring_power(1000) as _), (1, ring_power(500) as _)] + } + ), + ( + 21, + Support { + // error rate 1 + total: (ring_power(2500) - 1) as _, + voters: vec![ + (21, ring_power(1000) as _), + (3, ring_power(1000) as _), + (1, ring_power(500) as _) + ] + } + ) + ], ); }); } @@ -2434,8 +2398,8 @@ fn reward_validator_slashing_validator_does_not_overflow() { let exposure = Exposure:: { own_ring_balance: stake, own_kton_balance: 0, - own_power: Staking::currency_to_power(stake, Staking::ring_pool()), - total_power: Staking::currency_to_power(stake, Staking::ring_pool()), + own_power: ring_power(stake), + total_power: ring_power(stake), others: vec![], }; let reward = EraRewardPoints:: { @@ -2472,14 +2436,14 @@ fn reward_validator_slashing_validator_does_not_overflow() { &11, Exposure { own_ring_balance: 1, - total_power: Staking::currency_to_power(stake, Staking::ring_pool()), + total_power: ring_power(stake), own_kton_balance: 0, - own_power: Staking::currency_to_power(1, Staking::ring_pool()), + own_power: ring_power(1), others: vec![IndividualExposure { who: 2, ring_balance: stake - 1, kton_balance: 0, - power: Staking::currency_to_power(stake - 1, Staking::ring_pool()), + power: ring_power(stake - 1), }], }, ); @@ -2674,7 +2638,7 @@ fn slashing_performed_according_exposure() { offender: ( 11, Exposure { - total_power: Staking::currency_to_power(500, Staking::ring_pool()), + total_power: ring_power(500), own_ring_balance: 500, own_kton_balance: 0, own_power: 0, @@ -3450,16 +3414,8 @@ fn slash_kicks_validators_not_nominators_and_disables_nominator_for_kicked_valid let exposure_11 = Staking::eras_stakers(active_era(), &11); let exposure_21 = Staking::eras_stakers(active_era(), &21); - assert_eq_error_rate!( - exposure_11.total_power, - Staking::currency_to_power(1000 + 125, Staking::ring_pool()), - 1 - ); - assert_eq_error_rate!( - exposure_21.total_power, - Staking::currency_to_power(1000 + 375, Staking::ring_pool()), - 1 - ); + assert_eq_error_rate!(exposure_11.total_power, ring_power(1000 + 125), 1); + assert_eq_error_rate!(exposure_21.total_power, ring_power(1000 + 375), 1); on_offence_now( &[OffenceDetails { @@ -3497,18 +3453,12 @@ fn slash_kicks_validators_not_nominators_and_disables_nominator_for_kicked_valid let exposure_21 = Staking::eras_stakers(active_era(), &21); // 10 is re-elected, but without the support of 100 - assert_eq!( - exposure_11.total_power, - Staking::currency_to_power(900, Staking::ring_pool()) - ); + assert_eq!(exposure_11.total_power, ring_power(900)); // 20 is re-elected, with the (almost) entire support of 100 assert_eq_error_rate!( exposure_21.total_power, - Staking::currency_to_power( - 1000 + 500 - nominator_slash_amount_11, - Staking::ring_pool() - ), + ring_power(1000 + 500 - nominator_slash_amount_11), 10 ); }); @@ -3524,8 +3474,8 @@ fn claim_reward_at_the_last_era_and_no_double_claim_and_invalid_claim() { let init_balance_10 = Ring::free_balance(&10); let init_balance_100 = Ring::free_balance(&100); - let part_for_10 = Perbill::from_rational_approximation::(1000, 1125); - let part_for_100 = Perbill::from_rational_approximation::(125, 1125); + let part_for_10 = Perbill::from_rational::(1000, 1125); + let part_for_100 = Perbill::from_rational::(125, 1125); // Check state >::insert(11, RewardDestination::Controller); @@ -4068,42 +4018,6 @@ fn offences_weight_calculated_correctly() { }); } -#[test] -fn on_initialize_weight_is_correct() { - ExtBuilder::default() - .has_stakers(false) - .build_and_execute(|| { - assert_eq!(>::iter().count(), 0); - assert_eq!(>::iter().count(), 0); - // When this pallet has nothing, we do 4 reads each block - let base_weight = ::DbWeight::get().reads(4); - assert_eq!(base_weight, Staking::on_initialize(0)); - }); - - ExtBuilder::default() - .offchain_election_ext() - .validator_count(4) - .has_stakers(false) - .build() - .execute_with(|| { - crate::substrate_tests::offchain_election::build_offchain_election_test_ext(); - run_to_block(11); - Staking::on_finalize(System::block_number()); - System::set_block_number((System::block_number() + 1).into()); - Timestamp::set_timestamp(System::block_number() * 1000 + INIT_TIMESTAMP); - Session::on_initialize(System::block_number()); - - assert_eq!(>::iter().count(), 4); - assert_eq!(>::iter().count(), 5); - // With 4 validators and 5 nominator, we should increase weight by: - // - (4 + 5) reads - // - 3 Writes - let final_weight = - ::DbWeight::get().reads_writes(4 + 9, 3); - assert_eq!(final_weight, Staking::on_initialize(System::block_number())); - }); -} - #[test] fn payout_creates_controller() { ExtBuilder::default() @@ -4371,7 +4285,43 @@ fn cannot_bond_to_lower_than_ed() { mod election_data_provider { use super::*; - use sp_election_providers::ElectionDataProvider; + use frame_election_provider_support::ElectionDataProvider; + + #[test] + fn targets_2sec_block() { + let mut validators = 1000; + while ::WeightInfo::get_npos_targets(validators) + < 2 * frame_support::weights::constants::WEIGHT_PER_SECOND + { + validators += 1; + } + + println!( + "Can create a snapshot of {} validators in 2sec block", + validators + ); + } + + #[test] + fn voters_2sec_block() { + // we assume a network only wants up to 1000 validators in most cases, thus having 2000 + // candidates is as high as it gets. + let validators = 2000; + // we assume the worse case: each validator also has a slashing span. + let slashing_spans = validators; + let mut nominators = 1000; + + while ::WeightInfo::get_npos_voters(validators, nominators, slashing_spans) + < 2 * frame_support::weights::constants::WEIGHT_PER_SECOND + { + nominators += 1; + } + + println!( + "Can create a snapshot of {} nominators [{} validators, each 1 slashing] in 2sec block", + nominators, validators + ); + } #[test] fn voters_include_self_vote() { @@ -4381,7 +4331,9 @@ mod election_data_provider { .execute_with(|| { assert!(>::iter() .map(|(x, _)| x) - .all(|v| Staking::voters() + .all(|v| Staking::voters(None) + .unwrap() + .0 .into_iter() .find(|(w, _, t)| { v == *w && t[0] == *w }) .is_some())) @@ -4393,7 +4345,9 @@ mod election_data_provider { ExtBuilder::default().build().execute_with(|| { assert_eq!(Staking::nominators(101).unwrap().targets, vec![11, 21]); assert_eq!( - >::voters() + >::voters(None) + .unwrap() + .0 .iter() .find(|x| x.0 == 101) .unwrap() @@ -4407,7 +4361,9 @@ mod election_data_provider { // 11 is gone. start_active_era(2); assert_eq!( - >::voters() + >::voters(None) + .unwrap() + .0 .iter() .find(|x| x.0 == 101) .unwrap() @@ -4418,7 +4374,9 @@ mod election_data_provider { // resubmit and it is back assert_ok!(Staking::nominate(Origin::signed(100), vec![11, 21])); assert_eq!( - >::voters() + >::voters(None) + .unwrap() + .0 .iter() .find(|x| x.0 == 101) .unwrap() @@ -4428,6 +4386,20 @@ mod election_data_provider { }) } + #[test] + fn respects_len_limits() { + ExtBuilder::default().build().execute_with(|| { + assert_eq!( + Staking::voters(Some(1)).unwrap_err(), + "Voter snapshot too big" + ); + assert_eq!( + Staking::targets(Some(1)).unwrap_err(), + "Target snapshot too big" + ); + }); + } + #[test] fn estimate_next_election_works() { ExtBuilder::default() @@ -4451,10 +4423,7 @@ mod election_data_provider { 45 ); assert_eq!(staking_events().len(), 1); - assert_eq!( - *staking_events().last().unwrap(), - RawEvent::StakingElection(ElectionCompute::OnChain) - ); + assert_eq!(*staking_events().last().unwrap(), RawEvent::StakingElection); for b in 21..45 { run_to_block(b); @@ -4471,10 +4440,7 @@ mod election_data_provider { 70 ); assert_eq!(staking_events().len(), 3); - assert_eq!( - *staking_events().last().unwrap(), - RawEvent::StakingElection(ElectionCompute::OnChain) - ); + assert_eq!(*staking_events().last().unwrap(), RawEvent::StakingElection); }) } } diff --git a/frame/staking/src/weights.rs b/frame/staking/src/weights.rs index bbcc74ea20..b6d9f90ba0 100644 --- a/frame/staking/src/weights.rs +++ b/frame/staking/src/weights.rs @@ -1,7 +1,7 @@ //! Autogenerated weights for pallet_staking //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 -//! DATE: 2021-02-13, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: [], HIGH RANGE: [] +//! DATE: 2021-03-14, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 128 // Executed Command: @@ -33,6 +33,8 @@ pub trait WeightInfo { fn bond_extra() -> Weight; fn deposit_extra() -> Weight; fn unbond() -> Weight; + fn claim_mature_deposits() -> Weight; + fn try_claim_deposits_with_punish() -> Weight; fn validate() -> Weight; fn kick(k: u32) -> Weight; fn nominate(n: u32) -> Weight; @@ -53,147 +55,159 @@ pub trait WeightInfo { fn reap_stash(s: u32) -> Weight; fn new_era(v: u32, n: u32) -> Weight; fn submit_solution_better(v: u32, n: u32, a: u32, w: u32) -> Weight; + fn get_npos_voters(v: u32, n: u32, s: u32) -> Weight; + fn get_npos_targets(v: u32) -> Weight; } /// Weights for pallet_staking using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { fn bond() -> Weight { - (81_642_000 as Weight) + (80_317_000 as Weight) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) } fn bond_extra() -> Weight { - (66_025_000 as Weight) + (64_495_000 as Weight) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } fn deposit_extra() -> Weight { - (66_025_000 as Weight) + (64_495_000 as Weight) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } fn unbond() -> Weight { - (60_810_000 as Weight) + (59_679_000 as Weight) + .saturating_add(T::DbWeight::get().reads(5 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) + } + fn claim_mature_deposits() -> Weight { + (59_679_000 as Weight) + .saturating_add(T::DbWeight::get().reads(5 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) + } + fn try_claim_deposits_with_punish() -> Weight { + (59_679_000 as Weight) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } fn validate() -> Weight { - (21_009_000 as Weight) + (20_608_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } fn kick(k: u32) -> Weight { - (31_832_000 as Weight) - // Standard Error: 15_000 - .saturating_add((19_418_000 as Weight).saturating_mul(k as Weight)) + (33_365_000 as Weight) + // Standard Error: 11_000 + .saturating_add((18_830_000 as Weight).saturating_mul(k as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(k as Weight))) .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(k as Weight))) } fn nominate(n: u32) -> Weight { - (34_304_000 as Weight) - // Standard Error: 20_000 - .saturating_add((5_643_000 as Weight).saturating_mul(n as Weight)) + (33_885_000 as Weight) + // Standard Error: 22_000 + .saturating_add((5_562_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(n as Weight))) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } fn chill() -> Weight { - (20_103_000 as Weight) + (19_741_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } fn set_payee() -> Weight { - (13_858_000 as Weight) + (13_674_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } fn set_controller() -> Weight { - (30_269_000 as Weight) + (29_691_000 as Weight) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } fn set_validator_count() -> Weight { - (2_444_000 as Weight).saturating_add(T::DbWeight::get().writes(1 as Weight)) + (2_375_000 as Weight).saturating_add(T::DbWeight::get().writes(1 as Weight)) } fn force_no_eras() -> Weight { - (2_766_000 as Weight).saturating_add(T::DbWeight::get().writes(1 as Weight)) + (2_601_000 as Weight).saturating_add(T::DbWeight::get().writes(1 as Weight)) } fn force_new_era() -> Weight { - (2_724_000 as Weight).saturating_add(T::DbWeight::get().writes(1 as Weight)) + (2_605_000 as Weight).saturating_add(T::DbWeight::get().writes(1 as Weight)) } fn force_new_era_always() -> Weight { - (2_702_000 as Weight).saturating_add(T::DbWeight::get().writes(1 as Weight)) + (2_584_000 as Weight).saturating_add(T::DbWeight::get().writes(1 as Weight)) } fn set_invulnerables(v: u32) -> Weight { - (2_914_000 as Weight) + (2_725_000 as Weight) // Standard Error: 0 .saturating_add((35_000 as Weight).saturating_mul(v as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } fn force_unstake(s: u32) -> Weight { - (64_032_000 as Weight) - // Standard Error: 2_000 - .saturating_add((2_787_000 as Weight).saturating_mul(s as Weight)) + (63_551_000 as Weight) + // Standard Error: 7_000 + .saturating_add((2_844_000 as Weight).saturating_mul(s as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(8 as Weight)) .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) } fn cancel_deferred_slash(s: u32) -> Weight { - (5_903_394_000 as Weight) + (5_905_400_000 as Weight) // Standard Error: 391_000 - .saturating_add((34_834_000 as Weight).saturating_mul(s as Weight)) + .saturating_add((34_785_000 as Weight).saturating_mul(s as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } fn payout_stakers_dead_controller(n: u32) -> Weight { - (141_724_000 as Weight) - // Standard Error: 24_000 - .saturating_add((53_018_000 as Weight).saturating_mul(n as Weight)) + (142_264_000 as Weight) + // Standard Error: 22_000 + .saturating_add((52_542_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(11 as Weight)) .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) .saturating_add(T::DbWeight::get().writes(2 as Weight)) .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(n as Weight))) } fn payout_stakers_alive_staked(n: u32) -> Weight { - (159_994_000 as Weight) - // Standard Error: 28_000 - .saturating_add((67_746_000 as Weight).saturating_mul(n as Weight)) + (180_166_000 as Weight) + // Standard Error: 23_000 + .saturating_add((66_767_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(12 as Weight)) .saturating_add(T::DbWeight::get().reads((5 as Weight).saturating_mul(n as Weight))) .saturating_add(T::DbWeight::get().writes(3 as Weight)) .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(n as Weight))) } fn rebond(l: u32) -> Weight { - (42_177_000 as Weight) - // Standard Error: 1_000 - .saturating_add((82_000 as Weight).saturating_mul(l as Weight)) + (42_577_000 as Weight) + // Standard Error: 12_000 + .saturating_add((60_000 as Weight).saturating_mul(l as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } fn set_history_depth(e: u32) -> Weight { (0 as Weight) - // Standard Error: 65_000 - .saturating_add((34_151_000 as Weight).saturating_mul(e as Weight)) + // Standard Error: 68_000 + .saturating_add((33_362_000 as Weight).saturating_mul(e as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) .saturating_add(T::DbWeight::get().writes((7 as Weight).saturating_mul(e as Weight))) } fn reap_stash(s: u32) -> Weight { - (68_377_000 as Weight) - // Standard Error: 0 - .saturating_add((2_757_000 as Weight).saturating_mul(s as Weight)) + (68_474_000 as Weight) + // Standard Error: 1_000 + .saturating_add((2_770_000 as Weight).saturating_mul(s as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(8 as Weight)) .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) } fn new_era(v: u32, n: u32) -> Weight { (0 as Weight) - // Standard Error: 908_000 - .saturating_add((588_562_000 as Weight).saturating_mul(v as Weight)) + // Standard Error: 903_000 + .saturating_add((594_145_000 as Weight).saturating_mul(v as Weight)) // Standard Error: 45_000 - .saturating_add((83_485_000 as Weight).saturating_mul(n as Weight)) + .saturating_add((83_373_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(9 as Weight)) .saturating_add(T::DbWeight::get().reads((4 as Weight).saturating_mul(v as Weight))) .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) @@ -203,158 +217,187 @@ impl WeightInfo for SubstrateWeight { fn submit_solution_better(v: u32, n: u32, a: u32, w: u32) -> Weight { (0 as Weight) // Standard Error: 52_000 - .saturating_add((750_000 as Weight).saturating_mul(v as Weight)) + .saturating_add((1_460_000 as Weight).saturating_mul(v as Weight)) // Standard Error: 20_000 - .saturating_add((556_000 as Weight).saturating_mul(n as Weight)) + .saturating_add((754_000 as Weight).saturating_mul(n as Weight)) // Standard Error: 52_000 - .saturating_add((76_201_000 as Weight).saturating_mul(a as Weight)) + .saturating_add((74_798_000 as Weight).saturating_mul(a as Weight)) // Standard Error: 108_000 - .saturating_add((7_271_000 as Weight).saturating_mul(w as Weight)) + .saturating_add((8_108_000 as Weight).saturating_mul(w as Weight)) .saturating_add(T::DbWeight::get().reads(6 as Weight)) .saturating_add(T::DbWeight::get().reads((4 as Weight).saturating_mul(a as Weight))) .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(w as Weight))) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } + fn get_npos_voters(v: u32, n: u32, s: u32) -> Weight { + (0 as Weight) + // Standard Error: 94_000 + .saturating_add((29_321_000 as Weight).saturating_mul(v as Weight)) + // Standard Error: 94_000 + .saturating_add((66_885_000 as Weight).saturating_mul(n as Weight)) + // Standard Error: 1_283_000 + .saturating_add((22_991_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().reads((4 as Weight).saturating_mul(v as Weight))) + .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) + } + fn get_npos_targets(v: u32) -> Weight { + (0 as Weight) + // Standard Error: 26_000 + .saturating_add((10_972_000 as Weight).saturating_mul(v as Weight)) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(v as Weight))) + } } // For backwards compatibility and tests impl WeightInfo for () { fn bond() -> Weight { - (81_642_000 as Weight) + (80_317_000 as Weight) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(4 as Weight)) } fn bond_extra() -> Weight { - (66_025_000 as Weight) + (64_495_000 as Weight) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } fn deposit_extra() -> Weight { - (66_025_000 as Weight) + (64_495_000 as Weight) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } fn unbond() -> Weight { - (60_810_000 as Weight) + (59_679_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(5 as Weight)) + .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + } + fn claim_mature_deposits() -> Weight { + (59_679_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(5 as Weight)) + .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + } + fn try_claim_deposits_with_punish() -> Weight { + (59_679_000 as Weight) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } fn validate() -> Weight { - (21_009_000 as Weight) + (20_608_000 as Weight) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } fn kick(k: u32) -> Weight { - (31_832_000 as Weight) - // Standard Error: 15_000 - .saturating_add((19_418_000 as Weight).saturating_mul(k as Weight)) + (33_365_000 as Weight) + // Standard Error: 11_000 + .saturating_add((18_830_000 as Weight).saturating_mul(k as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(k as Weight))) .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(k as Weight))) } fn nominate(n: u32) -> Weight { - (34_304_000 as Weight) - // Standard Error: 20_000 - .saturating_add((5_643_000 as Weight).saturating_mul(n as Weight)) + (33_885_000 as Weight) + // Standard Error: 22_000 + .saturating_add((5_562_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(n as Weight))) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } fn chill() -> Weight { - (20_103_000 as Weight) + (19_741_000 as Weight) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } fn set_payee() -> Weight { - (13_858_000 as Weight) + (13_674_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } fn set_controller() -> Weight { - (30_269_000 as Weight) + (29_691_000 as Weight) .saturating_add(RocksDbWeight::get().reads(3 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } fn set_validator_count() -> Weight { - (2_444_000 as Weight).saturating_add(RocksDbWeight::get().writes(1 as Weight)) + (2_375_000 as Weight).saturating_add(RocksDbWeight::get().writes(1 as Weight)) } fn force_no_eras() -> Weight { - (2_766_000 as Weight).saturating_add(RocksDbWeight::get().writes(1 as Weight)) + (2_601_000 as Weight).saturating_add(RocksDbWeight::get().writes(1 as Weight)) } fn force_new_era() -> Weight { - (2_724_000 as Weight).saturating_add(RocksDbWeight::get().writes(1 as Weight)) + (2_605_000 as Weight).saturating_add(RocksDbWeight::get().writes(1 as Weight)) } fn force_new_era_always() -> Weight { - (2_702_000 as Weight).saturating_add(RocksDbWeight::get().writes(1 as Weight)) + (2_584_000 as Weight).saturating_add(RocksDbWeight::get().writes(1 as Weight)) } fn set_invulnerables(v: u32) -> Weight { - (2_914_000 as Weight) + (2_725_000 as Weight) // Standard Error: 0 .saturating_add((35_000 as Weight).saturating_mul(v as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } fn force_unstake(s: u32) -> Weight { - (64_032_000 as Weight) - // Standard Error: 2_000 - .saturating_add((2_787_000 as Weight).saturating_mul(s as Weight)) + (63_551_000 as Weight) + // Standard Error: 7_000 + .saturating_add((2_844_000 as Weight).saturating_mul(s as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(8 as Weight)) .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) } fn cancel_deferred_slash(s: u32) -> Weight { - (5_903_394_000 as Weight) + (5_905_400_000 as Weight) // Standard Error: 391_000 - .saturating_add((34_834_000 as Weight).saturating_mul(s as Weight)) + .saturating_add((34_785_000 as Weight).saturating_mul(s as Weight)) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } fn payout_stakers_dead_controller(n: u32) -> Weight { - (141_724_000 as Weight) - // Standard Error: 24_000 - .saturating_add((53_018_000 as Weight).saturating_mul(n as Weight)) + (142_264_000 as Weight) + // Standard Error: 22_000 + .saturating_add((52_542_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(11 as Weight)) .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(n as Weight))) } fn payout_stakers_alive_staked(n: u32) -> Weight { - (159_994_000 as Weight) - // Standard Error: 28_000 - .saturating_add((67_746_000 as Weight).saturating_mul(n as Weight)) + (180_166_000 as Weight) + // Standard Error: 23_000 + .saturating_add((66_767_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(12 as Weight)) .saturating_add(RocksDbWeight::get().reads((5 as Weight).saturating_mul(n as Weight))) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) .saturating_add(RocksDbWeight::get().writes((3 as Weight).saturating_mul(n as Weight))) } fn rebond(l: u32) -> Weight { - (42_177_000 as Weight) - // Standard Error: 1_000 - .saturating_add((82_000 as Weight).saturating_mul(l as Weight)) + (42_577_000 as Weight) + // Standard Error: 12_000 + .saturating_add((60_000 as Weight).saturating_mul(l as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } fn set_history_depth(e: u32) -> Weight { (0 as Weight) - // Standard Error: 65_000 - .saturating_add((34_151_000 as Weight).saturating_mul(e as Weight)) + // Standard Error: 68_000 + .saturating_add((33_362_000 as Weight).saturating_mul(e as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(4 as Weight)) .saturating_add(RocksDbWeight::get().writes((7 as Weight).saturating_mul(e as Weight))) } fn reap_stash(s: u32) -> Weight { - (68_377_000 as Weight) - // Standard Error: 0 - .saturating_add((2_757_000 as Weight).saturating_mul(s as Weight)) + (68_474_000 as Weight) + // Standard Error: 1_000 + .saturating_add((2_770_000 as Weight).saturating_mul(s as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(8 as Weight)) .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) } fn new_era(v: u32, n: u32) -> Weight { (0 as Weight) - // Standard Error: 908_000 - .saturating_add((588_562_000 as Weight).saturating_mul(v as Weight)) + // Standard Error: 903_000 + .saturating_add((594_145_000 as Weight).saturating_mul(v as Weight)) // Standard Error: 45_000 - .saturating_add((83_485_000 as Weight).saturating_mul(n as Weight)) + .saturating_add((83_373_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(9 as Weight)) .saturating_add(RocksDbWeight::get().reads((4 as Weight).saturating_mul(v as Weight))) .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) @@ -364,16 +407,35 @@ impl WeightInfo for () { fn submit_solution_better(v: u32, n: u32, a: u32, w: u32) -> Weight { (0 as Weight) // Standard Error: 52_000 - .saturating_add((750_000 as Weight).saturating_mul(v as Weight)) + .saturating_add((1_460_000 as Weight).saturating_mul(v as Weight)) // Standard Error: 20_000 - .saturating_add((556_000 as Weight).saturating_mul(n as Weight)) + .saturating_add((754_000 as Weight).saturating_mul(n as Weight)) // Standard Error: 52_000 - .saturating_add((76_201_000 as Weight).saturating_mul(a as Weight)) + .saturating_add((74_798_000 as Weight).saturating_mul(a as Weight)) // Standard Error: 108_000 - .saturating_add((7_271_000 as Weight).saturating_mul(w as Weight)) + .saturating_add((8_108_000 as Weight).saturating_mul(w as Weight)) .saturating_add(RocksDbWeight::get().reads(6 as Weight)) .saturating_add(RocksDbWeight::get().reads((4 as Weight).saturating_mul(a as Weight))) .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(w as Weight))) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } + fn get_npos_voters(v: u32, n: u32, s: u32) -> Weight { + (0 as Weight) + // Standard Error: 94_000 + .saturating_add((29_321_000 as Weight).saturating_mul(v as Weight)) + // Standard Error: 94_000 + .saturating_add((66_885_000 as Weight).saturating_mul(n as Weight)) + // Standard Error: 1_283_000 + .saturating_add((22_991_000 as Weight).saturating_mul(s as Weight)) + .saturating_add(RocksDbWeight::get().reads(2 as Weight)) + .saturating_add(RocksDbWeight::get().reads((4 as Weight).saturating_mul(v as Weight))) + .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) + } + fn get_npos_targets(v: u32) -> Weight { + (0 as Weight) + // Standard Error: 26_000 + .saturating_add((10_972_000 as Weight).saturating_mul(v as Weight)) + .saturating_add(RocksDbWeight::get().reads(1 as Weight)) + .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(v as Weight))) + } } diff --git a/frame/support/Cargo.toml b/frame/support/Cargo.toml index ab2e7c52f9..6992c37179 100644 --- a/frame/support/Cargo.toml +++ b/frame/support/Cargo.toml @@ -17,9 +17,9 @@ num-traits = { version = "0.2.14", default-features = false } # darwinia ethereum-primitives = { default-features = false, path = "../../primitives/ethereum-primitives" } # substrate -frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [features] diff --git a/frame/treasury/Cargo.toml b/frame/treasury/Cargo.toml index ad55a02ea9..0a6ab804a5 100644 --- a/frame/treasury/Cargo.toml +++ b/frame/treasury/Cargo.toml @@ -16,18 +16,18 @@ serde = { version = "1.0.124", optional = true, features = ["derive"] } # darwinia darwinia-support = { default-features = false, path = "../support" } # substrate -frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -frame-system = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +frame-system = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [dev-dependencies] # darwinia darwinia-balances = { path = "../balances" } # substrate -sp-core = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-io = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-storage = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +sp-core = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-io = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-storage = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [features] default = ["std"] diff --git a/frame/treasury/src/lib.rs b/frame/treasury/src/lib.rs index 7e5fce218e..989d518339 100644 --- a/frame/treasury/src/lib.rs +++ b/frame/treasury/src/lib.rs @@ -759,7 +759,7 @@ decl_module! { let tip = >::get(hash).ok_or(>::UnknownTip)?; let n = tip.closes.as_ref().ok_or(>::StillOpen)?; - ensure!(>::block_number() >= *n, >::Premature); + ensure!(>::block_number() >= *n, >::Premature); // closed. >::remove(&tip.reason); >::remove(hash); @@ -909,7 +909,7 @@ decl_module! { // If the sender is not the curator, and the curator is inactive, // slash the curator. if sender != *curator { - let block_number = >::block_number(); + let block_number = >::block_number(); if *update_due < block_number { slash_curator(curator, &mut bounty.curator_deposit); // Continue to change bounty status below... @@ -966,7 +966,7 @@ decl_module! { T::RingCurrency::reserve(curator, deposit)?; bounty.curator_deposit = deposit; - let update_due = >::block_number() + T::BountyUpdatePeriod::get(); + let update_due = >::block_number() + T::BountyUpdatePeriod::get(); bounty.status = BountyStatus::Active { curator: curator.clone(), update_due }; Ok(()) @@ -1001,7 +1001,7 @@ decl_module! { bounty.status = BountyStatus::PendingPayout { curator: signer, beneficiary: beneficiary.clone(), - unlock_at: >::block_number() + T::BountyDepositPayoutDelay::get(), + unlock_at: >::block_number() + T::BountyDepositPayoutDelay::get(), }; Ok(()) @@ -1022,7 +1022,7 @@ decl_module! { >::try_mutate_exists(bounty_id, |maybe_bounty| -> DispatchResult { let bounty = maybe_bounty.take().ok_or(>::InvalidIndex)?; if let BountyStatus::PendingPayout { curator, beneficiary, unlock_at } = bounty.status { - ensure!(>::block_number() >= unlock_at, >::Premature); + ensure!(>::block_number() >= unlock_at, >::Premature); let bounty_account = Self::bounty_account_id(bounty_id); let balance = T::RingCurrency::free_balance(&bounty_account); let fee = bounty.fee.min(balance); // just to be safe @@ -1120,7 +1120,7 @@ decl_module! { match bounty.status { BountyStatus::Active { ref curator, ref mut update_due } => { ensure!(*curator == signer, >::RequireCurator); - *update_due = (>::block_number() + T::BountyUpdatePeriod::get()).max(*update_due); + *update_due = (>::block_number() + T::BountyUpdatePeriod::get()).max(*update_due); }, _ => return Err(>::UnexpectedStatus.into()), } @@ -1240,7 +1240,7 @@ impl, I: Instance> Module { Self::retain_active_tips(&mut tip.tips); let threshold = (T::Tippers::count() + 1) / 2; if tip.tips.len() >= threshold && tip.closes.is_none() { - tip.closes = Some(>::block_number() + T::TipCountdown::get()); + tip.closes = Some(>::block_number() + T::TipCountdown::get()); true } else { false diff --git a/frame/treasury/src/mock.rs b/frame/treasury/src/mock.rs index 984631f7f0..0840498237 100644 --- a/frame/treasury/src/mock.rs +++ b/frame/treasury/src/mock.rs @@ -172,10 +172,10 @@ frame_support::construct_runtime! { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic { - System: frame_system::{Module, Call, Storage, Config, Event}, - Ring: darwinia_balances::::{Module, Call, Storage, Config, Event}, - Kton: darwinia_balances::::{Module, Call, Storage, Config, Event}, - Treasury: darwinia_treasury::{Module, Call, Storage, Config, Event}, + System: frame_system::{Pallet, Call, Storage, Config, Event}, + Ring: darwinia_balances::::{Pallet, Call, Storage, Config, Event}, + Kton: darwinia_balances::::{Pallet, Call, Storage, Config, Event}, + Treasury: darwinia_treasury::{Pallet, Call, Storage, Config, Event}, } } diff --git a/frame/vesting/Cargo.toml b/frame/vesting/Cargo.toml index 776aaedc2c..0ad103cf97 100644 --- a/frame/vesting/Cargo.toml +++ b/frame/vesting/Cargo.toml @@ -15,10 +15,10 @@ codec = { package = "parity-scale-codec", version = "2.0.1", default-featur enumflags2 = { version = "0.6.2" } serde = { version = "1.0.124", optional = true } # substrate -frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -frame-system = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +frame-system = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } # darwinia darwinia-support = { default-features = false, path = "../support" } @@ -26,9 +26,9 @@ darwinia-support = { default-features = false, path = "../support" } # crates hex-literal = "0.3.1" # substrate -sp-core = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-io = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-storage = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +sp-core = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-io = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-storage = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } # darwinia darwinia-balances = { path = "../balances" } diff --git a/frame/vesting/src/lib.rs b/frame/vesting/src/lib.rs index 0e3353a7f8..ea42d1a0cb 100644 --- a/frame/vesting/src/lib.rs +++ b/frame/vesting/src/lib.rs @@ -311,7 +311,7 @@ impl Module { /// current unvested amount. fn update_lock(who: T::AccountId) -> DispatchResult { let vesting = Self::vesting(&who).ok_or(Error::::NotVesting)?; - let now = >::block_number(); + let now = >::block_number(); let locked_now = vesting.locked_at::(now); if locked_now.is_zero() { @@ -342,7 +342,7 @@ where /// Get the amount that is currently being vested and cannot be transferred out of this account. fn vesting_balance(who: &T::AccountId) -> Option> { if let Some(v) = Self::vesting(who) { - let now = >::block_number(); + let now = >::block_number(); let locked_now = v.locked_at::(now); Some(T::Currency::free_balance(who).min(locked_now)) } else { @@ -469,9 +469,9 @@ mod tests { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Storage, Config, Event}, - Ring: darwinia_balances::::{Module, Call, Storage, Config, Event}, - Vesting: darwinia_vesting::{Module, Call, Storage, Event, Config}, + System: frame_system::{Pallet, Call, Storage, Config, Event}, + Ring: darwinia_balances::::{Pallet, Call, Storage, Config, Event}, + Vesting: darwinia_vesting::{Pallet, Call, Storage, Event, Config}, } } diff --git a/primitives/consensus/Cargo.toml b/primitives/consensus/Cargo.toml index 7b7a55375d..6bcc75b76f 100644 --- a/primitives/consensus/Cargo.toml +++ b/primitives/consensus/Cargo.toml @@ -16,9 +16,9 @@ ethereum = { version = "0.7.1", default-features = false, features = ["with-code rlp = { version = "0.5", default-features = false } sha3 = { version = "0.8", default-features = false } # substrate -sp-core = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +sp-core = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [features] default = ["std"] diff --git a/primitives/ethereum-primitives/Cargo.toml b/primitives/ethereum-primitives/Cargo.toml index c5632ffe13..1b42df3d2c 100644 --- a/primitives/ethereum-primitives/Cargo.toml +++ b/primitives/ethereum-primitives/Cargo.toml @@ -27,9 +27,9 @@ serde = { version = "1.0.124", optional = true, features = ["derive"] ethash = { default-features = false, git = "https://github.com/darwinia-network/rust-ethash" } merkle-patricia-trie = { default-features = false, path = "../merkle-patricia-trie" } # substrate -sp-io = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +sp-io = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [dev-dependencies] # crates @@ -38,7 +38,7 @@ serde_json = { version = "1.0.64" } # github triehash = { version = "0.8.4" } # substrate -frame-support = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +frame-support = { git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [features] default = ["std"] diff --git a/primitives/evm/Cargo.toml b/primitives/evm/Cargo.toml index 51872bd292..0740de7246 100644 --- a/primitives/evm/Cargo.toml +++ b/primitives/evm/Cargo.toml @@ -16,8 +16,8 @@ evm = { version = "0.24.0", default-features = false, features impl-trait-for-tuples = { version = "0.2.1" } serde = { version = "1.0.124", optional = true, features = ["derive"] } # substrate -sp-core = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +sp-core = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [features] default = ["std"] diff --git a/primitives/merkle-patricia-trie/Cargo.toml b/primitives/merkle-patricia-trie/Cargo.toml index 94991ce585..7f1397f702 100644 --- a/primitives/merkle-patricia-trie/Cargo.toml +++ b/primitives/merkle-patricia-trie/Cargo.toml @@ -20,7 +20,7 @@ hash = { package = "keccak-hash", version = "0.7.0", default-features = f hashbrown = { version = "0.9.1" } rlp = { version = "0.5.0", default-features = false } # substrate -sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [dev-dependencies] # crates diff --git a/primitives/relay/Cargo.toml b/primitives/relay/Cargo.toml index eaef95bb56..2cd38b76ee 100644 --- a/primitives/relay/Cargo.toml +++ b/primitives/relay/Cargo.toml @@ -13,9 +13,9 @@ version = "2.1.0" # crates codec = { package = "parity-scale-codec", version = "2.0.1", default-features = false } # substrate -frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } -sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.1" } +frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } +sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "rococo-v1.2" } [features] default = ["std"]