From 7539bf6dd906d383ef06e46c41adf2d315d00ff6 Mon Sep 17 00:00:00 2001 From: Dino Pacandi Date: Tue, 26 Mar 2024 17:14:54 +0100 Subject: [PATCH 01/19] Init commit --- Cargo.lock | 1772 +++++++++--------- Cargo.toml | 299 +-- bin/collator/src/local/service.rs | 2 + chain-extensions/pallet-assets/src/mock.rs | 1 + pallets/astar-xcm-benchmarks/src/mock.rs | 1 + pallets/block-rewards-hybrid/src/mock.rs | 1 + pallets/collator-selection/src/mock.rs | 1 + pallets/dapp-staking-v3/src/test/mock.rs | 1 + pallets/dapps-staking/src/mock.rs | 1 + pallets/dynamic-evm-base-fee/src/mock.rs | 1 + pallets/ethereum-checked/src/mock.rs | 2 + pallets/inflation/src/mock.rs | 1 + pallets/static-price-provider/src/mock.rs | 1 + pallets/unified-accounts/src/mock.rs | 2 + pallets/xc-asset-config/src/mock.rs | 1 + pallets/xvm/src/mock.rs | 1 + precompiles/assets-erc20/src/mock.rs | 2 + precompiles/dapp-staking-v3/src/test/mock.rs | 2 + precompiles/dapps-staking/src/mock.rs | 2 + precompiles/dispatch-lockdrop/src/mock.rs | 2 + precompiles/sr25519/src/mock.rs | 2 + precompiles/substrate-ecdsa/src/mock.rs | 2 + precompiles/unified-accounts/src/mock.rs | 2 + precompiles/utils/macro/src/derive_codec.rs | 18 +- precompiles/utils/src/evm/handle.rs | 3 +- precompiles/utils/src/precompile_set.rs | 4 +- precompiles/utils/src/substrate.rs | 2 +- precompiles/utils/src/testing/handle.rs | 1 + precompiles/utils/tests-external/lib.rs | 5 +- precompiles/xcm/src/mock.rs | 2 + precompiles/xvm/src/lib.rs | 7 +- precompiles/xvm/src/mock.rs | 2 + primitives/src/migrations/contract_v14.rs | 14 +- runtime/astar/Cargo.toml | 3 + runtime/astar/src/lib.rs | 16 + runtime/local/Cargo.toml | 2 + runtime/local/src/lib.rs | 41 +- runtime/shibuya/Cargo.toml | 3 + runtime/shibuya/src/lib.rs | 40 +- runtime/shiden/Cargo.toml | 3 + runtime/shiden/src/lib.rs | 15 + rust-toolchain.toml | 2 +- tests/xcm-simulator/src/mocks/parachain.rs | 1 + tests/xcm-simulator/src/mocks/relay_chain.rs | 1 + vendor/rpc/debug/src/lib.rs | 8 +- 45 files changed, 1211 insertions(+), 1084 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 548d1996ad..b63b70bec4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -110,7 +110,7 @@ dependencies = [ "cipher 0.3.0", "ctr 0.8.0", "ghash 0.4.4", - "subtle", + "subtle 2.4.1", ] [[package]] @@ -124,7 +124,7 @@ dependencies = [ "cipher 0.4.4", "ctr 0.9.2", "ghash 0.5.0", - "subtle", + "subtle 2.4.1", ] [[package]] @@ -307,6 +307,17 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bddcadddf5e9015d310179a59bb28c4d4b9920ad0f11e8e14dbadf654890c9a6" +[[package]] +name = "ark-bls12-377" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb00293ba84f51ce3bd026bd0de55899c4e68f0a39a5728cebae3a73ffdc0a4f" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-std", +] + [[package]] name = "ark-bls12-381" version = "0.4.0" @@ -406,22 +417,9 @@ dependencies = [ [[package]] name = "ark-scale" -version = "0.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49b08346a3e38e2be792ef53ee168623c9244d968ff00cd70fb9932f6fe36393" -dependencies = [ - "ark-ec", - "ark-ff", - "ark-serialize", - "ark-std", - "parity-scale-codec", -] - -[[package]] -name = "ark-scale" -version = "0.0.12" +version = "0.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f69c00b3b529be29528a6f2fd5fa7b1790f8bed81b9cdca17e326538545a179" +checksum = "51bd73bb6ddb72630987d37fa963e99196896c0d0ea81b7c894567e74a2f83af" dependencies = [ "ark-ec", "ark-ff", @@ -434,7 +432,7 @@ dependencies = [ [[package]] name = "ark-secret-scalar" version = "0.0.2" -source = "git+https://github.com/w3f/ring-vrf?rev=3119f51#3119f51b54b69308abfb0671f6176cb125ae1bf1" +source = "git+https://github.com/w3f/ring-vrf?rev=4b09416#4b09416fd23383ec436ddac127d58c7b7cd392c6" dependencies = [ "ark-ec", "ark-ff", @@ -482,7 +480,7 @@ dependencies = [ [[package]] name = "ark-transcript" version = "0.0.2" -source = "git+https://github.com/w3f/ring-vrf?rev=3119f51#3119f51b54b69308abfb0671f6176cb125ae1bf1" +source = "git+https://github.com/w3f/ring-vrf?rev=4b09416#4b09416fd23383ec436ddac127d58c7b7cd392c6" dependencies = [ "ark-ff", "ark-serialize", @@ -492,6 +490,12 @@ dependencies = [ "sha3", ] +[[package]] +name = "array-bytes" +version = "4.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f52f63c5c1316a16a4b35eaac8b76a98248961a533f061684cb2a7cb0eafb6c6" + [[package]] name = "array-bytes" version = "6.1.0" @@ -653,7 +657,7 @@ dependencies = [ "frame-benchmarking-cli", "frame-system", "frame-try-runtime", - "futures 0.3.28", + "futures 0.3.30", "jsonrpsee", "local-runtime", "log", @@ -754,7 +758,7 @@ dependencies = [ name = "astar-runtime" version = "5.35.0" dependencies = [ - "array-bytes", + "array-bytes 6.1.0", "astar-primitives", "cumulus-pallet-aura-ext", "cumulus-pallet-dmp-queue", @@ -834,6 +838,7 @@ dependencies = [ "sp-block-builder", "sp-consensus-aura", "sp-core", + "sp-genesis-builder", "sp-inherents", "sp-io", "sp-offchain", @@ -1023,17 +1028,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "async-recursion" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e97ce7de6cf12de5d7226c73f5ba9811622f4db3a5b91b55c53e987e5f91cba" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.48", -] - [[package]] name = "async-signal" version = "0.2.5" @@ -1075,7 +1069,7 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6d7b9decdf35d8908a7e3ef02f64c5e9b1695e230154c0e8de3969142d9b94c" dependencies = [ - "futures 0.3.28", + "futures 0.3.30", "pharos", "rustc_version 0.4.0", ] @@ -1152,13 +1146,12 @@ dependencies = [ [[package]] name = "bandersnatch_vrfs" version = "0.0.1" -source = "git+https://github.com/w3f/ring-vrf?rev=3119f51#3119f51b54b69308abfb0671f6176cb125ae1bf1" +source = "git+https://github.com/w3f/ring-vrf?rev=4b09416#4b09416fd23383ec436ddac127d58c7b7cd392c6" dependencies = [ "ark-bls12-381", "ark-ec", "ark-ed-on-bls12-381-bandersnatch", "ark-ff", - "ark-scale 0.0.12", "ark-serialize", "ark-std", "dleq_vrf", @@ -1234,9 +1227,9 @@ dependencies = [ [[package]] name = "binary-merkle-tree" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ - "hash-db 0.16.0", + "hash-db", "log", ] @@ -1309,6 +1302,18 @@ dependencies = [ "wyz", ] +[[package]] +name = "blake2" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94cb07b0da6a73955f8fb85d24c466778e70cda767a568229b104f0264089330" +dependencies = [ + "byte-tools", + "crypto-mac 0.7.0", + "digest 0.8.1", + "opaque-debug 0.2.3", +] + [[package]] name = "blake2" version = "0.10.6" @@ -1456,6 +1461,17 @@ dependencies = [ "thiserror", ] +[[package]] +name = "bp-xcm-bridge-hub-router" +version = "0.1.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" +dependencies = [ + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-runtime", +] + [[package]] name = "bs58" version = "0.4.0" @@ -1552,6 +1568,16 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "c2-chacha" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d27dae93fe7b1e0424dc57179ac396908c26b035a87234809f5c4dfd1b47dc80" +dependencies = [ + "cipher 0.2.5", + "ppv-lite86", +] + [[package]] name = "camino" version = "1.1.4" @@ -1622,7 +1648,7 @@ checksum = "5aca1a8fbc20b50ac9673ff014abfb2b5f4085ee1a850d408f14a159c5853ac7" dependencies = [ "aead 0.3.2", "cipher 0.2.5", - "subtle", + "subtle 2.4.1", ] [[package]] @@ -1655,6 +1681,16 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" +[[package]] +name = "chacha" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddf3c081b5fba1e5615640aae998e0fbd10c24cbd897ee39ed754a77601a4862" +dependencies = [ + "byteorder", + "keystream", +] + [[package]] name = "chacha20" version = "0.9.1" @@ -1889,7 +1925,7 @@ dependencies = [ [[package]] name = "common" version = "0.1.0" -source = "git+https://github.com/w3f/ring-proof?rev=0e948f3#0e948f3c28cbacecdd3020403c4841c0eb339213" +source = "git+https://github.com/w3f/ring-proof#b273d33f9981e2bb3375ab45faeb537f7ee35224" dependencies = [ "ark-ec", "ark-ff", @@ -1897,7 +1933,9 @@ dependencies = [ "ark-serialize", "ark-std", "fflonk", + "getrandom_or_panic", "merlin 3.0.0", + "rand_chacha 0.3.1", ] [[package]] @@ -1984,6 +2022,12 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" +[[package]] +name = "constcat" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd7e35aee659887cbfb97aaf227ac12cad1a9d7c71e55ff3376839ed4e282d08" + [[package]] name = "convert_case" version = "0.4.0" @@ -2232,7 +2276,7 @@ checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" dependencies = [ "generic-array 0.14.7", "rand_core 0.6.4", - "subtle", + "subtle 2.4.1", "zeroize", ] @@ -2244,7 +2288,7 @@ checksum = "cf4c2f4e1afd912bc40bfd6fed5d9dc1f288e0ba01bfcc835cc5bc3eb13efe15" dependencies = [ "generic-array 0.14.7", "rand_core 0.6.4", - "subtle", + "subtle 2.4.1", "zeroize", ] @@ -2259,6 +2303,16 @@ dependencies = [ "typenum", ] +[[package]] +name = "crypto-mac" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5" +dependencies = [ + "generic-array 0.12.4", + "subtle 1.0.0", +] + [[package]] name = "crypto-mac" version = "0.8.0" @@ -2266,7 +2320,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" dependencies = [ "generic-array 0.14.7", - "subtle", + "subtle 2.4.1", ] [[package]] @@ -2276,7 +2330,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" dependencies = [ "generic-array 0.14.7", - "subtle", + "subtle 2.4.1", ] [[package]] @@ -2300,7 +2354,7 @@ dependencies = [ [[package]] name = "cumulus-client-cli" version = "0.1.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "clap", "parity-scale-codec", @@ -2316,12 +2370,12 @@ dependencies = [ [[package]] name = "cumulus-client-collator" version = "0.1.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "cumulus-client-consensus-common", "cumulus-client-network", "cumulus-primitives-core", - "futures 0.3.28", + "futures 0.3.30", "parity-scale-codec", "parking_lot 0.12.1", "polkadot-node-primitives", @@ -2339,7 +2393,7 @@ dependencies = [ [[package]] name = "cumulus-client-consensus-aura" version = "0.1.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "async-trait", "cumulus-client-collator", @@ -2349,7 +2403,7 @@ dependencies = [ "cumulus-primitives-core", "cumulus-primitives-parachain-inherent", "cumulus-relay-chain-interface", - "futures 0.3.28", + "futures 0.3.30", "parity-scale-codec", "polkadot-node-primitives", "polkadot-node-subsystem", @@ -2381,14 +2435,14 @@ dependencies = [ [[package]] name = "cumulus-client-consensus-common" version = "0.1.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "async-trait", "cumulus-client-pov-recovery", "cumulus-primitives-core", "cumulus-relay-chain-interface", "dyn-clone", - "futures 0.3.28", + "futures 0.3.30", "log", "parity-scale-codec", "polkadot-primitives", @@ -2410,7 +2464,7 @@ dependencies = [ [[package]] name = "cumulus-client-consensus-proposer" version = "0.1.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "anyhow", "async-trait", @@ -2425,13 +2479,13 @@ dependencies = [ [[package]] name = "cumulus-client-consensus-relay-chain" version = "0.1.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "async-trait", "cumulus-client-consensus-common", "cumulus-primitives-core", "cumulus-relay-chain-interface", - "futures 0.3.28", + "futures 0.3.30", "parking_lot 0.12.1", "sc-consensus", "sp-api", @@ -2448,11 +2502,11 @@ dependencies = [ [[package]] name = "cumulus-client-network" version = "0.1.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "async-trait", "cumulus-relay-chain-interface", - "futures 0.3.28", + "futures 0.3.30", "futures-timer", "parity-scale-codec", "parking_lot 0.12.1", @@ -2471,12 +2525,12 @@ dependencies = [ [[package]] name = "cumulus-client-pov-recovery" version = "0.1.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "async-trait", "cumulus-primitives-core", "cumulus-relay-chain-interface", - "futures 0.3.28", + "futures 0.3.30", "futures-timer", "parity-scale-codec", "polkadot-node-primitives", @@ -2495,7 +2549,7 @@ dependencies = [ [[package]] name = "cumulus-client-service" version = "0.1.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "cumulus-client-cli", "cumulus-client-collator", @@ -2506,7 +2560,7 @@ dependencies = [ "cumulus-relay-chain-inprocess-interface", "cumulus-relay-chain-interface", "cumulus-relay-chain-minimal-node", - "futures 0.3.28", + "futures 0.3.30", "polkadot-primitives", "sc-client-api", "sc-consensus", @@ -2530,7 +2584,7 @@ dependencies = [ [[package]] name = "cumulus-pallet-aura-ext" version = "0.1.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "cumulus-pallet-parachain-system", "frame-support", @@ -2548,7 +2602,7 @@ dependencies = [ [[package]] name = "cumulus-pallet-dmp-queue" version = "0.1.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "cumulus-primitives-core", "frame-support", @@ -2565,7 +2619,7 @@ dependencies = [ [[package]] name = "cumulus-pallet-parachain-system" version = "0.1.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "bytes", "cumulus-pallet-parachain-system-proc-macro", @@ -2578,6 +2632,7 @@ dependencies = [ "log", "parity-scale-codec", "polkadot-parachain-primitives", + "polkadot-runtime-parachains", "scale-info", "sp-core", "sp-externalities", @@ -2595,7 +2650,7 @@ dependencies = [ [[package]] name = "cumulus-pallet-parachain-system-proc-macro" version = "0.1.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "proc-macro-crate 1.3.1", "proc-macro2", @@ -2606,7 +2661,7 @@ dependencies = [ [[package]] name = "cumulus-pallet-xcm" version = "0.1.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "cumulus-primitives-core", "frame-support", @@ -2622,8 +2677,9 @@ dependencies = [ [[package]] name = "cumulus-pallet-xcmp-queue" version = "0.1.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ + "bp-xcm-bridge-hub-router", "cumulus-primitives-core", "frame-benchmarking", "frame-support", @@ -2631,8 +2687,10 @@ dependencies = [ "log", "parity-scale-codec", "polkadot-runtime-common", + "polkadot-runtime-parachains", "rand_chacha 0.3.1", "scale-info", + "sp-core", "sp-io", "sp-runtime", "sp-std", @@ -2643,7 +2701,7 @@ dependencies = [ [[package]] name = "cumulus-primitives-aura" version = "0.1.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "parity-scale-codec", "polkadot-core-primitives", @@ -2657,7 +2715,7 @@ dependencies = [ [[package]] name = "cumulus-primitives-core" version = "0.1.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "parity-scale-codec", "polkadot-core-primitives", @@ -2674,7 +2732,7 @@ dependencies = [ [[package]] name = "cumulus-primitives-parachain-inherent" version = "0.1.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "async-trait", "cumulus-primitives-core", @@ -2697,10 +2755,10 @@ dependencies = [ [[package]] name = "cumulus-primitives-timestamp" version = "0.1.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "cumulus-primitives-core", - "futures 0.3.28", + "futures 0.3.30", "parity-scale-codec", "sp-inherents", "sp-std", @@ -2710,13 +2768,15 @@ dependencies = [ [[package]] name = "cumulus-primitives-utility" version = "0.1.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "cumulus-primitives-core", "frame-support", "log", + "pallet-xcm-benchmarks", "parity-scale-codec", "polkadot-runtime-common", + "polkadot-runtime-parachains", "sp-io", "sp-runtime", "sp-std", @@ -2728,12 +2788,12 @@ dependencies = [ [[package]] name = "cumulus-relay-chain-inprocess-interface" version = "0.1.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "async-trait", "cumulus-primitives-core", "cumulus-relay-chain-interface", - "futures 0.3.28", + "futures 0.3.30", "futures-timer", "polkadot-cli", "polkadot-service", @@ -2752,11 +2812,11 @@ dependencies = [ [[package]] name = "cumulus-relay-chain-interface" version = "0.1.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "async-trait", "cumulus-primitives-core", - "futures 0.3.28", + "futures 0.3.30", "jsonrpsee-core", "parity-scale-codec", "polkadot-overseer", @@ -2770,14 +2830,14 @@ dependencies = [ [[package]] name = "cumulus-relay-chain-minimal-node" version = "0.1.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ - "array-bytes", + "array-bytes 6.1.0", "async-trait", "cumulus-primitives-core", "cumulus-relay-chain-interface", "cumulus-relay-chain-rpc-interface", - "futures 0.3.28", + "futures 0.3.30", "polkadot-availability-recovery", "polkadot-collator-protocol", "polkadot-core-primitives", @@ -2794,24 +2854,24 @@ dependencies = [ "sc-service", "sc-tracing", "sc-utils", - "schnellru", "sp-api", "sp-consensus", "sp-consensus-babe", "sp-runtime", + "substrate-prometheus-endpoint", "tracing", ] [[package]] name = "cumulus-relay-chain-rpc-interface" version = "0.1.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "async-trait", "cumulus-primitives-core", "cumulus-relay-chain-interface", "either", - "futures 0.3.28", + "futures 0.3.30", "futures-timer", "jsonrpsee", "parity-scale-codec", @@ -2843,7 +2903,7 @@ dependencies = [ [[package]] name = "cumulus-test-relay-sproof-builder" version = "0.1.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "cumulus-primitives-core", "parity-scale-codec", @@ -2863,7 +2923,7 @@ dependencies = [ "byteorder", "digest 0.8.1", "rand_core 0.5.1", - "subtle", + "subtle 2.4.1", "zeroize", ] @@ -2876,7 +2936,7 @@ dependencies = [ "byteorder", "digest 0.9.0", "rand_core 0.5.1", - "subtle", + "subtle 2.4.1", "zeroize", ] @@ -2893,7 +2953,7 @@ dependencies = [ "fiat-crypto", "platforms", "rustc_version 0.4.0", - "subtle", + "subtle 2.4.1", "zeroize", ] @@ -3189,14 +3249,14 @@ dependencies = [ "block-buffer 0.10.4", "const-oid", "crypto-common", - "subtle", + "subtle 2.4.1", ] [[package]] name = "directories" -version = "4.0.1" +version = "5.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f51c5d4ddabd36886dd3e1438cb358cdcb0d7c499cb99cb4ac2e38e18b5cb210" +checksum = "9a49173b84e034382284f27f1af4dcbbd231ffa358c0fe316541a7337f376a35" dependencies = [ "dirs-sys", ] @@ -3213,13 +3273,14 @@ dependencies = [ [[package]] name = "dirs-sys" -version = "0.3.7" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" +checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" dependencies = [ "libc", + "option-ext", "redox_users", - "winapi", + "windows-sys 0.48.0", ] [[package]] @@ -3247,11 +3308,11 @@ dependencies = [ [[package]] name = "dleq_vrf" version = "0.0.2" -source = "git+https://github.com/w3f/ring-vrf?rev=3119f51#3119f51b54b69308abfb0671f6176cb125ae1bf1" +source = "git+https://github.com/w3f/ring-vrf?rev=4b09416#4b09416fd23383ec436ddac127d58c7b7cd392c6" dependencies = [ "ark-ec", "ark-ff", - "ark-scale 0.0.10", + "ark-scale", "ark-secret-scalar", "ark-serialize", "ark-std", @@ -3386,7 +3447,7 @@ dependencies = [ "rand_core 0.6.4", "serde", "sha2 0.10.7", - "subtle", + "subtle 2.4.1", "zeroize", ] @@ -3443,7 +3504,7 @@ dependencies = [ "pkcs8 0.9.0", "rand_core 0.6.4", "sec1 0.3.0", - "subtle", + "subtle 2.4.1", "zeroize", ] @@ -3462,7 +3523,7 @@ dependencies = [ "pkcs8 0.10.2", "rand_core 0.6.4", "sec1 0.7.2", - "subtle", + "subtle 2.4.1", "zeroize", ] @@ -3658,20 +3719,20 @@ dependencies = [ [[package]] name = "ethereum" -version = "0.14.0" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a89fb87a9e103f71b903b80b670200b54cc67a07578f070681f1fffb7396fb7" +checksum = "2e04d24d20b8ff2235cffbf242d5092de3aa45f77c5270ddbfadd2778ca13fea" dependencies = [ "bytes", "ethereum-types", - "hash-db 0.15.2", + "hash-db", "hash256-std-hasher", "parity-scale-codec", "rlp", "scale-info", "serde", "sha3", - "triehash", + "trie-root", ] [[package]] @@ -3941,8 +4002,9 @@ dependencies = [ [[package]] name = "evm" -version = "0.39.1" -source = "git+https://github.com/rust-blockchain/evm?rev=b7b82c7e1fc57b7449d6dfa6826600de37cc1e65#b7b82c7e1fc57b7449d6dfa6826600de37cc1e65" +version = "0.41.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "767f43e9630cc36cf8ff2777cbb0121b055f0d1fd6eaaa13b46a1808f0d0e7e9" dependencies = [ "auto_impl", "environmental", @@ -3961,8 +4023,9 @@ dependencies = [ [[package]] name = "evm-core" -version = "0.39.0" -source = "git+https://github.com/rust-blockchain/evm?rev=b7b82c7e1fc57b7449d6dfa6826600de37cc1e65#b7b82c7e1fc57b7449d6dfa6826600de37cc1e65" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1da6cedc5cedb4208e59467106db0d1f50db01b920920589f8e672c02fdc04f" dependencies = [ "parity-scale-codec", "primitive-types", @@ -3972,8 +4035,9 @@ dependencies = [ [[package]] name = "evm-gasometer" -version = "0.39.0" -source = "git+https://github.com/rust-blockchain/evm?rev=b7b82c7e1fc57b7449d6dfa6826600de37cc1e65#b7b82c7e1fc57b7449d6dfa6826600de37cc1e65" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dc0eb591abc5cd7b05bef6a036c2bb6c66ab6c5e0c5ce94bfe377ab670b1fd7" dependencies = [ "environmental", "evm-core", @@ -3983,8 +4047,9 @@ dependencies = [ [[package]] name = "evm-runtime" -version = "0.39.0" -source = "git+https://github.com/rust-blockchain/evm?rev=b7b82c7e1fc57b7449d6dfa6826600de37cc1e65#b7b82c7e1fc57b7449d6dfa6826600de37cc1e65" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84bbe09b64ae13a29514048c1bb6fda6374ac0b4f6a1f15a443348ab88ef42cd" dependencies = [ "auto_impl", "environmental", @@ -4013,7 +4078,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e43f2f1833d64e33f15592464d6fdd70f349dda7b1a53088eb83cd94014008c5" dependencies = [ - "futures 0.3.28", + "futures 0.3.30", ] [[package]] @@ -4028,25 +4093,13 @@ dependencies = [ "quote", ] -[[package]] -name = "expander" -version = "0.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3774182a5df13c3d1690311ad32fbe913feef26baba609fa2dd5f72042bd2ab6" -dependencies = [ - "blake2", - "fs-err", - "proc-macro2", - "quote", -] - [[package]] name = "expander" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f86a749cf851891866c10515ef6c299b5c69661465e9c3bbe7e07a2b77fb0f7" dependencies = [ - "blake2", + "blake2 0.10.6", "fs-err", "proc-macro2", "quote", @@ -4124,7 +4177,7 @@ dependencies = [ [[package]] name = "fc-api" version = "1.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.1.0#8a5a81a24c3e0fab668483b54882757b7302926d" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#76939a19b45d9908f0358b0aaed9a5ab20398f45" dependencies = [ "async-trait", "fp-storage", @@ -4136,7 +4189,7 @@ dependencies = [ [[package]] name = "fc-consensus" version = "2.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.1.0#8a5a81a24c3e0fab668483b54882757b7302926d" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#76939a19b45d9908f0358b0aaed9a5ab20398f45" dependencies = [ "async-trait", "fp-consensus", @@ -4152,7 +4205,7 @@ dependencies = [ [[package]] name = "fc-db" version = "2.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.1.0#8a5a81a24c3e0fab668483b54882757b7302926d" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#76939a19b45d9908f0358b0aaed9a5ab20398f45" dependencies = [ "async-trait", "fc-api", @@ -4173,13 +4226,13 @@ dependencies = [ [[package]] name = "fc-mapping-sync" version = "2.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.1.0#8a5a81a24c3e0fab668483b54882757b7302926d" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#76939a19b45d9908f0358b0aaed9a5ab20398f45" dependencies = [ "fc-db", "fc-storage", "fp-consensus", "fp-rpc", - "futures 0.3.28", + "futures 0.3.30", "futures-timer", "log", "parking_lot 0.12.1", @@ -4194,7 +4247,7 @@ dependencies = [ [[package]] name = "fc-rpc" version = "2.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.1.0#8a5a81a24c3e0fab668483b54882757b7302926d" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#76939a19b45d9908f0358b0aaed9a5ab20398f45" dependencies = [ "ethereum", "ethereum-types", @@ -4206,7 +4259,7 @@ dependencies = [ "fp-evm", "fp-rpc", "fp-storage", - "futures 0.3.28", + "futures 0.3.30", "hex", "jsonrpsee", "libsecp256k1", @@ -4248,7 +4301,7 @@ dependencies = [ [[package]] name = "fc-rpc-core" version = "1.1.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.1.0#8a5a81a24c3e0fab668483b54882757b7302926d" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#76939a19b45d9908f0358b0aaed9a5ab20398f45" dependencies = [ "ethereum", "ethereum-types", @@ -4261,7 +4314,7 @@ dependencies = [ [[package]] name = "fc-storage" version = "1.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.1.0#8a5a81a24c3e0fab668483b54882757b7302926d" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#76939a19b45d9908f0358b0aaed9a5ab20398f45" dependencies = [ "ethereum", "ethereum-types", @@ -4292,7 +4345,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" dependencies = [ "rand_core 0.6.4", - "subtle", + "subtle 2.4.1", ] [[package]] @@ -4302,7 +4355,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" dependencies = [ "rand_core 0.6.4", - "subtle", + "subtle 2.4.1", ] [[package]] @@ -4353,7 +4406,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "36530797b9bf31cd4ff126dcfee8170f86b00cfdcea3269d73133cc0415945c3" dependencies = [ "either", - "futures 0.3.28", + "futures 0.3.30", "futures-timer", "log", "num-traits", @@ -4409,7 +4462,7 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "fork-tree" version = "3.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "parity-scale-codec", ] @@ -4426,7 +4479,7 @@ dependencies = [ [[package]] name = "fp-account" version = "1.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.1.0#8a5a81a24c3e0fab668483b54882757b7302926d" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#76939a19b45d9908f0358b0aaed9a5ab20398f45" dependencies = [ "hex", "impl-serde", @@ -4445,7 +4498,7 @@ dependencies = [ [[package]] name = "fp-consensus" version = "2.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.1.0#8a5a81a24c3e0fab668483b54882757b7302926d" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#76939a19b45d9908f0358b0aaed9a5ab20398f45" dependencies = [ "ethereum", "parity-scale-codec", @@ -4457,7 +4510,7 @@ dependencies = [ [[package]] name = "fp-ethereum" version = "1.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.1.0#8a5a81a24c3e0fab668483b54882757b7302926d" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#76939a19b45d9908f0358b0aaed9a5ab20398f45" dependencies = [ "ethereum", "ethereum-types", @@ -4470,7 +4523,7 @@ dependencies = [ [[package]] name = "fp-evm" version = "3.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.1.0#8a5a81a24c3e0fab668483b54882757b7302926d" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#76939a19b45d9908f0358b0aaed9a5ab20398f45" dependencies = [ "evm", "frame-support", @@ -4486,7 +4539,7 @@ dependencies = [ [[package]] name = "fp-rpc" version = "3.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.1.0#8a5a81a24c3e0fab668483b54882757b7302926d" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#76939a19b45d9908f0358b0aaed9a5ab20398f45" dependencies = [ "ethereum", "ethereum-types", @@ -4503,7 +4556,7 @@ dependencies = [ [[package]] name = "fp-self-contained" version = "1.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.1.0#8a5a81a24c3e0fab668483b54882757b7302926d" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#76939a19b45d9908f0358b0aaed9a5ab20398f45" dependencies = [ "frame-support", "parity-scale-codec", @@ -4515,7 +4568,7 @@ dependencies = [ [[package]] name = "fp-storage" version = "2.0.0" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.1.0#8a5a81a24c3e0fab668483b54882757b7302926d" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#76939a19b45d9908f0358b0aaed9a5ab20398f45" dependencies = [ "parity-scale-codec", "serde", @@ -4530,7 +4583,7 @@ checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" [[package]] name = "frame-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-support", "frame-support-procedural", @@ -4555,10 +4608,10 @@ dependencies = [ [[package]] name = "frame-benchmarking-cli" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "Inflector", - "array-bytes", + "array-bytes 6.1.0", "chrono", "clap", "comfy-table", @@ -4603,7 +4656,7 @@ dependencies = [ [[package]] name = "frame-election-provider-solution-type" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "proc-macro-crate 1.3.1", "proc-macro2", @@ -4614,7 +4667,7 @@ dependencies = [ [[package]] name = "frame-election-provider-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-election-provider-solution-type", "frame-support", @@ -4631,7 +4684,7 @@ dependencies = [ [[package]] name = "frame-executive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-support", "frame-system", @@ -4661,10 +4714,9 @@ dependencies = [ [[package]] name = "frame-remote-externalities" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ - "async-recursion", - "futures 0.3.28", + "futures 0.3.30", "indicatif", "jsonrpsee", "log", @@ -4683,7 +4735,7 @@ dependencies = [ [[package]] name = "frame-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "aquamarine", "bitflags 1.3.2", @@ -4723,7 +4775,7 @@ dependencies = [ [[package]] name = "frame-support-procedural" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "Inflector", "cfg-expr", @@ -4735,13 +4787,14 @@ dependencies = [ "proc-macro-warning", "proc-macro2", "quote", + "sp-core-hashing", "syn 2.0.48", ] [[package]] name = "frame-support-procedural-tools" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate 1.3.1", @@ -4753,7 +4806,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "3.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "proc-macro2", "quote", @@ -4763,7 +4816,7 @@ dependencies = [ [[package]] name = "frame-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "cfg-if", "frame-support", @@ -4782,7 +4835,7 @@ dependencies = [ [[package]] name = "frame-system-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-benchmarking", "frame-support", @@ -4797,7 +4850,7 @@ dependencies = [ [[package]] name = "frame-system-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "parity-scale-codec", "sp-api", @@ -4806,7 +4859,7 @@ dependencies = [ [[package]] name = "frame-try-runtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-support", "parity-scale-codec", @@ -4855,9 +4908,9 @@ checksum = "3a471a38ef8ed83cd6e40aa59c1ffe17db6855c18e3604d9c4ed8c08ebc28678" [[package]] name = "futures" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" dependencies = [ "futures-channel", "futures-core", @@ -4870,9 +4923,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" dependencies = [ "futures-core", "futures-sink", @@ -4880,15 +4933,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" [[package]] name = "futures-executor" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" +checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" dependencies = [ "futures-core", "futures-task", @@ -4898,9 +4951,9 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" [[package]] name = "futures-lite" @@ -4939,9 +4992,9 @@ dependencies = [ [[package]] name = "futures-macro" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", @@ -4961,15 +5014,15 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" [[package]] name = "futures-task" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" [[package]] name = "futures-timer" @@ -4983,9 +5036,9 @@ dependencies = [ [[package]] name = "futures-util" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ "futures 0.1.31", "futures-channel", @@ -5061,6 +5114,15 @@ dependencies = [ "wasi 0.11.0+wasi-snapshot-preview1", ] +[[package]] +name = "getrandom_or_panic" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ea1015b5a70616b688dc230cfe50c8af89d972cb132d5a622814d29773b10b9" +dependencies = [ + "rand_core 0.6.4", +] + [[package]] name = "ghash" version = "0.4.4" @@ -5131,7 +5193,7 @@ checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" dependencies = [ "ff 0.12.1", "rand_core 0.6.4", - "subtle", + "subtle 2.4.1", ] [[package]] @@ -5142,7 +5204,7 @@ checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" dependencies = [ "ff 0.13.0", "rand_core 0.6.4", - "subtle", + "subtle 2.4.1", ] [[package]] @@ -5178,12 +5240,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "hash-db" -version = "0.15.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d23bd4e7b5eda0d0f3a307e8b381fdc8ba9000f26fbe912250c0a4cc3956364a" - [[package]] name = "hash-db" version = "0.16.0" @@ -5237,6 +5293,15 @@ dependencies = [ "fxhash", ] +[[package]] +name = "hashlink" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8094feaf31ff591f651a2664fb9cfd92bba7a60ce3197265e9482ebe753c8f7" +dependencies = [ + "hashbrown 0.14.0", +] + [[package]] name = "heck" version = "0.4.1" @@ -5489,7 +5554,7 @@ dependencies = [ "async-io 1.13.0", "core-foundation", "fnv", - "futures 0.3.28", + "futures 0.3.30", "if-addrs", "ipnet", "log", @@ -5973,18 +6038,10 @@ dependencies = [ ] [[package]] -name = "kusama-runtime-constants" +name = "keystream" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" -dependencies = [ - "frame-support", - "polkadot-primitives", - "polkadot-runtime-common", - "smallvec 1.11.0", - "sp-core", - "sp-runtime", - "sp-weights", -] +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c33070833c9ee02266356de0c43f723152bd38bd96ddf52c82b3af10c9138b28" [[package]] name = "kvdb" @@ -6021,9 +6078,9 @@ dependencies = [ [[package]] name = "landlock" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "520baa32708c4e957d2fc3a186bc5bd8d26637c33137f399ddfc202adb240068" +checksum = "1530c5b973eeed4ac216af7e24baf5737645a6272e361f1fb95710678b67d9cc" dependencies = [ "enumflags2", "libc", @@ -6074,7 +6131,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f210d259724eae82005b5c48078619b7745edb7b76de370b03f8ba59ea103097" dependencies = [ "bytes", - "futures 0.3.28", + "futures 0.3.30", "futures-timer", "getrandom 0.2.10", "instant", @@ -6133,7 +6190,7 @@ checksum = "3c1df63c0b582aa434fb09b2d86897fa2b419ffeccf934b36f87fcedc8e835c2" dependencies = [ "either", "fnv", - "futures 0.3.28", + "futures 0.3.30", "futures-timer", "instant", "libp2p-identity", @@ -6159,7 +6216,7 @@ version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "146ff7034daae62077c415c2376b8057368042df6ab95f5432ad5e88568b1554" dependencies = [ - "futures 0.3.28", + "futures 0.3.30", "libp2p-core", "log", "parking_lot 0.12.1", @@ -6175,7 +6232,7 @@ checksum = "5455f472243e63b9c497ff320ded0314254a9eb751799a39c283c6f20b793f3c" dependencies = [ "asynchronous-codec", "either", - "futures 0.3.28", + "futures 0.3.30", "futures-timer", "libp2p-core", "libp2p-identity", @@ -6218,7 +6275,7 @@ dependencies = [ "bytes", "either", "fnv", - "futures 0.3.28", + "futures 0.3.30", "futures-timer", "instant", "libp2p-core", @@ -6242,7 +6299,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19983e1f949f979a928f2c603de1cf180cc0dc23e4ac93a62651ccb18341460b" dependencies = [ "data-encoding", - "futures 0.3.28", + "futures 0.3.30", "if-watch", "libp2p-core", "libp2p-identity", @@ -6278,7 +6335,7 @@ checksum = "9c3673da89d29936bc6435bafc638e2f184180d554ce844db65915113f86ec5e" dependencies = [ "bytes", "curve25519-dalek 3.2.0", - "futures 0.3.28", + "futures 0.3.30", "libp2p-core", "libp2p-identity", "log", @@ -6300,7 +6357,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e57759c19c28a73ef1eb3585ca410cefb72c1a709fcf6de1612a378e4219202" dependencies = [ "either", - "futures 0.3.28", + "futures 0.3.30", "futures-timer", "instant", "libp2p-core", @@ -6317,7 +6374,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c6b26abd81cd2398382a1edfe739b539775be8a90fa6914f39b2ab49571ec735" dependencies = [ "bytes", - "futures 0.3.28", + "futures 0.3.30", "futures-timer", "if-watch", "libp2p-core", @@ -6339,7 +6396,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ffdb374267d42dc5ed5bc53f6e601d4a64ac5964779c6e40bb9e4f14c1e30d5" dependencies = [ "async-trait", - "futures 0.3.28", + "futures 0.3.30", "instant", "libp2p-core", "libp2p-identity", @@ -6356,7 +6413,7 @@ checksum = "903b3d592d7694e56204d211f29d31bc004be99386644ba8731fc3e3ef27b296" dependencies = [ "either", "fnv", - "futures 0.3.28", + "futures 0.3.30", "futures-timer", "instant", "libp2p-core", @@ -6386,7 +6443,7 @@ version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33d33698596d7722d85d3ab0c86c2c322254fce1241e91208e3679b4eb3026cf" dependencies = [ - "futures 0.3.28", + "futures 0.3.30", "futures-timer", "if-watch", "libc", @@ -6402,7 +6459,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff08d13d0dc66e5e9ba6279c1de417b84fa0d0adc3b03e5732928c180ec02781" dependencies = [ - "futures 0.3.28", + "futures 0.3.30", "futures-rustls", "libp2p-core", "libp2p-identity", @@ -6421,7 +6478,7 @@ version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77dff9d32353a5887adb86c8afc1de1a94d9e8c3bc6df8b2201d7cdf5c848f43" dependencies = [ - "futures 0.3.28", + "futures 0.3.30", "js-sys", "libp2p-core", "parity-send-wrapper", @@ -6438,7 +6495,7 @@ dependencies = [ "async-trait", "asynchronous-codec", "bytes", - "futures 0.3.28", + "futures 0.3.30", "futures-timer", "hex", "if-watch", @@ -6467,7 +6524,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "111273f7b3d3510524c752e8b7a5314b7f7a1fee7e68161c01a7d72cbb06db9f" dependencies = [ "either", - "futures 0.3.28", + "futures 0.3.30", "futures-rustls", "libp2p-core", "log", @@ -6485,7 +6542,7 @@ version = "0.43.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4dcd21d950662700a385d4c6d68e2f5f54d778e97068cdd718522222ef513bda" dependencies = [ - "futures 0.3.28", + "futures 0.3.30", "libp2p-core", "log", "thiserror", @@ -6534,7 +6591,7 @@ checksum = "5be9b9bb642d8522a44d533eab56c16c738301965504753b03ad1de3425d5451" dependencies = [ "crunchy", "digest 0.9.0", - "subtle", + "subtle 2.4.1", ] [[package]] @@ -6617,11 +6674,23 @@ version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" +[[package]] +name = "lioness" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ae926706ba42c425c9457121178330d75e273df2e82e28b758faf3de3a9acb9" +dependencies = [ + "arrayref", + "blake2 0.8.1", + "chacha", + "keystream", +] + [[package]] name = "local-runtime" version = "5.35.0" dependencies = [ - "array-bytes", + "array-bytes 6.1.0", "astar-primitives", "dapp-staking-v3-runtime-api", "fp-rpc", @@ -6695,6 +6764,7 @@ dependencies = [ "sp-block-builder", "sp-consensus-aura", "sp-core", + "sp-genesis-builder", "sp-inherents", "sp-io", "sp-offchain", @@ -6777,9 +6847,9 @@ dependencies = [ [[package]] name = "macro_magic" -version = "0.4.2" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aee866bfee30d2d7e83835a4574aad5b45adba4cc807f2a3bbba974e5d4383c9" +checksum = "e03844fc635e92f3a0067e25fa4bf3e3dbf3f2927bf3aa01bb7bc8f1c428949d" dependencies = [ "macro_magic_core", "macro_magic_macros", @@ -6789,9 +6859,9 @@ dependencies = [ [[package]] name = "macro_magic_core" -version = "0.4.2" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e766a20fd9c72bab3e1e64ed63f36bd08410e75803813df210d1ce297d7ad00" +checksum = "468155613a44cfd825f1fb0ffa532b018253920d404e6fca1e8d43155198a46d" dependencies = [ "const-random", "derive-syn-parse", @@ -6803,9 +6873,9 @@ dependencies = [ [[package]] name = "macro_magic_core_macros" -version = "0.4.3" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d710e1214dffbab3b5dacb21475dde7d6ed84c69ff722b3a47a782668d44fbac" +checksum = "9ea73aa640dc01d62a590d48c0c3521ed739d53b27f919b25c3551e233481654" dependencies = [ "proc-macro2", "quote", @@ -6814,9 +6884,9 @@ dependencies = [ [[package]] name = "macro_magic_macros" -version = "0.4.2" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8fb85ec1620619edf2984a7693497d4ec88a9665d8b87e942856884c92dbf2a" +checksum = "ef9d79ae96aaba821963320eb2b6e34d17df1e5a83d8a1985c29cc5be59577b3" dependencies = [ "macro_magic_core", "quote", @@ -6947,7 +7017,7 @@ version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "808b50db46293432a45e63bc15ea51e0ab4c0a1647b8eb114e31a3e698dd6fbe" dependencies = [ - "hash-db 0.16.0", + "hash-db", ] [[package]] @@ -6980,7 +7050,7 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69672161530e8aeca1d1400fbf3f1a1747ff60ea604265a4e906c2442df20532" dependencies = [ - "futures 0.3.28", + "futures 0.3.30", "rand 0.8.5", "thrift", ] @@ -7017,12 +7087,37 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "mixnet" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daa3eb39495d8e2e2947a1d862852c90cc6a4a8845f8b41c8829cb9fcc047f4a" +dependencies = [ + "arrayref", + "arrayvec 0.7.4", + "bitflags 1.3.2", + "blake2 0.10.6", + "c2-chacha", + "curve25519-dalek 4.1.1", + "either", + "hashlink", + "lioness", + "log", + "parking_lot 0.12.1", + "rand 0.8.5", + "rand_chacha 0.3.1", + "rand_distr", + "subtle 2.4.1", + "thiserror", + "zeroize", +] + [[package]] name = "mmr-gadget" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ - "futures 0.3.28", + "futures 0.3.30", "log", "parity-scale-codec", "sc-client-api", @@ -7039,7 +7134,7 @@ dependencies = [ [[package]] name = "mmr-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "anyhow", "jsonrpsee", @@ -7129,7 +7224,7 @@ name = "moonbeam-rpc-core-debug" version = "0.1.0" dependencies = [ "ethereum-types", - "futures 0.3.28", + "futures 0.3.30", "jsonrpsee", "moonbeam-client-evm-tracing", "moonbeam-rpc-core-types", @@ -7143,7 +7238,7 @@ name = "moonbeam-rpc-core-trace" version = "0.6.0" dependencies = [ "ethereum-types", - "futures 0.3.28", + "futures 0.3.30", "jsonrpsee", "moonbeam-client-evm-tracing", "moonbeam-rpc-core-types", @@ -7184,7 +7279,7 @@ dependencies = [ "fc-rpc", "fc-storage", "fp-rpc", - "futures 0.3.28", + "futures 0.3.30", "hex-literal", "jsonrpsee", "moonbeam-client-evm-tracing", @@ -7244,7 +7339,7 @@ dependencies = [ "fc-rpc-core", "fc-storage", "fp-rpc", - "futures 0.3.28", + "futures 0.3.30", "jsonrpsee", "moonbeam-client-evm-tracing", "moonbeam-rpc-core-trace", @@ -7362,7 +7457,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c8552ab875c1313b97b8d20cb857b9fd63e2d1d6a0a1b53ce9821e575405f27a" dependencies = [ "bytes", - "futures 0.3.28", + "futures 0.3.30", "log", "pin-project", "smallvec 1.11.0", @@ -7456,7 +7551,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "65b4b14489ab424703c092062176d52ba55485a89c076b4f9db05092b7223aa6" dependencies = [ "bytes", - "futures 0.3.28", + "futures 0.3.30", "log", "netlink-packet-core", "netlink-sys", @@ -7471,7 +7566,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6471bf08e7ac0135876a9581bf3217ef0333c191c128d34878079f42ee150411" dependencies = [ "bytes", - "futures 0.3.28", + "futures 0.3.30", "libc", "log", "tokio", @@ -7607,6 +7702,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" dependencies = [ "autocfg", + "libm", ] [[package]] @@ -7755,31 +7851,38 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + [[package]] name = "orchestra" -version = "0.0.5" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "227585216d05ba65c7ab0a0450a3cf2cbd81a98862a54c4df8e14d5ac6adb015" +checksum = "2356622ffdfe72362a45a1e5e87bb113b8327e596e39b91f11f0ef4395c8da79" dependencies = [ "async-trait", "dyn-clonable", - "futures 0.3.28", + "futures 0.3.30", "futures-timer", "orchestra-proc-macro", "pin-project", - "prioritized-metered-channel", + "prioritized-metered-channel 0.6.1", "thiserror", "tracing", ] [[package]] name = "orchestra-proc-macro" -version = "0.0.5" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2871aadd82a2c216ee68a69837a526dfe788ecbe74c4c5038a6acdbff6653066" +checksum = "eedb646674596266dc9bb2b5c7eea7c36b32ecc7777eba0d510196972d72c4fd" dependencies = [ - "expander 0.0.6", - "itertools 0.10.5", + "expander 2.0.0", + "indexmap 2.0.0", + "itertools 0.11.0", "petgraph", "proc-macro-crate 1.3.1", "proc-macro2", @@ -7798,8 +7901,8 @@ dependencies = [ [[package]] name = "orml-traits" -version = "0.4.1-dev" -source = "git+https://github.com/open-web3-stack/open-runtime-module-library?branch=polkadot-v1.1.0#b3694e631df7f1ca16b1973122937753fcdee9d4" +version = "0.6.7" +source = "git+https://github.com/AstarNetwork/open-runtime-module-library?branch=polkadot-v1.3.0#18fe59659a5f3ce1b2432e3d273f559963b73517" dependencies = [ "frame-support", "impl-trait-for-tuples", @@ -7818,8 +7921,8 @@ dependencies = [ [[package]] name = "orml-utilities" -version = "0.4.1-dev" -source = "git+https://github.com/open-web3-stack/open-runtime-module-library?branch=polkadot-v1.1.0#b3694e631df7f1ca16b1973122937753fcdee9d4" +version = "0.6.7" +source = "git+https://github.com/AstarNetwork/open-runtime-module-library?branch=polkadot-v1.3.0#18fe59659a5f3ce1b2432e3d273f559963b73517" dependencies = [ "frame-support", "parity-scale-codec", @@ -7833,8 +7936,8 @@ dependencies = [ [[package]] name = "orml-xcm-support" -version = "0.4.1-dev" -source = "git+https://github.com/open-web3-stack/open-runtime-module-library?branch=polkadot-v1.1.0#b3694e631df7f1ca16b1973122937753fcdee9d4" +version = "0.6.7" +source = "git+https://github.com/AstarNetwork/open-runtime-module-library?branch=polkadot-v1.3.0#18fe59659a5f3ce1b2432e3d273f559963b73517" dependencies = [ "frame-support", "orml-traits", @@ -7847,8 +7950,8 @@ dependencies = [ [[package]] name = "orml-xtokens" -version = "0.4.1-dev" -source = "git+https://github.com/open-web3-stack/open-runtime-module-library?branch=polkadot-v1.1.0#b3694e631df7f1ca16b1973122937753fcdee9d4" +version = "0.6.7" +source = "git+https://github.com/AstarNetwork/open-runtime-module-library?branch=polkadot-v1.3.0#18fe59659a5f3ce1b2432e3d273f559963b73517" dependencies = [ "cumulus-primitives-core", "frame-support", @@ -7889,10 +7992,25 @@ dependencies = [ "sha2 0.10.7", ] +[[package]] +name = "pallet-asset-rate" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-runtime", + "sp-std", +] + [[package]] name = "pallet-assets" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-benchmarking", "frame-support", @@ -7908,7 +8026,7 @@ dependencies = [ [[package]] name = "pallet-aura" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-support", "frame-system", @@ -7925,7 +8043,7 @@ dependencies = [ [[package]] name = "pallet-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-support", "frame-system", @@ -7941,7 +8059,7 @@ dependencies = [ [[package]] name = "pallet-authorship" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-support", "frame-system", @@ -7955,7 +8073,7 @@ dependencies = [ [[package]] name = "pallet-babe" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-benchmarking", "frame-support", @@ -7979,7 +8097,7 @@ dependencies = [ [[package]] name = "pallet-bags-list" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "aquamarine", "docify", @@ -8001,7 +8119,7 @@ dependencies = [ [[package]] name = "pallet-balances" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-benchmarking", "frame-support", @@ -8016,7 +8134,7 @@ dependencies = [ [[package]] name = "pallet-beefy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-support", "frame-system", @@ -8036,9 +8154,9 @@ dependencies = [ [[package]] name = "pallet-beefy-mmr" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ - "array-bytes", + "array-bytes 6.1.0", "binary-merkle-tree", "frame-support", "frame-system", @@ -8082,7 +8200,7 @@ dependencies = [ [[package]] name = "pallet-bounties" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-benchmarking", "frame-support", @@ -8164,7 +8282,7 @@ dependencies = [ [[package]] name = "pallet-child-bounties" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-benchmarking", "frame-support", @@ -8209,7 +8327,7 @@ dependencies = [ [[package]] name = "pallet-collective" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-benchmarking", "frame-support", @@ -8226,7 +8344,7 @@ dependencies = [ [[package]] name = "pallet-contracts" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "bitflags 1.3.2", "environmental", @@ -8256,7 +8374,7 @@ dependencies = [ [[package]] name = "pallet-contracts-primitives" version = "24.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "bitflags 1.3.2", "parity-scale-codec", @@ -8269,7 +8387,7 @@ dependencies = [ [[package]] name = "pallet-contracts-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "proc-macro2", "quote", @@ -8279,7 +8397,7 @@ dependencies = [ [[package]] name = "pallet-conviction-voting" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "assert_matches", "frame-benchmarking", @@ -8362,7 +8480,7 @@ dependencies = [ [[package]] name = "pallet-democracy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-benchmarking", "frame-support", @@ -8400,7 +8518,7 @@ dependencies = [ [[package]] name = "pallet-election-provider-multi-phase" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -8423,7 +8541,7 @@ dependencies = [ [[package]] name = "pallet-election-provider-support-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -8437,7 +8555,7 @@ dependencies = [ [[package]] name = "pallet-elections-phragmen" version = "5.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-benchmarking", "frame-support", @@ -8456,7 +8574,7 @@ dependencies = [ [[package]] name = "pallet-ethereum" version = "4.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.1.0#8a5a81a24c3e0fab668483b54882757b7302926d" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#76939a19b45d9908f0358b0aaed9a5ab20398f45" dependencies = [ "ethereum", "ethereum-types", @@ -8503,7 +8621,7 @@ dependencies = [ [[package]] name = "pallet-evm" version = "6.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.1.0#8a5a81a24c3e0fab668483b54882757b7302926d" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#76939a19b45d9908f0358b0aaed9a5ab20398f45" dependencies = [ "environmental", "evm", @@ -8512,7 +8630,7 @@ dependencies = [ "frame-benchmarking", "frame-support", "frame-system", - "hash-db 0.16.0", + "hash-db", "hex", "hex-literal", "impl-trait-for-tuples", @@ -8529,13 +8647,12 @@ dependencies = [ [[package]] name = "pallet-evm-chain-id" version = "1.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.1.0#8a5a81a24c3e0fab668483b54882757b7302926d" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#76939a19b45d9908f0358b0aaed9a5ab20398f45" dependencies = [ "frame-support", "frame-system", "parity-scale-codec", "scale-info", - "sp-runtime", ] [[package]] @@ -8567,7 +8684,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-blake2" version = "2.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.1.0#8a5a81a24c3e0fab668483b54882757b7302926d" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#76939a19b45d9908f0358b0aaed9a5ab20398f45" dependencies = [ "fp-evm", ] @@ -8575,7 +8692,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-bn128" version = "2.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.1.0#8a5a81a24c3e0fab668483b54882757b7302926d" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#76939a19b45d9908f0358b0aaed9a5ab20398f45" dependencies = [ "fp-evm", "sp-core", @@ -8638,7 +8755,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-dispatch" version = "2.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.1.0#8a5a81a24c3e0fab668483b54882757b7302926d" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#76939a19b45d9908f0358b0aaed9a5ab20398f45" dependencies = [ "fp-evm", "frame-support", @@ -8676,7 +8793,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-ed25519" version = "2.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.1.0#8a5a81a24c3e0fab668483b54882757b7302926d" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#76939a19b45d9908f0358b0aaed9a5ab20398f45" dependencies = [ "ed25519-dalek", "fp-evm", @@ -8685,7 +8802,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-modexp" version = "2.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.1.0#8a5a81a24c3e0fab668483b54882757b7302926d" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#76939a19b45d9908f0358b0aaed9a5ab20398f45" dependencies = [ "fp-evm", "num", @@ -8694,7 +8811,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-sha3fips" version = "2.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.1.0#8a5a81a24c3e0fab668483b54882757b7302926d" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#76939a19b45d9908f0358b0aaed9a5ab20398f45" dependencies = [ "fp-evm", "tiny-keccak", @@ -8703,7 +8820,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-simple" version = "2.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.1.0#8a5a81a24c3e0fab668483b54882757b7302926d" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#76939a19b45d9908f0358b0aaed9a5ab20398f45" dependencies = [ "fp-evm", "ripemd", @@ -8852,7 +8969,7 @@ dependencies = [ [[package]] name = "pallet-fast-unstake" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "docify", "frame-benchmarking", @@ -8871,7 +8988,7 @@ dependencies = [ [[package]] name = "pallet-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-benchmarking", "frame-support", @@ -8894,7 +9011,7 @@ dependencies = [ [[package]] name = "pallet-identity" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "enumflags2", "frame-benchmarking", @@ -8910,7 +9027,7 @@ dependencies = [ [[package]] name = "pallet-im-online" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-benchmarking", "frame-support", @@ -8930,7 +9047,7 @@ dependencies = [ [[package]] name = "pallet-indices" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-benchmarking", "frame-support", @@ -8966,7 +9083,7 @@ dependencies = [ [[package]] name = "pallet-insecure-randomness-collective-flip" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-support", "frame-system", @@ -8980,7 +9097,7 @@ dependencies = [ [[package]] name = "pallet-membership" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-benchmarking", "frame-support", @@ -8997,7 +9114,7 @@ dependencies = [ [[package]] name = "pallet-message-queue" version = "7.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-benchmarking", "frame-support", @@ -9016,7 +9133,7 @@ dependencies = [ [[package]] name = "pallet-mmr" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-benchmarking", "frame-support", @@ -9034,7 +9151,7 @@ dependencies = [ [[package]] name = "pallet-multisig" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-benchmarking", "frame-support", @@ -9050,7 +9167,7 @@ dependencies = [ [[package]] name = "pallet-nis" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-benchmarking", "frame-support", @@ -9066,7 +9183,7 @@ dependencies = [ [[package]] name = "pallet-nomination-pools" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-support", "frame-system", @@ -9085,7 +9202,7 @@ dependencies = [ [[package]] name = "pallet-nomination-pools-benchmarking" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -9105,7 +9222,7 @@ dependencies = [ [[package]] name = "pallet-nomination-pools-runtime-api" version = "1.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "pallet-nomination-pools", "parity-scale-codec", @@ -9116,7 +9233,7 @@ dependencies = [ [[package]] name = "pallet-offences" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-support", "frame-system", @@ -9133,7 +9250,7 @@ dependencies = [ [[package]] name = "pallet-offences-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -9157,7 +9274,7 @@ dependencies = [ [[package]] name = "pallet-preimage" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-benchmarking", "frame-support", @@ -9174,7 +9291,7 @@ dependencies = [ [[package]] name = "pallet-proxy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-benchmarking", "frame-support", @@ -9189,7 +9306,7 @@ dependencies = [ [[package]] name = "pallet-ranked-collective" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-benchmarking", "frame-support", @@ -9207,7 +9324,7 @@ dependencies = [ [[package]] name = "pallet-recovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-benchmarking", "frame-support", @@ -9222,7 +9339,7 @@ dependencies = [ [[package]] name = "pallet-referenda" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "assert_matches", "frame-benchmarking", @@ -9241,7 +9358,7 @@ dependencies = [ [[package]] name = "pallet-scheduler" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "docify", "frame-benchmarking", @@ -9259,7 +9376,7 @@ dependencies = [ [[package]] name = "pallet-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-support", "frame-system", @@ -9281,7 +9398,7 @@ dependencies = [ [[package]] name = "pallet-session-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-benchmarking", "frame-support", @@ -9298,7 +9415,7 @@ dependencies = [ [[package]] name = "pallet-society" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-benchmarking", "frame-support", @@ -9316,7 +9433,7 @@ dependencies = [ [[package]] name = "pallet-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -9339,7 +9456,7 @@ dependencies = [ [[package]] name = "pallet-staking-reward-curve" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "proc-macro-crate 1.3.1", "proc-macro2", @@ -9350,7 +9467,7 @@ dependencies = [ [[package]] name = "pallet-staking-reward-fn" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "log", "sp-arithmetic", @@ -9359,7 +9476,7 @@ dependencies = [ [[package]] name = "pallet-staking-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "parity-scale-codec", "sp-api", @@ -9368,7 +9485,7 @@ dependencies = [ [[package]] name = "pallet-state-trie-migration" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-benchmarking", "frame-support", @@ -9405,8 +9522,9 @@ dependencies = [ [[package]] name = "pallet-sudo" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ + "docify", "frame-benchmarking", "frame-support", "frame-system", @@ -9420,8 +9538,9 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ + "docify", "frame-benchmarking", "frame-support", "frame-system", @@ -9439,7 +9558,7 @@ dependencies = [ [[package]] name = "pallet-tips" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-benchmarking", "frame-support", @@ -9458,7 +9577,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-support", "frame-system", @@ -9474,7 +9593,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "jsonrpsee", "pallet-transaction-payment-rpc-runtime-api", @@ -9490,7 +9609,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "pallet-transaction-payment", "parity-scale-codec", @@ -9502,8 +9621,9 @@ dependencies = [ [[package]] name = "pallet-treasury" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ + "docify", "frame-benchmarking", "frame-support", "frame-system", @@ -9512,6 +9632,7 @@ dependencies = [ "parity-scale-codec", "scale-info", "serde", + "sp-core", "sp-runtime", "sp-std", ] @@ -9544,7 +9665,7 @@ dependencies = [ [[package]] name = "pallet-utility" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-benchmarking", "frame-support", @@ -9560,7 +9681,7 @@ dependencies = [ [[package]] name = "pallet-vesting" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-benchmarking", "frame-support", @@ -9575,7 +9696,7 @@ dependencies = [ [[package]] name = "pallet-whitelist" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-benchmarking", "frame-support", @@ -9610,7 +9731,7 @@ dependencies = [ [[package]] name = "pallet-xcm" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "bounded-collections", "frame-benchmarking", @@ -9631,7 +9752,7 @@ dependencies = [ [[package]] name = "pallet-xcm-benchmarks" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-benchmarking", "frame-support", @@ -9677,7 +9798,7 @@ dependencies = [ [[package]] name = "parachain-info" version = "0.1.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "cumulus-primitives-core", "frame-support", @@ -9694,7 +9815,7 @@ version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "592a28a24b09c9dc20ac8afaa6839abc417c720afe42c12e1e4a9d6aa2508d2e" dependencies = [ - "blake2", + "blake2 0.10.6", "crc32fast", "fs2", "hex", @@ -9932,7 +10053,7 @@ version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e9567389417feee6ce15dd6527a8a1ecac205ef62c2932bcf3d9f6fc5b78b414" dependencies = [ - "futures 0.3.28", + "futures 0.3.30", "rustc_version 0.4.0", ] @@ -10020,9 +10141,9 @@ checksum = "e3d7ddaed09e0eb771a79ab0fd64609ba0afb0a8366421957936ad14cbd13630" [[package]] name = "polkadot-approval-distribution" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ - "futures 0.3.28", + "futures 0.3.30", "futures-timer", "polkadot-node-jaeger", "polkadot-node-metrics", @@ -10038,10 +10159,10 @@ dependencies = [ [[package]] name = "polkadot-availability-bitfield-distribution" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "always-assert", - "futures 0.3.28", + "futures 0.3.30", "futures-timer", "polkadot-node-network-protocol", "polkadot-node-subsystem", @@ -10054,11 +10175,11 @@ dependencies = [ [[package]] name = "polkadot-availability-distribution" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "derive_more", "fatality", - "futures 0.3.28", + "futures 0.3.30", "parity-scale-codec", "polkadot-erasure-coding", "polkadot-node-network-protocol", @@ -10077,10 +10198,11 @@ dependencies = [ [[package]] name = "polkadot-availability-recovery" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ + "async-trait", "fatality", - "futures 0.3.28", + "futures 0.3.30", "parity-scale-codec", "polkadot-erasure-coding", "polkadot-node-network-protocol", @@ -10098,14 +10220,14 @@ dependencies = [ [[package]] name = "polkadot-cli" version = "1.1.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "clap", "frame-benchmarking-cli", - "futures 0.3.28", + "futures 0.3.30", "log", "polkadot-node-metrics", - "polkadot-performance-test", + "polkadot-node-primitives", "polkadot-service", "sc-cli", "sc-executor", @@ -10125,11 +10247,11 @@ dependencies = [ [[package]] name = "polkadot-collator-protocol" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "bitvec", "fatality", - "futures 0.3.28", + "futures 0.3.30", "futures-timer", "polkadot-node-network-protocol", "polkadot-node-primitives", @@ -10147,7 +10269,7 @@ dependencies = [ [[package]] name = "polkadot-core-primitives" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "parity-scale-codec", "scale-info", @@ -10159,11 +10281,11 @@ dependencies = [ [[package]] name = "polkadot-dispute-distribution" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "derive_more", "fatality", - "futures 0.3.28", + "futures 0.3.30", "futures-timer", "indexmap 1.9.3", "parity-scale-codec", @@ -10184,7 +10306,7 @@ dependencies = [ [[package]] name = "polkadot-erasure-coding" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "parity-scale-codec", "polkadot-node-primitives", @@ -10198,9 +10320,9 @@ dependencies = [ [[package]] name = "polkadot-gossip-support" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ - "futures 0.3.28", + "futures 0.3.30", "futures-timer", "polkadot-node-network-protocol", "polkadot-node-subsystem", @@ -10219,13 +10341,13 @@ dependencies = [ [[package]] name = "polkadot-network-bridge" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "always-assert", "async-trait", "bytes", "fatality", - "futures 0.3.28", + "futures 0.3.30", "parity-scale-codec", "parking_lot 0.12.1", "polkadot-node-metrics", @@ -10242,9 +10364,9 @@ dependencies = [ [[package]] name = "polkadot-node-collation-generation" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ - "futures 0.3.28", + "futures 0.3.30", "parity-scale-codec", "polkadot-erasure-coding", "polkadot-node-primitives", @@ -10260,11 +10382,11 @@ dependencies = [ [[package]] name = "polkadot-node-core-approval-voting" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "bitvec", "derive_more", - "futures 0.3.28", + "futures 0.3.30", "futures-timer", "kvdb", "merlin 2.0.1", @@ -10289,10 +10411,10 @@ dependencies = [ [[package]] name = "polkadot-node-core-av-store" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "bitvec", - "futures 0.3.28", + "futures 0.3.30", "futures-timer", "kvdb", "parity-scale-codec", @@ -10311,11 +10433,11 @@ dependencies = [ [[package]] name = "polkadot-node-core-backing" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "bitvec", "fatality", - "futures 0.3.28", + "futures 0.3.30", "polkadot-erasure-coding", "polkadot-node-primitives", "polkadot-node-subsystem", @@ -10330,9 +10452,9 @@ dependencies = [ [[package]] name = "polkadot-node-core-bitfield-signing" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ - "futures 0.3.28", + "futures 0.3.30", "polkadot-node-subsystem", "polkadot-node-subsystem-util", "polkadot-primitives", @@ -10345,10 +10467,10 @@ dependencies = [ [[package]] name = "polkadot-node-core-candidate-validation" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "async-trait", - "futures 0.3.28", + "futures 0.3.30", "futures-timer", "parity-scale-codec", "polkadot-node-core-pvf", @@ -10366,9 +10488,9 @@ dependencies = [ [[package]] name = "polkadot-node-core-chain-api" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ - "futures 0.3.28", + "futures 0.3.30", "polkadot-node-metrics", "polkadot-node-subsystem", "polkadot-primitives", @@ -10381,9 +10503,9 @@ dependencies = [ [[package]] name = "polkadot-node-core-chain-selection" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ - "futures 0.3.28", + "futures 0.3.30", "futures-timer", "kvdb", "parity-scale-codec", @@ -10398,10 +10520,10 @@ dependencies = [ [[package]] name = "polkadot-node-core-dispute-coordinator" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "fatality", - "futures 0.3.28", + "futures 0.3.30", "kvdb", "parity-scale-codec", "polkadot-node-primitives", @@ -10417,10 +10539,10 @@ dependencies = [ [[package]] name = "polkadot-node-core-parachains-inherent" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "async-trait", - "futures 0.3.28", + "futures 0.3.30", "futures-timer", "polkadot-node-subsystem", "polkadot-overseer", @@ -10434,11 +10556,11 @@ dependencies = [ [[package]] name = "polkadot-node-core-prospective-parachains" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "bitvec", "fatality", - "futures 0.3.28", + "futures 0.3.30", "parity-scale-codec", "polkadot-node-primitives", "polkadot-node-subsystem", @@ -10451,11 +10573,11 @@ dependencies = [ [[package]] name = "polkadot-node-core-provisioner" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "bitvec", "fatality", - "futures 0.3.28", + "futures 0.3.30", "futures-timer", "polkadot-node-primitives", "polkadot-node-subsystem", @@ -10468,11 +10590,13 @@ dependencies = [ [[package]] name = "polkadot-node-core-pvf" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "always-assert", - "futures 0.3.28", + "cfg-if", + "futures 0.3.30", "futures-timer", + "is_executable", "libc", "parity-scale-codec", "pin-project", @@ -10487,7 +10611,6 @@ dependencies = [ "sp-core", "sp-maybe-compressed-blob", "sp-wasm-interface", - "substrate-build-script-utils", "tempfile", "tokio", "tracing-gum", @@ -10496,9 +10619,9 @@ dependencies = [ [[package]] name = "polkadot-node-core-pvf-checker" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ - "futures 0.3.28", + "futures 0.3.30", "polkadot-node-primitives", "polkadot-node-subsystem", "polkadot-node-subsystem-util", @@ -10512,10 +10635,11 @@ dependencies = [ [[package]] name = "polkadot-node-core-pvf-common" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ + "cfg-if", "cpu-time", - "futures 0.3.28", + "futures 0.3.30", "landlock", "libc", "parity-scale-codec", @@ -10532,35 +10656,12 @@ dependencies = [ "tracing-gum", ] -[[package]] -name = "polkadot-node-core-pvf-prepare-worker" -version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" -dependencies = [ - "futures 0.3.28", - "libc", - "parity-scale-codec", - "polkadot-node-core-pvf-common", - "polkadot-parachain-primitives", - "polkadot-primitives", - "rayon", - "sc-executor", - "sc-executor-common", - "sc-executor-wasmtime", - "sp-io", - "sp-maybe-compressed-blob", - "sp-tracing", - "tikv-jemalloc-ctl", - "tokio", - "tracing-gum", -] - [[package]] name = "polkadot-node-core-runtime-api" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ - "futures 0.3.28", + "futures 0.3.30", "polkadot-node-metrics", "polkadot-node-subsystem", "polkadot-node-subsystem-types", @@ -10573,7 +10674,7 @@ dependencies = [ [[package]] name = "polkadot-node-jaeger" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "lazy_static", "log", @@ -10591,15 +10692,15 @@ dependencies = [ [[package]] name = "polkadot-node-metrics" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "bs58 0.5.0", - "futures 0.3.28", + "futures 0.3.30", "futures-timer", "log", "parity-scale-codec", "polkadot-primitives", - "prioritized-metered-channel", + "prioritized-metered-channel 0.5.1", "sc-cli", "sc-service", "sc-tracing", @@ -10610,14 +10711,14 @@ dependencies = [ [[package]] name = "polkadot-node-network-protocol" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "async-channel 1.9.0", "async-trait", "bitvec", "derive_more", "fatality", - "futures 0.3.28", + "futures 0.3.30", "hex", "parity-scale-codec", "polkadot-node-jaeger", @@ -10634,10 +10735,10 @@ dependencies = [ [[package]] name = "polkadot-node-primitives" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "bounded-vec", - "futures 0.3.28", + "futures 0.3.30", "parity-scale-codec", "polkadot-parachain-primitives", "polkadot-primitives", @@ -10656,7 +10757,7 @@ dependencies = [ [[package]] name = "polkadot-node-subsystem" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "polkadot-node-jaeger", "polkadot-node-subsystem-types", @@ -10666,17 +10767,18 @@ dependencies = [ [[package]] name = "polkadot-node-subsystem-types" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "async-trait", "derive_more", - "futures 0.3.28", + "futures 0.3.30", "orchestra", "polkadot-node-jaeger", "polkadot-node-network-protocol", "polkadot-node-primitives", "polkadot-primitives", "polkadot-statement-table", + "sc-client-api", "sc-network", "sc-transaction-pool-api", "smallvec 1.11.0", @@ -10690,12 +10792,12 @@ dependencies = [ [[package]] name = "polkadot-node-subsystem-util" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "async-trait", "derive_more", "fatality", - "futures 0.3.28", + "futures 0.3.30", "futures-channel", "itertools 0.10.5", "kvdb", @@ -10708,10 +10810,12 @@ dependencies = [ "polkadot-node-network-protocol", "polkadot-node-primitives", "polkadot-node-subsystem", + "polkadot-node-subsystem-types", "polkadot-overseer", "polkadot-primitives", - "prioritized-metered-channel", + "prioritized-metered-channel 0.5.1", "rand 0.8.5", + "sc-client-api", "schnellru", "sp-application-crypto", "sp-core", @@ -10723,10 +10827,10 @@ dependencies = [ [[package]] name = "polkadot-overseer" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "async-trait", - "futures 0.3.28", + "futures 0.3.30", "futures-timer", "orchestra", "parking_lot 0.12.1", @@ -10736,7 +10840,6 @@ dependencies = [ "polkadot-node-subsystem-types", "polkadot-primitives", "sc-client-api", - "schnellru", "sp-api", "sp-core", "tikv-jemalloc-ctl", @@ -10746,7 +10849,7 @@ dependencies = [ [[package]] name = "polkadot-parachain-primitives" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "bounded-collections", "derive_more", @@ -10760,28 +10863,10 @@ dependencies = [ "sp-std", ] -[[package]] -name = "polkadot-performance-test" -version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" -dependencies = [ - "env_logger 0.9.3", - "log", - "polkadot-erasure-coding", - "polkadot-node-core-pvf-prepare-worker", - "polkadot-node-primitives", - "polkadot-primitives", - "quote", - "sc-executor-common", - "sp-maybe-compressed-blob", - "staging-kusama-runtime", - "thiserror", -] - [[package]] name = "polkadot-primitives" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "bitvec", "hex-literal", @@ -10807,7 +10892,7 @@ dependencies = [ [[package]] name = "polkadot-rpc" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "jsonrpsee", "mmr-rpc", @@ -10837,106 +10922,9 @@ dependencies = [ ] [[package]] -name = "polkadot-runtime" +name = "polkadot-runtime-common" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" -dependencies = [ - "bitvec", - "frame-benchmarking", - "frame-election-provider-support", - "frame-executive", - "frame-support", - "frame-system", - "frame-system-benchmarking", - "frame-system-rpc-runtime-api", - "frame-try-runtime", - "hex-literal", - "log", - "pallet-authority-discovery", - "pallet-authorship", - "pallet-babe", - "pallet-bags-list", - "pallet-balances", - "pallet-bounties", - "pallet-child-bounties", - "pallet-collective", - "pallet-conviction-voting", - "pallet-democracy", - "pallet-election-provider-multi-phase", - "pallet-election-provider-support-benchmarking", - "pallet-elections-phragmen", - "pallet-fast-unstake", - "pallet-grandpa", - "pallet-identity", - "pallet-im-online", - "pallet-indices", - "pallet-membership", - "pallet-message-queue", - "pallet-multisig", - "pallet-nomination-pools", - "pallet-nomination-pools-benchmarking", - "pallet-nomination-pools-runtime-api", - "pallet-offences", - "pallet-offences-benchmarking", - "pallet-preimage", - "pallet-proxy", - "pallet-referenda", - "pallet-scheduler", - "pallet-session", - "pallet-session-benchmarking", - "pallet-staking", - "pallet-staking-reward-curve", - "pallet-staking-runtime-api", - "pallet-timestamp", - "pallet-tips", - "pallet-transaction-payment", - "pallet-transaction-payment-rpc-runtime-api", - "pallet-treasury", - "pallet-utility", - "pallet-vesting", - "pallet-whitelist", - "pallet-xcm", - "pallet-xcm-benchmarks", - "parity-scale-codec", - "polkadot-primitives", - "polkadot-runtime-common", - "polkadot-runtime-constants", - "polkadot-runtime-parachains", - "rustc-hex", - "scale-info", - "serde", - "serde_derive", - "smallvec 1.11.0", - "sp-api", - "sp-arithmetic", - "sp-authority-discovery", - "sp-block-builder", - "sp-consensus-babe", - "sp-consensus-beefy", - "sp-core", - "sp-inherents", - "sp-io", - "sp-mmr-primitives", - "sp-npos-elections", - "sp-offchain", - "sp-runtime", - "sp-session", - "sp-staking", - "sp-std", - "sp-storage", - "sp-transaction-pool", - "sp-version", - "staging-xcm", - "staging-xcm-builder", - "staging-xcm-executor", - "static_assertions", - "substrate-wasm-builder", -] - -[[package]] -name = "polkadot-runtime-common" -version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "bitvec", "frame-benchmarking", @@ -10946,6 +10934,7 @@ dependencies = [ "impl-trait-for-tuples", "libsecp256k1", "log", + "pallet-asset-rate", "pallet-authorship", "pallet-babe", "pallet-balances", @@ -10958,6 +10947,7 @@ dependencies = [ "pallet-transaction-payment", "pallet-treasury", "pallet-vesting", + "pallet-xcm-benchmarks", "parity-scale-codec", "polkadot-primitives", "polkadot-runtime-parachains", @@ -10976,27 +10966,15 @@ dependencies = [ "sp-staking", "sp-std", "staging-xcm", + "staging-xcm-builder", + "staging-xcm-executor", "static_assertions", ] -[[package]] -name = "polkadot-runtime-constants" -version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" -dependencies = [ - "frame-support", - "polkadot-primitives", - "polkadot-runtime-common", - "smallvec 1.11.0", - "sp-core", - "sp-runtime", - "sp-weights", -] - [[package]] name = "polkadot-runtime-metrics" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "bs58 0.5.0", "frame-benchmarking", @@ -11009,7 +10987,7 @@ dependencies = [ [[package]] name = "polkadot-runtime-parachains" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "bitflags 1.3.2", "bitvec", @@ -11029,6 +11007,7 @@ dependencies = [ "pallet-timestamp", "pallet-vesting", "parity-scale-codec", + "polkadot-core-primitives", "polkadot-parachain-primitives", "polkadot-primitives", "polkadot-runtime-metrics", @@ -11055,7 +11034,7 @@ dependencies = [ [[package]] name = "polkadot-service" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "async-trait", "frame-benchmarking", @@ -11063,7 +11042,7 @@ dependencies = [ "frame-support", "frame-system", "frame-system-rpc-runtime-api", - "futures 0.3.28", + "futures 0.3.30", "hex-literal", "is_executable", "kvdb", @@ -11110,8 +11089,6 @@ dependencies = [ "polkadot-parachain-primitives", "polkadot-primitives", "polkadot-rpc", - "polkadot-runtime", - "polkadot-runtime-common", "polkadot-runtime-parachains", "polkadot-statement-distribution", "rococo-runtime", @@ -11164,7 +11141,6 @@ dependencies = [ "sp-transaction-pool", "sp-version", "sp-weights", - "staging-kusama-runtime", "substrate-prometheus-endpoint", "thiserror", "tracing-gum", @@ -11174,12 +11150,12 @@ dependencies = [ [[package]] name = "polkadot-statement-distribution" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "arrayvec 0.7.4", "bitvec", "fatality", - "futures 0.3.28", + "futures 0.3.30", "futures-timer", "indexmap 1.9.3", "parity-scale-codec", @@ -11198,7 +11174,7 @@ dependencies = [ [[package]] name = "polkadot-statement-table" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "parity-scale-codec", "polkadot-primitives", @@ -11394,14 +11370,30 @@ dependencies = [ [[package]] name = "prioritized-metered-channel" -version = "0.2.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "382698e48a268c832d0b181ed438374a6bb708a82a8ca273bb0f61c74cf209c4" +checksum = "e99f0c89bd88f393aab44a4ab949351f7bc7e7e1179d11ecbfe50cbe4c47e342" dependencies = [ "coarsetime", "crossbeam-queue", "derive_more", - "futures 0.3.28", + "futures 0.3.30", + "futures-timer", + "nanorand", + "thiserror", + "tracing", +] + +[[package]] +name = "prioritized-metered-channel" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a172e6cc603231f2cf004232eabcecccc0da53ba576ab286ef7baa0cfc7927ad" +dependencies = [ + "coarsetime", + "crossbeam-queue", + "derive_more", + "futures 0.3.30", "futures-timer", "nanorand", "thiserror", @@ -11454,9 +11446,9 @@ dependencies = [ [[package]] name = "proc-macro-warning" -version = "0.4.2" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1eaa7fa0aa1929ffdf7eeb6eac234dde6268914a14ad44d23521ab6a9b258e" +checksum = "834da187cfe638ae8abb0203f0b33e5ccdb02a28e7199f2f47b3e2754f50edca" dependencies = [ "proc-macro2", "quote", @@ -11706,6 +11698,16 @@ dependencies = [ "getrandom 0.2.10", ] +[[package]] +name = "rand_distr" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32cb0b9bc82b0a0876c2dd994a7e7a2683d3e7390ca40e6886785ef0c7e3ee31" +dependencies = [ + "num-traits", + "rand 0.8.5", +] + [[package]] name = "rand_hc" version = "0.2.0" @@ -11957,19 +11959,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" dependencies = [ "hmac 0.12.1", - "subtle", + "subtle 2.4.1", ] [[package]] name = "ring" version = "0.1.0" -source = "git+https://github.com/w3f/ring-proof?rev=0e948f3#0e948f3c28cbacecdd3020403c4841c0eb339213" +source = "git+https://github.com/w3f/ring-proof#b273d33f9981e2bb3375ab45faeb537f7ee35224" dependencies = [ "ark-ec", "ark-ff", "ark-poly", "ark-serialize", "ark-std", + "blake2 0.10.6", "common", "fflonk", "merlin 3.0.0", @@ -12048,7 +12051,7 @@ dependencies = [ [[package]] name = "rococo-runtime" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "binary-merkle-tree", "frame-benchmarking", @@ -12060,6 +12063,7 @@ dependencies = [ "frame-try-runtime", "hex-literal", "log", + "pallet-asset-rate", "pallet-authority-discovery", "pallet-authorship", "pallet-babe", @@ -12069,6 +12073,7 @@ dependencies = [ "pallet-bounties", "pallet-child-bounties", "pallet-collective", + "pallet-conviction-voting", "pallet-democracy", "pallet-elections-phragmen", "pallet-grandpa", @@ -12083,7 +12088,9 @@ dependencies = [ "pallet-offences", "pallet-preimage", "pallet-proxy", + "pallet-ranked-collective", "pallet-recovery", + "pallet-referenda", "pallet-scheduler", "pallet-session", "pallet-society", @@ -12097,6 +12104,7 @@ dependencies = [ "pallet-treasury", "pallet-utility", "pallet-vesting", + "pallet-whitelist", "pallet-xcm", "pallet-xcm-benchmarks", "parity-scale-codec", @@ -12110,11 +12118,13 @@ dependencies = [ "serde_derive", "smallvec 1.11.0", "sp-api", + "sp-arithmetic", "sp-authority-discovery", "sp-block-builder", "sp-consensus-babe", "sp-consensus-beefy", "sp-core", + "sp-genesis-builder", "sp-inherents", "sp-io", "sp-mmr-primitives", @@ -12136,7 +12146,7 @@ dependencies = [ [[package]] name = "rococo-runtime-constants" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-support", "polkadot-primitives", @@ -12145,6 +12155,7 @@ dependencies = [ "sp-core", "sp-runtime", "sp-weights", + "staging-xcm", ] [[package]] @@ -12175,7 +12186,7 @@ version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "322c53fd76a18698f1c27381d58091de3a043d356aa5bd0d510608b565f469a0" dependencies = [ - "futures 0.3.28", + "futures 0.3.30", "log", "netlink-packet-route", "netlink-proto", @@ -12385,7 +12396,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26338f5e09bb721b85b135ea05af7767c90b52f6de4f087d4f4a3a9d64e7dc04" dependencies = [ - "futures 0.3.28", + "futures 0.3.30", "pin-project", "static_assertions", ] @@ -12435,7 +12446,7 @@ dependencies = [ [[package]] name = "sc-allocator" version = "4.1.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "log", "sp-core", @@ -12446,10 +12457,10 @@ dependencies = [ [[package]] name = "sc-authority-discovery" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "async-trait", - "futures 0.3.28", + "futures 0.3.30", "futures-timer", "ip_network", "libp2p", @@ -12474,9 +12485,9 @@ dependencies = [ [[package]] name = "sc-basic-authorship" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ - "futures 0.3.28", + "futures 0.3.30", "futures-timer", "log", "parity-scale-codec", @@ -12497,7 +12508,7 @@ dependencies = [ [[package]] name = "sc-block-builder" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "parity-scale-codec", "sc-client-api", @@ -12512,7 +12523,7 @@ dependencies = [ [[package]] name = "sc-chain-spec" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "memmap2", "sc-chain-spec-derive", @@ -12531,7 +12542,7 @@ dependencies = [ [[package]] name = "sc-chain-spec-derive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "proc-macro-crate 1.3.1", "proc-macro2", @@ -12542,13 +12553,13 @@ dependencies = [ [[package]] name = "sc-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ - "array-bytes", + "array-bytes 6.1.0", "chrono", "clap", "fdlimit", - "futures 0.3.28", + "futures 0.3.30", "libp2p-identity", "log", "names", @@ -12559,6 +12570,7 @@ dependencies = [ "sc-client-api", "sc-client-db", "sc-keystore", + "sc-mixnet", "sc-network", "sc-service", "sc-telemetry", @@ -12581,10 +12593,10 @@ dependencies = [ [[package]] name = "sc-client-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "fnv", - "futures 0.3.28", + "futures 0.3.30", "log", "parity-scale-codec", "parking_lot 0.12.1", @@ -12601,15 +12613,16 @@ dependencies = [ "sp-state-machine", "sp-statement-store", "sp-storage", + "sp-trie", "substrate-prometheus-endpoint", ] [[package]] name = "sc-client-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ - "hash-db 0.16.0", + "hash-db", "kvdb", "kvdb-memorydb", "kvdb-rocksdb", @@ -12633,10 +12646,10 @@ dependencies = [ [[package]] name = "sc-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "async-trait", - "futures 0.3.28", + "futures 0.3.30", "futures-timer", "libp2p-identity", "log", @@ -12658,10 +12671,10 @@ dependencies = [ [[package]] name = "sc-consensus-aura" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "async-trait", - "futures 0.3.28", + "futures 0.3.30", "log", "parity-scale-codec", "sc-block-builder", @@ -12687,11 +12700,11 @@ dependencies = [ [[package]] name = "sc-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "async-trait", "fork-tree", - "futures 0.3.28", + "futures 0.3.30", "log", "num-bigint", "num-rational", @@ -12704,7 +12717,6 @@ dependencies = [ "sc-consensus-slots", "sc-telemetry", "sc-transaction-pool-api", - "scale-info", "sp-api", "sp-application-crypto", "sp-block-builder", @@ -12723,9 +12735,9 @@ dependencies = [ [[package]] name = "sc-consensus-babe-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ - "futures 0.3.28", + "futures 0.3.30", "jsonrpsee", "sc-consensus-babe", "sc-consensus-epochs", @@ -12745,13 +12757,13 @@ dependencies = [ [[package]] name = "sc-consensus-beefy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ - "array-bytes", + "array-bytes 6.1.0", "async-channel 1.9.0", "async-trait", "fnv", - "futures 0.3.28", + "futures 0.3.30", "log", "parity-scale-codec", "parking_lot 0.12.1", @@ -12779,9 +12791,9 @@ dependencies = [ [[package]] name = "sc-consensus-beefy-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ - "futures 0.3.28", + "futures 0.3.30", "jsonrpsee", "log", "parity-scale-codec", @@ -12798,7 +12810,7 @@ dependencies = [ [[package]] name = "sc-consensus-epochs" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "fork-tree", "parity-scale-codec", @@ -12811,15 +12823,15 @@ dependencies = [ [[package]] name = "sc-consensus-grandpa" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "ahash 0.8.3", - "array-bytes", + "array-bytes 6.1.0", "async-trait", "dyn-clone", "finality-grandpa", "fork-tree", - "futures 0.3.28", + "futures 0.3.30", "futures-timer", "log", "parity-scale-codec", @@ -12852,10 +12864,10 @@ dependencies = [ [[package]] name = "sc-consensus-grandpa-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "finality-grandpa", - "futures 0.3.28", + "futures 0.3.30", "jsonrpsee", "log", "parity-scale-codec", @@ -12872,10 +12884,10 @@ dependencies = [ [[package]] name = "sc-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "async-trait", - "futures 0.3.28", + "futures 0.3.30", "futures-timer", "log", "parity-scale-codec", @@ -12895,7 +12907,7 @@ dependencies = [ [[package]] name = "sc-executor" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "parity-scale-codec", "parking_lot 0.12.1", @@ -12917,7 +12929,7 @@ dependencies = [ [[package]] name = "sc-executor-common" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "sc-allocator", "sp-maybe-compressed-blob", @@ -12929,12 +12941,13 @@ dependencies = [ [[package]] name = "sc-executor-wasmtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "anyhow", "cfg-if", "libc", "log", + "parking_lot 0.12.1", "rustix 0.36.17", "sc-allocator", "sc-executor-common", @@ -12946,10 +12959,10 @@ dependencies = [ [[package]] name = "sc-informant" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "ansi_term", - "futures 0.3.28", + "futures 0.3.30", "futures-timer", "log", "sc-client-api", @@ -12962,9 +12975,9 @@ dependencies = [ [[package]] name = "sc-keystore" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ - "array-bytes", + "array-bytes 6.1.0", "parking_lot 0.12.1", "serde_json", "sp-application-crypto", @@ -12973,19 +12986,47 @@ dependencies = [ "thiserror", ] +[[package]] +name = "sc-mixnet" +version = "0.1.0-dev" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" +dependencies = [ + "array-bytes 4.2.0", + "arrayvec 0.7.4", + "blake2 0.10.6", + "futures 0.3.30", + "futures-timer", + "libp2p-identity", + "log", + "mixnet", + "multiaddr", + "parity-scale-codec", + "parking_lot 0.12.1", + "sc-client-api", + "sc-network", + "sc-transaction-pool-api", + "sp-api", + "sp-consensus", + "sp-core", + "sp-keystore", + "sp-mixnet", + "sp-runtime", + "thiserror", +] + [[package]] name = "sc-network" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ - "array-bytes", + "array-bytes 6.1.0", "async-channel 1.9.0", "async-trait", "asynchronous-codec", "bytes", "either", "fnv", - "futures 0.3.28", + "futures 0.3.30", "futures-timer", "ip_network", "libp2p", @@ -13017,11 +13058,11 @@ dependencies = [ [[package]] name = "sc-network-bitswap" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "async-channel 1.9.0", "cid", - "futures 0.3.28", + "futures 0.3.30", "libp2p-identity", "log", "prost", @@ -13037,11 +13078,11 @@ dependencies = [ [[package]] name = "sc-network-common" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "async-trait", "bitflags 1.3.2", - "futures 0.3.28", + "futures 0.3.30", "libp2p-identity", "parity-scale-codec", "prost-build", @@ -13054,10 +13095,10 @@ dependencies = [ [[package]] name = "sc-network-gossip" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "ahash 0.8.3", - "futures 0.3.28", + "futures 0.3.30", "futures-timer", "libp2p", "log", @@ -13072,11 +13113,11 @@ dependencies = [ [[package]] name = "sc-network-light" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ - "array-bytes", + "array-bytes 6.1.0", "async-channel 1.9.0", - "futures 0.3.28", + "futures 0.3.30", "libp2p-identity", "log", "parity-scale-codec", @@ -13093,13 +13134,13 @@ dependencies = [ [[package]] name = "sc-network-sync" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ - "array-bytes", + "array-bytes 6.1.0", "async-channel 1.9.0", "async-trait", "fork-tree", - "futures 0.3.28", + "futures 0.3.30", "futures-timer", "libp2p", "log", @@ -13122,15 +13163,16 @@ dependencies = [ "sp-runtime", "substrate-prometheus-endpoint", "thiserror", + "tokio-stream", ] [[package]] name = "sc-network-transactions" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ - "array-bytes", - "futures 0.3.28", + "array-bytes 6.1.0", + "futures 0.3.30", "libp2p", "log", "parity-scale-codec", @@ -13145,12 +13187,12 @@ dependencies = [ [[package]] name = "sc-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ - "array-bytes", + "array-bytes 6.1.0", "bytes", "fnv", - "futures 0.3.28", + "futures 0.3.30", "futures-timer", "hyper", "hyper-rustls", @@ -13179,7 +13221,7 @@ dependencies = [ [[package]] name = "sc-proposer-metrics" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "log", "substrate-prometheus-endpoint", @@ -13188,9 +13230,9 @@ dependencies = [ [[package]] name = "sc-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ - "futures 0.3.28", + "futures 0.3.30", "jsonrpsee", "log", "parity-scale-codec", @@ -13198,6 +13240,7 @@ dependencies = [ "sc-block-builder", "sc-chain-spec", "sc-client-api", + "sc-mixnet", "sc-rpc-api", "sc-tracing", "sc-transaction-pool-api", @@ -13219,11 +13262,12 @@ dependencies = [ [[package]] name = "sc-rpc-api" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "jsonrpsee", "parity-scale-codec", "sc-chain-spec", + "sc-mixnet", "sc-transaction-pool-api", "scale-info", "serde", @@ -13238,7 +13282,7 @@ dependencies = [ [[package]] name = "sc-rpc-server" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "http", "jsonrpsee", @@ -13253,10 +13297,10 @@ dependencies = [ [[package]] name = "sc-rpc-spec-v2" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ - "array-bytes", - "futures 0.3.28", + "array-bytes 6.1.0", + "futures 0.3.30", "futures-util", "hex", "jsonrpsee", @@ -13281,12 +13325,12 @@ dependencies = [ [[package]] name = "sc-service" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "async-trait", "directories", "exit-future", - "futures 0.3.28", + "futures 0.3.30", "futures-timer", "jsonrpsee", "log", @@ -13345,7 +13389,7 @@ dependencies = [ [[package]] name = "sc-state-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "log", "parity-scale-codec", @@ -13356,7 +13400,7 @@ dependencies = [ [[package]] name = "sc-storage-monitor" version = "0.1.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "clap", "fs4", @@ -13370,7 +13414,7 @@ dependencies = [ [[package]] name = "sc-sync-state-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -13389,9 +13433,9 @@ dependencies = [ [[package]] name = "sc-sysinfo" version = "6.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ - "futures 0.3.28", + "futures 0.3.30", "libc", "log", "rand 0.8.5", @@ -13408,10 +13452,10 @@ dependencies = [ [[package]] name = "sc-telemetry" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "chrono", - "futures 0.3.28", + "futures 0.3.30", "libp2p", "log", "parking_lot 0.12.1", @@ -13427,7 +13471,7 @@ dependencies = [ [[package]] name = "sc-tracing" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "ansi_term", "atty", @@ -13456,7 +13500,7 @@ dependencies = [ [[package]] name = "sc-tracing-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "proc-macro-crate 1.3.1", "proc-macro2", @@ -13467,10 +13511,10 @@ dependencies = [ [[package]] name = "sc-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "async-trait", - "futures 0.3.28", + "futures 0.3.30", "futures-timer", "linked-hash-map", "log", @@ -13493,10 +13537,10 @@ dependencies = [ [[package]] name = "sc-transaction-pool-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "async-trait", - "futures 0.3.28", + "futures 0.3.30", "log", "parity-scale-codec", "serde", @@ -13509,10 +13553,10 @@ dependencies = [ [[package]] name = "sc-utils" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "async-channel 1.9.0", - "futures 0.3.28", + "futures 0.3.30", "futures-timer", "lazy_static", "log", @@ -13523,9 +13567,9 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.9.0" +version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35c0a159d0c45c12b20c5a844feb1fe4bea86e28f17b92a5f0c42193634d3782" +checksum = "788745a868b0e751750388f4e6546eb921ef714a4317fa6954f7cde114eb2eb7" dependencies = [ "bitvec", "cfg-if", @@ -13537,9 +13581,9 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.9.0" +version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "912e55f6d20e0e80d63733872b40e1227c0bce1e1ab81ba67d696339bfd7fd29" +checksum = "7dc2f4e8bc344b9fc3d5f74f72c2e55bfc38d28dc2ebc69c194a3df424e4d9ac" dependencies = [ "proc-macro-crate 1.3.1", "proc-macro2", @@ -13581,7 +13625,7 @@ dependencies = [ "rand 0.7.3", "rand_core 0.5.1", "sha2 0.8.2", - "subtle", + "subtle 2.4.1", "zeroize", ] @@ -13667,7 +13711,7 @@ dependencies = [ "der 0.6.1", "generic-array 0.14.7", "pkcs8 0.9.0", - "subtle", + "subtle 2.4.1", "zeroize", ] @@ -13681,7 +13725,7 @@ dependencies = [ "der 0.7.7", "generic-array 0.14.7", "pkcs8 0.10.2", - "subtle", + "subtle 2.4.1", "zeroize", ] @@ -13926,7 +13970,7 @@ dependencies = [ name = "shibuya-runtime" version = "5.35.0" dependencies = [ - "array-bytes", + "array-bytes 6.1.0", "astar-primitives", "astar-xcm-benchmarks", "cumulus-pallet-aura-ext", @@ -14023,6 +14067,7 @@ dependencies = [ "sp-block-builder", "sp-consensus-aura", "sp-core", + "sp-genesis-builder", "sp-inherents", "sp-io", "sp-offchain", @@ -14042,7 +14087,7 @@ dependencies = [ name = "shiden-runtime" version = "5.35.0" dependencies = [ - "array-bytes", + "array-bytes 6.1.0", "astar-primitives", "cumulus-pallet-aura-ext", "cumulus-pallet-dmp-queue", @@ -14123,6 +14168,7 @@ dependencies = [ "sp-block-builder", "sp-consensus-aura", "sp-core", + "sp-genesis-builder", "sp-inherents", "sp-io", "sp-offchain", @@ -14254,7 +14300,7 @@ dependencies = [ [[package]] name = "slot-range-helper" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "enumn", "parity-scale-codec", @@ -14407,14 +14453,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "58021967fd0a5eeeb23b08df6cc244a4d4a5b4aec1d27c9e02fad1a58b4cd74e" dependencies = [ "aes-gcm 0.10.2", - "blake2", + "blake2 0.10.6", "chacha20poly1305", "curve25519-dalek 4.1.1", "rand_core 0.6.4", "ring 0.17.7", "rustc_version 0.4.0", "sha2 0.10.7", - "subtle", + "subtle 2.4.1", ] [[package]] @@ -14446,7 +14492,7 @@ dependencies = [ "base64 0.13.1", "bytes", "flate2", - "futures 0.3.28", + "futures 0.3.30", "http", "httparse", "log", @@ -14457,9 +14503,9 @@ dependencies = [ [[package]] name = "sp-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ - "hash-db 0.16.0", + "hash-db", "log", "parity-scale-codec", "scale-info", @@ -14478,10 +14524,10 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "Inflector", - "blake2", + "blake2 0.10.6", "expander 2.0.0", "proc-macro-crate 1.3.1", "proc-macro2", @@ -14492,7 +14538,7 @@ dependencies = [ [[package]] name = "sp-application-crypto" version = "23.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "parity-scale-codec", "scale-info", @@ -14505,7 +14551,7 @@ dependencies = [ [[package]] name = "sp-arithmetic" version = "16.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "integer-sqrt", "num-traits", @@ -14519,7 +14565,7 @@ dependencies = [ [[package]] name = "sp-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "parity-scale-codec", "scale-info", @@ -14532,7 +14578,7 @@ dependencies = [ [[package]] name = "sp-block-builder" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "sp-api", "sp-inherents", @@ -14543,9 +14589,9 @@ dependencies = [ [[package]] name = "sp-blockchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ - "futures 0.3.28", + "futures 0.3.30", "log", "parity-scale-codec", "parking_lot 0.12.1", @@ -14561,10 +14607,10 @@ dependencies = [ [[package]] name = "sp-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "async-trait", - "futures 0.3.28", + "futures 0.3.30", "log", "sp-core", "sp-inherents", @@ -14576,7 +14622,7 @@ dependencies = [ [[package]] name = "sp-consensus-aura" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "async-trait", "parity-scale-codec", @@ -14593,7 +14639,7 @@ dependencies = [ [[package]] name = "sp-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "async-trait", "parity-scale-codec", @@ -14612,7 +14658,7 @@ dependencies = [ [[package]] name = "sp-consensus-beefy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "lazy_static", "parity-scale-codec", @@ -14631,7 +14677,7 @@ dependencies = [ [[package]] name = "sp-consensus-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "finality-grandpa", "log", @@ -14649,7 +14695,7 @@ dependencies = [ [[package]] name = "sp-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "parity-scale-codec", "scale-info", @@ -14661,19 +14707,18 @@ dependencies = [ [[package]] name = "sp-core" version = "21.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ - "array-bytes", - "arrayvec 0.7.4", + "array-bytes 6.1.0", "bandersnatch_vrfs", "bitflags 1.3.2", - "blake2", + "blake2 0.10.6", "bounded-collections", "bs58 0.5.0", "dyn-clonable", "ed25519-zebra 3.1.0", - "futures 0.3.28", - "hash-db 0.16.0", + "futures 0.3.30", + "hash-db", "hash256-std-hasher", "impl-serde", "lazy_static", @@ -14702,13 +14747,14 @@ dependencies = [ "thiserror", "tiny-bip39", "tracing", + "w3f-bls", "zeroize", ] [[package]] name = "sp-core-hashing" version = "9.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "blake2b_simd", "byteorder", @@ -14721,7 +14767,7 @@ dependencies = [ [[package]] name = "sp-core-hashing-proc-macro" version = "9.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "quote", "sp-core-hashing", @@ -14731,7 +14777,7 @@ dependencies = [ [[package]] name = "sp-database" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "kvdb", "parking_lot 0.12.1", @@ -14740,7 +14786,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "8.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "proc-macro2", "quote", @@ -14750,7 +14796,7 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.19.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "environmental", "parity-scale-codec", @@ -14761,7 +14807,7 @@ dependencies = [ [[package]] name = "sp-genesis-builder" version = "0.1.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "serde_json", "sp-api", @@ -14772,7 +14818,7 @@ dependencies = [ [[package]] name = "sp-inherents" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "async-trait", "impl-trait-for-tuples", @@ -14786,7 +14832,7 @@ dependencies = [ [[package]] name = "sp-io" version = "23.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "bytes", "ed25519-dalek", @@ -14810,7 +14856,7 @@ dependencies = [ [[package]] name = "sp-keyring" version = "24.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "lazy_static", "sp-core", @@ -14821,7 +14867,7 @@ dependencies = [ [[package]] name = "sp-keystore" version = "0.27.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "parity-scale-codec", "parking_lot 0.12.1", @@ -14833,7 +14879,7 @@ dependencies = [ [[package]] name = "sp-maybe-compressed-blob" version = "4.1.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "thiserror", "zstd 0.12.4", @@ -14842,7 +14888,7 @@ dependencies = [ [[package]] name = "sp-metadata-ir" version = "0.1.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-metadata", "parity-scale-codec", @@ -14850,10 +14896,22 @@ dependencies = [ "sp-std", ] +[[package]] +name = "sp-mixnet" +version = "0.1.0-dev" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" +dependencies = [ + "parity-scale-codec", + "scale-info", + "sp-api", + "sp-application-crypto", + "sp-std", +] + [[package]] name = "sp-mmr-primitives" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "ckb-merkle-mountain-range", "log", @@ -14871,7 +14929,7 @@ dependencies = [ [[package]] name = "sp-npos-elections" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "parity-scale-codec", "scale-info", @@ -14885,7 +14943,7 @@ dependencies = [ [[package]] name = "sp-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "sp-api", "sp-core", @@ -14895,7 +14953,7 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "8.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "backtrace", "lazy_static", @@ -14905,7 +14963,7 @@ dependencies = [ [[package]] name = "sp-rpc" version = "6.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "rustc-hash", "serde", @@ -14915,7 +14973,7 @@ dependencies = [ [[package]] name = "sp-runtime" version = "24.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "either", "hash256-std-hasher", @@ -14937,7 +14995,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "17.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "bytes", "impl-trait-for-tuples", @@ -14955,7 +15013,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "11.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "Inflector", "proc-macro-crate 1.3.1", @@ -14967,7 +15025,7 @@ dependencies = [ [[package]] name = "sp-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "parity-scale-codec", "scale-info", @@ -14982,7 +15040,7 @@ dependencies = [ [[package]] name = "sp-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", @@ -14996,9 +15054,9 @@ dependencies = [ [[package]] name = "sp-state-machine" version = "0.28.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ - "hash-db 0.16.0", + "hash-db", "log", "parity-scale-codec", "parking_lot 0.12.1", @@ -15017,7 +15075,7 @@ dependencies = [ [[package]] name = "sp-statement-store" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "aes-gcm 0.10.2", "curve25519-dalek 4.1.1", @@ -15041,12 +15099,12 @@ dependencies = [ [[package]] name = "sp-std" version = "8.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" [[package]] name = "sp-storage" version = "13.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "impl-serde", "parity-scale-codec", @@ -15059,7 +15117,7 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "async-trait", "parity-scale-codec", @@ -15072,7 +15130,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "10.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "parity-scale-codec", "sp-std", @@ -15084,7 +15142,7 @@ dependencies = [ [[package]] name = "sp-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "sp-api", "sp-runtime", @@ -15093,7 +15151,7 @@ dependencies = [ [[package]] name = "sp-transaction-storage-proof" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "async-trait", "parity-scale-codec", @@ -15108,16 +15166,17 @@ dependencies = [ [[package]] name = "sp-trie" version = "22.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "ahash 0.8.3", - "hash-db 0.16.0", + "hash-db", "hashbrown 0.13.2", "lazy_static", "memory-db", "nohash-hasher", "parity-scale-codec", "parking_lot 0.12.1", + "rand 0.8.5", "scale-info", "schnellru", "sp-core", @@ -15131,7 +15190,7 @@ dependencies = [ [[package]] name = "sp-version" version = "22.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "impl-serde", "parity-scale-codec", @@ -15148,7 +15207,7 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" version = "8.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "parity-scale-codec", "proc-macro2", @@ -15159,7 +15218,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "14.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "anyhow", "impl-trait-for-tuples", @@ -15172,7 +15231,7 @@ dependencies = [ [[package]] name = "sp-weights" version = "20.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "parity-scale-codec", "scale-info", @@ -15248,116 +15307,10 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" -[[package]] -name = "staging-kusama-runtime" -version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" -dependencies = [ - "binary-merkle-tree", - "bitvec", - "frame-benchmarking", - "frame-election-provider-support", - "frame-executive", - "frame-support", - "frame-system", - "frame-system-benchmarking", - "frame-system-rpc-runtime-api", - "frame-try-runtime", - "hex-literal", - "kusama-runtime-constants", - "log", - "pallet-authority-discovery", - "pallet-authorship", - "pallet-babe", - "pallet-bags-list", - "pallet-balances", - "pallet-beefy", - "pallet-beefy-mmr", - "pallet-bounties", - "pallet-child-bounties", - "pallet-collective", - "pallet-conviction-voting", - "pallet-democracy", - "pallet-election-provider-multi-phase", - "pallet-election-provider-support-benchmarking", - "pallet-elections-phragmen", - "pallet-fast-unstake", - "pallet-grandpa", - "pallet-identity", - "pallet-im-online", - "pallet-indices", - "pallet-membership", - "pallet-message-queue", - "pallet-mmr", - "pallet-multisig", - "pallet-nis", - "pallet-nomination-pools", - "pallet-nomination-pools-benchmarking", - "pallet-nomination-pools-runtime-api", - "pallet-offences", - "pallet-offences-benchmarking", - "pallet-preimage", - "pallet-proxy", - "pallet-ranked-collective", - "pallet-recovery", - "pallet-referenda", - "pallet-scheduler", - "pallet-session", - "pallet-session-benchmarking", - "pallet-society", - "pallet-staking", - "pallet-staking-runtime-api", - "pallet-state-trie-migration", - "pallet-timestamp", - "pallet-tips", - "pallet-transaction-payment", - "pallet-transaction-payment-rpc-runtime-api", - "pallet-treasury", - "pallet-utility", - "pallet-vesting", - "pallet-whitelist", - "pallet-xcm", - "pallet-xcm-benchmarks", - "parity-scale-codec", - "polkadot-primitives", - "polkadot-runtime-common", - "polkadot-runtime-parachains", - "rustc-hex", - "scale-info", - "serde", - "serde_derive", - "smallvec 1.11.0", - "sp-api", - "sp-application-crypto", - "sp-arithmetic", - "sp-authority-discovery", - "sp-block-builder", - "sp-consensus-babe", - "sp-consensus-beefy", - "sp-core", - "sp-inherents", - "sp-io", - "sp-mmr-primitives", - "sp-npos-elections", - "sp-offchain", - "sp-runtime", - "sp-session", - "sp-staking", - "sp-std", - "sp-storage", - "sp-transaction-pool", - "sp-version", - "staging-xcm", - "staging-xcm-builder", - "staging-xcm-executor", - "static_assertions", - "substrate-wasm-builder", -] - [[package]] name = "staging-xcm" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "bounded-collections", "derivative", @@ -15374,7 +15327,7 @@ dependencies = [ [[package]] name = "staging-xcm-builder" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-support", "frame-system", @@ -15396,7 +15349,7 @@ dependencies = [ [[package]] name = "staging-xcm-executor" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "environmental", "frame-benchmarking", @@ -15534,7 +15487,7 @@ dependencies = [ "md-5", "rand 0.8.5", "ring 0.16.20", - "subtle", + "subtle 2.4.1", "thiserror", "tokio", "url", @@ -15570,15 +15523,15 @@ dependencies = [ [[package]] name = "substrate-build-script-utils" version = "3.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" [[package]] name = "substrate-frame-rpc-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-system-rpc-runtime-api", - "futures 0.3.28", + "futures 0.3.30", "jsonrpsee", "log", "parity-scale-codec", @@ -15594,7 +15547,7 @@ dependencies = [ [[package]] name = "substrate-prometheus-endpoint" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "hyper", "log", @@ -15606,7 +15559,7 @@ dependencies = [ [[package]] name = "substrate-rpc-client" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "async-trait", "jsonrpsee", @@ -15619,7 +15572,7 @@ dependencies = [ [[package]] name = "substrate-state-trie-migration-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -15636,7 +15589,7 @@ dependencies = [ [[package]] name = "substrate-wasm-builder" version = "5.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "ansi_term", "build-helper", @@ -15660,6 +15613,12 @@ dependencies = [ "autocfg", ] +[[package]] +name = "subtle" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" + [[package]] name = "subtle" version = "2.4.1" @@ -16180,7 +16139,7 @@ dependencies = [ [[package]] name = "tracing-gum" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "coarsetime", "polkadot-node-jaeger", @@ -16192,7 +16151,7 @@ dependencies = [ [[package]] name = "tracing-gum-proc-macro" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "expander 2.0.0", "proc-macro-crate 1.3.1", @@ -16247,11 +16206,11 @@ dependencies = [ [[package]] name = "trie-db" -version = "0.27.1" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "767abe6ffed88a1889671a102c2861ae742726f52e0a5a425b92c9fbfa7e9c85" +checksum = "ff28e0f815c2fea41ebddf148e008b077d2faddb026c9555b29696114d602642" dependencies = [ - "hash-db 0.16.0", + "hash-db", "hashbrown 0.13.2", "log", "rustc-hex", @@ -16264,17 +16223,7 @@ version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4ed310ef5ab98f5fa467900ed906cb9232dd5376597e00fd4cba2a449d06c0b" dependencies = [ - "hash-db 0.16.0", -] - -[[package]] -name = "triehash" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1631b201eb031b563d2e85ca18ec8092508e262a3196ce9bd10a67ec87b9f5c" -dependencies = [ - "hash-db 0.15.2", - "rlp", + "hash-db", ] [[package]] @@ -16332,7 +16281,7 @@ checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" [[package]] name = "try-runtime-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "async-trait", "clap", @@ -16394,7 +16343,7 @@ checksum = "4712ee30d123ec7ae26d1e1b218395a16c87cdbaf4b3925d170d684af62ea5e8" dependencies = [ "async-trait", "base64 0.13.1", - "futures 0.3.28", + "futures 0.3.30", "log", "md-5", "rand 0.8.5", @@ -16498,7 +16447,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f214e8f697e925001e66ec2c6e37a4ef93f0f78c2eed7814394e10c62025b05" dependencies = [ "generic-array 0.14.7", - "subtle", + "subtle 2.4.1", ] [[package]] @@ -16508,7 +16457,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea" dependencies = [ "crypto-common", - "subtle", + "subtle 2.4.1", ] [[package]] @@ -16595,6 +16544,30 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" +[[package]] +name = "w3f-bls" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7335e4c132c28cc43caef6adb339789e599e39adbe78da0c4d547fad48cbc331" +dependencies = [ + "ark-bls12-377", + "ark-bls12-381", + "ark-ec", + "ark-ff", + "ark-serialize", + "ark-serialize-derive", + "arrayref", + "constcat", + "digest 0.10.7", + "rand 0.8.5", + "rand_chacha 0.3.1", + "rand_core 0.6.4", + "sha2 0.10.7", + "sha3", + "thiserror", + "zeroize", +] + [[package]] name = "waitgroup" version = "0.1.2" @@ -16727,9 +16700,9 @@ dependencies = [ [[package]] name = "wasm-opt" -version = "0.114.2" +version = "0.116.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "effbef3bd1dde18acb401f73e740a6f3d4a1bc651e9773bddc512fe4d8d68f67" +checksum = "fc942673e7684671f0c5708fc18993569d184265fd5223bb51fc8e5b9b6cfd52" dependencies = [ "anyhow", "libc", @@ -16743,9 +16716,9 @@ dependencies = [ [[package]] name = "wasm-opt-cxx-sys" -version = "0.114.2" +version = "0.116.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c09e24eb283919ace2ed5733bda4842a59ce4c8de110ef5c6d98859513d17047" +checksum = "8c57b28207aa724318fcec6575fe74803c23f6f266fce10cbc9f3f116762f12e" dependencies = [ "anyhow", "cxx", @@ -16755,9 +16728,9 @@ dependencies = [ [[package]] name = "wasm-opt-sys" -version = "0.114.2" +version = "0.116.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36f2f817bed2e8d65eb779fa37317e74de15585751f903c9118342d1970703a4" +checksum = "8a1cce564dc768dacbdb718fc29df2dba80bd21cb47d8f77ae7e3d95ceb98cbe" dependencies = [ "anyhow", "cc", @@ -16771,7 +16744,7 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be0ecb0db480561e9a7642b5d3e4187c128914e58aa84330b9493e3eb68c5e7f" dependencies = [ - "futures 0.3.28", + "futures 0.3.30", "js-sys", "parking_lot 0.11.2", "pin-utils", @@ -17158,7 +17131,7 @@ dependencies = [ "sha1", "sha2 0.10.7", "signature 1.6.4", - "subtle", + "subtle 2.4.1", "thiserror", "tokio", "webpki 0.21.4", @@ -17252,7 +17225,7 @@ dependencies = [ "rtcp", "rtp", "sha-1", - "subtle", + "subtle 2.4.1", "thiserror", "tokio", "webrtc-util", @@ -17282,7 +17255,7 @@ dependencies = [ [[package]] name = "westend-runtime" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "binary-merkle-tree", "bitvec", @@ -17296,6 +17269,7 @@ dependencies = [ "frame-try-runtime", "hex-literal", "log", + "pallet-asset-rate", "pallet-authority-discovery", "pallet-authorship", "pallet-babe", @@ -17304,6 +17278,7 @@ dependencies = [ "pallet-beefy", "pallet-beefy-mmr", "pallet-collective", + "pallet-conviction-voting", "pallet-democracy", "pallet-election-provider-multi-phase", "pallet-election-provider-support-benchmarking", @@ -17325,6 +17300,7 @@ dependencies = [ "pallet-preimage", "pallet-proxy", "pallet-recovery", + "pallet-referenda", "pallet-scheduler", "pallet-session", "pallet-session-benchmarking", @@ -17340,6 +17316,7 @@ dependencies = [ "pallet-treasury", "pallet-utility", "pallet-vesting", + "pallet-whitelist", "pallet-xcm", "pallet-xcm-benchmarks", "parity-scale-codec", @@ -17354,11 +17331,13 @@ dependencies = [ "smallvec 1.11.0", "sp-api", "sp-application-crypto", + "sp-arithmetic", "sp-authority-discovery", "sp-block-builder", "sp-consensus-babe", "sp-consensus-beefy", "sp-core", + "sp-genesis-builder", "sp-inherents", "sp-io", "sp-mmr-primitives", @@ -17381,7 +17360,7 @@ dependencies = [ [[package]] name = "westend-runtime-constants" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-support", "polkadot-primitives", @@ -17390,6 +17369,7 @@ dependencies = [ "sp-core", "sp-runtime", "sp-weights", + "staging-xcm", ] [[package]] @@ -17735,7 +17715,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7999f5f4217fe3818726b66257a4475f71e74ffd190776ad053fa159e50737f5" dependencies = [ "async_io_stream", - "futures 0.3.28", + "futures 0.3.30", "js-sys", "log", "pharos", @@ -17819,7 +17799,7 @@ dependencies = [ [[package]] name = "xcm-procedural" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "Inflector", "proc-macro2", @@ -17830,7 +17810,7 @@ dependencies = [ [[package]] name = "xcm-simulator" version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#c8d2251cafadc108ba2f1f8a3208dc547ff38901" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.3.0#401f8a3e9448db854f5605b679fa085b8f445039" dependencies = [ "frame-support", "parity-scale-codec", @@ -17923,7 +17903,7 @@ version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5d9ba232399af1783a58d8eb26f6b5006fbefe2dc9ef36bd283324792d03ea5" dependencies = [ - "futures 0.3.28", + "futures 0.3.30", "log", "nohash-hasher", "parking_lot 0.12.1", diff --git a/Cargo.toml b/Cargo.toml index 077e2a0c54..ef4a786f70 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,6 +35,8 @@ members = [ "vendor/runtime/ext", ] +resolver = "2" + exclude = ["vendor"] [profile.release] @@ -68,7 +70,7 @@ smallvec = "1.9.0" async-trait = "0.1.59" clap = { version = "4.2.5", features = ["derive"] } env_logger = "0.10.0" -futures = { version = "0.3.26" } +futures = { version = "0.3.30" } serde = { version = "1.0.151", default-features = false, features = ["derive", "alloc"] } serde_json = "1.0.92" tokio = { version = "1.24.2", features = ["macros", "sync"] } @@ -90,182 +92,183 @@ ethers = { version = "2.0.9", default_features = false } # Substrate # (wasm) -sp-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-core-hashing = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-io = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-std = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-tracing = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-block-builder = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-inherents = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-offchain = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-runtime-interface = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-session = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-transaction-pool = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-version = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-arithmetic = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-staking = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -sp-externalities = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } +sp-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +sp-core-hashing = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +sp-io = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +sp-std = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +sp-tracing = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +sp-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +sp-block-builder = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +sp-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +sp-inherents = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +sp-offchain = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +sp-runtime-interface = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +sp-session = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +sp-transaction-pool = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +sp-version = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +sp-arithmetic = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +sp-staking = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +sp-externalities = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +sp-genesis-builder = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } # (native) -sp-blockchain = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } -sp-consensus = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } -sp-keyring = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } -sp-keystore = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } -sp-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } -sp-trie = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } -sc-basic-authorship = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } -sc-chain-spec = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } -sc-client-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } -sc-client-db = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } -sc-consensus = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } -sc-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } -sc-consensus-babe = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } -sc-executor = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } -sc-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } -sc-network = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } -sc-network-sync = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } -sc-offchain = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } -sc-rpc = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } -sc-service = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } -sc-telemetry = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } -sc-tracing = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } -sc-transaction-pool = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } -sc-transaction-pool-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } -sc-utils = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } -substrate-prometheus-endpoint = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } -pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } -substrate-frame-rpc-system = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } -sc-cli = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } -try-runtime-cli = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } -frame-benchmarking-cli = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } +sp-blockchain = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } +sp-consensus = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } +sp-keyring = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } +sp-keystore = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } +sp-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } +sp-trie = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } +sc-basic-authorship = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } +sc-chain-spec = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } +sc-client-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } +sc-client-db = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } +sc-consensus = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } +sc-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } +sc-consensus-babe = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } +sc-executor = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } +sc-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } +sc-network = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } +sc-network-sync = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } +sc-offchain = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } +sc-rpc = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } +sc-service = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } +sc-telemetry = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } +sc-tracing = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } +sc-transaction-pool = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } +sc-transaction-pool-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } +sc-utils = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } +substrate-prometheus-endpoint = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } +pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } +substrate-frame-rpc-system = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } +sc-cli = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } +try-runtime-cli = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } +frame-benchmarking-cli = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } # Substrate pallets # (wasm) -pallet-assets = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -pallet-proxy = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -pallet-utility = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -frame-support = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -frame-system = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -frame-executive = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -pallet-aura = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -pallet-authorship = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -pallet-contracts = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -pallet-contracts-primitives = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -pallet-identity = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -pallet-multisig = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -pallet-insecure-randomness-collective-flip = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -pallet-session = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false, features = ["historical"] } -pallet-sudo = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -pallet-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -pallet-transaction-payment = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -pallet-vesting = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -frame-system-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -pallet-collective = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -frame-try-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -pallet-democracy = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -pallet-preimage = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -pallet-scheduler = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -pallet-treasury = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -pallet-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -pallet-message-queue = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } +pallet-assets = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +pallet-proxy = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +pallet-utility = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +frame-support = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +frame-system = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +frame-executive = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +pallet-aura = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +pallet-authorship = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +pallet-contracts = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +pallet-contracts-primitives = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +pallet-identity = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +pallet-multisig = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +pallet-insecure-randomness-collective-flip = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +pallet-session = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false, features = ["historical"] } +pallet-sudo = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +pallet-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +pallet-transaction-payment = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +pallet-vesting = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +frame-system-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +pallet-collective = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +frame-try-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +pallet-democracy = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +pallet-preimage = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +pallet-scheduler = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +pallet-treasury = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +pallet-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +pallet-message-queue = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } # EVM & Ethereum # (wasm) # To make it compatible with frontier -evm = { git = "https://github.com/rust-blockchain/evm", rev = "b7b82c7e1fc57b7449d6dfa6826600de37cc1e65", default-features = false } -evm-gasometer = { git = "https://github.com/rust-blockchain/evm", rev = "b7b82c7e1fc57b7449d6dfa6826600de37cc1e65", default-features = false } -evm-runtime = { git = "https://github.com/rust-blockchain/evm", rev = "b7b82c7e1fc57b7449d6dfa6826600de37cc1e65", default-features = false } +evm = { version = "0.41.1", default-features = false } +evm-gasometer = { version = "0.41.0", default-features = false } +evm-runtime = { version = "0.41.0", default-features = false } ethereum-types = { version = "0.14", default-features = false } -ethereum = { version = "0.14.0", default-features = false } +ethereum = { version = "0.15.0", default-features = false } # Frontier # (wasm) -fp-rpc = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.1.0", default-features = false } -fp-self-contained = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.1.0", default-features = false, features = ["serde"] } -pallet-ethereum = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.1.0", default-features = false, features = ["forbid-evm-reentrancy"] } -pallet-evm = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.1.0", default-features = false, features = ["forbid-evm-reentrancy"] } -pallet-evm-precompile-blake2 = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.1.0", default-features = false } -pallet-evm-precompile-bn128 = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.1.0", default-features = false } -pallet-evm-precompile-dispatch = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.1.0", default-features = false } -pallet-evm-precompile-ed25519 = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.1.0", default-features = false } -pallet-evm-precompile-modexp = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.1.0", default-features = false } -pallet-evm-precompile-sha3fips = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.1.0", default-features = false } -pallet-evm-precompile-simple = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.1.0", default-features = false } -pallet-base-fee = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.1.0", default-features = false } -pallet-evm-chain-id = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.1.0", default-features = false } -fp-evm = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.1.0", default-features = false } -fp-ethereum = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.1.0", default-features = false } +fp-rpc = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.3.0", default-features = false } +fp-self-contained = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.3.0", default-features = false, features = ["serde"] } +pallet-ethereum = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.3.0", default-features = false, features = ["forbid-evm-reentrancy"] } +pallet-evm = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.3.0", default-features = false, features = ["forbid-evm-reentrancy"] } +pallet-evm-precompile-blake2 = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.3.0", default-features = false } +pallet-evm-precompile-bn128 = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.3.0", default-features = false } +pallet-evm-precompile-dispatch = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.3.0", default-features = false } +pallet-evm-precompile-ed25519 = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.3.0", default-features = false } +pallet-evm-precompile-modexp = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.3.0", default-features = false } +pallet-evm-precompile-sha3fips = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.3.0", default-features = false } +pallet-evm-precompile-simple = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.3.0", default-features = false } +pallet-base-fee = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.3.0", default-features = false } +pallet-evm-chain-id = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.3.0", default-features = false } +fp-evm = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.3.0", default-features = false } +fp-ethereum = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.3.0", default-features = false } # (native) -fc-consensus = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.1.0" } -fc-db = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.1.0" } -fc-api = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.1.0" } -fc-mapping-sync = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.1.0" } -fc-rpc = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.1.0", features = ["rpc-binary-search-estimate", "txpool"] } -fc-rpc-core = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.1.0" } -fp-consensus = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.1.0" } -fp-storage = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.1.0" } -fc-storage = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.1.0" } +fc-consensus = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.3.0" } +fc-db = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.3.0" } +fc-api = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.3.0" } +fc-mapping-sync = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.3.0" } +fc-rpc = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.3.0", features = ["rpc-binary-search-estimate", "txpool"] } +fc-rpc-core = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.3.0" } +fp-consensus = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.3.0" } +fp-storage = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.3.0" } +fc-storage = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.3.0" } # Cumulus # (wasm) -cumulus-pallet-aura-ext = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -cumulus-pallet-dmp-queue = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -cumulus-pallet-parachain-system = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -cumulus-primitives-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -cumulus-primitives-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -cumulus-primitives-utility = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -parachain-info = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } +cumulus-pallet-aura-ext = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +cumulus-pallet-dmp-queue = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +cumulus-pallet-parachain-system = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +cumulus-primitives-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +cumulus-primitives-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +cumulus-primitives-utility = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +parachain-info = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } # (native) -cumulus-client-cli = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } -cumulus-client-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } -cumulus-client-consensus-common = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } -cumulus-client-consensus-relay-chain = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } -cumulus-client-network = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } -cumulus-client-service = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } -cumulus-primitives-parachain-inherent = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } -cumulus-relay-chain-inprocess-interface = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } -cumulus-relay-chain-interface = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } -cumulus-relay-chain-minimal-node = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } -cumulus-relay-chain-rpc-interface = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } -cumulus-test-relay-sproof-builder = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } +cumulus-client-cli = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } +cumulus-client-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } +cumulus-client-consensus-common = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } +cumulus-client-consensus-relay-chain = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } +cumulus-client-network = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } +cumulus-client-service = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } +cumulus-primitives-parachain-inherent = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } +cumulus-relay-chain-inprocess-interface = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } +cumulus-relay-chain-interface = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } +cumulus-relay-chain-minimal-node = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } +cumulus-relay-chain-rpc-interface = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } +cumulus-test-relay-sproof-builder = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } # Polkadot # (wasm) -polkadot-primitives = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -polkadot-runtime-common = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -polkadot-core-primitives = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -polkadot-parachain = { package = "polkadot-parachain-primitives", git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } +polkadot-primitives = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +polkadot-runtime-common = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +polkadot-core-primitives = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +polkadot-parachain = { package = "polkadot-parachain-primitives", git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } # XCM # (wasm) -cumulus-pallet-xcm = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -xcm = { package = "staging-xcm", git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -pallet-xcm = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -pallet-xcm-benchmarks = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -xcm-builder = { package = "staging-xcm-builder", git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -xcm-executor = { package = "staging-xcm-executor", git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } -xcm-simulator = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } +cumulus-pallet-xcm = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +xcm = { package = "staging-xcm", git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +pallet-xcm = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +pallet-xcm-benchmarks = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +xcm-builder = { package = "staging-xcm-builder", git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +xcm-executor = { package = "staging-xcm-executor", git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +xcm-simulator = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } # (native) -polkadot-cli = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } -polkadot-service = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } +polkadot-cli = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } +polkadot-service = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } # ORML # (wasm) -orml-xtokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", branch = "polkadot-v1.1.0", default-features = false } -orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-library", branch = "polkadot-v1.1.0", default-features = false } -orml-xcm-support = { git = "https://github.com/open-web3-stack/open-runtime-module-library", branch = "polkadot-v1.1.0", default-features = false } +orml-xtokens = { git = "https://github.com/AstarNetwork/open-runtime-module-library", branch = "polkadot-v1.3.0", default-features = false } +orml-traits = { git = "https://github.com/AstarNetwork/open-runtime-module-library", branch = "polkadot-v1.3.0", default-features = false } +orml-xcm-support = { git = "https://github.com/AstarNetwork/open-runtime-module-library", branch = "polkadot-v1.3.0", default-features = false } # Astar pallets & modules # (wasm) @@ -332,5 +335,5 @@ moonbeam-rpc-core-trace = { path = "./vendor/rpc-core/trace" } moonbeam-rpc-core-debug = { path = "./vendor/rpc-core/debug" } # Build deps -substrate-wasm-builder = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } -substrate-build-script-utils = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } +substrate-wasm-builder = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } +substrate-build-script-utils = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0" } diff --git a/bin/collator/src/local/service.rs b/bin/collator/src/local/service.rs index 8e16004f60..21ac4b061e 100644 --- a/bin/collator/src/local/service.rs +++ b/bin/collator/src/local/service.rs @@ -218,6 +218,7 @@ pub fn start_node( import_queue, block_announce_validator_builder: None, warp_sync_params: None, + block_relay: None, })?; if config.offchain_worker.enabled { @@ -531,6 +532,7 @@ pub fn start_node(config: Configuration) -> Result { import_queue, block_announce_validator_builder: None, warp_sync_params: None, + block_relay: None, })?; if config.offchain_worker.enabled { diff --git a/chain-extensions/pallet-assets/src/mock.rs b/chain-extensions/pallet-assets/src/mock.rs index c6fed3656e..8a21f6de68 100644 --- a/chain-extensions/pallet-assets/src/mock.rs +++ b/chain-extensions/pallet-assets/src/mock.rs @@ -137,6 +137,7 @@ impl pallet_balances::Config for Test { type WeightInfo = (); type RuntimeHoldReason = RuntimeHoldReason; type FreezeIdentifier = (); + type RuntimeFreezeReason = (); type MaxHolds = ConstU32<1>; type MaxFreezes = ConstU32<0>; } diff --git a/pallets/astar-xcm-benchmarks/src/mock.rs b/pallets/astar-xcm-benchmarks/src/mock.rs index 28a78e0028..8cc45dc4d4 100644 --- a/pallets/astar-xcm-benchmarks/src/mock.rs +++ b/pallets/astar-xcm-benchmarks/src/mock.rs @@ -147,6 +147,7 @@ impl pallet_balances::Config for Test { type WeightInfo = (); type RuntimeHoldReason = RuntimeHoldReason; type FreezeIdentifier = (); + type RuntimeFreezeReason = (); type MaxHolds = ConstU32<0>; type MaxFreezes = ConstU32<0>; } diff --git a/pallets/block-rewards-hybrid/src/mock.rs b/pallets/block-rewards-hybrid/src/mock.rs index e6535c8a7a..475d1c837e 100644 --- a/pallets/block-rewards-hybrid/src/mock.rs +++ b/pallets/block-rewards-hybrid/src/mock.rs @@ -98,6 +98,7 @@ impl pallet_balances::Config for TestRuntime { type AccountStore = System; type WeightInfo = (); type RuntimeHoldReason = RuntimeHoldReason; + type RuntimeFreezeReason = (); type FreezeIdentifier = (); type MaxHolds = ConstU32<0>; type MaxFreezes = ConstU32<0>; diff --git a/pallets/collator-selection/src/mock.rs b/pallets/collator-selection/src/mock.rs index ccc3af3254..374b4c8357 100644 --- a/pallets/collator-selection/src/mock.rs +++ b/pallets/collator-selection/src/mock.rs @@ -93,6 +93,7 @@ impl pallet_balances::Config for Test { type MaxReserves = MaxReserves; type ReserveIdentifier = [u8; 8]; type RuntimeHoldReason = RuntimeHoldReason; + type RuntimeFreezeReason = (); type FreezeIdentifier = (); type MaxHolds = ConstU32<0>; type MaxFreezes = ConstU32<0>; diff --git a/pallets/dapp-staking-v3/src/test/mock.rs b/pallets/dapp-staking-v3/src/test/mock.rs index 4f8746aadd..9ff157e4a2 100644 --- a/pallets/dapp-staking-v3/src/test/mock.rs +++ b/pallets/dapp-staking-v3/src/test/mock.rs @@ -99,6 +99,7 @@ impl pallet_balances::Config for Test { type AccountStore = System; type RuntimeHoldReason = RuntimeHoldReason; type FreezeIdentifier = RuntimeFreezeReason; + type RuntimeFreezeReason = RuntimeFreezeReason; type MaxHolds = ConstU32<0>; type MaxFreezes = ConstU32<1>; type WeightInfo = (); diff --git a/pallets/dapps-staking/src/mock.rs b/pallets/dapps-staking/src/mock.rs index 7f29b0aa57..3f325122cc 100644 --- a/pallets/dapps-staking/src/mock.rs +++ b/pallets/dapps-staking/src/mock.rs @@ -117,6 +117,7 @@ impl pallet_balances::Config for TestRuntime { type WeightInfo = (); type RuntimeHoldReason = RuntimeHoldReason; type FreezeIdentifier = (); + type RuntimeFreezeReason = (); type MaxHolds = ConstU32<0>; type MaxFreezes = ConstU32<0>; } diff --git a/pallets/dynamic-evm-base-fee/src/mock.rs b/pallets/dynamic-evm-base-fee/src/mock.rs index 5a26681695..dd5825b846 100644 --- a/pallets/dynamic-evm-base-fee/src/mock.rs +++ b/pallets/dynamic-evm-base-fee/src/mock.rs @@ -80,6 +80,7 @@ impl pallet_balances::Config for TestRuntime { type WeightInfo = (); type RuntimeHoldReason = RuntimeHoldReason; type FreezeIdentifier = (); + type RuntimeFreezeReason = (); type MaxHolds = ConstU32<0>; type MaxFreezes = ConstU32<0>; } diff --git a/pallets/ethereum-checked/src/mock.rs b/pallets/ethereum-checked/src/mock.rs index e2a9c9471c..e3d0510ec3 100644 --- a/pallets/ethereum-checked/src/mock.rs +++ b/pallets/ethereum-checked/src/mock.rs @@ -79,6 +79,7 @@ impl pallet_balances::Config for TestRuntime { type WeightInfo = (); type RuntimeHoldReason = RuntimeHoldReason; type FreezeIdentifier = (); + type RuntimeFreezeReason = (); type MaxHolds = ConstU32<0>; type MaxFreezes = ConstU32<0>; } @@ -180,6 +181,7 @@ impl pallet_evm::Config for TestRuntime { type Timestamp = Timestamp; type WeightInfo = pallet_evm::weights::SubstrateWeight; type GasLimitPovSizeRatio = ConstU64<4>; + type SuicideQuickClearLimit = ConstU32<0>; } parameter_types! { diff --git a/pallets/inflation/src/mock.rs b/pallets/inflation/src/mock.rs index 5a8893b023..6fbdb56195 100644 --- a/pallets/inflation/src/mock.rs +++ b/pallets/inflation/src/mock.rs @@ -96,6 +96,7 @@ impl pallet_balances::Config for Test { type WeightInfo = (); type RuntimeHoldReason = RuntimeHoldReason; type FreezeIdentifier = (); + type RuntimeFreezeReason = (); type MaxHolds = ConstU32<0>; type MaxFreezes = ConstU32<0>; } diff --git a/pallets/static-price-provider/src/mock.rs b/pallets/static-price-provider/src/mock.rs index 00b102e573..e9af03e23a 100644 --- a/pallets/static-price-provider/src/mock.rs +++ b/pallets/static-price-provider/src/mock.rs @@ -79,6 +79,7 @@ impl pallet_balances::Config for Test { type WeightInfo = (); type RuntimeHoldReason = RuntimeHoldReason; type FreezeIdentifier = (); + type RuntimeFreezeReason = (); type MaxHolds = ConstU32<0>; type MaxFreezes = ConstU32<0>; } diff --git a/pallets/unified-accounts/src/mock.rs b/pallets/unified-accounts/src/mock.rs index 67933e5180..08d99898f6 100644 --- a/pallets/unified-accounts/src/mock.rs +++ b/pallets/unified-accounts/src/mock.rs @@ -79,6 +79,7 @@ impl pallet_balances::Config for TestRuntime { type WeightInfo = (); type RuntimeHoldReason = RuntimeHoldReason; type FreezeIdentifier = (); + type RuntimeFreezeReason = (); type MaxHolds = ConstU32<0>; type MaxFreezes = ConstU32<0>; } @@ -134,6 +135,7 @@ impl pallet_evm::Config for TestRuntime { type Timestamp = Timestamp; type WeightInfo = pallet_evm::weights::SubstrateWeight; type GasLimitPovSizeRatio = ConstU64<4>; + type SuicideQuickClearLimit = ConstU32<0>; } parameter_types! { diff --git a/pallets/xc-asset-config/src/mock.rs b/pallets/xc-asset-config/src/mock.rs index aa6acb45e8..aa13c0c2d8 100644 --- a/pallets/xc-asset-config/src/mock.rs +++ b/pallets/xc-asset-config/src/mock.rs @@ -90,6 +90,7 @@ impl pallet_balances::Config for Test { type AccountStore = System; type WeightInfo = (); type RuntimeHoldReason = RuntimeHoldReason; + type RuntimeFreezeReason = (); type FreezeIdentifier = (); type MaxHolds = ConstU32<0>; type MaxFreezes = ConstU32<0>; diff --git a/pallets/xvm/src/mock.rs b/pallets/xvm/src/mock.rs index 9f548e1675..8060c7f2c8 100644 --- a/pallets/xvm/src/mock.rs +++ b/pallets/xvm/src/mock.rs @@ -81,6 +81,7 @@ impl pallet_balances::Config for TestRuntime { type WeightInfo = (); type RuntimeHoldReason = RuntimeHoldReason; type FreezeIdentifier = (); + type RuntimeFreezeReason = (); type MaxHolds = ConstU32<0>; type MaxFreezes = ConstU32<0>; } diff --git a/precompiles/assets-erc20/src/mock.rs b/precompiles/assets-erc20/src/mock.rs index d4838cf8f0..4ec556c695 100644 --- a/precompiles/assets-erc20/src/mock.rs +++ b/precompiles/assets-erc20/src/mock.rs @@ -145,6 +145,7 @@ impl pallet_balances::Config for Runtime { type WeightInfo = (); type RuntimeHoldReason = (); type FreezeIdentifier = (); + type RuntimeFreezeReason = (); type MaxHolds = ConstU32<0>; type MaxFreezes = ConstU32<0>; } @@ -178,6 +179,7 @@ impl pallet_evm::Config for Runtime { type OnCreate = (); type WeightInfo = (); type GasLimitPovSizeRatio = ConstU64<4>; + type SuicideQuickClearLimit = ConstU32<0>; } // These parameters dont matter much as this will only be called by root with the forced arguments diff --git a/precompiles/dapp-staking-v3/src/test/mock.rs b/precompiles/dapp-staking-v3/src/test/mock.rs index b15dfc5147..5232828181 100644 --- a/precompiles/dapp-staking-v3/src/test/mock.rs +++ b/precompiles/dapp-staking-v3/src/test/mock.rs @@ -114,6 +114,7 @@ impl pallet_balances::Config for Test { type AccountStore = System; type RuntimeHoldReason = RuntimeHoldReason; type FreezeIdentifier = RuntimeFreezeReason; + type RuntimeFreezeReason = RuntimeFreezeReason; type MaxHolds = ConstU32<0>; type MaxFreezes = ConstU32<1>; type WeightInfo = (); @@ -173,6 +174,7 @@ impl pallet_evm::Config for Test { type OnCreate = (); type WeightInfo = (); type GasLimitPovSizeRatio = ConstU64<4>; + type SuicideQuickClearLimit = ConstU32<0>; } impl pallet_timestamp::Config for Test { diff --git a/precompiles/dapps-staking/src/mock.rs b/precompiles/dapps-staking/src/mock.rs index bde91984a6..52f70ce542 100644 --- a/precompiles/dapps-staking/src/mock.rs +++ b/precompiles/dapps-staking/src/mock.rs @@ -194,6 +194,7 @@ impl pallet_balances::Config for TestRuntime { type WeightInfo = (); type RuntimeHoldReason = RuntimeHoldReason; type FreezeIdentifier = (); + type RuntimeFreezeReason = (); type MaxHolds = (); type MaxFreezes = (); } @@ -253,6 +254,7 @@ impl pallet_evm::Config for TestRuntime { type OnCreate = (); type WeightInfo = (); type GasLimitPovSizeRatio = ConstU64<4>; + type SuicideQuickClearLimit = ConstU32<0>; } parameter_types! { diff --git a/precompiles/dispatch-lockdrop/src/mock.rs b/precompiles/dispatch-lockdrop/src/mock.rs index a5d45dae4a..4eef2f7529 100644 --- a/precompiles/dispatch-lockdrop/src/mock.rs +++ b/precompiles/dispatch-lockdrop/src/mock.rs @@ -133,6 +133,7 @@ impl pallet_balances::Config for TestRuntime { type WeightInfo = (); type RuntimeHoldReason = RuntimeHoldReason; type FreezeIdentifier = (); + type RuntimeFreezeReason = (); type MaxHolds = ConstU32<0>; type MaxFreezes = ConstU32<0>; } @@ -193,6 +194,7 @@ impl pallet_evm::Config for TestRuntime { type OnCreate = (); type WeightInfo = (); type GasLimitPovSizeRatio = ConstU64<4>; + type SuicideQuickClearLimit = ConstU32<0>; } impl pallet_utility::Config for TestRuntime { diff --git a/precompiles/sr25519/src/mock.rs b/precompiles/sr25519/src/mock.rs index b29c9e8801..f26efbdce2 100644 --- a/precompiles/sr25519/src/mock.rs +++ b/precompiles/sr25519/src/mock.rs @@ -185,6 +185,7 @@ impl pallet_balances::Config for Runtime { type WeightInfo = (); type RuntimeHoldReason = RuntimeHoldReason; type FreezeIdentifier = (); + type RuntimeFreezeReason = (); type MaxHolds = ConstU32<0>; type MaxFreezes = ConstU32<0>; } @@ -218,6 +219,7 @@ impl pallet_evm::Config for Runtime { type FindAuthor = (); type WeightInfo = (); type GasLimitPovSizeRatio = ConstU64<4>; + type SuicideQuickClearLimit = ConstU32<0>; } // Configure a mock runtime to test the pallet. diff --git a/precompiles/substrate-ecdsa/src/mock.rs b/precompiles/substrate-ecdsa/src/mock.rs index 962d0dc2b0..3b46cbc131 100644 --- a/precompiles/substrate-ecdsa/src/mock.rs +++ b/precompiles/substrate-ecdsa/src/mock.rs @@ -185,6 +185,7 @@ impl pallet_balances::Config for Runtime { type WeightInfo = (); type RuntimeHoldReason = RuntimeHoldReason; type FreezeIdentifier = (); + type RuntimeFreezeReason = (); type MaxHolds = ConstU32<0>; type MaxFreezes = ConstU32<0>; } @@ -218,6 +219,7 @@ impl pallet_evm::Config for Runtime { type OnCreate = (); type WeightInfo = (); type GasLimitPovSizeRatio = ConstU64<4>; + type SuicideQuickClearLimit = ConstU32<0>; } // Configure a mock runtime to test the pallet. diff --git a/precompiles/unified-accounts/src/mock.rs b/precompiles/unified-accounts/src/mock.rs index 5c40431754..21dbcc32ae 100644 --- a/precompiles/unified-accounts/src/mock.rs +++ b/precompiles/unified-accounts/src/mock.rs @@ -180,6 +180,7 @@ impl pallet_balances::Config for TestRuntime { type AccountStore = System; type WeightInfo = (); type RuntimeHoldReason = RuntimeHoldReason; + type RuntimeFreezeReason = (); type FreezeIdentifier = (); type MaxHolds = ConstU32<0>; type MaxFreezes = ConstU32<0>; @@ -225,6 +226,7 @@ impl pallet_evm::Config for TestRuntime { type OnCreate = (); type WeightInfo = (); type GasLimitPovSizeRatio = ConstU64<4>; + type SuicideQuickClearLimit = ConstU32<0>; } parameter_types! { diff --git a/precompiles/utils/macro/src/derive_codec.rs b/precompiles/utils/macro/src/derive_codec.rs index f4ef4770e6..f1bcdf1f02 100644 --- a/precompiles/utils/macro/src/derive_codec.rs +++ b/precompiles/utils/macro/src/derive_codec.rs @@ -34,15 +34,15 @@ pub fn main(input: TokenStream) -> TokenStream { } = parse_macro_input!(input as DeriveInput); let syn::Data::Struct(syn::DataStruct { - fields: syn::Fields::Named(fields), - .. - }) = data - else { - return quote_spanned! { ident.span() => - compile_error!("Codec can only be derived for structs with named fields"); - } - .into(); - }; + fields: syn::Fields::Named(fields), + .. + }) = data + else { + return quote_spanned! { ident.span() => + compile_error!("Codec can only be derived for structs with named fields"); + } + .into(); + }; let fields = fields.named; if fields.is_empty() { diff --git a/precompiles/utils/src/evm/handle.rs b/precompiles/utils/src/evm/handle.rs index 9f68718cfd..1ed775348f 100644 --- a/precompiles/utils/src/evm/handle.rs +++ b/precompiles/utils/src/evm/handle.rs @@ -60,7 +60,7 @@ impl PrecompileHandleExt for T { ) -> Result<(), evm::ExitError> { self.record_cost(crate::prelude::RuntimeHelper::::db_read_gas_cost())?; // TODO: record ref time when precompile will be benchmarked - self.record_external_cost(None, Some(data_max_encoded_len as u64)) + self.record_external_cost(None, Some(data_max_encoded_len as u64), None) } /// Record cost of a log manualy. @@ -190,6 +190,7 @@ mod tests { &mut self, _ref_time: Option, _proof_size: Option, + _storage_growth: Option, ) -> Result<(), fp_evm::ExitError> { Ok(()) } diff --git a/precompiles/utils/src/precompile_set.rs b/precompiles/utils/src/precompile_set.rs index 836eeb9815..57afdf42cb 100644 --- a/precompiles/utils/src/precompile_set.rs +++ b/precompiles/utils/src/precompile_set.rs @@ -476,8 +476,10 @@ impl<'a, H: PrecompileHandle> PrecompileHandle for RestrictiveHandle<'a, H> { &mut self, ref_time: Option, proof_size: Option, + storage_growth: Option, ) -> Result<(), ExitError> { - self.handle.record_external_cost(ref_time, proof_size) + self.handle + .record_external_cost(ref_time, proof_size, storage_growth) } fn refund_external_cost(&mut self, ref_time: Option, proof_size: Option) { diff --git a/precompiles/utils/src/substrate.rs b/precompiles/utils/src/substrate.rs index 5873afaaac..bc5eda2c34 100644 --- a/precompiles/utils/src/substrate.rs +++ b/precompiles/utils/src/substrate.rs @@ -77,7 +77,7 @@ where // Make sure there is enough remaining weight // TODO: record ref time when precompile will be benchmarked - handle.record_external_cost(None, Some(weight.proof_size())) + handle.record_external_cost(None, Some(weight.proof_size()), None) } #[inline(always)] diff --git a/precompiles/utils/src/testing/handle.rs b/precompiles/utils/src/testing/handle.rs index cf34dda88c..f03e7cee6e 100644 --- a/precompiles/utils/src/testing/handle.rs +++ b/precompiles/utils/src/testing/handle.rs @@ -208,6 +208,7 @@ impl PrecompileHandle for MockHandle { &mut self, _ref_time: Option, _proof_size: Option, + _storage_growth: Option, ) -> Result<(), ExitError> { Ok(()) } diff --git a/precompiles/utils/tests-external/lib.rs b/precompiles/utils/tests-external/lib.rs index 04c20bc0bb..e030c7a630 100644 --- a/precompiles/utils/tests-external/lib.rs +++ b/precompiles/utils/tests-external/lib.rs @@ -97,6 +97,7 @@ impl pallet_balances::Config for Runtime { type ReserveIdentifier = [u8; 4]; type RuntimeHoldReason = RuntimeHoldReason; type FreezeIdentifier = (); + type RuntimeFreezeReason = (); type MaxLocks = (); type MaxReserves = (); type MaxHolds = (); @@ -162,6 +163,7 @@ impl PrecompileHandle for MockPrecompileHandle { &mut self, _ref_time: Option, _proof_size: Option, + _storage_growth: Option, ) -> Result<(), fp_evm::ExitError> { Ok(()) } @@ -219,7 +221,6 @@ parameter_types! { let block_gas_limit = BlockGasLimit::get().min(u64::MAX.into()).low_u64(); block_gas_limit.saturating_div(MAX_POV_SIZE) }; - pub SuicideQuickClearLimit: u32 = 0; } impl pallet_evm::Config for Runtime { @@ -241,7 +242,7 @@ impl pallet_evm::Config for Runtime { type OnCreate = (); type FindAuthor = (); type GasLimitPovSizeRatio = GasLimitPovSizeRatio; - type SuicideQuickClearLimit = SuicideQuickClearLimit; + type SuicideQuickClearLimit = ConstU32<0>; type Timestamp = Timestamp; type WeightInfo = pallet_evm::weights::SubstrateWeight; } diff --git a/precompiles/xcm/src/mock.rs b/precompiles/xcm/src/mock.rs index 2a3ce2e908..d94382482d 100644 --- a/precompiles/xcm/src/mock.rs +++ b/precompiles/xcm/src/mock.rs @@ -295,6 +295,7 @@ impl pallet_balances::Config for Runtime { type WeightInfo = (); type RuntimeHoldReason = RuntimeHoldReason; type FreezeIdentifier = (); + type RuntimeFreezeReason = (); type MaxHolds = (); type MaxFreezes = (); } @@ -384,6 +385,7 @@ impl pallet_evm::Config for Runtime { type OnCreate = (); type WeightInfo = (); type GasLimitPovSizeRatio = ConstU64<4>; + type SuicideQuickClearLimit = ConstU32<0>; type Timestamp = Timestamp; } diff --git a/precompiles/xvm/src/lib.rs b/precompiles/xvm/src/lib.rs index 658b68fb7d..95ff0bf577 100644 --- a/precompiles/xvm/src/lib.rs +++ b/precompiles/xvm/src/lib.rs @@ -98,8 +98,11 @@ where Err(f) => f.used_weight, }; handle.record_cost(R::GasWeightMapping::weight_to_gas(used_weight))?; - handle - .record_external_cost(Some(used_weight.ref_time()), Some(used_weight.proof_size()))?; + handle.record_external_cost( + Some(used_weight.ref_time()), + Some(used_weight.proof_size()), + None, + )?; match call_result { Ok(success) => { diff --git a/precompiles/xvm/src/mock.rs b/precompiles/xvm/src/mock.rs index 5d23e088d5..8792f1743f 100644 --- a/precompiles/xvm/src/mock.rs +++ b/precompiles/xvm/src/mock.rs @@ -203,6 +203,7 @@ impl pallet_balances::Config for Runtime { type WeightInfo = (); type RuntimeHoldReason = RuntimeHoldReason; type FreezeIdentifier = (); + type RuntimeFreezeReason = (); type MaxHolds = ConstU32<0>; type MaxFreezes = ConstU32<0>; } @@ -236,6 +237,7 @@ impl pallet_evm::Config for Runtime { type OnCreate = (); type WeightInfo = (); type GasLimitPovSizeRatio = ConstU64<4>; + type SuicideQuickClearLimit = ConstU32<0>; } thread_local! { diff --git a/primitives/src/migrations/contract_v14.rs b/primitives/src/migrations/contract_v14.rs index 4c5516fa22..ca0f6fe5cd 100644 --- a/primitives/src/migrations/contract_v14.rs +++ b/primitives/src/migrations/contract_v14.rs @@ -162,13 +162,13 @@ where if remaining > Zero::zero() { log::warn!( - target: LOG_TARGET, - "Code owner's account 0x{:?} for code {:?} has some non-unreservable deposit {:?} from a total of {:?} that will remain in reserved.", - HexDisplay::from(&code_info.owner.encode()), - hash, - remaining, - code_info.deposit - ); + target: LOG_TARGET, + "Code owner's account 0x{:?} for code {:?} has some non-unreservable deposit {:?} from a total of {:?} that will remain in reserved.", + HexDisplay::from(&code_info.owner.encode()), + hash, + remaining, + code_info.deposit + ); } let unreserved = code_info.deposit.saturating_sub(remaining); diff --git a/runtime/astar/Cargo.toml b/runtime/astar/Cargo.toml index e0d3cce606..cadf42a3c6 100644 --- a/runtime/astar/Cargo.toml +++ b/runtime/astar/Cargo.toml @@ -24,6 +24,7 @@ sp-arithmetic = { workspace = true } sp-block-builder = { workspace = true } sp-consensus-aura = { workspace = true } sp-core = { workspace = true } +sp-genesis-builder = { workspace = true } sp-inherents = { workspace = true } sp-io = { workspace = true } sp-offchain = { workspace = true } @@ -128,6 +129,7 @@ substrate-wasm-builder = { workspace = true, optional = true } default = ["std"] std = [ "parity-scale-codec/std", + "sp-genesis-builder/std", "fp-rpc/std", "fp-self-contained/std", "sp-std/std", @@ -233,6 +235,7 @@ runtime-benchmarks = [ "astar-primitives/runtime-benchmarks", "pallet-assets/runtime-benchmarks", "pallet-dynamic-evm-base-fee/runtime-benchmarks", + "cumulus-primitives-utility/runtime-benchmarks", ] try-runtime = [ "fp-self-contained/try-runtime", diff --git a/runtime/astar/src/lib.rs b/runtime/astar/src/lib.rs index d9a36dbe2d..c6b204e1fb 100644 --- a/runtime/astar/src/lib.rs +++ b/runtime/astar/src/lib.rs @@ -26,6 +26,7 @@ use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; use frame_support::{ construct_runtime, dispatch::DispatchClass, + genesis_builder_helper::{build_config, create_default_config}, parameter_types, traits::{ AsEnsureOriginWithArg, ConstBool, ConstU32, Contains, Currency, FindAuthor, Get, Imbalance, @@ -47,6 +48,7 @@ use frame_system::{ use pallet_ethereum::PostLogContent; use pallet_evm::{FeeCalculator, GasWeightMapping, Runner}; use pallet_evm_precompile_assets_erc20::AddressToAssetId; +use pallet_identity::simple::IdentityInfo; use pallet_transaction_payment::{ FeeDetails, Multiplier, RuntimeDispatchInfo, TargetedFeeAdjustment, }; @@ -293,6 +295,7 @@ impl pallet_identity::Config for Runtime { type SubAccountDeposit = SubAccountDeposit; type MaxSubAccounts = MaxSubAccounts; type MaxAdditionalFields = MaxAdditionalFields; + type IdentityInformation = IdentityInfo; type MaxRegistrars = MaxRegistrars; type Slashed = (); type ForceOrigin = EnsureRoot<::AccountId>; @@ -552,6 +555,7 @@ impl pallet_balances::Config for Runtime { type AccountStore = frame_system::Pallet; type WeightInfo = pallet_balances::weights::SubstrateWeight; type RuntimeHoldReason = RuntimeHoldReason; + type RuntimeFreezeReason = RuntimeFreezeReason; type FreezeIdentifier = RuntimeFreezeReason; type MaxHolds = ConstU32<1>; type MaxFreezes = ConstU32<1>; @@ -858,6 +862,7 @@ impl pallet_evm::Config for Runtime { type OnCreate = (); type FindAuthor = FindAuthorTruncated; type GasLimitPovSizeRatio = GasLimitPovSizeRatio; + type SuicideQuickClearLimit = ConstU32<0>; type WeightInfo = pallet_evm::weights::SubstrateWeight; } @@ -1693,6 +1698,17 @@ impl_runtime_apis! { } } + + impl sp_genesis_builder::GenesisBuilder for Runtime { + fn create_default_config() -> Vec { + create_default_config::() + } + + fn build_config(config: Vec) -> sp_genesis_builder::Result { + build_config::(config) + } + } + #[cfg(feature = "runtime-benchmarks")] impl frame_benchmarking::Benchmark for Runtime { fn benchmark_metadata(extra: bool) -> ( diff --git a/runtime/local/Cargo.toml b/runtime/local/Cargo.toml index e902778398..1f42a18fae 100644 --- a/runtime/local/Cargo.toml +++ b/runtime/local/Cargo.toml @@ -52,6 +52,7 @@ sp-arithmetic = { workspace = true } sp-block-builder = { workspace = true } sp-consensus-aura = { workspace = true } sp-core = { workspace = true } +sp-genesis-builder = { workspace = true } sp-inherents = { workspace = true } sp-io = { workspace = true } sp-offchain = { workspace = true } @@ -136,6 +137,7 @@ std = [ "pallet-dynamic-evm-base-fee/std", "pallet-ethereum/std", "pallet-evm/std", + "sp-genesis-builder/std", "pallet-evm-precompile-blake2/std", "pallet-evm-precompile-simple/std", "pallet-evm-precompile-bn128/std", diff --git a/runtime/local/src/lib.rs b/runtime/local/src/lib.rs index c5deca8141..ec10836809 100644 --- a/runtime/local/src/lib.rs +++ b/runtime/local/src/lib.rs @@ -25,10 +25,13 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); use frame_support::{ - construct_runtime, parameter_types, + construct_runtime, + genesis_builder_helper::{build_config, create_default_config}, + parameter_types, traits::{ - AsEnsureOriginWithArg, ConstU128, ConstU32, ConstU64, Currency, EitherOfDiverse, - EqualPrivilegeOnly, FindAuthor, Get, InstanceFilter, Nothing, OnFinalize, WithdrawReasons, + fungible::HoldConsideration, AsEnsureOriginWithArg, ConstU128, ConstU32, ConstU64, + Currency, EitherOfDiverse, EqualPrivilegeOnly, FindAuthor, Get, InstanceFilter, + LinearStoragePrice, Nothing, OnFinalize, WithdrawReasons, }, weights::{ constants::{ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_REF_TIME_PER_SECOND}, @@ -53,7 +56,7 @@ use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, traits::{ AccountIdConversion, AccountIdLookup, BlakeTwo256, Block as BlockT, ConvertInto, - DispatchInfoOf, Dispatchable, NumberFor, PostDispatchInfoOf, UniqueSaturatedInto, + DispatchInfoOf, Dispatchable, NumberFor, PostDispatchInfoOf, UniqueSaturatedInto, IdentityLookup, }, transaction_validity::{TransactionSource, TransactionValidity, TransactionValidityError}, ApplyExtrinsicResult, FixedPointNumber, Perbill, Permill, Perquintill, RuntimeDebug, @@ -302,6 +305,7 @@ impl pallet_balances::Config for Runtime { type AccountStore = System; type WeightInfo = weights::pallet_balances::SubstrateWeight; type RuntimeHoldReason = RuntimeHoldReason; + type RuntimeFreezeReason = RuntimeFreezeReason; type FreezeIdentifier = RuntimeFreezeReason; type MaxHolds = ConstU32<1>; type MaxFreezes = ConstU32<1>; @@ -690,6 +694,7 @@ impl pallet_evm::Config for Runtime { type OnCreate = (); type FindAuthor = FindAuthorTruncated; type GasLimitPovSizeRatio = GasLimitPovSizeRatio; + type SuicideQuickClearLimit = ConstU32<0>; type WeightInfo = pallet_evm::weights::SubstrateWeight; } @@ -725,6 +730,7 @@ impl pallet_scheduler::Config for Runtime { parameter_types! { pub const PreimageBaseDeposit: Balance = deposit(1, 0); pub const PreimageByteDeposit: Balance = deposit(0, 1); + pub const PreimageHoldReason: RuntimeHoldReason = RuntimeHoldReason::Preimage(pallet_preimage::HoldReason::Preimage); } impl pallet_preimage::Config for Runtime { @@ -732,8 +738,12 @@ impl pallet_preimage::Config for Runtime { type RuntimeEvent = RuntimeEvent; type Currency = Balances; type ManagerOrigin = EnsureRoot; - type BaseDeposit = PreimageBaseDeposit; - type ByteDeposit = PreimageByteDeposit; + type Consideration = HoldConsideration< + AccountId, + Balances, + PreimageHoldReason, + LinearStoragePrice, + >; } parameter_types! { @@ -804,6 +814,14 @@ impl pallet_treasury::Config for Runtime { type MaxApprovals = ConstU32<100>; type WeightInfo = pallet_treasury::weights::SubstrateWeight; type SpendOrigin = frame_support::traits::NeverEnsureOrigin; + type AssetKind = (); + type Beneficiary = AccountId; + type BeneficiaryLookup = IdentityLookup; + type Paymaster = (); + type BalanceConverter = (); + type PayoutPeriod = (); + #[cfg(feature = "runtime-benchmarks")] + type BenchmarkHelper = (); } parameter_types! { @@ -1763,6 +1781,17 @@ impl_runtime_apis! { } } + + impl sp_genesis_builder::GenesisBuilder for Runtime { + fn create_default_config() -> Vec { + create_default_config::() + } + + fn build_config(config: Vec) -> sp_genesis_builder::Result { + build_config::(config) + } + } + #[cfg(feature = "runtime-benchmarks")] impl frame_benchmarking::Benchmark for Runtime { fn benchmark_metadata(extra: bool) -> ( diff --git a/runtime/shibuya/Cargo.toml b/runtime/shibuya/Cargo.toml index b79a95e063..96cbd73f40 100644 --- a/runtime/shibuya/Cargo.toml +++ b/runtime/shibuya/Cargo.toml @@ -24,6 +24,7 @@ sp-arithmetic = { workspace = true } sp-block-builder = { workspace = true } sp-consensus-aura = { workspace = true } sp-core = { workspace = true } +sp-genesis-builder = { workspace = true } sp-inherents = { workspace = true } sp-io = { workspace = true } sp-offchain = { workspace = true } @@ -153,6 +154,7 @@ std = [ "sp-std/std", "sp-api/std", "sp-core/std", + "sp-genesis-builder/std", "sp-consensus-aura/std", "pallet-dapp-staking-migration/std", "sp-io/std", @@ -275,6 +277,7 @@ runtime-benchmarks = [ "astar-primitives/runtime-benchmarks", "pallet-assets/runtime-benchmarks", "pallet-dynamic-evm-base-fee/runtime-benchmarks", + "cumulus-primitives-utility/runtime-benchmarks", ] try-runtime = [ "fp-self-contained/try-runtime", diff --git a/runtime/shibuya/src/lib.rs b/runtime/shibuya/src/lib.rs index 41e1b079c4..a5f881a6b2 100644 --- a/runtime/shibuya/src/lib.rs +++ b/runtime/shibuya/src/lib.rs @@ -26,11 +26,12 @@ use cumulus_pallet_parachain_system::AnyRelayNumber; use frame_support::{ construct_runtime, dispatch::DispatchClass, + genesis_builder_helper::{build_config, create_default_config}, parameter_types, traits::{ - AsEnsureOriginWithArg, ConstU32, Contains, Currency, EitherOfDiverse, EqualPrivilegeOnly, - FindAuthor, Get, Imbalance, InstanceFilter, Nothing, OnFinalize, OnUnbalanced, - WithdrawReasons, + fungible::HoldConsideration, AsEnsureOriginWithArg, ConstU32, Contains, Currency, + EitherOfDiverse, EqualPrivilegeOnly, FindAuthor, Get, Imbalance, InstanceFilter, + LinearStoragePrice, Nothing, OnFinalize, OnUnbalanced, WithdrawReasons, }, weights::{ constants::{ @@ -47,6 +48,7 @@ use frame_system::{ }; use pallet_ethereum::PostLogContent; use pallet_evm::{FeeCalculator, GasWeightMapping, Runner}; +use pallet_identity::simple::IdentityInfo; use pallet_transaction_payment::{ FeeDetails, Multiplier, RuntimeDispatchInfo, TargetedFeeAdjustment, }; @@ -59,7 +61,7 @@ use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, traits::{ AccountIdConversion, AccountIdLookup, BlakeTwo256, Block as BlockT, ConvertInto, - DispatchInfoOf, Dispatchable, OpaqueKeys, PostDispatchInfoOf, UniqueSaturatedInto, + DispatchInfoOf, Dispatchable, OpaqueKeys, PostDispatchInfoOf, UniqueSaturatedInto, IdentityLookup, }, transaction_validity::{TransactionSource, TransactionValidity, TransactionValidityError}, ApplyExtrinsicResult, FixedPointNumber, Perbill, Permill, Perquintill, RuntimeDebug, @@ -325,6 +327,7 @@ impl pallet_identity::Config for Runtime { type SubAccountDeposit = SubAccountDeposit; type MaxSubAccounts = MaxSubAccounts; type MaxAdditionalFields = MaxAdditionalFields; + type IdentityInformation = IdentityInfo; type MaxRegistrars = MaxRegistrars; type Slashed = Treasury; type ForceOrigin = EnsureRoot; @@ -369,6 +372,7 @@ impl pallet_scheduler::Config for Runtime { parameter_types! { pub const PreimageBaseDeposit: Balance = deposit(1, 0); pub const PreimageByteDeposit: Balance = deposit(0, 1); + pub const PreimageHoldReason: RuntimeHoldReason = RuntimeHoldReason::Preimage(pallet_preimage::HoldReason::Preimage); } impl pallet_preimage::Config for Runtime { @@ -376,8 +380,12 @@ impl pallet_preimage::Config for Runtime { type RuntimeEvent = RuntimeEvent; type Currency = Balances; type ManagerOrigin = EnsureRoot; - type BaseDeposit = PreimageBaseDeposit; - type ByteDeposit = PreimageByteDeposit; + type Consideration = HoldConsideration< + AccountId, + Balances, + PreimageHoldReason, + LinearStoragePrice, + >; } impl pallet_static_price_provider::Config for Runtime { @@ -909,6 +917,7 @@ impl pallet_evm::Config for Runtime { type OnCreate = (); type FindAuthor = FindAuthorTruncated; type GasLimitPovSizeRatio = GasLimitPovSizeRatio; + type SuicideQuickClearLimit = ConstU32<0>; type WeightInfo = pallet_evm::weights::SubstrateWeight; } @@ -992,6 +1001,14 @@ impl pallet_treasury::Config for Runtime { type MaxApprovals = ConstU32<100>; type WeightInfo = pallet_treasury::weights::SubstrateWeight; type SpendOrigin = frame_support::traits::NeverEnsureOrigin; + type AssetKind = (); + type Beneficiary = AccountId; + type BeneficiaryLookup = IdentityLookup; + type Paymaster = (); + type BalanceConverter = (); + type PayoutPeriod = (); + #[cfg(feature = "runtime-benchmarks")] + type BenchmarkHelper = (); } parameter_types! { @@ -1942,6 +1959,17 @@ impl_runtime_apis! { } } + + impl sp_genesis_builder::GenesisBuilder for Runtime { + fn create_default_config() -> Vec { + create_default_config::() + } + + fn build_config(config: Vec) -> sp_genesis_builder::Result { + build_config::(config) + } + } + #[cfg(feature = "runtime-benchmarks")] impl frame_benchmarking::Benchmark for Runtime { fn benchmark_metadata(extra: bool) -> ( diff --git a/runtime/shiden/Cargo.toml b/runtime/shiden/Cargo.toml index 556b7b60f4..fb1d0edf2f 100644 --- a/runtime/shiden/Cargo.toml +++ b/runtime/shiden/Cargo.toml @@ -25,6 +25,7 @@ sp-arithmetic = { workspace = true } sp-block-builder = { workspace = true } sp-consensus-aura = { workspace = true } sp-core = { workspace = true } +sp-genesis-builder = { workspace = true } sp-inherents = { workspace = true } sp-io = { workspace = true } sp-offchain = { workspace = true } @@ -163,6 +164,7 @@ std = [ "pallet-evm-precompile-blake2/std", "pallet-evm-precompile-simple/std", "pallet-evm-precompile-bn128/std", + "sp-genesis-builder/std", "pallet-evm-precompile-dispatch/std", "pallet-evm-precompile-ed25519/std", "pallet-evm-precompile-modexp/std", @@ -237,6 +239,7 @@ runtime-benchmarks = [ "astar-primitives/runtime-benchmarks", "pallet-assets/runtime-benchmarks", "pallet-dynamic-evm-base-fee/runtime-benchmarks", + "cumulus-primitives-utility/runtime-benchmarks", ] try-runtime = [ "astar-primitives/try-runtime", diff --git a/runtime/shiden/src/lib.rs b/runtime/shiden/src/lib.rs index 9ea9064569..df806f140f 100644 --- a/runtime/shiden/src/lib.rs +++ b/runtime/shiden/src/lib.rs @@ -26,6 +26,7 @@ use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; use frame_support::{ construct_runtime, dispatch::DispatchClass, + genesis_builder_helper::{build_config, create_default_config}, parameter_types, traits::{ AsEnsureOriginWithArg, ConstU32, Contains, Currency, FindAuthor, Get, Imbalance, @@ -46,6 +47,7 @@ use frame_system::{ }; use pallet_ethereum::PostLogContent; use pallet_evm::{FeeCalculator, GasWeightMapping, Runner}; +use pallet_identity::simple::IdentityInfo; use pallet_transaction_payment::{ FeeDetails, Multiplier, RuntimeDispatchInfo, TargetedFeeAdjustment, }; @@ -297,6 +299,7 @@ impl pallet_identity::Config for Runtime { type SubAccountDeposit = SubAccountDeposit; type MaxSubAccounts = MaxSubAccounts; type MaxAdditionalFields = MaxAdditionalFields; + type IdentityInformation = IdentityInfo; type MaxRegistrars = MaxRegistrars; type Slashed = (); type ForceOrigin = EnsureRoot<::AccountId>; @@ -560,6 +563,7 @@ impl pallet_balances::Config for Runtime { type AccountStore = frame_system::Pallet; type WeightInfo = pallet_balances::weights::SubstrateWeight; type RuntimeHoldReason = RuntimeHoldReason; + type RuntimeFreezeReason = RuntimeFreezeReason; type FreezeIdentifier = RuntimeFreezeReason; type MaxHolds = ConstU32<1>; type MaxFreezes = ConstU32<1>; @@ -854,6 +858,7 @@ impl pallet_evm::Config for Runtime { type OnCreate = (); type FindAuthor = FindAuthorTruncated; type GasLimitPovSizeRatio = GasLimitPovSizeRatio; + type SuicideQuickClearLimit = ConstU32<0>; type WeightInfo = pallet_evm::weights::SubstrateWeight; } @@ -1719,6 +1724,16 @@ impl_runtime_apis! { } } + impl sp_genesis_builder::GenesisBuilder for Runtime { + fn create_default_config() -> Vec { + create_default_config::() + } + + fn build_config(config: Vec) -> sp_genesis_builder::Result { + build_config::(config) + } + } + #[cfg(feature = "runtime-benchmarks")] impl frame_benchmarking::Benchmark for Runtime { fn benchmark_metadata(extra: bool) -> ( diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 18ab590fbd..e850fef942 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] -channel = "1.70.0" +channel = "1.73.0" components = ["rustfmt", "clippy"] targets = ["wasm32-unknown-unknown"] profile = "minimal" diff --git a/tests/xcm-simulator/src/mocks/parachain.rs b/tests/xcm-simulator/src/mocks/parachain.rs index 3833a38849..5cb53da0fd 100644 --- a/tests/xcm-simulator/src/mocks/parachain.rs +++ b/tests/xcm-simulator/src/mocks/parachain.rs @@ -121,6 +121,7 @@ impl pallet_balances::Config for Runtime { type MaxReserves = MaxReserves; type ReserveIdentifier = [u8; 8]; type RuntimeHoldReason = RuntimeHoldReason; + type RuntimeFreezeReason = RuntimeFreezeReason; type FreezeIdentifier = RuntimeFreezeReason; type MaxHolds = ConstU32<1>; type MaxFreezes = ConstU32<0>; diff --git a/tests/xcm-simulator/src/mocks/relay_chain.rs b/tests/xcm-simulator/src/mocks/relay_chain.rs index 63b31d39dc..28918c7abf 100644 --- a/tests/xcm-simulator/src/mocks/relay_chain.rs +++ b/tests/xcm-simulator/src/mocks/relay_chain.rs @@ -91,6 +91,7 @@ impl pallet_balances::Config for Runtime { type ReserveIdentifier = [u8; 8]; type RuntimeHoldReason = RuntimeHoldReason; type FreezeIdentifier = (); + type RuntimeFreezeReason = (); type MaxHolds = ConstU32<0>; type MaxFreezes = ConstU32<0>; } diff --git a/vendor/rpc/debug/src/lib.rs b/vendor/rpc/debug/src/lib.rs index de67bb0398..86ad8f43dd 100644 --- a/vendor/rpc/debug/src/lib.rs +++ b/vendor/rpc/debug/src/lib.rs @@ -319,8 +319,8 @@ where let blockchain = backend.blockchain(); // Get the header I want to work with. let Ok(hash) = client.expect_block_hash_from_id(&reference_id) else { - return Err(internal_err("Block header not found")) - }; + return Err(internal_err("Block header not found")); + }; let header = match client.header(hash) { Ok(Some(h)) => h, _ => return Err(internal_err("Block header not found")), @@ -453,8 +453,8 @@ where let blockchain = backend.blockchain(); // Get the header I want to work with. let Ok(reference_hash) = client.expect_block_hash_from_id(&reference_id) else { - return Err(internal_err("Block header not found")) - }; + return Err(internal_err("Block header not found")); + }; let header = match client.header(reference_hash) { Ok(Some(h)) => h, _ => return Err(internal_err("Block header not found")), From be03b5535668071826ea0fe47fb74cfd0f48ec6a Mon Sep 17 00:00:00 2001 From: Dino Pacandi Date: Wed, 27 Mar 2024 08:22:25 +0100 Subject: [PATCH 02/19] Further modifications --- Cargo.lock | 31 -- Cargo.toml | 1 - bin/collator/src/local/chain_spec.rs | 40 +- .../src/parachain/chain_spec/shibuya.rs | 17 +- pallets/block-rewards-hybrid/Cargo.toml | 53 --- .../block-rewards-hybrid/src/benchmarking.rs | 61 --- pallets/block-rewards-hybrid/src/lib.rs | 395 ---------------- pallets/block-rewards-hybrid/src/mock.rs | 198 -------- pallets/block-rewards-hybrid/src/tests.rs | 445 ------------------ pallets/block-rewards-hybrid/src/weights.rs | 82 ---- runtime/astar/src/xcm_config.rs | 4 +- runtime/local/Cargo.toml | 22 - runtime/local/src/lib.rs | 263 +---------- runtime/local/src/precompiles.rs | 2 +- runtime/shibuya/Cargo.toml | 14 - runtime/shibuya/src/lib.rs | 197 +------- runtime/shibuya/src/xcm_config.rs | 4 +- runtime/shiden/src/xcm_config.rs | 4 +- 18 files changed, 33 insertions(+), 1800 deletions(-) delete mode 100644 pallets/block-rewards-hybrid/Cargo.toml delete mode 100644 pallets/block-rewards-hybrid/src/benchmarking.rs delete mode 100644 pallets/block-rewards-hybrid/src/lib.rs delete mode 100644 pallets/block-rewards-hybrid/src/mock.rs delete mode 100644 pallets/block-rewards-hybrid/src/tests.rs delete mode 100644 pallets/block-rewards-hybrid/src/weights.rs diff --git a/Cargo.lock b/Cargo.lock index b63b70bec4..4cc74bbad7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6710,17 +6710,12 @@ dependencies = [ "pallet-assets", "pallet-aura", "pallet-balances", - "pallet-block-rewards-hybrid", "pallet-chain-extension-assets", "pallet-chain-extension-unified-accounts", "pallet-chain-extension-xvm", - "pallet-collective", "pallet-contracts", "pallet-contracts-primitives", - "pallet-dapp-staking-migration", "pallet-dapp-staking-v3", - "pallet-dapps-staking", - "pallet-democracy", "pallet-dynamic-evm-base-fee", "pallet-ethereum", "pallet-ethereum-checked", @@ -6750,7 +6745,6 @@ dependencies = [ "pallet-timestamp", "pallet-transaction-payment", "pallet-transaction-payment-rpc-runtime-api", - "pallet-treasury", "pallet-unified-accounts", "pallet-utility", "pallet-vesting", @@ -8176,27 +8170,6 @@ dependencies = [ "sp-std", ] -[[package]] -name = "pallet-block-rewards-hybrid" -version = "0.1.0" -dependencies = [ - "astar-primitives", - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "pallet-balances", - "pallet-timestamp", - "parity-scale-codec", - "scale-info", - "serde", - "sp-arithmetic", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", -] - [[package]] name = "pallet-bounties" version = "4.0.0-dev" @@ -14007,12 +13980,9 @@ dependencies = [ "pallet-chain-extension-unified-accounts", "pallet-chain-extension-xvm", "pallet-collator-selection", - "pallet-collective", "pallet-contracts", "pallet-contracts-primitives", - "pallet-dapp-staking-migration", "pallet-dapp-staking-v3", - "pallet-democracy", "pallet-dynamic-evm-base-fee", "pallet-ethereum", "pallet-ethereum-checked", @@ -14046,7 +14016,6 @@ dependencies = [ "pallet-timestamp", "pallet-transaction-payment", "pallet-transaction-payment-rpc-runtime-api", - "pallet-treasury", "pallet-unified-accounts", "pallet-utility", "pallet-vesting", diff --git a/Cargo.toml b/Cargo.toml index ef4a786f70..04a3840696 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -272,7 +272,6 @@ orml-xcm-support = { git = "https://github.com/AstarNetwork/open-runtime-module- # Astar pallets & modules # (wasm) -pallet-block-rewards-hybrid = { path = "./pallets/block-rewards-hybrid", default-features = false } pallet-collator-selection = { path = "./pallets/collator-selection", default-features = false } pallet-dapps-staking = { path = "./pallets/dapps-staking", default-features = false } pallet-dapp-staking-v3 = { path = "./pallets/dapp-staking-v3", default-features = false } diff --git a/bin/collator/src/local/chain_spec.rs b/bin/collator/src/local/chain_spec.rs index b224142c0e..9609d39027 100644 --- a/bin/collator/src/local/chain_spec.rs +++ b/bin/collator/src/local/chain_spec.rs @@ -19,17 +19,15 @@ //! Chain specifications. use local_runtime::{ - wasm_binary_unwrap, AccountId, AuraConfig, AuraId, BalancesConfig, BlockRewardConfig, - CouncilConfig, DappStakingConfig, DemocracyConfig, EVMConfig, GrandpaConfig, GrandpaId, - InflationConfig, InflationParameters, Precompiles, RewardDistributionConfig, - RuntimeGenesisConfig, Signature, SudoConfig, SystemConfig, TechnicalCommitteeConfig, - TierThreshold, TreasuryConfig, VestingConfig, AST, + wasm_binary_unwrap, AccountId, AuraConfig, AuraId, BalancesConfig, DappStakingConfig, + EVMConfig, GrandpaConfig, GrandpaId, InflationConfig, InflationParameters, Precompiles, + RuntimeGenesisConfig, Signature, SudoConfig, SystemConfig, TierThreshold, VestingConfig, AST, }; use sc_service::ChainType; use sp_core::{crypto::Ss58Codec, sr25519, Pair, Public}; use sp_runtime::{ traits::{IdentifyAccount, Verify}, - Perbill, Permill, + Permill, }; type AccountPublic = ::Signer; @@ -117,18 +115,6 @@ fn testnet_genesis( .map(|k| (k, 1_000_000_000 * AST)) .collect(), }, - block_reward: BlockRewardConfig { - // Make sure sum is 100 - reward_config: RewardDistributionConfig { - treasury_percent: Perbill::from_percent(25), - base_staker_percent: Perbill::from_percent(30), - dapps_percent: Perbill::from_percent(20), - collators_percent: Perbill::zero(), - adjustable_percent: Perbill::from_percent(25), - ideal_dapps_staking_tvl: Perbill::from_percent(40), - }, - ..Default::default() - }, vesting: VestingConfig { vesting: vec![] }, aura: AuraConfig { authorities: initial_authorities.iter().map(|x| (x.0.clone())).collect(), @@ -164,24 +150,6 @@ fn testnet_genesis( }, assets: Default::default(), transaction_payment: Default::default(), - council: CouncilConfig { - members: vec![ - get_account_id_from_seed::("Alice"), - get_account_id_from_seed::("Bob"), - get_account_id_from_seed::("Charlie"), - ], - phantom: Default::default(), - }, - technical_committee: TechnicalCommitteeConfig { - members: vec![ - get_account_id_from_seed::("Alice"), - get_account_id_from_seed::("Bob"), - get_account_id_from_seed::("Charlie"), - ], - phantom: Default::default(), - }, - democracy: DemocracyConfig::default(), - treasury: TreasuryConfig::default(), dapp_staking: DappStakingConfig { reward_portion: vec![ Permill::from_percent(40), diff --git a/bin/collator/src/parachain/chain_spec/shibuya.rs b/bin/collator/src/parachain/chain_spec/shibuya.rs index 98ab8eec34..4e7d9ec445 100644 --- a/bin/collator/src/parachain/chain_spec/shibuya.rs +++ b/bin/collator/src/parachain/chain_spec/shibuya.rs @@ -22,10 +22,9 @@ use cumulus_primitives_core::ParaId; use sc_service::ChainType; use shibuya_runtime::{ wasm_binary_unwrap, AccountId, AuraConfig, AuraId, Balance, BalancesConfig, - CollatorSelectionConfig, CouncilConfig, DappStakingConfig, DemocracyConfig, EVMChainIdConfig, - EVMConfig, InflationConfig, InflationParameters, ParachainInfoConfig, Precompiles, - RuntimeGenesisConfig, SessionConfig, SessionKeys, Signature, SudoConfig, SystemConfig, - TechnicalCommitteeConfig, TierThreshold, TreasuryConfig, VestingConfig, SBY, + CollatorSelectionConfig, DappStakingConfig, EVMChainIdConfig, EVMConfig, InflationConfig, + InflationParameters, ParachainInfoConfig, Precompiles, RuntimeGenesisConfig, SessionConfig, + SessionKeys, Signature, SudoConfig, SystemConfig, TierThreshold, VestingConfig, SBY, }; use sp_core::{sr25519, Pair, Public}; @@ -161,16 +160,6 @@ fn make_genesis( assets: Default::default(), parachain_system: Default::default(), transaction_payment: Default::default(), - council: CouncilConfig { - members: vec![], - phantom: Default::default(), - }, - technical_committee: TechnicalCommitteeConfig { - members: vec![], - phantom: Default::default(), - }, - democracy: DemocracyConfig::default(), - treasury: TreasuryConfig::default(), dapp_staking: DappStakingConfig { reward_portion: vec![ Permill::from_percent(40), diff --git a/pallets/block-rewards-hybrid/Cargo.toml b/pallets/block-rewards-hybrid/Cargo.toml deleted file mode 100644 index 1c654578e8..0000000000 --- a/pallets/block-rewards-hybrid/Cargo.toml +++ /dev/null @@ -1,53 +0,0 @@ -[package] -name = "pallet-block-rewards-hybrid" -version = "0.1.0" -license = "Apache-2.0" -description = "FRAME pallet for managing block reward issuance & distribution" -authors.workspace = true -edition.workspace = true -homepage.workspace = true -repository.workspace = true - -[dependencies] -log = { workspace = true } -parity-scale-codec = { workspace = true } -serde = { workspace = true } - -astar-primitives = { workspace = true } -frame-benchmarking = { workspace = true, optional = true } -frame-support = { workspace = true } -frame-system = { workspace = true } -scale-info = { workspace = true } -sp-arithmetic = { workspace = true } -sp-runtime = { workspace = true } -sp-std = { workspace = true } - -[dev-dependencies] -pallet-balances = { workspace = true } -pallet-timestamp = { workspace = true } -sp-core = { workspace = true } -sp-io = { workspace = true } - -[features] -default = ["std"] -std = [ - "parity-scale-codec/std", - "sp-core/std", - "scale-info/std", - "sp-std/std", - "serde/std", - "log/std", - "frame-support/std", - "frame-system/std", - "pallet-timestamp/std", - "pallet-balances/std", - "astar-primitives/std", -] -runtime-benchmarks = [ - "frame-benchmarking", - "frame-support/runtime-benchmarks", - "frame-system/runtime-benchmarks", - "sp-runtime/runtime-benchmarks", - "astar-primitives/runtime-benchmarks", -] -try-runtime = ["frame-support/try-runtime"] diff --git a/pallets/block-rewards-hybrid/src/benchmarking.rs b/pallets/block-rewards-hybrid/src/benchmarking.rs deleted file mode 100644 index c8e7366b0e..0000000000 --- a/pallets/block-rewards-hybrid/src/benchmarking.rs +++ /dev/null @@ -1,61 +0,0 @@ -// This file is part of Astar. - -// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later - -// Astar 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. - -// Astar 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 Astar. If not, see . - -#![cfg(feature = "runtime-benchmarks")] - -use super::*; - -use frame_benchmarking::v2::*; -use frame_system::{Pallet as System, RawOrigin}; - -/// Assert that the last event equals the provided one. -fn assert_last_event(generic_event: ::RuntimeEvent) { - System::::assert_last_event(generic_event.into()); -} - -#[benchmarks(where T: Config)] -mod benchmarks { - use super::*; - - #[benchmark] - fn set_configuration() { - let reward_config = RewardDistributionConfig::default(); - assert!(reward_config.is_consistent()); - - #[extrinsic_call] - _(RawOrigin::Root, reward_config.clone()); - - assert_last_event::(Event::::DistributionConfigurationChanged(reward_config).into()); - } - - impl_benchmark_test_suite!( - Pallet, - crate::benchmarking::tests::new_test_ext(), - crate::mock::TestRuntime, - ); -} - -#[cfg(test)] -mod tests { - use crate::mock; - use sp_io::TestExternalities; - - pub fn new_test_ext() -> TestExternalities { - mock::ExternalityBuilder::build() - } -} diff --git a/pallets/block-rewards-hybrid/src/lib.rs b/pallets/block-rewards-hybrid/src/lib.rs deleted file mode 100644 index e7859fcdad..0000000000 --- a/pallets/block-rewards-hybrid/src/lib.rs +++ /dev/null @@ -1,395 +0,0 @@ -// This file is part of Astar. - -// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later - -// Astar 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. - -// Astar 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 Astar. If not, see . - -//! # Block Reward Distribution Pallet -//! -//! - [`Config`] -//! -//! ## Overview -//! -//! Pallet that implements block reward issuance and distribution mechanics. -//! -//! After issuing a block reward, pallet will calculate how to distribute the reward -//! based on configurable parameters and chain state. -//! -//! Major on-chain factors which can influence reward distribution are total issuance and total value locked by dapps staking. -//! -//! ## Interface -//! -//! ### Dispatchable Function -//! -//! - `set_configuration` - used to change reward distribution configuration parameters -//! -//! ### Other -//! -//! - `on_timestamp_set` - This pallet implements the `OnTimestampSet` trait to handle block production. -//! Note: We assume that it's impossible to set timestamp two times in a block. -//! -//! ## Usage -//! -//! 1. Pallet should be set as a handler of `OnTimestampSet`. -//! 2. `DappsStakingTvlProvider` handler should be defined as an impl of `TvlProvider` trait. For example: -//! ```nocompile -//! pub struct TvlProvider(); -//! impl Get for TvlProvider { -//! fn tvl() -> Balance { -//! DappsStaking::total_locked_value() -//! } -//! } -//! ``` -//! 3. `BeneficiaryPayout` handler should be defined as an impl of `BeneficiaryPayout` trait. For example: -//! ```nocompile -//! pub struct BeneficiaryPayout(); -//! impl BeneficiaryPayout> for BeneficiaryPayout { -//! -//! fn treasury(reward: NegativeImbalanceOf) { -//! Balances::resolve_creating(&TREASURY_POT.into_account(), reward); -//! } -//! -//! fn collators(reward: NegativeImbalanceOf) { -//! Balances::resolve_creating(&COLLATOR_POT.into_account(), reward); -//! } -//! -//! fn dapps_staking(stakers: NegativeImbalanceOf, dapps: NegativeImbalanceOf) { -//! DappsStaking::rewards(stakers, dapps); -//! } -//! } -//! ``` -//! 4. Set `MaxBlockRewardAmount` to the max reward amount distributed per block. -//! Max amount will be reached if `ideal_dapps_staking_tvl` is reached. -//! - -#![cfg_attr(not(feature = "std"), no_std)] - -pub use pallet::*; - -use astar_primitives::Balance; -use frame_support::pallet_prelude::*; -use frame_support::traits::{Currency, Get, Imbalance, OnTimestampSet}; -use frame_system::{ensure_root, pallet_prelude::*}; -use serde::{Deserialize, Serialize}; -use sp_runtime::{ - traits::{CheckedAdd, Zero}, - Perbill, -}; -use sp_std::vec; - -#[cfg(any(feature = "runtime-benchmarks"))] -pub mod benchmarking; -#[cfg(test)] -mod mock; -#[cfg(test)] -mod tests; - -pub mod weights; -pub use weights::WeightInfo; - -#[frame_support::pallet] -pub mod pallet { - - use super::*; - - #[pallet::pallet] - pub struct Pallet(PhantomData); - - // Negative imbalance type of this pallet. - pub(crate) type NegativeImbalanceOf = <::Currency as Currency< - ::AccountId, - >>::NegativeImbalance; - - #[pallet::config] - pub trait Config: frame_system::Config { - /// The currency trait. - type Currency: Currency; - - /// Provides information about how much value is locked by dapps staking - type DappsStakingTvlProvider: Get; - - /// Used to payout rewards - type BeneficiaryPayout: BeneficiaryPayout>; - - /// The amount of issuance for each block. - #[pallet::constant] - type MaxBlockRewardAmount: Get; - - /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; - - /// Weight information for extrinsics in this pallet. - type WeightInfo: WeightInfo; - } - - #[pallet::storage] - #[pallet::getter(fn reward_config)] - pub type RewardDistributionConfigStorage = - StorageValue<_, RewardDistributionConfig, ValueQuery>; - - #[pallet::event] - #[pallet::generate_deposit(pub(crate) fn deposit_event)] - pub enum Event { - /// Distribution configuration has been updated. - DistributionConfigurationChanged(RewardDistributionConfig), - } - - #[pallet::error] - pub enum Error { - /// Sum of all rations must be one whole (100%) - InvalidDistributionConfiguration, - } - - #[pallet::genesis_config] - #[derive(frame_support::DefaultNoBound)] - pub struct GenesisConfig { - pub reward_config: RewardDistributionConfig, - #[serde(skip)] - pub _config: sp_std::marker::PhantomData, - } - - #[pallet::genesis_build] - impl BuildGenesisConfig for GenesisConfig { - fn build(&self) { - assert!(self.reward_config.is_consistent()); - RewardDistributionConfigStorage::::put(self.reward_config.clone()) - } - } - - #[pallet::call] - impl Pallet { - /// Sets the reward distribution configuration parameters which will be used from next block reward distribution. - /// - /// It is mandatory that all components of configuration sum up to one whole (**100%**), - /// otherwise an error `InvalidDistributionConfiguration` will be raised. - /// - /// - `reward_distro_params` - reward distribution params - /// - /// Emits `DistributionConfigurationChanged` with config embeded into event itself. - /// - #[pallet::call_index(0)] - #[pallet::weight(T::WeightInfo::set_configuration())] - pub fn set_configuration( - origin: OriginFor, - reward_distro_params: RewardDistributionConfig, - ) -> DispatchResultWithPostInfo { - ensure_root(origin)?; - - ensure!( - reward_distro_params.is_consistent(), - Error::::InvalidDistributionConfiguration - ); - RewardDistributionConfigStorage::::put(reward_distro_params.clone()); - - Self::deposit_event(Event::::DistributionConfigurationChanged( - reward_distro_params, - )); - - Ok(().into()) - } - } - - impl OnTimestampSet for Pallet { - fn on_timestamp_set(_moment: Moment) { - let rewards = Self::calculate_rewards(T::MaxBlockRewardAmount::get()); - let inflation = T::Currency::issue(rewards.sum()); - Self::distribute_rewards(inflation, rewards); - } - } - - impl Pallet { - /// Calculates the amount of rewards for each beneficiary - /// - /// # Arguments - /// * `block_reward` - the block reward amount - /// - fn calculate_rewards(block_reward: Balance) -> Rewards { - let distro_params = Self::reward_config(); - - // Pre-calculate balance which will be deposited for each beneficiary - let base_staker_balance = distro_params.base_staker_percent * block_reward; - let dapps_reward = distro_params.dapps_percent * block_reward; - let collators_reward = distro_params.collators_percent * block_reward; - let treasury_reward = distro_params.treasury_percent * block_reward; - - // This is part is the TVL dependant staker reward - let adjustable_balance = distro_params.adjustable_percent * block_reward; - - // Calculate total staker reward - let adjustable_staker_part = if distro_params.ideal_dapps_staking_tvl.is_zero() { - adjustable_balance - } else { - Self::tvl_percentage() / distro_params.ideal_dapps_staking_tvl * adjustable_balance - }; - - let staker_reward = base_staker_balance.saturating_add(adjustable_staker_part); - - Rewards { - treasury_reward, - staker_reward, - dapps_reward, - collators_reward, - } - } - - /// Distribute reward between beneficiaries. - /// - /// # Arguments - /// * `inflation` - inflation issued for this block - /// * `rewards` - rewards that will be split and distributed - /// - fn distribute_rewards(inflation: NegativeImbalanceOf, rewards: Rewards) { - // Prepare imbalances - let (dapps_imbalance, remainder) = inflation.split(rewards.dapps_reward); - let (stakers_imbalance, remainder) = remainder.split(rewards.staker_reward); - let (collator_imbalance, remainder) = remainder.split(rewards.collators_reward); - let (treasury_imbalance, _) = remainder.split(rewards.treasury_reward); - - // Payout beneficiaries - T::BeneficiaryPayout::treasury(treasury_imbalance); - T::BeneficiaryPayout::collators(collator_imbalance); - T::BeneficiaryPayout::dapps_staking(stakers_imbalance, dapps_imbalance); - } - - /// Provides TVL as percentage of total issuance - fn tvl_percentage() -> Perbill { - let total_issuance = T::Currency::total_issuance(); - if total_issuance.is_zero() { - log::warn!("Total issuance is zero - this should be impossible."); - Zero::zero() - } else { - Perbill::from_rational(T::DappsStakingTvlProvider::get(), total_issuance) - } - } - } -} - -/// List of configuration parameters used to calculate reward distribution portions for all the beneficiaries. -/// -/// Note that if `ideal_dapps_staking_tvl` is set to `Zero`, entire `adjustable_percent` goes to the stakers. -/// -#[derive( - PartialEq, - Eq, - Clone, - Encode, - Decode, - RuntimeDebug, - TypeInfo, - MaxEncodedLen, - Serialize, - Deserialize, -)] -pub struct RewardDistributionConfig { - /// Base percentage of reward that goes to treasury - #[codec(compact)] - pub treasury_percent: Perbill, - /// Base percentage of reward that goes to stakers - #[codec(compact)] - pub base_staker_percent: Perbill, - /// Percentage of rewards that goes to dApps - #[codec(compact)] - pub dapps_percent: Perbill, - /// Percentage of reward that goes to collators - #[codec(compact)] - pub collators_percent: Perbill, - /// Adjustable reward percentage that either goes to treasury or to stakers - #[codec(compact)] - pub adjustable_percent: Perbill, - /// Target dapps-staking TVL percentage at which adjustable inflation towards stakers becomes saturated - #[codec(compact)] - pub ideal_dapps_staking_tvl: Perbill, -} - -impl Default for RewardDistributionConfig { - /// `default` values based on configuration at the time of writing this code. - /// Should be overriden by desired params. - fn default() -> Self { - RewardDistributionConfig { - treasury_percent: Perbill::from_percent(40), - base_staker_percent: Perbill::from_percent(25), - dapps_percent: Perbill::from_percent(25), - collators_percent: Perbill::from_percent(10), - adjustable_percent: Zero::zero(), - ideal_dapps_staking_tvl: Zero::zero(), - } - } -} - -impl RewardDistributionConfig { - /// `true` if sum of all percentages is `one whole`, `false` otherwise. - pub fn is_consistent(&self) -> bool { - // TODO: perhaps this can be writen in a more cleaner way? - // experimental-only `try_reduce` could be used but it's not available - // https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.try_reduce - - let variables = vec![ - &self.treasury_percent, - &self.base_staker_percent, - &self.dapps_percent, - &self.collators_percent, - &self.adjustable_percent, - ]; - - let mut accumulator = Perbill::zero(); - for config_param in variables { - let result = accumulator.checked_add(config_param); - if let Some(mid_result) = result { - accumulator = mid_result; - } else { - return false; - } - } - - Perbill::one() == accumulator - } -} - -/// Represents rewards distribution balances for each beneficiary -#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, TypeInfo, MaxEncodedLen)] -#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] -pub struct Rewards { - treasury_reward: Balance, - staker_reward: Balance, - dapps_reward: Balance, - collators_reward: Balance, -} - -impl Rewards { - fn sum(&self) -> Balance { - self.treasury_reward - .saturating_add(self.staker_reward) - .saturating_add(self.dapps_reward) - .saturating_add(self.collators_reward) - } -} - -/// Defines functions used to payout the beneficiaries of block rewards -pub trait BeneficiaryPayout { - /// Payout reward to the treasury - fn treasury(reward: Imbalance); - - /// Payout reward to the collators - fn collators(reward: Imbalance); - - /// Payout reward to dapps staking - /// - /// # Arguments - /// - /// * `stakers` - reward that goes towards staker reward pot - /// * `dapps` - reward that goes towards dapps reward pot - /// - fn dapps_staking(stakers: Imbalance, dapps: Imbalance); -} diff --git a/pallets/block-rewards-hybrid/src/mock.rs b/pallets/block-rewards-hybrid/src/mock.rs deleted file mode 100644 index 475d1c837e..0000000000 --- a/pallets/block-rewards-hybrid/src/mock.rs +++ /dev/null @@ -1,198 +0,0 @@ -// This file is part of Astar. - -// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later - -// Astar 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. - -// Astar 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 Astar. If not, see . - -use crate::{self as pallet_block_reward, NegativeImbalanceOf}; - -use frame_support::{ - construct_runtime, parameter_types, - traits::Currency, - traits::{ConstU32, Get}, - weights::Weight, - PalletId, -}; -use sp_core::H256; -use sp_io::TestExternalities; -use sp_runtime::{ - traits::{AccountIdConversion, BlakeTwo256, IdentityLookup}, - BuildStorage, -}; -use sp_std::cell::RefCell; - -pub(crate) type AccountId = u64; -pub(crate) type Balance = u128; - -type Block = frame_system::mocking::MockBlock; - -/// Value shouldn't be less than 2 for testing purposes, otherwise we cannot test certain corner cases. -pub(crate) const EXISTENTIAL_DEPOSIT: Balance = 2; - -construct_runtime!( - pub struct TestRuntime { - System: frame_system, - Balances: pallet_balances, - Timestamp: pallet_timestamp, - BlockReward: pallet_block_reward, - } -); - -parameter_types! { - pub const BlockHashCount: u64 = 250; - pub BlockWeights: frame_system::limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max(Weight::from_parts(1024, 0)); -} - -impl frame_system::Config for TestRuntime { - type BaseCallFilter = frame_support::traits::Everything; - type BlockWeights = (); - type BlockLength = (); - type RuntimeOrigin = RuntimeOrigin; - type Nonce = u64; - type RuntimeCall = RuntimeCall; - type Block = Block; - type Hash = H256; - type Hashing = BlakeTwo256; - type AccountId = AccountId; - type Lookup = IdentityLookup; - type RuntimeEvent = RuntimeEvent; - type BlockHashCount = BlockHashCount; - type DbWeight = (); - type Version = (); - type PalletInfo = PalletInfo; - type AccountData = pallet_balances::AccountData; - type OnNewAccount = (); - type OnKilledAccount = (); - type SystemWeightInfo = (); - type SS58Prefix = (); - type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; -} - -parameter_types! { - pub const MaxLocks: u32 = 4; - pub const ExistentialDeposit: Balance = EXISTENTIAL_DEPOSIT; -} - -impl pallet_balances::Config for TestRuntime { - type MaxLocks = MaxLocks; - type MaxReserves = (); - type ReserveIdentifier = [u8; 8]; - type Balance = Balance; - type RuntimeEvent = RuntimeEvent; - type DustRemoval = (); - type ExistentialDeposit = ExistentialDeposit; - type AccountStore = System; - type WeightInfo = (); - type RuntimeHoldReason = RuntimeHoldReason; - type RuntimeFreezeReason = (); - type FreezeIdentifier = (); - type MaxHolds = ConstU32<0>; - type MaxFreezes = ConstU32<0>; -} - -parameter_types! { - pub const MinimumPeriod: u64 = 3; -} - -impl pallet_timestamp::Config for TestRuntime { - type Moment = u64; - type OnTimestampSet = (); - type MinimumPeriod = MinimumPeriod; - type WeightInfo = (); -} - -// A fairly high block reward so we can detect slight changes in reward distribution -// due to TVL changes. -pub(crate) const BLOCK_REWARD: Balance = 1_000_000; - -// Fake accounts used to simulate reward beneficiaries balances -pub(crate) const TREASURY_POT: PalletId = PalletId(*b"moktrsry"); -pub(crate) const COLLATOR_POT: PalletId = PalletId(*b"mokcolat"); -pub(crate) const STAKERS_POT: PalletId = PalletId(*b"mokstakr"); -pub(crate) const DAPPS_POT: PalletId = PalletId(*b"mokdapps"); - -thread_local! { - static TVL: RefCell = RefCell::new(1_000_000_000); -} - -// Type used as TVL provider -pub struct TvlProvider(); -impl Get for TvlProvider { - fn get() -> Balance { - TVL.with(|t| t.borrow().clone()) - } -} - -pub(crate) fn set_tvl(v: Balance) { - TVL.with(|t| *t.borrow_mut() = v) -} - -// Type used as beneficiary payout handle -pub struct BeneficiaryPayout(); -impl pallet_block_reward::BeneficiaryPayout> - for BeneficiaryPayout -{ - fn treasury(reward: NegativeImbalanceOf) { - Balances::resolve_creating(&TREASURY_POT.into_account_truncating(), reward); - } - - fn collators(reward: NegativeImbalanceOf) { - Balances::resolve_creating(&COLLATOR_POT.into_account_truncating(), reward); - } - - fn dapps_staking( - stakers: NegativeImbalanceOf, - dapps: NegativeImbalanceOf, - ) { - Balances::resolve_creating(&STAKERS_POT.into_account_truncating(), stakers); - Balances::resolve_creating(&DAPPS_POT.into_account_truncating(), dapps); - } -} - -parameter_types! { - pub const RewardAmount: Balance = BLOCK_REWARD; -} - -impl pallet_block_reward::Config for TestRuntime { - type RuntimeEvent = RuntimeEvent; - type Currency = Balances; - type MaxBlockRewardAmount = RewardAmount; - type DappsStakingTvlProvider = TvlProvider; - type BeneficiaryPayout = BeneficiaryPayout; - type WeightInfo = (); -} - -pub struct ExternalityBuilder; - -impl ExternalityBuilder { - pub fn build() -> TestExternalities { - let mut storage = frame_system::GenesisConfig::::default() - .build_storage() - .unwrap(); - - // This will cause some initial issuance - pallet_balances::GenesisConfig:: { - balances: vec![(1, 9000), (2, 800), (3, 10000)], - } - .assimilate_storage(&mut storage) - .ok(); - - let mut ext = TestExternalities::from(storage); - ext.execute_with(|| System::set_block_number(1)); - ext - } -} diff --git a/pallets/block-rewards-hybrid/src/tests.rs b/pallets/block-rewards-hybrid/src/tests.rs deleted file mode 100644 index 0ba92d500a..0000000000 --- a/pallets/block-rewards-hybrid/src/tests.rs +++ /dev/null @@ -1,445 +0,0 @@ -// This file is part of Astar. - -// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later - -// Astar 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. - -// Astar 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 Astar. If not, see . - -use super::{pallet::Error, Event, *}; -use frame_support::{assert_noop, assert_ok, traits::OnTimestampSet}; -use mock::{Balance, *}; -use sp_runtime::{ - traits::{AccountIdConversion, BadOrigin, Zero}, - Perbill, -}; - -#[test] -fn default_reward_distribution_config_is_consitent() { - let reward_config = RewardDistributionConfig::default(); - assert!(reward_config.is_consistent()); -} - -#[test] -fn reward_distribution_config_is_consistent() { - // 1 - let reward_config = RewardDistributionConfig { - treasury_percent: Perbill::from_percent(100), - base_staker_percent: Zero::zero(), - dapps_percent: Zero::zero(), - collators_percent: Zero::zero(), - adjustable_percent: Zero::zero(), - ideal_dapps_staking_tvl: Zero::zero(), - }; - assert!(reward_config.is_consistent()); - - // 2 - let reward_config = RewardDistributionConfig { - treasury_percent: Zero::zero(), - base_staker_percent: Perbill::from_percent(100), - dapps_percent: Zero::zero(), - collators_percent: Zero::zero(), - adjustable_percent: Zero::zero(), - ideal_dapps_staking_tvl: Zero::zero(), - }; - assert!(reward_config.is_consistent()); - - // 3 - let reward_config = RewardDistributionConfig { - treasury_percent: Zero::zero(), - base_staker_percent: Zero::zero(), - dapps_percent: Zero::zero(), - collators_percent: Zero::zero(), - adjustable_percent: Perbill::from_percent(100), - ideal_dapps_staking_tvl: Perbill::from_percent(13), - }; - assert!(reward_config.is_consistent()); - - // 4 - // 100% - let reward_config = RewardDistributionConfig { - treasury_percent: Perbill::from_rational(4663701u32, 100000000u32), - base_staker_percent: Perbill::from_rational(2309024u32, 10000000u32), - dapps_percent: Perbill::from_rational(173094531u32, 1000000000u32), - collators_percent: Perbill::from_rational(29863296u32, 1000000000u32), - adjustable_percent: Perbill::from_rational(519502763u32, 1000000000u32), - ideal_dapps_staking_tvl: Perbill::from_percent(60), - }; - assert!(reward_config.is_consistent()); -} - -#[test] -fn reward_distribution_config_not_consistent() { - // 1 - let reward_config = RewardDistributionConfig { - treasury_percent: Perbill::from_percent(100), - ..Default::default() - }; - assert!(!reward_config.is_consistent()); - - // 2 - let reward_config = RewardDistributionConfig { - adjustable_percent: Perbill::from_percent(100), - ..Default::default() - }; - assert!(!reward_config.is_consistent()); - - // 3 - // 99% - let reward_config = RewardDistributionConfig { - treasury_percent: Perbill::from_percent(10), - base_staker_percent: Perbill::from_percent(20), - dapps_percent: Perbill::from_percent(20), - collators_percent: Perbill::from_percent(30), - adjustable_percent: Perbill::from_percent(19), - ideal_dapps_staking_tvl: Zero::zero(), - }; - assert!(!reward_config.is_consistent()); - - // 4 - // 101% - let reward_config = RewardDistributionConfig { - treasury_percent: Perbill::from_percent(10), - base_staker_percent: Perbill::from_percent(20), - dapps_percent: Perbill::from_percent(20), - collators_percent: Perbill::from_percent(31), - adjustable_percent: Perbill::from_percent(20), - ideal_dapps_staking_tvl: Zero::zero(), - }; - assert!(!reward_config.is_consistent()); -} - -#[test] -fn set_configuration_fails() { - ExternalityBuilder::build().execute_with(|| { - // 1 - assert_noop!( - BlockReward::set_configuration(RuntimeOrigin::signed(1), Default::default()), - BadOrigin - ); - - // 2 - let reward_config = RewardDistributionConfig { - treasury_percent: Perbill::from_percent(100), - ..Default::default() - }; - assert!(!reward_config.is_consistent()); - assert_noop!( - BlockReward::set_configuration(RuntimeOrigin::root(), reward_config), - Error::::InvalidDistributionConfiguration, - ); - }) -} - -#[test] -fn set_configuration_is_ok() { - ExternalityBuilder::build().execute_with(|| { - // custom config so it differs from the default one - let reward_config = RewardDistributionConfig { - treasury_percent: Perbill::from_percent(3), - base_staker_percent: Perbill::from_percent(14), - dapps_percent: Perbill::from_percent(18), - collators_percent: Perbill::from_percent(31), - adjustable_percent: Perbill::from_percent(34), - ideal_dapps_staking_tvl: Perbill::from_percent(87), - }; - assert!(reward_config.is_consistent()); - - assert_ok!(BlockReward::set_configuration( - RuntimeOrigin::root(), - reward_config.clone() - )); - System::assert_last_event(mock::RuntimeEvent::BlockReward( - Event::DistributionConfigurationChanged(reward_config.clone()), - )); - - assert_eq!( - RewardDistributionConfigStorage::::get(), - reward_config - ); - }) -} - -#[test] -fn inflation_and_total_issuance_as_expected() { - ExternalityBuilder::build().execute_with(|| { - let init_issuance = ::Currency::total_issuance(); - - for block in 0..10 { - assert_eq!( - ::Currency::total_issuance(), - block * BLOCK_REWARD + init_issuance - ); - BlockReward::on_timestamp_set(0); - assert_eq!( - ::Currency::total_issuance(), - (block + 1) * BLOCK_REWARD + init_issuance - ); - } - }) -} - -#[test] -fn reward_distribution_as_expected() { - ExternalityBuilder::build().execute_with(|| { - // Ensure that initially, all beneficiaries have no free balance - let init_balance_snapshot = FreeBalanceSnapshot::new(); - assert!(init_balance_snapshot.is_zero()); - - // Prepare a custom config (easily discernable percentages for visual verification) - let reward_config = RewardDistributionConfig { - treasury_percent: Perbill::from_percent(10), - base_staker_percent: Perbill::from_percent(20), - dapps_percent: Perbill::from_percent(25), - collators_percent: Perbill::from_percent(5), - adjustable_percent: Perbill::from_percent(40), - ideal_dapps_staking_tvl: Perbill::from_percent(50), - }; - assert!(reward_config.is_consistent()); - assert_ok!(BlockReward::set_configuration( - RuntimeOrigin::root(), - reward_config.clone() - )); - - // Issue rewards a couple of times and verify distribution is as expected - // also ensure that the non distributed reward amount is burn - // (that the total issuance is only increased by the amount that has been rewarded) - for _block in 1..=100 { - // TVL amount is updated every block - // to ensure TVL ratio as expected - adjust_tvl(30); - let init_balance_state = FreeBalanceSnapshot::new(); - let total_issuance_before = ::Currency::total_issuance(); - let distributed_rewards = Rewards::calculate(&reward_config); - - BlockReward::on_timestamp_set(0); - - let final_balance_state = FreeBalanceSnapshot::new(); - init_balance_state.assert_distribution(&final_balance_state, &distributed_rewards); - - assert_eq!( - ::Currency::total_issuance(), - total_issuance_before + distributed_rewards.sum() - ); - } - }) -} - -#[test] -fn non_distributed_reward_amount_is_burned() { - ExternalityBuilder::build().execute_with(|| { - // Ensure that initially, all beneficiaries have no free balance - let init_balance_snapshot = FreeBalanceSnapshot::new(); - assert!(init_balance_snapshot.is_zero()); - - // Prepare a custom config (easily discernible percentages for visual verification) - let reward_config = RewardDistributionConfig { - treasury_percent: Perbill::from_percent(10), - base_staker_percent: Perbill::from_percent(20), - dapps_percent: Perbill::from_percent(25), - collators_percent: Perbill::from_percent(5), - adjustable_percent: Perbill::from_percent(40), - ideal_dapps_staking_tvl: Perbill::from_percent(50), - }; - assert!(reward_config.is_consistent()); - assert_ok!(BlockReward::set_configuration( - RuntimeOrigin::root(), - reward_config.clone() - )); - - for tvl in [30, 50, 70, 100] { - for _block in 1..=100 { - // TVL amount is updated every block - // to ensure TVL ratio as expected - adjust_tvl(tvl); - let total_issuance_before = ::Currency::total_issuance(); - let distributed_rewards = Rewards::calculate(&reward_config); - let burned_amount = BLOCK_REWARD - distributed_rewards.sum(); - - BlockReward::on_timestamp_set(0); - - assert_eq!( - ::Currency::total_issuance(), - total_issuance_before + BLOCK_REWARD - burned_amount - ); - } - } - }) -} - -#[test] -fn reward_distribution_no_adjustable_part() { - ExternalityBuilder::build().execute_with(|| { - let reward_config = RewardDistributionConfig { - treasury_percent: Perbill::from_percent(10), - base_staker_percent: Perbill::from_percent(45), - dapps_percent: Perbill::from_percent(40), - collators_percent: Perbill::from_percent(5), - adjustable_percent: Perbill::zero(), - ideal_dapps_staking_tvl: Perbill::from_percent(50), // this is irrelevant - }; - assert!(reward_config.is_consistent()); - assert_ok!(BlockReward::set_configuration( - RuntimeOrigin::root(), - reward_config.clone() - )); - - // no adjustable part so we don't expect rewards to change with TVL percentage - let const_rewards = Rewards::calculate(&reward_config); - - for _block in 1..=100 { - let init_balance_state = FreeBalanceSnapshot::new(); - let rewards = Rewards::calculate(&reward_config); - - assert_eq!(rewards, const_rewards); - - BlockReward::on_timestamp_set(0); - - let final_balance_state = FreeBalanceSnapshot::new(); - init_balance_state.assert_distribution(&final_balance_state, &rewards); - } - }) -} - -#[test] -fn reward_distribution_all_zero_except_one() { - ExternalityBuilder::build().execute_with(|| { - let reward_config = RewardDistributionConfig { - treasury_percent: Perbill::zero(), - base_staker_percent: Perbill::zero(), - dapps_percent: Perbill::zero(), - collators_percent: Perbill::zero(), - adjustable_percent: Perbill::one(), - ideal_dapps_staking_tvl: Perbill::from_percent(50), // this is irrelevant - }; - assert!(reward_config.is_consistent()); - assert_ok!(BlockReward::set_configuration( - RuntimeOrigin::root(), - reward_config.clone() - )); - - for _block in 1..=10 { - let init_balance_state = FreeBalanceSnapshot::new(); - let rewards = Rewards::calculate(&reward_config); - - BlockReward::on_timestamp_set(0); - - let final_balance_state = FreeBalanceSnapshot::new(); - init_balance_state.assert_distribution(&final_balance_state, &rewards); - } - }) -} - -/// Represents free balance snapshot at a specific point in time -#[derive(PartialEq, Eq, Clone, RuntimeDebug)] -struct FreeBalanceSnapshot { - treasury: Balance, - collators: Balance, - stakers: Balance, - dapps: Balance, -} - -impl FreeBalanceSnapshot { - /// Creates a new free balance snapshot using current balance state. - /// - /// Future balance changes won't be reflected in this instance. - fn new() -> Self { - Self { - treasury: ::Currency::free_balance( - &TREASURY_POT.into_account_truncating(), - ), - collators: ::Currency::free_balance( - &COLLATOR_POT.into_account_truncating(), - ), - stakers: ::Currency::free_balance( - &STAKERS_POT.into_account_truncating(), - ), - dapps: ::Currency::free_balance( - &DAPPS_POT.into_account_truncating(), - ), - } - } - - /// `true` if all free balances equal `Zero`, `false` otherwise - fn is_zero(&self) -> bool { - self.treasury.is_zero() - && self.collators.is_zero() - && self.stakers.is_zero() - && self.dapps.is_zero() - } - - /// Asserts that `post_reward_state` is as expected. - /// - /// Increase in balances, based on `rewards` values, is verified. - /// - fn assert_distribution(&self, post_reward_state: &Self, rewards: &Rewards) { - assert_eq!( - self.treasury + rewards.treasury_reward, - post_reward_state.treasury - ); - assert_eq!( - self.stakers + rewards.staker_reward, - post_reward_state.stakers - ); - assert_eq!( - self.collators + rewards.collators_reward, - post_reward_state.collators - ); - assert_eq!(self.dapps + rewards.dapps_reward, post_reward_state.dapps); - } -} - -impl Rewards { - /// Pre-calculates the reward distribution, using the provided `RewardDistributionConfig`. - /// Method assumes that total issuance will be increased by `BLOCK_REWARD`. - /// - /// Both current `total_issuance` and `TVL` are used. If these are changed after calling this function, - /// they won't be reflected in the struct. - /// - fn calculate(reward_config: &RewardDistributionConfig) -> Self { - // Calculate `tvl-independent` portions - let treasury_reward = reward_config.treasury_percent * BLOCK_REWARD; - let base_staker_reward = reward_config.base_staker_percent * BLOCK_REWARD; - let dapps_reward = reward_config.dapps_percent * BLOCK_REWARD; - let collators_reward = reward_config.collators_percent * BLOCK_REWARD; - let adjustable_reward = reward_config.adjustable_percent * BLOCK_REWARD; - - // Calculate `tvl-dependent` portions - let total_issuance = ::Currency::total_issuance(); - let tvl = ::DappsStakingTvlProvider::get(); - let tvl_percentage = Perbill::from_rational(tvl, total_issuance); - - // Calculate factor for adjusting staker reward portion - let factor = if reward_config.ideal_dapps_staking_tvl.is_zero() { - Perbill::one() - } else { - tvl_percentage / reward_config.ideal_dapps_staking_tvl - }; - - // Adjustable reward portions - let adjustable_staker_reward = factor * adjustable_reward; - - let staker_reward = base_staker_reward + adjustable_staker_reward; - - Self { - treasury_reward, - staker_reward, - dapps_reward, - collators_reward, - } - } -} - -fn adjust_tvl(desired_percent: u128) { - set_tvl(::Currency::total_issuance() / 100 * desired_percent); -} diff --git a/pallets/block-rewards-hybrid/src/weights.rs b/pallets/block-rewards-hybrid/src/weights.rs deleted file mode 100644 index 12c0be364f..0000000000 --- a/pallets/block-rewards-hybrid/src/weights.rs +++ /dev/null @@ -1,82 +0,0 @@ - -// This file is part of Astar. - -// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later - -// Astar 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. - -// Astar 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 Astar. If not, see . - -//! Autogenerated weights for block_rewards_hybrid -//! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-11-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `devserver-01`, CPU: `Intel(R) Xeon(R) E-2236 CPU @ 3.40GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("shibuya-dev"), DB CACHE: 1024 - -// Executed Command: -// ./target/release/astar-collator -// benchmark -// pallet -// --chain=shibuya-dev -// --steps=50 -// --repeat=20 -// --pallet=block_rewards_hybrid -// --extrinsic=* -// --execution=wasm -// --wasm-execution=compiled -// --heap-pages=4096 -// --output=./benchmark-results/shibuya-dev/rewards_hybrid_weights.rs -// --template=./scripts/templates/weight-template.hbs - -#![cfg_attr(rustfmt, rustfmt_skip)] -#![allow(unused_parens)] -#![allow(unused_imports)] - -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; -use core::marker::PhantomData; - -/// Weight functions needed for block_rewards_hybrid. -pub trait WeightInfo { - fn set_configuration() -> Weight; -} - -/// Weights for block_rewards_hybrid using the Substrate node and recommended hardware. -pub struct SubstrateWeight(PhantomData); -impl WeightInfo for SubstrateWeight { - /// Storage: BlockReward RewardDistributionConfigStorage (r:0 w:1) - /// Proof: BlockReward RewardDistributionConfigStorage (max_values: Some(1), max_size: Some(24), added: 519, mode: MaxEncodedLen) - fn set_configuration() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 8_645_000 picoseconds. - Weight::from_parts(8_848_000, 0) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } -} - -// For backwards compatibility and tests -impl WeightInfo for () { - /// Storage: BlockReward RewardDistributionConfigStorage (r:0 w:1) - /// Proof: BlockReward RewardDistributionConfigStorage (max_values: Some(1), max_size: Some(24), added: 519, mode: MaxEncodedLen) - fn set_configuration() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 8_645_000 picoseconds. - Weight::from_parts(8_848_000, 0) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } -} \ No newline at end of file diff --git a/runtime/astar/src/xcm_config.rs b/runtime/astar/src/xcm_config.rs index 4432429d01..b5ce14941c 100644 --- a/runtime/astar/src/xcm_config.rs +++ b/runtime/astar/src/xcm_config.rs @@ -31,6 +31,8 @@ use frame_system::EnsureRoot; use sp_runtime::traits::{Convert, MaybeEquivalence}; // Polkadot imports +use cumulus_primitives_core::ParaId; +use polkadot_runtime_common::xcm_sender::NoPriceForMessageDelivery; use xcm::latest::prelude::*; use xcm_builder::{ Account32Hash, AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, @@ -333,7 +335,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime { type ExecuteOverweightOrigin = EnsureRoot; type ControllerOrigin = EnsureRoot; type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin; - type PriceForSiblingDelivery = (); + type PriceForSiblingDelivery = NoPriceForMessageDelivery; type WeightInfo = cumulus_pallet_xcmp_queue::weights::SubstrateWeight; } diff --git a/runtime/local/Cargo.toml b/runtime/local/Cargo.toml index 1f42a18fae..20ef2b745b 100644 --- a/runtime/local/Cargo.toml +++ b/runtime/local/Cargo.toml @@ -22,10 +22,8 @@ frame-system = { workspace = true } pallet-assets = { workspace = true } pallet-aura = { workspace = true } pallet-balances = { workspace = true } -pallet-collective = { workspace = true } pallet-contracts = { workspace = true } pallet-contracts-primitives = { workspace = true } -pallet-democracy = { workspace = true } pallet-ethereum = { workspace = true } pallet-ethereum-checked = { workspace = true } pallet-evm = { workspace = true } @@ -44,7 +42,6 @@ pallet-scheduler = { workspace = true } pallet-sudo = { workspace = true } pallet-timestamp = { workspace = true } pallet-transaction-payment = { workspace = true } -pallet-treasury = { workspace = true } pallet-utility = { workspace = true } pallet-vesting = { workspace = true } sp-api = { workspace = true } @@ -68,12 +65,9 @@ pallet-transaction-payment-rpc-runtime-api = { workspace = true } # Astar pallets astar-primitives = { workspace = true } -pallet-block-rewards-hybrid = { workspace = true } pallet-chain-extension-unified-accounts = { workspace = true } pallet-chain-extension-xvm = { workspace = true } -pallet-dapp-staking-migration = { workspace = true } pallet-dapp-staking-v3 = { workspace = true } -pallet-dapps-staking = { workspace = true } pallet-dynamic-evm-base-fee = { workspace = true } pallet-evm-precompile-assets-erc20 = { workspace = true } pallet-evm-precompile-dapp-staking-v3 = { workspace = true } @@ -123,14 +117,11 @@ std = [ "pallet-assets/std", "pallet-aura/std", "pallet-balances/std", - "pallet-block-rewards-hybrid/std", "pallet-contracts/std", "pallet-contracts-primitives/std", "pallet-chain-extension-xvm/std", "pallet-chain-extension-unified-accounts/std", - "pallet-dapps-staking/std", "pallet-dapp-staking-v3/std", - "pallet-dapp-staking-migration/std", "dapp-staking-v3-runtime-api/std", "pallet-inflation/std", "pallet-static-price-provider/std", @@ -176,10 +167,7 @@ std = [ "sp-io/std", "frame-benchmarking/std", "frame-try-runtime/std", - "pallet-collective/std", - "pallet-democracy/std", "pallet-scheduler/std", - "pallet-treasury/std", "pallet-xvm/std", "pallet-unified-accounts/std", "pallet-ethereum-checked/std", @@ -196,12 +184,9 @@ runtime-benchmarks = [ "frame-system-benchmarking/runtime-benchmarks", "frame-system/runtime-benchmarks", "sp-runtime/runtime-benchmarks", - "pallet-dapps-staking/runtime-benchmarks", - "pallet-block-rewards-hybrid/runtime-benchmarks", "pallet-balances/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", "pallet-ethereum/runtime-benchmarks", - "pallet-collective/runtime-benchmarks", "pallet-preimage/runtime-benchmarks", "pallet-ethereum-checked/runtime-benchmarks", "pallet-unified-accounts/runtime-benchmarks", @@ -210,7 +195,6 @@ runtime-benchmarks = [ "pallet-dapp-staking-v3/runtime-benchmarks", "pallet-inflation/runtime-benchmarks", "pallet-dynamic-evm-base-fee/runtime-benchmarks", - "pallet-dapp-staking-migration/runtime-benchmarks", ] try-runtime = [ "fp-self-contained/try-runtime", @@ -221,9 +205,7 @@ try-runtime = [ "frame-system/try-runtime", "pallet-aura/try-runtime", "pallet-balances/try-runtime", - "pallet-block-rewards-hybrid/try-runtime", "pallet-contracts/try-runtime", - "pallet-dapps-staking/try-runtime", "pallet-dapp-staking-v3/try-runtime", "pallet-inflation/try-runtime", "pallet-grandpa/try-runtime", @@ -238,15 +220,11 @@ try-runtime = [ "pallet-ethereum/try-runtime", "pallet-assets/try-runtime", "pallet-scheduler/try-runtime", - "pallet-democracy/try-runtime", - "pallet-collective/try-runtime", "pallet-proxy/try-runtime", - "pallet-treasury/try-runtime", "pallet-preimage/try-runtime", "pallet-dynamic-evm-base-fee/try-runtime", "pallet-evm/try-runtime", "pallet-ethereum-checked/try-runtime", - "pallet-dapp-staking-migration/try-runtime", "pallet-static-price-provider/try-runtime", ] evm-tracing = [ diff --git a/runtime/local/src/lib.rs b/runtime/local/src/lib.rs index ec10836809..8dc45392f9 100644 --- a/runtime/local/src/lib.rs +++ b/runtime/local/src/lib.rs @@ -30,8 +30,8 @@ use frame_support::{ parameter_types, traits::{ fungible::HoldConsideration, AsEnsureOriginWithArg, ConstU128, ConstU32, ConstU64, - Currency, EitherOfDiverse, EqualPrivilegeOnly, FindAuthor, Get, InstanceFilter, - LinearStoragePrice, Nothing, OnFinalize, WithdrawReasons, + Currency, EqualPrivilegeOnly, FindAuthor, Get, InstanceFilter, LinearStoragePrice, Nothing, + OnFinalize, WithdrawReasons, }, weights::{ constants::{ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_REF_TIME_PER_SECOND}, @@ -56,7 +56,7 @@ use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, traits::{ AccountIdConversion, AccountIdLookup, BlakeTwo256, Block as BlockT, ConvertInto, - DispatchInfoOf, Dispatchable, NumberFor, PostDispatchInfoOf, UniqueSaturatedInto, IdentityLookup, + DispatchInfoOf, Dispatchable, NumberFor, PostDispatchInfoOf, UniqueSaturatedInto, }, transaction_validity::{TransactionSource, TransactionValidity, TransactionValidityError}, ApplyExtrinsicResult, FixedPointNumber, Perbill, Permill, Perquintill, RuntimeDebug, @@ -73,7 +73,6 @@ use astar_primitives::{ }; pub use astar_primitives::{AccountId, Signature}; -pub use pallet_block_rewards_hybrid::RewardDistributionConfig; pub use pallet_dapp_staking_v3::TierThreshold; pub use crate::precompiles::WhitelistedCalls; @@ -280,7 +279,7 @@ parameter_types! { impl pallet_timestamp::Config for Runtime { /// A timestamp: milliseconds since the unix epoch. type Moment = u64; - type OnTimestampSet = (Aura, BlockReward); + type OnTimestampSet = Aura; type MinimumPeriod = MinimumPeriod; type WeightInfo = pallet_timestamp::weights::SubstrateWeight; } @@ -428,71 +427,6 @@ parameter_types! { type NegativeImbalance = >::NegativeImbalance; -pub struct DappsStakingTvlProvider(); -impl Get for DappsStakingTvlProvider { - fn get() -> Balance { - DappsStaking::tvl() - } -} - -pub struct BeneficiaryPayout(); -impl pallet_block_rewards_hybrid::BeneficiaryPayout for BeneficiaryPayout { - fn treasury(reward: NegativeImbalance) { - Balances::resolve_creating(&TreasuryPalletId::get().into_account_truncating(), reward); - } - - fn collators(_reward: NegativeImbalance) { - // no collators for local dev node - } - - fn dapps_staking(stakers: NegativeImbalance, dapps: NegativeImbalance) { - DappsStaking::rewards(stakers, dapps) - } -} - -parameter_types! { - pub const MaxBlockRewardAmount: Balance = 230_718 * MILLIAST; -} - -impl pallet_block_rewards_hybrid::Config for Runtime { - type Currency = Balances; - type DappsStakingTvlProvider = DappsStakingTvlProvider; - type BeneficiaryPayout = BeneficiaryPayout; - type MaxBlockRewardAmount = MaxBlockRewardAmount; - type RuntimeEvent = RuntimeEvent; - type WeightInfo = pallet_block_rewards_hybrid::weights::SubstrateWeight; -} - -parameter_types! { - pub const BlockPerEra: BlockNumber = 60; - pub const RegisterDeposit: Balance = 100 * AST; - pub const MaxNumberOfStakersPerContract: u32 = 512; - pub const MinimumStakingAmount: Balance = 10 * AST; - pub const MinimumRemainingAmount: Balance = AST; - pub const MaxUnlockingChunks: u32 = 2; - pub const UnbondingPeriod: u32 = 2; - pub const MaxEraStakeValues: u32 = 5; -} - -impl pallet_dapps_staking::Config for Runtime { - type Currency = Balances; - type BlockPerEra = BlockPerEra; - type SmartContract = SmartContract; - type RegisterDeposit = RegisterDeposit; - type RuntimeEvent = RuntimeEvent; - type WeightInfo = pallet_dapps_staking::weights::SubstrateWeight; - type MaxNumberOfStakersPerContract = MaxNumberOfStakersPerContract; - type MinimumStakingAmount = MinimumStakingAmount; - type PalletId = DappsStakingPalletId; - type MaxUnlockingChunks = MaxUnlockingChunks; - type UnbondingPeriod = UnbondingPeriod; - type MinimumRemainingAmount = MinimumRemainingAmount; - type MaxEraStakeValues = MaxEraStakeValues; - type UnregisteredDappRewardRetention = ConstU32<3>; - type ForcePalletDisabled = ConstBool; // This will be set to `true` when needed - type DelegateClaimFee = ConstU128<1>; -} - impl pallet_static_price_provider::Config for Runtime { type RuntimeEvent = RuntimeEvent; } @@ -578,11 +512,6 @@ impl pallet_inflation::Config for Runtime { type WeightInfo = pallet_inflation::weights::SubstrateWeight; } -impl pallet_dapp_staking_migration::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type WeightInfo = pallet_dapp_staking_migration::weights::SubstrateWeight; -} - impl pallet_utility::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; @@ -746,159 +675,6 @@ impl pallet_preimage::Config for Runtime { >; } -parameter_types! { - pub CouncilMotionDuration: BlockNumber = 3 * MINUTES; - pub MaxProposalWeight: Weight = Perbill::from_percent(50) * RuntimeBlockWeights::get().max_block; -} - -type CouncilCollective = pallet_collective::Instance1; -impl pallet_collective::Config for Runtime { - type RuntimeOrigin = RuntimeOrigin; - type RuntimeEvent = RuntimeEvent; - type Proposal = RuntimeCall; - type MotionDuration = CouncilMotionDuration; - type MaxProposals = ConstU32<100>; - type MaxMembers = ConstU32<3>; - type DefaultVote = pallet_collective::PrimeDefaultVote; - type WeightInfo = pallet_collective::weights::SubstrateWeight; - type SetMembersOrigin = EnsureRoot; - type MaxProposalWeight = MaxProposalWeight; -} - -parameter_types! { - pub const TechnicalCommitteeMotionDuration: BlockNumber = 3 * MINUTES; -} - -type TechnicalCommitteeCollective = pallet_collective::Instance2; -impl pallet_collective::Config for Runtime { - type RuntimeOrigin = RuntimeOrigin; - type RuntimeEvent = RuntimeEvent; - type Proposal = RuntimeCall; - type MotionDuration = TechnicalCommitteeMotionDuration; - type MaxProposals = ConstU32<100>; - type MaxMembers = ConstU32<3>; - type DefaultVote = pallet_collective::PrimeDefaultVote; - type WeightInfo = pallet_collective::weights::SubstrateWeight; - type SetMembersOrigin = EnsureRoot; - type MaxProposalWeight = MaxProposalWeight; -} - -parameter_types! { - pub const ProposalBond: Permill = Permill::from_percent(5); - pub const ProposalBondMinimum: Balance = 100 * AST; - pub const ProposalBondMaximum: Balance = 500 * AST; - pub const SpendPeriod: BlockNumber = 1 * MINUTES; - pub const Burn: Permill = Permill::from_percent(1); -} - -impl pallet_treasury::Config for Runtime { - type PalletId = TreasuryPalletId; - type Currency = Balances; - type ApproveOrigin = EitherOfDiverse< - EnsureRoot, - pallet_collective::EnsureProportionAtLeast, - >; - type RejectOrigin = EitherOfDiverse< - EnsureRoot, - pallet_collective::EnsureProportionMoreThan, - >; - type RuntimeEvent = RuntimeEvent; - type OnSlash = Treasury; - type ProposalBond = ProposalBond; - type ProposalBondMinimum = ProposalBondMinimum; - type ProposalBondMaximum = ProposalBondMaximum; - type SpendPeriod = SpendPeriod; - type Burn = Burn; - type BurnDestination = (); - type SpendFunds = (); - type MaxApprovals = ConstU32<100>; - type WeightInfo = pallet_treasury::weights::SubstrateWeight; - type SpendOrigin = frame_support::traits::NeverEnsureOrigin; - type AssetKind = (); - type Beneficiary = AccountId; - type BeneficiaryLookup = IdentityLookup; - type Paymaster = (); - type BalanceConverter = (); - type PayoutPeriod = (); - #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHelper = (); -} - -parameter_types! { - pub LaunchPeriod: BlockNumber = 1 * MINUTES; - pub VotingPeriod: BlockNumber = 3 * MINUTES; - pub FastTrackVotingPeriod: BlockNumber = 1 * MINUTES; - pub const MinimumDeposit: Balance = 7000 * AST; - pub EnactmentPeriod: BlockNumber = 5 * MINUTES; - pub VoteLockingPeriod: BlockNumber = 10 * MINUTES; - pub CooloffPeriod: BlockNumber = 10 * MINUTES; - pub const InstantAllowed: bool = true; -} - -impl pallet_democracy::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type Currency = Balances; - type EnactmentPeriod = EnactmentPeriod; - type LaunchPeriod = LaunchPeriod; - type VotingPeriod = VotingPeriod; - type VoteLockingPeriod = VoteLockingPeriod; - type MinimumDeposit = MinimumDeposit; - /// A straight majority of the council can decide what their next motion is. - type ExternalOrigin = EitherOfDiverse< - pallet_collective::EnsureProportionAtLeast, - EnsureRoot, - >; - /// A 60% super-majority can have the next scheduled referendum be a straight majority-carries vote. - type ExternalMajorityOrigin = EitherOfDiverse< - pallet_collective::EnsureProportionAtLeast, - EnsureRoot, - >; - /// A unanimous council can have the next scheduled referendum be a straight default-carries - /// (NTB) vote. - type ExternalDefaultOrigin = EitherOfDiverse< - pallet_collective::EnsureProportionAtLeast, - EnsureRoot, - >; - type SubmitOrigin = EnsureSigned; - /// Two thirds of the technical committee can have an `ExternalMajority/ExternalDefault` vote - /// be tabled immediately and with a shorter voting/enactment period. - type FastTrackOrigin = EitherOfDiverse< - pallet_collective::EnsureProportionAtLeast, - EnsureRoot, - >; - type InstantOrigin = EitherOfDiverse< - pallet_collective::EnsureProportionAtLeast, - EnsureRoot, - >; - type InstantAllowed = InstantAllowed; - type FastTrackVotingPeriod = FastTrackVotingPeriod; - // To cancel a proposal which has been passed, 2/3 of the council must agree to it. - type CancellationOrigin = EitherOfDiverse< - pallet_collective::EnsureProportionAtLeast, - EnsureRoot, - >; - // To cancel a proposal before it has been passed, the technical committee must be unanimous or - // Root must agree. - type CancelProposalOrigin = EitherOfDiverse< - pallet_collective::EnsureProportionAtLeast, - EnsureRoot, - >; - type BlacklistOrigin = EnsureRoot; - // Any single technical committee member may veto a coming council proposal, however they can - // only do it once and it lasts only for the cooloff period. - type VetoOrigin = pallet_collective::EnsureMember; - type CooloffPeriod = CooloffPeriod; - type Slash = Treasury; - type Scheduler = Scheduler; - type MaxVotes = ConstU32<100>; - type PalletsOrigin = OriginCaller; - type WeightInfo = pallet_democracy::weights::SubstrateWeight; - type MaxProposals = ConstU32<100>; - type Preimages = Preimage; - type MaxDeposits = ConstU32<100>; - type MaxBlacklisted = ConstU32<100>; -} - parameter_types! { pub const MinVestedTransfer: Balance = 1 * AST; pub UnvestedFundsAllowedWithdrawReasons: WithdrawReasons = @@ -996,9 +772,6 @@ pub enum ProxyType { Balances, /// All Runtime calls from Pallet Assets allowed for proxy account Assets, - /// Only Runtime Calls related to governance for proxy account - /// To know exact calls check InstanceFilter implementation for ProxyTypes - Governance, /// Only reject_announcement call from pallet proxy allowed for proxy account CancelProxy, /// All runtime calls from pallet DappStaking allowed for proxy account @@ -1034,15 +807,10 @@ impl InstanceFilter for ProxyType { | RuntimeCall::Vesting(pallet_vesting::Call::vest{..}) | RuntimeCall::Vesting(pallet_vesting::Call::vest_other{..}) // Specifically omitting Vesting `vested_transfer`, and `force_vested_transfer` - | RuntimeCall::DappsStaking(..) + | RuntimeCall::DappStaking(..) // Skip entire EVM pallet // Skip entire Ethereum pallet - | RuntimeCall::DynamicEvmBaseFee(..) - // Skip entire Contracts pallet - | RuntimeCall::Democracy(..) - | RuntimeCall::Council(..) - | RuntimeCall::TechnicalCommittee(..) - | RuntimeCall::Treasury(..) + | RuntimeCall::DynamicEvmBaseFee(..) // Skip entire Contracts pallet ) } // All Runtime calls from Pallet Balances allowed for proxy account @@ -1053,15 +821,6 @@ impl InstanceFilter for ProxyType { ProxyType::Assets => { matches!(c, RuntimeCall::Assets(..)) } - ProxyType::Governance => { - matches!( - c, - RuntimeCall::Democracy(..) - | RuntimeCall::Council(..) - | RuntimeCall::TechnicalCommittee(..) - | RuntimeCall::Treasury(..) - ) - } // Only reject_announcement call from pallet proxy allowed for proxy account ProxyType::CancelProxy => { matches!( @@ -1128,12 +887,9 @@ construct_runtime!( Grandpa: pallet_grandpa, Balances: pallet_balances, Vesting: pallet_vesting, - DappsStaking: pallet_dapps_staking, DappStaking: pallet_dapp_staking_v3, - DappStakingMigration: pallet_dapp_staking_migration, Inflation: pallet_inflation, StaticPriceProvider: pallet_static_price_provider, - BlockReward: pallet_block_rewards_hybrid, TransactionPayment: pallet_transaction_payment, EVM: pallet_evm, Ethereum: pallet_ethereum, @@ -1142,10 +898,6 @@ construct_runtime!( Sudo: pallet_sudo, Assets: pallet_assets, Scheduler: pallet_scheduler, - Democracy: pallet_democracy, - Council: pallet_collective::, - TechnicalCommittee: pallet_collective::, - Treasury: pallet_treasury, Xvm: pallet_xvm, Proxy: pallet_proxy, Preimage: pallet_preimage, @@ -1265,11 +1017,8 @@ mod benches { [frame_system, SystemBench::] [pallet_balances, Balances] [pallet_timestamp, Timestamp] - [pallet_dapps_staking, DappsStaking] - [pallet_block_rewards_hybrid, BlockReward] [pallet_ethereum_checked, EthereumChecked] [pallet_dapp_staking_v3, DappStaking] - [pallet_dapp_staking_migration, DappStakingMigration] [pallet_inflation, Inflation] [pallet_dynamic_evm_base_fee, DynamicEvmBaseFee] ); diff --git a/runtime/local/src/precompiles.rs b/runtime/local/src/precompiles.rs index f037d3fa9b..2edec7f84b 100644 --- a/runtime/local/src/precompiles.rs +++ b/runtime/local/src/precompiles.rs @@ -60,7 +60,7 @@ impl Contains for WhitelistedCalls { | RuntimeCall::Utility(pallet_utility::Call::batch_all { calls }) => { calls.iter().all(|call| WhitelistedCalls::contains(call)) } - RuntimeCall::DappsStaking(_) => true, + RuntimeCall::DappStaking(_) => true, RuntimeCall::Assets(pallet_assets::Call::transfer { .. }) => true, _ => false, } diff --git a/runtime/shibuya/Cargo.toml b/runtime/shibuya/Cargo.toml index 96cbd73f40..bbf1830939 100644 --- a/runtime/shibuya/Cargo.toml +++ b/runtime/shibuya/Cargo.toml @@ -44,10 +44,8 @@ pallet-assets = { workspace = true } pallet-aura = { workspace = true } pallet-authorship = { workspace = true } pallet-balances = { workspace = true } -pallet-collective = { workspace = true } pallet-contracts = { workspace = true } pallet-contracts-primitives = { workspace = true } -pallet-democracy = { workspace = true } pallet-ethereum = { workspace = true } pallet-evm = { workspace = true } pallet-evm-chain-id = { workspace = true } @@ -69,7 +67,6 @@ pallet-sudo = { workspace = true } pallet-timestamp = { workspace = true } pallet-transaction-payment = { workspace = true } pallet-transaction-payment-rpc-runtime-api = { workspace = true } -pallet-treasury = { workspace = true } pallet-utility = { workspace = true } pallet-vesting = { workspace = true } @@ -102,7 +99,6 @@ astar-xcm-benchmarks = { workspace = true, optional = true } pallet-chain-extension-unified-accounts = { workspace = true } pallet-chain-extension-xvm = { workspace = true } pallet-collator-selection = { workspace = true } -pallet-dapp-staking-migration = { workspace = true } pallet-dapp-staking-v3 = { workspace = true } pallet-dynamic-evm-base-fee = { workspace = true } pallet-ethereum-checked = { workspace = true } @@ -156,7 +152,6 @@ std = [ "sp-core/std", "sp-genesis-builder/std", "sp-consensus-aura/std", - "pallet-dapp-staking-migration/std", "sp-io/std", "sp-runtime/std", "sp-runtime-interface/std", @@ -209,9 +204,6 @@ std = [ "pallet-timestamp/std", "pallet-vesting/std", "pallet-proxy/std", - "pallet-democracy/std", - "pallet-collective/std", - "pallet-treasury/std", "sp-offchain/std", "sp-session/std", "pallet-sudo/std", @@ -252,7 +244,6 @@ std = [ ] runtime-benchmarks = [ "astar-xcm-benchmarks/runtime-benchmarks", - "pallet-dapp-staking-migration/runtime-benchmarks", "pallet-xcm-benchmarks/runtime-benchmarks", "frame-benchmarking", "frame-support/runtime-benchmarks", @@ -263,7 +254,6 @@ runtime-benchmarks = [ "pallet-inflation/runtime-benchmarks", "pallet-balances/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", - "pallet-collective/runtime-benchmarks", "pallet-ethereum/runtime-benchmarks", "pallet-xcm/runtime-benchmarks", "pallet-xc-asset-config/runtime-benchmarks", @@ -301,7 +291,6 @@ try-runtime = [ "pallet-assets/try-runtime", "pallet-authorship/try-runtime", "pallet-collator-selection/try-runtime", - "pallet-dapp-staking-migration/try-runtime", "pallet-session/try-runtime", "pallet-xcm/try-runtime", "pallet-identity/try-runtime", @@ -310,9 +299,6 @@ try-runtime = [ "pallet-scheduler/try-runtime", "pallet-proxy/try-runtime", "pallet-contracts/try-runtime", - "pallet-democracy/try-runtime", - "pallet-collective/try-runtime", - "pallet-treasury/try-runtime", "pallet-evm-chain-id/try-runtime", "cumulus-pallet-aura-ext/try-runtime", "cumulus-pallet-dmp-queue/try-runtime", diff --git a/runtime/shibuya/src/lib.rs b/runtime/shibuya/src/lib.rs index a5f881a6b2..35c7140a43 100644 --- a/runtime/shibuya/src/lib.rs +++ b/runtime/shibuya/src/lib.rs @@ -30,8 +30,8 @@ use frame_support::{ parameter_types, traits::{ fungible::HoldConsideration, AsEnsureOriginWithArg, ConstU32, Contains, Currency, - EitherOfDiverse, EqualPrivilegeOnly, FindAuthor, Get, Imbalance, InstanceFilter, - LinearStoragePrice, Nothing, OnFinalize, OnUnbalanced, WithdrawReasons, + EqualPrivilegeOnly, FindAuthor, Get, Imbalance, InstanceFilter, LinearStoragePrice, + Nothing, OnFinalize, OnUnbalanced, WithdrawReasons, }, weights::{ constants::{ @@ -61,7 +61,7 @@ use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, traits::{ AccountIdConversion, AccountIdLookup, BlakeTwo256, Block as BlockT, ConvertInto, - DispatchInfoOf, Dispatchable, OpaqueKeys, PostDispatchInfoOf, UniqueSaturatedInto, IdentityLookup, + DispatchInfoOf, Dispatchable, OpaqueKeys, PostDispatchInfoOf, UniqueSaturatedInto, }, transaction_validity::{TransactionSource, TransactionValidity, TransactionValidityError}, ApplyExtrinsicResult, FixedPointNumber, Perbill, Permill, Perquintill, RuntimeDebug, @@ -329,7 +329,7 @@ impl pallet_identity::Config for Runtime { type MaxAdditionalFields = MaxAdditionalFields; type IdentityInformation = IdentityInfo; type MaxRegistrars = MaxRegistrars; - type Slashed = Treasury; + type Slashed = (); type ForceOrigin = EnsureRoot; type RegistrarOrigin = EnsureRoot; type WeightInfo = pallet_identity::weights::SubstrateWeight; @@ -620,6 +620,7 @@ impl pallet_balances::Config for Runtime { type AccountStore = frame_system::Pallet; type WeightInfo = weights::pallet_balances::SubstrateWeight; type RuntimeHoldReason = RuntimeHoldReason; + type RuntimeFreezeReason = RuntimeFreezeReason; type FreezeIdentifier = RuntimeFreezeReason; type MaxHolds = ConstU32<1>; type MaxFreezes = ConstU32<1>; @@ -935,158 +936,6 @@ impl pallet_ethereum::Config for Runtime { type ExtraDataLength = ConstU32<30>; } -parameter_types! { - pub CouncilMotionDuration: BlockNumber = 36 * HOURS; - pub MaxProposalWeight: Weight = Perbill::from_percent(50) * RuntimeBlockWeights::get().max_block; -} - -type CouncilCollective = pallet_collective::Instance1; -impl pallet_collective::Config for Runtime { - type RuntimeOrigin = RuntimeOrigin; - type RuntimeEvent = RuntimeEvent; - type Proposal = RuntimeCall; - type MotionDuration = CouncilMotionDuration; - type MaxProposals = ConstU32<100>; - type MaxMembers = ConstU32<10>; - type DefaultVote = pallet_collective::PrimeDefaultVote; - type WeightInfo = pallet_collective::weights::SubstrateWeight; - type SetMembersOrigin = EnsureRoot; - type MaxProposalWeight = MaxProposalWeight; -} - -parameter_types! { - pub const TechnicalCommitteeMotionDuration: BlockNumber = 36 * HOURS; -} - -type TechnicalCommitteeCollective = pallet_collective::Instance2; -impl pallet_collective::Config for Runtime { - type RuntimeOrigin = RuntimeOrigin; - type RuntimeEvent = RuntimeEvent; - type Proposal = RuntimeCall; - type MotionDuration = TechnicalCommitteeMotionDuration; - type MaxProposals = ConstU32<100>; - type MaxMembers = ConstU32<10>; - type DefaultVote = pallet_collective::PrimeDefaultVote; - type WeightInfo = pallet_collective::weights::SubstrateWeight; - type SetMembersOrigin = EnsureRoot; - type MaxProposalWeight = MaxProposalWeight; -} - -parameter_types! { - pub const ProposalBond: Permill = Permill::from_percent(5); - pub const ProposalBondMinimum: Balance = 100 * SBY; - pub const SpendPeriod: BlockNumber = 1 * DAYS; -} - -impl pallet_treasury::Config for Runtime { - type PalletId = TreasuryPalletId; - type Currency = Balances; - type ApproveOrigin = EitherOfDiverse< - EnsureRoot, - pallet_collective::EnsureProportionAtLeast, - >; - type RejectOrigin = EitherOfDiverse< - EnsureRoot, - pallet_collective::EnsureProportionMoreThan, - >; - type RuntimeEvent = RuntimeEvent; - type OnSlash = Treasury; - type ProposalBond = ProposalBond; - type ProposalBondMinimum = ProposalBondMinimum; - type ProposalBondMaximum = (); - type SpendPeriod = SpendPeriod; - type Burn = (); - type BurnDestination = (); - type SpendFunds = (); - type MaxApprovals = ConstU32<100>; - type WeightInfo = pallet_treasury::weights::SubstrateWeight; - type SpendOrigin = frame_support::traits::NeverEnsureOrigin; - type AssetKind = (); - type Beneficiary = AccountId; - type BeneficiaryLookup = IdentityLookup; - type Paymaster = (); - type BalanceConverter = (); - type PayoutPeriod = (); - #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHelper = (); -} - -parameter_types! { - pub LaunchPeriod: BlockNumber = 7 * DAYS; - pub VotingPeriod: BlockNumber = 14 * DAYS; - pub FastTrackVotingPeriod: BlockNumber = 1 * DAYS; - pub const MinimumDeposit: Balance = 1000 * SBY; - pub EnactmentPeriod: BlockNumber = 2 * DAYS; - pub VoteLockingPeriod: BlockNumber = 7 * DAYS; - pub CooloffPeriod: BlockNumber = 7 * DAYS; - pub const InstantAllowed: bool = true; -} - -impl pallet_democracy::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type Currency = Balances; - type EnactmentPeriod = EnactmentPeriod; - type LaunchPeriod = LaunchPeriod; - type VotingPeriod = VotingPeriod; - type VoteLockingPeriod = VoteLockingPeriod; - type MinimumDeposit = MinimumDeposit; - /// A straight majority of the council can decide what their next motion is. - type ExternalOrigin = EitherOfDiverse< - pallet_collective::EnsureProportionAtLeast, - EnsureRoot, - >; - /// A 60% super-majority can have the next scheduled referendum be a straight majority-carries vote. - type ExternalMajorityOrigin = EitherOfDiverse< - pallet_collective::EnsureProportionAtLeast, - EnsureRoot, - >; - /// A unanimous council can have the next scheduled referendum be a straight default-carries - /// (NTB) vote. - type ExternalDefaultOrigin = EitherOfDiverse< - pallet_collective::EnsureProportionAtLeast, - EnsureRoot, - >; - type SubmitOrigin = EnsureSigned; - /// Two thirds of the technical committee can have an `ExternalMajority/ExternalDefault` vote - /// be tabled immediately and with a shorter voting/enactment period. - type FastTrackOrigin = EitherOfDiverse< - pallet_collective::EnsureProportionAtLeast, - EnsureRoot, - >; - type InstantOrigin = EitherOfDiverse< - pallet_collective::EnsureProportionAtLeast, - EnsureRoot, - >; - type InstantAllowed = InstantAllowed; - type FastTrackVotingPeriod = FastTrackVotingPeriod; - // To cancel a proposal which has been passed, 2/3 of the council must agree to it. - type CancellationOrigin = EitherOfDiverse< - pallet_collective::EnsureProportionAtLeast, - EnsureRoot, - >; - // To cancel a proposal before it has been passed, the technical committee must be unanimous or - // Root must agree. - type CancelProposalOrigin = EitherOfDiverse< - pallet_collective::EnsureProportionAtLeast, - EnsureRoot, - >; - type BlacklistOrigin = EnsureRoot; - // Any single technical committee member may veto a coming council proposal, however they can - // only do it once and it lasts only for the cooloff period. - type VetoOrigin = pallet_collective::EnsureMember; - type CooloffPeriod = CooloffPeriod; - // The amount of balance that must be deposited per byte of preimage stored. - type Slash = Treasury; - type Scheduler = Scheduler; - type MaxVotes = ConstU32<100>; - type PalletsOrigin = OriginCaller; - type WeightInfo = pallet_democracy::weights::SubstrateWeight; - type MaxProposals = ConstU32<100>; - type Preimages = Preimage; - type MaxDeposits = ConstU32<100>; - type MaxBlacklisted = ConstU32<100>; -} - impl pallet_sudo::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; @@ -1126,8 +975,7 @@ pub enum ProxyType { Balances, /// All Runtime calls from Pallet Assets allowed for proxy account Assets, - /// Only Runtime Calls related to governance for proxy account - /// To know exact calls check InstanceFilter implementation for ProxyTypes + /// Not used at the moment, but kept for backwards compatibility. Governance, /// Only provide_judgement call from pallet identity allowed for proxy account IdentityJudgement, @@ -1180,12 +1028,7 @@ impl InstanceFilter for ProxyType { | RuntimeCall::XcAssetConfig(..) // Skip entire EVM pallet // Skip entire Ethereum pallet - | RuntimeCall::DynamicEvmBaseFee(..) - // Skip entire Contracts pallet - | RuntimeCall::Democracy(..) - | RuntimeCall::Council(..) - | RuntimeCall::TechnicalCommittee(..) - | RuntimeCall::Treasury(..) + | RuntimeCall::DynamicEvmBaseFee(..) // Skip entire Contracts pallet ) } // All Runtime calls from Pallet Balances allowed for proxy account @@ -1196,15 +1039,6 @@ impl InstanceFilter for ProxyType { ProxyType::Assets => { matches!(c, RuntimeCall::Assets(..)) } - ProxyType::Governance => { - matches!( - c, - RuntimeCall::Democracy(..) - | RuntimeCall::Council(..) - | RuntimeCall::TechnicalCommittee(..) - | RuntimeCall::Treasury(..) - ) - } // Only provide_judgement call from pallet identity allowed for proxy account ProxyType::IdentityJudgement => { matches!( @@ -1231,6 +1065,8 @@ impl InstanceFilter for ProxyType { ) ) } + // Not used at the moment, but kept for backwards compatibility. + ProxyType::Governance => false, } } @@ -1287,11 +1123,6 @@ impl pallet_unified_accounts::Config for Runtime { type WeightInfo = pallet_unified_accounts::weights::SubstrateWeight; } -impl pallet_dapp_staking_migration::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type WeightInfo = pallet_dapp_staking_migration::weights::SubstrateWeight; -} - construct_runtime!( pub struct Runtime { @@ -1336,18 +1167,12 @@ construct_runtime!( Contracts: pallet_contracts = 70, - Democracy: pallet_democracy = 80, - Council: pallet_collective:: = 81, - TechnicalCommittee: pallet_collective:: = 82, - Treasury: pallet_treasury = 83, Preimage: pallet_preimage = 84, Xvm: pallet_xvm = 90, Sudo: pallet_sudo = 99, - // Remove after migrating to v6 storage - DappStakingMigration: pallet_dapp_staking_migration = 252, // To be removed & cleaned up once proper oracle is implemented StaticPriceProvider: pallet_static_price_provider = 253, } @@ -1390,8 +1215,7 @@ pub type Executive = frame_executive::Executive< /// All migrations that will run on the next runtime upgrade. /// /// Once done, migrations should be removed from the tuple. -pub type Migrations = - (pallet_dapp_staking_migration::SingularStakingInfoTranslationUpgrade,); +pub type Migrations = (); type EventRecord = frame_system::EventRecord< ::RuntimeEvent, @@ -1479,7 +1303,6 @@ mod benches { [pallet_unified_accounts, UnifiedAccounts] [xcm_benchmarks_generic, XcmGeneric] [xcm_benchmarks_fungible, XcmFungible] - [pallet_dapp_staking_migration, DappStakingMigration] ); } diff --git a/runtime/shibuya/src/xcm_config.rs b/runtime/shibuya/src/xcm_config.rs index 4c46ecdef1..a7b63c4073 100644 --- a/runtime/shibuya/src/xcm_config.rs +++ b/runtime/shibuya/src/xcm_config.rs @@ -31,6 +31,8 @@ use frame_system::EnsureRoot; use sp_runtime::traits::{Convert, MaybeEquivalence}; // Polkadot imports +use cumulus_primitives_core::ParaId; +use polkadot_runtime_common::xcm_sender::NoPriceForMessageDelivery; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowUnpaidExecutionFrom, @@ -263,7 +265,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime { type ExecuteOverweightOrigin = EnsureRoot; type ControllerOrigin = EnsureRoot; type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin; - type PriceForSiblingDelivery = (); + type PriceForSiblingDelivery = NoPriceForMessageDelivery; type WeightInfo = cumulus_pallet_xcmp_queue::weights::SubstrateWeight; } diff --git a/runtime/shiden/src/xcm_config.rs b/runtime/shiden/src/xcm_config.rs index d007a0f5e4..a1ff693b3e 100644 --- a/runtime/shiden/src/xcm_config.rs +++ b/runtime/shiden/src/xcm_config.rs @@ -31,6 +31,8 @@ use frame_system::EnsureRoot; use sp_runtime::traits::{Convert, MaybeEquivalence}; // Polkadot imports +use cumulus_primitives_core::ParaId; +use polkadot_runtime_common::xcm_sender::NoPriceForMessageDelivery; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowUnpaidExecutionFrom, @@ -336,7 +338,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime { type ExecuteOverweightOrigin = EnsureRoot; type ControllerOrigin = EnsureRoot; type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin; - type PriceForSiblingDelivery = (); + type PriceForSiblingDelivery = NoPriceForMessageDelivery; type WeightInfo = cumulus_pallet_xcmp_queue::weights::SubstrateWeight; } From 18b99ebd6f89a7e3329c7408d8c3673e39e1da0e Mon Sep 17 00:00:00 2001 From: Dino Pacandi Date: Wed, 27 Mar 2024 08:31:20 +0100 Subject: [PATCH 03/19] Further cleanup --- Cargo.lock | 52 - pallets/dapps-staking/Cargo.toml | 62 - pallets/dapps-staking/README.md | 85 - pallets/dapps-staking/src/benchmarking.rs | 320 --- pallets/dapps-staking/src/lib.rs | 569 ----- pallets/dapps-staking/src/mock.rs | 280 --- pallets/dapps-staking/src/pallet/mod.rs | 1422 ----------- pallets/dapps-staking/src/testing_utils.rs | 738 ------ pallets/dapps-staking/src/tests.rs | 2604 -------------------- pallets/dapps-staking/src/tests_lib.rs | 310 --- pallets/dapps-staking/src/weights.rs | 422 ---- precompiles/dapps-staking/Cargo.toml | 56 - precompiles/dapps-staking/DappsStaking.sol | 90 - precompiles/dapps-staking/src/lib.rs | 439 ---- precompiles/dapps-staking/src/mock.rs | 407 --- precompiles/dapps-staking/src/tests.rs | 684 ----- runtime/astar/Cargo.toml | 2 - tests/integration/Cargo.toml | 1 - tests/xcm-simulator/Cargo.toml | 2 - tests/xcm-simulator/src/mocks/parachain.rs | 54 +- 20 files changed, 8 insertions(+), 8591 deletions(-) delete mode 100644 pallets/dapps-staking/Cargo.toml delete mode 100644 pallets/dapps-staking/README.md delete mode 100644 pallets/dapps-staking/src/benchmarking.rs delete mode 100644 pallets/dapps-staking/src/lib.rs delete mode 100644 pallets/dapps-staking/src/mock.rs delete mode 100644 pallets/dapps-staking/src/pallet/mod.rs delete mode 100644 pallets/dapps-staking/src/testing_utils.rs delete mode 100644 pallets/dapps-staking/src/tests.rs delete mode 100644 pallets/dapps-staking/src/tests_lib.rs delete mode 100644 pallets/dapps-staking/src/weights.rs delete mode 100644 precompiles/dapps-staking/Cargo.toml delete mode 100644 precompiles/dapps-staking/DappsStaking.sol delete mode 100644 precompiles/dapps-staking/src/lib.rs delete mode 100644 precompiles/dapps-staking/src/mock.rs delete mode 100644 precompiles/dapps-staking/src/tests.rs diff --git a/Cargo.lock b/Cargo.lock index 4cc74bbad7..91842f4834 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -795,7 +795,6 @@ dependencies = [ "pallet-contracts-primitives", "pallet-dapp-staking-migration", "pallet-dapp-staking-v3", - "pallet-dapps-staking", "pallet-dynamic-evm-base-fee", "pallet-ethereum", "pallet-evm", @@ -5720,7 +5719,6 @@ dependencies = [ "pallet-contracts", "pallet-contracts-primitives", "pallet-dapp-staking-v3", - "pallet-dapps-staking", "pallet-ethereum-checked", "pallet-evm", "pallet-evm-precompile-assets-erc20", @@ -8426,30 +8424,6 @@ dependencies = [ "sp-std", ] -[[package]] -name = "pallet-dapps-staking" -version = "3.10.0" -dependencies = [ - "assert_matches", - "astar-primitives", - "frame-benchmarking", - "frame-support", - "frame-system", - "num-traits", - "pallet-balances", - "pallet-session", - "pallet-timestamp", - "parity-scale-codec", - "scale-info", - "serde", - "sp-arithmetic", - "sp-core", - "sp-io", - "sp-runtime", - "sp-staking", - "sp-std", -] - [[package]] name = "pallet-democracy" version = "4.0.0-dev" @@ -8700,31 +8674,6 @@ dependencies = [ "sp-std", ] -[[package]] -name = "pallet-evm-precompile-dapps-staking" -version = "3.6.3" -dependencies = [ - "derive_more", - "fp-evm", - "frame-support", - "frame-system", - "log", - "num_enum 0.5.11", - "pallet-balances", - "pallet-dapps-staking", - "pallet-evm", - "pallet-timestamp", - "parity-scale-codec", - "precompile-utils", - "scale-info", - "serde", - "sha3", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", -] - [[package]] name = "pallet-evm-precompile-dispatch" version = "2.0.0-dev" @@ -17811,7 +17760,6 @@ dependencies = [ "pallet-balances", "pallet-contracts", "pallet-contracts-primitives", - "pallet-dapps-staking", "pallet-insecure-randomness-collective-flip", "pallet-message-queue", "pallet-proxy", diff --git a/pallets/dapps-staking/Cargo.toml b/pallets/dapps-staking/Cargo.toml deleted file mode 100644 index dfd7033893..0000000000 --- a/pallets/dapps-staking/Cargo.toml +++ /dev/null @@ -1,62 +0,0 @@ -[package] -name = "pallet-dapps-staking" -version = "3.10.0" -description = "FRAME pallet to staking for dapps" -authors.workspace = true -edition.workspace = true -homepage.workspace = true -repository.workspace = true - -[dependencies] -frame-support = { workspace = true } -frame-system = { workspace = true } -num-traits = { workspace = true } -parity-scale-codec = { workspace = true } - -astar-primitives = { workspace = true } -scale-info = { workspace = true } -serde = { workspace = true, optional = true } -sp-arithmetic = { workspace = true } -sp-core = { workspace = true } -sp-io = { workspace = true } -sp-runtime = { workspace = true } -sp-staking = { workspace = true } -sp-std = { workspace = true } - -frame-benchmarking = { workspace = true, optional = true } - -[dev-dependencies] -assert_matches = { workspace = true } -pallet-balances = { workspace = true } -pallet-session = { workspace = true } -pallet-timestamp = { workspace = true } - -[features] -default = ["std"] -std = [ - "serde", - "parity-scale-codec/std", - "scale-info/std", - "num-traits/std", - "sp-core/std", - "sp-runtime/std", - "sp-arithmetic/std", - "sp-io/std", - "sp-std/std", - "frame-support/std", - "frame-system/std", - "pallet-balances/std", - "pallet-session/std", - "pallet-timestamp/std", - "sp-staking/std", - "frame-benchmarking?/std", - "astar-primitives/std", -] -runtime-benchmarks = [ - "frame-benchmarking", - "frame-support/runtime-benchmarks", - "frame-system/runtime-benchmarks", - "sp-runtime/runtime-benchmarks", - "astar-primitives/runtime-benchmarks", -] -try-runtime = ["frame-support/try-runtime"] diff --git a/pallets/dapps-staking/README.md b/pallets/dapps-staking/README.md deleted file mode 100644 index d8ec211a11..0000000000 --- a/pallets/dapps-staking/README.md +++ /dev/null @@ -1,85 +0,0 @@ -# Pallet dapps-staking RPC API -This document describes the interface for the pallet-dapps-staking. - -Table of Contents: -1. [Terminology](#Terminology) -2. [Referent implementatio](#Referent) -3. [FAQ](#FAQ) - -## Terminology -### Actors in dApps Staking - -- `developer`: a developer or organization who deploys the smart contract -- `staker`: any Astar user who stakes tokens on the developer's smart contract - - -### Abbreviations and Terminology -- `dApp`: decentralized application, is an application that runs on a distributed network. -- `smart contract`: on-chain part of the dApp -- `contract`: short for smart contract -- `EVM`: Ethereum Virtual Machine. Solidity Smart contract runs on it. -- `ink!`: Smart Contract written in Rust, compiled to WASM. -- `era`: Period of time. After it ends, rewards can be claimed. It is defined by the number of produced blocks. Duration of an era for this pallet is configurable. The exact duration depends on block production duration. -- `claim`: Claim ownership of the rewards from the contract's reward pool. -- `bond`: Freeze funds to gain rewards. -- `stake`: In this pallet a staker stakes bonded funds on a smart contract . -- `unstake`: Unfreeze bonded funds and stop gaining rewards. -- `wasm`: Web Assembly. -- `contracts's reward pool`: Sum of unclaimed rewards on the contract. Including developer and staker parts. - ---- - ---- -## Referent API implementation -https://github.com/AstarNetwork/astar-apps - ---- -## FAQ - -### Does it matter which project I stake on? -It matters because this means you're supporting that project. -Project reward is calculated based on how much stakers have staked on that project. -You want to support good projects which bring value to the ecosystem since that will make -the ecosystem more valuable, increasing the value of your tokens as a result. - -Use the power you have and make sure to stake on projects you support and find beneficial. - -### Does my reward depend on the project I stake on? -No, the reward you get only depends on the total amount you have staked, invariant of dapp(s) on which you staked. -This allows you to select the dapp you like and want to support, without having to worry if you'll be earning less rewards than you -would if you staked on another dapp. - -### When do the projects/developers get their rewards? -Rewards will be deposited to beneficiaries once either `claim_staker` or `claim_dapp` is called. -We advise users to use our official portal for claiming rewards since the complexity of the protocol is hidden there. - -### What happens if nobody calls the claim function for a long time? -At the moment, there is no history depth limit and your reward will be waiting for you. -However, this will be changed in the future. - -### When developers register their dApp, which has no contract yet, what kind of address do they need to input? -There has to be a contract. Registration can’t be done without the contract. - -### Can projects/developers change contract address once it is registered for dApps staking? -The contract address can't be changed for the dApps staking. However, if the project needs to deploy new version of the contract, they can still use old (registered) contract address for dApp staking purposes. - -### How do projects/developers (who joins dApps staking) get their stakers' address and the amount staked? -`GeneralStakerInfo` storage item can be checked. -This would require developer to fetch all values from the map and find the ones where second key equals that of the contract they are interested in. -If the last staked value is greater than `Zero`, it means staker (first key) is staking on that contract. - -### What is the maximum numbers of stakers per dapps? -Please check in the source code constant `MaxNumberOfStakersPerContract`. - -### What is the minimum numbers of stakers per dapps? -Please check in the source code constant `MinimumStakingAmount`. - -### When developers register their dApp, can they registar WASM contract? (If not, can they update it in the future?) -The developers can register several dApps. But they need to use separate accounts and separate contract addresses. -The rule is - -```1 developer <=> 1 contract``` - -### Does dApps staking supports Wasm contracts? -Yes. -Once the Wasm contracts are enabled on a parachain, Wasm contract could be used for dApps staking. diff --git a/pallets/dapps-staking/src/benchmarking.rs b/pallets/dapps-staking/src/benchmarking.rs deleted file mode 100644 index ce259ad217..0000000000 --- a/pallets/dapps-staking/src/benchmarking.rs +++ /dev/null @@ -1,320 +0,0 @@ -// This file is part of Astar. - -// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later - -// Astar 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. - -// Astar 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 Astar. If not, see . - -#![cfg(feature = "runtime-benchmarks")] - -use super::*; -use crate::Pallet as DappsStaking; - -use frame_benchmarking::{account, benchmarks, impl_benchmark_test_suite, whitelisted_caller}; -use frame_support::traits::{Currency, Get, OnFinalize, OnInitialize}; -use frame_system::{Pallet as System, RawOrigin}; -use sp_runtime::traits::{One, TrailingZeroInput}; - -const SEED: u32 = 9000; -const STAKER_BLOCK_REWARD: u32 = 1234u32; -const DAPP_BLOCK_REWARD: u32 = 9876u32; - -/// Used to prepare Dapps staking for testing. -/// Resets all existing storage ensuring a clean run for the code that follows. -/// -/// Also initializes the first block which should start a new era. -fn initialize() { - // Remove everything from storage. - let _ = Ledger::::clear(u32::MAX, None); - let _ = RegisteredDevelopers::::clear(u32::MAX, None); - let _ = RegisteredDapps::::clear(u32::MAX, None); - let _ = GeneralEraInfo::::clear(u32::MAX, None); - let _ = ContractEraStake::::clear(u32::MAX, None); - let _ = GeneralStakerInfo::::clear(u32::MAX, None); - CurrentEra::::kill(); - BlockRewardAccumulator::::kill(); - - // Initialize the first block. - payout_block_rewards::(); - DappsStaking::::on_initialize(1u32.into()); -} - -/// Generate an unique smart contract using the provided index as a sort-of indetifier -fn smart_contract(index: u8) -> T::SmartContract { - // This is a hacky approach to provide different smart contracts without touching the smart contract trait. - // In case this proves troublesome in the future, recommendation is to just replace it with - // runtime-benchmarks only trait that allows us to construct an arbitrary valid smart contract instance. - let mut encoded_smart_contract = T::SmartContract::default().encode(); - *encoded_smart_contract.last_mut().unwrap() = index; - - Decode::decode(&mut TrailingZeroInput::new(encoded_smart_contract.as_ref())) - .expect("Shouldn't occur as long as EVM is the default type.") -} - -/// Payout block rewards to stakers & dapps -fn payout_block_rewards() { - DappsStaking::::rewards( - T::Currency::issue(STAKER_BLOCK_REWARD.into()), - T::Currency::issue(DAPP_BLOCK_REWARD.into()), - ); -} - -/// Assert that the last event equals the provided one. -fn assert_last_event(generic_event: ::RuntimeEvent) { - frame_system::Pallet::::assert_last_event(generic_event.into()); -} - -/// Advance to the specified era, block by block. -fn advance_to_era(n: EraIndex) { - while DappsStaking::::current_era() < n { - DappsStaking::::on_finalize(System::::block_number()); - System::::set_block_number(System::::block_number() + One::one()); - // This is performed outside of dapps staking but we expect it before on_initialize - payout_block_rewards::(); - DappsStaking::::on_initialize(System::::block_number()); - } -} - -/// Used to register a contract by a developer account. -/// -/// Registered contract is returned. -fn register_contract( - index: u8, -) -> Result<(T::AccountId, T::SmartContract), &'static str> { - let developer: T::AccountId = account("developer", index.into(), SEED); - let smart_contract = smart_contract::(index); - T::Currency::make_free_balance_be(&developer, Balance::max_value()); - DappsStaking::::register( - RawOrigin::Root.into(), - developer.clone(), - smart_contract.clone(), - )?; - - Ok((developer, smart_contract)) -} - -/// Used to bond_and_stake the given contract with the specified amount of stakers. -/// Method will create new staker accounts using the provided seed. -/// -/// Returns all created staker accounts in a vector. -fn prepare_bond_and_stake( - number_of_stakers: u32, - contract_id: &T::SmartContract, - seed: u32, -) -> Result, &'static str> { - let stake_balance = T::MinimumStakingAmount::get(); // maybe make this an argument? - let mut stakers = Vec::new(); - - for id in 0..number_of_stakers { - let staker_acc: T::AccountId = account("pre_staker", id, seed); - stakers.push(staker_acc.clone()); - T::Currency::make_free_balance_be(&staker_acc, Balance::max_value()); - - DappsStaking::::bond_and_stake( - RawOrigin::Signed(staker_acc).into(), - contract_id.clone(), - stake_balance, - )?; - } - - Ok(stakers) -} - -benchmarks! { - - register { - initialize::(); - let developer_id = whitelisted_caller(); - let contract_id = T::SmartContract::default(); - T::Currency::make_free_balance_be(&developer_id, Balance::max_value()); - }: _(RawOrigin::Root, developer_id.clone(), contract_id.clone()) - verify { - assert_last_event::(Event::::NewContract(developer_id, contract_id).into()); - } - - unregister { - initialize::(); - let (developer_id, contract_id) = register_contract::(1)?; - prepare_bond_and_stake::(1, &contract_id, SEED)?; - - }: _(RawOrigin::Root, contract_id.clone()) - verify { - assert_last_event::(Event::::ContractRemoved(developer_id, contract_id).into()); - } - - withdraw_from_unregistered { - initialize::(); - let (developer, contract_id) = register_contract::(1)?; - let stakers = prepare_bond_and_stake::(1, &contract_id, SEED)?; - let staker = stakers[0].clone(); - let stake_amount = Balance::max_value() / 2u128; - - DappsStaking::::bond_and_stake(RawOrigin::Signed(staker.clone()).into(), contract_id.clone(), stake_amount)?; - DappsStaking::::unregister(RawOrigin::Root.into(), contract_id.clone())?; - }: _(RawOrigin::Signed(staker.clone()), contract_id.clone()) - verify { - let staker_info = DappsStaking::::staker_info(&staker, &contract_id); - assert!(staker_info.latest_staked_value().is_zero()); - } - - bond_and_stake { - initialize::(); - - let (_, contract_id) = register_contract::(1)?; - - let staker = whitelisted_caller(); - let _ = T::Currency::make_free_balance_be(&staker, Balance::max_value()); - let amount = Balance::max_value() / 2u128; - - }: _(RawOrigin::Signed(staker.clone()), contract_id.clone(), amount) - verify { - assert_last_event::(Event::::BondAndStake(staker, contract_id, amount).into()); - } - - unbond_and_unstake { - initialize::(); - - let (_, contract_id) = register_contract::(1)?; - - let staker = whitelisted_caller(); - let _ = T::Currency::make_free_balance_be(&staker, Balance::max_value()); - let amount = Balance::max_value() / 2u128; - - DappsStaking::::bond_and_stake(RawOrigin::Signed(staker.clone()).into(), contract_id.clone(), amount)?; - - }: _(RawOrigin::Signed(staker.clone()), contract_id.clone(), amount) - verify { - assert_last_event::(Event::::UnbondAndUnstake(staker, contract_id, amount).into()); - } - - withdraw_unbonded { - initialize::(); - - let (_, contract_id) = register_contract::(1)?; - - let staker = whitelisted_caller(); - let _ = T::Currency::make_free_balance_be(&staker, Balance::max_value()); - let stake_amount = Balance::max_value() / 2u128; - let unstake_amount = stake_amount / 2u128; - - DappsStaking::::bond_and_stake(RawOrigin::Signed(staker.clone()).into(), contract_id.clone(), stake_amount)?; - DappsStaking::::unbond_and_unstake(RawOrigin::Signed(staker.clone()).into(), contract_id, unstake_amount)?; - - let current_era = DappsStaking::::current_era(); - advance_to_era::(current_era + 1 + T::UnbondingPeriod::get()); - - }: _(RawOrigin::Signed(staker.clone())) - verify { - assert_last_event::(Event::::Withdrawn(staker, unstake_amount).into()); - } - - nomination_transfer { - initialize::(); - - let (_, origin_contract_id) = register_contract::(1)?; - let (_, target_contract_id) = register_contract::(2)?; - - let staker = prepare_bond_and_stake::(1, &origin_contract_id, SEED)?[0].clone(); - - }: _(RawOrigin::Signed(staker.clone()), origin_contract_id.clone(), T::MinimumStakingAmount::get(), target_contract_id.clone()) - verify { - assert_last_event::(Event::::NominationTransfer(staker, origin_contract_id, T::MinimumStakingAmount::get(), target_contract_id).into()); - } - - claim_staker_with_restake { - initialize::(); - let (_, contract_id) = register_contract::(1)?; - - let claim_era = DappsStaking::::current_era(); - let stakers = prepare_bond_and_stake::(1, &contract_id, SEED)?; - let staker = stakers[0].clone(); - - DappsStaking::::set_reward_destination(RawOrigin::Signed(staker.clone()).into(), RewardDestination::StakeBalance)?; - advance_to_era::(claim_era + 1u32); - - }: claim_staker(RawOrigin::Signed(staker.clone()), contract_id.clone()) - verify { - let mut staker_info = DappsStaking::::staker_info(&staker, &contract_id); - let (era, _) = staker_info.claim(); - assert!(era > claim_era); - } - - claim_staker_without_restake { - initialize::(); - let (_, contract_id) = register_contract::(1)?; - - let claim_era = DappsStaking::::current_era(); - let stakers = prepare_bond_and_stake::(1, &contract_id, SEED)?; - let staker = stakers[0].clone(); - - DappsStaking::::set_reward_destination(RawOrigin::Signed(staker.clone()).into(), RewardDestination::FreeBalance)?; - advance_to_era::(claim_era + 1u32); - - }: claim_staker(RawOrigin::Signed(staker.clone()), contract_id.clone()) - verify { - let mut staker_info = DappsStaking::::staker_info(&staker, &contract_id); - let (era, _) = staker_info.claim(); - assert!(era > claim_era); - } - - claim_dapp { - initialize::(); - let (developer, contract_id) = register_contract::(1)?; - - let claim_era = DappsStaking::::current_era(); - prepare_bond_and_stake::(1, &contract_id, SEED)?; - advance_to_era::(claim_era + 1u32); - - }: _(RawOrigin::Signed(developer.clone()), contract_id.clone(), claim_era) - verify { - let staking_info = DappsStaking::::contract_stake_info(&contract_id, claim_era).unwrap(); - assert!(staking_info.contract_reward_claimed); - } - - force_new_era { - }: _(RawOrigin::Root) - - maintenance_mode { - }: _(RawOrigin::Root, true) - - set_reward_destination { - initialize::(); - - let option = RewardDestination::FreeBalance; - let (_, contract_id) = register_contract::(1)?; - - let stakers = prepare_bond_and_stake::(1, &contract_id, SEED)?; - let staker = stakers[0].clone(); - }: _(RawOrigin::Signed(staker.clone()), option) - verify { - assert_last_event::(Event::::RewardDestination(staker, option).into()); - } - -} - -#[cfg(test)] -mod tests { - use crate::mock; - use sp_io::TestExternalities; - - pub fn new_test_ext() -> TestExternalities { - mock::ExternalityBuilder::build() - } -} - -impl_benchmark_test_suite!( - DappsStaking, - crate::benchmarking::tests::new_test_ext(), - crate::mock::TestRuntime, -); diff --git a/pallets/dapps-staking/src/lib.rs b/pallets/dapps-staking/src/lib.rs deleted file mode 100644 index 8ad9ae89c0..0000000000 --- a/pallets/dapps-staking/src/lib.rs +++ /dev/null @@ -1,569 +0,0 @@ -// This file is part of Astar. - -// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later - -// Astar 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. - -// Astar 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 Astar. If not, see . - -//! # Dapps Staking Pallet -//! -//! - [`Config`] -//! -//! ## Overview -//! -//! Pallet that implements dapps staking protocol. -//! -//! Dapps staking protocol is a completely decentralized & innovative approach to reward developers for their contribution to the Astar/Shiden ecosystem. -//! Stakers can pick a dapp and nominate it for rewards by locking their tokens. Dapps will be rewarded, based on the proportion of locked tokens. -//! Stakers are also rewarded, based on the total amount they've locked (invariant of the dapp they staked on). -//! -//! Rewards are accumulated throughout an **era** and when **era** finishes, both stakers and developers can claim their rewards for that era. -//! This is a continous process. Rewards can be claimed even for eras which are older than the last one (no limit at the moment). -//! -//! Reward claiming isn't automated since the whole process is done **on-chain** and is fully decentralized. -//! Both stakers and developers are responsible for claiming their own rewards. -//! -//! -//! ## Interface -//! -//! ### Dispatchable Function -//! -//! - `register` - used to register a new contract for dapps staking -//! - `unregister` - used to unregister contract from dapps staking, making it ineligible for receiveing future rewards -//! - `withdraw_from_unregistered` - used by stakers to withdraw their stake from an unregistered contract (no unbonding period) -//! - `bond_and_stake` - basic call for nominating a dapp and locking stakers tokens into dapps staking -//! - `unbond_and_unstake` - removes nomination from the contract, starting the unbonding process for the unstaked funds -//! - `withdraw_unbonded` - withdraws all funds that have completed the unbonding period -//! - `nomination_transfer` - transfer nomination from one contract to another contract (avoids unbonding period) -//! - `claim_staker` - claims staker reward for a single era -//! - `claim_dapp` - claims dapp rewards for the specified era -//! - `force_new_era` - forces new era on the start of the next block -//! - `maintenance_mode` - enables or disables pallet maintenance mode -//! - `set_reward_destination` - sets reward destination for the staker rewards -//! - `set_contract_stake_info` - root-only call to set storage value (used for fixing corrupted data) -//! - `burn_stale_reward` - root-only call to burn unclaimed, stale rewards from unregistered contracts -//! -//! User is encouraged to refer to specific function implementations for more comprehensive documentation. -//! -//! ### Other -//! -//! - `on_initialize` - part of `Hooks` trait, it's important to call this per block since it handles reward snapshots and era advancement. -//! - `account_id` - returns pallet's account Id -//! - `ensure_pallet_enabled` - checks whether pallet is in maintenance mode or not and returns appropriate `Result` -//! - `rewards` - used to deposit staker and dapps rewards into dApps staking reward pool -//! - `tvl` - total value locked in dApps staking (might differ from total staked value) -//! -#![cfg_attr(not(feature = "std"), no_std)] - -use astar_primitives::Balance; -use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; -use scale_info::TypeInfo; -use sp_runtime::{traits::Zero, RuntimeDebug}; -use sp_std::prelude::*; -pub mod pallet; -pub mod weights; - -#[cfg(any(feature = "runtime-benchmarks"))] -pub mod benchmarking; -#[cfg(test)] -mod mock; -#[cfg(test)] -mod testing_utils; -#[cfg(test)] -mod tests; -#[cfg(test)] -mod tests_lib; - -pub use pallet::pallet::*; -pub use weights::WeightInfo; - -/// Counter for the number of eras that have passed. -pub type EraIndex = u32; - -// This represents the max assumed vector length that any storage item should have. -// In particular, this relates to `UnbondingInfo` and `StakerInfo`. -// In structs which are bound in size, `MaxEncodedLen` can just be derived but that's not the case for standard `vec`. -// To fix this 100% correctly, we'd need to do one of the following: -// -// - Use `BoundedVec` instead of `Vec` and do storage migration -// - Introduce a new type `S: Get` into the aforementioned structs and use it to inject max allowed size, -// thus allowing us to correctly calculate max encoded len -// -// The issue with first approach is that it requires storage migration which we want to avoid -// unless it's really necessary. The issue with second approach is that it makes code much more -// difficult to work with since all of it will be ridden with injections of the `S` type. -// -// Since dApps staking has been stable for long time and there are plans to redesign & refactor it, -// doing neither of the above makes sense, timewise. So we use an assumption that vec length -// won't go over the following constant. -const MAX_ASSUMED_VEC_LEN: u32 = 10; - -/// DApp State descriptor -#[derive(Copy, Clone, PartialEq, Eq, Encode, Decode, RuntimeDebug, TypeInfo, MaxEncodedLen)] -pub enum DAppState { - /// Contract is registered and active. - Registered, - /// Contract has been unregistered and is inactive. - /// Claim for past eras and unbonding is still possible but no additional staking can be done. - Unregistered(EraIndex), -} - -#[derive(Clone, PartialEq, Eq, Encode, Decode, RuntimeDebug, TypeInfo, MaxEncodedLen)] -pub struct DAppInfo { - /// Developer (owner) account - pub developer: AccountId, - /// Current DApp State - pub state: DAppState, -} - -impl DAppInfo { - /// Create new `DAppInfo` struct instance with the given developer and state `Registered` - fn new(developer: AccountId) -> Self { - Self { - developer, - state: DAppState::Registered, - } - } - - /// `true` if dApp has been unregistered, `false` otherwise - pub fn is_unregistered(&self) -> bool { - matches!(self.state, DAppState::Unregistered(_)) - } -} - -/// Mode of era-forcing. -#[derive(Copy, Clone, PartialEq, Eq, Encode, Decode, RuntimeDebug, TypeInfo, MaxEncodedLen)] -#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] -pub enum Forcing { - /// Not forcing anything - just let whatever happen. - NotForcing, - /// Force a new era, then reset to `NotForcing` as soon as it is done. - /// Note that this will force to trigger an election until a new era is triggered, if the - /// election failed, the next session end will trigger a new election again, until success. - ForceNew, -} - -impl Default for Forcing { - fn default() -> Self { - Forcing::NotForcing - } -} - -/// A record of rewards allocated for stakers and dapps -#[derive(PartialEq, Eq, Clone, Default, Encode, Decode, RuntimeDebug, TypeInfo, MaxEncodedLen)] -pub struct RewardInfo { - /// Total amount of rewards for stakers in an era - #[codec(compact)] - pub stakers: Balance, - /// Total amount of rewards for dapps in an era - #[codec(compact)] - pub dapps: Balance, -} - -/// A record for total rewards and total amount staked for an era -#[derive(PartialEq, Eq, Clone, Default, Encode, Decode, RuntimeDebug, TypeInfo, MaxEncodedLen)] -pub struct EraInfo { - /// Total amount of earned rewards for an era - pub rewards: RewardInfo, - /// Total staked amount in an era - #[codec(compact)] - pub staked: Balance, - /// Total locked amount in an era - #[codec(compact)] - pub locked: Balance, -} - -/// Used to split total EraPayout among contracts. -/// Each tuple (contract, era) has this structure. -/// This will be used to reward contracts developer and his stakers. -#[derive(Clone, PartialEq, Encode, Decode, Default, RuntimeDebug, TypeInfo, MaxEncodedLen)] -pub struct ContractStakeInfo { - /// Total staked amount. - #[codec(compact)] - pub total: Balance, - /// Total number of active stakers - #[codec(compact)] - number_of_stakers: u32, - /// Indicates whether rewards were claimed for this era or not - contract_reward_claimed: bool, -} - -/// Storage value representing the current Dapps staking pallet storage version. -/// Used by `on_runtime_upgrade` to determine whether a storage migration is needed or not. -#[derive(Encode, Decode, Clone, Copy, PartialEq, Eq, RuntimeDebug, TypeInfo, MaxEncodedLen)] -pub enum Version { - V1_0_0, - V2_0_0, - V3_0_0, - V4_0_0, -} - -impl Default for Version { - fn default() -> Self { - Version::V4_0_0 - } -} - -/// Used to represent how much was staked in a particular era. -/// E.g. `{staked: 1000, era: 5}` means that in era `5`, staked amount was 1000. -#[derive(Encode, Decode, Clone, Copy, PartialEq, Eq, RuntimeDebug, TypeInfo, MaxEncodedLen)] -pub struct EraStake { - /// Staked amount in era - #[codec(compact)] - staked: Balance, - /// Staked era - #[codec(compact)] - era: EraIndex, -} - -impl EraStake { - /// Create a new instance of `EraStake` with given values - fn new(staked: Balance, era: EraIndex) -> Self { - Self { staked, era } - } -} - -/// Used to provide a compact and bounded storage for information about stakes in unclaimed eras. -/// -/// In order to avoid creating a separate storage entry for each `(staker, contract, era)` triplet, -/// this struct is used to provide a more memory efficient solution. -/// -/// Basic idea is to store `EraStake` structs into a vector from which a complete -/// picture of **unclaimed eras** and stakes can be constructed. -/// -/// # Example -/// For simplicity, the following example will represent `EraStake` using `` notation. -/// Let us assume we have the following vector in `StakerInfo` struct. -/// -/// `[<5, 1000>, <6, 1500>, <8, 2100>, <9, 0>, <11, 500>]` -/// -/// This tells us which eras are unclaimed and how much it was staked in each era. -/// The interpretation is the following: -/// 1. In era **5**, staked amount was **1000** (interpreted from `<5, 1000>`) -/// 2. In era **6**, staker staked additional **500**, increasing total staked amount to **1500** -/// 3. No entry for era **7** exists which means there were no changes from the former entry. -/// This means that in era **7**, staked amount was also **1500** -/// 4. In era **8**, staker staked an additional **600**, increasing total stake to **2100** -/// 5. In era **9**, staker unstaked everything from the contract (interpreted from `<9, 0>`) -/// 6. No changes were made in era **10** so we can interpret this same as the previous entry which means **0** staked amount. -/// 7. In era **11**, staker staked **500** on the contract, making his stake active again after 2 eras of inactivity. -/// -/// **NOTE:** It is important to understand that staker **DID NOT** claim any rewards during this period. -/// -#[derive(Encode, Decode, Clone, Default, PartialEq, Eq, RuntimeDebug, TypeInfo)] -pub struct StakerInfo { - // Size of this list would be limited by a configurable constant - stakes: Vec, -} - -impl MaxEncodedLen for StakerInfo { - // This is just an assumption, will be calculated properly in the future. See the comment for `MAX_ASSUMED_VEC_LEN`. - fn max_encoded_len() -> usize { - parity_scale_codec::Compact(MAX_ASSUMED_VEC_LEN) - .encoded_size() - .saturating_add( - (MAX_ASSUMED_VEC_LEN as usize).saturating_mul(EraStake::max_encoded_len()), - ) - } -} - -impl StakerInfo { - /// `true` if no active stakes and unclaimed eras exist, `false` otherwise - fn is_empty(&self) -> bool { - self.stakes.is_empty() - } - - /// number of `EraStake` chunks - fn len(&self) -> u32 { - self.stakes.len() as u32 - } - - /// Stakes some value in the specified era. - /// - /// User should ensure that given era is either equal or greater than the - /// latest available era in the staking info. - /// - /// # Example - /// - /// The following example demonstrates how internal vector changes when `stake` is called: - /// - /// `stakes: [<5, 1000>, <7, 1300>]` - /// * `stake(7, 100)` will result in `[<5, 1000>, <7, 1400>]` - /// * `stake(9, 200)` will result in `[<5, 1000>, <7, 1400>, <9, 1600>]` - /// - fn stake(&mut self, current_era: EraIndex, value: Balance) -> Result<(), &str> { - if let Some(era_stake) = self.stakes.last_mut() { - if era_stake.era > current_era { - return Err("Unexpected era"); - } - - let new_stake_value = era_stake.staked.saturating_add(value); - - if current_era == era_stake.era { - *era_stake = EraStake::new(new_stake_value, current_era) - } else { - self.stakes - .push(EraStake::new(new_stake_value, current_era)) - } - } else { - self.stakes.push(EraStake::new(value, current_era)); - } - - Ok(()) - } - - /// Unstakes some value in the specified era. - /// - /// User should ensure that given era is either equal or greater than the - /// latest available era in the staking info. - /// - /// # Example 1 - /// - /// `stakes: [<5, 1000>, <7, 1300>]` - /// * `unstake(7, 100)` will result in `[<5, 1000>, <7, 1200>]` - /// * `unstake(9, 400)` will result in `[<5, 1000>, <7, 1200>, <9, 800>]` - /// * `unstake(10, 800)` will result in `[<5, 1000>, <7, 1200>, <9, 800>, <10, 0>]` - /// - /// # Example 2 - /// - /// `stakes: [<5, 1000>]` - /// * `unstake(5, 1000)` will result in `[]` - /// - /// Note that if no unclaimed eras remain, vector will be cleared. - /// - fn unstake(&mut self, current_era: EraIndex, value: Balance) -> Result<(), &str> { - if let Some(era_stake) = self.stakes.last_mut() { - if era_stake.era > current_era { - return Err("Unexpected era"); - } - - let new_stake_value = era_stake.staked.saturating_sub(value); - if current_era == era_stake.era { - *era_stake = EraStake::new(new_stake_value, current_era) - } else { - self.stakes - .push(EraStake::new(new_stake_value, current_era)) - } - - // Removes unstaked values if they're no longer valid for comprehension - if !self.stakes.is_empty() && self.stakes[0].staked.is_zero() { - self.stakes.remove(0); - } - } - - Ok(()) - } - - /// `Claims` the oldest era available for claiming. - /// In case valid era exists, returns `(claim era, staked amount)` tuple. - /// If no valid era exists, returns `(0, 0)` tuple. - /// - /// # Example - /// - /// The following example will demonstrate how the internal vec changes when `claim` is called consecutively. - /// - /// `stakes: [<5, 1000>, <7, 1300>, <8, 0>, <15, 3000>]` - /// - /// 1. `claim()` will return `(5, 1000)` - /// Internal vector is modified to `[<6, 1000>, <7, 1300>, <8, 0>, <15, 3000>]` - /// - /// 2. `claim()` will return `(6, 1000)`. - /// Internal vector is modified to `[<7, 1300>, <8, 0>, <15, 3000>]` - /// - /// 3. `claim()` will return `(7, 1300)`. - /// Internal vector is modified to `[<15, 3000>]` - /// Note that `0` staked period is discarded since nothing can be claimed there. - /// - /// 4. `claim()` will return `(15, 3000)`. - /// Internal vector is modified to `[16, 3000]` - /// - /// Repeated calls would continue to modify vector following the same rule as in *4.* - /// - fn claim(&mut self) -> (EraIndex, Balance) { - if let Some(era_stake) = self.stakes.first() { - let era_stake = *era_stake; - - if self.stakes.len() == 1 || self.stakes[1].era > era_stake.era + 1 { - self.stakes[0] = EraStake { - staked: era_stake.staked, - era: era_stake.era.saturating_add(1), - } - } else { - // in case: self.stakes[1].era == era_stake.era + 1 - self.stakes.remove(0); - } - - // Removes unstaked values if they're no longer valid for comprehension - if !self.stakes.is_empty() && self.stakes[0].staked.is_zero() { - self.stakes.remove(0); - } - - (era_stake.era, era_stake.staked) - } else { - (0, Zero::zero()) - } - } - - /// Latest staked value. - /// E.g. if staker is fully unstaked, this will return `Zero`. - /// Otherwise returns a non-zero balance. - pub fn latest_staked_value(&self) -> Balance { - self.stakes.last().map_or(Zero::zero(), |x| x.staked) - } -} - -/// Represents an balance amount undergoing the unbonding process. -/// Since unbonding takes time, it's important to keep track of when and how much was unbonded. -#[derive( - Clone, Copy, PartialEq, Encode, Decode, Default, RuntimeDebug, TypeInfo, MaxEncodedLen, -)] -pub struct UnlockingChunk { - /// Amount being unlocked - #[codec(compact)] - amount: Balance, - /// Era in which the amount will become unlocked and can be withdrawn. - #[codec(compact)] - unlock_era: EraIndex, -} - -impl UnlockingChunk { - // Adds the specified amount to this chunk - fn add_amount(&mut self, amount: Balance) { - self.amount = self.amount + amount - } -} - -/// Contains unlocking chunks. -/// This is a convenience struct that provides various utility methods to help with unbonding handling. -#[derive(Clone, PartialEq, Encode, Decode, Default, RuntimeDebug, TypeInfo)] -pub struct UnbondingInfo { - // Vector of unlocking chunks. Sorted in ascending order in respect to unlock_era. - unlocking_chunks: Vec, -} - -impl MaxEncodedLen for UnbondingInfo { - // This is just an assumption, will be calculated properly in the future. See the comment for `MAX_ASSUMED_VEC_LEN`. - fn max_encoded_len() -> usize { - parity_scale_codec::Compact(MAX_ASSUMED_VEC_LEN) - .encoded_size() - .saturating_add( - (MAX_ASSUMED_VEC_LEN as usize).saturating_mul(UnlockingChunk::max_encoded_len()), - ) - } -} - -impl UnbondingInfo { - /// Returns total number of unlocking chunks. - fn len(&self) -> u32 { - self.unlocking_chunks.len() as u32 - } - - /// True if no unlocking chunks exist, false otherwise. - fn is_empty(&self) -> bool { - self.unlocking_chunks.is_empty() - } - - /// Returns sum of all unlocking chunks. - pub fn sum(&self) -> Balance { - self.unlocking_chunks - .iter() - .map(|chunk| chunk.amount) - .reduce(|c1, c2| c1 + c2) - .unwrap_or_default() - } - - /// Adds a new unlocking chunk to the vector, preserving the unlock_era based ordering. - fn add(&mut self, chunk: UnlockingChunk) { - // It is possible that the unbonding period changes so we need to account for that - match self - .unlocking_chunks - .binary_search_by(|x| x.unlock_era.cmp(&chunk.unlock_era)) - { - // Merge with existing chunk if unlock_eras match - Ok(pos) => self.unlocking_chunks[pos].add_amount(chunk.amount), - // Otherwise insert where it should go. Note that this will in almost all cases return the last index. - Err(pos) => self.unlocking_chunks.insert(pos, chunk), - } - } - - /// Partitions the unlocking chunks into two groups: - /// - /// First group includes all chunks which have unlock era lesser or equal to the specified era. - /// Second group includes all the rest. - /// - /// Order of chunks is preserved in the two new structs. - fn partition(self, era: EraIndex) -> (Self, Self) { - let (matching_chunks, other_chunks): (Vec, Vec) = self - .unlocking_chunks - .iter() - .partition(|chunk| chunk.unlock_era <= era); - - ( - Self { - unlocking_chunks: matching_chunks, - }, - Self { - unlocking_chunks: other_chunks, - }, - ) - } - - #[cfg(test)] - /// Return clone of the internal vector. Should only be used for testing. - fn vec(&self) -> Vec { - self.unlocking_chunks.clone() - } -} - -/// Instruction on how to handle reward payout for stakers. -/// In order to make staking more competitive, majority of stakers will want to -/// automatically restake anything they earn. -#[derive(Encode, Decode, Clone, Copy, PartialEq, Eq, RuntimeDebug, TypeInfo, MaxEncodedLen)] -pub enum RewardDestination { - /// Rewards are transferred to stakers free balance without any further action. - FreeBalance, - /// Rewards are transferred to stakers balance and are immediately re-staked - /// on the contract from which the reward was received. - StakeBalance, -} - -impl Default for RewardDestination { - fn default() -> Self { - RewardDestination::FreeBalance - } -} - -/// Contains information about account's locked & unbonding balances. -#[derive(Clone, PartialEq, Encode, Decode, Default, RuntimeDebug, TypeInfo, MaxEncodedLen)] -pub struct AccountLedger { - /// Total balance locked. - #[codec(compact)] - pub locked: Balance, - /// Information about unbonding chunks. - pub unbonding_info: UnbondingInfo, - /// Instruction on how to handle reward payout - reward_destination: RewardDestination, -} - -impl AccountLedger { - /// `true` if ledger is empty (no locked funds, no unbonding chunks), `false` otherwise. - pub fn is_empty(&self) -> bool { - self.locked.is_zero() && self.unbonding_info.is_empty() - } - - /// Configured reward destination - pub fn reward_destination(&self) -> RewardDestination { - self.reward_destination - } -} diff --git a/pallets/dapps-staking/src/mock.rs b/pallets/dapps-staking/src/mock.rs deleted file mode 100644 index 3f325122cc..0000000000 --- a/pallets/dapps-staking/src/mock.rs +++ /dev/null @@ -1,280 +0,0 @@ -// This file is part of Astar. - -// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later - -// Astar 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. - -// Astar 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 Astar. If not, see . - -use crate::{self as pallet_dapps_staking, weights}; - -use frame_support::{ - construct_runtime, parameter_types, - traits::{Currency, OnFinalize, OnInitialize}, - weights::Weight, - PalletId, -}; -use sp_core::{H160, H256}; - -use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; -use sp_io::TestExternalities; -use sp_runtime::{ - traits::{BlakeTwo256, ConstBool, ConstU128, ConstU32, IdentityLookup}, - BuildStorage, -}; - -pub(crate) type AccountId = u64; -pub(crate) type BlockNumber = u64; -pub(crate) type Balance = u128; -pub(crate) type EraIndex = u32; - -type Block = frame_system::mocking::MockBlock; - -/// Value shouldn't be less than 2 for testing purposes, otherwise we cannot test certain corner cases. -pub(crate) const EXISTENTIAL_DEPOSIT: Balance = 2; -pub(crate) const MAX_NUMBER_OF_STAKERS: u32 = 4; -/// Value shouldn't be less than 2 for testing purposes, otherwise we cannot test certain corner cases. -pub(crate) const MINIMUM_STAKING_AMOUNT: Balance = 10; -pub(crate) const MINIMUM_REMAINING_AMOUNT: Balance = EXISTENTIAL_DEPOSIT; -pub(crate) const MAX_UNLOCKING_CHUNKS: u32 = 4; -pub(crate) const UNBONDING_PERIOD: EraIndex = 3; -pub(crate) const MAX_ERA_STAKE_VALUES: u32 = 8; -pub(crate) const REWARD_RETENTION_PERIOD: u32 = 2; - -// Do note that this needs to at least be 3 for tests to be valid. It can be greater but not smaller. -pub(crate) const BLOCKS_PER_ERA: BlockNumber = 3; - -pub(crate) const REGISTER_DEPOSIT: Balance = 10; - -pub(crate) const STAKER_BLOCK_REWARD: Balance = 531911; -pub(crate) const DAPP_BLOCK_REWARD: Balance = 773333; - -construct_runtime!( - pub struct TestRuntime { - System: frame_system, - Balances: pallet_balances, - Timestamp: pallet_timestamp, - DappsStaking: pallet_dapps_staking, - } -); - -parameter_types! { - pub const BlockHashCount: u64 = 250; - pub BlockWeights: frame_system::limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max(Weight::from_parts(1024, 0)); -} - -impl frame_system::Config for TestRuntime { - type BaseCallFilter = frame_support::traits::Everything; - type BlockWeights = (); - type BlockLength = (); - type RuntimeOrigin = RuntimeOrigin; - type Nonce = u64; - type RuntimeCall = RuntimeCall; - type Block = Block; - type Hash = H256; - type Hashing = BlakeTwo256; - type AccountId = AccountId; - type Lookup = IdentityLookup; - type RuntimeEvent = RuntimeEvent; - type BlockHashCount = BlockHashCount; - type DbWeight = (); - type Version = (); - type PalletInfo = PalletInfo; - type AccountData = pallet_balances::AccountData; - type OnNewAccount = (); - type OnKilledAccount = (); - type SystemWeightInfo = (); - type SS58Prefix = (); - type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; -} - -parameter_types! { - pub const MaxLocks: u32 = 4; - pub const ExistentialDeposit: Balance = EXISTENTIAL_DEPOSIT; -} - -impl pallet_balances::Config for TestRuntime { - type MaxLocks = MaxLocks; - type MaxReserves = (); - type ReserveIdentifier = [u8; 8]; - type Balance = Balance; - type RuntimeEvent = RuntimeEvent; - type DustRemoval = (); - type ExistentialDeposit = ExistentialDeposit; - type AccountStore = System; - type WeightInfo = (); - type RuntimeHoldReason = RuntimeHoldReason; - type FreezeIdentifier = (); - type RuntimeFreezeReason = (); - type MaxHolds = ConstU32<0>; - type MaxFreezes = ConstU32<0>; -} - -parameter_types! { - pub const MinimumPeriod: u64 = 3; -} - -impl pallet_timestamp::Config for TestRuntime { - type Moment = u64; - type OnTimestampSet = (); - type MinimumPeriod = MinimumPeriod; - type WeightInfo = (); -} - -parameter_types! { - pub const RegisterDeposit: Balance = REGISTER_DEPOSIT; - pub const BlockPerEra: BlockNumber = BLOCKS_PER_ERA; - pub const MaxNumberOfStakersPerContract: u32 = MAX_NUMBER_OF_STAKERS; - pub const MinimumStakingAmount: Balance = MINIMUM_STAKING_AMOUNT; - pub const DappsStakingPalletId: PalletId = PalletId(*b"mokdpstk"); - pub const MinimumRemainingAmount: Balance = MINIMUM_REMAINING_AMOUNT; - pub const MaxUnlockingChunks: u32 = MAX_UNLOCKING_CHUNKS; - pub const UnbondingPeriod: EraIndex = UNBONDING_PERIOD; - pub const MaxEraStakeValues: u32 = MAX_ERA_STAKE_VALUES; -} - -impl pallet_dapps_staking::Config for TestRuntime { - type RuntimeEvent = RuntimeEvent; - type Currency = Balances; - type BlockPerEra = BlockPerEra; - type RegisterDeposit = RegisterDeposit; - type SmartContract = MockSmartContract; - type WeightInfo = weights::SubstrateWeight; - type MaxNumberOfStakersPerContract = MaxNumberOfStakersPerContract; - type MinimumStakingAmount = MinimumStakingAmount; - type PalletId = DappsStakingPalletId; - type MinimumRemainingAmount = MinimumRemainingAmount; - type MaxUnlockingChunks = MaxUnlockingChunks; - type UnbondingPeriod = UnbondingPeriod; - type MaxEraStakeValues = MaxEraStakeValues; - type UnregisteredDappRewardRetention = ConstU32; - type ForcePalletDisabled = ConstBool; - type DelegateClaimFee = ConstU128<7>; -} - -#[derive( - PartialEq, Eq, Copy, Clone, Encode, Decode, Debug, scale_info::TypeInfo, MaxEncodedLen, -)] -pub enum MockSmartContract { - Evm(sp_core::H160), - Wasm(AccountId), -} - -impl Default for MockSmartContract { - fn default() -> Self { - MockSmartContract::Evm(H160::repeat_byte(0x01)) - } -} - -pub struct ExternalityBuilder; - -impl ExternalityBuilder { - pub fn build() -> TestExternalities { - let mut storage = frame_system::GenesisConfig::::default() - .build_storage() - .unwrap(); - - pallet_balances::GenesisConfig:: { - balances: vec![ - (1, 9000), - (2, 800), - (3, 10000), - (4, 4900), - (5, 3800), - (6, 20), - (7, 1000), - (8, 2000), - (9, 10000), - (10, 300), - (11, 400), - (20, 20), - (540, EXISTENTIAL_DEPOSIT), - (1337, 1_000_000_000_000), - ], - } - .assimilate_storage(&mut storage) - .ok(); - - let mut ext = TestExternalities::from(storage); - ext.execute_with(|| System::set_block_number(1)); - ext - } -} - -/// Used to run to the specified block number -pub fn run_to_block(n: u64) { - while System::block_number() < n { - DappsStaking::on_finalize(System::block_number()); - System::set_block_number(System::block_number() + 1); - // This is performed outside of dapps staking but we expect it before on_initialize - payout_block_rewards(); - DappsStaking::on_initialize(System::block_number()); - } -} - -/// Used to run the specified number of blocks -pub fn run_for_blocks(n: u64) { - run_to_block(System::block_number() + n); -} - -/// Advance blocks to the beginning of an era. -/// -/// Function has no effect if era is already passed. -pub fn advance_to_era(n: EraIndex) { - while DappsStaking::current_era() < n { - run_for_blocks(1); - } -} - -/// Initialize first block. -/// This method should only be called once in a UT otherwise the first block will get initialized multiple times. -pub fn initialize_first_block() { - // This assert prevents method misuse - assert_eq!(System::block_number(), 1 as BlockNumber); - - // This is performed outside of dapps staking but we expect it before on_initialize - payout_block_rewards(); - DappsStaking::on_initialize(System::block_number()); - run_to_block(2); -} - -/// Returns total block rewards that goes to dapps-staking. -/// Contains both `dapps` reward and `stakers` reward. -pub fn joint_block_reward() -> Balance { - STAKER_BLOCK_REWARD + DAPP_BLOCK_REWARD -} - -/// Payout block rewards to stakers & dapps -fn payout_block_rewards() { - DappsStaking::rewards( - Balances::issue(STAKER_BLOCK_REWARD.into()), - Balances::issue(DAPP_BLOCK_REWARD.into()), - ); -} - -// Used to get a vec of all dapps staking events -pub fn dapps_staking_events() -> Vec> { - System::events() - .into_iter() - .map(|r| r.event) - .filter_map(|e| { - if let RuntimeEvent::DappsStaking(inner) = e { - Some(inner) - } else { - None - } - }) - .collect() -} diff --git a/pallets/dapps-staking/src/pallet/mod.rs b/pallets/dapps-staking/src/pallet/mod.rs deleted file mode 100644 index 5d8142a180..0000000000 --- a/pallets/dapps-staking/src/pallet/mod.rs +++ /dev/null @@ -1,1422 +0,0 @@ -// This file is part of Astar. - -// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later - -// Astar 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. - -// Astar 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 Astar. If not, see . - -//! Dapps staking FRAME Pallet. - -use super::*; -use frame_support::{ - dispatch::DispatchResult, - ensure, - pallet_prelude::*, - traits::{ - Currency, ExistenceRequirement, Get, Imbalance, LockIdentifier, LockableCurrency, - ReservableCurrency, WithdrawReasons, - }, - weights::Weight, - PalletId, -}; -use frame_system::{ensure_root, ensure_signed, pallet_prelude::*}; -use sp_runtime::{ - traits::{AccountIdConversion, Zero}, - Perbill, -}; -use sp_std::{convert::From, mem}; - -pub const STAKING_ID: LockIdentifier = *b"dapstake"; - -#[frame_support::pallet] -#[allow(clippy::module_inception)] -pub mod pallet { - use super::*; - - #[pallet::pallet] - pub struct Pallet(PhantomData); - - // Negative imbalance type of this pallet. - type NegativeImbalanceOf = <::Currency as Currency< - ::AccountId, - >>::NegativeImbalance; - - #[pallet::config] - pub trait Config: frame_system::Config { - /// The staking balance. - type Currency: Currency - + LockableCurrency> - + ReservableCurrency; - - /// Describes smart contract in the context required by dapps staking. - type SmartContract: Default + Parameter + Member + MaxEncodedLen; - - /// Number of blocks per era. - #[pallet::constant] - type BlockPerEra: Get>; - - /// Deposit that will be reserved as part of new contract registration. - #[pallet::constant] - type RegisterDeposit: Get; - - /// Maximum number of unique stakers per contract. - #[pallet::constant] - type MaxNumberOfStakersPerContract: Get; - - /// Minimum amount user must have staked on contract. - /// User can stake less if they already have the minimum staking amount staked on that particular contract. - #[pallet::constant] - type MinimumStakingAmount: Get; - - /// Dapps staking pallet Id - #[pallet::constant] - type PalletId: Get; - - /// Minimum amount that should be left on staker account after staking. - /// Serves as a safeguard to prevent users from locking their entire free balance. - #[pallet::constant] - type MinimumRemainingAmount: Get; - - /// Max number of unlocking chunks per account Id <-> contract Id pairing. - /// If value is zero, unlocking becomes impossible. - #[pallet::constant] - type MaxUnlockingChunks: Get; - - /// Number of eras that need to pass until unstaked value can be withdrawn. - /// Current era is always counted as full era (regardless how much blocks are remaining). - /// When set to `0`, it's equal to having no unbonding period. - #[pallet::constant] - type UnbondingPeriod: Get; - - /// Max number of unique `EraStake` values that can exist for a `(staker, contract)` pairing. - /// When stakers claims rewards, they will either keep the number of `EraStake` values the same or they will reduce them by one. - /// Stakers cannot add an additional `EraStake` value by calling `bond&stake` or `unbond&unstake` if they've reached the max number of values. - /// - /// This ensures that history doesn't grow indefinitely - if there are too many chunks, stakers should first claim their former rewards - /// before adding additional `EraStake` values. - #[pallet::constant] - type MaxEraStakeValues: Get; - - /// Number of eras that need to pass until dApp rewards for the unregistered contracts can be burned. - /// Developer can still claim rewards after this period has passed, iff it hasn't been burned yet. - /// - /// For example, if retention is set to `2` and current era is `10`, it means that all unclaimed rewards bellow era `8` can be burned. - #[pallet::constant] - type UnregisteredDappRewardRetention: Get; - - /// Can be used to force pallet into permanent maintenance mode. - #[pallet::constant] - type ForcePalletDisabled: Get; - - /// The fee that will be charged for claiming rewards on behalf of a staker. - /// This amount will be transferred from the staker over to the caller. - #[pallet::constant] - type DelegateClaimFee: Get; - - /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; - - /// Weight information for extrinsics in this pallet. - type WeightInfo: WeightInfo; - } - - /// Denotes whether pallet is disabled (in maintenance mode) or not - #[pallet::storage] - #[pallet::whitelist_storage] - #[pallet::getter(fn pallet_disabled)] - pub type PalletDisabled = StorageValue<_, bool, ValueQuery>; - - /// Denotes whether pallet decommissioning has started or not. - #[pallet::storage] - #[pallet::whitelist_storage] - pub type DecommissionStarted = StorageValue<_, bool, ValueQuery>; - - /// General information about the staker (non-smart-contract specific). - #[pallet::storage] - #[pallet::getter(fn ledger)] - pub type Ledger = - StorageMap<_, Blake2_128Concat, T::AccountId, AccountLedger, ValueQuery>; - - /// The current era index. - #[pallet::storage] - #[pallet::whitelist_storage] - #[pallet::getter(fn current_era)] - pub type CurrentEra = StorageValue<_, EraIndex, ValueQuery>; - - /// Accumulator for block rewards during an era. It is reset at every new era - #[pallet::storage] - #[pallet::getter(fn block_reward_accumulator)] - pub type BlockRewardAccumulator = StorageValue<_, RewardInfo, ValueQuery>; - - #[pallet::type_value] - pub fn ForceEraOnEmpty() -> Forcing { - Forcing::NotForcing - } - - /// Mode of era forcing. - #[pallet::storage] - #[pallet::whitelist_storage] - #[pallet::getter(fn force_era)] - pub type ForceEra = StorageValue<_, Forcing, ValueQuery, ForceEraOnEmpty>; - - /// Stores the block number of when the next era starts - #[pallet::storage] - #[pallet::whitelist_storage] - #[pallet::getter(fn next_era_starting_block)] - pub type NextEraStartingBlock = StorageValue<_, BlockNumberFor, ValueQuery>; - - /// Simple map where developer account points to their smart contract - #[pallet::storage] - #[pallet::getter(fn registered_contract)] - pub type RegisteredDevelopers = - StorageMap<_, Blake2_128Concat, T::AccountId, T::SmartContract>; - - /// Simple map where smart contract points to basic info about it (e.g. developer address, state) - #[pallet::storage] - #[pallet::getter(fn dapp_info)] - pub type RegisteredDapps = - StorageMap<_, Blake2_128Concat, T::SmartContract, DAppInfo>; - - /// General information about an era like TVL, total staked value, rewards. - #[pallet::storage] - #[pallet::getter(fn general_era_info)] - pub type GeneralEraInfo = StorageMap<_, Twox64Concat, EraIndex, EraInfo>; - - /// Staking information about contract in a particular era. - #[pallet::storage] - #[pallet::getter(fn contract_stake_info)] - pub type ContractEraStake = StorageDoubleMap< - _, - Blake2_128Concat, - T::SmartContract, - Twox64Concat, - EraIndex, - ContractStakeInfo, - >; - - /// Info about stakers stakes on particular contracts. - #[pallet::storage] - #[pallet::getter(fn staker_info)] - pub type GeneralStakerInfo = StorageDoubleMap< - _, - Blake2_128Concat, - T::AccountId, - Blake2_128Concat, - T::SmartContract, - StakerInfo, - ValueQuery, - >; - - /// Stores the current pallet storage version. - #[pallet::storage] - #[pallet::getter(fn storage_version)] - pub type StorageVersion = StorageValue<_, Version, ValueQuery>; - - #[pallet::event] - #[pallet::generate_deposit(pub(crate) fn deposit_event)] - pub enum Event { - /// Account has bonded and staked funds on a smart contract. - BondAndStake(T::AccountId, T::SmartContract, Balance), - /// Account has unbonded & unstaked some funds. Unbonding process begins. - UnbondAndUnstake(T::AccountId, T::SmartContract, Balance), - /// Account has fully withdrawn all staked amount from an unregistered contract. - WithdrawFromUnregistered(T::AccountId, T::SmartContract, Balance), - /// Account has withdrawn unbonded funds. - Withdrawn(T::AccountId, Balance), - /// New contract added for staking. - NewContract(T::AccountId, T::SmartContract), - /// Contract removed from dapps staking. - ContractRemoved(T::AccountId, T::SmartContract), - /// New dapps staking era. Distribute era rewards to contracts. - NewDappStakingEra(EraIndex), - /// Reward paid to staker or developer. - Reward(T::AccountId, T::SmartContract, EraIndex, Balance), - /// Maintenance mode has been enabled or disabled - MaintenanceMode(bool), - /// Reward handling modified - RewardDestination(T::AccountId, RewardDestination), - /// Nomination part has been transfered from one contract to another. - /// - /// \(staker account, origin smart contract, amount, target smart contract\) - NominationTransfer(T::AccountId, T::SmartContract, Balance, T::SmartContract), - /// Stale, unclaimed reward from an unregistered contract has been burned. - /// - /// \(developer account, smart contract, era, amount burned\) - StaleRewardBurned(T::AccountId, T::SmartContract, EraIndex, Balance), - /// Pallet is being decommissioned. - Decommission, - } - - #[pallet::error] - pub enum Error { - /// Disabled - Disabled, - /// No change in maintenance mode - NoMaintenanceModeChange, - /// Upgrade is too heavy, reduce the weight parameter. - UpgradeTooHeavy, - /// Can not stake with zero value. - StakingWithNoValue, - /// Can not stake with value less than minimum staking value - InsufficientValue, - /// Number of stakers per contract exceeded. - MaxNumberOfStakersExceeded, - /// Targets must be operated contracts - NotOperatedContract, - /// Contract isn't staked. - NotStakedContract, - /// Contract isn't unregistered. - NotUnregisteredContract, - /// Unclaimed rewards should be claimed before withdrawing stake. - UnclaimedRewardsRemaining, - /// Unstaking a contract with zero value - UnstakingWithNoValue, - /// There are no previously unbonded funds that can be unstaked and withdrawn. - NothingToWithdraw, - /// The contract is already registered by other account - AlreadyRegisteredContract, - /// This account was already used to register contract - AlreadyUsedDeveloperAccount, - /// Smart contract not owned by the account id. - NotOwnedContract, - /// Report issue on github if this is ever emitted - UnknownEraReward, - /// Report issue on github if this is ever emitted - UnexpectedStakeInfoEra, - /// Contract has too many unlocking chunks. Withdraw the existing chunks if possible - /// or wait for current chunks to complete unlocking process to withdraw them. - TooManyUnlockingChunks, - /// Contract already claimed in this era and reward is distributed - AlreadyClaimedInThisEra, - /// Era parameter is out of bounds - EraOutOfBounds, - /// Too many active `EraStake` values for (staker, contract) pairing. - /// Claim existing rewards to fix this problem. - TooManyEraStakeValues, - /// Account is not actively staking - NotActiveStaker, - /// Transfering nomination to the same contract - NominationTransferToSameContract, - /// Decommission is in progress so this call is not allowed. - DecommissionInProgress, - /// Delegated claim call is not allowed if both the staker & caller are the same accounts. - ClaimForCallerAccount, - } - - #[pallet::hooks] - impl Hooks> for Pallet { - fn on_initialize(now: BlockNumberFor) -> Weight { - // As long as pallet is disabled, we shouldn't allow any storage modifications. - // This means we might prolong an era but it's acceptable. - // Runtime upgrade should be timed so we ensure that we complete it before - // a new era is triggered. This code is just a safety net to ensure nothing is broken - // if we fail to do that. - if PalletDisabled::::get() || T::ForcePalletDisabled::get() { - return T::DbWeight::get().reads(3); - } - - // In case decommissioning has started, we don't allow eras to change anymore. - if DecommissionStarted::::get() { - return T::DbWeight::get().reads(3); - } - - let force_new_era = Self::force_era().eq(&Forcing::ForceNew); - let previous_era = Self::current_era(); - let next_era_starting_block = Self::next_era_starting_block(); - - // Value is compared to 1 since genesis block is ignored - if now >= next_era_starting_block || force_new_era || previous_era.is_zero() { - let blocks_per_era = T::BlockPerEra::get(); - let next_era = previous_era + 1; - CurrentEra::::put(next_era); - - NextEraStartingBlock::::put(now + blocks_per_era); - - let reward = BlockRewardAccumulator::::take(); - Self::reward_balance_snapshot(previous_era, reward); - let consumed_weight = Self::rotate_staking_info(previous_era); - - if force_new_era { - ForceEra::::put(Forcing::NotForcing); - } - - Self::deposit_event(Event::::NewDappStakingEra(next_era)); - - consumed_weight + T::DbWeight::get().reads_writes(8, 3) - } else { - T::DbWeight::get().reads(7) - } - } - } - - #[pallet::call] - impl Pallet { - /// Used to register contract for dapps staking. - /// The origin account used is treated as the `developer` account. - /// - /// Depending on the pallet configuration/state it is possible that developer needs to be whitelisted prior to registration. - /// - /// As part of this call, `RegisterDeposit` will be reserved from devs account. - #[pallet::call_index(0)] - #[pallet::weight(T::WeightInfo::register())] - pub fn register( - origin: OriginFor, - developer: T::AccountId, - contract_id: T::SmartContract, - ) -> DispatchResultWithPostInfo { - Self::ensure_pallet_enabled()?; - Self::ensure_not_in_decommission()?; - ensure_root(origin)?; - - ensure!( - !RegisteredDevelopers::::contains_key(&developer), - Error::::AlreadyUsedDeveloperAccount, - ); - ensure!( - !RegisteredDapps::::contains_key(&contract_id), - Error::::AlreadyRegisteredContract, - ); - - T::Currency::reserve(&developer, T::RegisterDeposit::get())?; - - RegisteredDapps::::insert(contract_id.clone(), DAppInfo::new(developer.clone())); - RegisteredDevelopers::::insert(&developer, contract_id.clone()); - - Self::deposit_event(Event::::NewContract(developer, contract_id)); - - Ok(().into()) - } - - /// Unregister existing contract from dapps staking, making it ineligible for rewards from current era onwards. - /// This must be called by the root (at the moment). - /// - /// Deposit is returned to the developer but existing stakers should manually call `withdraw_from_unregistered` if they wish to to unstake. - /// - /// **Warning**: After this action ,contract can not be registered for dapps staking again. - #[pallet::call_index(1)] - #[pallet::weight(T::WeightInfo::unregister())] - pub fn unregister( - origin: OriginFor, - contract_id: T::SmartContract, - ) -> DispatchResultWithPostInfo { - Self::ensure_pallet_enabled()?; - Self::ensure_not_in_decommission()?; - ensure_root(origin)?; - - let mut dapp_info = - RegisteredDapps::::get(&contract_id).ok_or(Error::::NotOperatedContract)?; - ensure!( - dapp_info.state == DAppState::Registered, - Error::::NotOperatedContract - ); - let developer = dapp_info.developer.clone(); - - let current_era = Self::current_era(); - dapp_info.state = DAppState::Unregistered(current_era); - RegisteredDapps::::insert(&contract_id, dapp_info); - - T::Currency::unreserve(&developer, T::RegisterDeposit::get()); - - Self::deposit_event(Event::::ContractRemoved(developer, contract_id)); - - Ok(().into()) - } - - /// Withdraw locked funds from a contract that was unregistered. - /// - /// Funds don't need to undergo the unbonding period - they are returned immediately to the staker's free balance. - #[pallet::call_index(2)] - #[pallet::weight(T::WeightInfo::withdraw_from_unregistered())] - pub fn withdraw_from_unregistered( - origin: OriginFor, - contract_id: T::SmartContract, - ) -> DispatchResultWithPostInfo { - Self::ensure_pallet_enabled()?; - Self::ensure_not_in_decommission()?; - let staker = ensure_signed(origin)?; - - // dApp must exist and it has to be unregistered - let dapp_info = - RegisteredDapps::::get(&contract_id).ok_or(Error::::NotOperatedContract)?; - - let unregistered_era = if let DAppState::Unregistered(x) = dapp_info.state { - x - } else { - return Err(Error::::NotUnregisteredContract.into()); - }; - - // There should be some leftover staked amount - let mut staker_info = Self::staker_info(&staker, &contract_id); - let staked_value = staker_info.latest_staked_value(); - ensure!(staked_value > Zero::zero(), Error::::NotStakedContract); - - // Don't allow withdrawal until all rewards have been claimed. - let (claimable_era, _) = staker_info.claim(); - ensure!( - claimable_era >= unregistered_era || claimable_era.is_zero(), - Error::::UnclaimedRewardsRemaining - ); - - // Unlock the staked amount immediately. No unbonding period for this scenario. - let mut ledger = Self::ledger(&staker); - ledger.locked = ledger.locked.saturating_sub(staked_value); - Self::update_ledger(&staker, ledger); - - Self::update_staker_info(&staker, &contract_id, Default::default()); - - let current_era = Self::current_era(); - GeneralEraInfo::::mutate(¤t_era, |value| { - if let Some(x) = value { - x.staked = x.staked.saturating_sub(staked_value); - x.locked = x.locked.saturating_sub(staked_value); - } - }); - - Self::deposit_event(Event::::WithdrawFromUnregistered( - staker, - contract_id, - staked_value, - )); - - Ok(().into()) - } - - /// Lock up and stake balance of the origin account. - /// - /// `value` must be more than the `minimum_balance` specified by `MinimumStakingAmount` - /// unless account already has bonded value equal or more than 'minimum_balance'. - /// - /// The dispatch origin for this call must be _Signed_ by the staker's account. - #[pallet::call_index(3)] - #[pallet::weight(T::WeightInfo::bond_and_stake())] - pub fn bond_and_stake( - origin: OriginFor, - contract_id: T::SmartContract, - #[pallet::compact] value: Balance, - ) -> DispatchResultWithPostInfo { - Self::ensure_pallet_enabled()?; - Self::ensure_not_in_decommission()?; - let staker = ensure_signed(origin)?; - - // Check that contract is ready for staking. - ensure!( - Self::is_active(&contract_id), - Error::::NotOperatedContract - ); - - // Get the staking ledger or create an entry if it doesn't exist. - let mut ledger = Self::ledger(&staker); - let available_balance = Self::available_staking_balance(&staker, &ledger); - let value_to_stake = value.min(available_balance); - ensure!( - value_to_stake > Zero::zero(), - Error::::StakingWithNoValue - ); - - let current_era = Self::current_era(); - let mut staking_info = - Self::contract_stake_info(&contract_id, current_era).unwrap_or_default(); - let mut staker_info = Self::staker_info(&staker, &contract_id); - - Self::stake_on_contract( - &mut staker_info, - &mut staking_info, - value_to_stake, - current_era, - )?; - - ledger.locked = ledger.locked.saturating_add(value_to_stake); - - // Update storage - GeneralEraInfo::::mutate(¤t_era, |value| { - if let Some(x) = value { - x.staked = x.staked.saturating_add(value_to_stake); - x.locked = x.locked.saturating_add(value_to_stake); - } - }); - - Self::update_ledger(&staker, ledger); - Self::update_staker_info(&staker, &contract_id, staker_info); - ContractEraStake::::insert(&contract_id, current_era, staking_info); - - Self::deposit_event(Event::::BondAndStake( - staker, - contract_id, - value_to_stake, - )); - Ok(().into()) - } - - /// Start unbonding process and unstake balance from the contract. - /// - /// The unstaked amount will no longer be eligible for rewards but still won't be unlocked. - /// User needs to wait for the unbonding period to finish before being able to withdraw - /// the funds via `withdraw_unbonded` call. - /// - /// In case remaining staked balance on contract is below minimum staking amount, - /// entire stake for that contract will be unstaked. - #[pallet::call_index(4)] - #[pallet::weight(T::WeightInfo::unbond_and_unstake())] - pub fn unbond_and_unstake( - origin: OriginFor, - contract_id: T::SmartContract, - #[pallet::compact] value: Balance, - ) -> DispatchResultWithPostInfo { - Self::ensure_pallet_enabled()?; - let staker = ensure_signed(origin)?; - - ensure!(value > Zero::zero(), Error::::UnstakingWithNoValue); - ensure!( - Self::is_active(&contract_id), - Error::::NotOperatedContract, - ); - - let current_era = Self::current_era(); - let mut staker_info = Self::staker_info(&staker, &contract_id); - let mut contract_stake_info = - Self::contract_stake_info(&contract_id, current_era).unwrap_or_default(); - - let value_to_unstake = Self::unstake_from_contract( - &mut staker_info, - &mut contract_stake_info, - value, - current_era, - )?; - - // Update the chunks and write them to storage - let mut ledger = Self::ledger(&staker); - ledger.unbonding_info.add(UnlockingChunk { - amount: value_to_unstake, - unlock_era: current_era + T::UnbondingPeriod::get(), - }); - // This should be done AFTER insertion since it's possible for chunks to merge - ensure!( - ledger.unbonding_info.len() <= T::MaxUnlockingChunks::get(), - Error::::TooManyUnlockingChunks - ); - - Self::update_ledger(&staker, ledger); - - // Update total staked value in era. - GeneralEraInfo::::mutate(¤t_era, |value| { - if let Some(x) = value { - x.staked = x.staked.saturating_sub(value_to_unstake) - } - }); - Self::update_staker_info(&staker, &contract_id, staker_info); - ContractEraStake::::insert(&contract_id, current_era, contract_stake_info); - - Self::deposit_event(Event::::UnbondAndUnstake( - staker, - contract_id, - value_to_unstake, - )); - - Ok(().into()) - } - - /// Withdraw all funds that have completed the unbonding process. - /// - /// If there are unbonding chunks which will be fully unbonded in future eras, - /// they will remain and can be withdrawn later. - #[pallet::call_index(5)] - #[pallet::weight(T::WeightInfo::withdraw_unbonded())] - pub fn withdraw_unbonded(origin: OriginFor) -> DispatchResultWithPostInfo { - Self::ensure_pallet_enabled()?; - let staker = ensure_signed(origin)?; - - let mut ledger = Self::ledger(&staker); - let current_era = Self::current_era(); - - let (valid_chunks, future_chunks) = ledger.unbonding_info.partition(current_era); - let withdraw_amount = valid_chunks.sum(); - - ensure!(!withdraw_amount.is_zero(), Error::::NothingToWithdraw); - - // Get the staking ledger and update it - ledger.locked = ledger.locked.saturating_sub(withdraw_amount); - ledger.unbonding_info = future_chunks; - - Self::update_ledger(&staker, ledger); - GeneralEraInfo::::mutate(¤t_era, |value| { - if let Some(x) = value { - x.locked = x.locked.saturating_sub(withdraw_amount) - } - }); - - Self::deposit_event(Event::::Withdrawn(staker, withdraw_amount)); - - Ok(().into()) - } - - /// Transfer nomination from one contract to another. - /// - /// Same rules as for `bond_and_stake` and `unbond_and_unstake` apply. - /// Minor difference is that there is no unbonding period so this call won't - /// check whether max number of unbonding chunks is exceeded. - /// - #[pallet::call_index(6)] - #[pallet::weight(T::WeightInfo::nomination_transfer())] - pub fn nomination_transfer( - origin: OriginFor, - origin_contract_id: T::SmartContract, - #[pallet::compact] value: Balance, - target_contract_id: T::SmartContract, - ) -> DispatchResultWithPostInfo { - Self::ensure_pallet_enabled()?; - Self::ensure_not_in_decommission()?; - let staker = ensure_signed(origin)?; - - // Contracts must differ and both must be active - ensure!( - origin_contract_id != target_contract_id, - Error::::NominationTransferToSameContract - ); - ensure!( - Self::is_active(&origin_contract_id), - Error::::NotOperatedContract - ); - ensure!( - Self::is_active(&target_contract_id), - Error::::NotOperatedContract - ); - - // Validate origin contract related data & update it - let current_era = Self::current_era(); - let mut origin_staker_info = Self::staker_info(&staker, &origin_contract_id); - let mut origin_staking_info = - Self::contract_stake_info(&origin_contract_id, current_era).unwrap_or_default(); - - let origin_to_target_transfer_value = Self::unstake_from_contract( - &mut origin_staker_info, - &mut origin_staking_info, - value, - current_era, - )?; - - // Validate target contract related data & update it - let mut target_staker_info = Self::staker_info(&staker, &target_contract_id); - let mut target_staking_info = - Self::contract_stake_info(&target_contract_id, current_era).unwrap_or_default(); - - Self::stake_on_contract( - &mut target_staker_info, - &mut target_staking_info, - origin_to_target_transfer_value, - current_era, - )?; - - // Update origin data - ContractEraStake::::insert(&origin_contract_id, current_era, origin_staking_info); - Self::update_staker_info(&staker, &origin_contract_id, origin_staker_info); - - // Update target data - ContractEraStake::::insert(&target_contract_id, current_era, target_staking_info); - Self::update_staker_info(&staker, &target_contract_id, target_staker_info); - - Self::deposit_event(Event::::NominationTransfer( - staker, - origin_contract_id, - origin_to_target_transfer_value, - target_contract_id, - )); - - Ok(().into()) - } - - /// Claim earned staker rewards for the oldest unclaimed era. - /// In order to claim multiple eras, this call has to be called multiple times. - /// - /// The rewards are always added to the staker's free balance (account) but depending on the reward destination configuration, - /// they might be immediately re-staked. - #[pallet::call_index(7)] - #[pallet::weight(T::WeightInfo::claim_staker_with_restake().max(T::WeightInfo::claim_staker_without_restake()))] - pub fn claim_staker( - origin: OriginFor, - contract_id: T::SmartContract, - ) -> DispatchResultWithPostInfo { - Self::ensure_pallet_enabled()?; - let staker = ensure_signed(origin)?; - - Self::internal_claim_staker_for(staker.clone(), staker, contract_id, false) - } - - /// Claim earned dapp rewards for the specified era. - /// - /// Call must ensure that the specified era is eligible for reward payout and that it hasn't already been paid out for the dapp. - #[pallet::call_index(8)] - #[pallet::weight(T::WeightInfo::claim_dapp())] - pub fn claim_dapp( - origin: OriginFor, - contract_id: T::SmartContract, - #[pallet::compact] era: EraIndex, - ) -> DispatchResultWithPostInfo { - Self::ensure_pallet_enabled()?; - let _ = ensure_signed(origin)?; - - let dapp_info = - RegisteredDapps::::get(&contract_id).ok_or(Error::::NotOperatedContract)?; - - let mut contract_stake_info = - Self::contract_stake_info(&contract_id, era).unwrap_or_default(); - - let dapp_reward = Self::calculate_dapp_reward(&contract_stake_info, &dapp_info, era)?; - - // Withdraw reward funds from the dapps staking - let reward_imbalance = T::Currency::withdraw( - &Self::account_id(), - dapp_reward, - WithdrawReasons::TRANSFER, - ExistenceRequirement::AllowDeath, - )?; - - T::Currency::resolve_creating(&dapp_info.developer, reward_imbalance); - Self::deposit_event(Event::::Reward( - dapp_info.developer, - contract_id.clone(), - era, - dapp_reward, - )); - - // updated counter for total rewards paid to the contract - contract_stake_info.contract_reward_claimed = true; - ContractEraStake::::insert(&contract_id, era, contract_stake_info); - - Ok(().into()) - } - - /// Force a new era at the start of the next block. - /// - /// The dispatch origin must be Root. - #[pallet::call_index(9)] - #[pallet::weight(T::WeightInfo::force_new_era())] - pub fn force_new_era(origin: OriginFor) -> DispatchResult { - Self::ensure_pallet_enabled()?; - ensure_root(origin)?; - ForceEra::::put(Forcing::ForceNew); - Ok(()) - } - - /// `true` will disable pallet, enabling maintenance mode. `false` will do the opposite. - /// - /// The dispatch origin must be Root. - #[pallet::call_index(10)] - #[pallet::weight(T::WeightInfo::maintenance_mode())] - pub fn maintenance_mode( - origin: OriginFor, - enable_maintenance: bool, - ) -> DispatchResultWithPostInfo { - ensure_root(origin)?; - let is_disabled = PalletDisabled::::get(); - - ensure!( - is_disabled ^ enable_maintenance, - Error::::NoMaintenanceModeChange - ); - PalletDisabled::::put(enable_maintenance); - - Self::deposit_event(Event::::MaintenanceMode(enable_maintenance)); - Ok(().into()) - } - - /// Used to set reward destination for staker rewards. - /// - /// User must be an active staker in order to use this call. - /// This will apply to all existing unclaimed rewards. - #[pallet::call_index(11)] - #[pallet::weight(T::WeightInfo::set_reward_destination())] - pub fn set_reward_destination( - origin: OriginFor, - reward_destination: RewardDestination, - ) -> DispatchResultWithPostInfo { - Self::ensure_pallet_enabled()?; - let staker = ensure_signed(origin)?; - - Self::internal_set_reward_destination_for(staker, reward_destination) - } - - /// Used to force set `ContractEraStake` storage values. - /// The purpose of this call is only for fixing one of the issues detected with dapps-staking. - /// - /// The dispatch origin must be Root. - #[pallet::call_index(12)] - #[pallet::weight(T::DbWeight::get().writes(1))] - pub fn set_contract_stake_info( - origin: OriginFor, - contract: T::SmartContract, - era: EraIndex, - contract_stake_info: ContractStakeInfo, - ) -> DispatchResultWithPostInfo { - ensure_root(origin)?; - - ContractEraStake::::insert(contract, era, contract_stake_info); - - Ok(().into()) - } - - /// Used to burn unclaimed & stale rewards from an unregistered contract. - #[pallet::call_index(13)] - #[pallet::weight(T::WeightInfo::claim_dapp())] - pub fn burn_stale_reward( - origin: OriginFor, - contract_id: T::SmartContract, - #[pallet::compact] era: EraIndex, - ) -> DispatchResultWithPostInfo { - Self::ensure_pallet_enabled()?; - Self::ensure_not_in_decommission()?; - ensure_root(origin)?; - - let dapp_info = - RegisteredDapps::::get(&contract_id).ok_or(Error::::NotOperatedContract)?; - ensure!( - dapp_info.is_unregistered(), - Error::::NotUnregisteredContract - ); - - let current_era = Self::current_era(); - - let burn_era_limit = - current_era.saturating_sub(T::UnregisteredDappRewardRetention::get()); - ensure!(era < burn_era_limit, Error::::EraOutOfBounds); - - let mut contract_stake_info = - Self::contract_stake_info(&contract_id, era).unwrap_or_default(); - - let dapp_reward = Self::calculate_dapp_reward(&contract_stake_info, &dapp_info, era)?; - - // Withdraw reward funds from the dapps staking pot and burn them - let imbalance_to_burn = T::Currency::withdraw( - &Self::account_id(), - dapp_reward, - WithdrawReasons::TRANSFER, - ExistenceRequirement::AllowDeath, - )?; - mem::drop(imbalance_to_burn); - - // mark entry as `claimed` but it means it's just handled (want to avoid rename since pallet will soon be redesigned). - contract_stake_info.contract_reward_claimed = true; - ContractEraStake::::insert(&contract_id, era, contract_stake_info); - - Self::deposit_event(Event::::StaleRewardBurned( - dapp_info.developer, - contract_id.clone(), - era, - dapp_reward, - )); - - Ok(().into()) - } - - /// Claim earned staker rewards for the given staker, and the oldest unclaimed era. - /// In order to claim multiple eras, this call has to be called multiple times. - /// - /// This call can only be used during the pallet decommission process. - #[pallet::call_index(14)] - #[pallet::weight(T::WeightInfo::claim_staker_with_restake().max(T::WeightInfo::claim_staker_without_restake()))] - pub fn claim_staker_for( - origin: OriginFor, - staker: T::AccountId, - contract_id: T::SmartContract, - ) -> DispatchResultWithPostInfo { - Self::ensure_pallet_enabled()?; - let caller = ensure_signed(origin)?; - - ensure!(caller != staker, Error::::ClaimForCallerAccount); - - Self::internal_claim_staker_for(caller, staker, contract_id, true) - } - - /// Used to set reward destination for staker rewards, for the given staker - /// - #[pallet::call_index(15)] - #[pallet::weight(T::WeightInfo::set_reward_destination())] - pub fn set_reward_destination_for( - origin: OriginFor, - staker: T::AccountId, - reward_destination: RewardDestination, - ) -> DispatchResultWithPostInfo { - Self::ensure_pallet_enabled()?; - - ensure_signed(origin)?; - - Self::internal_set_reward_destination_for(staker, reward_destination) - } - - /// Enable the `decommission` flag for the pallet. - /// - /// The dispatch origin must be Root. - #[pallet::call_index(16)] - #[pallet::weight(T::WeightInfo::maintenance_mode())] // Good enough approximation - pub fn decommission(origin: OriginFor) -> DispatchResultWithPostInfo { - Self::ensure_pallet_enabled()?; - Self::ensure_not_in_decommission()?; - ensure_root(origin)?; - - DecommissionStarted::::put(true); - Self::deposit_event(Event::::Decommission); - - Ok(().into()) - } - } - - impl Pallet { - /// Calculate the dApp reward for the specified era. - /// If successfull, returns reward amount. - /// In case reward cannot be claimed or was already claimed, an error is raised. - fn calculate_dapp_reward( - contract_stake_info: &ContractStakeInfo, - dapp_info: &DAppInfo, - era: EraIndex, - ) -> Result> { - let current_era = Self::current_era(); - if let DAppState::Unregistered(unregister_era) = dapp_info.state { - ensure!(era < unregister_era, Error::::NotOperatedContract); - } - ensure!(era < current_era, Error::::EraOutOfBounds); - - ensure!( - !contract_stake_info.contract_reward_claimed, - Error::::AlreadyClaimedInThisEra, - ); - ensure!( - contract_stake_info.total > Zero::zero(), - Error::::NotStakedContract, - ); - - let reward_and_stake = - Self::general_era_info(era).ok_or(Error::::UnknownEraReward)?; - - // Calculate the contract reward for this era. - let (dapp_reward, _) = Self::dev_stakers_split(&contract_stake_info, &reward_and_stake); - - Ok(dapp_reward) - } - - /// An utility method used to stake specified amount on an arbitrary contract. - /// - /// `StakerInfo` and `ContractStakeInfo` are provided and all checks are made to ensure that it's possible to - /// complete staking operation. - /// - /// # Arguments - /// - /// * `staker_info` - info about staker's stakes on the contract up to current moment - /// * `staking_info` - general info about contract stakes up to current moment - /// * `value` - value which is being bonded & staked - /// * `current_era` - current dapps-staking era - /// - /// # Returns - /// - /// If stake operation was successful, given structs are properly modified. - /// If not, an error is returned and structs are left in an undefined state. - /// - fn stake_on_contract( - staker_info: &mut StakerInfo, - staking_info: &mut ContractStakeInfo, - value: Balance, - current_era: EraIndex, - ) -> Result<(), Error> { - ensure!( - !staker_info.latest_staked_value().is_zero() - || staking_info.number_of_stakers < T::MaxNumberOfStakersPerContract::get(), - Error::::MaxNumberOfStakersExceeded - ); - if staker_info.latest_staked_value().is_zero() { - staking_info.number_of_stakers = staking_info.number_of_stakers.saturating_add(1); - } - - staker_info - .stake(current_era, value) - .map_err(|_| Error::::UnexpectedStakeInfoEra)?; - ensure!( - // One spot should remain for compounding reward claim call - staker_info.len() < T::MaxEraStakeValues::get(), - Error::::TooManyEraStakeValues - ); - ensure!( - staker_info.latest_staked_value() >= T::MinimumStakingAmount::get(), - Error::::InsufficientValue, - ); - - // Increment ledger and total staker value for contract. - staking_info.total = staking_info.total.saturating_add(value); - - Ok(()) - } - - /// An utility method used to unstake specified amount from an arbitrary contract. - /// - /// The amount unstaked can be different in case staked amount would fall bellow `MinimumStakingAmount`. - /// In that case, entire staked amount will be unstaked. - /// - /// `StakerInfo` and `ContractStakeInfo` are provided and all checks are made to ensure that it's possible to - /// complete unstake operation. - /// - /// # Arguments - /// - /// * `staker_info` - info about staker's stakes on the contract up to current moment - /// * `staking_info` - general info about contract stakes up to current moment - /// * `value` - value which should be unstaked - /// * `current_era` - current dapps-staking era - /// - /// # Returns - /// - /// If unstake operation was successful, given structs are properly modified and total unstaked value is returned. - /// If not, an error is returned and structs are left in an undefined state. - /// - fn unstake_from_contract( - staker_info: &mut StakerInfo, - contract_stake_info: &mut ContractStakeInfo, - value: Balance, - current_era: EraIndex, - ) -> Result> { - let staked_value = staker_info.latest_staked_value(); - ensure!(staked_value > Zero::zero(), Error::::NotStakedContract); - - // Calculate the value which will be unstaked. - let remaining = staked_value.saturating_sub(value); - let value_to_unstake = if remaining < T::MinimumStakingAmount::get() { - contract_stake_info.number_of_stakers = - contract_stake_info.number_of_stakers.saturating_sub(1); - staked_value - } else { - value - }; - contract_stake_info.total = contract_stake_info.total.saturating_sub(value_to_unstake); - - // Sanity check - ensure!( - value_to_unstake > Zero::zero(), - Error::::UnstakingWithNoValue - ); - - staker_info - .unstake(current_era, value_to_unstake) - .map_err(|_| Error::::UnexpectedStakeInfoEra)?; - ensure!( - // One spot should remain for compounding reward claim call - staker_info.len() < T::MaxEraStakeValues::get(), - Error::::TooManyEraStakeValues - ); - - Ok(value_to_unstake) - } - - /// Get AccountId assigned to the pallet. - pub(crate) fn account_id() -> T::AccountId { - T::PalletId::get().into_account_truncating() - } - - /// `Err` if pallet disabled for maintenance, `Ok` otherwise - pub fn ensure_pallet_enabled() -> Result<(), Error> { - if PalletDisabled::::get() || T::ForcePalletDisabled::get() { - Err(Error::::Disabled) - } else { - Ok(()) - } - } - - /// `Err` if pallet is undergoing decommission, `Ok` otherwise - pub fn ensure_not_in_decommission() -> Result<(), Error> { - if DecommissionStarted::::get() { - Err(Error::::DecommissionInProgress) - } else { - Ok(()) - } - } - - /// Update the ledger for a staker. This will also update the stash lock. - /// This lock will lock the entire funds except paying for further transactions. - fn update_ledger(staker: &T::AccountId, ledger: AccountLedger) { - if ledger.is_empty() { - Ledger::::remove(&staker); - T::Currency::remove_lock(STAKING_ID, staker); - } else { - T::Currency::set_lock(STAKING_ID, staker, ledger.locked, WithdrawReasons::all()); - Ledger::::insert(staker, ledger); - } - } - - /// Update the staker info for the `(staker, contract_id)` pairing. - /// If staker_info is empty, remove it from the DB. Otherwise, store it. - fn update_staker_info( - staker: &T::AccountId, - contract_id: &T::SmartContract, - staker_info: StakerInfo, - ) { - if staker_info.is_empty() { - GeneralStakerInfo::::remove(staker, contract_id) - } else { - GeneralStakerInfo::::insert(staker, contract_id, staker_info) - } - } - - /// The block rewards are accumulated on the pallets's account during an era. - /// This function takes a snapshot of the pallet's balance accrued during current era - /// and stores it for future distribution - /// - /// This is called just at the beginning of an era. - fn reward_balance_snapshot(era: EraIndex, rewards: RewardInfo) { - // Get the reward and stake information for previous era - let mut era_info = Self::general_era_info(era).unwrap_or_default(); - - // Prepare info for the next era - GeneralEraInfo::::insert( - era + 1, - EraInfo { - rewards: Default::default(), - staked: era_info.staked, - locked: era_info.locked, - }, - ); - - // Set the reward for the previous era. - era_info.rewards = rewards; - - GeneralEraInfo::::insert(era, era_info); - } - - /// Used to copy all `ContractStakeInfo` from the ending era over to the next era. - /// This is the most primitive solution since it scales with number of dApps. - /// It is possible to provide a hybrid solution which allows laziness but also prevents - /// a situation where we don't have access to the required data. - fn rotate_staking_info(current_era: EraIndex) -> Weight { - let next_era = current_era + 1; - - let mut consumed_weight = Weight::zero(); - - for (contract_id, dapp_info) in RegisteredDapps::::iter() { - // Ignore dapp if it was unregistered - consumed_weight = consumed_weight.saturating_add(T::DbWeight::get().reads(1)); - if let DAppState::Unregistered(_) = dapp_info.state { - continue; - } - - // Copy data from era `X` to era `X + 1` - if let Some(mut staking_info) = Self::contract_stake_info(&contract_id, current_era) - { - staking_info.contract_reward_claimed = false; - ContractEraStake::::insert(&contract_id, next_era, staking_info); - - consumed_weight = - consumed_weight.saturating_add(T::DbWeight::get().reads_writes(1, 1)); - } else { - consumed_weight = consumed_weight.saturating_add(T::DbWeight::get().reads(1)); - } - } - - consumed_weight - } - - /// Returns available staking balance for the potential staker - fn available_staking_balance(staker: &T::AccountId, ledger: &AccountLedger) -> Balance { - // Ensure that staker has enough balance to bond & stake. - let free_balance = - T::Currency::free_balance(staker).saturating_sub(T::MinimumRemainingAmount::get()); - - // Remove already locked funds from the free balance - free_balance.saturating_sub(ledger.locked) - } - - /// `true` if contract is active, `false` if it has been unregistered - fn is_active(contract_id: &T::SmartContract) -> bool { - RegisteredDapps::::get(contract_id) - .map_or(false, |dapp_info| dapp_info.state == DAppState::Registered) - } - - /// `true` if all the conditions for restaking the reward have been met, `false` otherwise - pub(crate) fn should_restake_reward( - reward_destination: RewardDestination, - dapp_state: DAppState, - latest_staked_value: Balance, - ) -> bool { - reward_destination == RewardDestination::StakeBalance - && dapp_state == DAppState::Registered - && latest_staked_value > Zero::zero() - } - - /// Calculate reward split between developer and stakers. - /// - /// Returns (developer reward, joint stakers reward) - pub(crate) fn dev_stakers_split( - contract_info: &ContractStakeInfo, - era_info: &EraInfo, - ) -> (Balance, Balance) { - let contract_stake_portion = - Perbill::from_rational(contract_info.total, era_info.staked); - - let developer_reward_part = contract_stake_portion * era_info.rewards.dapps; - let stakers_joint_reward = contract_stake_portion * era_info.rewards.stakers; - - (developer_reward_part, stakers_joint_reward) - } - - /// Adds `stakers` and `dapps` rewards to the reward pool. - /// - /// - `stakers` - portion of the reward that will be distributed to stakers - /// - `dapps` - portion of the reward that will be distributed to dapps - pub fn rewards(stakers: NegativeImbalanceOf, dapps: NegativeImbalanceOf) { - BlockRewardAccumulator::::mutate(|accumulated_reward| { - accumulated_reward.dapps = accumulated_reward.dapps.saturating_add(dapps.peek()); - accumulated_reward.stakers = - accumulated_reward.stakers.saturating_add(stakers.peek()); - }); - - T::Currency::resolve_creating(&Self::account_id(), stakers.merge(dapps)); - } - - /// Returns total value locked by dapps-staking. - /// - /// Note that this can differ from _total staked value_ since some funds might be undergoing the unbonding period. - pub fn tvl() -> Balance { - let current_era = Self::current_era(); - if let Some(era_info) = Self::general_era_info(current_era) { - era_info.locked - } else { - // Should never happen since era info for current era must always exist - Zero::zero() - } - } - - /// Claim earned staker rewards for the given staker, and the oldest unclaimed era. - fn internal_claim_staker_for( - caller: T::AccountId, - staker: T::AccountId, - contract_id: T::SmartContract, - refund_caller: bool, - ) -> DispatchResultWithPostInfo { - // Ensure we have something to claim - let mut staker_info = Self::staker_info(&staker, &contract_id); - let (era, staked) = staker_info.claim(); - ensure!(staked > Zero::zero(), Error::::NotStakedContract); - - let dapp_info = - RegisteredDapps::::get(&contract_id).ok_or(Error::::NotOperatedContract)?; - - if let DAppState::Unregistered(unregister_era) = dapp_info.state { - ensure!(era < unregister_era, Error::::NotOperatedContract); - } - - let current_era = Self::current_era(); - ensure!(era < current_era, Error::::EraOutOfBounds); - - let staking_info = Self::contract_stake_info(&contract_id, era).unwrap_or_default(); - let reward_and_stake = - Self::general_era_info(era).ok_or(Error::::UnknownEraReward)?; - - let (_, stakers_joint_reward) = - Self::dev_stakers_split(&staking_info, &reward_and_stake); - let max_staker_reward = - Perbill::from_rational(staked, staking_info.total) * stakers_joint_reward; - - // Withdraw reward funds from the dapps staking pot - let total_imbalance = T::Currency::withdraw( - &Self::account_id(), - max_staker_reward, - WithdrawReasons::TRANSFER, - ExistenceRequirement::AllowDeath, - )?; - - let (refund_imbalance, reward_imbalance) = if refund_caller { - let claim_fee = T::DelegateClaimFee::get(); - total_imbalance.split(claim_fee) - } else { - (NegativeImbalanceOf::::zero(), total_imbalance) - }; - - let staker_reward = reward_imbalance.peek(); - - let mut ledger = Self::ledger(&staker); - - let should_restake_reward = Self::should_restake_reward( - ledger.reward_destination, - dapp_info.state, - staker_info.latest_staked_value(), - ); - - if should_restake_reward { - staker_info - .stake(current_era, staker_reward) - .map_err(|_| Error::::UnexpectedStakeInfoEra)?; - - // Restaking will, in the worst case, remove one, and add one record, - // so it's fine if the vector is full - ensure!( - staker_info.len() <= T::MaxEraStakeValues::get(), - Error::::TooManyEraStakeValues - ); - - ledger.locked = ledger.locked.saturating_add(staker_reward); - Self::update_ledger(&staker, ledger); - - // Update storage - GeneralEraInfo::::mutate(¤t_era, |value| { - if let Some(x) = value { - x.staked = x.staked.saturating_add(staker_reward); - x.locked = x.locked.saturating_add(staker_reward); - } - }); - - ContractEraStake::::mutate(contract_id.clone(), current_era, |staking_info| { - if let Some(x) = staking_info { - x.total = x.total.saturating_add(staker_reward); - } - }); - - Self::deposit_event(Event::::BondAndStake( - staker.clone(), - contract_id.clone(), - staker_reward, - )); - } - - T::Currency::resolve_creating(&staker, reward_imbalance); - Self::update_staker_info(&staker, &contract_id, staker_info); - - Self::deposit_event(Event::::Reward(staker, contract_id, era, staker_reward)); - - // Weight-wise this operation is essentially free since it caller balance is already updated to due to the fee. - // - // We also do this operation AFTER depositing the reward event since it's possible some off-chain logic relies on - // event counting, and we want to avoid breaking it. - if refund_caller { - T::Currency::resolve_creating(&caller, refund_imbalance); - } - - Ok(Some(if should_restake_reward { - T::WeightInfo::claim_staker_with_restake() - } else { - T::WeightInfo::claim_staker_without_restake() - }) - .into()) - } - - /// Sets the reward destination for the given staker. - fn internal_set_reward_destination_for( - staker: T::AccountId, - reward_destination: RewardDestination, - ) -> DispatchResultWithPostInfo { - let mut ledger = Self::ledger(&staker); - - ensure!(!ledger.is_empty(), Error::::NotActiveStaker); - - // this is done directly instead of using update_ledger helper - // because there's no need to interact with the Currency locks - ledger.reward_destination = reward_destination; - Ledger::::insert(&staker, ledger); - - Self::deposit_event(Event::::RewardDestination(staker, reward_destination)); - Ok(().into()) - } - } -} diff --git a/pallets/dapps-staking/src/testing_utils.rs b/pallets/dapps-staking/src/testing_utils.rs deleted file mode 100644 index 368ffdddcd..0000000000 --- a/pallets/dapps-staking/src/testing_utils.rs +++ /dev/null @@ -1,738 +0,0 @@ -// This file is part of Astar. - -// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later - -// Astar 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. - -// Astar 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 Astar. If not, see . - -use super::{pallet::pallet::Event, *}; -use frame_support::assert_ok; -use mock::{Balance, EraIndex, *}; -use sp_runtime::{traits::AccountIdConversion, Perbill}; - -/// Helper struct used to store information relevant to era/contract/staker combination. -pub(crate) struct MemorySnapshot { - era_info: EraInfo, - dapp_info: DAppInfo, - staker_info: StakerInfo, - contract_info: ContractStakeInfo, - free_balance: Balance, - ledger: AccountLedger, -} - -impl MemorySnapshot { - /// Prepares a new `MemorySnapshot` struct based on the given arguments. - pub(crate) fn all( - era: EraIndex, - contract_id: &MockSmartContract, - account: AccountId, - ) -> Self { - Self { - era_info: DappsStaking::general_era_info(era).unwrap(), - dapp_info: RegisteredDapps::::get(contract_id).unwrap(), - staker_info: GeneralStakerInfo::::get(&account, contract_id), - contract_info: DappsStaking::contract_stake_info(contract_id, era).unwrap_or_default(), - ledger: DappsStaking::ledger(&account), - free_balance: ::Currency::free_balance(&account), - } - } - - /// Prepares a new `MemorySnapshot` struct but only with contract-related info - /// (no info specific for individual staker). - pub(crate) fn contract(era: EraIndex, contract_id: &MockSmartContract) -> Self { - Self { - era_info: DappsStaking::general_era_info(era).unwrap(), - dapp_info: RegisteredDapps::::get(contract_id).unwrap(), - staker_info: Default::default(), - contract_info: DappsStaking::contract_stake_info(contract_id, era).unwrap_or_default(), - ledger: Default::default(), - free_balance: Default::default(), - } - } -} - -/// Used to fetch the free balance of dapps staking account -pub(crate) fn free_balance_of_dapps_staking_account() -> Balance { - ::Currency::free_balance(&account_id()) -} - -/// Used to fetch pallet account Id -pub(crate) fn account_id() -> AccountId { - ::PalletId::get().into_account_truncating() -} - -/// Used to get total dapps reward for an era. -pub(crate) fn get_total_reward_per_era() -> Balance { - mock::joint_block_reward() * BLOCKS_PER_ERA as Balance -} - -/// Used to register contract for staking and assert success. -pub(crate) fn assert_register(developer: AccountId, contract_id: &MockSmartContract) { - let init_reserved_balance = ::Currency::reserved_balance(&developer); - - // Contract shouldn't exist. - assert!(!RegisteredDapps::::contains_key(contract_id)); - assert!(!RegisteredDevelopers::::contains_key( - developer - )); - - // Verify op is successful - assert_ok!(DappsStaking::register( - RuntimeOrigin::root(), - developer, - contract_id.clone() - )); - - let dapp_info = RegisteredDapps::::get(contract_id).unwrap(); - assert_eq!(dapp_info.state, DAppState::Registered); - assert_eq!(dapp_info.developer, developer); - assert_eq!( - *contract_id, - RegisteredDevelopers::::get(developer).unwrap() - ); - - let final_reserved_balance = ::Currency::reserved_balance(&developer); - assert_eq!( - final_reserved_balance, - init_reserved_balance + ::RegisterDeposit::get() - ); -} - -/// Perform `unregister` with all the accompanied checks including before/after storage comparison. -pub(crate) fn assert_unregister(developer: AccountId, contract_id: &MockSmartContract) { - let current_era = DappsStaking::current_era(); - let init_state = MemorySnapshot::contract(current_era, contract_id); - let init_reserved_balance = ::Currency::reserved_balance(&developer); - - // dApp should be registered prior to unregistering it - assert_eq!(init_state.dapp_info.state, DAppState::Registered); - - // Ensure that contract can be unregistered - assert_ok!(DappsStaking::unregister( - RuntimeOrigin::root(), - contract_id.clone() - )); - System::assert_last_event(mock::RuntimeEvent::DappsStaking(Event::ContractRemoved( - developer, - contract_id.clone(), - ))); - - let final_state = MemorySnapshot::contract(current_era, contract_id); - let final_reserved_balance = ::Currency::reserved_balance(&developer); - assert_eq!( - final_reserved_balance, - init_reserved_balance - ::RegisterDeposit::get() - ); - - assert_eq!(final_state.era_info.staked, init_state.era_info.staked); - - assert_eq!( - final_state.contract_info.total, - init_state.contract_info.total - ); - assert_eq!( - final_state.contract_info.number_of_stakers, - init_state.contract_info.number_of_stakers - ); - - assert_eq!( - final_state.dapp_info.state, - DAppState::Unregistered(current_era) - ); - assert_eq!(final_state.dapp_info.developer, developer); -} - -/// Perform `withdraw_from_unregistered` with all the accompanied checks including before/after storage comparison. -pub(crate) fn assert_withdraw_from_unregistered( - staker: AccountId, - contract_id: &MockSmartContract, -) { - let current_era = DappsStaking::current_era(); - let init_state = MemorySnapshot::all(current_era, contract_id, staker); - - // Initial checks - if let DAppState::Unregistered(era) = init_state.dapp_info.state { - assert!(era <= DappsStaking::current_era()); - } else { - panic!("Contract should be unregistered.") - }; - - let staked_value = init_state.staker_info.latest_staked_value(); - assert!(staked_value > 0); - - // Op with verification - assert_ok!(DappsStaking::withdraw_from_unregistered( - RuntimeOrigin::signed(staker.clone()), - contract_id.clone() - )); - System::assert_last_event(mock::RuntimeEvent::DappsStaking( - Event::WithdrawFromUnregistered(staker, contract_id.clone(), staked_value), - )); - - let final_state = MemorySnapshot::all(current_era, contract_id, staker); - - // Verify that all final states are as expected - assert_eq!( - init_state.era_info.staked, - final_state.era_info.staked + staked_value - ); - assert_eq!( - init_state.era_info.locked, - final_state.era_info.locked + staked_value - ); - assert_eq!(init_state.dapp_info, final_state.dapp_info); - assert_eq!( - init_state.ledger.locked, - final_state.ledger.locked + staked_value - ); - assert_eq!( - init_state.ledger.unbonding_info, - final_state.ledger.unbonding_info - ); - - assert!(final_state.staker_info.latest_staked_value().is_zero()); - assert!(!GeneralStakerInfo::::contains_key( - &staker, - contract_id - )); -} - -/// Perform `bond_and_stake` with all the accompanied checks including before/after storage comparison. -pub(crate) fn assert_bond_and_stake( - staker: AccountId, - contract_id: &MockSmartContract, - value: Balance, -) { - let current_era = DappsStaking::current_era(); - let init_state = MemorySnapshot::all(current_era, &contract_id, staker); - - // Calculate the expected value that will be staked. - let available_for_staking = init_state.free_balance - - init_state.ledger.locked - - ::MinimumRemainingAmount::get(); - let staking_value = available_for_staking.min(value); - - // Perform op and verify everything is as expected - assert_ok!(DappsStaking::bond_and_stake( - RuntimeOrigin::signed(staker), - contract_id.clone(), - value, - )); - System::assert_last_event(mock::RuntimeEvent::DappsStaking(Event::BondAndStake( - staker, - contract_id.clone(), - staking_value, - ))); - - let final_state = MemorySnapshot::all(current_era, &contract_id, staker); - - // In case staker hasn't been staking this contract until now - if init_state.staker_info.latest_staked_value() == 0 { - assert!(GeneralStakerInfo::::contains_key( - &staker, - contract_id - )); - assert_eq!( - final_state.contract_info.number_of_stakers, - init_state.contract_info.number_of_stakers + 1 - ); - } - - // Verify the remaining states - assert_eq!( - final_state.era_info.staked, - init_state.era_info.staked + staking_value - ); - assert_eq!( - final_state.era_info.locked, - init_state.era_info.locked + staking_value - ); - assert_eq!( - final_state.contract_info.total, - init_state.contract_info.total + staking_value - ); - assert_eq!( - final_state.staker_info.latest_staked_value(), - init_state.staker_info.latest_staked_value() + staking_value - ); - assert_eq!( - final_state.ledger.locked, - init_state.ledger.locked + staking_value - ); -} - -/// Used to perform start_unbonding with success and storage assertions. -pub(crate) fn assert_unbond_and_unstake( - staker: AccountId, - contract_id: &MockSmartContract, - value: Balance, -) { - // Get latest staking info - let current_era = DappsStaking::current_era(); - let init_state = MemorySnapshot::all(current_era, &contract_id, staker); - - // Calculate the expected resulting unbonding amount - let remaining_staked = init_state - .staker_info - .latest_staked_value() - .saturating_sub(value); - let expected_unbond_amount = if remaining_staked < MINIMUM_STAKING_AMOUNT { - init_state.staker_info.latest_staked_value() - } else { - value - }; - let remaining_staked = init_state.staker_info.latest_staked_value() - expected_unbond_amount; - - // Ensure op is successful and event is emitted - assert_ok!(DappsStaking::unbond_and_unstake( - RuntimeOrigin::signed(staker), - contract_id.clone(), - value - )); - System::assert_last_event(mock::RuntimeEvent::DappsStaking(Event::UnbondAndUnstake( - staker, - contract_id.clone(), - expected_unbond_amount, - ))); - - // Fetch the latest unbonding info so we can compare it to initial unbonding info - let final_state = MemorySnapshot::all(current_era, &contract_id, staker); - let expected_unlock_era = current_era + UNBONDING_PERIOD; - match init_state - .ledger - .unbonding_info - .vec() - .binary_search_by(|x| x.unlock_era.cmp(&expected_unlock_era)) - { - Ok(_) => assert_eq!( - init_state.ledger.unbonding_info.len(), - final_state.ledger.unbonding_info.len() - ), - Err(_) => assert_eq!( - init_state.ledger.unbonding_info.len() + 1, - final_state.ledger.unbonding_info.len() - ), - } - assert_eq!( - init_state.ledger.unbonding_info.sum() + expected_unbond_amount, - final_state.ledger.unbonding_info.sum() - ); - - // Push the unlocking chunk we expect to have at the end and compare two structs - let mut unbonding_info = init_state.ledger.unbonding_info.clone(); - unbonding_info.add(UnlockingChunk { - amount: expected_unbond_amount, - unlock_era: current_era + UNBONDING_PERIOD, - }); - assert_eq!(unbonding_info, final_state.ledger.unbonding_info); - - // Ensure that total locked value for staker hasn't been changed. - assert_eq!(init_state.ledger.locked, final_state.ledger.locked); - if final_state.ledger.is_empty() { - assert!(!Ledger::::contains_key(&staker)); - } - - // Ensure that total staked amount has been decreased for contract and staking points are updated - assert_eq!( - init_state.contract_info.total - expected_unbond_amount, - final_state.contract_info.total - ); - assert_eq!( - init_state.staker_info.latest_staked_value() - expected_unbond_amount, - final_state.staker_info.latest_staked_value() - ); - - // Ensure that the number of stakers is as expected - let delta = if remaining_staked > 0 { 0 } else { 1 }; - assert_eq!( - init_state.contract_info.number_of_stakers - delta, - final_state.contract_info.number_of_stakers - ); - - // Ensure that total staked value has been decreased - assert_eq!( - init_state.era_info.staked - expected_unbond_amount, - final_state.era_info.staked - ); - // Ensure that locked amount is the same since this will only start the unbonding period - assert_eq!(init_state.era_info.locked, final_state.era_info.locked); -} - -/// Used to perform start_unbonding with success and storage assertions. -pub(crate) fn assert_withdraw_unbonded(staker: AccountId) { - let current_era = DappsStaking::current_era(); - - let init_era_info = GeneralEraInfo::::get(current_era).unwrap(); - let init_ledger = Ledger::::get(&staker); - - // Get the current unlocking chunks - let (valid_info, remaining_info) = init_ledger.unbonding_info.partition(current_era); - let expected_unbond_amount = valid_info.sum(); - - // Ensure op is successful and event is emitted - assert_ok!(DappsStaking::withdraw_unbonded(RuntimeOrigin::signed( - staker - ),)); - System::assert_last_event(mock::RuntimeEvent::DappsStaking(Event::Withdrawn( - staker, - expected_unbond_amount, - ))); - - // Fetch the latest unbonding info so we can compare it to expected remainder - let final_ledger = Ledger::::get(&staker); - assert_eq!(remaining_info, final_ledger.unbonding_info); - if final_ledger.unbonding_info.is_empty() && final_ledger.locked == 0 { - assert!(!Ledger::::contains_key(&staker)); - } - - // Compare the ledger and total staked value - let final_rewards_and_stakes = GeneralEraInfo::::get(current_era).unwrap(); - assert_eq!(final_rewards_and_stakes.staked, init_era_info.staked); - assert_eq!( - final_rewards_and_stakes.locked, - init_era_info.locked - expected_unbond_amount - ); - assert_eq!( - final_ledger.locked, - init_ledger.locked - expected_unbond_amount - ); -} - -/// Used to perform nomination transfer with success and storage assertions. -pub(crate) fn assert_nomination_transfer( - staker: AccountId, - origin_contract_id: &MockSmartContract, - value: Balance, - target_contract_id: &MockSmartContract, -) { - // Get latest staking info - let current_era = DappsStaking::current_era(); - let origin_init_state = MemorySnapshot::all(current_era, &origin_contract_id, staker); - let target_init_state = MemorySnapshot::all(current_era, &target_contract_id, staker); - - // Calculate value which will actually be transfered - let init_staked_value = origin_init_state.staker_info.latest_staked_value(); - let expected_transfer_amount = if init_staked_value - value >= MINIMUM_STAKING_AMOUNT { - value - } else { - init_staked_value - }; - - // Ensure op is successful and event is emitted - assert_ok!(DappsStaking::nomination_transfer( - RuntimeOrigin::signed(staker), - origin_contract_id.clone(), - value, - target_contract_id.clone() - )); - System::assert_last_event(mock::RuntimeEvent::DappsStaking(Event::NominationTransfer( - staker, - origin_contract_id.clone(), - expected_transfer_amount, - target_contract_id.clone(), - ))); - - let origin_final_state = MemorySnapshot::all(current_era, &origin_contract_id, staker); - let target_final_state = MemorySnapshot::all(current_era, &target_contract_id, staker); - - // Ensure staker info has increased/decreased staked amount - assert_eq!( - origin_final_state.staker_info.latest_staked_value(), - init_staked_value - expected_transfer_amount - ); - assert_eq!( - target_final_state.staker_info.latest_staked_value(), - target_init_state.staker_info.latest_staked_value() + expected_transfer_amount - ); - - // Ensure total value staked on contracts has appropriately increased/decreased - assert_eq!( - origin_final_state.contract_info.total, - origin_init_state.contract_info.total - expected_transfer_amount - ); - assert_eq!( - target_final_state.contract_info.total, - target_init_state.contract_info.total + expected_transfer_amount - ); - - // Ensure number of contracts has been reduced on origin contract if it is fully unstaked - let origin_contract_fully_unstaked = init_staked_value == expected_transfer_amount; - if origin_contract_fully_unstaked { - assert_eq!( - origin_final_state.contract_info.number_of_stakers + 1, - origin_init_state.contract_info.number_of_stakers - ); - } - - // Ensure number of contracts has been increased on target contract it is first stake by the staker - let no_init_stake_on_target_contract = target_init_state - .staker_info - .latest_staked_value() - .is_zero(); - if no_init_stake_on_target_contract { - assert_eq!( - target_final_state.contract_info.number_of_stakers, - target_init_state.contract_info.number_of_stakers + 1 - ); - } - - // Ensure DB entry has been removed if era stake vector is empty - let fully_unstaked_and_nothing_to_claim = - origin_contract_fully_unstaked && origin_final_state.staker_info.clone().claim() == (0, 0); - if fully_unstaked_and_nothing_to_claim { - assert!(!GeneralStakerInfo::::contains_key( - &staker, - &origin_contract_id - )); - } -} - -/// Used to perform claim for stakers with success assertion -pub(crate) fn assert_claim_staker(claimer: AccountId, contract_id: &MockSmartContract) { - let (claim_era, _) = DappsStaking::staker_info(&claimer, contract_id).claim(); - let current_era = DappsStaking::current_era(); - - //clean up possible leftover events - System::reset_events(); - - let init_state_claim_era = MemorySnapshot::all(claim_era, contract_id, claimer); - let init_state_current_era = MemorySnapshot::all(current_era, contract_id, claimer); - - // Calculate contract portion of the reward - let (_, stakers_joint_reward) = DappsStaking::dev_stakers_split( - &init_state_claim_era.contract_info, - &init_state_claim_era.era_info, - ); - - let (claim_era, staked) = init_state_claim_era.staker_info.clone().claim(); - assert!(claim_era > 0); // Sanity check - if this fails, method is being used incorrectly - - // Cannot claim rewards post unregister era, this indicates a bug! - if let DAppState::Unregistered(unregistered_era) = init_state_claim_era.dapp_info.state { - assert!(unregistered_era > claim_era); - } - - let calculated_reward = - Perbill::from_rational(staked, init_state_claim_era.contract_info.total) - * stakers_joint_reward; - let issuance_before_claim = ::Currency::total_issuance(); - - assert_ok!(DappsStaking::claim_staker( - RuntimeOrigin::signed(claimer), - contract_id.clone(), - )); - - let final_state_current_era = MemorySnapshot::all(current_era, contract_id, claimer); - - // assert staked and free balances depending on restake check, - assert_restake_reward( - &init_state_current_era, - &final_state_current_era, - calculated_reward, - ); - - // check for stake event if restaking is performed - if DappsStaking::should_restake_reward( - init_state_current_era.ledger.reward_destination, - init_state_current_era.dapp_info.state, - init_state_current_era.staker_info.latest_staked_value(), - ) { - // There should be at least 2 events, Reward and BondAndStake. - // if there's less, panic is acceptable - let events = dapps_staking_events(); - let second_last_event = &events[events.len() - 2]; - assert_eq!( - second_last_event.clone(), - Event::::BondAndStake(claimer, contract_id.clone(), calculated_reward) - ); - } - - // last event should be Reward, regardless of restaking - System::assert_last_event(mock::RuntimeEvent::DappsStaking(Event::Reward( - claimer, - contract_id.clone(), - claim_era, - calculated_reward, - ))); - - let (new_era, _) = final_state_current_era.staker_info.clone().claim(); - if final_state_current_era.staker_info.is_empty() { - assert!(new_era.is_zero()); - assert!(!GeneralStakerInfo::::contains_key( - &claimer, - contract_id - )); - } else { - assert!(new_era > claim_era); - } - assert!(new_era.is_zero() || new_era > claim_era); - - // Claim shouldn't mint new tokens, instead it should just transfer from the dapps staking pallet account - let issuance_after_claim = ::Currency::total_issuance(); - assert_eq!(issuance_before_claim, issuance_after_claim); - - // Old `claim_era` contract info should never be changed - let final_state_claim_era = MemorySnapshot::all(claim_era, contract_id, claimer); - assert_eq!( - init_state_claim_era.contract_info, - final_state_claim_era.contract_info - ); -} - -// assert staked and locked states depending on should_restake_reward -// returns should_restake_reward result so further checks can be made -fn assert_restake_reward( - init_state_current_era: &MemorySnapshot, - final_state_current_era: &MemorySnapshot, - reward: Balance, -) { - if DappsStaking::should_restake_reward( - init_state_current_era.ledger.reward_destination, - init_state_current_era.dapp_info.state, - init_state_current_era.staker_info.latest_staked_value(), - ) { - // staked values should increase - assert_eq!( - init_state_current_era.staker_info.latest_staked_value() + reward, - final_state_current_era.staker_info.latest_staked_value() - ); - assert_eq!( - init_state_current_era.era_info.staked + reward, - final_state_current_era.era_info.staked - ); - assert_eq!( - init_state_current_era.era_info.locked + reward, - final_state_current_era.era_info.locked - ); - assert_eq!( - init_state_current_era.contract_info.total + reward, - final_state_current_era.contract_info.total - ); - } else { - // staked values should remain the same, and free balance increase - assert_eq!( - init_state_current_era.free_balance + reward, - final_state_current_era.free_balance - ); - assert_eq!( - init_state_current_era.era_info.staked, - final_state_current_era.era_info.staked - ); - assert_eq!( - init_state_current_era.era_info.locked, - final_state_current_era.era_info.locked - ); - assert_eq!( - init_state_current_era.contract_info, - final_state_current_era.contract_info - ); - } -} - -/// Used to perform claim for dApp reward with success assertion -pub(crate) fn assert_claim_dapp(contract_id: &MockSmartContract, claim_era: EraIndex) { - let developer = DappsStaking::dapp_info(contract_id).unwrap().developer; - let init_state = MemorySnapshot::all(claim_era, contract_id, developer); - assert!(!init_state.contract_info.contract_reward_claimed); - - // Cannot claim rewards post unregister era - if let DAppState::Unregistered(unregistered_era) = init_state.dapp_info.state { - assert!(unregistered_era > claim_era); - } - - // Calculate contract portion of the reward - let (calculated_reward, _) = - DappsStaking::dev_stakers_split(&init_state.contract_info, &init_state.era_info); - - assert_ok!(DappsStaking::claim_dapp( - RuntimeOrigin::signed(developer), - contract_id.clone(), - claim_era, - )); - System::assert_last_event(mock::RuntimeEvent::DappsStaking(Event::Reward( - developer, - contract_id.clone(), - claim_era, - calculated_reward, - ))); - - let final_state = MemorySnapshot::all(claim_era, &contract_id, developer); - assert_eq!( - init_state.free_balance + calculated_reward, - final_state.free_balance - ); - - assert!(final_state.contract_info.contract_reward_claimed); - - // Just in case dev is also a staker - this shouldn't cause any change in StakerInfo or Ledger - assert_eq!(init_state.staker_info, final_state.staker_info); - assert_eq!(init_state.ledger, final_state.ledger); -} - -// change reward destination and verify the update -pub(crate) fn assert_set_reward_destination( - account_id: AccountId, - reward_destination: RewardDestination, -) { - assert_ok!(DappsStaking::set_reward_destination( - RuntimeOrigin::signed(account_id), - reward_destination - )); - - System::assert_last_event(mock::RuntimeEvent::DappsStaking(Event::RewardDestination( - account_id, - reward_destination, - ))); - - let ledger = Ledger::::get(&account_id); - - assert_eq!(ledger.reward_destination, reward_destination); -} - -/// Used to burn stale rewards with success assertions -pub(crate) fn assert_burn_stale_reward( - contract_id: &MockSmartContract, - claim_era: EraIndex, -) { - let developer = DappsStaking::dapp_info(contract_id).unwrap().developer; - let init_state = MemorySnapshot::all(claim_era, contract_id, developer); - let issuance_before_claim = ::Currency::total_issuance(); - - assert!(!init_state.contract_info.contract_reward_claimed); - - // Calculate contract portion of the reward - let (calculated_reward, _) = - DappsStaking::dev_stakers_split(&init_state.contract_info, &init_state.era_info); - - assert_ok!(DappsStaking::burn_stale_reward( - RuntimeOrigin::root(), - contract_id.clone(), - claim_era, - )); - System::assert_last_event(mock::RuntimeEvent::DappsStaking(Event::StaleRewardBurned( - developer, - contract_id.clone(), - claim_era, - calculated_reward, - ))); - - let final_state = MemorySnapshot::all(claim_era, &contract_id, developer); - let issuance_after_claim = ::Currency::total_issuance(); - assert_eq!(init_state.free_balance, final_state.free_balance); - assert!(final_state.contract_info.contract_reward_claimed); - assert_eq!( - issuance_before_claim - calculated_reward, - issuance_after_claim - ); -} diff --git a/pallets/dapps-staking/src/tests.rs b/pallets/dapps-staking/src/tests.rs deleted file mode 100644 index c91ec0b78d..0000000000 --- a/pallets/dapps-staking/src/tests.rs +++ /dev/null @@ -1,2604 +0,0 @@ -// This file is part of Astar. - -// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later - -// Astar 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. - -// Astar 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 Astar. If not, see . - -use super::{pallet::pallet::Error, pallet::pallet::Event, *}; -use frame_support::{ - assert_noop, assert_ok, assert_storage_noop, - traits::{Currency, Get, OnFinalize, OnInitialize}, - weights::Weight, -}; -use mock::{Balance, Balances, MockSmartContract, *}; -use sp_core::H160; -use sp_runtime::{ - traits::{BadOrigin, Zero}, - Perbill, -}; - -use ::assert_matches::assert_matches; - -use testing_utils::*; - -#[test] -fn on_initialize_when_dapp_staking_enabled_in_mid_of_an_era_is_ok() { - ExternalityBuilder::build().execute_with(|| { - // Set a block number in mid of an era - System::set_block_number(2); - - // Verify that current era is 0 since dapps staking hasn't been initialized yet - assert_eq!(0u32, DappsStaking::current_era()); - - // Call on initialize in the mid of an era (according to block number calculation) - // but since no era was initialized before, it will trigger a new era init. - DappsStaking::on_initialize(System::block_number()); - assert_eq!(1u32, DappsStaking::current_era()); - }) -} - -#[test] -fn rewards_is_ok() { - ExternalityBuilder::build().execute_with(|| { - // At the beginning, both should be 0 - assert_eq!( - BlockRewardAccumulator::::get(), - Default::default() - ); - assert!(free_balance_of_dapps_staking_account().is_zero()); - - // After handling imbalance, accumulator and account should be updated - let dapps_reward = 12345; - let stakers_reward = 9999; - let total_reward = dapps_reward + stakers_reward; - DappsStaking::rewards( - Balances::issue(stakers_reward), - Balances::issue(dapps_reward), - ); - - assert_eq!(total_reward, free_balance_of_dapps_staking_account()); - let reward_accumulator = BlockRewardAccumulator::::get(); - assert_eq!(reward_accumulator.stakers, stakers_reward); - assert_eq!(reward_accumulator.dapps, dapps_reward); - - // After triggering a new era, accumulator should be set to 0 but account shouldn't consume any new imbalance - DappsStaking::on_initialize(System::block_number()); - assert_eq!( - BlockRewardAccumulator::::get(), - Default::default() - ); - assert_eq!(total_reward, free_balance_of_dapps_staking_account()); - }) -} - -#[test] -fn on_initialize_is_ok() { - ExternalityBuilder::build().execute_with(|| { - // Before we start, era is zero - assert!(DappsStaking::current_era().is_zero()); - - // We initialize the first block and advance to second one. New era must be triggered. - initialize_first_block(); - let current_era = DappsStaking::current_era(); - assert_eq!(1, current_era); - - let previous_era = current_era; - advance_to_era(previous_era + 10); - - // Check that all reward&stakes are as expected - let current_era = DappsStaking::current_era(); - for era in 1..current_era { - let reward_info = GeneralEraInfo::::get(era).unwrap().rewards; - assert_eq!( - get_total_reward_per_era(), - reward_info.stakers + reward_info.dapps - ); - } - // Current era rewards should be 0 - let era_rewards = GeneralEraInfo::::get(current_era).unwrap(); - assert_eq!(0, era_rewards.staked); - assert_eq!(era_rewards.rewards, Default::default()); - }) -} - -#[test] -fn new_era_length_is_always_blocks_per_era() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - let blocks_per_era = mock::BLOCKS_PER_ERA; - - // go to beginning of an era - advance_to_era(mock::DappsStaking::current_era() + 1); - - // record era number and block number - let start_era = mock::DappsStaking::current_era(); - let starting_block_number = System::block_number(); - - // go to next era - advance_to_era(mock::DappsStaking::current_era() + 1); - let ending_block_number = System::block_number(); - - // make sure block number difference is is blocks_per_era - assert_eq!(mock::DappsStaking::current_era(), start_era + 1); - assert_eq!(ending_block_number - starting_block_number, blocks_per_era); - }) -} - -#[test] -fn new_era_is_handled_with_maintenance_mode() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - // enable maintenance mode - assert_ok!(DappsStaking::maintenance_mode(RuntimeOrigin::root(), true)); - assert!(PalletDisabled::::exists()); - System::assert_last_event(mock::RuntimeEvent::DappsStaking(Event::MaintenanceMode( - true, - ))); - - // advance 9 blocks or 3 era lengths (advance_to_era() doesn't work in maintenance mode) - run_for_blocks(mock::BLOCKS_PER_ERA * 3); - - // verify that `current block > NextEraStartingBlock` but era hasn't changed - assert!(System::block_number() > DappsStaking::next_era_starting_block()); - assert_eq!(DappsStaking::current_era(), 1); - - // disable maintenance mode - assert_ok!(DappsStaking::maintenance_mode(RuntimeOrigin::root(), false)); - System::assert_last_event(mock::RuntimeEvent::DappsStaking(Event::MaintenanceMode( - false, - ))); - - // advance one era - run_for_blocks(mock::BLOCKS_PER_ERA); - - // verify we're at block 14 - assert_eq!(System::block_number(), (4 * mock::BLOCKS_PER_ERA) + 2); // 2 from initialization, advanced 4 eras worth of blocks - - // verify era was updated and NextEraStartingBlock is 15 - assert_eq!(DappsStaking::current_era(), 2); - assert_eq!( - DappsStaking::next_era_starting_block(), - (5 * mock::BLOCKS_PER_ERA) - ); - }) -} - -#[test] -fn new_forced_era_length_is_always_blocks_per_era() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - let blocks_per_era = mock::BLOCKS_PER_ERA; - - // go to beginning of an era - advance_to_era(mock::DappsStaking::current_era() + 1); - - // go to middle of era - run_for_blocks(1); // can be any number between 0 and blocks_per_era - - // force new era - >::put(Forcing::ForceNew); - run_for_blocks(1); // calls on_initialize() - - // note the start block number of new (forced) era - let start_block_number = System::block_number(); - - // go to start of next era - advance_to_era(mock::DappsStaking::current_era() + 1); - - // show the length of the forced era is equal to blocks_per_era - let end_block_number = System::block_number(); - assert_eq!(end_block_number - start_block_number, blocks_per_era); - }) -} - -#[test] -fn new_era_is_ok() { - ExternalityBuilder::build().execute_with(|| { - // set initial era index - advance_to_era(DappsStaking::current_era() + 10); - let starting_era = DappsStaking::current_era(); - - // verify that block reward is zero at the beginning of an era - assert_eq!(DappsStaking::block_reward_accumulator(), Default::default()); - - // Increment block by setting it to the first block in era value - run_for_blocks(1); - let current_era = DappsStaking::current_era(); - assert_eq!(starting_era, current_era); - - // verify that block reward is added to the block_reward_accumulator - let block_reward = DappsStaking::block_reward_accumulator(); - assert_eq!( - joint_block_reward(), - block_reward.stakers + block_reward.dapps - ); - - // register and bond to verify storage item - let staker = 2; - let developer = 3; - let staked_amount = 100; - let contract = MockSmartContract::Evm(H160::repeat_byte(0x01)); - assert_register(developer, &contract); - assert_bond_and_stake(staker, &contract, staked_amount); - - // CurrentEra should be incremented - // block_reward_accumulator should be reset to 0 - advance_to_era(DappsStaking::current_era() + 1); - - let current_era = DappsStaking::current_era(); - assert_eq!(starting_era + 1, current_era); - System::assert_last_event(mock::RuntimeEvent::DappsStaking(Event::NewDappStakingEra( - starting_era + 1, - ))); - - // verify that block reward accumulator is reset to 0 - let block_reward = DappsStaking::block_reward_accumulator(); - assert_eq!(block_reward, Default::default()); - - let expected_era_reward = get_total_reward_per_era(); - let expected_dapps_reward = DAPP_BLOCK_REWARD * BLOCKS_PER_ERA as Balance; - let expected_stakers_reward = STAKER_BLOCK_REWARD * BLOCKS_PER_ERA as Balance; - - // verify that .staked is copied and .reward is added - let era_rewards = GeneralEraInfo::::get(starting_era).unwrap(); - assert_eq!(staked_amount, era_rewards.staked); - assert_eq!( - expected_era_reward, - era_rewards.rewards.dapps + era_rewards.rewards.stakers - ); - assert_eq!(expected_dapps_reward, era_rewards.rewards.dapps); - assert_eq!(expected_stakers_reward, era_rewards.rewards.stakers); - }) -} - -#[test] -fn new_era_forcing() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - advance_to_era(3); - let starting_era = mock::DappsStaking::current_era(); - - // call on_initialize. It is not last block in the era, but it should increment the era - >::put(Forcing::ForceNew); - run_for_blocks(1); - - // check that era is incremented - let current = mock::DappsStaking::current_era(); - assert_eq!(starting_era + 1, current); - - // check that forcing is cleared - assert_eq!(mock::DappsStaking::force_era(), Forcing::NotForcing); - - // check the event for the new era - System::assert_last_event(mock::RuntimeEvent::DappsStaking(Event::NewDappStakingEra( - starting_era + 1, - ))); - }) -} - -#[test] -fn general_staker_info_is_ok() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let first_contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - assert_register(10, &first_contract_id); - - let second_contract_id = MockSmartContract::Evm(H160::repeat_byte(0x02)); - assert_register(11, &second_contract_id); - - let (staker_1, staker_2, staker_3) = (1, 2, 3); - let amount = 100; - - let starting_era = 3; - advance_to_era(starting_era); - assert_bond_and_stake(staker_1, &first_contract_id, amount); - assert_bond_and_stake(staker_2, &first_contract_id, amount); - - let mid_era = 7; - advance_to_era(mid_era); - assert_unbond_and_unstake(staker_2, &first_contract_id, amount); - assert_bond_and_stake(staker_3, &first_contract_id, amount); - assert_bond_and_stake(staker_3, &second_contract_id, amount); - - let final_era = 12; - advance_to_era(final_era); - - // Check first interval - let mut first_staker_info = DappsStaking::staker_info(&staker_1, &first_contract_id); - let mut second_staker_info = DappsStaking::staker_info(&staker_2, &first_contract_id); - let mut third_staker_info = DappsStaking::staker_info(&staker_3, &first_contract_id); - - for era in starting_era..mid_era { - let contract_info = DappsStaking::contract_stake_info(&first_contract_id, era).unwrap(); - assert_eq!(2, contract_info.number_of_stakers); - - assert_eq!((era, amount), first_staker_info.claim()); - assert_eq!((era, amount), second_staker_info.claim()); - - assert!(!ContractEraStake::::contains_key( - &second_contract_id, - era - )); - } - - // Check second interval - for era in mid_era..=final_era { - let first_contract_info = - DappsStaking::contract_stake_info(&first_contract_id, era).unwrap(); - assert_eq!(2, first_contract_info.number_of_stakers); - - assert_eq!((era, amount), first_staker_info.claim()); - assert_eq!((era, amount), third_staker_info.claim()); - - assert_eq!( - DappsStaking::contract_stake_info(&second_contract_id, era) - .unwrap() - .number_of_stakers, - 1 - ); - } - - // Check that before starting era nothing exists - assert!(!ContractEraStake::::contains_key( - &first_contract_id, - starting_era - 1 - )); - assert!(!ContractEraStake::::contains_key( - &second_contract_id, - starting_era - 1 - )); - }) -} - -#[test] -fn register_is_ok() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let developer = 1; - let ok_contract = MockSmartContract::Evm(H160::repeat_byte(0x01)); - - assert!(::Currency::reserved_balance(&developer).is_zero()); - assert_register(developer, &ok_contract); - System::assert_last_event(mock::RuntimeEvent::DappsStaking(Event::NewContract( - developer, - ok_contract, - ))); - - assert_eq!( - RegisterDeposit::get(), - ::Currency::reserved_balance(&developer) - ); - }) -} - -#[test] -fn register_with_non_root_fails() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let developer = 1; - let ok_contract = MockSmartContract::Evm(H160::repeat_byte(0x01)); - - assert_noop!( - DappsStaking::register(RuntimeOrigin::signed(developer), developer, ok_contract), - BadOrigin - ); - }) -} - -#[test] -fn register_twice_with_same_account_fails() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let developer = 1; - let contract1 = MockSmartContract::Evm(H160::repeat_byte(0x01)); - let contract2 = MockSmartContract::Evm(H160::repeat_byte(0x02)); - - assert_register(developer, &contract1); - - System::assert_last_event(mock::RuntimeEvent::DappsStaking(Event::NewContract( - developer, contract1, - ))); - - // now register different contract with same account - assert_noop!( - DappsStaking::register(RuntimeOrigin::root(), developer, contract2), - Error::::AlreadyUsedDeveloperAccount - ); - }) -} - -#[test] -fn register_same_contract_twice_fails() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let developer1 = 1; - let developer2 = 2; - let contract = MockSmartContract::Evm(H160::repeat_byte(0x01)); - - assert_register(developer1, &contract); - - System::assert_last_event(mock::RuntimeEvent::DappsStaking(Event::NewContract( - developer1, contract, - ))); - - // now register same contract by different developer - assert_noop!( - DappsStaking::register(RuntimeOrigin::root(), developer2, contract), - Error::::AlreadyRegisteredContract - ); - }) -} - -#[test] -fn unregister_after_register_is_ok() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let developer = 1; - let contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - - assert_register(developer, &contract_id); - assert_unregister(developer, &contract_id); - assert!(::Currency::reserved_balance(&developer).is_zero()); - - // Not possible to unregister a contract twice - assert_noop!( - DappsStaking::unregister(RuntimeOrigin::root(), contract_id.clone()), - Error::::NotOperatedContract - ); - }) -} - -#[test] -fn unregister_with_non_root() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let developer = 1; - let contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - - assert_register(developer, &contract_id); - - // Not possible to unregister if caller isn't root - assert_noop!( - DappsStaking::unregister(RuntimeOrigin::signed(developer), contract_id.clone()), - BadOrigin - ); - }) -} - -#[test] -fn unregister_stake_and_unstake_is_not_ok() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let developer = 1; - let staker = 2; - let contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - - // Register contract, stake it, unstake a bit - assert_register(developer, &contract_id); - assert_bond_and_stake(staker, &contract_id, 100); - assert_unbond_and_unstake(staker, &contract_id, 10); - - // Unregister contract and verify that stake & unstake no longer work - assert_unregister(developer, &contract_id); - - assert_noop!( - DappsStaking::bond_and_stake(RuntimeOrigin::signed(staker), contract_id.clone(), 100), - Error::::NotOperatedContract - ); - assert_noop!( - DappsStaking::unbond_and_unstake( - RuntimeOrigin::signed(staker), - contract_id.clone(), - 100 - ), - Error::::NotOperatedContract - ); - }) -} - -#[test] -fn withdraw_from_unregistered_is_ok() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let developer = 1; - let dummy_developer = 2; - let staker_1 = 3; - let staker_2 = 4; - let staked_value_1 = 150; - let staked_value_2 = 330; - let contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - let dummy_contract_id = MockSmartContract::Evm(H160::repeat_byte(0x05)); - - // Register both contracts and stake them - assert_register(developer, &contract_id); - assert_register(dummy_developer, &dummy_contract_id); - assert_bond_and_stake(staker_1, &contract_id, staked_value_1); - assert_bond_and_stake(staker_2, &contract_id, staked_value_2); - - // This contract will just exist so it helps us with testing ledger content - assert_bond_and_stake(staker_1, &dummy_contract_id, staked_value_1); - - // Advance eras. This will accumulate some rewards. - advance_to_era(5); - - assert_unregister(developer, &contract_id); - - // Claim all past rewards - for era in 1..DappsStaking::current_era() { - assert_claim_staker(staker_1, &contract_id); - assert_claim_staker(staker_2, &contract_id); - assert_claim_dapp(&contract_id, era); - } - - // Unbond everything from the contract. - assert_withdraw_from_unregistered(staker_1, &contract_id); - assert_withdraw_from_unregistered(staker_2, &contract_id); - - // No additional claim ops should be possible - assert_noop!( - DappsStaking::claim_staker(RuntimeOrigin::signed(staker_1), contract_id.clone()), - Error::::NotStakedContract - ); - assert_noop!( - DappsStaking::claim_staker(RuntimeOrigin::signed(staker_2), contract_id.clone()), - Error::::NotStakedContract - ); - assert_noop!( - DappsStaking::claim_dapp( - RuntimeOrigin::signed(developer), - contract_id.clone(), - DappsStaking::current_era() - ), - Error::::NotOperatedContract - ); - }) -} - -#[test] -fn withdraw_from_unregistered_when_contract_doesnt_exist() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - assert_noop!( - DappsStaking::withdraw_from_unregistered(RuntimeOrigin::signed(1), contract_id), - Error::::NotOperatedContract - ); - }) -} - -#[test] -fn withdraw_from_unregistered_when_contract_is_still_registered() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let developer = 1; - let contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - assert_register(developer, &contract_id); - - assert_noop!( - DappsStaking::withdraw_from_unregistered(RuntimeOrigin::signed(1), contract_id), - Error::::NotUnregisteredContract - ); - }) -} - -#[test] -fn withdraw_from_unregistered_when_nothing_is_staked() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let developer = 1; - let contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - assert_register(developer, &contract_id); - - let staker = 2; - let no_staker = 3; - assert_bond_and_stake(staker, &contract_id, 100); - - assert_unregister(developer, &contract_id); - - // No staked amount so call should fail. - assert_noop!( - DappsStaking::withdraw_from_unregistered(RuntimeOrigin::signed(no_staker), contract_id), - Error::::NotStakedContract - ); - - // Call should fail if called twice since no staked funds remain. - assert_withdraw_from_unregistered(staker, &contract_id); - assert_noop!( - DappsStaking::withdraw_from_unregistered(RuntimeOrigin::signed(staker), contract_id), - Error::::NotStakedContract - ); - }) -} - -#[test] -fn withdraw_from_unregistered_when_unclaimed_rewards_remaining() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let developer = 1; - let contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - assert_register(developer, &contract_id); - - let staker = 2; - assert_bond_and_stake(staker, &contract_id, 100); - - // Advance eras. This will accumulate some rewards. - advance_to_era(5); - - assert_unregister(developer, &contract_id); - - for _ in 1..DappsStaking::current_era() { - assert_noop!( - DappsStaking::withdraw_from_unregistered( - RuntimeOrigin::signed(staker), - contract_id - ), - Error::::UnclaimedRewardsRemaining - ); - assert_claim_staker(staker, &contract_id); - } - - // Withdraw should work after all rewards have been claimed - assert_withdraw_from_unregistered(staker, &contract_id); - }) -} - -#[test] -fn bond_and_stake_different_eras_is_ok() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let staker_id = 1; - let contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - assert_register(20, &contract_id); - - // initially, storage values should be None - let current_era = DappsStaking::current_era(); - assert!(DappsStaking::contract_stake_info(&contract_id, current_era).is_none()); - - assert_bond_and_stake(staker_id, &contract_id, 100); - - advance_to_era(current_era + 2); - - // Stake and bond again on the same contract but using a different amount. - assert_bond_and_stake(staker_id, &contract_id, 300); - }) -} - -#[test] -fn bond_and_stake_two_different_contracts_is_ok() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let staker_id = 1; - let first_contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - let second_contract_id = MockSmartContract::Evm(H160::repeat_byte(0x02)); - - // Insert contracts under registered contracts. Don't use the staker Id. - assert_register(5, &first_contract_id); - assert_register(6, &second_contract_id); - - // Stake on both contracts. - assert_bond_and_stake(staker_id, &first_contract_id, 100); - assert_bond_and_stake(staker_id, &second_contract_id, 300); - }) -} - -#[test] -fn bond_and_stake_two_stakers_one_contract_is_ok() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let first_staker_id = 1; - let second_staker_id = 2; - let first_stake_value = 50; - let second_stake_value = 235; - let contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - - // Insert a contract under registered contracts. - assert_register(10, &contract_id); - - // Both stakers stake on the same contract, expect a pass. - assert_bond_and_stake(first_staker_id, &contract_id, first_stake_value); - assert_bond_and_stake(second_staker_id, &contract_id, second_stake_value); - }) -} - -#[test] -fn bond_and_stake_different_value_is_ok() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let staker_id = 1; - let contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - - // Insert a contract under registered contracts. - assert_register(20, &contract_id); - - // Bond&stake almost the entire available balance of the staker. - let staker_free_balance = - Balances::free_balance(&staker_id).saturating_sub(MINIMUM_REMAINING_AMOUNT); - assert_bond_and_stake(staker_id, &contract_id, staker_free_balance - 1); - - // Bond&stake again with less than existential deposit but this time expect a pass - // since we're only increasing the already staked amount. - assert_bond_and_stake(staker_id, &contract_id, 1); - - // Bond&stake more than what's available in funds. Verify that only what's available is bonded&staked. - let staker_id = 2; - let staker_free_balance = Balances::free_balance(&staker_id); - assert_bond_and_stake(staker_id, &contract_id, staker_free_balance + 1); - - // Verify the minimum transferable amount of stakers account - let transferable_balance = - Balances::free_balance(&staker_id) - Ledger::::get(staker_id).locked; - assert_eq!(MINIMUM_REMAINING_AMOUNT, transferable_balance); - - // Bond&stake some amount, a bit less than free balance - let staker_id = 3; - let staker_free_balance = - Balances::free_balance(&staker_id).saturating_sub(MINIMUM_REMAINING_AMOUNT); - assert_bond_and_stake(staker_id, &contract_id, staker_free_balance - 200); - - // Try to bond&stake more than we have available (since we already locked most of the free balance). - assert_bond_and_stake(staker_id, &contract_id, 500); - }) -} - -#[test] -fn bond_and_stake_on_unregistered_contract_fails() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let staker_id = 1; - let stake_value = 100; - - // Check not registered contract. Expect an error. - let evm_contract = MockSmartContract::Evm(H160::repeat_byte(0x01)); - assert_noop!( - DappsStaking::bond_and_stake( - RuntimeOrigin::signed(staker_id), - evm_contract, - stake_value - ), - Error::::NotOperatedContract - ); - }) -} - -#[test] -fn bond_and_stake_insufficient_value() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - let staker_id = 1; - let contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - - // Insert a contract under registered contracts. - assert_register(20, &contract_id); - - // If user tries to make an initial bond&stake with less than minimum amount, raise an error. - assert_noop!( - DappsStaking::bond_and_stake( - RuntimeOrigin::signed(staker_id), - contract_id.clone(), - MINIMUM_STAKING_AMOUNT - 1 - ), - Error::::InsufficientValue - ); - - // Now bond&stake the entire stash so we lock all the available funds. - let staker_free_balance = Balances::free_balance(&staker_id); - assert_bond_and_stake(staker_id, &contract_id, staker_free_balance); - - // Now try to bond&stake some additional funds and expect an error since we cannot bond&stake 0. - assert_noop!( - DappsStaking::bond_and_stake(RuntimeOrigin::signed(staker_id), contract_id.clone(), 1), - Error::::StakingWithNoValue - ); - }) -} - -#[test] -fn bond_and_stake_too_many_stakers_per_contract() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - // Insert a contract under registered contracts. - assert_register(10, &contract_id); - - // Stake with MAX_NUMBER_OF_STAKERS on the same contract. It must work. - for staker_id in 1..=MAX_NUMBER_OF_STAKERS { - assert_bond_and_stake(staker_id.into(), &contract_id, 100); - } - - // Now try to stake with an additional staker and expect an error. - assert_noop!( - DappsStaking::bond_and_stake( - RuntimeOrigin::signed((1 + MAX_NUMBER_OF_STAKERS).into()), - contract_id.clone(), - 100 - ), - Error::::MaxNumberOfStakersExceeded - ); - }) -} - -#[test] -fn bond_and_stake_too_many_era_stakes() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let staker_id = 1; - let contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - // Insert a contract under registered contracts. - assert_register(10, &contract_id); - - // Stake with MAX_NUMBER_OF_STAKERS - 1 on the same contract. It must work. - let start_era = DappsStaking::current_era(); - for offset in 1..MAX_ERA_STAKE_VALUES { - assert_bond_and_stake(staker_id, &contract_id, 100); - advance_to_era(start_era + offset); - } - - // Now try to stake with an additional staker and expect an error. - assert_noop!( - DappsStaking::bond_and_stake(RuntimeOrigin::signed(staker_id), contract_id, 100), - Error::::TooManyEraStakeValues - ); - }) -} - -#[test] -fn unbond_and_unstake_multiple_time_is_ok() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let staker_id = 1; - let contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - let original_staked_value = 300 + MINIMUM_STAKING_AMOUNT; - let old_era = DappsStaking::current_era(); - - // Insert a contract under registered contracts, bond&stake it. - assert_register(10, &contract_id); - assert_bond_and_stake(staker_id, &contract_id, original_staked_value); - advance_to_era(old_era + 1); - - // Unstake such an amount so there will remain staked funds on the contract - let unstaked_value = 100; - assert_unbond_and_unstake(staker_id, &contract_id, unstaked_value); - - // Unbond yet again, but don't advance era - // Unstake such an amount so there will remain staked funds on the contract - let unstaked_value = 50; - assert_unbond_and_unstake(staker_id, &contract_id, unstaked_value); - }) -} - -#[test] -fn unbond_and_unstake_value_below_staking_threshold() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let staker_id = 1; - let contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - let first_value_to_unstake = 300; - let staked_value = first_value_to_unstake + MINIMUM_STAKING_AMOUNT; - - // Insert a contract under registered contracts, bond&stake it. - assert_register(10, &contract_id); - assert_bond_and_stake(staker_id, &contract_id, staked_value); - - // Unstake such an amount that exactly minimum staking amount will remain staked. - assert_unbond_and_unstake(staker_id, &contract_id, first_value_to_unstake); - - // Unstake 1 token and expect that the entire staked amount will be unstaked. - assert_unbond_and_unstake(staker_id, &contract_id, 1); - }) -} - -#[test] -fn unbond_and_unstake_in_different_eras() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let (first_staker_id, second_staker_id) = (1, 2); - let contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - let staked_value = 500; - - // Insert a contract under registered contracts, bond&stake it with two different stakers. - assert_register(10, &contract_id); - assert_bond_and_stake(first_staker_id, &contract_id, staked_value); - assert_bond_and_stake(second_staker_id, &contract_id, staked_value); - - // Advance era, unbond&withdraw with first staker, verify that it was successful - advance_to_era(DappsStaking::current_era() + 10); - let current_era = DappsStaking::current_era(); - assert_unbond_and_unstake(first_staker_id, &contract_id, 100); - - // Advance era, unbond with second staker and verify storage values are as expected - advance_to_era(current_era + 10); - assert_unbond_and_unstake(second_staker_id, &contract_id, 333); - }) -} - -#[test] -fn unbond_and_unstake_calls_in_same_era_can_exceed_max_chunks() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - assert_register(10, &contract_id); - - let staker = 1; - assert_bond_and_stake(staker, &contract_id, 200 * MAX_UNLOCKING_CHUNKS as Balance); - - // Ensure that we can unbond up to a limited amount of time. - for _ in 0..MAX_UNLOCKING_CHUNKS * 2 { - assert_unbond_and_unstake(1, &contract_id, 10); - assert_eq!(1, Ledger::::get(&staker).unbonding_info.len()); - } - }) -} - -#[test] -fn unbond_and_unstake_with_zero_value_is_not_ok() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - assert_register(10, &contract_id); - - assert_noop!( - DappsStaking::unbond_and_unstake(RuntimeOrigin::signed(1), contract_id, 0), - Error::::UnstakingWithNoValue - ); - }) -} - -#[test] -fn unbond_and_unstake_on_not_operated_contract_is_not_ok() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - assert_noop!( - DappsStaking::unbond_and_unstake(RuntimeOrigin::signed(1), contract_id, 100), - Error::::NotOperatedContract - ); - }) -} - -#[test] -fn unbond_and_unstake_too_many_unlocking_chunks_is_not_ok() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - assert_register(10, &contract_id); - - let staker = 1; - let unstake_amount = 10; - let stake_amount = - MINIMUM_STAKING_AMOUNT * 10 + unstake_amount * MAX_UNLOCKING_CHUNKS as Balance; - - assert_bond_and_stake(staker, &contract_id, stake_amount); - - // Ensure that we can unbond up to a limited amount of time. - for _ in 0..MAX_UNLOCKING_CHUNKS { - advance_to_era(DappsStaking::current_era() + 1); - assert_unbond_and_unstake(staker, &contract_id, unstake_amount); - } - - // Ensure that we're at the max but can still add new chunks since it should be merged with the existing one - assert_eq!( - MAX_UNLOCKING_CHUNKS, - DappsStaking::ledger(&staker).unbonding_info.len() - ); - assert_unbond_and_unstake(staker, &contract_id, unstake_amount); - - // Ensure that further unbonding attempts result in an error. - advance_to_era(DappsStaking::current_era() + 1); - assert_noop!( - DappsStaking::unbond_and_unstake( - RuntimeOrigin::signed(staker), - contract_id.clone(), - unstake_amount - ), - Error::::TooManyUnlockingChunks, - ); - }) -} - -#[test] -fn unbond_and_unstake_on_not_staked_contract_is_not_ok() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - assert_register(10, &contract_id); - - assert_noop!( - DappsStaking::unbond_and_unstake(RuntimeOrigin::signed(1), contract_id, 10), - Error::::NotStakedContract, - ); - }) -} - -#[test] -fn unbond_and_unstake_too_many_era_stakes() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let staker_id = 1; - let contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - assert_register(10, &contract_id); - - // Fill up the `EraStakes` vec - let start_era = DappsStaking::current_era(); - for offset in 1..MAX_ERA_STAKE_VALUES { - assert_bond_and_stake(staker_id, &contract_id, 100); - advance_to_era(start_era + offset); - } - - // At this point, we have max allowed amount of `EraStake` values so we cannot create - // an additional one. - assert_noop!( - DappsStaking::unbond_and_unstake(RuntimeOrigin::signed(staker_id), contract_id, 10), - Error::::TooManyEraStakeValues - ); - }) -} - -#[ignore] -#[test] -fn unbond_and_unstake_with_no_chunks_allowed() { - // UT can be used to verify situation when MaxUnlockingChunks = 0. Requires mock modification. - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - // Sanity check - assert_eq!(::MaxUnlockingChunks::get(), 0); - - let contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - assert_register(10, &contract_id); - - let staker_id = 1; - assert_bond_and_stake(staker_id, &contract_id, 100); - - assert_noop!( - DappsStaking::unbond_and_unstake( - RuntimeOrigin::signed(staker_id), - contract_id.clone(), - 20 - ), - Error::::TooManyUnlockingChunks, - ); - }) -} - -#[test] -fn withdraw_unbonded_is_ok() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - assert_register(10, &contract_id); - - let staker_id = 1; - assert_bond_and_stake(staker_id, &contract_id, 1000); - - let first_unbond_value = 75; - let second_unbond_value = 39; - let initial_era = DappsStaking::current_era(); - - // Unbond some amount in the initial era - assert_unbond_and_unstake(staker_id, &contract_id, first_unbond_value); - - // Advance one era and then unbond some more - advance_to_era(initial_era + 1); - assert_unbond_and_unstake(staker_id, &contract_id, second_unbond_value); - - // Now advance one era before first chunks finishes the unbonding process - advance_to_era(initial_era + UNBONDING_PERIOD - 1); - assert_noop!( - DappsStaking::withdraw_unbonded(RuntimeOrigin::signed(staker_id)), - Error::::NothingToWithdraw - ); - - // Advance one additional era and expect that the first chunk can be withdrawn - advance_to_era(DappsStaking::current_era() + 1); - assert_ok!(DappsStaking::withdraw_unbonded(RuntimeOrigin::signed( - staker_id - ),)); - System::assert_last_event(mock::RuntimeEvent::DappsStaking(Event::Withdrawn( - staker_id, - first_unbond_value, - ))); - - // Advance one additional era and expect that the first chunk can be withdrawn - advance_to_era(DappsStaking::current_era() + 1); - assert_ok!(DappsStaking::withdraw_unbonded(RuntimeOrigin::signed( - staker_id - ),)); - System::assert_last_event(mock::RuntimeEvent::DappsStaking(Event::Withdrawn( - staker_id, - second_unbond_value, - ))); - - // Advance one additional era but since we have nothing else to withdraw, expect an error - advance_to_era(initial_era + UNBONDING_PERIOD - 1); - assert_noop!( - DappsStaking::withdraw_unbonded(RuntimeOrigin::signed(staker_id)), - Error::::NothingToWithdraw - ); - }) -} - -#[test] -fn withdraw_unbonded_full_vector_is_ok() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - assert_register(10, &contract_id); - - let staker_id = 1; - assert_bond_and_stake(staker_id, &contract_id, 1000); - - // Repeatedly start unbonding and advance era to create unlocking chunks - let init_unbonding_amount = 15; - for x in 1..=MAX_UNLOCKING_CHUNKS { - assert_unbond_and_unstake(staker_id, &contract_id, init_unbonding_amount * x as u128); - advance_to_era(DappsStaking::current_era() + 1); - } - - // Now clean up all that are eligible for clean-up - assert_withdraw_unbonded(staker_id); - - // This is a sanity check for the test. Some chunks should remain, otherwise test isn't testing realistic unbonding period. - assert!(!Ledger::::get(&staker_id) - .unbonding_info - .is_empty()); - - while !Ledger::::get(&staker_id) - .unbonding_info - .is_empty() - { - advance_to_era(DappsStaking::current_era() + 1); - assert_withdraw_unbonded(staker_id); - } - }) -} - -#[test] -fn withdraw_unbonded_no_value_is_not_ok() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - assert_noop!( - DappsStaking::withdraw_unbonded(RuntimeOrigin::signed(1)), - Error::::NothingToWithdraw, - ); - }) -} - -#[ignore] -#[test] -fn withdraw_unbonded_no_unbonding_period() { - // UT can be used to verify situation when UnbondingPeriod = 0. Requires mock modification. - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - // Sanity check - assert_eq!(::UnbondingPeriod::get(), 0); - - let contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - assert_register(10, &contract_id); - - let staker_id = 1; - assert_bond_and_stake(staker_id, &contract_id, 100); - assert_unbond_and_unstake(staker_id, &contract_id, 20); - - // Try to withdraw but expect an error since current era hasn't passed yet - assert_noop!( - DappsStaking::withdraw_unbonded(RuntimeOrigin::signed(staker_id)), - Error::::NothingToWithdraw, - ); - - // Advance an era and expect successful withdrawal - advance_to_era(DappsStaking::current_era() + 1); - assert_withdraw_unbonded(staker_id); - }) -} - -#[test] -fn nomination_transfer_is_ok() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let origin_developer = 1; - let target_developer = 2; - let staker = 3; - let origin_contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - let target_contract_id = MockSmartContract::Evm(H160::repeat_byte(0x02)); - - assert_register(origin_developer, &origin_contract_id); - assert_register(target_developer, &target_contract_id); - assert_bond_and_stake(staker, &origin_contract_id, MINIMUM_STAKING_AMOUNT * 2); - - // The first transfer will ensure that both contracts are staked after operation is complete - assert_nomination_transfer( - staker, - &origin_contract_id, - MINIMUM_STAKING_AMOUNT, - &target_contract_id, - ); - assert!( - !GeneralStakerInfo::::get(&staker, &origin_contract_id) - .latest_staked_value() - .is_zero() - ); - - // The second operation should fully unstake origin contract since it takes it below minimum staking amount - assert_nomination_transfer( - staker, - &origin_contract_id, - MINIMUM_STAKING_AMOUNT, - &target_contract_id, - ); - assert!( - GeneralStakerInfo::::get(&staker, &origin_contract_id) - .latest_staked_value() - .is_zero() - ); - }) -} - -#[test] -fn nomination_transfer_to_same_contract_is_not_ok() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - let developer = 1; - let staker = 2; - let contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - - assert_register(developer, &contract_id); - - assert_noop!( - DappsStaking::nomination_transfer( - RuntimeOrigin::signed(staker), - contract_id, - 100, - contract_id, - ), - Error::::NominationTransferToSameContract - ); - }) -} - -#[test] -fn nomination_transfer_to_inactive_contracts_is_not_ok() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let origin_developer = 1; - let target_developer = 2; - let staker = 3; - let origin_contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - let target_contract_id = MockSmartContract::Evm(H160::repeat_byte(0x02)); - - // 1. Neither contract is registered - assert_noop!( - DappsStaking::nomination_transfer( - RuntimeOrigin::signed(staker), - origin_contract_id, - 100, - target_contract_id, - ), - Error::::NotOperatedContract - ); - - // 2. Only first contract is registered - assert_register(origin_developer, &origin_contract_id); - assert_noop!( - DappsStaking::nomination_transfer( - RuntimeOrigin::signed(staker), - origin_contract_id, - 100, - target_contract_id, - ), - Error::::NotOperatedContract - ); - - // 3. Both are registered but then target contract gets unregistered - assert_register(target_developer, &target_contract_id); - assert_bond_and_stake(staker, &origin_contract_id, 100); - assert_nomination_transfer(staker, &origin_contract_id, 100, &target_contract_id); - - assert_unregister(target_developer, &target_contract_id); - assert_noop!( - DappsStaking::nomination_transfer( - RuntimeOrigin::signed(staker), - origin_contract_id, - 100, - target_contract_id, - ), - Error::::NotOperatedContract - ); - - // 4. Origin contract is unregistered - assert_unregister(origin_developer, &origin_contract_id); - assert_noop!( - DappsStaking::nomination_transfer( - RuntimeOrigin::signed(staker), - origin_contract_id, - 100, - target_contract_id, - ), - Error::::NotOperatedContract - ); - }) -} - -#[test] -fn nomination_transfer_from_not_staked_contract() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let origin_developer = 1; - let target_developer = 2; - let staker = 3; - let origin_contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - let target_contract_id = MockSmartContract::Evm(H160::repeat_byte(0x02)); - - assert_register(origin_developer, &origin_contract_id); - assert_register(target_developer, &target_contract_id); - - assert_noop!( - DappsStaking::nomination_transfer( - RuntimeOrigin::signed(staker), - origin_contract_id.clone(), - 20, - target_contract_id.clone() - ), - Error::::NotStakedContract - ); - }) -} - -#[test] -fn nomination_transfer_with_no_value() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let origin_developer = 1; - let target_developer = 2; - let staker = 3; - let origin_contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - let target_contract_id = MockSmartContract::Evm(H160::repeat_byte(0x02)); - - assert_register(origin_developer, &origin_contract_id); - assert_register(target_developer, &target_contract_id); - assert_bond_and_stake(staker, &origin_contract_id, 100); - - assert_noop!( - DappsStaking::nomination_transfer( - RuntimeOrigin::signed(staker), - origin_contract_id.clone(), - Zero::zero(), - target_contract_id.clone() - ), - Error::::UnstakingWithNoValue - ); - }) -} - -#[test] -fn nomination_transfer_with_insufficient_value() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let origin_developer = 1; - let target_developer = 2; - let staker = 3; - let origin_contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - let target_contract_id = MockSmartContract::Evm(H160::repeat_byte(0x02)); - - assert_register(origin_developer, &origin_contract_id); - assert_register(target_developer, &target_contract_id); - assert_bond_and_stake(staker, &origin_contract_id, 100); - - assert_noop!( - DappsStaking::nomination_transfer( - RuntimeOrigin::signed(staker), - origin_contract_id.clone(), - MINIMUM_STAKING_AMOUNT - 1, - target_contract_id.clone() - ), - Error::::InsufficientValue - ); - }) -} - -#[test] -fn nomination_transfer_contracts_have_too_many_era_stake_values() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let origin_developer = 1; - let target_developer = 2; - let staker = 3; - let origin_contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - let target_contract_id = MockSmartContract::Evm(H160::repeat_byte(0x02)); - - assert_register(origin_developer, &origin_contract_id); - assert_register(target_developer, &target_contract_id); - - // Ensure we fill up era stakes vector - for _ in 1..MAX_ERA_STAKE_VALUES { - // We use bond&stake since its only limiting factor is max era stake values - assert_bond_and_stake(staker, &origin_contract_id, 15); - advance_to_era(DappsStaking::current_era() + 1); - } - assert_noop!( - DappsStaking::bond_and_stake( - RuntimeOrigin::signed(staker), - origin_contract_id.clone(), - 15 - ), - Error::::TooManyEraStakeValues - ); - - // Ensure it's not possible to transfer from origin contract since it's era stake values are maxed - assert_noop!( - DappsStaking::nomination_transfer( - RuntimeOrigin::signed(staker), - origin_contract_id.clone(), - 15, - target_contract_id.clone() - ), - Error::::TooManyEraStakeValues - ); - - // Swap origin and target to verify that same is true if target contract era stake values is maxed out - let (origin_contract_id, target_contract_id) = (target_contract_id, origin_contract_id); - assert_bond_and_stake(staker, &origin_contract_id, 15); - assert_noop!( - DappsStaking::nomination_transfer( - RuntimeOrigin::signed(staker), - origin_contract_id.clone(), - 15, - target_contract_id.clone() - ), - Error::::TooManyEraStakeValues - ); - }) -} - -#[test] -fn nomination_transfer_max_number_of_stakers_exceeded() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let origin_developer = 1; - let target_developer = 2; - // This one will only stake on origin contract - let first_staker = 3; - // This one will stake on both origin and target contracts - let second_staker = 4; - let origin_contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - let target_contract_id = MockSmartContract::Evm(H160::repeat_byte(0x02)); - - // Register contracts and bond&stake them with both stakers - assert_register(origin_developer, &origin_contract_id); - assert_register(target_developer, &target_contract_id); - - assert_bond_and_stake(first_staker, &origin_contract_id, 23); - assert_bond_and_stake(second_staker, &target_contract_id, 37); - assert_bond_and_stake(second_staker, &target_contract_id, 41); - - // Fill up the second contract with stakers until max number of stakers limit has been reached - for temp_staker in (second_staker + 1)..(MAX_NUMBER_OF_STAKERS as u64 + second_staker) { - Balances::resolve_creating(&temp_staker, Balances::issue(100)); - assert_bond_and_stake(temp_staker, &target_contract_id, 13); - } - // Sanity check + assurance that first_staker isn't staking on target contract - assert_noop!( - DappsStaking::bond_and_stake( - RuntimeOrigin::signed(first_staker), - target_contract_id.clone(), - 19 - ), - Error::::MaxNumberOfStakersExceeded - ); - - // Now attempt transfer nomination and expect an error - assert_noop!( - DappsStaking::nomination_transfer( - RuntimeOrigin::signed(first_staker), - origin_contract_id.clone(), - 19, - target_contract_id.clone(), - ), - Error::::MaxNumberOfStakersExceeded - ); - }) -} - -#[test] -fn claim_not_staked_contract() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let developer = 1; - let staker = 2; - let contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - - assert_register(developer, &contract_id); - - assert_noop!( - DappsStaking::claim_staker(RuntimeOrigin::signed(staker), contract_id), - Error::::NotStakedContract - ); - - advance_to_era(DappsStaking::current_era() + 1); - assert_noop!( - DappsStaking::claim_dapp(RuntimeOrigin::signed(developer), contract_id, 1), - Error::::NotStakedContract - ); - }) -} - -#[test] -fn claim_not_operated_contract() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let developer = 1; - let staker = 2; - let contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - - assert_register(developer, &contract_id); - assert_bond_and_stake(staker, &contract_id, 100); - - // Advance one era and unregister the contract - advance_to_era(DappsStaking::current_era() + 1); - assert_unregister(developer, &contract_id); - - // First claim should pass but second should fail because contract was unregistered - assert_claim_staker(staker, &contract_id); - assert_noop!( - DappsStaking::claim_staker(RuntimeOrigin::signed(staker), contract_id), - Error::::NotOperatedContract - ); - - assert_claim_dapp(&contract_id, 1); - assert_noop!( - DappsStaking::claim_dapp(RuntimeOrigin::signed(developer), contract_id, 2), - Error::::NotOperatedContract - ); - }) -} - -#[test] -fn claim_invalid_era() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let developer = 1; - let staker = 2; - let contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - - let start_era = DappsStaking::current_era(); - assert_register(developer, &contract_id); - assert_bond_and_stake(staker, &contract_id, 100); - advance_to_era(start_era + 5); - - for era in start_era..DappsStaking::current_era() { - assert_claim_staker(staker, &contract_id); - assert_claim_dapp(&contract_id, era); - } - - assert_noop!( - DappsStaking::claim_staker(RuntimeOrigin::signed(staker), contract_id), - Error::::EraOutOfBounds - ); - assert_noop!( - DappsStaking::claim_dapp( - RuntimeOrigin::signed(developer), - contract_id, - DappsStaking::current_era() - ), - Error::::EraOutOfBounds - ); - }) -} - -#[test] -fn claim_dapp_same_era_twice() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let developer = 1; - let staker = 2; - let contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - - let start_era = DappsStaking::current_era(); - assert_register(developer, &contract_id); - assert_bond_and_stake(staker, &contract_id, 100); - advance_to_era(start_era + 1); - - assert_claim_dapp(&contract_id, start_era); - assert_noop!( - DappsStaking::claim_dapp(RuntimeOrigin::signed(developer), contract_id, start_era), - Error::::AlreadyClaimedInThisEra - ); - }) -} - -#[test] -fn claim_is_ok() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let first_developer = 1; - let second_developer = 2; - let first_staker = 3; - let second_staker = 4; - let first_contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - let second_contract_id = MockSmartContract::Evm(H160::repeat_byte(0x02)); - - let start_era = DappsStaking::current_era(); - - // Prepare a scenario with different stakes - - assert_register(first_developer, &first_contract_id); - assert_register(second_developer, &second_contract_id); - assert_bond_and_stake(first_staker, &first_contract_id, 100); - assert_bond_and_stake(second_staker, &first_contract_id, 45); - - // Just so ratio isn't 100% in favor of the first contract - assert_bond_and_stake(first_staker, &second_contract_id, 33); - assert_bond_and_stake(second_staker, &second_contract_id, 22); - - let eras_advanced = 3; - advance_to_era(start_era + eras_advanced); - - for x in 0..eras_advanced.into() { - assert_bond_and_stake(first_staker, &first_contract_id, 20 + x * 3); - assert_bond_and_stake(second_staker, &first_contract_id, 5 + x * 5); - advance_to_era(DappsStaking::current_era() + 1); - } - - // Ensure that all past eras can be claimed - let current_era = DappsStaking::current_era(); - for era in start_era..current_era { - assert_claim_staker(first_staker, &first_contract_id); - assert_claim_dapp(&first_contract_id, era); - assert_claim_staker(second_staker, &first_contract_id); - } - - // Shouldn't be possible to claim current era. - // Also, previous claim calls should have claimed everything prior to current era. - assert_noop!( - DappsStaking::claim_staker( - RuntimeOrigin::signed(first_staker), - first_contract_id.clone() - ), - Error::::EraOutOfBounds - ); - assert_noop!( - DappsStaking::claim_dapp( - RuntimeOrigin::signed(first_developer), - first_contract_id, - current_era - ), - Error::::EraOutOfBounds - ); - }) -} - -#[test] -fn claim_after_unregister_is_ok() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let developer = 1; - let staker = 2; - let contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - - let start_era = DappsStaking::current_era(); - assert_register(developer, &contract_id); - let stake_value = 100; - assert_bond_and_stake(staker, &contract_id, stake_value); - - // Advance few eras, then unstake everything - advance_to_era(start_era + 5); - assert_unbond_and_unstake(staker, &contract_id, stake_value); - let full_unstake_era = DappsStaking::current_era(); - let number_of_staking_eras = full_unstake_era - start_era; - - // Few eras pass, then staker stakes again - advance_to_era(DappsStaking::current_era() + 3); - let stake_value = 75; - let restake_era = DappsStaking::current_era(); - assert_bond_and_stake(staker, &contract_id, stake_value); - - // Again, few eras pass then contract is unregistered - advance_to_era(DappsStaking::current_era() + 3); - assert_unregister(developer, &contract_id); - let unregister_era = DappsStaking::current_era(); - let number_of_staking_eras = number_of_staking_eras + unregister_era - restake_era; - advance_to_era(DappsStaking::current_era() + 2); - - // Ensure that staker can claim all the eras that he had an active stake - for _ in 0..number_of_staking_eras { - assert_claim_staker(staker, &contract_id); - } - assert_noop!( - DappsStaking::claim_staker(RuntimeOrigin::signed(staker), contract_id.clone()), - Error::::NotOperatedContract - ); - - // Ensure the same for dapp reward - for era in start_era..unregister_era { - if era >= full_unstake_era && era < restake_era { - assert_noop!( - DappsStaking::claim_dapp( - RuntimeOrigin::signed(developer), - contract_id.clone(), - era - ), - Error::::NotStakedContract - ); - } else { - assert_claim_dapp(&contract_id, era); - } - } - }) -} - -#[test] -fn claim_only_payout_is_ok() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let developer = 1; - let staker = 2; - let contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - - // stake some tokens - let start_era = DappsStaking::current_era(); - assert_register(developer, &contract_id); - let stake_value = 100; - assert_bond_and_stake(staker, &contract_id, stake_value); - - // disable reward restaking - advance_to_era(start_era + 1); - assert_set_reward_destination(staker, RewardDestination::FreeBalance); - - // ensure it's claimed correctly - assert_claim_staker(staker, &contract_id); - }) -} - -#[test] -fn claim_with_zero_staked_is_ok() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let developer = 1; - let staker = 2; - let contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - let start_era = DappsStaking::current_era(); - assert_register(developer, &contract_id); - - // stake some tokens and wait for an era - let stake_value = 100; - assert_bond_and_stake(staker, &contract_id, stake_value); - advance_to_era(start_era + 1); - - // ensure reward_destination is set to StakeBalance - assert_set_reward_destination(staker, RewardDestination::StakeBalance); - - // unstake all the tokens - assert_unbond_and_unstake(staker, &contract_id, stake_value); - - // ensure claimed value goes to claimer's free balance - assert_claim_staker(staker, &contract_id); - }) -} - -#[test] -fn claims_with_different_reward_destination_is_ok() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let developer = 1; - let staker = 2; - let contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - - // stake some tokens - let start_era = DappsStaking::current_era(); - assert_register(developer, &contract_id); - let stake_value = 100; - assert_bond_and_stake(staker, &contract_id, stake_value); - - // disable compounding mode, wait 3 eras - assert_set_reward_destination(staker, RewardDestination::FreeBalance); - advance_to_era(start_era + 1); - // ensure staker can claim rewards to wallet - assert_claim_staker(staker, &contract_id); - - // enable compounding mode, wait 3 eras - assert_set_reward_destination(staker, RewardDestination::StakeBalance); - advance_to_era(start_era + 2); - // ensure staker can claim with compounding - assert_claim_staker(staker, &contract_id); - }) -} - -#[test] -fn claiming_when_stakes_full_without_compounding_is_ok() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let staker_id = 1; - let contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - // Insert a contract under registered contracts. - assert_register(10, &contract_id); - - // Stake with MAX_ERA_STAKE_VALUES - 1 on the same contract. It must work. - let start_era = DappsStaking::current_era(); - for offset in 1..MAX_ERA_STAKE_VALUES { - assert_bond_and_stake(staker_id, &contract_id, 100); - advance_to_era(start_era + offset * 5); - } - - // Make sure reward_destination is set to StakeBalance - assert_set_reward_destination(staker_id, RewardDestination::StakeBalance); - - // claim and restake once, so there's a claim record for the for the current era in the stakes vec - assert_claim_staker(staker_id, &contract_id); - - // making another gap in eras and trying to claim and restake would exceed MAX_ERA_STAKE_VALUES - advance_to_era(DappsStaking::current_era() + 1); - assert_noop!( - DappsStaking::claim_staker(RuntimeOrigin::signed(staker_id), contract_id), - Error::::TooManyEraStakeValues - ); - - // set reward_destination to FreeBalance (disable restaking) - assert_set_reward_destination(staker_id, RewardDestination::FreeBalance); - - // claiming should work again - assert_claim_staker(staker_id, &contract_id); - }) -} - -#[test] -fn changing_reward_destination_for_empty_ledger_is_not_ok() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - let staker = 1; - assert_noop!( - DappsStaking::set_reward_destination( - RuntimeOrigin::signed(staker), - RewardDestination::FreeBalance - ), - Error::::NotActiveStaker - ); - }); -} - -#[test] -fn default_reward_destination_is_free_balance() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let staker = 1; - assert_eq!( - DappsStaking::ledger(&staker).reward_destination, - RewardDestination::FreeBalance - ); - }); -} - -#[test] -fn claim_dapp_with_zero_stake_periods_is_ok() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let developer = 1; - let staker = 2; - let contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - - // Prepare scenario: - - let start_era = DappsStaking::current_era(); - assert_register(developer, &contract_id); - let stake_value = 100; - assert_bond_and_stake(staker, &contract_id, stake_value); - - advance_to_era(start_era + 5); - let first_full_unstake_era = DappsStaking::current_era(); - assert_unbond_and_unstake(staker, &contract_id, stake_value); - - advance_to_era(DappsStaking::current_era() + 7); - let restake_era = DappsStaking::current_era(); - assert_bond_and_stake(staker, &contract_id, stake_value); - - advance_to_era(DappsStaking::current_era() + 4); - let second_full_unstake_era = DappsStaking::current_era(); - assert_unbond_and_unstake(staker, &contract_id, stake_value); - advance_to_era(DappsStaking::current_era() + 10); - - // Ensure that first interval can be claimed - for era in start_era..first_full_unstake_era { - assert_claim_dapp(&contract_id, era); - } - - // Ensure that the empty interval cannot be claimed - for era in first_full_unstake_era..restake_era { - assert_noop!( - DappsStaking::claim_dapp( - RuntimeOrigin::signed(developer), - contract_id.clone(), - era - ), - Error::::NotStakedContract - ); - } - - // Ensure that second interval can be claimed - for era in restake_era..second_full_unstake_era { - assert_claim_dapp(&contract_id, era); - } - - // Ensure no more claims are possible since contract was fully unstaked - assert_noop!( - DappsStaking::claim_dapp( - RuntimeOrigin::signed(developer), - contract_id.clone(), - second_full_unstake_era - ), - Error::::NotStakedContract - ); - - // Now stake again and ensure contract can once again be claimed - let last_claim_era = DappsStaking::current_era(); - assert_bond_and_stake(staker, &contract_id, stake_value); - advance_to_era(last_claim_era + 1); - assert_claim_dapp(&contract_id, last_claim_era); - }) -} - -#[test] -fn maintenance_mode_is_ok() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - assert_ok!(DappsStaking::ensure_pallet_enabled()); - assert!(!PalletDisabled::::exists()); - - assert_ok!(DappsStaking::maintenance_mode(RuntimeOrigin::root(), true)); - assert!(PalletDisabled::::exists()); - System::assert_last_event(mock::RuntimeEvent::DappsStaking(Event::MaintenanceMode( - true, - ))); - - let account = 1; - let contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - - // - // 1 - assert_noop!( - DappsStaking::register(RuntimeOrigin::root(), account, contract_id), - Error::::Disabled - ); - assert_noop!( - DappsStaking::unregister(RuntimeOrigin::root(), contract_id), - Error::::Disabled - ); - assert_noop!( - DappsStaking::withdraw_from_unregistered(RuntimeOrigin::signed(account), contract_id), - Error::::Disabled - ); - - // - // 2 - assert_noop!( - DappsStaking::bond_and_stake(RuntimeOrigin::signed(account), contract_id, 100), - Error::::Disabled - ); - assert_noop!( - DappsStaking::unbond_and_unstake(RuntimeOrigin::signed(account), contract_id, 100), - Error::::Disabled - ); - assert_noop!( - DappsStaking::claim_dapp(RuntimeOrigin::signed(account), contract_id, 5), - Error::::Disabled - ); - assert_noop!( - DappsStaking::claim_staker(RuntimeOrigin::signed(account), contract_id), - Error::::Disabled - ); - assert_noop!( - DappsStaking::withdraw_unbonded(RuntimeOrigin::signed(account)), - Error::::Disabled - ); - assert_noop!( - DappsStaking::nomination_transfer( - RuntimeOrigin::signed(account), - contract_id, - 100, - contract_id, - ), - Error::::Disabled - ); - assert_noop!( - DappsStaking::claim_staker_for(RuntimeOrigin::signed(account), account, contract_id), - Error::::Disabled - ); - assert_noop!( - DappsStaking::decommission(RuntimeOrigin::root()), - Error::::Disabled - ); - - // - // 3 - assert_noop!( - DappsStaking::force_new_era(RuntimeOrigin::root()), - Error::::Disabled - ); - // shouldn't do anything since we're in maintenance mode - assert_eq!(DappsStaking::on_initialize(3), Weight::zero()); - - // - // 4 - assert_ok!(DappsStaking::maintenance_mode(RuntimeOrigin::root(), false)); - System::assert_last_event(mock::RuntimeEvent::DappsStaking(Event::MaintenanceMode( - false, - ))); - assert_register(account, &contract_id); - }) -} - -#[test] -fn maintenance_mode_no_change() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - // Expect an error since maintenance mode is already disabled - assert_ok!(DappsStaking::ensure_pallet_enabled()); - assert_noop!( - DappsStaking::maintenance_mode(RuntimeOrigin::root(), false), - Error::::NoMaintenanceModeChange - ); - - // Same for the case when maintenance mode is already enabled - assert_ok!(DappsStaking::maintenance_mode(RuntimeOrigin::root(), true)); - assert_noop!( - DappsStaking::maintenance_mode(RuntimeOrigin::root(), true), - Error::::NoMaintenanceModeChange - ); - }) -} - -#[test] -fn decommision_is_ok() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - // Init sanity check - assert_ok!(DappsStaking::ensure_not_in_decommission()); - assert!(!DecommissionStarted::::exists()); - - // Enable decommission mode - assert_ok!(DappsStaking::decommission(RuntimeOrigin::root())); - assert!(DecommissionStarted::::get()); - System::assert_last_event(mock::RuntimeEvent::DappsStaking(Event::Decommission)); - - let account = 1; - let contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - - // Ensure that expected calls no longer work - assert_noop!( - DappsStaking::register(RuntimeOrigin::root(), account, contract_id), - Error::::DecommissionInProgress - ); - assert_noop!( - DappsStaking::unregister(RuntimeOrigin::root(), contract_id), - Error::::DecommissionInProgress - ); - assert_noop!( - DappsStaking::withdraw_from_unregistered(RuntimeOrigin::signed(account), contract_id), - Error::::DecommissionInProgress - ); - - assert_noop!( - DappsStaking::bond_and_stake(RuntimeOrigin::signed(account), contract_id, 100), - Error::::DecommissionInProgress - ); - assert_noop!( - DappsStaking::nomination_transfer( - RuntimeOrigin::signed(account), - contract_id, - 100, - contract_id, - ), - Error::::DecommissionInProgress - ); - - // Ensure that expected calls still work (or at least don't fail with `DecommissionInProgress` error) - assert_noop!( - DappsStaking::claim_staker(RuntimeOrigin::signed(account), contract_id,), - Error::::NotStakedContract - ); - assert_noop!( - DappsStaking::claim_dapp(RuntimeOrigin::signed(account), contract_id, 1,), - Error::::NotOperatedContract - ); - assert_noop!( - DappsStaking::unbond_and_unstake(RuntimeOrigin::signed(account), contract_id, 100), - Error::::NotOperatedContract - ); - assert_noop!( - DappsStaking::withdraw_unbonded(RuntimeOrigin::signed(account)), - Error::::NothingToWithdraw - ); - assert_noop!( - DappsStaking::set_reward_destination( - RuntimeOrigin::signed(account), - RewardDestination::StakeBalance - ), - Error::::NotActiveStaker - ); - }) -} - -#[test] -fn no_era_change_during_decommission() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - // Enable decommission mode and set the next era to start immediately after this block - assert_ok!(DappsStaking::decommission(RuntimeOrigin::root())); - NextEraStartingBlock::::put(System::block_number() + 1); - - // Ensure nothing happens during on_initialize - assert_storage_noop!(DappsStaking::on_finalize(System::block_number())); - assert_storage_noop!(DappsStaking::on_initialize(System::block_number() + 1)); - assert_storage_noop!(DappsStaking::on_finalize(System::block_number() + 1)); - assert_storage_noop!(DappsStaking::on_initialize(System::block_number() + 2)); - }) -} - -#[test] -fn dev_stakers_split_util() { - let base_stakers_reward = 7 * 11 * 13 * 17; - let base_dapps_reward = 19 * 23 * 31; - let staked_on_contract = 123456; - let total_staked = staked_on_contract * 3; - - // Prepare structs - let staking_points = ContractStakeInfo { - total: staked_on_contract, - number_of_stakers: 10, - contract_reward_claimed: false, - }; - let era_info = EraInfo { - rewards: RewardInfo { - dapps: base_dapps_reward, - stakers: base_stakers_reward, - }, - staked: total_staked, - locked: total_staked, - }; - - let (dev_reward, stakers_reward) = DappsStaking::dev_stakers_split(&staking_points, &era_info); - - let contract_stake_ratio = Perbill::from_rational(staked_on_contract, total_staked); - let calculated_stakers_reward = contract_stake_ratio * base_stakers_reward; - let calculated_dev_reward = contract_stake_ratio * base_dapps_reward; - assert_eq!(calculated_dev_reward, dev_reward); - assert_eq!(calculated_stakers_reward, stakers_reward); - - assert_eq!( - calculated_stakers_reward + calculated_dev_reward, - dev_reward + stakers_reward - ); -} - -#[test] -pub fn tvl_util_test() { - ExternalityBuilder::build().execute_with(|| { - // Ensure TVL is zero before first block and also after first block - assert!(DappsStaking::tvl().is_zero()); - initialize_first_block(); - assert!(DappsStaking::tvl().is_zero()); - - let developer = 1; - let contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - assert_register(developer, &contract_id); - - // Expect TVL to change as we bond&stake more - let iterations = 10; - let stake_value = 100; - for x in 1..=iterations { - assert_bond_and_stake(developer, &contract_id, stake_value); - assert_eq!(DappsStaking::tvl(), stake_value * x); - } - - // Era advancement should have no effect on TVL - advance_to_era(5); - assert_eq!(DappsStaking::tvl(), stake_value * iterations); - }) -} - -#[test] -pub fn set_contract_stake_info() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - assert_register(10, &contract_id); - - let staker_id = 1; - assert_bond_and_stake(staker_id, &contract_id, 1000); - - // Read current contract stake info, then overwrite it with different value - let original_contract_stake_info = - DappsStaking::contract_stake_info(&contract_id, 1).unwrap(); - let mut modified_info = original_contract_stake_info.clone(); - modified_info.total = modified_info.total + 17; - ContractEraStake::::insert(&contract_id, 1, modified_info); - - // Ensure only root can call it - assert_noop!( - DappsStaking::set_contract_stake_info( - RuntimeOrigin::signed(1), - contract_id.clone(), - 1, - original_contract_stake_info.clone() - ), - BadOrigin - ); - - // Verify we can fix the corrupted stroage - assert_ne!( - ContractEraStake::::get(&contract_id, 1).unwrap(), - original_contract_stake_info - ); - assert_ok!(DappsStaking::set_contract_stake_info( - RuntimeOrigin::root(), - contract_id.clone(), - 1, - original_contract_stake_info.clone() - )); - assert_eq!( - ContractEraStake::::get(&contract_id, 1).unwrap(), - original_contract_stake_info - ); - }) -} - -#[test] -fn custom_max_encoded_len() { - let max_unbonding_info_len = 10 * (4 + 16) + 1; - assert_eq!( - UnbondingInfo::max_encoded_len(), - max_unbonding_info_len as usize - ); - - let max_staker_info_len = 10 * (4 + 16) + 1; - assert_eq!(StakerInfo::max_encoded_len(), max_staker_info_len as usize); -} - -#[test] -fn burn_stale_reward_is_ok() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let developer = 1; - let staker = 3; - let contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - - let start_era = DappsStaking::current_era(); - - // Register & stake on contract - assert_register(developer, &contract_id); - assert_bond_and_stake(staker, &contract_id, 100); - - // Advance enough eras so stale rewards become burnable - let eras_advanced = REWARD_RETENTION_PERIOD + 1; - advance_to_era(start_era + eras_advanced); - assert_unregister(developer, &contract_id); - - assert_burn_stale_reward(&contract_id, start_era); - }) -} - -#[test] -fn burn_stale_reward_from_registered_dapp_fails() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let developer = 1; - let staker = 3; - let contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - - let start_era = DappsStaking::current_era(); - - // Register & stake on contract - assert_register(developer, &contract_id); - assert_bond_and_stake(staker, &contract_id, 100); - - // Advance enough eras so stale rewards would become burnable, in case dapp was unregistered - let eras_advanced = REWARD_RETENTION_PERIOD; - advance_to_era(start_era + eras_advanced); - - // Rewards shouldn't be burnable since retention period hasn't expired yet - assert_noop!( - DappsStaking::burn_stale_reward(RuntimeOrigin::root(), contract_id, start_era,), - Error::::NotUnregisteredContract - ); - }) -} - -#[test] -fn burn_stale_reward_before_retention_period_finished_fails() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let developer = 1; - let staker = 3; - let contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - - let start_era = DappsStaking::current_era(); - - // Register & stake on contract - assert_register(developer, &contract_id); - assert_bond_and_stake(staker, &contract_id, 100); - - // Advance enough eras so stale rewards become burnable - let eras_advanced = REWARD_RETENTION_PERIOD; - advance_to_era(start_era + eras_advanced); - assert_unregister(developer, &contract_id); - - // Rewards shouldn't be burnable since retention period hasn't expired yet - assert_noop!( - DappsStaking::burn_stale_reward(RuntimeOrigin::root(), contract_id, start_era,), - Error::::EraOutOfBounds - ); - }) -} - -#[test] -fn burn_stale_reward_negative_checks() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - let developer = 1; - let staker = 3; - let contract_id = MockSmartContract::Evm(H160::repeat_byte(0x01)); - - // Cannot burn from non-existing contract - assert_noop!( - DappsStaking::burn_stale_reward(RuntimeOrigin::root(), contract_id, 1,), - Error::::NotOperatedContract - ); - - // Cannot burn unless called with root privileges - assert_noop!( - DappsStaking::burn_stale_reward(RuntimeOrigin::signed(developer), contract_id, 1,), - BadOrigin - ); - - // Register & stake on contract - assert_register(developer, &contract_id); - assert_bond_and_stake(staker, &contract_id, 100); - - // Advance enough eras so stale rewards become burnable - let start_era = DappsStaking::current_era(); - let eras_advanced = REWARD_RETENTION_PERIOD + 2; - advance_to_era(start_era + eras_advanced); - assert_unregister(developer, &contract_id); - - // Claim them (before they are burned) - assert_claim_dapp(&contract_id, start_era); - - // No longer possible to burn if reward was claimed - assert_noop!( - DappsStaking::burn_stale_reward(RuntimeOrigin::root(), contract_id, start_era,), - Error::::AlreadyClaimedInThisEra - ); - }) -} - -#[test] -fn decommission_works() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - // Sanity check - assert!( - !DecommissionStarted::::get(), - "Init state must be false." - ); - - // Ensure non-root cannot call it - assert_noop!( - DappsStaking::decommission(RuntimeOrigin::signed(1)), - BadOrigin - ); - - // Assert post-call state - assert_ok!(DappsStaking::decommission(RuntimeOrigin::root())); - System::assert_last_event(mock::RuntimeEvent::DappsStaking(Event::Decommission)); - assert!( - DecommissionStarted::::get(), - "Must be true after decommission has started." - ); - }) -} - -#[test] -fn claim_staker_for_works() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - // Register a dApp and stake some amount on it - let developer = 1; - let claimer = 2; - let staker = claimer + 1; // has to be different - let smart_contract = MockSmartContract::Evm(H160::repeat_byte(0x02)); - assert_register(developer, &smart_contract); - assert_bond_and_stake(staker, &smart_contract, 17); - assert_set_reward_destination(staker, RewardDestination::StakeBalance); - - // Advance to next era so we can claim rewards for it - advance_to_era(DappsStaking::current_era() + 1); - - // 1. Call regular claim, and check the reward amount - let init_ledger = DappsStaking::ledger(&staker); - System::reset_events(); - assert_ok!(DappsStaking::claim_staker( - RuntimeOrigin::signed(staker), - smart_contract.clone() - )); - let post_ledger = DappsStaking::ledger(&staker); - - let (event_staker, init_reward) = match &System::events()[4].event { - mock::RuntimeEvent::DappsStaking(Event::Reward(staker, _, _, reward)) => (*staker, *reward), - _ => panic!("Unexpected event"), - }; - assert_eq!(event_staker, staker); - - assert_eq!( - post_ledger.locked, - init_ledger.locked + init_reward, - "We expect full reward to be re-locked" - ); - - // 2. Check that delegated claim works as expected - advance_to_era(DappsStaking::current_era() + 1); - System::reset_events(); - - let init_ledger = DappsStaking::ledger(&staker); - assert_ok!(DappsStaking::claim_staker_for( - RuntimeOrigin::signed(claimer), - staker, - smart_contract.clone() - )); - let post_ledger = DappsStaking::ledger(&staker); - - // We expect 6 events in total - // - 2 events related to reward withdraw & deposit - // - 2 restake events - // - 1 event related to dApps staking reward - // - 1 events related to delegated claim fee deposit - let events = System::events(); - assert_eq!(events.len(), 6); - - // Deposit the reward to the caller. Reward must be reduced by the delegate claim fee amount. - let fee_amount = ::DelegateClaimFee::get(); - let expected_reward = init_reward - fee_amount; - assert!(expected_reward > fee_amount, "Reward must be greater than fee amount"); - assert_matches!( - events[4].event, - mock::RuntimeEvent::DappsStaking(Event::Reward(staker, _, _, reward)) if staker == staker && reward == expected_reward - ); - - // Deposit the call refund fee to the caller. - assert_matches!( - events[5].event, - mock::RuntimeEvent::Balances(pallet_balances::Event::Deposit{who, amount}) if who == claimer && amount == fee_amount - ); - - assert_eq!( - post_ledger.locked, - init_ledger.locked + expected_reward, - "We expect the reward to be relocked, but it should be reduced by the fee amount." - ); - }) -} - -#[test] -fn claim_staker_for_fails_if_caller_is_same_as_staker() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - // Register a dApp and stake some amount on it - let developer = 1; - let staker = 2; - let smart_contract = MockSmartContract::Evm(H160::repeat_byte(0x02)); - assert_register(developer, &smart_contract); - assert_bond_and_stake(staker, &smart_contract, 13); - - // Advance to next era so we can claim rewards for it - advance_to_era(DappsStaking::current_era() + 1); - - assert_noop!( - DappsStaking::claim_staker_for( - RuntimeOrigin::signed(staker), - staker, - smart_contract.clone() - ), - Error::::ClaimForCallerAccount - ); - }) -} - -#[test] -fn set_reward_destination_for_works() { - ExternalityBuilder::build().execute_with(|| { - initialize_first_block(); - - // Register a dApp and stake some amount on it - let developer = 1; - let caller = 2; - let staker = caller + 1; // has to be different - let smart_contract = MockSmartContract::Evm(H160::repeat_byte(0x02)); - assert_register(developer, &smart_contract); - assert_bond_and_stake(staker, &smart_contract, 17); - - assert_ok!(DappsStaking::set_reward_destination_for( - RuntimeOrigin::signed(caller), - staker, - RewardDestination::StakeBalance - )); - - // The reward destination must be set for the staker, not the caller. - System::assert_last_event(mock::RuntimeEvent::DappsStaking(Event::RewardDestination( - staker, - RewardDestination::StakeBalance, - ))); - }) -} diff --git a/pallets/dapps-staking/src/tests_lib.rs b/pallets/dapps-staking/src/tests_lib.rs deleted file mode 100644 index 142f55e44d..0000000000 --- a/pallets/dapps-staking/src/tests_lib.rs +++ /dev/null @@ -1,310 +0,0 @@ -// This file is part of Astar. - -// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later - -// Astar 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. - -// Astar 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 Astar. If not, see . - -use super::*; -use frame_support::assert_ok; -use mock::Balance; - -#[test] -fn unbonding_info_test() { - let mut unbonding_info = UnbondingInfo::default(); - - // assert basic ops on empty info - assert!(unbonding_info.is_empty()); - assert!(unbonding_info.len().is_zero()); - let (first_info, second_info) = unbonding_info.clone().partition(2); - assert!(first_info.is_empty()); - assert!(second_info.is_empty()); - - // Prepare unlocking chunks. - let count = 5; - let base_amount: Balance = 100; - let base_unlock_era = 4 * count; - let mut chunks = vec![]; - for x in 1_u32..=count as u32 { - chunks.push(UnlockingChunk { - amount: base_amount * x as Balance, - unlock_era: base_unlock_era - 3 * x, - }); - } - - // Add one unlocking chunk and verify basic ops. - unbonding_info.add(chunks[0 as usize]); - - assert!(!unbonding_info.is_empty()); - assert_eq!(1, unbonding_info.len()); - assert_eq!(chunks[0 as usize].amount, unbonding_info.sum()); - - let (first_info, second_info) = unbonding_info.clone().partition(base_unlock_era); - assert_eq!(1, first_info.len()); - assert_eq!(chunks[0 as usize].amount, first_info.sum()); - assert!(second_info.is_empty()); - - // Add remainder and verify basic ops - for x in unbonding_info.len() as usize..chunks.len() { - unbonding_info.add(chunks[x]); - // Ensure internal vec is sorted - assert!(unbonding_info - .vec() - .windows(2) - .all(|w| w[0].unlock_era <= w[1].unlock_era)); - } - assert_eq!(chunks.len(), unbonding_info.len() as usize); - let total: Balance = chunks.iter().map(|c| c.amount).sum(); - assert_eq!(total, unbonding_info.sum()); - - let partition_era = chunks[2].unlock_era + 1; - let (first_info, second_info) = unbonding_info.clone().partition(partition_era); - assert_eq!(3, first_info.len()); - assert_eq!(2, second_info.len()); - assert_eq!(unbonding_info.sum(), first_info.sum() + second_info.sum()); -} - -#[test] -fn staker_info_basic() { - let staker_info = StakerInfo::default(); - - assert!(staker_info.is_empty()); - assert_eq!(staker_info.len(), 0); - assert_eq!(staker_info.latest_staked_value(), 0); -} - -#[test] -fn staker_info_stake_ops() { - let mut staker_info = StakerInfo::default(); - - // Do first stake and verify it - let first_era = 1; - let first_stake = 100; - assert_ok!(staker_info.stake(first_era, first_stake)); - assert!(!staker_info.is_empty()); - assert_eq!(staker_info.len(), 1); - assert_eq!(staker_info.latest_staked_value(), first_stake); - - // Do second stake and verify it - let second_era = first_era + 1; - let second_stake = 200; - assert_ok!(staker_info.stake(second_era, second_stake)); - assert_eq!(staker_info.len(), 2); - assert_eq!( - staker_info.latest_staked_value(), - first_stake + second_stake - ); - - // Do third stake and verify it - let third_era = second_era + 2; // must be greater than 1 so a `hole` is present - let third_stake = 333; - assert_ok!(staker_info.stake(third_era, third_stake)); - assert_eq!( - staker_info.latest_staked_value(), - first_stake + second_stake + third_stake - ); - assert_eq!(staker_info.len(), 3); - - // Do fourth stake and verify it - let fourth_era = third_era; // ensure that multi-stake in same era works - let fourth_stake = 444; - assert_ok!(staker_info.stake(fourth_era, fourth_stake)); - assert_eq!(staker_info.len(), 3); - assert_eq!( - staker_info.latest_staked_value(), - first_stake + second_stake + third_stake + fourth_stake - ); -} - -#[test] -fn staker_info_stake_error() { - let mut staker_info = StakerInfo::default(); - assert_ok!(staker_info.stake(5, 100)); - if let Err(_) = staker_info.stake(4, 100) { - } else { - panic!("Mustn't be able to stake with past era."); - } -} - -#[test] -fn staker_info_unstake_ops() { - let mut staker_info = StakerInfo::default(); - - // Unstake on empty staker_info - assert!(staker_info.is_empty()); - assert_ok!(staker_info.unstake(1, 100)); - assert!(staker_info.is_empty()); - - // Prepare some stakes - let (first_era, second_era) = (1, 3); - let (first_stake, second_stake) = (110, 222); - let total_staked = first_stake + second_stake; - assert_ok!(staker_info.stake(first_era, first_stake)); - assert_ok!(staker_info.stake(second_era, second_stake)); - - // Unstake an existing EraStake - let first_unstake_era = second_era; - let first_unstake = 55; - assert_ok!(staker_info.unstake(first_unstake_era, first_unstake)); - assert_eq!(staker_info.len(), 2); - assert_eq!( - staker_info.latest_staked_value(), - total_staked - first_unstake - ); - let total_staked = total_staked - first_unstake; - - // Unstake an non-existing EraStake - let second_unstake_era = first_unstake_era + 2; - let second_unstake = 37; - assert_ok!(staker_info.unstake(second_unstake_era, second_unstake)); - assert_eq!(staker_info.len(), 3); - assert_eq!( - staker_info.latest_staked_value(), - total_staked - second_unstake - ); - let total_staked = total_staked - second_unstake; - - // Save this for later - let temp_staker_info = staker_info.clone(); - - // Fully unstake existing EraStake - assert_ok!(staker_info.unstake(second_unstake_era, total_staked)); - assert_eq!(staker_info.len(), 3); - assert_eq!(staker_info.latest_staked_value(), 0); - - // Fully unstake non-existing EraStake - let mut staker_info = temp_staker_info; // restore - assert_ok!(staker_info.unstake(second_unstake_era + 1, total_staked)); - assert_eq!(staker_info.len(), 4); - assert_eq!(staker_info.latest_staked_value(), 0); -} - -#[test] -fn stake_after_full_unstake() { - let mut staker_info = StakerInfo::default(); - - // Stake some amount - let first_era = 1; - let first_stake = 100; - assert_ok!(staker_info.stake(first_era, first_stake)); - assert_eq!(staker_info.latest_staked_value(), first_stake); - - // Unstake all in next era - let unstake_era = first_era + 1; - assert_ok!(staker_info.unstake(unstake_era, first_stake)); - assert!(staker_info.latest_staked_value().is_zero()); - assert_eq!(staker_info.len(), 2); - - // Stake again in the next era - let restake_era = unstake_era + 2; - let restake_value = 57; - assert_ok!(staker_info.stake(restake_era, restake_value)); - assert_eq!(staker_info.latest_staked_value(), restake_value); - assert_eq!(staker_info.len(), 3); -} - -#[test] -fn staker_info_unstake_error() { - let mut staker_info = StakerInfo::default(); - assert_ok!(staker_info.stake(5, 100)); - if let Err(_) = staker_info.unstake(4, 100) { - } else { - panic!("Mustn't be able to unstake with past era."); - } -} - -#[test] -fn staker_info_claim_ops_basic() { - let mut staker_info = StakerInfo::default(); - - // Empty staker info - assert!(staker_info.is_empty()); - assert_eq!(staker_info.claim(), (0, 0)); - assert!(staker_info.is_empty()); - - // Only one unstaked exists - assert_ok!(staker_info.stake(1, 100)); - assert_ok!(staker_info.unstake(1, 100)); - assert!(staker_info.is_empty()); - assert_eq!(staker_info.claim(), (0, 0)); - assert!(staker_info.is_empty()); - - // Only one staked exists - staker_info = StakerInfo::default(); - let stake_era = 1; - let stake_value = 123; - assert_ok!(staker_info.stake(stake_era, stake_value)); - assert_eq!(staker_info.len(), 1); - assert_eq!(staker_info.claim(), (stake_era, stake_value)); - assert_eq!(staker_info.len(), 1); -} - -#[test] -fn staker_info_claim_ops_advanced() { - let mut staker_info = StakerInfo::default(); - - // Two consecutive eras staked, third era contains a gap with the second one - let (first_stake_era, second_stake_era, third_stake_era) = (1, 2, 4); - let (first_stake_value, second_stake_value, third_stake_value) = (123, 456, 789); - - assert_ok!(staker_info.stake(first_stake_era, first_stake_value)); - assert_ok!(staker_info.stake(second_stake_era, second_stake_value)); - assert_ok!(staker_info.stake(third_stake_era, third_stake_value)); - - // First claim - assert_eq!(staker_info.len(), 3); - assert_eq!(staker_info.claim(), (first_stake_era, first_stake_value)); - assert_eq!(staker_info.len(), 2); - - // Second claim - assert_eq!( - staker_info.claim(), - (second_stake_era, first_stake_value + second_stake_value) - ); - assert_eq!(staker_info.len(), 2); - - // Third claim, expect that 3rd era stake is the same as second - assert_eq!( - staker_info.claim(), - (3, first_stake_value + second_stake_value) - ); - assert_eq!(staker_info.len(), 1); - - // Fully unstake 5th era - let total_staked = first_stake_value + second_stake_value + third_stake_value; - assert_ok!(staker_info.unstake(5, total_staked)); - assert_eq!(staker_info.len(), 2); - - // Stake 7th era (so after it was unstaked) - let fourth_era = 7; - let fourth_stake_value = 147; - assert_ok!(staker_info.stake(fourth_era, fourth_stake_value)); - assert_eq!(staker_info.len(), 3); - - // Claim 4th era - assert_eq!(staker_info.claim(), (third_stake_era, total_staked)); - assert_eq!(staker_info.len(), 1); - - // Claim 7th era - assert_eq!(staker_info.claim(), (fourth_era, fourth_stake_value)); - assert_eq!(staker_info.len(), 1); - assert_eq!(staker_info.latest_staked_value(), fourth_stake_value); - - // Claim future eras - for x in 1..10 { - assert_eq!(staker_info.claim(), (fourth_era + x, fourth_stake_value)); - assert_eq!(staker_info.len(), 1); - assert_eq!(staker_info.latest_staked_value(), fourth_stake_value); - } -} diff --git a/pallets/dapps-staking/src/weights.rs b/pallets/dapps-staking/src/weights.rs deleted file mode 100644 index 193e088310..0000000000 --- a/pallets/dapps-staking/src/weights.rs +++ /dev/null @@ -1,422 +0,0 @@ -// This file is part of Astar. - -// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later - -// Astar 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. - -// Astar 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 Astar. If not, see . - -//! Autogenerated weights for pallet_dapps_staking -//! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-04-04, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `devserver-01`, CPU: `Intel(R) Xeon(R) E-2236 CPU @ 3.40GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("shibuya-dev"), DB CACHE: 1024 - -// Executed Command: -// ./target/release/astar-collator -// benchmark -// pallet -// --chain=shibuya-dev -// --steps=50 -// --repeat=20 -// --pallet=pallet_dapps_staking -// --extrinsic=* -// --execution=wasm -// --wasm-execution=compiled -// --heap-pages=4096 -// --output=./benchmark-results/dapps_staking_weights.rs -// --template=./scripts/templates/weight-template.hbs - -#![cfg_attr(rustfmt, rustfmt_skip)] -#![allow(unused_parens)] -#![allow(unused_imports)] - -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; -use sp_std::marker::PhantomData; - -/// Weight functions needed for pallet_dapps_staking. -pub trait WeightInfo { - fn register() -> Weight; - fn unregister() -> Weight; - fn withdraw_from_unregistered() -> Weight; - fn bond_and_stake() -> Weight; - fn unbond_and_unstake() -> Weight; - fn withdraw_unbonded() -> Weight; - fn nomination_transfer() -> Weight; - fn claim_staker_with_restake() -> Weight; - fn claim_staker_without_restake() -> Weight; - fn claim_dapp() -> Weight; - fn force_new_era() -> Weight; - fn maintenance_mode() -> Weight; - fn set_reward_destination() -> Weight; -} - -/// Weights for pallet_dapps_staking using the Substrate node and recommended hardware. -pub struct SubstrateWeight(PhantomData); -impl WeightInfo for SubstrateWeight { - // Storage: DappsStaking RegisteredDevelopers (r:1 w:1) - // Proof: DappsStaking RegisteredDevelopers (max_values: None, max_size: Some(81), added: 2556, mode: MaxEncodedLen) - // Storage: DappsStaking RegisteredDapps (r:1 w:1) - // Proof: DappsStaking RegisteredDapps (max_values: None, max_size: Some(86), added: 2561, mode: MaxEncodedLen) - fn register() -> Weight { - // Minimum execution time: 25_265 nanoseconds. - Weight::from_parts(26_091_000, 0) - .saturating_add(Weight::from_parts(0, 5117)) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) - } - // Storage: DappsStaking RegisteredDapps (r:1 w:1) - // Proof: DappsStaking RegisteredDapps (max_values: None, max_size: Some(86), added: 2561, mode: MaxEncodedLen) - // Storage: System Account (r:1 w:1) - // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - fn unregister() -> Weight { - // Minimum execution time: 27_241 nanoseconds. - Weight::from_parts(27_411_000, 0) - .saturating_add(Weight::from_parts(0, 5164)) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) - } - // Storage: DappsStaking RegisteredDapps (r:1 w:0) - // Proof: DappsStaking RegisteredDapps (max_values: None, max_size: Some(86), added: 2561, mode: MaxEncodedLen) - // Storage: DappsStaking GeneralStakerInfo (r:1 w:1) - // Proof: DappsStaking GeneralStakerInfo (max_values: None, max_size: Some(298), added: 2773, mode: MaxEncodedLen) - // Storage: DappsStaking Ledger (r:1 w:1) - // Proof: DappsStaking Ledger (max_values: None, max_size: Some(266), added: 2741, mode: MaxEncodedLen) - // Storage: Balances Locks (r:1 w:1) - // Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) - // Storage: System Account (r:1 w:1) - // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - // Storage: DappsStaking GeneralEraInfo (r:1 w:1) - // Proof: DappsStaking GeneralEraInfo (max_values: None, max_size: Some(76), added: 2551, mode: MaxEncodedLen) - fn withdraw_from_unregistered() -> Weight { - // Minimum execution time: 44_491 nanoseconds. - Weight::from_parts(45_042_000, 0) - .saturating_add(Weight::from_parts(0, 17003)) - .saturating_add(T::DbWeight::get().reads(6_u64)) - .saturating_add(T::DbWeight::get().writes(5_u64)) - } - // Storage: DappsStaking RegisteredDapps (r:1 w:0) - // Proof: DappsStaking RegisteredDapps (max_values: None, max_size: Some(86), added: 2561, mode: MaxEncodedLen) - // Storage: DappsStaking Ledger (r:1 w:1) - // Proof: DappsStaking Ledger (max_values: None, max_size: Some(266), added: 2741, mode: MaxEncodedLen) - // Storage: DappsStaking ContractEraStake (r:1 w:1) - // Proof: DappsStaking ContractEraStake (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) - // Storage: DappsStaking GeneralStakerInfo (r:1 w:1) - // Proof: DappsStaking GeneralStakerInfo (max_values: None, max_size: Some(298), added: 2773, mode: MaxEncodedLen) - // Storage: DappsStaking GeneralEraInfo (r:1 w:1) - // Proof: DappsStaking GeneralEraInfo (max_values: None, max_size: Some(76), added: 2551, mode: MaxEncodedLen) - // Storage: Balances Locks (r:1 w:1) - // Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) - fn bond_and_stake() -> Weight { - // Minimum execution time: 43_099 nanoseconds. - Weight::from_parts(43_939_000, 0) - .saturating_add(Weight::from_parts(0, 16957)) - .saturating_add(T::DbWeight::get().reads(6_u64)) - .saturating_add(T::DbWeight::get().writes(5_u64)) - } - // Storage: DappsStaking RegisteredDapps (r:1 w:0) - // Proof: DappsStaking RegisteredDapps (max_values: None, max_size: Some(86), added: 2561, mode: MaxEncodedLen) - // Storage: DappsStaking GeneralStakerInfo (r:1 w:1) - // Proof: DappsStaking GeneralStakerInfo (max_values: None, max_size: Some(298), added: 2773, mode: MaxEncodedLen) - // Storage: DappsStaking ContractEraStake (r:1 w:1) - // Proof: DappsStaking ContractEraStake (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) - // Storage: DappsStaking Ledger (r:1 w:1) - // Proof: DappsStaking Ledger (max_values: None, max_size: Some(266), added: 2741, mode: MaxEncodedLen) - // Storage: Balances Locks (r:1 w:1) - // Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) - // Storage: DappsStaking GeneralEraInfo (r:1 w:1) - // Proof: DappsStaking GeneralEraInfo (max_values: None, max_size: Some(76), added: 2551, mode: MaxEncodedLen) - fn unbond_and_unstake() -> Weight { - // Minimum execution time: 46_783 nanoseconds. - Weight::from_parts(47_487_000, 0) - .saturating_add(Weight::from_parts(0, 16957)) - .saturating_add(T::DbWeight::get().reads(6_u64)) - .saturating_add(T::DbWeight::get().writes(5_u64)) - } - // Storage: DappsStaking Ledger (r:1 w:1) - // Proof: DappsStaking Ledger (max_values: None, max_size: Some(266), added: 2741, mode: MaxEncodedLen) - // Storage: Balances Locks (r:1 w:1) - // Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) - // Storage: DappsStaking GeneralEraInfo (r:1 w:1) - // Proof: DappsStaking GeneralEraInfo (max_values: None, max_size: Some(76), added: 2551, mode: MaxEncodedLen) - fn withdraw_unbonded() -> Weight { - // Minimum execution time: 30_952 nanoseconds. - Weight::from_parts(31_615_000, 0) - .saturating_add(Weight::from_parts(0, 9066)) - .saturating_add(T::DbWeight::get().reads(3_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) - } - // Storage: DappsStaking RegisteredDapps (r:2 w:0) - // Proof: DappsStaking RegisteredDapps (max_values: None, max_size: Some(86), added: 2561, mode: MaxEncodedLen) - // Storage: DappsStaking GeneralStakerInfo (r:2 w:2) - // Proof: DappsStaking GeneralStakerInfo (max_values: None, max_size: Some(298), added: 2773, mode: MaxEncodedLen) - // Storage: DappsStaking ContractEraStake (r:2 w:2) - // Proof: DappsStaking ContractEraStake (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) - fn nomination_transfer() -> Weight { - // Minimum execution time: 38_247 nanoseconds. - Weight::from_parts(38_832_000, 0) - .saturating_add(Weight::from_parts(0, 15782)) - .saturating_add(T::DbWeight::get().reads(6_u64)) - .saturating_add(T::DbWeight::get().writes(4_u64)) - } - // Storage: DappsStaking GeneralStakerInfo (r:1 w:1) - // Proof: DappsStaking GeneralStakerInfo (max_values: None, max_size: Some(298), added: 2773, mode: MaxEncodedLen) - // Storage: DappsStaking RegisteredDapps (r:1 w:0) - // Proof: DappsStaking RegisteredDapps (max_values: None, max_size: Some(86), added: 2561, mode: MaxEncodedLen) - // Storage: DappsStaking ContractEraStake (r:2 w:1) - // Proof: DappsStaking ContractEraStake (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) - // Storage: DappsStaking GeneralEraInfo (r:2 w:1) - // Proof: DappsStaking GeneralEraInfo (max_values: None, max_size: Some(76), added: 2551, mode: MaxEncodedLen) - // Storage: DappsStaking Ledger (r:1 w:1) - // Proof: DappsStaking Ledger (max_values: None, max_size: Some(266), added: 2741, mode: MaxEncodedLen) - // Storage: Balances Locks (r:1 w:1) - // Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) - // Storage: System Account (r:1 w:1) - // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - fn claim_staker_with_restake() -> Weight { - // Minimum execution time: 60_558 nanoseconds. - Weight::from_parts(61_264_000, 0) - .saturating_add(Weight::from_parts(0, 24668)) - .saturating_add(T::DbWeight::get().reads(9_u64)) - .saturating_add(T::DbWeight::get().writes(6_u64)) - } - // Storage: DappsStaking GeneralStakerInfo (r:1 w:1) - // Proof: DappsStaking GeneralStakerInfo (max_values: None, max_size: Some(298), added: 2773, mode: MaxEncodedLen) - // Storage: DappsStaking RegisteredDapps (r:1 w:0) - // Proof: DappsStaking RegisteredDapps (max_values: None, max_size: Some(86), added: 2561, mode: MaxEncodedLen) - // Storage: DappsStaking ContractEraStake (r:1 w:0) - // Proof: DappsStaking ContractEraStake (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) - // Storage: DappsStaking GeneralEraInfo (r:1 w:0) - // Proof: DappsStaking GeneralEraInfo (max_values: None, max_size: Some(76), added: 2551, mode: MaxEncodedLen) - // Storage: DappsStaking Ledger (r:1 w:0) - // Proof: DappsStaking Ledger (max_values: None, max_size: Some(266), added: 2741, mode: MaxEncodedLen) - fn claim_staker_without_restake() -> Weight { - // Minimum execution time: 33_178 nanoseconds. - Weight::from_parts(33_576_000, 0) - .saturating_add(Weight::from_parts(0, 13183)) - .saturating_add(T::DbWeight::get().reads(5_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - // Storage: DappsStaking RegisteredDapps (r:1 w:0) - // Proof: DappsStaking RegisteredDapps (max_values: None, max_size: Some(86), added: 2561, mode: MaxEncodedLen) - // Storage: DappsStaking ContractEraStake (r:1 w:1) - // Proof: DappsStaking ContractEraStake (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) - // Storage: DappsStaking GeneralEraInfo (r:1 w:0) - // Proof: DappsStaking GeneralEraInfo (max_values: None, max_size: Some(76), added: 2551, mode: MaxEncodedLen) - fn claim_dapp() -> Weight { - // Minimum execution time: 25_126 nanoseconds. - Weight::from_parts(25_489_000, 0) - .saturating_add(Weight::from_parts(0, 7669)) - .saturating_add(T::DbWeight::get().reads(3_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - fn force_new_era() -> Weight { - // Minimum execution time: 3_446 nanoseconds. - Weight::from_parts(3_676_000, 0) - .saturating_add(Weight::from_parts(0, 0)) - } - fn maintenance_mode() -> Weight { - // Minimum execution time: 7_871 nanoseconds. - Weight::from_parts(8_137_000, 0) - .saturating_add(Weight::from_parts(0, 0)) - } - // Storage: DappsStaking Ledger (r:1 w:1) - // Proof: DappsStaking Ledger (max_values: None, max_size: Some(266), added: 2741, mode: MaxEncodedLen) - fn set_reward_destination() -> Weight { - // Minimum execution time: 15_697 nanoseconds. - Weight::from_parts(16_009_000, 0) - .saturating_add(Weight::from_parts(0, 2741)) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } -} - -// For backwards compatibility and tests -impl WeightInfo for () { - // Storage: DappsStaking RegisteredDevelopers (r:1 w:1) - // Proof: DappsStaking RegisteredDevelopers (max_values: None, max_size: Some(81), added: 2556, mode: MaxEncodedLen) - // Storage: DappsStaking RegisteredDapps (r:1 w:1) - // Proof: DappsStaking RegisteredDapps (max_values: None, max_size: Some(86), added: 2561, mode: MaxEncodedLen) - fn register() -> Weight { - // Minimum execution time: 25_265 nanoseconds. - Weight::from_parts(26_091_000, 0) - .saturating_add(Weight::from_parts(0, 5117)) - .saturating_add(RocksDbWeight::get().reads(2_u64)) - .saturating_add(RocksDbWeight::get().writes(2_u64)) - } - // Storage: DappsStaking RegisteredDapps (r:1 w:1) - // Proof: DappsStaking RegisteredDapps (max_values: None, max_size: Some(86), added: 2561, mode: MaxEncodedLen) - // Storage: System Account (r:1 w:1) - // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - fn unregister() -> Weight { - // Minimum execution time: 27_241 nanoseconds. - Weight::from_parts(27_411_000, 0) - .saturating_add(Weight::from_parts(0, 5164)) - .saturating_add(RocksDbWeight::get().reads(2_u64)) - .saturating_add(RocksDbWeight::get().writes(2_u64)) - } - // Storage: DappsStaking RegisteredDapps (r:1 w:0) - // Proof: DappsStaking RegisteredDapps (max_values: None, max_size: Some(86), added: 2561, mode: MaxEncodedLen) - // Storage: DappsStaking GeneralStakerInfo (r:1 w:1) - // Proof: DappsStaking GeneralStakerInfo (max_values: None, max_size: Some(298), added: 2773, mode: MaxEncodedLen) - // Storage: DappsStaking Ledger (r:1 w:1) - // Proof: DappsStaking Ledger (max_values: None, max_size: Some(266), added: 2741, mode: MaxEncodedLen) - // Storage: Balances Locks (r:1 w:1) - // Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) - // Storage: System Account (r:1 w:1) - // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - // Storage: DappsStaking GeneralEraInfo (r:1 w:1) - // Proof: DappsStaking GeneralEraInfo (max_values: None, max_size: Some(76), added: 2551, mode: MaxEncodedLen) - fn withdraw_from_unregistered() -> Weight { - // Minimum execution time: 44_491 nanoseconds. - Weight::from_parts(45_042_000, 0) - .saturating_add(Weight::from_parts(0, 17003)) - .saturating_add(RocksDbWeight::get().reads(6_u64)) - .saturating_add(RocksDbWeight::get().writes(5_u64)) - } - // Storage: DappsStaking RegisteredDapps (r:1 w:0) - // Proof: DappsStaking RegisteredDapps (max_values: None, max_size: Some(86), added: 2561, mode: MaxEncodedLen) - // Storage: DappsStaking Ledger (r:1 w:1) - // Proof: DappsStaking Ledger (max_values: None, max_size: Some(266), added: 2741, mode: MaxEncodedLen) - // Storage: DappsStaking ContractEraStake (r:1 w:1) - // Proof: DappsStaking ContractEraStake (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) - // Storage: DappsStaking GeneralStakerInfo (r:1 w:1) - // Proof: DappsStaking GeneralStakerInfo (max_values: None, max_size: Some(298), added: 2773, mode: MaxEncodedLen) - // Storage: DappsStaking GeneralEraInfo (r:1 w:1) - // Proof: DappsStaking GeneralEraInfo (max_values: None, max_size: Some(76), added: 2551, mode: MaxEncodedLen) - // Storage: Balances Locks (r:1 w:1) - // Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) - fn bond_and_stake() -> Weight { - // Minimum execution time: 43_099 nanoseconds. - Weight::from_parts(43_939_000, 0) - .saturating_add(Weight::from_parts(0, 16957)) - .saturating_add(RocksDbWeight::get().reads(6_u64)) - .saturating_add(RocksDbWeight::get().writes(5_u64)) - } - // Storage: DappsStaking RegisteredDapps (r:1 w:0) - // Proof: DappsStaking RegisteredDapps (max_values: None, max_size: Some(86), added: 2561, mode: MaxEncodedLen) - // Storage: DappsStaking GeneralStakerInfo (r:1 w:1) - // Proof: DappsStaking GeneralStakerInfo (max_values: None, max_size: Some(298), added: 2773, mode: MaxEncodedLen) - // Storage: DappsStaking ContractEraStake (r:1 w:1) - // Proof: DappsStaking ContractEraStake (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) - // Storage: DappsStaking Ledger (r:1 w:1) - // Proof: DappsStaking Ledger (max_values: None, max_size: Some(266), added: 2741, mode: MaxEncodedLen) - // Storage: Balances Locks (r:1 w:1) - // Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) - // Storage: DappsStaking GeneralEraInfo (r:1 w:1) - // Proof: DappsStaking GeneralEraInfo (max_values: None, max_size: Some(76), added: 2551, mode: MaxEncodedLen) - fn unbond_and_unstake() -> Weight { - // Minimum execution time: 46_783 nanoseconds. - Weight::from_parts(47_487_000, 0) - .saturating_add(Weight::from_parts(0, 16957)) - .saturating_add(RocksDbWeight::get().reads(6_u64)) - .saturating_add(RocksDbWeight::get().writes(5_u64)) - } - // Storage: DappsStaking Ledger (r:1 w:1) - // Proof: DappsStaking Ledger (max_values: None, max_size: Some(266), added: 2741, mode: MaxEncodedLen) - // Storage: Balances Locks (r:1 w:1) - // Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) - // Storage: DappsStaking GeneralEraInfo (r:1 w:1) - // Proof: DappsStaking GeneralEraInfo (max_values: None, max_size: Some(76), added: 2551, mode: MaxEncodedLen) - fn withdraw_unbonded() -> Weight { - // Minimum execution time: 30_952 nanoseconds. - Weight::from_parts(31_615_000, 0) - .saturating_add(Weight::from_parts(0, 9066)) - .saturating_add(RocksDbWeight::get().reads(3_u64)) - .saturating_add(RocksDbWeight::get().writes(3_u64)) - } - // Storage: DappsStaking RegisteredDapps (r:2 w:0) - // Proof: DappsStaking RegisteredDapps (max_values: None, max_size: Some(86), added: 2561, mode: MaxEncodedLen) - // Storage: DappsStaking GeneralStakerInfo (r:2 w:2) - // Proof: DappsStaking GeneralStakerInfo (max_values: None, max_size: Some(298), added: 2773, mode: MaxEncodedLen) - // Storage: DappsStaking ContractEraStake (r:2 w:2) - // Proof: DappsStaking ContractEraStake (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) - fn nomination_transfer() -> Weight { - // Minimum execution time: 38_247 nanoseconds. - Weight::from_parts(38_832_000, 0) - .saturating_add(Weight::from_parts(0, 15782)) - .saturating_add(RocksDbWeight::get().reads(6_u64)) - .saturating_add(RocksDbWeight::get().writes(4_u64)) - } - // Storage: DappsStaking GeneralStakerInfo (r:1 w:1) - // Proof: DappsStaking GeneralStakerInfo (max_values: None, max_size: Some(298), added: 2773, mode: MaxEncodedLen) - // Storage: DappsStaking RegisteredDapps (r:1 w:0) - // Proof: DappsStaking RegisteredDapps (max_values: None, max_size: Some(86), added: 2561, mode: MaxEncodedLen) - // Storage: DappsStaking ContractEraStake (r:2 w:1) - // Proof: DappsStaking ContractEraStake (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) - // Storage: DappsStaking GeneralEraInfo (r:2 w:1) - // Proof: DappsStaking GeneralEraInfo (max_values: None, max_size: Some(76), added: 2551, mode: MaxEncodedLen) - // Storage: DappsStaking Ledger (r:1 w:1) - // Proof: DappsStaking Ledger (max_values: None, max_size: Some(266), added: 2741, mode: MaxEncodedLen) - // Storage: Balances Locks (r:1 w:1) - // Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) - // Storage: System Account (r:1 w:1) - // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - fn claim_staker_with_restake() -> Weight { - // Minimum execution time: 60_558 nanoseconds. - Weight::from_parts(61_264_000, 0) - .saturating_add(Weight::from_parts(0, 24668)) - .saturating_add(RocksDbWeight::get().reads(9_u64)) - .saturating_add(RocksDbWeight::get().writes(6_u64)) - } - // Storage: DappsStaking GeneralStakerInfo (r:1 w:1) - // Proof: DappsStaking GeneralStakerInfo (max_values: None, max_size: Some(298), added: 2773, mode: MaxEncodedLen) - // Storage: DappsStaking RegisteredDapps (r:1 w:0) - // Proof: DappsStaking RegisteredDapps (max_values: None, max_size: Some(86), added: 2561, mode: MaxEncodedLen) - // Storage: DappsStaking ContractEraStake (r:1 w:0) - // Proof: DappsStaking ContractEraStake (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) - // Storage: DappsStaking GeneralEraInfo (r:1 w:0) - // Proof: DappsStaking GeneralEraInfo (max_values: None, max_size: Some(76), added: 2551, mode: MaxEncodedLen) - // Storage: DappsStaking Ledger (r:1 w:0) - // Proof: DappsStaking Ledger (max_values: None, max_size: Some(266), added: 2741, mode: MaxEncodedLen) - fn claim_staker_without_restake() -> Weight { - // Minimum execution time: 33_178 nanoseconds. - Weight::from_parts(33_576_000, 0) - .saturating_add(Weight::from_parts(0, 13183)) - .saturating_add(RocksDbWeight::get().reads(5_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } - // Storage: DappsStaking RegisteredDapps (r:1 w:0) - // Proof: DappsStaking RegisteredDapps (max_values: None, max_size: Some(86), added: 2561, mode: MaxEncodedLen) - // Storage: DappsStaking ContractEraStake (r:1 w:1) - // Proof: DappsStaking ContractEraStake (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) - // Storage: DappsStaking GeneralEraInfo (r:1 w:0) - // Proof: DappsStaking GeneralEraInfo (max_values: None, max_size: Some(76), added: 2551, mode: MaxEncodedLen) - fn claim_dapp() -> Weight { - // Minimum execution time: 25_126 nanoseconds. - Weight::from_parts(25_489_000, 0) - .saturating_add(Weight::from_parts(0, 7669)) - .saturating_add(RocksDbWeight::get().reads(3_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } - fn force_new_era() -> Weight { - // Minimum execution time: 3_446 nanoseconds. - Weight::from_parts(3_676_000, 0) - .saturating_add(Weight::from_parts(0, 0)) - } - fn maintenance_mode() -> Weight { - // Minimum execution time: 7_871 nanoseconds. - Weight::from_parts(8_137_000, 0) - .saturating_add(Weight::from_parts(0, 0)) - } - // Storage: DappsStaking Ledger (r:1 w:1) - // Proof: DappsStaking Ledger (max_values: None, max_size: Some(266), added: 2741, mode: MaxEncodedLen) - fn set_reward_destination() -> Weight { - // Minimum execution time: 15_697 nanoseconds. - Weight::from_parts(16_009_000, 0) - .saturating_add(Weight::from_parts(0, 2741)) - .saturating_add(RocksDbWeight::get().reads(1_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } -} \ No newline at end of file diff --git a/precompiles/dapps-staking/Cargo.toml b/precompiles/dapps-staking/Cargo.toml deleted file mode 100644 index aa5584170c..0000000000 --- a/precompiles/dapps-staking/Cargo.toml +++ /dev/null @@ -1,56 +0,0 @@ -[package] -name = "pallet-evm-precompile-dapps-staking" -version = "3.6.3" -license = "Apache-2.0" -description = "dApps Staking EVM precompiles" -authors.workspace = true -edition.workspace = true -homepage.workspace = true -repository.workspace = true - -[dependencies] -log = { workspace = true } -num_enum = { workspace = true } -parity-scale-codec = { workspace = true } -scale-info = { workspace = true } - -frame-support = { workspace = true } -frame-system = { workspace = true } - -sp-core = { workspace = true } -sp-runtime = { workspace = true } -sp-std = { workspace = true } - -# Astar -pallet-dapps-staking = { workspace = true } -precompile-utils = { workspace = true, default-features = false } - -# Frontier -fp-evm = { workspace = true } -pallet-evm = { workspace = true } - -[dev-dependencies] -derive_more = { workspace = true } -pallet-balances = { workspace = true, features = ["std"] } -pallet-timestamp = { workspace = true } -precompile-utils = { workspace = true, features = ["testing"] } -serde = { workspace = true } -sha3 = { workspace = true } -sp-io = { workspace = true } - -[features] -default = ["std"] -std = [ - "parity-scale-codec/std", - "scale-info/std", - "sp-std/std", - "sp-core/std", - "sp-runtime/std", - "fp-evm/std", - "frame-support/std", - "frame-system/std", - "pallet-dapps-staking/std", - "pallet-evm/std", - "precompile-utils/std", - "pallet-balances/std", -] diff --git a/precompiles/dapps-staking/DappsStaking.sol b/precompiles/dapps-staking/DappsStaking.sol deleted file mode 100644 index 83b5af5f6d..0000000000 --- a/precompiles/dapps-staking/DappsStaking.sol +++ /dev/null @@ -1,90 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause - -pragma solidity >=0.7.0; - -/// Interface to the precompiled contract on Shibuya/Shiden/Astar -/// Predeployed at the address 0x0000000000000000000000000000000000005001 -/// For better understanding check the source code: -/// repo: https://github.com/AstarNetwork/astar -/// code: frame/dapps-staking/src/pallet -interface DappsStaking { - - // Storage getters - - /// @notice Read current era. - /// @return era: The current era - function read_current_era() external view returns (uint256); - - /// @notice Read unbonding period constant. - /// @return period: The unbonding period in eras - function read_unbonding_period() external view returns (uint256); - - /// @notice Read Total network reward for the given era - /// @return reward: Total network reward for the given era - function read_era_reward(uint32 era) external view returns (uint128); - - /// @notice Read Total staked amount for the given era - /// @return staked: Total staked amount for the given era - function read_era_staked(uint32 era) external view returns (uint128); - - /// @notice Read Staked amount for the staker - /// @param staker: The staker address in form of 20 or 32 hex bytes - /// @return amount: Staked amount by the staker - function read_staked_amount(bytes calldata staker) external view returns (uint128); - - /// @notice Read Staked amount on a given contract for the staker - /// @param contract_id: The smart contract address used for staking - /// @param staker: The staker address in form of 20 or 32 hex bytes - /// @return amount: Staked amount by the staker - function read_staked_amount_on_contract(address contract_id, bytes calldata staker) external view returns (uint128); - - /// @notice Read the staked amount from the era when the amount was last staked/unstaked - /// @return total: The most recent total staked amount on contract - function read_contract_stake(address contract_id) external view returns (uint128); - - - // Extrinsic calls - - /// @notice Register is root origin only and not allowed via evm precompile. - /// This should always fail. - function register(address) external returns (bool); - - /// @notice Stake provided amount on the contract. - function bond_and_stake(address, uint128) external returns (bool); - - /// @notice Start unbonding process and unstake balance from the contract. - function unbond_and_unstake(address, uint128) external returns (bool); - - /// @notice Withdraw all funds that have completed the unbonding process. - function withdraw_unbonded() external returns (bool); - - /// @notice Claim earned staker rewards for the oldest unclaimed era. - /// In order to claim multiple eras, this call has to be called multiple times. - /// Staker account is derived from the caller address. - /// @param smart_contract: The smart contract address used for staking - function claim_staker(address smart_contract) external returns (bool); - - /// @notice Claim one era of unclaimed dapp rewards for the specified contract and era. - /// @param smart_contract: The smart contract address used for staking - /// @param era: The era to be claimed - function claim_dapp(address smart_contract, uint128 era) external returns (bool); - - /// Instruction how to handle reward payout for staker. - /// `FreeBalance` - Reward will be paid out to the staker (free balance). - /// `StakeBalance` - Reward will be paid out to the staker and is immediately restaked (locked balance) - enum RewardDestination {FreeBalance, StakeBalance} - - /// @notice Set reward destination for staker rewards - /// @param reward_destination: The instruction on how the reward payout should be handled - function set_reward_destination(RewardDestination reward_destination) external returns (bool); - - /// @notice Withdraw staked funds from an unregistered contract. - /// @param smart_contract: The smart contract address used for staking - function withdraw_from_unregistered(address smart_contract) external returns (bool); - - /// @notice Transfer part or entire nomination from origin smart contract to target smart contract - /// @param origin_smart_contract: The origin smart contract address - /// @param amount: The amount to transfer from origin to target - /// @param target_smart_contract: The target smart contract address - function nomination_transfer(address origin_smart_contract, uint128 amount, address target_smart_contract) external returns (bool); -} diff --git a/precompiles/dapps-staking/src/lib.rs b/precompiles/dapps-staking/src/lib.rs deleted file mode 100644 index 0f4e5b7226..0000000000 --- a/precompiles/dapps-staking/src/lib.rs +++ /dev/null @@ -1,439 +0,0 @@ -// This file is part of Astar. - -// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later - -// Astar 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. - -// Astar 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 Astar. If not, see . - -//! Astar dApps staking interface. - -#![cfg_attr(not(feature = "std"), no_std)] - -use fp_evm::PrecompileHandle; -use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; - -use frame_support::{ - dispatch::{GetDispatchInfo, PostDispatchInfo}, - traits::{Currency, Get}, -}; -use pallet_dapps_staking::RewardDestination; -use pallet_evm::AddressMapping; -use precompile_utils::prelude::*; -use sp_core::{ConstU32, H160, U256}; -use sp_runtime::traits::{Dispatchable, Zero}; -use sp_std::marker::PhantomData; -use sp_std::prelude::*; -extern crate alloc; - -type BalanceOf = <::Currency as Currency< - ::AccountId, ->>::Balance; - -pub const STAKER_BYTES_LIMIT: u32 = 32; -type GetStakerBytesLimit = ConstU32; - -#[cfg(test)] -mod mock; -#[cfg(test)] -mod tests; - -/// This is only used to encode SmartContract enum -#[derive(PartialEq, Eq, Copy, Clone, Encode, Decode, Debug)] -pub enum Contract { - /// EVM smart contract instance. - Evm(H160), - /// Wasm smart contract instance. Not used in this precompile - Wasm(A), -} - -pub struct DappsStakingWrapper(PhantomData); - -#[precompile_utils::precompile] -impl DappsStakingWrapper -where - R: pallet_evm::Config + pallet_dapps_staking::Config, - BalanceOf: solidity::Codec, - ::RuntimeOrigin: From>, - R::RuntimeCall: Dispatchable + GetDispatchInfo, - R::RuntimeCall: From>, - R::AccountId: From<[u8; 32]>, -{ - /// Fetch current era from CurrentEra storage map - #[precompile::public("read_current_era()")] - #[precompile::view] - fn read_current_era(handle: &mut impl PrecompileHandle) -> EvmResult { - // TODO: benchmark this function so we can measure ref time & PoV correctly - // Storage item: CurrentEra: - // Twox64(8) + EraIndex(4) - handle.record_db_read::(12)?; - - let current_era = pallet_dapps_staking::CurrentEra::::get(); - Ok(current_era.into()) - } - - /// Fetch unbonding period - #[precompile::public("read_unbonding_period()")] - #[precompile::view] - fn read_unbonding_period(_: &mut impl PrecompileHandle) -> EvmResult { - // constant, no DB read - let unbonding_period = R::UnbondingPeriod::get(); - - Ok(unbonding_period.into()) - } - - /// Fetch reward from EraRewardsAndStakes storage map - #[precompile::public("read_era_reward(uint32)")] - #[precompile::view] - fn read_era_reward(handle: &mut impl PrecompileHandle, era: u32) -> EvmResult { - // TODO: benchmark this function so we can measure ref time & PoV correctly - // Storage item: GeneralEraInfo: - // Twox64Concat(8) + EraIndex(4) + EraInfo::max_encoded_len - handle.record_db_read::(12 + pallet_dapps_staking::EraInfo::max_encoded_len())?; - - // call pallet-dapps-staking - let read_reward = pallet_dapps_staking::GeneralEraInfo::::get(era); - let reward = read_reward.map_or(Zero::zero(), |r| { - r.rewards.stakers.saturating_add(r.rewards.dapps) - }); - - Ok(reward.into()) - } - - /// Fetch total staked amount from EraRewardsAndStakes storage map - #[precompile::public("read_era_staked(uint32)")] - #[precompile::view] - fn read_era_staked(handle: &mut impl PrecompileHandle, era: u32) -> EvmResult { - // TODO: benchmark this function so we can measure ref time & PoV correctly - // Storage item: GeneralEraInfo: - // Twox64Concat(8) + EraIndex(4) + EraInfo::max_encoded_len - handle.record_db_read::(12 + pallet_dapps_staking::EraInfo::max_encoded_len())?; - - // call pallet-dapps-staking - let reward_and_stake = pallet_dapps_staking::GeneralEraInfo::::get(era); - // compose output - let staked = reward_and_stake.map_or(Zero::zero(), |r| r.staked); - let staked = TryInto::::try_into(staked).unwrap_or(0); - - Ok(staked.into()) - } - - /// Fetch Ledger storage map for an account - #[precompile::public("read_staked_amount(bytes)")] - #[precompile::view] - fn read_staked_amount( - handle: &mut impl PrecompileHandle, - staker: BoundedBytes, - ) -> EvmResult { - // TODO: benchmark this function so we can measure ref time & PoV correctly - // Storage item: Ledger: - // Blake2_128Concat(16 + 32) + Ledger::max_encoded_len - handle.record_db_read::(48 + pallet_dapps_staking::AccountLedger::max_encoded_len())?; - - // parse input parameters for pallet-dapps-staking call - let staker = Self::parse_input_address(staker.into())?; - - // call pallet-dapps-staking - let ledger = pallet_dapps_staking::Ledger::::get(&staker); - log::trace!(target: "ds-precompile", "read_staked_amount for account:{:?}, ledger.locked:{:?}", staker, ledger.locked); - - Ok(ledger.locked.into()) - } - - /// Read GeneralStakerInfo for account/contract - #[precompile::public("read_staked_amount_on_contract(address,bytes)")] - #[precompile::view] - fn read_staked_amount_on_contract( - handle: &mut impl PrecompileHandle, - contract_h160: Address, - staker: BoundedBytes, - ) -> EvmResult { - // TODO: benchmark this function so we can measure ref time & PoV correctly - // Storage item: GeneralStakerInfo: - // Blake2_128Concat(16 + 32) + Blake2_128Concat(16 + SmartContract::max_encoded_len) + StakerInfo::max_encoded_len - handle.record_db_read::( - 64 + ::SmartContract::max_encoded_len() - + pallet_dapps_staking::StakerInfo::max_encoded_len(), - )?; - - // parse contract address - let contract_id = Self::decode_smart_contract(contract_h160.into())?; - - // parse input parameters for pallet-dapps-staking call - let staker = Self::parse_input_address(staker.into())?; - - // call pallet-dapps-staking - let staking_info = pallet_dapps_staking::GeneralStakerInfo::::get(&staker, &contract_id); - let staked_amount = staking_info.latest_staked_value(); - log::trace!(target: "ds-precompile", "read_staked_amount_on_contract for account:{:?}, contract: {:?} => staked_amount:{:?}", staker, contract_id, staked_amount); - - Ok(staked_amount.into()) - } - - /// Read the amount staked on contract in the given era - #[precompile::public("read_contract_stake(address)")] - #[precompile::view] - fn read_contract_stake( - handle: &mut impl PrecompileHandle, - contract_h160: Address, - ) -> EvmResult { - // TODO: benchmark this function so we can measure ref time & PoV correctly - // Storage item: CurrentEra: - // Twox64(8) + EraIndex(4) - handle.record_db_read::(16)?; - // TODO: benchmark this function so we can measure ref time & PoV correctly - // Storage item: ContractEraStake: - // Blake2_128Concat(16 + SmartContract::max_encoded_len) + Twox64Concat(8 + 4) + ContractStakeInfo::max_encoded_len - handle.record_db_read::( - 28 + ::SmartContract::max_encoded_len() - + pallet_dapps_staking::ContractStakeInfo::max_encoded_len(), - )?; - - let contract_id = Self::decode_smart_contract(contract_h160.into())?; - let current_era = pallet_dapps_staking::CurrentEra::::get(); - - // call pallet-dapps-staking - let staking_info = - pallet_dapps_staking::Pallet::::contract_stake_info(&contract_id, current_era) - .unwrap_or_default(); - - // encode output with total - let total = TryInto::::try_into(staking_info.total).unwrap_or(0); - log::trace!(target: "ds-precompile", "read_contract_stake for contract: {:?} => staked_amount:{:?}", contract_id, total); - Ok(total.into()) - } - - /// Register contract with the dapp-staking pallet - /// Register is root origin only. This should always fail when called via evm precompile. - #[precompile::public("register(address)")] - fn register(_: &mut impl PrecompileHandle, _address: Address) -> EvmResult { - // register is root-origin call. it should always fail when called via evm precompiles. - Err(RevertReason::custom("register via evm precompile is not allowed").into()) - } - - /// Lock up and stake balance of the origin account. - #[precompile::public("bond_and_stake(address,uint128)")] - fn bond_and_stake( - handle: &mut impl PrecompileHandle, - contract_h160: Address, - value: u128, - ) -> EvmResult { - // parse contract's address - let contract_id = Self::decode_smart_contract(contract_h160.into())?; - - log::trace!(target: "ds-precompile", "bond_and_stake {:?}, {:?}", contract_id, value); - - // Build call with origin. - let origin = R::AddressMapping::into_account_id(handle.context().caller); - let call = pallet_dapps_staking::Call::::bond_and_stake { contract_id, value }; - - RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call)?; - - Ok(true) - } - - /// Start unbonding process and unstake balance from the contract. - #[precompile::public("unbond_and_unstake(address,uint128)")] - fn unbond_and_unstake( - handle: &mut impl PrecompileHandle, - contract_h160: Address, - value: u128, - ) -> EvmResult { - // parse contract's address - let contract_id = Self::decode_smart_contract(contract_h160.into())?; - - log::trace!(target: "ds-precompile", "unbond_and_unstake {:?}, {:?}", contract_id, value); - - // Build call with origin. - let origin = R::AddressMapping::into_account_id(handle.context().caller); - let call = pallet_dapps_staking::Call::::unbond_and_unstake { contract_id, value }; - - RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call)?; - - Ok(true) - } - - /// Start unbonding process and unstake balance from the contract. - #[precompile::public("withdraw_unbonded()")] - fn withdraw_unbonded(handle: &mut impl PrecompileHandle) -> EvmResult { - // Build call with origin. - let origin = R::AddressMapping::into_account_id(handle.context().caller); - let call = pallet_dapps_staking::Call::::withdraw_unbonded {}; - - RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call)?; - - Ok(true) - } - - /// Claim rewards for the contract in the dapps-staking pallet - #[precompile::public("claim_dapp(address,uint128)")] - fn claim_dapp( - handle: &mut impl PrecompileHandle, - contract_h160: Address, - era: u128, - ) -> EvmResult { - // parse contract's address - let contract_id = Self::decode_smart_contract(contract_h160.into())?; - - // parse era - let era = era - .try_into() - .map_err::(|_| RevertReason::value_is_too_large("era type").into()) - .in_field("era")?; - - log::trace!(target: "ds-precompile", "claim_dapp {:?}, era {:?}", contract_id, era); - - // Build call with origin. - let origin = R::AddressMapping::into_account_id(handle.context().caller); - let call = pallet_dapps_staking::Call::::claim_dapp { contract_id, era }; - - RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call)?; - - Ok(true) - } - - /// Claim rewards for the contract in the dapps-staking pallet - #[precompile::public("claim_staker(address)")] - fn claim_staker(handle: &mut impl PrecompileHandle, contract_h160: Address) -> EvmResult { - // parse contract's address - let contract_id = Self::decode_smart_contract(contract_h160.into())?; - log::trace!(target: "ds-precompile", "claim_staker {:?}", contract_id); - - // Build call with origin. - let origin = R::AddressMapping::into_account_id(handle.context().caller); - let call = pallet_dapps_staking::Call::::claim_staker { contract_id }; - - RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call)?; - - Ok(true) - } - - /// Set claim reward destination for the caller - #[precompile::public("set_reward_destination(uint8)")] - fn set_reward_destination( - handle: &mut impl PrecompileHandle, - reward_destination_raw: u8, - ) -> EvmResult { - // Transform raw value into dapps staking enum - let reward_destination = if reward_destination_raw == 0 { - RewardDestination::FreeBalance - } else if reward_destination_raw == 1 { - RewardDestination::StakeBalance - } else { - return Err(RevertReason::custom("Unexpected reward destination value.").into()); - }; - - // Build call with origin. - let origin = R::AddressMapping::into_account_id(handle.context().caller); - log::trace!(target: "ds-precompile", "set_reward_destination {:?} {:?}", origin, reward_destination); - - let call = pallet_dapps_staking::Call::::set_reward_destination { reward_destination }; - - RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call)?; - - Ok(true) - } - - /// Withdraw staked funds from the unregistered contract - #[precompile::public("withdraw_from_unregistered(address)")] - fn withdraw_from_unregistered( - handle: &mut impl PrecompileHandle, - contract_h160: Address, - ) -> EvmResult { - // parse contract's address - let contract_id = Self::decode_smart_contract(contract_h160.into())?; - log::trace!(target: "ds-precompile", "withdraw_from_unregistered {:?}", contract_id); - - // Build call with origin. - let origin = R::AddressMapping::into_account_id(handle.context().caller); - let call = pallet_dapps_staking::Call::::withdraw_from_unregistered { contract_id }; - - RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call)?; - - Ok(true) - } - - /// Claim rewards for the contract in the dapps-staking pallet - #[precompile::public("nomination_transfer(address,uint128,address)")] - fn nomination_transfer( - handle: &mut impl PrecompileHandle, - origin_contract_h160: Address, - value: u128, - target_contract_h160: Address, - ) -> EvmResult { - // parse origin contract's address - let origin_contract_id = Self::decode_smart_contract(origin_contract_h160.into())?; - - // parse target contract's address - let target_contract_id = Self::decode_smart_contract(target_contract_h160.into())?; - - log::trace!(target: "ds-precompile", "nomination_transfer {:?} {:?} {:?}", origin_contract_id, value, target_contract_id); - - // Build call with origin. - let origin = R::AddressMapping::into_account_id(handle.context().caller); - let call = pallet_dapps_staking::Call::::nomination_transfer { - origin_contract_id, - value, - target_contract_id, - }; - - RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call)?; - - Ok(true) - } - - /// Helper method to decode type SmartContract enum - pub fn decode_smart_contract( - contract_h160: H160, - ) -> EvmResult<::SmartContract> { - // Encode contract address to fit SmartContract enum. - // Since the SmartContract enum type can't be accessed from this pecompile, - // use locally defined enum clone (see Contract enum) - let contract_enum_encoded = Contract::::Evm(contract_h160).encode(); - - // encoded enum will add one byte before the contract's address - // therefore we need to decode len(H160) + 1 byte = 21 - let smart_contract = ::SmartContract::decode( - &mut &contract_enum_encoded[..21], - ) - .map_err(|_| revert("Error while decoding SmartContract"))?; - - Ok(smart_contract) - } - - /// Helper method to parse H160 or SS58 address - fn parse_input_address(staker_vec: Vec) -> EvmResult { - let staker: R::AccountId = match staker_vec.len() { - // public address of the ss58 account has 32 bytes - 32 => { - let mut staker_bytes = [0_u8; 32]; - staker_bytes[..].clone_from_slice(&staker_vec[0..32]); - - staker_bytes.into() - } - // public address of the H160 account has 20 bytes - 20 => { - let mut staker_bytes = [0_u8; 20]; - staker_bytes[..].clone_from_slice(&staker_vec[0..20]); - - R::AddressMapping::into_account_id(staker_bytes.into()) - } - _ => { - // Return err if account length is wrong - return Err(revert("Error while parsing staker's address")); - } - }; - - Ok(staker) - } -} diff --git a/precompiles/dapps-staking/src/mock.rs b/precompiles/dapps-staking/src/mock.rs deleted file mode 100644 index 52f70ce542..0000000000 --- a/precompiles/dapps-staking/src/mock.rs +++ /dev/null @@ -1,407 +0,0 @@ -// This file is part of Astar. - -// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later - -// Astar 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. - -// Astar 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 Astar. If not, see . - -use super::*; - -use fp_evm::{IsPrecompileResult, Precompile}; -use frame_support::{ - construct_runtime, parameter_types, - traits::{ConstBool, ConstU128, ConstU64, Currency, OnFinalize, OnInitialize}, - weights::{RuntimeDbWeight, Weight}, - PalletId, -}; -use pallet_dapps_staking::weights; -use pallet_evm::{ - AddressMapping, EnsureAddressNever, EnsureAddressRoot, PrecompileResult, PrecompileSet, -}; -use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; -use serde::{Deserialize, Serialize}; -use sp_core::{H160, H256}; -use sp_io::TestExternalities; -use sp_runtime::{ - traits::{BlakeTwo256, ConstU32, IdentityLookup}, - AccountId32, BuildStorage, -}; -extern crate alloc; - -pub(crate) type BlockNumber = u64; -pub(crate) type Balance = u128; -pub(crate) type EraIndex = u32; -pub(crate) const MILLIAST: Balance = 1_000_000_000_000_000; -pub(crate) const AST: Balance = 1_000 * MILLIAST; - -pub(crate) const TEST_CONTRACT: H160 = H160::repeat_byte(0x09); - -type Block = frame_system::mocking::MockBlock; - -/// Value shouldn't be less than 2 for testing purposes, otherwise we cannot test certain corner cases. -pub(crate) const MAX_NUMBER_OF_STAKERS: u32 = 4; -/// Value shouldn't be less than 2 for testing purposes, otherwise we cannot test certain corner cases. -pub(crate) const MINIMUM_STAKING_AMOUNT: Balance = 10 * AST; -pub(crate) const MINIMUM_REMAINING_AMOUNT: Balance = 1; -pub(crate) const MAX_UNLOCKING_CHUNKS: u32 = 4; -pub(crate) const UNBONDING_PERIOD: EraIndex = 3; -pub(crate) const MAX_ERA_STAKE_VALUES: u32 = 10; - -// Do note that this needs to at least be 3 for tests to be valid. It can be greater but not smaller. -pub(crate) const BLOCKS_PER_ERA: BlockNumber = 3; - -pub(crate) const REGISTER_DEPOSIT: Balance = 10 * AST; - -pub(crate) const STAKER_BLOCK_REWARD: Balance = 531911; -pub(crate) const DAPP_BLOCK_REWARD: Balance = 773333; - -#[derive( - Eq, - PartialEq, - Ord, - PartialOrd, - Clone, - Encode, - Decode, - Debug, - MaxEncodedLen, - Serialize, - Deserialize, - derive_more::Display, - scale_info::TypeInfo, -)] - -pub enum TestAccount { - Empty, - Alex, - Bobo, - Dino, -} - -impl Default for TestAccount { - fn default() -> Self { - Self::Empty - } -} - -// needed for associated type in pallet_evm -impl AddressMapping for TestAccount { - fn into_account_id(h160_account: H160) -> AccountId32 { - match h160_account { - a if a == H160::repeat_byte(0x01) => TestAccount::Alex.into(), - a if a == H160::repeat_byte(0x02) => TestAccount::Bobo.into(), - a if a == H160::repeat_byte(0x03) => TestAccount::Dino.into(), - _ => TestAccount::Empty.into(), - } - } -} - -impl From for H160 { - fn from(x: TestAccount) -> H160 { - match x { - TestAccount::Alex => H160::repeat_byte(0x01), - TestAccount::Bobo => H160::repeat_byte(0x02), - TestAccount::Dino => H160::repeat_byte(0x03), - _ => Default::default(), - } - } -} - -impl From for TestAccount { - fn from(address: H160) -> TestAccount { - match address { - a if a == H160::repeat_byte(0x01) => TestAccount::Alex, - a if a == H160::repeat_byte(0x02) => TestAccount::Bobo, - a if a == H160::repeat_byte(0x03) => TestAccount::Dino, - _ => Default::default(), - } - } -} - -impl From for AccountId32 { - fn from(x: TestAccount) -> Self { - match x { - TestAccount::Alex => AccountId32::from([1u8; 32]), - TestAccount::Bobo => AccountId32::from([2u8; 32]), - TestAccount::Dino => AccountId32::from([3u8; 32]), - _ => AccountId32::from([0u8; 32]), - } - } -} - -pub const READ_WEIGHT: u64 = 3; -pub const WRITE_WEIGHT: u64 = 7; - -parameter_types! { - pub const BlockHashCount: u64 = 250; - pub BlockWeights: frame_system::limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max(Weight::from_parts(1024, 0)); - pub const TestWeights: RuntimeDbWeight = RuntimeDbWeight { - read: READ_WEIGHT, - write: WRITE_WEIGHT, - }; -} - -impl frame_system::Config for TestRuntime { - type BaseCallFilter = frame_support::traits::Everything; - type BlockWeights = (); - type BlockLength = (); - type RuntimeOrigin = RuntimeOrigin; - type Nonce = u64; - type RuntimeCall = RuntimeCall; - type Block = Block; - type Hash = H256; - type Hashing = BlakeTwo256; - type AccountId = AccountId32; - type Lookup = IdentityLookup; - type RuntimeEvent = RuntimeEvent; - type BlockHashCount = BlockHashCount; - type DbWeight = TestWeights; - type Version = (); - type PalletInfo = PalletInfo; - type AccountData = pallet_balances::AccountData; - type OnNewAccount = (); - type OnKilledAccount = (); - type SystemWeightInfo = (); - type SS58Prefix = (); - type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; -} - -parameter_types! { - pub const ExistentialDeposit: u128 = 1; -} -impl pallet_balances::Config for TestRuntime { - type MaxReserves = (); - type ReserveIdentifier = [u8; 4]; - type MaxLocks = (); - type Balance = Balance; - type RuntimeEvent = RuntimeEvent; - type DustRemoval = (); - type ExistentialDeposit = ExistentialDeposit; - type AccountStore = System; - type WeightInfo = (); - type RuntimeHoldReason = RuntimeHoldReason; - type FreezeIdentifier = (); - type RuntimeFreezeReason = (); - type MaxHolds = (); - type MaxFreezes = (); -} - -pub fn precompile_address() -> H160 { - H160::from_low_u64_be(0x5001) -} - -#[derive(Debug, Clone, Copy)] -pub struct DappPrecompile(PhantomData); - -impl PrecompileSet for DappPrecompile -where - R: pallet_evm::Config, - DappsStakingWrapper: Precompile, -{ - fn execute(&self, handle: &mut impl PrecompileHandle) -> Option { - match handle.code_address() { - a if a == precompile_address() => Some(DappsStakingWrapper::::execute(handle)), - _ => None, - } - } - - fn is_precompile(&self, address: sp_core::H160, _gas: u64) -> IsPrecompileResult { - IsPrecompileResult::Answer { - is_precompile: address == precompile_address(), - extra_cost: 0, - } - } -} - -pub type PrecompileCall = DappsStakingWrapperCall; - -parameter_types! { - pub PrecompilesValue: DappPrecompile = DappPrecompile(Default::default()); - pub WeightPerGas: Weight = Weight::from_parts(1, 0); -} - -impl pallet_evm::Config for TestRuntime { - type FeeCalculator = (); - type GasWeightMapping = pallet_evm::FixedGasWeightMapping; - type WeightPerGas = WeightPerGas; - type CallOrigin = EnsureAddressRoot; - type WithdrawOrigin = EnsureAddressNever; - type AddressMapping = TestAccount; - type Currency = Balances; - type RuntimeEvent = RuntimeEvent; - type Runner = pallet_evm::runner::stack::Runner; - type PrecompilesType = DappPrecompile; - type PrecompilesValue = PrecompilesValue; - type Timestamp = Timestamp; - type ChainId = (); - type OnChargeTransaction = (); - type BlockGasLimit = (); - type BlockHashMapping = pallet_evm::SubstrateBlockHashMapping; - type FindAuthor = (); - type OnCreate = (); - type WeightInfo = (); - type GasLimitPovSizeRatio = ConstU64<4>; - type SuicideQuickClearLimit = ConstU32<0>; -} - -parameter_types! { - pub const MinimumPeriod: u64 = 5; -} -impl pallet_timestamp::Config for TestRuntime { - type Moment = u64; - type OnTimestampSet = (); - type MinimumPeriod = MinimumPeriod; - type WeightInfo = (); -} - -#[derive( - PartialEq, Eq, Copy, Clone, Encode, Decode, Debug, scale_info::TypeInfo, MaxEncodedLen, -)] -pub enum MockSmartContract { - Evm(sp_core::H160), - Wasm(AccountId32), -} - -impl Default for MockSmartContract { - fn default() -> Self { - MockSmartContract::Evm(H160::repeat_byte(0x00)) - } -} - -parameter_types! { - pub const RegisterDeposit: Balance = REGISTER_DEPOSIT; - pub const BlockPerEra: BlockNumber = BLOCKS_PER_ERA; - pub const MaxNumberOfStakersPerContract: u32 = MAX_NUMBER_OF_STAKERS; - pub const MinimumStakingAmount: Balance = MINIMUM_STAKING_AMOUNT; - pub const DappsStakingPalletId: PalletId = PalletId(*b"mokdpstk"); - pub const MinimumRemainingAmount: Balance = MINIMUM_REMAINING_AMOUNT; - pub const MaxUnlockingChunks: u32 = MAX_UNLOCKING_CHUNKS; - pub const UnbondingPeriod: EraIndex = UNBONDING_PERIOD; - pub const MaxEraStakeValues: u32 = MAX_ERA_STAKE_VALUES; -} - -impl pallet_dapps_staking::Config for TestRuntime { - type RuntimeEvent = RuntimeEvent; - type Currency = Balances; - type BlockPerEra = BlockPerEra; - type RegisterDeposit = RegisterDeposit; - type SmartContract = MockSmartContract; - type WeightInfo = weights::SubstrateWeight; - type MaxNumberOfStakersPerContract = MaxNumberOfStakersPerContract; - type MinimumStakingAmount = MinimumStakingAmount; - type PalletId = DappsStakingPalletId; - type MinimumRemainingAmount = MinimumRemainingAmount; - type MaxUnlockingChunks = MaxUnlockingChunks; - type UnbondingPeriod = UnbondingPeriod; - type MaxEraStakeValues = MaxEraStakeValues; - type UnregisteredDappRewardRetention = ConstU32<2>; - type ForcePalletDisabled = ConstBool; - type DelegateClaimFee = ConstU128<1>; -} - -pub struct ExternalityBuilder { - balances: Vec<(AccountId32, Balance)>, -} - -impl Default for ExternalityBuilder { - fn default() -> ExternalityBuilder { - ExternalityBuilder { balances: vec![] } - } -} - -impl ExternalityBuilder { - pub fn build(self) -> TestExternalities { - let mut storage = frame_system::GenesisConfig::::default() - .build_storage() - .unwrap(); - - pallet_balances::GenesisConfig:: { - balances: self.balances, - } - .assimilate_storage(&mut storage) - .ok(); - - let mut ext = TestExternalities::from(storage); - ext.execute_with(|| System::set_block_number(1)); - ext - } - - pub(crate) fn with_balances(mut self, balances: Vec<(AccountId32, Balance)>) -> Self { - self.balances = balances; - self - } -} - -construct_runtime!( - pub struct TestRuntime { - System: frame_system, - Balances: pallet_balances, - Evm: pallet_evm, - Timestamp: pallet_timestamp, - DappsStaking: pallet_dapps_staking, - } -); - -/// Used to run to the specified block number -pub fn run_to_block(n: u64) { - while System::block_number() < n { - DappsStaking::on_finalize(System::block_number()); - System::set_block_number(System::block_number() + 1); - // This is performed outside of dapps staking but we expect it before on_initialize - payout_block_rewards(); - DappsStaking::on_initialize(System::block_number()); - } -} - -/// Used to run the specified number of blocks -pub fn run_for_blocks(n: u64) { - run_to_block(System::block_number() + n); -} - -/// Advance blocks to the beginning of an era. -/// -/// Function has no effect if era is already passed. -pub fn advance_to_era(n: EraIndex) { - while DappsStaking::current_era() < n { - run_for_blocks(1); - } -} - -/// Initialize first block. -/// This method should only be called once in a UT otherwise the first block will get initialized multiple times. -pub fn initialize_first_block() { - // This assert prevents method misuse - assert_eq!(System::block_number(), 1 as BlockNumber); - - // This is performed outside of dapps staking but we expect it before on_initialize - payout_block_rewards(); - DappsStaking::on_initialize(System::block_number()); - run_to_block(2); -} - -/// Returns total block rewards that goes to dapps-staking. -/// Contains both `dapps` reward and `stakers` reward. -pub fn joint_block_reward() -> Balance { - STAKER_BLOCK_REWARD + DAPP_BLOCK_REWARD -} - -/// Payout block rewards to stakers & dapps -fn payout_block_rewards() { - DappsStaking::rewards( - Balances::issue(STAKER_BLOCK_REWARD.into()), - Balances::issue(DAPP_BLOCK_REWARD.into()), - ); -} diff --git a/precompiles/dapps-staking/src/tests.rs b/precompiles/dapps-staking/src/tests.rs deleted file mode 100644 index 8844574de2..0000000000 --- a/precompiles/dapps-staking/src/tests.rs +++ /dev/null @@ -1,684 +0,0 @@ -// This file is part of Astar. - -// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later - -// Astar 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. - -// Astar 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 Astar. If not, see . - -extern crate alloc; -use crate::{ - mock::{ - advance_to_era, initialize_first_block, precompile_address, DappsStaking, EraIndex, - ExternalityBuilder, RuntimeOrigin, TestAccount, AST, UNBONDING_PERIOD, *, - }, - *, -}; -use frame_support::assert_ok; -use pallet_dapps_staking::RewardDestination; -use precompile_utils::testing::*; -use sp_core::H160; -use sp_runtime::{traits::Zero, AccountId32, Perbill}; - -fn precompiles() -> DappPrecompile { - PrecompilesValue::get() -} - -#[test] -fn current_era_is_ok() { - ExternalityBuilder::default().build().execute_with(|| { - initialize_first_block(); - - let current_era = DappsStaking::current_era(); - - precompiles() - .prepare_test( - TestAccount::Alex, - precompile_address(), - PrecompileCall::read_current_era {}, - ) - .expect_cost(READ_WEIGHT) - .expect_no_logs() - .execute_returns(current_era); - - // advance to era 5 and check output - advance_to_era(5); - let current_era = DappsStaking::current_era(); - - precompiles() - .prepare_test( - TestAccount::Alex, - precompile_address(), - PrecompileCall::read_current_era {}, - ) - .expect_cost(READ_WEIGHT) - .expect_no_logs() - .execute_returns(current_era); - }); -} - -#[test] -fn read_unbonding_period_is_ok() { - ExternalityBuilder::default().build().execute_with(|| { - initialize_first_block(); - - precompiles() - .prepare_test( - TestAccount::Alex, - precompile_address(), - PrecompileCall::read_unbonding_period {}, - ) - .expect_cost(0) - .expect_no_logs() - .execute_returns(UNBONDING_PERIOD as u128); - }); -} - -#[test] -fn read_era_reward_is_ok() { - ExternalityBuilder::default().build().execute_with(|| { - initialize_first_block(); - - advance_to_era(3); - let era_reward = joint_block_reward() * BLOCKS_PER_ERA as u128; - let second_era: EraIndex = 2; - - precompiles() - .prepare_test( - TestAccount::Alex, - precompile_address(), - PrecompileCall::read_era_reward { - era: second_era.into(), - }, - ) - .expect_cost(READ_WEIGHT) - .expect_no_logs() - .execute_returns(era_reward); - }); -} - -#[test] -fn read_era_staked_is_ok() { - ExternalityBuilder::default().build().execute_with(|| { - initialize_first_block(); - - let zero_era = EraIndex::zero(); - let staked = Balance::zero(); - - precompiles() - .prepare_test( - TestAccount::Alex, - precompile_address(), - PrecompileCall::read_era_staked { era: zero_era }, - ) - .expect_cost(READ_WEIGHT) - .expect_no_logs() - .execute_returns(staked); - }); -} - -#[test] -fn register_via_precompile_fails() { - ExternalityBuilder::default() - .with_balances(vec![(TestAccount::Alex.into(), 200 * AST)]) - .build() - .execute_with(|| { - initialize_first_block(); - - precompiles() - .prepare_test( - TestAccount::Alex, - precompile_address(), - PrecompileCall::register { - _address: Address(TEST_CONTRACT.clone()), - }, - ) - .expect_no_logs() - .execute_reverts(|output| output == b"register via evm precompile is not allowed"); - }); -} - -#[test] -fn bond_and_stake_is_ok() { - ExternalityBuilder::default() - .with_balances(vec![ - (TestAccount::Alex.into(), 200 * AST), - (TestAccount::Bobo.into(), 200 * AST), - (TestAccount::Dino.into(), 100 * AST), - ]) - .build() - .execute_with(|| { - initialize_first_block(); - - register_and_verify(TestAccount::Alex, TEST_CONTRACT); - - let amount_staked_bobo = 100 * AST; - bond_stake_and_verify(TestAccount::Bobo, TEST_CONTRACT, amount_staked_bobo); - - let amount_staked_dino = 50 * AST; - bond_stake_and_verify(TestAccount::Dino, TEST_CONTRACT, amount_staked_dino); - - contract_era_stake_verify(TEST_CONTRACT, amount_staked_bobo + amount_staked_dino); - verify_staked_amount(TEST_CONTRACT, TestAccount::Bobo.into(), amount_staked_bobo); - verify_staked_amount(TEST_CONTRACT, TestAccount::Dino.into(), amount_staked_dino); - }); -} - -#[test] -fn unbond_and_unstake_is_ok() { - ExternalityBuilder::default() - .with_balances(vec![ - (TestAccount::Alex.into(), 200 * AST), - (TestAccount::Bobo.into(), 200 * AST), - (TestAccount::Dino.into(), 100 * AST), - ]) - .build() - .execute_with(|| { - initialize_first_block(); - - // register new contract by Alex - let developer = TestAccount::Alex.into(); - register_and_verify(developer, TEST_CONTRACT); - - let amount_staked_bobo = 100 * AST; - bond_stake_and_verify(TestAccount::Bobo, TEST_CONTRACT, amount_staked_bobo); - let amount_staked_dino = 50 * AST; - bond_stake_and_verify(TestAccount::Dino, TEST_CONTRACT, amount_staked_dino); - - // Bobo unstakes all - let era = 2; - advance_to_era(era); - unbond_unstake_and_verify(TestAccount::Bobo, TEST_CONTRACT, amount_staked_bobo); - - contract_era_stake_verify(TEST_CONTRACT, amount_staked_dino); - verify_staked_amount(TEST_CONTRACT, TestAccount::Dino, amount_staked_dino); - - // withdraw unbonded funds - advance_to_era(era + UNBONDING_PERIOD + 1); - withdraw_unbonded_verify(TestAccount::Bobo); - }); -} - -#[test] -fn claim_dapp_is_ok() { - ExternalityBuilder::default() - .with_balances(vec![ - (TestAccount::Alex.into(), 200 * AST), - (TestAccount::Bobo.into(), 200 * AST), - (TestAccount::Dino.into(), 200 * AST), - ]) - .build() - .execute_with(|| { - initialize_first_block(); - - // register new contract by Alex - let developer = TestAccount::Alex; - register_and_verify(developer, TEST_CONTRACT); - - let stake_amount_total = 300 * AST; - let ratio_bobo = Perbill::from_rational(3u32, 5u32); - let ratio_dino = Perbill::from_rational(2u32, 5u32); - let amount_staked_bobo = ratio_bobo * stake_amount_total; - bond_stake_and_verify(TestAccount::Bobo, TEST_CONTRACT, amount_staked_bobo); - - let amount_staked_dino = ratio_dino * stake_amount_total; - bond_stake_and_verify(TestAccount::Dino, TEST_CONTRACT, amount_staked_dino); - - // advance era and claim reward - let era = 5; - advance_to_era(era); - claim_dapp_and_verify(TEST_CONTRACT, era - 1); - - //check that the reward is payed out to the developer - let developer_reward = DAPP_BLOCK_REWARD * BLOCKS_PER_ERA as Balance; - assert_eq!( - ::Currency::free_balance( - &TestAccount::Alex.into() - ), - (200 * AST) + developer_reward - REGISTER_DEPOSIT - ); - }); -} - -#[test] -fn claim_staker_is_ok() { - ExternalityBuilder::default() - .with_balances(vec![ - (TestAccount::Alex.into(), 200 * AST), - (TestAccount::Bobo.into(), 200 * AST), - (TestAccount::Dino.into(), 200 * AST), - ]) - .build() - .execute_with(|| { - initialize_first_block(); - - // register new contract by Alex - let developer = TestAccount::Alex; - register_and_verify(developer, TEST_CONTRACT); - - let stake_amount_total = 300 * AST; - let ratio_bobo = Perbill::from_rational(3u32, 5u32); - let ratio_dino = Perbill::from_rational(2u32, 5u32); - let amount_staked_bobo = ratio_bobo * stake_amount_total; - bond_stake_and_verify(TestAccount::Bobo, TEST_CONTRACT, amount_staked_bobo); - - let amount_staked_dino = ratio_dino * stake_amount_total; - bond_stake_and_verify(TestAccount::Dino, TEST_CONTRACT, amount_staked_dino); - - // advance era and claim reward - advance_to_era(5); - - let stakers_reward = STAKER_BLOCK_REWARD * BLOCKS_PER_ERA as Balance; - - // Ensure that all rewards can be claimed for the first staker - for era in 1..DappsStaking::current_era() as Balance { - claim_staker_and_verify(TestAccount::Bobo, TEST_CONTRACT); - assert_eq!( - ::Currency::free_balance( - &TestAccount::Bobo.into() - ), - (200 * AST) + ratio_bobo * stakers_reward * era - ); - } - - // Repeat the same thing for the second staker - for era in 1..DappsStaking::current_era() as Balance { - claim_staker_and_verify(TestAccount::Dino, TEST_CONTRACT); - assert_eq!( - ::Currency::free_balance( - &TestAccount::Dino.into() - ), - (200 * AST) + ratio_dino * stakers_reward * era - ); - } - }); -} - -#[test] -fn set_reward_destination() { - ExternalityBuilder::default() - .with_balances(vec![ - (TestAccount::Alex.into(), 200 * AST), - (TestAccount::Bobo.into(), 200 * AST), - ]) - .build() - .execute_with(|| { - initialize_first_block(); - // register contract and stake it - register_and_verify(TestAccount::Alex.into(), TEST_CONTRACT); - - // bond & stake the origin contract - bond_stake_and_verify(TestAccount::Bobo, TEST_CONTRACT, 100 * AST); - - // change destinations and verfiy it was successful - set_reward_destination_verify(TestAccount::Bobo.into(), RewardDestination::FreeBalance); - set_reward_destination_verify( - TestAccount::Bobo.into(), - RewardDestination::StakeBalance, - ); - set_reward_destination_verify(TestAccount::Bobo.into(), RewardDestination::FreeBalance); - }); -} - -#[test] -fn withdraw_from_unregistered() { - ExternalityBuilder::default() - .with_balances(vec![ - (TestAccount::Alex.into(), 200 * AST), - (TestAccount::Bobo.into(), 200 * AST), - ]) - .build() - .execute_with(|| { - initialize_first_block(); - - // register new contract by Alex - let developer = TestAccount::Alex.into(); - register_and_verify(developer, TEST_CONTRACT); - - let amount_staked_bobo = 100 * AST; - bond_stake_and_verify(TestAccount::Bobo, TEST_CONTRACT, amount_staked_bobo); - - let contract_id = - decode_smart_contract_from_array(TEST_CONTRACT.clone().to_fixed_bytes()).unwrap(); - assert_ok!(DappsStaking::unregister(RuntimeOrigin::root(), contract_id)); - - withdraw_from_unregistered_verify(TestAccount::Bobo.into(), TEST_CONTRACT); - }); -} - -#[test] -fn nomination_transfer() { - ExternalityBuilder::default() - .with_balances(vec![ - (TestAccount::Alex.into(), 200 * AST), - (TestAccount::Dino.into(), 200 * AST), - (TestAccount::Bobo.into(), 200 * AST), - ]) - .build() - .execute_with(|| { - initialize_first_block(); - - // register two contracts for nomination transfer test - let origin_contract = H160::repeat_byte(0x09); - let target_contract = H160::repeat_byte(0x0A); - register_and_verify(TestAccount::Alex.into(), origin_contract); - register_and_verify(TestAccount::Dino.into(), target_contract); - - // bond & stake the origin contract - let amount_staked_bobo = 100 * AST; - bond_stake_and_verify(TestAccount::Bobo, origin_contract, amount_staked_bobo); - - // transfer nomination and ensure it was successful - nomination_transfer_verify( - TestAccount::Bobo, - origin_contract, - 10 * AST, - target_contract, - ); - }); -} - -// **************************************************************************************************** -// Helper functions -// **************************************************************************************************** - -/// helper function to register and verify if registration is valid -fn register_and_verify(developer: TestAccount, contract: H160) { - let smart_contract = - decode_smart_contract_from_array(contract.clone().to_fixed_bytes()).unwrap(); - DappsStaking::register( - RuntimeOrigin::root(), - developer.clone().into(), - smart_contract, - ) - .unwrap(); - - // check the storage after the register - let dev_account_id: AccountId32 = developer.into(); - let smart_contract_bytes = - (DappsStaking::registered_contract(dev_account_id).unwrap_or_default()).encode(); - - assert_eq!( - // 0-th byte is enum value discriminator - smart_contract_bytes[1..21], - contract.to_fixed_bytes() - ); -} - -/// helper function to read ledger storage item -fn read_staked_amount_h160_verify(staker: TestAccount, amount: u128) { - precompiles() - .prepare_test( - staker.clone(), - precompile_address(), - PrecompileCall::read_staked_amount { - staker: H160::from(staker).to_fixed_bytes().into(), - }, - ) - .expect_no_logs() - .execute_returns(amount); -} - -/// helper function to read ledger storage item for ss58 account -fn read_staked_amount_ss58_verify(staker: TestAccount, amount: u128) { - precompiles() - .prepare_test( - staker.clone(), - precompile_address(), - PrecompileCall::read_staked_amount { - staker: AccountId32::from(staker).encode().into(), - }, - ) - .expect_no_logs() - .execute_returns(amount); -} - -/// helper function to bond, stake and verify if resulet is OK -fn bond_stake_and_verify(staker: TestAccount, contract: H160, amount: u128) { - precompiles() - .prepare_test( - staker.clone(), - precompile_address(), - PrecompileCall::bond_and_stake { - contract_h160: Address(contract), - value: amount, - }, - ) - .expect_no_logs() - .execute_returns(true); - - read_staked_amount_h160_verify(staker.clone(), amount); - read_staked_amount_ss58_verify(staker, amount); -} - -/// helper function to unbond, unstake and verify if result is OK -fn unbond_unstake_and_verify(staker: TestAccount, contract: H160, amount: u128) { - precompiles() - .prepare_test( - staker.clone(), - precompile_address(), - PrecompileCall::unbond_and_unstake { - contract_h160: Address(contract), - value: amount, - }, - ) - .expect_no_logs() - .execute_returns(true); -} - -/// helper function to withdraw unstaked funds and verify if result is OK -fn withdraw_unbonded_verify(staker: TestAccount) { - let staker_acc_id = AccountId32::from(staker.clone()); - - // call unbond_and_unstake(). Check usable_balance before and after the call - assert_ne!( - ::Currency::free_balance(&staker_acc_id), - ::Currency::usable_balance(&staker_acc_id) - ); - - precompiles() - .prepare_test( - staker.clone(), - precompile_address(), - PrecompileCall::withdraw_unbonded {}, - ) - .expect_no_logs() - .execute_returns(true); - - assert_eq!( - ::Currency::free_balance(&staker_acc_id), - ::Currency::usable_balance(&staker_acc_id) - ); -} - -/// helper function to verify change of reward destination for a staker -fn set_reward_destination_verify(staker: TestAccount, reward_destination: RewardDestination) { - // Read staker's ledger - let staker_acc_id = AccountId32::from(staker.clone()); - let init_ledger = DappsStaking::ledger(&staker_acc_id); - // Ensure that something is staked or being unbonded - assert!(!init_ledger.is_empty()); - - let reward_destination_raw: u8 = match reward_destination { - RewardDestination::FreeBalance => 0, - RewardDestination::StakeBalance => 1, - }; - precompiles() - .prepare_test( - staker.clone(), - precompile_address(), - PrecompileCall::set_reward_destination { - reward_destination_raw, - }, - ) - .expect_no_logs() - .execute_returns(true); - - let final_ledger = DappsStaking::ledger(&staker_acc_id); - assert_eq!(final_ledger.reward_destination(), reward_destination); -} - -/// helper function to withdraw funds from unregistered contract -fn withdraw_from_unregistered_verify(staker: TestAccount, contract: H160) { - let smart_contract = - decode_smart_contract_from_array(contract.clone().to_fixed_bytes()).unwrap(); - let staker_acc_id = AccountId32::from(staker.clone()); - let init_staker_info = DappsStaking::staker_info(&staker_acc_id, &smart_contract); - assert!(!init_staker_info.latest_staked_value().is_zero()); - - precompiles() - .prepare_test( - staker.clone(), - precompile_address(), - PrecompileCall::withdraw_from_unregistered { - contract_h160: Address(contract), - }, - ) - .expect_no_logs() - .execute_returns(true); - - let final_staker_info = DappsStaking::staker_info(&staker_acc_id, &smart_contract); - assert!(final_staker_info.latest_staked_value().is_zero()); -} - -/// helper function to verify nomination transfer from origin to target contract -fn nomination_transfer_verify( - staker: TestAccount, - origin_contract: H160, - amount: Balance, - target_contract: H160, -) { - let origin_smart_contract = - decode_smart_contract_from_array(origin_contract.clone().to_fixed_bytes()).unwrap(); - let target_smart_contract = - decode_smart_contract_from_array(target_contract.clone().to_fixed_bytes()).unwrap(); - let staker_acc_id = AccountId32::from(staker.clone()); - - // Read init data staker info states - let init_origin_staker_info = DappsStaking::staker_info(&staker_acc_id, &origin_smart_contract); - let init_target_staker_info = DappsStaking::staker_info(&staker_acc_id, &target_smart_contract); - - precompiles() - .prepare_test( - staker.clone(), - precompile_address(), - PrecompileCall::nomination_transfer { - origin_contract_h160: Address(origin_contract), - value: amount, - target_contract_h160: Address(target_contract), - }, - ) - .expect_no_logs() - .execute_returns(true); - - let final_origin_staker_info = - DappsStaking::staker_info(&staker_acc_id, &origin_smart_contract); - let final_target_staker_info = - DappsStaking::staker_info(&staker_acc_id, &target_smart_contract); - - // Verify final state - let will_be_unstaked = init_origin_staker_info - .latest_staked_value() - .saturating_sub(amount) - < MINIMUM_STAKING_AMOUNT; - let transfer_amount = if will_be_unstaked { - init_origin_staker_info.latest_staked_value() - } else { - amount - }; - - assert_eq!( - final_origin_staker_info.latest_staked_value() + transfer_amount, - init_origin_staker_info.latest_staked_value() - ); - assert_eq!( - final_target_staker_info.latest_staked_value() - transfer_amount, - init_target_staker_info.latest_staked_value() - ); -} - -/// helper function to bond, stake and verify if result is OK -fn claim_dapp_and_verify(contract: H160, era: EraIndex) { - precompiles() - .prepare_test( - TestAccount::Bobo, - precompile_address(), - PrecompileCall::claim_dapp { - contract_h160: Address(contract), - era: era as u128, - }, - ) - .expect_no_logs() - .execute_returns(true); -} - -/// helper function to bond, stake and verify if the result is OK -fn claim_staker_and_verify(staker: TestAccount, contract: H160) { - precompiles() - .prepare_test( - staker, - precompile_address(), - PrecompileCall::claim_staker { - contract_h160: Address(contract), - }, - ) - .expect_no_logs() - .execute_returns(true); -} - -fn contract_era_stake_verify(contract: H160, amount: Balance) { - precompiles() - .prepare_test( - TestAccount::Alex, - precompile_address(), - PrecompileCall::read_contract_stake { - contract_h160: Address(contract), - }, - ) - .expect_cost(2 * READ_WEIGHT) - .expect_no_logs() - .execute_returns(amount); -} - -/// helper function to verify latest staked amount -fn verify_staked_amount(contract: H160, staker: TestAccount, amount: Balance) { - precompiles() - .prepare_test( - staker.clone(), - precompile_address(), - PrecompileCall::read_staked_amount_on_contract { - contract_h160: Address(contract), - staker: H160::from(staker).to_fixed_bytes().into(), - }, - ) - .expect_cost(READ_WEIGHT) - .expect_no_logs() - .execute_returns(amount); -} - -/// Helper method to decode type SmartContract enum from [u8; 20] -fn decode_smart_contract_from_array( - contract_array: [u8; 20], -) -> Result<::SmartContract, String> { - // Encode contract address to fit SmartContract enum. - let mut contract_enum_encoded: [u8; 21] = [0; 21]; - contract_enum_encoded[0] = 0; // enum for EVM H160 address is 0 - contract_enum_encoded[1..21].copy_from_slice(&contract_array); - - let smart_contract = ::SmartContract::decode( - &mut &contract_enum_encoded[..21], - ) - .map_err(|_| "Error while decoding SmartContract")?; - - Ok(smart_contract) -} diff --git a/runtime/astar/Cargo.toml b/runtime/astar/Cargo.toml index cadf42a3c6..ee77aef640 100644 --- a/runtime/astar/Cargo.toml +++ b/runtime/astar/Cargo.toml @@ -103,7 +103,6 @@ astar-primitives = { workspace = true } pallet-collator-selection = { workspace = true } pallet-dapp-staking-migration = { workspace = true } pallet-dapp-staking-v3 = { workspace = true } -pallet-dapps-staking = { workspace = true } pallet-evm-precompile-assets-erc20 = { workspace = true } pallet-evm-precompile-dapp-staking-v3 = { workspace = true } pallet-evm-precompile-sr25519 = { workspace = true } @@ -247,7 +246,6 @@ try-runtime = [ "pallet-aura/try-runtime", "pallet-balances/try-runtime", "pallet-proxy/try-runtime", - "pallet-dapps-staking/try-runtime", "pallet-dapp-staking-v3/try-runtime", "pallet-dapp-staking-migration/try-runtime", "pallet-inflation/try-runtime", diff --git a/tests/integration/Cargo.toml b/tests/integration/Cargo.toml index 595ee1afb2..ad9f920a2d 100644 --- a/tests/integration/Cargo.toml +++ b/tests/integration/Cargo.toml @@ -35,7 +35,6 @@ sp-runtime = { workspace = true } assets-chain-extension-types = { workspace = true } pallet-collator-selection = { workspace = true } pallet-dapp-staking-v3 = { workspace = true } -pallet-dapps-staking = { workspace = true } pallet-ethereum-checked = { workspace = true } pallet-evm-precompile-assets-erc20 = { workspace = true } pallet-evm-precompile-dispatch = { workspace = true } diff --git a/tests/xcm-simulator/Cargo.toml b/tests/xcm-simulator/Cargo.toml index 0b784de7d4..22407f1fab 100644 --- a/tests/xcm-simulator/Cargo.toml +++ b/tests/xcm-simulator/Cargo.toml @@ -33,7 +33,6 @@ sp-tracing = { workspace = true } # Custom Astar inclusions astar-primitives = { workspace = true } astar-test-utils = { workspace = true } -pallet-dapps-staking = { workspace = true } pallet-xc-asset-config = { workspace = true } # polkadot deps @@ -76,7 +75,6 @@ std = [ "cumulus-pallet-xcm/std", "pallet-assets/std", "polkadot-primitives/std", - "pallet-dapps-staking/std", "pallet-proxy/std", "pallet-utility/std", "pallet-message-queue/std", diff --git a/tests/xcm-simulator/src/mocks/parachain.rs b/tests/xcm-simulator/src/mocks/parachain.rs index 5cb53da0fd..cdca3f3f91 100644 --- a/tests/xcm-simulator/src/mocks/parachain.rs +++ b/tests/xcm-simulator/src/mocks/parachain.rs @@ -281,45 +281,6 @@ impl OnUnbalanced for BurnFees { } } -#[derive( - PartialEq, Eq, Copy, Clone, Encode, Decode, MaxEncodedLen, RuntimeDebug, scale_info::TypeInfo, -)] -pub enum SmartContract { - Wasm(u32), -} - -impl Default for SmartContract { - fn default() -> Self { - SmartContract::Wasm(0) - } -} - -parameter_types! { - pub const DappsStakingPalletId: PalletId = PalletId(*b"py/dpsst"); - pub const MaxUnlockingChunks: u32 = 5; - pub const UnbondingPeriod: u32 = 5; - pub const MaxEraStakeValues: u32 = 5; -} - -impl pallet_dapps_staking::Config for Runtime { - type Currency = Balances; - type BlockPerEra = ConstU64<5>; - type SmartContract = SmartContract; - type RegisterDeposit = ConstU128<1>; - type RuntimeEvent = RuntimeEvent; - type WeightInfo = pallet_dapps_staking::weights::SubstrateWeight; - type MaxNumberOfStakersPerContract = ConstU32<8>; - type MinimumStakingAmount = ConstU128<1>; - type PalletId = DappsStakingPalletId; - type MinimumRemainingAmount = ConstU128<0>; - type MaxUnlockingChunks = ConstU32<4>; - type UnbondingPeriod = ConstU32<2>; - type MaxEraStakeValues = ConstU32<4>; - type UnregisteredDappRewardRetention = ConstU32<7>; - type ForcePalletDisabled = ConstBool; - type DelegateClaimFee = ConstU128<1>; -} - /// The type used to represent the kinds of proxying allowed. #[derive( Copy, @@ -336,7 +297,7 @@ impl pallet_dapps_staking::Config for Runtime { )] pub enum ProxyType { CancelProxy, - DappsStaking, + DappStaking, StakerRewardClaim, } @@ -355,14 +316,15 @@ impl InstanceFilter for ProxyType { RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. }) ) } - ProxyType::DappsStaking => { - matches!(c, RuntimeCall::DappsStaking(..) | RuntimeCall::Utility(..)) + ProxyType::DappStaking => { + matches!(c, RuntimeCall::DappStaking(..) | RuntimeCall::Utility(..)) } ProxyType::StakerRewardClaim => { matches!( c, - RuntimeCall::DappsStaking(pallet_dapps_staking::Call::claim_staker { .. }) - | RuntimeCall::Utility(..) + RuntimeCall::DappStaking( + pallet_dapp_staking::Call::claim_staker_rewards { .. } + ) | RuntimeCall::Utility(..) ) } } @@ -370,7 +332,7 @@ impl InstanceFilter for ProxyType { fn is_superset(&self, o: &Self) -> bool { match (self, o) { - (Self::StakerRewardClaim, Self::DappsStaking) => true, + (Self::StakerRewardClaim, Self::DappStaking) => true, (x, y) if x == y => true, _ => false, } @@ -683,7 +645,7 @@ construct_runtime!( Assets: pallet_assets, XcAssetConfig: pallet_xc_asset_config, CumulusXcm: cumulus_pallet_xcm, - DappsStaking: pallet_dapps_staking, + DappStaking: pallet_dapp_staking_v3, Proxy: pallet_proxy, Utility: pallet_utility, Randomness: pallet_insecure_randomness_collective_flip, From 54c91990cdcb2d6900368a393d573586035888ff Mon Sep 17 00:00:00 2001 From: Dino Pacandi Date: Wed, 27 Mar 2024 08:55:32 +0100 Subject: [PATCH 04/19] Migrations & benchmark fixes --- .../src/fungible/benchmarking.rs | 8 +++---- runtime/astar/src/lib.rs | 13 ++---------- runtime/shibuya/src/lib.rs | 21 ++++++++++++++++++- runtime/shiden/src/lib.rs | 18 ++++++++-------- 4 files changed, 35 insertions(+), 25 deletions(-) diff --git a/pallets/astar-xcm-benchmarks/src/fungible/benchmarking.rs b/pallets/astar-xcm-benchmarks/src/fungible/benchmarking.rs index eb21999ce2..ae8aa01722 100644 --- a/pallets/astar-xcm-benchmarks/src/fungible/benchmarking.rs +++ b/pallets/astar-xcm-benchmarks/src/fungible/benchmarking.rs @@ -61,11 +61,11 @@ mod benchmarks { >::deposit_asset( &asset_to_deposit, &sender_location, - &XcmContext { + Some(&XcmContext { origin: Some(sender_location.clone()), message_id: [0; 32], topic: None, - }, + }), ) .unwrap(); @@ -103,11 +103,11 @@ mod benchmarks { >::deposit_asset( &asset_to_deposit, &sender_location, - &XcmContext { + Some(&XcmContext { origin: Some(sender_location.clone()), message_id: [0; 32], topic: None, - }, + }), ) .unwrap(); assert!(T::TransactAsset::balance(&dest_account).is_zero()); diff --git a/runtime/astar/src/lib.rs b/runtime/astar/src/lib.rs index c6b204e1fb..9f489ad246 100644 --- a/runtime/astar/src/lib.rs +++ b/runtime/astar/src/lib.rs @@ -420,11 +420,6 @@ impl pallet_inflation::Config for Runtime { type WeightInfo = weights::pallet_inflation::SubstrateWeight; } -impl pallet_dapp_staking_migration::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type WeightInfo = pallet_dapp_staking_migration::weights::SubstrateWeight; -} - impl pallet_utility::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; @@ -1082,8 +1077,6 @@ construct_runtime!( // To be removed & cleaned up once proper oracle is implemented StaticPriceProvider: pallet_static_price_provider = 253, - // To be removed & cleaned up after migration has been finished - DappStakingMigration: pallet_dapp_staking_migration = 254, } ); @@ -1123,18 +1116,17 @@ pub type Executive = frame_executive::Executive< parameter_types! { pub const DappStakingMigrationName: &'static str = "DappStakingMigration"; + } /// All migrations that will run on the next runtime upgrade. /// /// Once done, migrations should be removed from the tuple. pub type Migrations = ( - // Part of astar-83, need to first cleanup old storage before re-using the pallet + // TODO: mark with version number frame_support::migrations::RemovePallet< DappStakingMigrationName, ::DbWeight, >, - // Part of astar-83 - (pallet_dapp_staking_migration::SingularStakingInfoTranslationUpgrade,), ); type EventRecord = frame_system::EventRecord< @@ -1214,7 +1206,6 @@ mod benches { [pallet_timestamp, Timestamp] [pallet_dapp_staking_v3, DappStaking] [pallet_inflation, Inflation] - [pallet_dapp_staking_migration, DappStakingMigration] [pallet_xc_asset_config, XcAssetConfig] [pallet_collator_selection, CollatorSelection] [pallet_xcm, PolkadotXcm] diff --git a/runtime/shibuya/src/lib.rs b/runtime/shibuya/src/lib.rs index 35c7140a43..bda1162a3e 100644 --- a/runtime/shibuya/src/lib.rs +++ b/runtime/shibuya/src/lib.rs @@ -1212,10 +1212,27 @@ pub type Executive = frame_executive::Executive< Migrations, >; +parameter_types! { + pub const DappStakingMigrationName: &'static str = "DappStakingMigration"; + pub const DemocracyName: &'static str = "Democracy"; + pub const CouncilName: &'static str = "Council"; + pub const TechnicalCommitteeName: &'static str = "TechnicalCommittee"; + pub const TreasuryName: &'static str = "Treasury"; + +} +use frame_support::migrations::RemovePallet; + /// All migrations that will run on the next runtime upgrade. /// /// Once done, migrations should be removed from the tuple. -pub type Migrations = (); +pub type Migrations = ( + // TODO: mark with version number + RemovePallet::DbWeight>, + RemovePallet::DbWeight>, + RemovePallet::DbWeight>, + RemovePallet::DbWeight>, + RemovePallet::DbWeight>, +); type EventRecord = frame_system::EventRecord< ::RuntimeEvent, @@ -1839,6 +1856,7 @@ impl_runtime_apis! { impl pallet_xcm_benchmarks::Config for Runtime { type XcmConfig = xcm_config::XcmConfig; type AccountIdConverter = xcm_config::LocationToAccountId; + type DeliveryHelper = (); // destination location to be used in benchmarks fn valid_destination() -> Result { Ok(MultiLocation::parent()) @@ -1850,6 +1868,7 @@ impl_runtime_apis! { impl pallet_xcm_benchmarks::generic::Config for Runtime { type RuntimeCall = RuntimeCall; + type TransactAsset = Balances; fn worst_case_response() -> (u64, Response) { (0u64, Response::Version(Default::default())) } diff --git a/runtime/shiden/src/lib.rs b/runtime/shiden/src/lib.rs index df806f140f..dde212fb25 100644 --- a/runtime/shiden/src/lib.rs +++ b/runtime/shiden/src/lib.rs @@ -1031,11 +1031,6 @@ impl pallet_proxy::Config for Runtime { type AnnouncementDepositFactor = AnnouncementDepositFactor; } -impl pallet_dapp_staking_migration::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type WeightInfo = pallet_dapp_staking_migration::weights::SubstrateWeight; -} - construct_runtime!( pub struct Runtime { @@ -1082,8 +1077,6 @@ construct_runtime!( Sudo: pallet_sudo = 99, - // Remove after migrating to v6 storage - DappStakingMigration: pallet_dapp_staking_migration = 252, // To be removed & cleaned up once proper oracle is implemented StaticPriceProvider: pallet_static_price_provider = 253, } @@ -1123,12 +1116,19 @@ pub type Executive = frame_executive::Executive< Migrations, >; +parameter_types! { + pub const DappStakingMigrationName: &'static str = "DappStakingMigration"; + +} /// All migrations that will run on the next runtime upgrade. /// /// Once done, migrations should be removed from the tuple. pub type Migrations = ( - // Part of shiden-122 - pallet_dapp_staking_migration::SingularStakingInfoTranslationUpgrade, + // TODO: mark with version number + frame_support::migrations::RemovePallet< + DappStakingMigrationName, + ::DbWeight, + >, ); use frame_support::traits::OnRuntimeUpgrade; From 501d04b9aac9fc1d72425c898ef58ed67b89b31c Mon Sep 17 00:00:00 2001 From: Dino Pacandi Date: Wed, 27 Mar 2024 15:39:40 +0100 Subject: [PATCH 05/19] Fix tests & compilation issues --- Cargo.lock | 4 +- Cargo.toml | 5 - pallets/astar-xcm-benchmarks/src/mock.rs | 3 + pallets/ethereum-checked/Cargo.toml | 1 + pallets/ethereum-checked/src/tests.rs | 15 ++- pallets/xvm/src/mock.rs | 2 +- precompiles/xcm/src/mock.rs | 6 +- runtime/local/src/lib.rs | 2 +- runtime/shibuya/src/lib.rs | 2 +- runtime/shiden/Cargo.toml | 3 - tests/integration/src/setup.rs | 1 - tests/xcm-simulator/Cargo.toml | 4 + tests/xcm-simulator/src/mocks/mod.rs | 22 +--- tests/xcm-simulator/src/mocks/parachain.rs | 114 +++++++++++++++++++-- tests/xcm-simulator/src/tests/general.rs | 64 ++++++------ 15 files changed, 177 insertions(+), 71 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 91842f4834..ccd4ee5aba 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8550,6 +8550,7 @@ dependencies = [ "ethereum-types", "fp-ethereum", "fp-evm", + "fp-rpc", "frame-benchmarking", "frame-support", "frame-system", @@ -14038,7 +14039,6 @@ dependencies = [ "pallet-authorship", "pallet-balances", "pallet-collator-selection", - "pallet-collective", "pallet-contracts", "pallet-contracts-primitives", "pallet-dapp-staking-migration", @@ -17747,6 +17747,7 @@ dependencies = [ name = "xcm-simulator-tests" version = "0.1.0" dependencies = [ + "assert_matches", "astar-primitives", "astar-test-utils", "cumulus-pallet-xcm", @@ -17760,6 +17761,7 @@ dependencies = [ "pallet-balances", "pallet-contracts", "pallet-contracts-primitives", + "pallet-dapp-staking-v3", "pallet-insecure-randomness-collective-flip", "pallet-message-queue", "pallet-proxy", diff --git a/Cargo.toml b/Cargo.toml index 04a3840696..cfa7f5da4d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -170,12 +170,9 @@ pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/parityt pallet-vesting = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } frame-system-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } -pallet-collective = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } frame-try-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } -pallet-democracy = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } pallet-preimage = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } pallet-scheduler = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } -pallet-treasury = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } pallet-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } pallet-message-queue = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } @@ -273,7 +270,6 @@ orml-xcm-support = { git = "https://github.com/AstarNetwork/open-runtime-module- # Astar pallets & modules # (wasm) pallet-collator-selection = { path = "./pallets/collator-selection", default-features = false } -pallet-dapps-staking = { path = "./pallets/dapps-staking", default-features = false } pallet-dapp-staking-v3 = { path = "./pallets/dapp-staking-v3", default-features = false } pallet-dapp-staking-migration = { path = "./pallets/dapp-staking-migration", default-features = false } pallet-xc-asset-config = { path = "./pallets/xc-asset-config", default-features = false } @@ -295,7 +291,6 @@ pallet-evm-precompile-sr25519 = { path = "./precompiles/sr25519", default-featur pallet-evm-precompile-substrate-ecdsa = { path = "./precompiles/substrate-ecdsa", default-features = false } pallet-evm-precompile-xcm = { path = "./precompiles/xcm", default-features = false } pallet-evm-precompile-xvm = { path = "./precompiles/xvm", default-features = false } -pallet-evm-precompile-dapps-staking = { path = "./precompiles/dapps-staking", default-features = false } pallet-evm-precompile-dapp-staking-v3 = { path = "./precompiles/dapp-staking-v3", default-features = false } pallet-evm-precompile-unified-accounts = { path = "./precompiles/unified-accounts", default-features = false } pallet-evm-precompile-dispatch-lockdrop = { path = "./precompiles/dispatch-lockdrop", default-features = false } diff --git a/pallets/astar-xcm-benchmarks/src/mock.rs b/pallets/astar-xcm-benchmarks/src/mock.rs index 8cc45dc4d4..9b848d8b79 100644 --- a/pallets/astar-xcm-benchmarks/src/mock.rs +++ b/pallets/astar-xcm-benchmarks/src/mock.rs @@ -252,6 +252,8 @@ impl xcm_executor::Config for XcmConfig { impl pallet_xcm_benchmarks::Config for Test { type XcmConfig = XcmConfig; type AccountIdConverter = AccountIdConverter; + type DeliveryHelper = (); + fn valid_destination() -> Result { let valid_destination: MultiLocation = X1(AccountId32 { network: None, @@ -272,6 +274,7 @@ impl pallet_xcm_benchmarks::Config for Test { impl pallet_xcm_benchmarks::generic::Config for Test { type RuntimeCall = RuntimeCall; + type TransactAsset = Balances; fn worst_case_response() -> (u64, Response) { let assets: MultiAssets = (Concrete(Here.into()), 100).into(); diff --git a/pallets/ethereum-checked/Cargo.toml b/pallets/ethereum-checked/Cargo.toml index c9aaca3e8a..e2538195fe 100644 --- a/pallets/ethereum-checked/Cargo.toml +++ b/pallets/ethereum-checked/Cargo.toml @@ -27,6 +27,7 @@ astar-primitives = { workspace = true } [dev-dependencies] ethereum = { workspace = true } +fp-rpc = { workspace = true } pallet-balances = { workspace = true } pallet-ethereum = { workspace = true } pallet-evm = { workspace = true } diff --git a/pallets/ethereum-checked/src/tests.rs b/pallets/ethereum-checked/src/tests.rs index e5c9b8f41c..620d80772e 100644 --- a/pallets/ethereum-checked/src/tests.rs +++ b/pallets/ethereum-checked/src/tests.rs @@ -22,7 +22,8 @@ use super::*; use mock::*; use astar_primitives::ethereum_checked::EthereumTxInput; -use ethereum::{ReceiptV3, TransactionV2 as Transaction}; +use ethereum::{ReceiptV3, ReceiptV3 as Receipt, TransactionV2 as Transaction}; +pub use fp_rpc::TransactionStatus; use frame_support::{assert_noop, assert_ok}; use sp_runtime::DispatchError; @@ -31,6 +32,14 @@ fn bounded_input(data: &'static str) -> EthereumTxInput { .expect("input too large") } +// A hacky way to get around crate pub visibility of the storage item. +#[frame_support::storage_alias] +type Pending = StorageValue< + pallet_ethereum::Pallet, + Vec<(Transaction, TransactionStatus, Receipt)>, + ValueQuery, +>; + #[test] fn transact_works() { ExtBuilder::default().build().execute_with(|| { @@ -52,7 +61,7 @@ fn transact_works() { RawOrigin::XcmEthereumTx(ALICE).into(), store_tx )); - let pending = pallet_ethereum::Pending::::get(); + let pending = Pending::::get(); assert_eq!(pending.len(), 2); match pending[0] { @@ -143,7 +152,7 @@ fn no_hash_collision() { )); } - let mut tx_hashes = pallet_ethereum::Pending::::get() + let mut tx_hashes = Pending::::get() .iter() .map(|(tx, _, _)| tx.hash()) .collect::>(); diff --git a/pallets/xvm/src/mock.rs b/pallets/xvm/src/mock.rs index 8060c7f2c8..1c22a799fe 100644 --- a/pallets/xvm/src/mock.rs +++ b/pallets/xvm/src/mock.rs @@ -82,7 +82,7 @@ impl pallet_balances::Config for TestRuntime { type RuntimeHoldReason = RuntimeHoldReason; type FreezeIdentifier = (); type RuntimeFreezeReason = (); - type MaxHolds = ConstU32<0>; + type MaxHolds = ConstU32<1>; type MaxFreezes = ConstU32<0>; } diff --git a/precompiles/xcm/src/mock.rs b/precompiles/xcm/src/mock.rs index d94382482d..b14fbafbf2 100644 --- a/precompiles/xcm/src/mock.rs +++ b/precompiles/xcm/src/mock.rs @@ -412,7 +412,11 @@ pub type Barrier = ( pub struct LocalAssetTransactor; impl TransactAsset for LocalAssetTransactor { - fn deposit_asset(_what: &MultiAsset, _who: &MultiLocation, _context: &XcmContext) -> XcmResult { + fn deposit_asset( + _what: &MultiAsset, + _who: &MultiLocation, + _context: Option<&XcmContext>, + ) -> XcmResult { Ok(()) } diff --git a/runtime/local/src/lib.rs b/runtime/local/src/lib.rs index 8dc45392f9..3fcee065c8 100644 --- a/runtime/local/src/lib.rs +++ b/runtime/local/src/lib.rs @@ -306,7 +306,7 @@ impl pallet_balances::Config for Runtime { type RuntimeHoldReason = RuntimeHoldReason; type RuntimeFreezeReason = RuntimeFreezeReason; type FreezeIdentifier = RuntimeFreezeReason; - type MaxHolds = ConstU32<1>; + type MaxHolds = ConstU32<2>; type MaxFreezes = ConstU32<1>; } diff --git a/runtime/shibuya/src/lib.rs b/runtime/shibuya/src/lib.rs index bda1162a3e..96d556a66b 100644 --- a/runtime/shibuya/src/lib.rs +++ b/runtime/shibuya/src/lib.rs @@ -622,7 +622,7 @@ impl pallet_balances::Config for Runtime { type RuntimeHoldReason = RuntimeHoldReason; type RuntimeFreezeReason = RuntimeFreezeReason; type FreezeIdentifier = RuntimeFreezeReason; - type MaxHolds = ConstU32<1>; + type MaxHolds = ConstU32<2>; type MaxFreezes = ConstU32<1>; } diff --git a/runtime/shiden/Cargo.toml b/runtime/shiden/Cargo.toml index fb1d0edf2f..3ff11c5fe3 100644 --- a/runtime/shiden/Cargo.toml +++ b/runtime/shiden/Cargo.toml @@ -96,7 +96,6 @@ orml-xtokens = { workspace = true } array-bytes = { workspace = true } frame-benchmarking = { workspace = true, optional = true } frame-system-benchmarking = { workspace = true, optional = true } -pallet-collective = { workspace = true, optional = true } # try-runtime frame-try-runtime = { workspace = true, optional = true } @@ -156,7 +155,6 @@ std = [ "pallet-assets/std", "pallet-balances/std", "pallet-contracts/std", - "pallet-collective/std", "pallet-contracts-primitives/std", "pallet-dynamic-evm-base-fee/std", "pallet-ethereum/std", @@ -230,7 +228,6 @@ runtime-benchmarks = [ "pallet-dapp-staking-migration/runtime-benchmarks", "pallet-inflation/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", - "pallet-collective/runtime-benchmarks", "pallet-ethereum/runtime-benchmarks", "pallet-xcm/runtime-benchmarks", "xcm-builder/runtime-benchmarks", diff --git a/tests/integration/src/setup.rs b/tests/integration/src/setup.rs index 5ec33ada14..8de00143a0 100644 --- a/tests/integration/src/setup.rs +++ b/tests/integration/src/setup.rs @@ -162,7 +162,6 @@ pub const INITIAL_AMOUNT: u128 = 100_000 * UNIT; pub type SystemError = frame_system::Error; pub use pallet_balances::Call as BalancesCall; pub use pallet_dapp_staking_v3 as DappStakingCall; -pub use pallet_dapps_staking as DappsStakingCall; pub use pallet_proxy::Event as ProxyEvent; pub use pallet_utility::{Call as UtilityCall, Event as UtilityEvent}; diff --git a/tests/xcm-simulator/Cargo.toml b/tests/xcm-simulator/Cargo.toml index 22407f1fab..b8bed7b801 100644 --- a/tests/xcm-simulator/Cargo.toml +++ b/tests/xcm-simulator/Cargo.toml @@ -8,6 +8,7 @@ homepage.workspace = true repository.workspace = true [dev-dependencies] +assert_matches = { workspace = true } log = { workspace = true } parity-scale-codec = { workspace = true } scale-info = { workspace = true } @@ -33,6 +34,7 @@ sp-tracing = { workspace = true } # Custom Astar inclusions astar-primitives = { workspace = true } astar-test-utils = { workspace = true } +pallet-dapp-staking-v3 = { workspace = true } pallet-xc-asset-config = { workspace = true } # polkadot deps @@ -81,6 +83,7 @@ std = [ "orml-xtokens/std", "orml-traits/std", "orml-xcm-support/std", + "pallet-dapp-staking-v3/std", ] runtime-benchmarks = [ "frame-system/runtime-benchmarks", @@ -96,4 +99,5 @@ runtime-benchmarks = [ "orml-xtokens/runtime-benchmarks", "astar-primitives/runtime-benchmarks", "pallet-message-queue/runtime-benchmarks", + "pallet-dapp-staking-v3/runtime-benchmarks", ] diff --git a/tests/xcm-simulator/src/mocks/mod.rs b/tests/xcm-simulator/src/mocks/mod.rs index 624c8d5cd0..c578051d73 100644 --- a/tests/xcm-simulator/src/mocks/mod.rs +++ b/tests/xcm-simulator/src/mocks/mod.rs @@ -20,7 +20,7 @@ pub(crate) mod msg_queue; pub(crate) mod parachain; pub(crate) mod relay_chain; -use frame_support::traits::{Currency, IsType, OnFinalize, OnInitialize}; +use frame_support::traits::{IsType, OnFinalize, OnInitialize}; use sp_runtime::traits::{Bounded, StaticLookup}; use sp_runtime::{BuildStorage, DispatchResult}; use xcm::latest::prelude::*; @@ -31,8 +31,6 @@ pub const ALICE: sp_runtime::AccountId32 = sp_runtime::AccountId32::new([0xFAu8; pub const BOB: sp_runtime::AccountId32 = sp_runtime::AccountId32::new([0xFBu8; 32]); pub const INITIAL_BALANCE: u128 = 1_000_000_000_000_000_000_000_000; pub const ONE: u128 = 1_000_000_000_000_000_000; -pub const DAPP_STAKER_REWARD_PER_BLOCK: parachain::Balance = 1_000; -pub const DAPP_STAKER_DEV_PER_BLOCK: parachain::Balance = 250; decl_test_parachain! { pub struct ParaA { @@ -140,9 +138,7 @@ pub fn para_ext(para_id: u32) -> sp_io::TestExternalities { System::set_block_number(1); MsgQueue::set_para_id(para_id.into()); - parachain::DappsStaking::on_initialize(1); - let (staker_rewards, dev_rewards) = issue_dapps_staking_rewards(); - parachain::DappsStaking::rewards(staker_rewards, dev_rewards); + parachain::DappStaking::on_initialize(1); }); ext } @@ -178,7 +174,7 @@ pub fn advance_parachain_block_to(block_number: u64) { let current_block_number = parachain::System::block_number(); parachain::PolkadotXcm::on_finalize(current_block_number); parachain::Balances::on_finalize(current_block_number); - parachain::DappsStaking::on_finalize(current_block_number); + parachain::DappStaking::on_finalize(current_block_number); parachain::System::on_finalize(current_block_number); // Forward 1 block @@ -189,23 +185,13 @@ pub fn advance_parachain_block_to(block_number: u64) { // On Initialize parachain::System::on_initialize(current_block_number); { - parachain::DappsStaking::on_initialize(current_block_number); - let (staker_rewards, dev_rewards) = issue_dapps_staking_rewards(); - parachain::DappsStaking::rewards(staker_rewards, dev_rewards); + parachain::DappStaking::on_initialize(current_block_number); } parachain::Balances::on_initialize(current_block_number); parachain::PolkadotXcm::on_initialize(current_block_number); } } -/// Issues and returns negative imbalances of (staker rewards, developer rewards) -fn issue_dapps_staking_rewards() -> (parachain::NegativeImbalance, parachain::NegativeImbalance) { - ( - parachain::Balances::issue(DAPP_STAKER_REWARD_PER_BLOCK), - parachain::Balances::issue(DAPP_STAKER_DEV_PER_BLOCK), - ) -} - /// Register and configure the asset for use in XCM /// It first create the asset in `pallet_assets` and then register the asset multilocation /// mapping in `pallet_xc_asset_config`, and lastly set the asset per second for calculating diff --git a/tests/xcm-simulator/src/mocks/parachain.rs b/tests/xcm-simulator/src/mocks/parachain.rs index cdca3f3f91..d564fb1f9e 100644 --- a/tests/xcm-simulator/src/mocks/parachain.rs +++ b/tests/xcm-simulator/src/mocks/parachain.rs @@ -40,7 +40,7 @@ use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use sp_core::H256; use sp_runtime::{ traits::{AccountIdConversion, Convert, Get, IdentityLookup, MaybeEquivalence}, - AccountId32, Perbill, RuntimeDebug, + AccountId32, FixedU64, Perbill, RuntimeDebug, }; use sp_std::marker::PhantomData; use sp_std::prelude::*; @@ -61,9 +61,15 @@ use orml_xcm_support::DisabledParachainFee; use xcm_executor::{traits::JustTry, XcmExecutor}; -use astar_primitives::xcm::{ - AllowTopLevelPaidExecutionFrom, AssetLocationIdConverter, FixedRateOfForeignAsset, - ReserveAssetFilter, XcmFungibleFeeHandler, +use astar_primitives::{ + dapp_staking::{ + AccountCheck, CycleConfiguration, SmartContract, SmartContractHandle, StakingRewardHandler, + }, + oracle::PriceProvider, + xcm::{ + AllowTopLevelPaidExecutionFrom, AssetLocationIdConverter, FixedRateOfForeignAsset, + ReserveAssetFilter, XcmFungibleFeeHandler, + }, }; pub type AccountId = AccountId32; @@ -124,7 +130,7 @@ impl pallet_balances::Config for Runtime { type RuntimeFreezeReason = RuntimeFreezeReason; type FreezeIdentifier = RuntimeFreezeReason; type MaxHolds = ConstU32<1>; - type MaxFreezes = ConstU32<0>; + type MaxFreezes = ConstU32<1>; } impl pallet_utility::Config for Runtime { @@ -323,7 +329,7 @@ impl InstanceFilter for ProxyType { matches!( c, RuntimeCall::DappStaking( - pallet_dapp_staking::Call::claim_staker_rewards { .. } + pallet_dapp_staking_v3::Call::claim_staker_rewards { .. } ) | RuntimeCall::Utility(..) ) } @@ -634,6 +640,102 @@ impl orml_xtokens::Config for Runtime { type ReserveProvider = AbsoluteAndRelativeReserveProvider; } +pub struct DummyCycleConfiguration; +impl CycleConfiguration for DummyCycleConfiguration { + fn periods_per_cycle() -> u32 { + 4 + } + + fn eras_per_voting_subperiod() -> u32 { + 8 + } + + fn eras_per_build_and_earn_subperiod() -> u32 { + 16 + } + + fn blocks_per_era() -> u32 { + 10 + } +} + +pub struct DummyAccountCheck; +impl AccountCheck for DummyAccountCheck { + fn allowed_to_stake(_: &AccountId) -> bool { + true + } +} + +pub struct DummyStakingRewardHandler; +impl StakingRewardHandler for DummyStakingRewardHandler { + fn staker_and_dapp_reward_pools(_total_staked_value: Balance) -> (Balance, Balance) { + ( + Balance::from(1_000_000_000_000_u128), + Balance::from(1_000_000_000_u128), + ) + } + + fn bonus_reward_pool() -> Balance { + Balance::from(3_000_000_u128) + } + + fn payout_reward(_: &AccountId, _: Balance) -> Result<(), ()> { + Ok(()) + } +} + +pub struct DummyPriceProvider; +impl PriceProvider for DummyPriceProvider { + fn average_price() -> FixedU64 { + FixedU64::from_rational(1, 10) + } +} + +pub(crate) type MockSmartContract = SmartContract; + +#[cfg(feature = "runtime-benchmarks")] +pub struct BenchmarkHelper(sp_std::marker::PhantomData<(SC, ACC)>); +#[cfg(feature = "runtime-benchmarks")] +impl pallet_dapp_staking_v3::BenchmarkHelper + for BenchmarkHelper +{ + fn get_smart_contract(id: u32) -> MockSmartContract { + MockSmartContract::wasm(AccountId::from([id as u8; 32])) + } + + fn set_balance(account: &AccountId, amount: Balance) { + use frame_support::traits::fungible::Unbalanced as FunUnbalanced; + Balances::write_balance(account, amount) + .expect("Must succeed in test/benchmark environment."); + } +} + +impl pallet_dapp_staking_v3::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type RuntimeFreezeReason = RuntimeFreezeReason; + type Currency = Balances; + type SmartContract = MockSmartContract; + type ManagerOrigin = frame_system::EnsureRoot; + type NativePriceProvider = DummyPriceProvider; + type StakingRewardHandler = DummyStakingRewardHandler; + type CycleConfiguration = DummyCycleConfiguration; + type Observers = (); + type AccountCheck = DummyAccountCheck; + type TierSlots = astar_primitives::dapp_staking::StandardTierSlots; + type EraRewardSpanLength = ConstU32<1>; + type RewardRetentionInPeriods = ConstU32<2>; + type MaxNumberOfContracts = ConstU32<10>; + type MaxUnlockingChunks = ConstU32<5>; + type MinimumLockedAmount = ConstU128<3>; + type UnlockingPeriod = ConstU32<2>; + type MaxNumberOfStakedContracts = ConstU32<5>; + type MinimumStakeAmount = ConstU128<3>; + type NumberOfTiers = ConstU32<4>; + type WeightInfo = (); + #[cfg(feature = "runtime-benchmarks")] + type BenchmarkHelper = BenchmarkHelper; +} + type Block = frame_system::mocking::MockBlock; construct_runtime!( diff --git a/tests/xcm-simulator/src/tests/general.rs b/tests/xcm-simulator/src/tests/general.rs index 1931f5d069..6f6f4c5ffb 100644 --- a/tests/xcm-simulator/src/tests/general.rs +++ b/tests/xcm-simulator/src/tests/general.rs @@ -23,6 +23,8 @@ use parity_scale_codec::Encode; use xcm::prelude::*; use xcm_simulator::TestExt; +use astar_primitives::dapp_staking::SmartContractHandle; + #[test] fn basic_dmp() { MockNet::reset(); @@ -190,31 +192,35 @@ fn remote_dapps_staking_staker_claim() { // The idea of this test case is to remotely claim dApps staking staker rewards. // Remote claim will be sent from parachain A to parachain B. - let smart_contract = parachain::SmartContract::Wasm(1337); + let smart_contract = + parachain::MockSmartContract::wasm(parachain::AccountId::from([13 as u8; 32])); let stake_amount = 100_000_000; // 1st step // Register contract & stake on it. Advance a few blocks until at least era 4 since we need 3 claimable rewards. // Enable parachain A sovereign account to claim on Alice's behalf. ParaB::execute_with(|| { - assert_ok!(parachain::DappsStaking::register( + assert_ok!(parachain::DappStaking::register( parachain::RuntimeOrigin::root(), ALICE, smart_contract.clone(), )); - assert_ok!(parachain::DappsStaking::bond_and_stake( + assert_ok!(parachain::DappStaking::lock( parachain::RuntimeOrigin::signed(ALICE), - smart_contract.clone(), stake_amount, )); - assert_ok!(parachain::DappsStaking::set_reward_destination( + assert_ok!(parachain::DappStaking::stake( parachain::RuntimeOrigin::signed(ALICE), - pallet_dapps_staking::RewardDestination::StakeBalance, + smart_contract.clone(), + stake_amount, )); - // advance enough blocks so we at least get to era 4 - advance_parachain_block_to(20); - assert!(parachain::DappsStaking::current_era() >= 4); + // advance enough blocks so we at least get to era 5 - this gives us era 2, 3 and 4 for claiming + while pallet_dapp_staking_v3::ActiveProtocolState::::get().era < 5 { + advance_parachain_block_to(parachain::System::block_number() + 1); + } + // Ensure it's not first block so event storage is clear + advance_parachain_block_to(parachain::System::block_number() + 1); // Register para A sovereign account as proxy with dApps staking privileges assert_ok!(parachain::Proxy::add_proxy( @@ -225,11 +231,9 @@ fn remote_dapps_staking_staker_claim() { )); }); - let claim_staker_call = parachain::RuntimeCall::DappsStaking(pallet_dapps_staking::Call::< + let claim_staker_call = parachain::RuntimeCall::DappStaking(pallet_dapp_staking_v3::Call::< parachain::Runtime, - >::claim_staker { - contract_id: smart_contract.clone(), - }); + >::claim_staker_rewards {}); // 2nd step // Dispatch remote `claim_staker` call from Para A to Para B @@ -264,23 +268,23 @@ fn remote_dapps_staking_staker_claim() { // Receive claim & verify it was successful ParaB::execute_with(|| { // We expect exactly one `Reward` event - assert_eq!( - parachain::System::events() - .iter() - .filter(|r| matches!( - r.event, - parachain::RuntimeEvent::DappsStaking( - pallet_dapps_staking::Event::Reward { .. } - ) - )) - .count(), - 1 + let dapp_staking_events = parachain::System::events() + .into_iter() + .map(|r| r.event) + .filter_map(|e| { + ::RuntimeEvent::from(e) + .try_into() + .ok() + }) + .collect::>>(); + + assert_eq!(dapp_staking_events.len(), 1); + assert_matches::assert_matches!( + dapp_staking_events[0].clone(), + pallet_dapp_staking_v3::Event::Reward { account, .. } + if account == ALICE ); - // Extra check to ensure reward was claimed for `Alice` - let staker_info = parachain::DappsStaking::staker_info(&ALICE, &smart_contract); - assert!(staker_info.latest_staked_value() > stake_amount); - // Cleanup events parachain::System::reset_events(); }); @@ -328,8 +332,8 @@ fn remote_dapps_staking_staker_claim() { .iter() .filter(|r| matches!( r.event, - parachain::RuntimeEvent::DappsStaking( - pallet_dapps_staking::Event::Reward { .. } + parachain::RuntimeEvent::DappStaking( + pallet_dapp_staking_v3::Event::Reward { .. } ) )) .count(), From 58b46c28df21591c692be948cbc979051b60f34b Mon Sep 17 00:00:00 2001 From: Dino Pacandi Date: Wed, 27 Mar 2024 15:45:38 +0100 Subject: [PATCH 06/19] Eth debug RPC --- bin/collator/src/rpc.rs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/bin/collator/src/rpc.rs b/bin/collator/src/rpc.rs index 99d47e0189..8eb517904f 100644 --- a/bin/collator/src/rpc.rs +++ b/bin/collator/src/rpc.rs @@ -21,9 +21,9 @@ use cumulus_primitives_parachain_inherent::ParachainInherentData; use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder; use fc_rpc::{ - pending::ConsensusDataProvider, Eth, EthApiServer, EthBlockDataCacheTask, EthFilter, - EthFilterApiServer, EthPubSub, EthPubSubApiServer, Net, NetApiServer, OverrideHandle, Web3, - Web3ApiServer, + pending::ConsensusDataProvider, Debug, DebugApiServer, Eth, EthApiServer, + EthBlockDataCacheTask, EthFilter, EthFilterApiServer, EthPubSub, EthPubSubApiServer, Net, + NetApiServer, OverrideHandle, Web3, Web3ApiServer, }; use fc_rpc_core::types::{FeeHistoryCache, FilterPool}; use jsonrpsee::RpcModule; @@ -379,12 +379,12 @@ where io.merge( EthFilter::new( client.clone(), - frontier_backend, + frontier_backend.clone(), graph.clone(), filter_pool, max_stored_filters, max_past_logs, - block_data_cache, + block_data_cache.clone(), ) .into_rpc(), )?; @@ -399,11 +399,21 @@ where client.clone(), sync, subscription_task_executor, - overrides, + overrides.clone(), pubsub_notification_sinks, ) .into_rpc(), )?; + io.merge( + Debug::new( + client.clone(), + frontier_backend, + overrides, + block_data_cache, + ) + .into_rpc(), + )?; + Ok(io) } From 307e9e1b07306201b31ff5e153261705afde69ec Mon Sep 17 00:00:00 2001 From: Dino Pacandi Date: Wed, 27 Mar 2024 15:48:46 +0100 Subject: [PATCH 07/19] Remove todos --- primitives/src/xcm/tests.rs | 50 ------------------- runtime/local/src/lib.rs | 5 +- runtime/local/src/precompiles.rs | 1 - runtime/shibuya/src/precompiles.rs | 1 - runtime/shiden/src/precompiles.rs | 1 - tests/xcm-simulator/src/mocks/parachain.rs | 1 - .../src/tests/fungible_assets.rs | 7 +-- 7 files changed, 3 insertions(+), 63 deletions(-) diff --git a/primitives/src/xcm/tests.rs b/primitives/src/xcm/tests.rs index 5a95473ee1..573908220e 100644 --- a/primitives/src/xcm/tests.rs +++ b/primitives/src/xcm/tests.rs @@ -427,53 +427,3 @@ fn reserve_asset_filter_for_unsupported_asset_multi_location() { assert!(!ReserveAssetFilter::contains(&multi_asset, &origin)); } - -// TODO: can be deleted after uplift to `polkadot-v0.9.44` or beyond. -#[test] -fn hashed_description_sanity_check() { - let acc_key_20_mul = MultiLocation { - parents: 1, - interior: X2( - Parachain(1), - AccountKey20 { - network: None, - key: [7u8; 20], - }, - ), - }; - // Ensure derived value is same as it would be using `polkadot-v0.9.44` code. - let derived_account = - HashedDescription::<[u8; 32], DescribeFamily>::convert_location( - &acc_key_20_mul, - ); - assert_eq!( - derived_account, - Some([ - 61_u8, 117, 247, 231, 100, 219, 128, 176, 180, 200, 187, 102, 93, 107, 187, 145, 25, - 146, 50, 248, 244, 153, 83, 95, 207, 165, 90, 10, 220, 39, 23, 49 - ]) - ); - - let acc_id_32_mul = MultiLocation { - parents: 1, - interior: X2( - Parachain(50), - AccountId32 { - network: None, - id: [3; 32].into(), - }, - ), - }; - // Ensure derived value is same as it would be using `polkadot-v0.9.44` code. - let derived_account = - HashedDescription::<[u8; 32], DescribeFamily>::convert_location( - &acc_id_32_mul, - ); - assert_eq!( - derived_account, - Some([ - 123, 171, 79, 159, 78, 47, 62, 233, 108, 149, 131, 249, 23, 192, 178, 52, 235, 133, - 147, 145, 152, 89, 129, 92, 63, 79, 211, 235, 213, 152, 201, 205 - ]) - ); -} diff --git a/runtime/local/src/lib.rs b/runtime/local/src/lib.rs index 3fcee065c8..fe1cc2202b 100644 --- a/runtime/local/src/lib.rs +++ b/runtime/local/src/lib.rs @@ -874,11 +874,8 @@ impl pallet_proxy::Config for Runtime { type AnnouncementDepositFactor = ConstU128<{ MILLIAST * 660 }>; } -// TODO: remove this once https://github.com/paritytech/substrate/issues/12161 is resolved -#[rustfmt::skip] construct_runtime!( - pub struct Runtime - { + pub struct Runtime { System: frame_system, Utility: pallet_utility, Timestamp: pallet_timestamp, diff --git a/runtime/local/src/precompiles.rs b/runtime/local/src/precompiles.rs index 2edec7f84b..008858dd71 100644 --- a/runtime/local/src/precompiles.rs +++ b/runtime/local/src/precompiles.rs @@ -112,7 +112,6 @@ pub type LocalPrecompilesSetAt = ( AddressU64<1025>, Dispatch>, // Not callable from smart contract nor precompiles, only EOA accounts - // TODO: test this without the gensis hack for blacklisted (), >, PrecompileAt, ECRecoverPublicKey, (CallableByContract, CallableByPrecompile)>, diff --git a/runtime/shibuya/src/precompiles.rs b/runtime/shibuya/src/precompiles.rs index c499c4d121..931299b19e 100644 --- a/runtime/shibuya/src/precompiles.rs +++ b/runtime/shibuya/src/precompiles.rs @@ -113,7 +113,6 @@ pub type ShibuyaPrecompilesSetAt = ( AddressU64<1025>, Dispatch>, // Not callable from smart contract nor precompiles, only EOA accounts - // TODO: test this without the gensis hack for blacklisted (), >, PrecompileAt, ECRecoverPublicKey, (CallableByContract, CallableByPrecompile)>, diff --git a/runtime/shiden/src/precompiles.rs b/runtime/shiden/src/precompiles.rs index e3f858af5f..d15b4b2939 100644 --- a/runtime/shiden/src/precompiles.rs +++ b/runtime/shiden/src/precompiles.rs @@ -83,7 +83,6 @@ pub type ShidenPrecompilesSetAt = ( AddressU64<1025>, Dispatch>, // Not callable from smart contract nor precompiles, only EOA accounts - // TODO: test this without the gensis hack for blacklisted (), >, PrecompileAt, ECRecoverPublicKey, (CallableByContract, CallableByPrecompile)>, diff --git a/tests/xcm-simulator/src/mocks/parachain.rs b/tests/xcm-simulator/src/mocks/parachain.rs index d564fb1f9e..49c50aaa04 100644 --- a/tests/xcm-simulator/src/mocks/parachain.rs +++ b/tests/xcm-simulator/src/mocks/parachain.rs @@ -211,7 +211,6 @@ parameter_types! { pub SS58Prefix: u8 = 5; } -// TODO: changing depost per item and per byte to `deposit` function will require storage migration it seems parameter_types! { pub const DepositPerItem: Balance = MILLISDN / 1_000_000; pub const DepositPerByte: Balance = MILLISDN / 1_000_000; diff --git a/tests/xcm-simulator/src/tests/fungible_assets.rs b/tests/xcm-simulator/src/tests/fungible_assets.rs index 8cf234c17b..82eb902a96 100644 --- a/tests/xcm-simulator/src/tests/fungible_assets.rs +++ b/tests/xcm-simulator/src/tests/fungible_assets.rs @@ -21,9 +21,8 @@ use frame_support::{assert_ok, weights::Weight}; use xcm::prelude::*; use xcm_simulator::TestExt; -// TODO: remove this when retiring pallet-xcm fork #[test] -fn para_to_para_reserve_transfer_and_back_via_pallet_xcm() { +fn para_to_para_reserve_transfer_and_back_via_xtokens() { MockNet::reset(); let sibling_asset_id = 123 as u128; @@ -409,12 +408,10 @@ fn para_to_para_reserve_transfer_local_asset() { }); } -// TODO: remove this when retiring pallet-xcm fork -// // Send a relay asset (like DOT/KSM) to a parachain A // and send it back from Parachain A to relaychain #[test] -fn receive_relay_asset_from_relay_and_send_them_back_via_pallet_xcm() { +fn receive_relay_asset_from_relay_and_send_them_back_via_xtokens() { MockNet::reset(); let source_location = (Parent,); From 55893a902f1ee73a320de68e9c28db64b9f5051b Mon Sep 17 00:00:00 2001 From: Dino Pacandi Date: Wed, 27 Mar 2024 15:57:19 +0100 Subject: [PATCH 08/19] TODOs --- CONTRIBUTING.md | 4 ---- bin/xcm-tools/src/command.rs | 6 ++++-- primitives/src/dapp_staking.rs | 7 ------- primitives/src/xcm/mod.rs | 23 +---------------------- runtime/shibuya/src/xcm_config.rs | 7 +++---- runtime/shiden/src/xcm_config.rs | 12 ++++++------ 6 files changed, 14 insertions(+), 45 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 22bdbd8c64..df43224ca8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -60,10 +60,6 @@ All branch names should adhere to the following rules: - `doc/*`: documentation changes - `fix/*`: bug fixes - -**TODO**: We don't really use this at all from what I've seen? -- `development/*`: nodes that are actively in development (including release candidates) will have the `development/` prefix in their branch name. - Every major feature will be first deployed on our testnet parachain _Shibuya_ after which it can be deployed on one of the production networks. The expected flow is: diff --git a/bin/xcm-tools/src/command.rs b/bin/xcm-tools/src/command.rs index 1378307c57..e8cbfa929a 100644 --- a/bin/xcm-tools/src/command.rs +++ b/bin/xcm-tools/src/command.rs @@ -20,7 +20,6 @@ use crate::cli::*; -use astar_primitives::xcm::DescribeAllTerminal; use clap::Parser; use cumulus_primitives_core::ParaId; use polkadot_parachain::primitives::Sibling; @@ -28,7 +27,10 @@ use polkadot_primitives::AccountId; use sp_core::hexdisplay::HexDisplay; use sp_runtime::traits::AccountIdConversion; use xcm::latest::prelude::*; -use xcm_builder::{DescribeFamily, HashedDescription, ParentIsPreset, SiblingParachainConvertsVia}; +use xcm_builder::{ + DescribeAllTerminal, DescribeFamily, HashedDescription, ParentIsPreset, + SiblingParachainConvertsVia, +}; use xcm_executor::traits::ConvertLocation; /// CLI error type. diff --git a/primitives/src/dapp_staking.rs b/primitives/src/dapp_staking.rs index 282be84945..766b1e07e1 100644 --- a/primitives/src/dapp_staking.rs +++ b/primitives/src/dapp_staking.rs @@ -156,13 +156,6 @@ pub enum SmartContract { Wasm(AccountId), } -// TODO: remove this once dApps staking v2 has been removed. -impl Default for SmartContract { - fn default() -> Self { - Self::evm([0x01; 20].into()) - } -} - impl SmartContractHandle for SmartContract { fn evm(address: H160) -> Self { Self::Evm(address) diff --git a/primitives/src/xcm/mod.rs b/primitives/src/xcm/mod.rs index c7ab998b5c..dfd9ca7388 100644 --- a/primitives/src/xcm/mod.rs +++ b/primitives/src/xcm/mod.rs @@ -37,9 +37,8 @@ use frame_support::{ traits::{tokens::fungibles, Contains, ContainsPair, Get, ProcessMessageError}, weights::constants::WEIGHT_REF_TIME_PER_SECOND, }; -use parity_scale_codec::Encode; use sp_runtime::traits::{Bounded, Convert, MaybeEquivalence, Zero}; -use sp_std::{marker::PhantomData, vec::Vec}; +use sp_std::marker::PhantomData; // Polkadot imports use xcm::latest::{prelude::*, Weight}; @@ -269,26 +268,6 @@ impl< } } -// TODO: remove this after uplift to `polkadot-v1.3.0` or beyond, and replace it with code in XCM builder. - -pub struct DescribeBodyTerminal; -impl xcm_builder::DescribeLocation for DescribeBodyTerminal { - fn describe_location(l: &MultiLocation) -> Option> { - match (l.parents, &l.interior) { - (0, X1(Plurality { id, part })) => Some((b"Body", id, part).encode()), - _ => return None, - } - } -} - -pub type DescribeAllTerminal = ( - xcm_builder::DescribeTerminus, - xcm_builder::DescribePalletTerminal, - xcm_builder::DescribeAccountId32Terminal, - xcm_builder::DescribeAccountKey20Terminal, - DescribeBodyTerminal, -); - /// Convert `AccountId` to `MultiLocation`. pub struct AccountIdToMultiLocation; impl Convert for AccountIdToMultiLocation { diff --git a/runtime/shibuya/src/xcm_config.rs b/runtime/shibuya/src/xcm_config.rs index a7b63c4073..c8c18ae67b 100644 --- a/runtime/shibuya/src/xcm_config.rs +++ b/runtime/shibuya/src/xcm_config.rs @@ -36,8 +36,8 @@ use polkadot_runtime_common::xcm_sender::NoPriceForMessageDelivery; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowUnpaidExecutionFrom, - ConvertedConcreteId, CurrencyAdapter, DescribeFamily, EnsureXcmOrigin, FungiblesAdapter, - HashedDescription, IsConcrete, NoChecking, ParentAsSuperuser, ParentIsPreset, + ConvertedConcreteId, CurrencyAdapter, DescribeAllTerminal, DescribeFamily, EnsureXcmOrigin, + FungiblesAdapter, HashedDescription, IsConcrete, NoChecking, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, WeightInfoBounds, WithComputedOrigin, @@ -50,8 +50,7 @@ use orml_xcm_support::DisabledParachainFee; // Astar imports use astar_primitives::xcm::{ AbsoluteAndRelativeReserveProvider, AccountIdToMultiLocation, AllowTopLevelPaidExecutionFrom, - DescribeAllTerminal, FixedRateOfForeignAsset, ReserveAssetFilter, XcmFungibleFeeHandler, - MAX_ASSETS, + FixedRateOfForeignAsset, ReserveAssetFilter, XcmFungibleFeeHandler, MAX_ASSETS, }; parameter_types! { diff --git a/runtime/shiden/src/xcm_config.rs b/runtime/shiden/src/xcm_config.rs index a1ff693b3e..9c474e3d57 100644 --- a/runtime/shiden/src/xcm_config.rs +++ b/runtime/shiden/src/xcm_config.rs @@ -36,11 +36,11 @@ use polkadot_runtime_common::xcm_sender::NoPriceForMessageDelivery; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowUnpaidExecutionFrom, - ConvertedConcreteId, CurrencyAdapter, DescribeFamily, EnsureXcmOrigin, FixedWeightBounds, - FungiblesAdapter, HashedDescription, IsConcrete, NoChecking, ParentAsSuperuser, ParentIsPreset, - RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, - SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, - UsingComponents, WithComputedOrigin, + ConvertedConcreteId, CurrencyAdapter, DescribeAllTerminal, DescribeFamily, EnsureXcmOrigin, + FixedWeightBounds, FungiblesAdapter, HashedDescription, IsConcrete, NoChecking, + ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, + SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, + SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, WithComputedOrigin, }; use xcm_executor::{ traits::{JustTry, WithOriginFilter}, @@ -53,7 +53,7 @@ use orml_xcm_support::DisabledParachainFee; // Astar imports use astar_primitives::xcm::{ AbsoluteAndRelativeReserveProvider, AccountIdToMultiLocation, AllowTopLevelPaidExecutionFrom, - DescribeAllTerminal, FixedRateOfForeignAsset, ReserveAssetFilter, XcmFungibleFeeHandler, + FixedRateOfForeignAsset, ReserveAssetFilter, XcmFungibleFeeHandler, }; parameter_types! { From d2e43fb2be210d357a5b97e8e9cb3e810ae43a7c Mon Sep 17 00:00:00 2001 From: Dino Pacandi Date: Wed, 27 Mar 2024 16:28:02 +0100 Subject: [PATCH 09/19] Fixes --- Cargo.lock | 120 ++++++++++++------ Cargo.toml | 2 +- primitives/src/xcm/tests.rs | 3 - .../src/assets_chain_extensions.rs | 2 +- .../src/dispatch_precompile_filter.rs | 4 +- tests/integration/src/proxy.rs | 8 +- tests/integration/src/unified_accounts.rs | 2 +- 7 files changed, 91 insertions(+), 50 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ccd4ee5aba..99a6910de5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -829,7 +829,7 @@ dependencies = [ "polkadot-parachain-primitives", "polkadot-primitives", "polkadot-runtime-common", - "precompile-utils", + "precompile-utils 0.1.0 (git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0)", "scale-info", "smallvec 1.11.0", "sp-api", @@ -4176,7 +4176,7 @@ dependencies = [ [[package]] name = "fc-api" version = "1.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#76939a19b45d9908f0358b0aaed9a5ab20398f45" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" dependencies = [ "async-trait", "fp-storage", @@ -4188,7 +4188,7 @@ dependencies = [ [[package]] name = "fc-consensus" version = "2.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#76939a19b45d9908f0358b0aaed9a5ab20398f45" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" dependencies = [ "async-trait", "fp-consensus", @@ -4204,7 +4204,7 @@ dependencies = [ [[package]] name = "fc-db" version = "2.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#76939a19b45d9908f0358b0aaed9a5ab20398f45" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" dependencies = [ "async-trait", "fc-api", @@ -4225,7 +4225,7 @@ dependencies = [ [[package]] name = "fc-mapping-sync" version = "2.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#76939a19b45d9908f0358b0aaed9a5ab20398f45" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" dependencies = [ "fc-db", "fc-storage", @@ -4246,7 +4246,7 @@ dependencies = [ [[package]] name = "fc-rpc" version = "2.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#76939a19b45d9908f0358b0aaed9a5ab20398f45" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" dependencies = [ "ethereum", "ethereum-types", @@ -4300,7 +4300,7 @@ dependencies = [ [[package]] name = "fc-rpc-core" version = "1.1.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#76939a19b45d9908f0358b0aaed9a5ab20398f45" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" dependencies = [ "ethereum", "ethereum-types", @@ -4313,7 +4313,7 @@ dependencies = [ [[package]] name = "fc-storage" version = "1.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#76939a19b45d9908f0358b0aaed9a5ab20398f45" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" dependencies = [ "ethereum", "ethereum-types", @@ -4478,7 +4478,7 @@ dependencies = [ [[package]] name = "fp-account" version = "1.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#76939a19b45d9908f0358b0aaed9a5ab20398f45" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" dependencies = [ "hex", "impl-serde", @@ -4497,7 +4497,7 @@ dependencies = [ [[package]] name = "fp-consensus" version = "2.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#76939a19b45d9908f0358b0aaed9a5ab20398f45" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" dependencies = [ "ethereum", "parity-scale-codec", @@ -4509,7 +4509,7 @@ dependencies = [ [[package]] name = "fp-ethereum" version = "1.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#76939a19b45d9908f0358b0aaed9a5ab20398f45" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" dependencies = [ "ethereum", "ethereum-types", @@ -4522,7 +4522,7 @@ dependencies = [ [[package]] name = "fp-evm" version = "3.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#76939a19b45d9908f0358b0aaed9a5ab20398f45" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" dependencies = [ "evm", "frame-support", @@ -4538,7 +4538,7 @@ dependencies = [ [[package]] name = "fp-rpc" version = "3.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#76939a19b45d9908f0358b0aaed9a5ab20398f45" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" dependencies = [ "ethereum", "ethereum-types", @@ -4555,7 +4555,7 @@ dependencies = [ [[package]] name = "fp-self-contained" version = "1.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#76939a19b45d9908f0358b0aaed9a5ab20398f45" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" dependencies = [ "frame-support", "parity-scale-codec", @@ -4567,7 +4567,7 @@ dependencies = [ [[package]] name = "fp-storage" version = "2.0.0" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#76939a19b45d9908f0358b0aaed9a5ab20398f45" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" dependencies = [ "parity-scale-codec", "serde", @@ -5728,7 +5728,7 @@ dependencies = [ "pallet-unified-accounts", "pallet-utility", "parity-scale-codec", - "precompile-utils", + "precompile-utils 0.1.0 (git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0)", "sha3", "shibuya-runtime", "shiden-runtime", @@ -6748,7 +6748,7 @@ dependencies = [ "pallet-vesting", "pallet-xvm", "parity-scale-codec", - "precompile-utils", + "precompile-utils 0.1.0 (git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0)", "scale-info", "smallvec 1.11.0", "sp-api", @@ -8521,7 +8521,7 @@ dependencies = [ [[package]] name = "pallet-ethereum" version = "4.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#76939a19b45d9908f0358b0aaed9a5ab20398f45" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" dependencies = [ "ethereum", "ethereum-types", @@ -8569,7 +8569,7 @@ dependencies = [ [[package]] name = "pallet-evm" version = "6.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#76939a19b45d9908f0358b0aaed9a5ab20398f45" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" dependencies = [ "environmental", "evm", @@ -8595,7 +8595,7 @@ dependencies = [ [[package]] name = "pallet-evm-chain-id" version = "1.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#76939a19b45d9908f0358b0aaed9a5ab20398f45" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" dependencies = [ "frame-support", "frame-system", @@ -8618,7 +8618,7 @@ dependencies = [ "pallet-evm", "pallet-timestamp", "parity-scale-codec", - "precompile-utils", + "precompile-utils 0.1.0 (git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0)", "scale-info", "serde", "sha3", @@ -8632,7 +8632,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-blake2" version = "2.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#76939a19b45d9908f0358b0aaed9a5ab20398f45" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" dependencies = [ "fp-evm", ] @@ -8640,7 +8640,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-bn128" version = "2.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#76939a19b45d9908f0358b0aaed9a5ab20398f45" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" dependencies = [ "fp-evm", "sp-core", @@ -8664,7 +8664,7 @@ dependencies = [ "pallet-evm", "pallet-timestamp", "parity-scale-codec", - "precompile-utils", + "precompile-utils 0.1.0 (git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0)", "scale-info", "serde", "sha3", @@ -8678,7 +8678,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-dispatch" version = "2.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#76939a19b45d9908f0358b0aaed9a5ab20398f45" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" dependencies = [ "fp-evm", "frame-support", @@ -8705,7 +8705,7 @@ dependencies = [ "pallet-timestamp", "pallet-utility", "parity-scale-codec", - "precompile-utils", + "precompile-utils 0.1.0 (git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0)", "scale-info", "sp-core", "sp-io", @@ -8716,7 +8716,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-ed25519" version = "2.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#76939a19b45d9908f0358b0aaed9a5ab20398f45" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" dependencies = [ "ed25519-dalek", "fp-evm", @@ -8725,7 +8725,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-modexp" version = "2.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#76939a19b45d9908f0358b0aaed9a5ab20398f45" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" dependencies = [ "fp-evm", "num", @@ -8734,7 +8734,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-sha3fips" version = "2.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#76939a19b45d9908f0358b0aaed9a5ab20398f45" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" dependencies = [ "fp-evm", "tiny-keccak", @@ -8743,7 +8743,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-simple" version = "2.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#76939a19b45d9908f0358b0aaed9a5ab20398f45" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" dependencies = [ "fp-evm", "ripemd", @@ -8765,7 +8765,7 @@ dependencies = [ "pallet-evm", "pallet-timestamp", "parity-scale-codec", - "precompile-utils", + "precompile-utils 0.1.0 (git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0)", "scale-info", "serde", "sp-core", @@ -8790,7 +8790,7 @@ dependencies = [ "pallet-evm", "pallet-timestamp", "parity-scale-codec", - "precompile-utils", + "precompile-utils 0.1.0 (git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0)", "scale-info", "serde", "sp-core", @@ -8819,7 +8819,7 @@ dependencies = [ "pallet-timestamp", "pallet-unified-accounts", "parity-scale-codec", - "precompile-utils", + "precompile-utils 0.1.0 (git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0)", "scale-info", "serde", "sp-core", @@ -8851,7 +8851,7 @@ dependencies = [ "pallet-timestamp", "pallet-xcm", "parity-scale-codec", - "precompile-utils", + "precompile-utils 0.1.0 (git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0)", "scale-info", "serde", "sp-core", @@ -8880,7 +8880,7 @@ dependencies = [ "pallet-evm", "pallet-timestamp", "parity-scale-codec", - "precompile-utils", + "precompile-utils 0.1.0 (git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0)", "scale-info", "serde", "sp-core", @@ -9577,7 +9577,7 @@ dependencies = [ "pallet-evm", "pallet-timestamp", "parity-scale-codec", - "precompile-utils", + "precompile-utils 0.1.0 (git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0)", "scale-info", "sp-core", "sp-io", @@ -11209,6 +11209,50 @@ dependencies = [ "staging-xcm", ] +[[package]] +name = "precompile-utils" +version = "0.1.0" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" +dependencies = [ + "derive_more", + "environmental", + "evm", + "fp-evm", + "frame-support", + "frame-system", + "hex", + "hex-literal", + "impl-trait-for-tuples", + "log", + "num_enum 0.7.0", + "pallet-evm", + "parity-scale-codec", + "precompile-utils-macro", + "scale-info", + "serde", + "similar-asserts", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", + "sp-weights", + "staging-xcm", +] + +[[package]] +name = "precompile-utils-macro" +version = "0.1.0" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" +dependencies = [ + "case", + "num_enum 0.7.0", + "prettyplease 0.2.15", + "proc-macro2", + "quote", + "sp-core-hashing", + "syn 1.0.109", +] + [[package]] name = "precompile-utils-macro-v2" version = "0.1.0" @@ -13978,7 +14022,7 @@ dependencies = [ "polkadot-parachain-primitives", "polkadot-primitives", "polkadot-runtime-common", - "precompile-utils", + "precompile-utils 0.1.0 (git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0)", "scale-info", "smallvec 1.11.0", "sp-api", @@ -14078,7 +14122,7 @@ dependencies = [ "polkadot-parachain-primitives", "polkadot-primitives", "polkadot-runtime-common", - "precompile-utils", + "precompile-utils 0.1.0 (git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0)", "scale-info", "smallvec 1.11.0", "sp-api", diff --git a/Cargo.toml b/Cargo.toml index cfa7f5da4d..2747b8914c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -303,7 +303,7 @@ xvm-chain-extension-types = { path = "./chain-extensions/types/xvm", default-fea assets-chain-extension-types = { path = "./chain-extensions/types/assets", default-features = false } unified-accounts-chain-extension-types = { path = "./chain-extensions/types/unified-accounts", default-features = false } -precompile-utils = { path = "./precompiles/utils", default-features = false } +precompile-utils = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.3.0", default-features = false } local-runtime = { path = "./runtime/local", default-features = false } shibuya-runtime = { path = "./runtime/shibuya", default-features = false } diff --git a/primitives/src/xcm/tests.rs b/primitives/src/xcm/tests.rs index 573908220e..352083a7be 100644 --- a/primitives/src/xcm/tests.rs +++ b/primitives/src/xcm/tests.rs @@ -17,11 +17,8 @@ // along with Astar. If not, see . use super::*; -use crate::xcm::DescribeAllTerminal; use frame_support::assert_ok; use sp_runtime::traits::{MaybeEquivalence, Zero}; -use xcm_builder::{DescribeFamily, HashedDescription}; -use xcm_executor::traits::ConvertLocation; type AssetId = u128; diff --git a/tests/integration/src/assets_chain_extensions.rs b/tests/integration/src/assets_chain_extensions.rs index 8eb65a6fb3..57859b6300 100644 --- a/tests/integration/src/assets_chain_extensions.rs +++ b/tests/integration/src/assets_chain_extensions.rs @@ -165,7 +165,7 @@ fn approve_works() { // Contract approve Alice to spend 100 tokens // First the contract need Existential DDeposit - assert_ok!(Balances::transfer( + assert_ok!(Balances::transfer_allow_death( RuntimeOrigin::signed(ALICE), contract_id.clone().into(), UNIT, diff --git a/tests/integration/src/dispatch_precompile_filter.rs b/tests/integration/src/dispatch_precompile_filter.rs index b406b43d05..48f42c4c69 100644 --- a/tests/integration/src/dispatch_precompile_filter.rs +++ b/tests/integration/src/dispatch_precompile_filter.rs @@ -43,7 +43,7 @@ fn filter_accepts_batch_call_with_whitelisted_calls() { fn filter_rejects_non_whitelisted_batch_calls() { ExtBuilder::default().build().execute_with(|| { // CASE1 - only non whitelisted calls - let transfer_call = RuntimeCall::Balances(BalancesCall::transfer { + let transfer_call = RuntimeCall::Balances(BalancesCall::transfer_allow_death { dest: MultiAddress::Id(CAT), value: 100_000_000_000, }); @@ -90,7 +90,7 @@ fn filter_accepts_whitelisted_calls() { fn filter_rejects_non_whitelisted_calls() { ExtBuilder::default().build().execute_with(|| { // Random call from non whitelisted pallet doesn't work - let transfer_call = RuntimeCall::Balances(BalancesCall::transfer { + let transfer_call = RuntimeCall::Balances(BalancesCall::transfer_allow_death { dest: MultiAddress::Id(CAT), value: 100_000_000_000, }); diff --git a/tests/integration/src/proxy.rs b/tests/integration/src/proxy.rs index c54bc30ca8..3a69cba343 100644 --- a/tests/integration/src/proxy.rs +++ b/tests/integration/src/proxy.rs @@ -32,7 +32,7 @@ fn test_utility_call_pass_for_any() { )); // Preparing Utility call - let transfer_call = RuntimeCall::Balances(BalancesCall::transfer { + let transfer_call = RuntimeCall::Balances(BalancesCall::transfer_allow_death { dest: MultiAddress::Id(CAT), value: 100_000_000_000, }); @@ -67,7 +67,7 @@ fn test_utility_call_pass_for_balances() { )); // Preparing Utility call - let transfer_call = RuntimeCall::Balances(BalancesCall::transfer { + let transfer_call = RuntimeCall::Balances(BalancesCall::transfer_allow_death { dest: MultiAddress::Id(CAT), value: 100_000_000_000, }); @@ -102,7 +102,7 @@ fn test_utility_call_fail_non_transfer() { )); // Preparing Utility call - let transfer_call = RuntimeCall::Balances(BalancesCall::transfer { + let transfer_call = RuntimeCall::Balances(BalancesCall::transfer_allow_death { dest: MultiAddress::Id(CAT), value: 100_000_000_000, }); @@ -142,7 +142,7 @@ fn test_utility_call_fail_for_dappstaking() { )); // Preparing Utility call - let transfer_call = RuntimeCall::Balances(BalancesCall::transfer { + let transfer_call = RuntimeCall::Balances(BalancesCall::transfer_allow_death { dest: MultiAddress::Id(CAT), value: 100_000_000_000, }); diff --git a/tests/integration/src/unified_accounts.rs b/tests/integration/src/unified_accounts.rs index 7870be16ca..e0ca150858 100644 --- a/tests/integration/src/unified_accounts.rs +++ b/tests/integration/src/unified_accounts.rs @@ -32,7 +32,7 @@ fn transfer_to_h160_via_lookup() { assert!(EVM::is_account_empty(ð_address)); // tranfer to evm account - assert_ok!(Balances::transfer( + assert_ok!(Balances::transfer_allow_death( RuntimeOrigin::signed(ALICE), MultiAddress::Address20(eth_address.clone().into()), UNIT, From 79faabe4337218ed70e2f7bff50481e252fc50db Mon Sep 17 00:00:00 2001 From: Dino Pacandi Date: Wed, 27 Mar 2024 16:51:20 +0100 Subject: [PATCH 10/19] Change dep back --- Cargo.lock | 72 +++++++++++------------------------------------------- Cargo.toml | 2 +- 2 files changed, 15 insertions(+), 59 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 99a6910de5..be7ab0b3e4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -829,7 +829,7 @@ dependencies = [ "polkadot-parachain-primitives", "polkadot-primitives", "polkadot-runtime-common", - "precompile-utils 0.1.0 (git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0)", + "precompile-utils", "scale-info", "smallvec 1.11.0", "sp-api", @@ -5728,7 +5728,7 @@ dependencies = [ "pallet-unified-accounts", "pallet-utility", "parity-scale-codec", - "precompile-utils 0.1.0 (git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0)", + "precompile-utils", "sha3", "shibuya-runtime", "shiden-runtime", @@ -6748,7 +6748,7 @@ dependencies = [ "pallet-vesting", "pallet-xvm", "parity-scale-codec", - "precompile-utils 0.1.0 (git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0)", + "precompile-utils", "scale-info", "smallvec 1.11.0", "sp-api", @@ -8618,7 +8618,7 @@ dependencies = [ "pallet-evm", "pallet-timestamp", "parity-scale-codec", - "precompile-utils 0.1.0 (git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0)", + "precompile-utils", "scale-info", "serde", "sha3", @@ -8664,7 +8664,7 @@ dependencies = [ "pallet-evm", "pallet-timestamp", "parity-scale-codec", - "precompile-utils 0.1.0 (git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0)", + "precompile-utils", "scale-info", "serde", "sha3", @@ -8705,7 +8705,7 @@ dependencies = [ "pallet-timestamp", "pallet-utility", "parity-scale-codec", - "precompile-utils 0.1.0 (git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0)", + "precompile-utils", "scale-info", "sp-core", "sp-io", @@ -8765,7 +8765,7 @@ dependencies = [ "pallet-evm", "pallet-timestamp", "parity-scale-codec", - "precompile-utils 0.1.0 (git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0)", + "precompile-utils", "scale-info", "serde", "sp-core", @@ -8790,7 +8790,7 @@ dependencies = [ "pallet-evm", "pallet-timestamp", "parity-scale-codec", - "precompile-utils 0.1.0 (git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0)", + "precompile-utils", "scale-info", "serde", "sp-core", @@ -8819,7 +8819,7 @@ dependencies = [ "pallet-timestamp", "pallet-unified-accounts", "parity-scale-codec", - "precompile-utils 0.1.0 (git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0)", + "precompile-utils", "scale-info", "serde", "sp-core", @@ -8851,7 +8851,7 @@ dependencies = [ "pallet-timestamp", "pallet-xcm", "parity-scale-codec", - "precompile-utils 0.1.0 (git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0)", + "precompile-utils", "scale-info", "serde", "sp-core", @@ -8880,7 +8880,7 @@ dependencies = [ "pallet-evm", "pallet-timestamp", "parity-scale-codec", - "precompile-utils 0.1.0 (git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0)", + "precompile-utils", "scale-info", "serde", "sp-core", @@ -9577,7 +9577,7 @@ dependencies = [ "pallet-evm", "pallet-timestamp", "parity-scale-codec", - "precompile-utils 0.1.0 (git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0)", + "precompile-utils", "scale-info", "sp-core", "sp-io", @@ -11209,50 +11209,6 @@ dependencies = [ "staging-xcm", ] -[[package]] -name = "precompile-utils" -version = "0.1.0" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" -dependencies = [ - "derive_more", - "environmental", - "evm", - "fp-evm", - "frame-support", - "frame-system", - "hex", - "hex-literal", - "impl-trait-for-tuples", - "log", - "num_enum 0.7.0", - "pallet-evm", - "parity-scale-codec", - "precompile-utils-macro", - "scale-info", - "serde", - "similar-asserts", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", - "sp-weights", - "staging-xcm", -] - -[[package]] -name = "precompile-utils-macro" -version = "0.1.0" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" -dependencies = [ - "case", - "num_enum 0.7.0", - "prettyplease 0.2.15", - "proc-macro2", - "quote", - "sp-core-hashing", - "syn 1.0.109", -] - [[package]] name = "precompile-utils-macro-v2" version = "0.1.0" @@ -14022,7 +13978,7 @@ dependencies = [ "polkadot-parachain-primitives", "polkadot-primitives", "polkadot-runtime-common", - "precompile-utils 0.1.0 (git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0)", + "precompile-utils", "scale-info", "smallvec 1.11.0", "sp-api", @@ -14122,7 +14078,7 @@ dependencies = [ "polkadot-parachain-primitives", "polkadot-primitives", "polkadot-runtime-common", - "precompile-utils 0.1.0 (git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0)", + "precompile-utils", "scale-info", "smallvec 1.11.0", "sp-api", diff --git a/Cargo.toml b/Cargo.toml index 2747b8914c..cfa7f5da4d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -303,7 +303,7 @@ xvm-chain-extension-types = { path = "./chain-extensions/types/xvm", default-fea assets-chain-extension-types = { path = "./chain-extensions/types/assets", default-features = false } unified-accounts-chain-extension-types = { path = "./chain-extensions/types/unified-accounts", default-features = false } -precompile-utils = { git = "https://github.com/AstarNetwork/frontier", branch = "polkadot-v1.3.0", default-features = false } +precompile-utils = { path = "./precompiles/utils", default-features = false } local-runtime = { path = "./runtime/local", default-features = false } shibuya-runtime = { path = "./runtime/shibuya", default-features = false } From 0f944acab9e78c8e66549b3d0266aa14e1ce3215 Mon Sep 17 00:00:00 2001 From: Dino Pacandi Date: Wed, 27 Mar 2024 17:01:42 +0100 Subject: [PATCH 11/19] Remove double debug server --- bin/collator/src/rpc.rs | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/bin/collator/src/rpc.rs b/bin/collator/src/rpc.rs index 8eb517904f..b3d98d6f27 100644 --- a/bin/collator/src/rpc.rs +++ b/bin/collator/src/rpc.rs @@ -21,9 +21,9 @@ use cumulus_primitives_parachain_inherent::ParachainInherentData; use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder; use fc_rpc::{ - pending::ConsensusDataProvider, Debug, DebugApiServer, Eth, EthApiServer, - EthBlockDataCacheTask, EthFilter, EthFilterApiServer, EthPubSub, EthPubSubApiServer, Net, - NetApiServer, OverrideHandle, Web3, Web3ApiServer, + pending::ConsensusDataProvider, Eth, EthApiServer, EthBlockDataCacheTask, EthFilter, + EthFilterApiServer, EthPubSub, EthPubSubApiServer, Net, NetApiServer, OverrideHandle, Web3, + Web3ApiServer, }; use fc_rpc_core::types::{FeeHistoryCache, FilterPool}; use jsonrpsee::RpcModule; @@ -405,15 +405,5 @@ where .into_rpc(), )?; - io.merge( - Debug::new( - client.clone(), - frontier_backend, - overrides, - block_data_cache, - ) - .into_rpc(), - )?; - Ok(io) } From 2bc3b6759a0fa1f562166cfd10c4367dfd375528 Mon Sep 17 00:00:00 2001 From: Dino Pacandi Date: Wed, 27 Mar 2024 17:20:48 +0100 Subject: [PATCH 12/19] Linting --- vendor/rpc/trace/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vendor/rpc/trace/src/lib.rs b/vendor/rpc/trace/src/lib.rs index 265d13cb3b..e754969f8a 100644 --- a/vendor/rpc/trace/src/lib.rs +++ b/vendor/rpc/trace/src/lib.rs @@ -66,7 +66,7 @@ pub struct Trace { impl Clone for Trace { fn clone(&self) -> Self { Self { - _phantom: PhantomData::default(), + _phantom: PhantomData, client: Arc::clone(&self.client), requester: self.requester.clone(), max_count: self.max_count, @@ -87,7 +87,7 @@ where client, requester, max_count, - _phantom: PhantomData::default(), + _phantom: PhantomData, } } From a011505fda9d4a0522f9412ac37073628909c5be Mon Sep 17 00:00:00 2001 From: Dino Pacandi Date: Thu, 28 Mar 2024 14:41:52 +0100 Subject: [PATCH 13/19] Cleanup --- bin/collator/src/rpc.rs | 6 +++--- runtime/astar/src/lib.rs | 1 - runtime/shibuya/src/lib.rs | 1 - runtime/shiden/src/lib.rs | 1 - 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/bin/collator/src/rpc.rs b/bin/collator/src/rpc.rs index b3d98d6f27..99d47e0189 100644 --- a/bin/collator/src/rpc.rs +++ b/bin/collator/src/rpc.rs @@ -379,12 +379,12 @@ where io.merge( EthFilter::new( client.clone(), - frontier_backend.clone(), + frontier_backend, graph.clone(), filter_pool, max_stored_filters, max_past_logs, - block_data_cache.clone(), + block_data_cache, ) .into_rpc(), )?; @@ -399,7 +399,7 @@ where client.clone(), sync, subscription_task_executor, - overrides.clone(), + overrides, pubsub_notification_sinks, ) .into_rpc(), diff --git a/runtime/astar/src/lib.rs b/runtime/astar/src/lib.rs index 9f489ad246..843cff3790 100644 --- a/runtime/astar/src/lib.rs +++ b/runtime/astar/src/lib.rs @@ -1122,7 +1122,6 @@ parameter_types! { /// /// Once done, migrations should be removed from the tuple. pub type Migrations = ( - // TODO: mark with version number frame_support::migrations::RemovePallet< DappStakingMigrationName, ::DbWeight, diff --git a/runtime/shibuya/src/lib.rs b/runtime/shibuya/src/lib.rs index 96d556a66b..71e5d6030f 100644 --- a/runtime/shibuya/src/lib.rs +++ b/runtime/shibuya/src/lib.rs @@ -1226,7 +1226,6 @@ use frame_support::migrations::RemovePallet; /// /// Once done, migrations should be removed from the tuple. pub type Migrations = ( - // TODO: mark with version number RemovePallet::DbWeight>, RemovePallet::DbWeight>, RemovePallet::DbWeight>, diff --git a/runtime/shiden/src/lib.rs b/runtime/shiden/src/lib.rs index dde212fb25..3bb789e666 100644 --- a/runtime/shiden/src/lib.rs +++ b/runtime/shiden/src/lib.rs @@ -1124,7 +1124,6 @@ parameter_types! { /// /// Once done, migrations should be removed from the tuple. pub type Migrations = ( - // TODO: mark with version number frame_support::migrations::RemovePallet< DappStakingMigrationName, ::DbWeight, From d1d3cc78eb3319a20d96d1f6252a62a8403aca3f Mon Sep 17 00:00:00 2001 From: Dino Pacandi Date: Fri, 29 Mar 2024 11:24:01 +0100 Subject: [PATCH 14/19] Coverage CI change --- .github/workflows/coverage.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yaml b/.github/workflows/coverage.yaml index 3251f3968c..637da7a6f8 100644 --- a/.github/workflows/coverage.yaml +++ b/.github/workflows/coverage.yaml @@ -43,11 +43,12 @@ jobs: - name: Install deps run: sudo apt -y install protobuf-compiler + # return astar-collator to the exclusion list, -e astar-collator, after uplifting past v1.3.0 - name: Run all tests & Generate report uses: actions-rs/tarpaulin@v0.1 with: version: 0.22.0 - args: '--workspace --features try-runtime,runtime-benchmarks -e astar-collator xcm-tools local-runtime shibuya-runtime shiden-runtime astar-runtime integration-tests --exclude-files vendor/* bin/* runtime/* tests/* **/mock.rs **/weights.rs precompiles/utils/*' + args: '--workspace --features try-runtime,runtime-benchmarks -e xcm-tools local-runtime shibuya-runtime shiden-runtime astar-runtime integration-tests --exclude-files vendor/* bin/* runtime/* tests/* **/mock.rs **/weights.rs precompiles/utils/*' out-type: Xml - name: Code Coverage Summary Report From f2b8269e45073edd598d7a9019d694073baa3cf6 Mon Sep 17 00:00:00 2001 From: Dino Pacandi Date: Fri, 29 Mar 2024 16:06:49 +0100 Subject: [PATCH 15/19] Fixes --- .github/workflows/coverage.yaml | 3 +-- precompiles/utils/macro/Cargo.toml | 9 +++++++++ precompiles/xcm/Cargo.toml | 1 + tests/integration/Cargo.toml | 16 +++++++++++----- vendor/evm-tracing/Cargo.toml | 6 +++--- vendor/primitives/txpool/Cargo.toml | 1 + vendor/rpc-core/types/Cargo.toml | 4 ++-- 7 files changed, 28 insertions(+), 12 deletions(-) diff --git a/.github/workflows/coverage.yaml b/.github/workflows/coverage.yaml index 637da7a6f8..3251f3968c 100644 --- a/.github/workflows/coverage.yaml +++ b/.github/workflows/coverage.yaml @@ -43,12 +43,11 @@ jobs: - name: Install deps run: sudo apt -y install protobuf-compiler - # return astar-collator to the exclusion list, -e astar-collator, after uplifting past v1.3.0 - name: Run all tests & Generate report uses: actions-rs/tarpaulin@v0.1 with: version: 0.22.0 - args: '--workspace --features try-runtime,runtime-benchmarks -e xcm-tools local-runtime shibuya-runtime shiden-runtime astar-runtime integration-tests --exclude-files vendor/* bin/* runtime/* tests/* **/mock.rs **/weights.rs precompiles/utils/*' + args: '--workspace --features try-runtime,runtime-benchmarks -e astar-collator xcm-tools local-runtime shibuya-runtime shiden-runtime astar-runtime integration-tests --exclude-files vendor/* bin/* runtime/* tests/* **/mock.rs **/weights.rs precompiles/utils/*' out-type: Xml - name: Code Coverage Summary Report diff --git a/precompiles/utils/macro/Cargo.toml b/precompiles/utils/macro/Cargo.toml index d55db0c220..c13219412a 100644 --- a/precompiles/utils/macro/Cargo.toml +++ b/precompiles/utils/macro/Cargo.toml @@ -31,3 +31,12 @@ fp-evm = { workspace = true } frame-support = { workspace = true } sp-core-hashing = { workspace = true } sp-std = { workspace = true } + +[features] +default = ["std"] +std = [ + "fp-evm/std", + "frame-support/std", + "sp-core-hashing/std", + "sp-std/std", +] diff --git a/precompiles/xcm/Cargo.toml b/precompiles/xcm/Cargo.toml index b2d71dd70c..a131fe9c52 100644 --- a/precompiles/xcm/Cargo.toml +++ b/precompiles/xcm/Cargo.toml @@ -70,5 +70,6 @@ std = [ "orml-xtokens/std", "orml-xcm-support/std", "orml-traits/std", + "astar-primitives/std", ] runtime-benchmarks = ["pallet-xcm/runtime-benchmarks", "pallet-assets/runtime-benchmarks", "xcm-builder/runtime-benchmarks"] diff --git a/tests/integration/Cargo.toml b/tests/integration/Cargo.toml index ad9f920a2d..e90ec9c87b 100644 --- a/tests/integration/Cargo.toml +++ b/tests/integration/Cargo.toml @@ -44,14 +44,20 @@ precompile-utils = { workspace = true } unified-accounts-chain-extension-types = { workspace = true } astar-primitives = { workspace = true } -astar-runtime = { workspace = true, features = ["std"], optional = true } -astar-test-utils = { workspace = true, features = ["std"] } -shibuya-runtime = { workspace = true, features = ["std"], optional = true } -shiden-runtime = { workspace = true, features = ["std"], optional = true } +astar-runtime = { workspace = true, optional = true } +astar-test-utils = { workspace = true } +shibuya-runtime = { workspace = true, optional = true } +shiden-runtime = { workspace = true, optional = true } [features] default = ["std"] -std = [] +std = [ + "astar-runtime/std", + "shibuya-runtime/std", + "shiden-runtime/std", + "astar-primitives/std", + "astar-test-utils/std", +] shibuya = ["shibuya-runtime"] shiden = ["shiden-runtime"] astar = ["astar-runtime"] diff --git a/vendor/evm-tracing/Cargo.toml b/vendor/evm-tracing/Cargo.toml index 557126f6f2..f11ca8c712 100644 --- a/vendor/evm-tracing/Cargo.toml +++ b/vendor/evm-tracing/Cargo.toml @@ -10,13 +10,13 @@ version = "0.1.0" [dependencies] ethereum-types = { workspace = true, features = ["std"] } hex = { workspace = true, features = ["serde"] } -serde = { workspace = true } +serde = { workspace = true, features = ["std"] } serde_json = { workspace = true } # Moonbeam evm-tracing-events = { workspace = true, features = ["std"] } -moonbeam-rpc-primitives-debug = { workspace = true } +moonbeam-rpc-primitives-debug = { workspace = true, features = ["std"] } # Substrate -parity-scale-codec = { workspace = true } +parity-scale-codec = { workspace = true, features = ["std"] } sp-std = { workspace = true, features = ["std"] } diff --git a/vendor/primitives/txpool/Cargo.toml b/vendor/primitives/txpool/Cargo.toml index e980333b9b..9b4dcb0290 100644 --- a/vendor/primitives/txpool/Cargo.toml +++ b/vendor/primitives/txpool/Cargo.toml @@ -27,4 +27,5 @@ std = [ "sp-io/std", "sp-runtime/std", "sp-std/std", + "parity-scale-codec/std", ] diff --git a/vendor/rpc-core/types/Cargo.toml b/vendor/rpc-core/types/Cargo.toml index bc561cde28..eaae4263f2 100644 --- a/vendor/rpc-core/types/Cargo.toml +++ b/vendor/rpc-core/types/Cargo.toml @@ -8,6 +8,6 @@ repository = "https://github.com/PureStake/moonbeam/" version = "0.1.0" [dependencies] -ethereum-types = { workspace = true, features = ["std"] } -serde = { workspace = true } +ethereum-types = { workspace = true, features = ["std", "serialize"] } +serde = { workspace = true, features = ["std"] } serde_json = { workspace = true } From 0e57cc6217ab8f41ee0f677bab22e19c2797ea9d Mon Sep 17 00:00:00 2001 From: Dino Pacandi Date: Thu, 4 Apr 2024 15:38:18 +0200 Subject: [PATCH 16/19] Post-merge fixes --- Cargo.lock | 13 +++++-------- bin/collator/src/parachain/chain_spec/shibuya.rs | 5 +++-- pallets/price-aggregator/src/lib.rs | 10 +++++----- pallets/price-aggregator/src/mock.rs | 1 + runtime/astar/src/lib.rs | 4 ++++ runtime/shibuya/Cargo.toml | 1 - runtime/shibuya/src/lib.rs | 5 ----- runtime/shiden/src/lib.rs | 4 ++++ runtime/shiden/src/xcm_config.rs | 8 ++++---- tests/xcm-simulator/src/mocks/parachain.rs | 6 +++--- 10 files changed, 29 insertions(+), 28 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b07df76392..850064c940 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7852,7 +7852,10 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "option-ext" version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" +[[package]] name = "oracle-benchmarks" version = "0.1.0" dependencies = [ @@ -7871,12 +7874,6 @@ dependencies = [ "sp-std", ] -[[package]] -name = "orchestra" -version = "0.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" - [[package]] name = "orchestra" version = "0.3.5" @@ -7921,8 +7918,8 @@ dependencies = [ [[package]] name = "orml-oracle" -version = "0.4.1-dev" -source = "git+https://github.com/open-web3-stack/open-runtime-module-library?branch=polkadot-v1.1.0#b3694e631df7f1ca16b1973122937753fcdee9d4" +version = "0.6.7" +source = "git+https://github.com/AstarNetwork/open-runtime-module-library?branch=polkadot-v1.3.0#18fe59659a5f3ce1b2432e3d273f559963b73517" dependencies = [ "frame-support", "frame-system", diff --git a/bin/collator/src/parachain/chain_spec/shibuya.rs b/bin/collator/src/parachain/chain_spec/shibuya.rs index d895bc76d1..c870d27539 100644 --- a/bin/collator/src/parachain/chain_spec/shibuya.rs +++ b/bin/collator/src/parachain/chain_spec/shibuya.rs @@ -23,8 +23,9 @@ use sc_service::ChainType; use shibuya_runtime::{ wasm_binary_unwrap, AccountId, AuraConfig, AuraId, Balance, BalancesConfig, CollatorSelectionConfig, DappStakingConfig, EVMChainIdConfig, EVMConfig, InflationConfig, - InflationParameters, ParachainInfoConfig, Precompiles, RuntimeGenesisConfig, SessionConfig, - SessionKeys, Signature, SudoConfig, SystemConfig, TierThreshold, VestingConfig, SBY, + InflationParameters, OracleMembershipConfig, ParachainInfoConfig, Precompiles, + PriceAggregatorConfig, RuntimeGenesisConfig, SessionConfig, SessionKeys, Signature, SudoConfig, + SystemConfig, TierThreshold, VestingConfig, SBY, }; use sp_core::{sr25519, Pair, Public}; diff --git a/pallets/price-aggregator/src/lib.rs b/pallets/price-aggregator/src/lib.rs index 014792aff5..7fd507cbe5 100644 --- a/pallets/price-aggregator/src/lib.rs +++ b/pallets/price-aggregator/src/lib.rs @@ -455,11 +455,11 @@ pub mod pallet { Ok(()) => {} Err(_) => { log::error!( - target: LOG_TARGET, - "Failed to push native currency value into the ongoing block due to exceeded capacity. \ - Value was submitted by: {:?}", - who - ); + target: LOG_TARGET, + "Failed to push native currency value into the ongoing block due to exceeded capacity. \ + Value was submitted by: {:?}", + who + ); } }); } diff --git a/pallets/price-aggregator/src/mock.rs b/pallets/price-aggregator/src/mock.rs index dd0661b031..50f606292b 100644 --- a/pallets/price-aggregator/src/mock.rs +++ b/pallets/price-aggregator/src/mock.rs @@ -81,6 +81,7 @@ impl pallet_balances::Config for Test { type WeightInfo = (); type RuntimeHoldReason = RuntimeHoldReason; type FreezeIdentifier = (); + type RuntimeFreezeReason = RuntimeFreezeReason; type MaxHolds = ConstU32<0>; type MaxFreezes = ConstU32<0>; } diff --git a/runtime/astar/src/lib.rs b/runtime/astar/src/lib.rs index 3f41f3c4a4..526b7f39a2 100644 --- a/runtime/astar/src/lib.rs +++ b/runtime/astar/src/lib.rs @@ -1749,6 +1749,8 @@ impl_runtime_apis! { impl pallet_xcm_benchmarks::Config for Runtime { type XcmConfig = xcm_config::XcmConfig; type AccountIdConverter = xcm_config::LocationToAccountId; + type DeliveryHelper = (); + // destination location to be used in benchmarks fn valid_destination() -> Result { Ok(MultiLocation::parent()) @@ -1760,6 +1762,8 @@ impl_runtime_apis! { impl pallet_xcm_benchmarks::generic::Config for Runtime { type RuntimeCall = RuntimeCall; + type TransactAsset = Balances; + fn worst_case_response() -> (u64, Response) { (0u64, Response::Version(Default::default())) } diff --git a/runtime/shibuya/Cargo.toml b/runtime/shibuya/Cargo.toml index 57d84e33af..69a115bfb6 100644 --- a/runtime/shibuya/Cargo.toml +++ b/runtime/shibuya/Cargo.toml @@ -255,7 +255,6 @@ std = [ runtime-benchmarks = [ "astar-xcm-benchmarks/runtime-benchmarks", "oracle-benchmarks/runtime-benchmarks", - "pallet-dapp-staking-migration/runtime-benchmarks", "pallet-xcm-benchmarks/runtime-benchmarks", "frame-benchmarking", "frame-support/runtime-benchmarks", diff --git a/runtime/shibuya/src/lib.rs b/runtime/shibuya/src/lib.rs index 0aad8dd776..3d8cbb4a78 100644 --- a/runtime/shibuya/src/lib.rs +++ b/runtime/shibuya/src/lib.rs @@ -1204,11 +1204,6 @@ impl oracle_benchmarks::Config for Runtime { type AddMember = AddMemberBenchmark; } -impl pallet_dapp_staking_migration::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type WeightInfo = pallet_dapp_staking_migration::weights::SubstrateWeight; -} - construct_runtime!( pub struct Runtime { diff --git a/runtime/shiden/src/lib.rs b/runtime/shiden/src/lib.rs index 0322570f37..1843468f77 100644 --- a/runtime/shiden/src/lib.rs +++ b/runtime/shiden/src/lib.rs @@ -1785,6 +1785,8 @@ impl_runtime_apis! { impl pallet_xcm_benchmarks::Config for Runtime { type XcmConfig = xcm_config::XcmConfig; type AccountIdConverter = xcm_config::LocationToAccountId; + type DeliveryHelper = (); + // destination location to be used in benchmarks fn valid_destination() -> Result { Ok(MultiLocation::parent()) @@ -1796,6 +1798,8 @@ impl_runtime_apis! { impl pallet_xcm_benchmarks::generic::Config for Runtime { type RuntimeCall = RuntimeCall; + type TransactAsset = Balances; + fn worst_case_response() -> (u64, Response) { (0u64, Response::Version(Default::default())) } diff --git a/runtime/shiden/src/xcm_config.rs b/runtime/shiden/src/xcm_config.rs index f6896c9ae7..c4e53cf54f 100644 --- a/runtime/shiden/src/xcm_config.rs +++ b/runtime/shiden/src/xcm_config.rs @@ -37,10 +37,10 @@ use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowUnpaidExecutionFrom, ConvertedConcreteId, CurrencyAdapter, DescribeAllTerminal, DescribeFamily, EnsureXcmOrigin, - FixedWeightBounds, FungiblesAdapter, HashedDescription, IsConcrete, NoChecking, - ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, - SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, - SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, WeightInfoBounds, WithComputedOrigin, + FungiblesAdapter, HashedDescription, IsConcrete, NoChecking, ParentAsSuperuser, ParentIsPreset, + RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, + SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, + UsingComponents, WeightInfoBounds, WithComputedOrigin, }; use xcm_executor::{ traits::{JustTry, WithOriginFilter}, diff --git a/tests/xcm-simulator/src/mocks/parachain.rs b/tests/xcm-simulator/src/mocks/parachain.rs index 49c50aaa04..9e3b1f76e7 100644 --- a/tests/xcm-simulator/src/mocks/parachain.rs +++ b/tests/xcm-simulator/src/mocks/parachain.rs @@ -40,7 +40,7 @@ use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use sp_core::H256; use sp_runtime::{ traits::{AccountIdConversion, Convert, Get, IdentityLookup, MaybeEquivalence}, - AccountId32, FixedU64, Perbill, RuntimeDebug, + AccountId32, FixedU128, Perbill, RuntimeDebug, }; use sp_std::marker::PhantomData; use sp_std::prelude::*; @@ -685,8 +685,8 @@ impl StakingRewardHandler for DummyStakingRewardHandler { pub struct DummyPriceProvider; impl PriceProvider for DummyPriceProvider { - fn average_price() -> FixedU64 { - FixedU64::from_rational(1, 10) + fn average_price() -> FixedU128 { + FixedU128::from_rational(1, 10) } } From bce3a5c64cafc9dc4ca18d08fbb4991656513ef6 Mon Sep 17 00:00:00 2001 From: Dino Pacandi Date: Mon, 15 Apr 2024 17:42:30 +0900 Subject: [PATCH 17/19] Comments --- Cargo.lock | 48 +++++++++++++-------------- pallets/ethereum-checked/src/tests.rs | 12 ++----- 2 files changed, 26 insertions(+), 34 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 850064c940..a17726640b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4179,7 +4179,7 @@ dependencies = [ [[package]] name = "fc-api" version = "1.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#198d640a72a957ca94cdbee3c4416598dd45ec6d" dependencies = [ "async-trait", "fp-storage", @@ -4191,7 +4191,7 @@ dependencies = [ [[package]] name = "fc-consensus" version = "2.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#198d640a72a957ca94cdbee3c4416598dd45ec6d" dependencies = [ "async-trait", "fp-consensus", @@ -4207,7 +4207,7 @@ dependencies = [ [[package]] name = "fc-db" version = "2.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#198d640a72a957ca94cdbee3c4416598dd45ec6d" dependencies = [ "async-trait", "fc-api", @@ -4228,7 +4228,7 @@ dependencies = [ [[package]] name = "fc-mapping-sync" version = "2.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#198d640a72a957ca94cdbee3c4416598dd45ec6d" dependencies = [ "fc-db", "fc-storage", @@ -4249,7 +4249,7 @@ dependencies = [ [[package]] name = "fc-rpc" version = "2.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#198d640a72a957ca94cdbee3c4416598dd45ec6d" dependencies = [ "ethereum", "ethereum-types", @@ -4303,7 +4303,7 @@ dependencies = [ [[package]] name = "fc-rpc-core" version = "1.1.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#198d640a72a957ca94cdbee3c4416598dd45ec6d" dependencies = [ "ethereum", "ethereum-types", @@ -4316,7 +4316,7 @@ dependencies = [ [[package]] name = "fc-storage" version = "1.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#198d640a72a957ca94cdbee3c4416598dd45ec6d" dependencies = [ "ethereum", "ethereum-types", @@ -4481,7 +4481,7 @@ dependencies = [ [[package]] name = "fp-account" version = "1.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#198d640a72a957ca94cdbee3c4416598dd45ec6d" dependencies = [ "hex", "impl-serde", @@ -4500,7 +4500,7 @@ dependencies = [ [[package]] name = "fp-consensus" version = "2.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#198d640a72a957ca94cdbee3c4416598dd45ec6d" dependencies = [ "ethereum", "parity-scale-codec", @@ -4512,7 +4512,7 @@ dependencies = [ [[package]] name = "fp-ethereum" version = "1.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#198d640a72a957ca94cdbee3c4416598dd45ec6d" dependencies = [ "ethereum", "ethereum-types", @@ -4525,7 +4525,7 @@ dependencies = [ [[package]] name = "fp-evm" version = "3.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#198d640a72a957ca94cdbee3c4416598dd45ec6d" dependencies = [ "evm", "frame-support", @@ -4541,7 +4541,7 @@ dependencies = [ [[package]] name = "fp-rpc" version = "3.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#198d640a72a957ca94cdbee3c4416598dd45ec6d" dependencies = [ "ethereum", "ethereum-types", @@ -4558,7 +4558,7 @@ dependencies = [ [[package]] name = "fp-self-contained" version = "1.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#198d640a72a957ca94cdbee3c4416598dd45ec6d" dependencies = [ "frame-support", "parity-scale-codec", @@ -4570,7 +4570,7 @@ dependencies = [ [[package]] name = "fp-storage" version = "2.0.0" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#198d640a72a957ca94cdbee3c4416598dd45ec6d" dependencies = [ "parity-scale-codec", "serde", @@ -8564,7 +8564,7 @@ dependencies = [ [[package]] name = "pallet-ethereum" version = "4.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#198d640a72a957ca94cdbee3c4416598dd45ec6d" dependencies = [ "ethereum", "ethereum-types", @@ -8612,7 +8612,7 @@ dependencies = [ [[package]] name = "pallet-evm" version = "6.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#198d640a72a957ca94cdbee3c4416598dd45ec6d" dependencies = [ "environmental", "evm", @@ -8638,7 +8638,7 @@ dependencies = [ [[package]] name = "pallet-evm-chain-id" version = "1.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#198d640a72a957ca94cdbee3c4416598dd45ec6d" dependencies = [ "frame-support", "frame-system", @@ -8675,7 +8675,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-blake2" version = "2.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#198d640a72a957ca94cdbee3c4416598dd45ec6d" dependencies = [ "fp-evm", ] @@ -8683,7 +8683,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-bn128" version = "2.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#198d640a72a957ca94cdbee3c4416598dd45ec6d" dependencies = [ "fp-evm", "sp-core", @@ -8721,7 +8721,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-dispatch" version = "2.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#198d640a72a957ca94cdbee3c4416598dd45ec6d" dependencies = [ "fp-evm", "frame-support", @@ -8759,7 +8759,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-ed25519" version = "2.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#198d640a72a957ca94cdbee3c4416598dd45ec6d" dependencies = [ "ed25519-dalek", "fp-evm", @@ -8768,7 +8768,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-modexp" version = "2.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#198d640a72a957ca94cdbee3c4416598dd45ec6d" dependencies = [ "fp-evm", "num", @@ -8777,7 +8777,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-sha3fips" version = "2.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#198d640a72a957ca94cdbee3c4416598dd45ec6d" dependencies = [ "fp-evm", "tiny-keccak", @@ -8786,7 +8786,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-simple" version = "2.0.0-dev" -source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#73d814d42ed30e9b896adeff1cb2429bd465e82e" +source = "git+https://github.com/AstarNetwork/frontier?branch=polkadot-v1.3.0#198d640a72a957ca94cdbee3c4416598dd45ec6d" dependencies = [ "fp-evm", "ripemd", diff --git a/pallets/ethereum-checked/src/tests.rs b/pallets/ethereum-checked/src/tests.rs index 620d80772e..e037265883 100644 --- a/pallets/ethereum-checked/src/tests.rs +++ b/pallets/ethereum-checked/src/tests.rs @@ -32,14 +32,6 @@ fn bounded_input(data: &'static str) -> EthereumTxInput { .expect("input too large") } -// A hacky way to get around crate pub visibility of the storage item. -#[frame_support::storage_alias] -type Pending = StorageValue< - pallet_ethereum::Pallet, - Vec<(Transaction, TransactionStatus, Receipt)>, - ValueQuery, ->; - #[test] fn transact_works() { ExtBuilder::default().build().execute_with(|| { @@ -61,7 +53,7 @@ fn transact_works() { RawOrigin::XcmEthereumTx(ALICE).into(), store_tx )); - let pending = Pending::::get(); + let pending = pallet_ethereum::Pending::::get(); assert_eq!(pending.len(), 2); match pending[0] { @@ -152,7 +144,7 @@ fn no_hash_collision() { )); } - let mut tx_hashes = Pending::::get() + let mut tx_hashes = pallet_ethereum::Pending::::get() .iter() .map(|(tx, _, _)| tx.hash()) .collect::>(); From 616af3febbd269ce969a129e5b1f49ba474f947e Mon Sep 17 00:00:00 2001 From: Dino Pacandi Date: Mon, 15 Apr 2024 17:45:59 +0900 Subject: [PATCH 18/19] Remove dead code --- primitives/src/lib.rs | 3 - primitives/src/migrations/contract_v12.rs | 379 ------------------ primitives/src/migrations/contract_v12_fix.rs | 161 -------- primitives/src/migrations/contract_v14.rs | 284 ------------- primitives/src/migrations/mod.rs | 66 --- 5 files changed, 893 deletions(-) delete mode 100644 primitives/src/migrations/contract_v12.rs delete mode 100644 primitives/src/migrations/contract_v12_fix.rs delete mode 100644 primitives/src/migrations/contract_v14.rs delete mode 100644 primitives/src/migrations/mod.rs diff --git a/primitives/src/lib.rs b/primitives/src/lib.rs index eefc28fd5c..7f7ed3302e 100644 --- a/primitives/src/lib.rs +++ b/primitives/src/lib.rs @@ -44,9 +44,6 @@ pub mod testing; /// Oracle & price primitives. pub mod oracle; -/// Common Migrations -pub mod migrations; - /// Benchmark primitives #[cfg(feature = "runtime-benchmarks")] pub mod benchmarks; diff --git a/primitives/src/migrations/contract_v12.rs b/primitives/src/migrations/contract_v12.rs deleted file mode 100644 index 0cbb866fa5..0000000000 --- a/primitives/src/migrations/contract_v12.rs +++ /dev/null @@ -1,379 +0,0 @@ -// This file is part of Astar. - -// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later - -// Astar 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. - -// Astar 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 Astar. If not, see . - -//! Move `OwnerInfo` to `CodeInfo`, add `determinism` field to the latter, clear `CodeStorage` and -//! repay deposits. - -use frame_support::{ - pallet_prelude::*, - storage_alias, - traits::{fungible::Inspect, ReservableCurrency}, - DefaultNoBound, Identity, -}; -use pallet_contracts::{ - migration::{IsFinished, MigrationStep}, - weights::WeightInfo, - Config, Determinism, Pallet, -}; -use parity_scale_codec::{Decode, Encode}; -use scale_info::prelude::format; -use sp_core::hexdisplay::HexDisplay; -#[cfg(feature = "try-runtime")] -use sp_runtime::TryRuntimeError; -use sp_runtime::{traits::Zero, FixedPointNumber, FixedU128, Saturating}; -use sp_std::prelude::*; - -const LOG_TARGET: &str = "runtime::contracts"; - -pub type AccountIdOf = ::AccountId; -type CodeHash = ::Hash; -type BalanceOf = - <::Currency as Inspect<::AccountId>>::Balance; - -mod old { - use super::*; - - pub type BalanceOf = ::AccountId, - >>::Balance; - - #[derive(Encode, Decode, scale_info::TypeInfo, MaxEncodedLen)] - #[codec(mel_bound())] - #[scale_info(skip_type_params(T, OldCurrency))] - pub struct OwnerInfo - where - OldCurrency: ReservableCurrency<::AccountId>, - { - pub owner: AccountIdOf, - #[codec(compact)] - pub deposit: BalanceOf, - #[codec(compact)] - pub refcount: u64, - } - - #[derive(Encode, Decode, scale_info::TypeInfo)] - #[codec(mel_bound())] - #[scale_info(skip_type_params(T))] - pub struct PrefabWasmModule { - #[codec(compact)] - pub instruction_weights_version: u32, - #[codec(compact)] - pub initial: u32, - #[codec(compact)] - pub maximum: u32, - pub code: Vec, - pub determinism: Determinism, - } - - #[storage_alias] - pub type OwnerInfoOf = - StorageMap, Identity, CodeHash, OwnerInfo>; - - #[storage_alias] - pub type CodeStorage = - StorageMap, Identity, CodeHash, PrefabWasmModule>; -} - -#[derive(Encode, Decode, scale_info::TypeInfo, MaxEncodedLen)] -#[codec(mel_bound())] -#[scale_info(skip_type_params(T, OldCurrency))] -pub struct CodeInfo -where - OldCurrency: ReservableCurrency<::AccountId>, -{ - owner: AccountIdOf, - #[codec(compact)] - deposit: old::BalanceOf, - #[codec(compact)] - refcount: u64, - determinism: Determinism, - code_len: u32, -} - -#[storage_alias] -pub type CodeInfoOf = - StorageMap, Identity, CodeHash, CodeInfo>; - -#[storage_alias] -pub type PristineCode = StorageMap, Identity, CodeHash, Vec>; - -#[cfg(feature = "runtime-benchmarks")] -pub fn store_old_dummy_code(len: usize, account: T::AccountId) -where - OldCurrency: ReservableCurrency<::AccountId> + 'static, -{ - use sp_runtime::traits::Hash; - - let code = vec![42u8; len]; - let hash = T::Hashing::hash(&code); - PristineCode::::insert(hash, code.clone()); - - let module = old::PrefabWasmModule { - instruction_weights_version: Default::default(), - initial: Default::default(), - maximum: Default::default(), - code, - determinism: Determinism::Enforced, - }; - old::CodeStorage::::insert(hash, module); - - let info = old::OwnerInfo { - owner: account, - deposit: u32::MAX.into(), - refcount: u64::MAX, - }; - old::OwnerInfoOf::::insert(hash, info); -} - -#[derive(Encode, Decode, MaxEncodedLen, DefaultNoBound)] -pub struct Migration -where - OldCurrency: ReservableCurrency<::AccountId>, - OldCurrency::Balance: From>, -{ - last_code_hash: Option>, - _phantom: PhantomData, -} - -impl MigrationStep for Migration -where - OldCurrency: ReservableCurrency<::AccountId> + 'static, - OldCurrency::Balance: From>, -{ - const VERSION: u16 = 12; - - fn max_step_weight() -> Weight { - T::WeightInfo::v12_migration_step(T::MaxCodeLen::get()) - } - - fn step(&mut self) -> (IsFinished, Weight) { - let mut iter = if let Some(last_key) = self.last_code_hash.take() { - old::OwnerInfoOf::::iter_from( - old::OwnerInfoOf::::hashed_key_for(last_key), - ) - } else { - old::OwnerInfoOf::::iter() - }; - if let Some((hash, old_info)) = iter.next() { - log::debug!( - target: LOG_TARGET, - "Migrating OwnerInfo for code_hash {:?}", - hash - ); - - let module = old::CodeStorage::::take(hash) - .expect(format!("No PrefabWasmModule found for code_hash: {:?}", hash).as_str()); - - let code_len = module.code.len(); - // We print this to measure the impact of the migration. - // Storage removed: deleted PrefabWasmModule's encoded len. - // Storage added: determinism field encoded len (as all other CodeInfo fields are the - // same as in the deleted OwnerInfo). - log::debug!( - target: LOG_TARGET, - "Storage removed: 1 item, {} bytes", - &code_len, - ); - - // Storage usage prices could change over time, and accounts who uploaded their - // contracts code before the storage deposits where introduced, had not been ever - // charged with any deposit for that (see migration v6). - // - // This is why deposit to be refunded here is calculated as follows: - // - // 1. Calculate the deposit amount for storage before the migration, given current - // prices. - // 2. Given current reserved deposit amount, calculate the correction factor. - // 3. Calculate the deposit amount for storage after the migration, given current - // prices. - // 4. Calculate real deposit amount to be reserved after the migration. - let price_per_byte = T::DepositPerByte::get(); - let price_per_item = T::DepositPerItem::get(); - let bytes_before = module - .encoded_size() - .saturating_add(code_len) - .saturating_add(old::OwnerInfo::::max_encoded_len()) - as u32; - let items_before = 3u32; - let deposit_expected_before = price_per_byte - .saturating_mul(bytes_before.into()) - .saturating_add(price_per_item.saturating_mul(items_before.into())); - let ratio = FixedU128::checked_from_rational(old_info.deposit, deposit_expected_before) - .unwrap_or_default() - .min(FixedU128::from_u32(1)); - let bytes_after = - code_len.saturating_add(CodeInfo::::max_encoded_len()) as u32; - let items_after = 2u32; - let deposit_expected_after = price_per_byte - .saturating_mul(bytes_after.into()) - .saturating_add(price_per_item.saturating_mul(items_after.into())); - let deposit = ratio.saturating_mul_int(deposit_expected_after); - - let info = CodeInfo:: { - determinism: module.determinism, - owner: old_info.owner, - deposit: deposit.into(), - refcount: old_info.refcount, - code_len: code_len as u32, - }; - - let amount = old_info.deposit.saturating_sub(info.deposit); - if !amount.is_zero() { - OldCurrency::unreserve(&info.owner, amount); - log::debug!( - target: LOG_TARGET, - "Deposit refunded: {:?} Balance, to: {:?}", - &amount, - HexDisplay::from(&info.owner.encode()) - ); - } else { - log::warn!( - target: LOG_TARGET, - "new deposit: {:?} >= old deposit: {:?}", - &info.deposit, - &old_info.deposit - ); - } - CodeInfoOf::::insert(hash, info); - - self.last_code_hash = Some(hash); - - ( - IsFinished::No, - T::WeightInfo::v12_migration_step(code_len as u32), - ) - } else { - log::debug!(target: LOG_TARGET, "No more OwnerInfo to migrate"); - (IsFinished::Yes, T::WeightInfo::v12_migration_step(0)) - } - } - - #[cfg(feature = "try-runtime")] - fn pre_upgrade_step() -> Result, TryRuntimeError> { - let len = 100; - log::debug!(target: LOG_TARGET, "Taking sample of {} OwnerInfo(s)", len); - let sample: Vec<_> = old::OwnerInfoOf::::iter() - .take(len) - .map(|(k, v)| { - let module = old::CodeStorage::::get(k) - .expect("No PrefabWasmModule found for code_hash: {:?}"); - let info: CodeInfo = CodeInfo { - determinism: module.determinism, - deposit: v.deposit, - refcount: v.refcount, - owner: v.owner, - code_len: module.code.len() as u32, - }; - (k, info) - }) - .collect(); - - let storage: u32 = old::CodeStorage::::iter() - .map(|(_k, v)| v.encoded_size() as u32) - .sum(); - let mut deposit: old::BalanceOf = Default::default(); - old::OwnerInfoOf::::iter().for_each(|(_k, v)| deposit += v.deposit); - - Ok((sample, deposit, storage).encode()) - } - - #[cfg(feature = "try-runtime")] - fn post_upgrade_step(state: Vec) -> Result<(), TryRuntimeError> { - let state = <( - Vec<(CodeHash, CodeInfo)>, - old::BalanceOf, - u32, - ) as Decode>::decode(&mut &state[..]) - .unwrap(); - - log::debug!( - target: LOG_TARGET, - "Validating state of {} Codeinfo(s)", - state.0.len() - ); - for (hash, old) in state.0 { - let info = CodeInfoOf::::get(&hash) - .expect(format!("CodeInfo for code_hash {:?} not found!", hash).as_str()); - ensure!(info.determinism == old.determinism, "invalid determinism"); - ensure!(info.owner == old.owner, "invalid owner"); - ensure!(info.refcount == old.refcount, "invalid refcount"); - } - - if let Some((k, _)) = old::CodeStorage::::iter().next() { - log::warn!( - target: LOG_TARGET, - "CodeStorage is still NOT empty, found code_hash: {:?}", - k - ); - } else { - log::debug!(target: LOG_TARGET, "CodeStorage is empty."); - } - if let Some((k, _)) = old::OwnerInfoOf::::iter().next() { - log::warn!( - target: LOG_TARGET, - "OwnerInfoOf is still NOT empty, found code_hash: {:?}", - k - ); - } else { - log::debug!(target: LOG_TARGET, "OwnerInfoOf is empty."); - } - - let mut deposit: old::BalanceOf = Default::default(); - let mut items = 0u32; - let mut storage_info = 0u32; - CodeInfoOf::::iter().for_each(|(_k, v)| { - deposit += v.deposit; - items += 1; - storage_info += v.encoded_size() as u32; - }); - let mut storage_code = 0u32; - PristineCode::::iter().for_each(|(_k, v)| { - storage_code += v.len() as u32; - }); - let (_, old_deposit, storage_module) = state; - // CodeInfoOf::max_encoded_len == OwnerInfoOf::max_encoded_len + 1 - // I.e. code info adds up 1 byte per record. - let info_bytes_added = items.clone(); - // We removed 1 PrefabWasmModule, and added 1 byte of determinism flag, per contract code. - let storage_removed = storage_module.saturating_sub(info_bytes_added); - // module+code+info - bytes - let storage_was = storage_module - .saturating_add(storage_code) - .saturating_add(storage_info) - .saturating_sub(info_bytes_added); - // We removed 1 storage item (PrefabWasmMod) for every stored contract code (was stored 3 - // items per code). - let items_removed = items; - log::info!( - target: LOG_TARGET, - "Storage freed, bytes: {} (of {}), items: {} (of {})", - storage_removed, - storage_was, - items_removed, - items_removed * 3, - ); - log::info!( - target: LOG_TARGET, - "Deposits returned, total: {:?} Balance (of {:?} Balance)", - old_deposit.saturating_sub(deposit), - old_deposit, - ); - - Ok(()) - } -} diff --git a/primitives/src/migrations/contract_v12_fix.rs b/primitives/src/migrations/contract_v12_fix.rs deleted file mode 100644 index 35b1918f28..0000000000 --- a/primitives/src/migrations/contract_v12_fix.rs +++ /dev/null @@ -1,161 +0,0 @@ -// This file is part of Astar. - -// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later - -// Astar 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. - -// Astar 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 Astar. If not, see . - -//! Migrate CodeInfo from faulty alias introduced on contracts's v12 migration - -use frame_support::{ - pallet_prelude::*, storage_alias, traits::fungible::Inspect, DefaultNoBound, Identity, -}; -use pallet_contracts::{ - migration::{IsFinished, MigrationStep}, - weights::WeightInfo, - Config, Determinism, Pallet, -}; -use parity_scale_codec::{Decode, Encode}; -#[cfg(feature = "try-runtime")] -use scale_info::prelude::format; -#[cfg(feature = "try-runtime")] -use sp_runtime::TryRuntimeError; -use sp_std::marker::PhantomData; -#[cfg(feature = "try-runtime")] -use sp_std::vec::Vec; - -const LOG_TARGET: &str = "runtime::contracts"; - -type BalanceOf = - <::Currency as Inspect<::AccountId>>::Balance; -type AccountIdOf = ::AccountId; -type CodeHash = ::Hash; -type CodeVec = BoundedVec::MaxCodeLen>; - -mod old { - use super::*; - - #[storage_alias] - pub type CodeInfoOf = StorageMap, Twox64Concat, CodeHash, CodeInfo>; -} - -#[derive(Encode, Decode, scale_info::TypeInfo, MaxEncodedLen)] -#[codec(mel_bound())] -#[scale_info(skip_type_params(T))] -pub struct CodeInfo { - owner: AccountIdOf, - #[codec(compact)] - deposit: BalanceOf, - #[codec(compact)] - refcount: u64, - determinism: Determinism, - code_len: u32, -} - -#[storage_alias] -pub type CodeInfoOf = StorageMap, Identity, CodeHash, CodeInfo>; - -#[storage_alias] -pub type PristineCode = StorageMap, Identity, CodeHash, CodeVec>; - -#[derive(Encode, Decode, MaxEncodedLen, DefaultNoBound)] -pub struct Migration { - last_code_hash: Option>, - _phantom: PhantomData, -} - -/// Logic as follows, -/// Since we need to modifiy `CodeInfoOf` mapping we cannot use `iter()` or `drain()` on it as -/// that will be undefined behaviour, so we are iterating over keys of `PristineCode` mappings -/// which are code hashes. -/// -/// Migration Weights: Reusing v12 migration weights as most heavy operation which is moving -/// code info is same. -impl MigrationStep for Migration { - const VERSION: u16 = 15; - - fn max_step_weight() -> Weight { - T::WeightInfo::v12_migration_step(T::MaxCodeLen::get()) - } - - fn step(&mut self) -> (IsFinished, Weight) { - let mut iter = if let Some(last_key) = self.last_code_hash.take() { - PristineCode::::iter_keys_from(PristineCode::::hashed_key_for(last_key)) - } else { - PristineCode::::iter_keys() - }; - - if let Some(code_hash) = iter.next() { - if let Some(code_info) = old::CodeInfoOf::::take(code_hash) { - log::debug!( - target: LOG_TARGET, - "Migrating CodeInfoOf for code_hash {:?}", - code_hash - ); - - let code_len = code_info.code_len; - - CodeInfoOf::::insert(code_hash, code_info); - - self.last_code_hash = Some(code_hash); - (IsFinished::No, T::WeightInfo::v12_migration_step(code_len)) - } else { - log::warn!( - target: LOG_TARGET, - "No CodeInfo found for code_hash {:?}, maybe new contract?", - code_hash - ); - // old CodeInfo not found, it's newly deployed contract - self.last_code_hash = Some(code_hash); - (IsFinished::No, T::WeightInfo::v12_migration_step(0)) - } - } else { - log::debug!(target: LOG_TARGET, "No more CodeInfo to migrate"); - (IsFinished::Yes, T::WeightInfo::v12_migration_step(0)) - } - } - - #[cfg(feature = "try-runtime")] - fn pre_upgrade_step() -> Result, TryRuntimeError> { - let len = 100; - let sample: Vec<_> = old::CodeInfoOf::::iter_keys().take(len).collect(); - log::debug!( - target: LOG_TARGET, - "Taking sample of {} CodeInfoOf(s)", - sample.len() - ); - - Ok(sample.encode()) - } - - #[cfg(feature = "try-runtime")] - fn post_upgrade_step(state: Vec) -> Result<(), TryRuntimeError> { - let state = > as Decode>::decode(&mut &state[..]).unwrap(); - - log::debug!( - target: LOG_TARGET, - "Validating state of {} Codeinfo(s)", - state.len() - ); - for hash in state { - ensure!( - old::CodeInfoOf::::get(&hash).is_none(), - "Old CodeInfoFor is not none!" - ); - let _ = CodeInfoOf::::get(&hash) - .expect(format!("CodeInfo for code_hash {:?} not found!", hash).as_str()); - } - Ok(()) - } -} diff --git a/primitives/src/migrations/contract_v14.rs b/primitives/src/migrations/contract_v14.rs deleted file mode 100644 index ca0f6fe5cd..0000000000 --- a/primitives/src/migrations/contract_v14.rs +++ /dev/null @@ -1,284 +0,0 @@ -// This file is part of Astar. - -// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later - -// Astar 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. - -// Astar 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 Astar. If not, see . - -//! Update the code owner balance, make the code upload deposit balance to be held instead of -//! reserved. Since [`Currency`](frame_support::traits::Currency) has been -//! [deprecated](https://github.com/paritytech/substrate/pull/12951), we need the deposits to be -//! handled by the [`frame_support::traits::fungible`] traits. - -#[cfg(feature = "try-runtime")] -use frame_support::traits::fungible::InspectHold; -use frame_support::{ - pallet_prelude::*, - storage_alias, - traits::{ - fungible::{Inspect, MutateHold}, - ReservableCurrency, - }, - DefaultNoBound, -}; -use pallet_contracts::{ - migration::{IsFinished, MigrationStep}, - weights::WeightInfo, - Config, Determinism, HoldReason, Pallet, -}; -use parity_scale_codec::{Decode, Encode}; -use sp_core::hexdisplay::HexDisplay; -#[cfg(feature = "try-runtime")] -use sp_runtime::TryRuntimeError; -use sp_runtime::{traits::Zero, Saturating}; -#[cfg(feature = "try-runtime")] -use sp_std::collections::btree_map::BTreeMap; -#[cfg(feature = "try-runtime")] -use sp_std::vec::Vec; - -const LOG_TARGET: &str = "runtime::contracts"; - -type CodeHash = ::Hash; -type BalanceOf = - <::Currency as Inspect<::AccountId>>::Balance; -pub type AccountIdOf = ::AccountId; - -mod old { - use super::*; - - pub type BalanceOf = ::AccountId, - >>::Balance; - - #[derive(Encode, Decode, scale_info::TypeInfo, MaxEncodedLen)] - #[codec(mel_bound())] - #[scale_info(skip_type_params(T, OldCurrency))] - pub struct CodeInfo - where - T: Config, - OldCurrency: ReservableCurrency<::AccountId>, - { - pub owner: AccountIdOf, - #[codec(compact)] - pub deposit: old::BalanceOf, - #[codec(compact)] - pub refcount: u64, - pub determinism: Determinism, - pub code_len: u32, - } - - #[storage_alias] - pub type CodeInfoOf = - StorageMap, Identity, CodeHash, CodeInfo>; -} - -#[cfg(feature = "runtime-benchmarks")] -pub fn store_dummy_code(account: T::AccountId) -where - T: Config, - OldCurrency: ReservableCurrency<::AccountId> + 'static, -{ - use sp_runtime::traits::Hash; - use sp_std::vec; - - let len = T::MaxCodeLen::get(); - let code = vec![42u8; len as usize]; - let hash = T::Hashing::hash(&code); - - let info = old::CodeInfo { - owner: account, - deposit: 10_000u32.into(), - refcount: u64::MAX, - determinism: Determinism::Enforced, - code_len: len, - }; - old::CodeInfoOf::::insert(hash, info); -} - -#[cfg(feature = "try-runtime")] -#[derive(Encode, Decode)] -/// Accounts for the balance allocation of a code owner. -struct BalanceAllocation -where - T: Config, - OldCurrency: ReservableCurrency<::AccountId>, -{ - /// Total reserved balance as code upload deposit for the owner. - reserved: old::BalanceOf, - /// Total balance of the owner. - total: old::BalanceOf, -} - -#[derive(Encode, Decode, MaxEncodedLen, DefaultNoBound)] -pub struct Migration -where - T: Config, - OldCurrency: ReservableCurrency<::AccountId>, -{ - last_code_hash: Option>, - _phantom: PhantomData<(T, OldCurrency)>, -} - -impl MigrationStep for Migration -where - T: Config, - OldCurrency: 'static + ReservableCurrency<::AccountId>, - BalanceOf: From, -{ - const VERSION: u16 = 14; - - fn max_step_weight() -> Weight { - T::WeightInfo::v14_migration_step() - } - - fn step(&mut self) -> (IsFinished, Weight) { - let mut iter = if let Some(last_hash) = self.last_code_hash.take() { - old::CodeInfoOf::::iter_from( - old::CodeInfoOf::::hashed_key_for(last_hash), - ) - } else { - old::CodeInfoOf::::iter() - }; - - if let Some((hash, code_info)) = iter.next() { - log::debug!( - target: LOG_TARGET, - "Migrating code upload deposit for 0x{:?}", - HexDisplay::from(&code_info.owner.encode()) - ); - - let remaining = OldCurrency::unreserve(&code_info.owner, code_info.deposit); - - if remaining > Zero::zero() { - log::warn!( - target: LOG_TARGET, - "Code owner's account 0x{:?} for code {:?} has some non-unreservable deposit {:?} from a total of {:?} that will remain in reserved.", - HexDisplay::from(&code_info.owner.encode()), - hash, - remaining, - code_info.deposit - ); - } - - let unreserved = code_info.deposit.saturating_sub(remaining); - let amount = BalanceOf::::from(unreserved); - - log::debug!( - target: LOG_TARGET, - "Holding {:?} on the code owner's account 0x{:?} for code {:?}.", - amount, - HexDisplay::from(&code_info.owner.encode()), - hash, - ); - - T::Currency::hold( - &HoldReason::CodeUploadDepositReserve.into(), - &code_info.owner, - amount, - ) - .unwrap_or_else(|err| { - log::error!( - target: LOG_TARGET, - "Failed to hold {:?} from the code owner's account 0x{:?} for code {:?}, reason: {:?}.", - amount, - HexDisplay::from(&code_info.owner.encode()), - hash, - err - ); - }); - - self.last_code_hash = Some(hash); - (IsFinished::No, T::WeightInfo::v14_migration_step()) - } else { - log::debug!(target: LOG_TARGET, "No more code upload deposit to migrate"); - (IsFinished::Yes, T::WeightInfo::v14_migration_step()) - } - } - - #[cfg(feature = "try-runtime")] - fn pre_upgrade_step() -> Result, TryRuntimeError> { - let info: Vec<_> = old::CodeInfoOf::::iter().collect(); - - let mut owner_balance_allocation = - BTreeMap::, BalanceAllocation>::new(); - - // Calculates the balance allocation by accumulating the code upload deposits of all codes - // owned by an owner. - for (_, code_info) in info { - owner_balance_allocation - .entry(code_info.owner.clone()) - .and_modify(|alloc| { - alloc.reserved = alloc.reserved.saturating_add(code_info.deposit); - }) - .or_insert(BalanceAllocation { - reserved: code_info.deposit, - total: OldCurrency::total_balance(&code_info.owner), - }); - } - - Ok(owner_balance_allocation.encode()) - } - - #[cfg(feature = "try-runtime")] - fn post_upgrade_step(state: Vec) -> Result<(), TryRuntimeError> { - let owner_balance_allocation = - , BalanceAllocation> as Decode>::decode( - &mut &state[..], - ) - .expect("pre_upgrade_step provides a valid state; qed"); - - let mut total_held: BalanceOf = Zero::zero(); - let count = owner_balance_allocation.len(); - for (owner, old_balance_allocation) in owner_balance_allocation { - let held = - T::Currency::balance_on_hold(&HoldReason::CodeUploadDepositReserve.into(), &owner); - log::debug!( - target: LOG_TARGET, - "Validating code upload deposit for owner 0x{:?}, reserved: {:?}, held: {:?}", - HexDisplay::from(&owner.encode()), - old_balance_allocation.reserved, - held - ); - ensure!( - held == old_balance_allocation.reserved.into(), - "Held amount mismatch" - ); - - log::debug!( - target: LOG_TARGET, - "Validating total balance for owner 0x{:?}, new: {:?}, old: {:?}", - HexDisplay::from(&owner.encode()), - T::Currency::total_balance(&owner), - old_balance_allocation.total - ); - ensure!( - T::Currency::total_balance(&owner) - == BalanceOf::::decode(&mut &old_balance_allocation.total.encode()[..]) - .unwrap(), - "Balance mismatch " - ); - total_held += held; - } - - log::info!(target: LOG_TARGET, "Code owners processed: {:?}.", count); - - log::info!( - target: LOG_TARGET, - "Total held amount for code upload deposit: {:?}", - total_held - ); - - Ok(()) - } -} diff --git a/primitives/src/migrations/mod.rs b/primitives/src/migrations/mod.rs deleted file mode 100644 index 7d4ee838f1..0000000000 --- a/primitives/src/migrations/mod.rs +++ /dev/null @@ -1,66 +0,0 @@ -// This file is part of Astar. - -// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later - -// Astar 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. - -// Astar 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 Astar. If not, see . - -#[cfg(feature = "try-runtime")] -use frame_support::ensure; -use frame_support::traits::{OnRuntimeUpgrade, PalletInfoAccess, StorageVersion}; -use frame_support::weights::Weight; -use sp_core::Get; -#[cfg(feature = "try-runtime")] -use sp_runtime::TryRuntimeError; -use sp_std::marker::PhantomData; -#[cfg(feature = "try-runtime")] -use sp_std::vec::Vec; - -pub mod contract_v12; -pub mod contract_v12_fix; -pub mod contract_v14; - -/// Force set pallet-contracts version -pub struct ForceContractsVersion { - _phantom: PhantomData, -} - -impl OnRuntimeUpgrade for ForceContractsVersion { - fn on_runtime_upgrade() -> Weight { - StorageVersion::new(V).put::>(); - ::DbWeight::get().writes(1) - } - - #[cfg(feature = "try-runtime")] - fn post_upgrade(_state: Vec) -> Result<(), TryRuntimeError> { - let pallet_version = StorageVersion::get::>(); - ensure!(pallet_version == V, "Contracts pallet version mismatch"); - Ok(()) - } -} - -/// Noop migration that checks for pallet version in try-runtime - -pub struct EnsurePalletVersion { - _phantam: PhantomData

, -} - -impl OnRuntimeUpgrade for EnsurePalletVersion { - #[cfg(feature = "try-runtime")] - fn post_upgrade(_state: Vec) -> Result<(), TryRuntimeError> { - let pallet_version = StorageVersion::get::

(); - ensure!(pallet_version == V, "Pallet version mismatch"); - Ok(()) - } -} From b427753b652cf038afec7d091551f1bb37c88597 Mon Sep 17 00:00:00 2001 From: Dino Pacandi Date: Tue, 23 Apr 2024 18:51:11 +0900 Subject: [PATCH 19/19] Remove unused import --- pallets/ethereum-checked/src/tests.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pallets/ethereum-checked/src/tests.rs b/pallets/ethereum-checked/src/tests.rs index e037265883..c0d350e05a 100644 --- a/pallets/ethereum-checked/src/tests.rs +++ b/pallets/ethereum-checked/src/tests.rs @@ -22,7 +22,7 @@ use super::*; use mock::*; use astar_primitives::ethereum_checked::EthereumTxInput; -use ethereum::{ReceiptV3, ReceiptV3 as Receipt, TransactionV2 as Transaction}; +use ethereum::{ReceiptV3 as Receipt, TransactionV2 as Transaction}; pub use fp_rpc::TransactionStatus; use frame_support::{assert_noop, assert_ok}; use sp_runtime::DispatchError; @@ -57,7 +57,7 @@ fn transact_works() { assert_eq!(pending.len(), 2); match pending[0] { - (Transaction::EIP1559(ref t), _, ReceiptV3::EIP1559(ref r)) => { + (Transaction::EIP1559(ref t), _, Receipt::EIP1559(ref r)) => { // nonce 0, status code 1 (success) assert_eq!(t.nonce, U256::zero()); assert_eq!(r.status_code, 1); @@ -65,7 +65,7 @@ fn transact_works() { _ => panic!("unexpected transaction type"), } match pending[1] { - (Transaction::EIP1559(ref t), _, ReceiptV3::EIP1559(ref r)) => { + (Transaction::EIP1559(ref t), _, Receipt::EIP1559(ref r)) => { // nonce 1, status code 1 (success) assert_eq!(t.nonce, U256::one()); assert_eq!(r.status_code, 1);