From 913bacf217cb2dbe627d95a268883236facb5c51 Mon Sep 17 00:00:00 2001 From: inodelisia <63119441+inodelisia@users.noreply.github.com> Date: Mon, 14 Jun 2021 11:43:39 +0300 Subject: [PATCH 1/4] hyperspace-specversion-200 --- Cargo.lock | 900 ++++++++------ Cargo.toml | 16 +- bin/node/cli/Cargo.toml | 99 +- bin/node/cli/src/chain_spec.rs | 22 +- bin/node/cli/src/command.rs | 4 +- bin/node/cli/src/rpc.rs | 39 +- bin/node/cli/src/service.rs | 123 +- bin/node/primitives/Cargo.toml | 8 +- bin/node/primitives/src/lib.rs | 2 +- bin/node/runtime/hyperspace/Cargo.toml | 99 +- .../hyperspace/src/authority_discovery.rs | 6 + bin/node/runtime/hyperspace/src/authorship.rs | 15 + bin/node/runtime/hyperspace/src/babe.rs | 25 + bin/node/runtime/hyperspace/src/balances.rs | 40 + bin/node/runtime/hyperspace/src/claims.rs | 17 + bin/node/runtime/hyperspace/src/collective.rs | 65 + bin/node/runtime/hyperspace/src/democracy.rs | 64 + bin/node/runtime/hyperspace/src/dvm.rs | 31 + .../hyperspace/src/elections_phragmen.rs | 38 + .../hyperspace/src/ethereum_backing.rs | 30 + .../runtime/hyperspace/src/ethereum_relay.rs | 29 + bin/node/runtime/hyperspace/src/evm.rs | 35 + bin/node/runtime/hyperspace/src/grandpa.rs | 20 + bin/node/runtime/hyperspace/src/header_mmr.rs | 5 + bin/node/runtime/hyperspace/src/identity.rs | 28 + bin/node/runtime/hyperspace/src/im_online.rs | 18 + bin/node/runtime/hyperspace/src/lib.rs | 1085 +++-------------- bin/node/runtime/hyperspace/src/membership.rs | 27 + bin/node/runtime/hyperspace/src/multisig.rs | 21 + bin/node/runtime/hyperspace/src/offences.rs | 18 + .../runtime/hyperspace/src/oldetp_backing.rs | 14 + .../runtime/hyperspace/src/oldetp_issuing.rs | 15 + .../runtime/hyperspace/src/oldna_backing.rs | 15 + bin/node/runtime/hyperspace/src/proxy.rs | 122 ++ bin/node/runtime/hyperspace/src/recovery.rs | 20 + .../hyperspace/src/relay_authorities.rs | 38 + .../runtime/hyperspace/src/relayer_game.rs | 20 + bin/node/runtime/hyperspace/src/scheduler.rs | 23 + bin/node/runtime/hyperspace/src/session.rs | 31 + .../hyperspace/src/session_historical.rs | 13 + bin/node/runtime/hyperspace/src/society.rs | 32 + bin/node/runtime/hyperspace/src/staking.rs | 63 + bin/node/runtime/hyperspace/src/sudo.rs | 9 + bin/node/runtime/hyperspace/src/system.rs | 78 ++ bin/node/runtime/hyperspace/src/timestamp.rs | 14 + .../hyperspace/src/transaction_payment.rs | 29 + bin/node/runtime/hyperspace/src/treasury.rs | 53 + bin/node/runtime/hyperspace/src/utility.rs | 10 + bin/node/runtime/hyperspace/src/vesting.rs | 16 + client/cli/Cargo.toml | 10 +- client/dvm/consensus/Cargo.toml | 29 +- client/dvm/consensus/src/lib.rs | 103 +- client/dvm/db/Cargo.toml | 21 + client/dvm/db/src/lib.rs | 227 ++++ client/dvm/db/src/utils.rs | 40 + client/dvm/mapping-sync/Cargo.toml | 26 + client/dvm/mapping-sync/src/lib.rs | 162 +++ client/dvm/mapping-sync/src/worker.rs | 129 ++ client/dvm/rpc/Cargo.toml | 41 +- client/dvm/rpc/src/eth.rs | 942 ++++++++++---- client/dvm/rpc/src/eth_pubsub.rs | 220 ++-- client/dvm/rpc/src/lib.rs | 26 +- client/dvm/rpc/src/overrides/mod.rs | 136 +++ .../rpc/src/overrides/schema_v1_override.rs | 133 ++ frame/balances/Cargo.toml | 16 +- frame/balances/rpc/Cargo.toml | 8 +- frame/balances/rpc/runtime-api/Cargo.toml | 6 +- frame/balances/src/tests.rs | 10 +- frame/bridge/ethereum/backing/Cargo.toml | 26 +- frame/bridge/ethereum/backing/src/lib.rs | 11 +- frame/bridge/ethereum/backing/src/mock.rs | 1 - .../backing/src/test_with_linear_relay.rs | 3 +- .../ethereum/backing/src/test_with_relay.rs | 3 +- frame/bridge/ethereum/linear-relay/Cargo.toml | 14 +- .../bridge/ethereum/linear-relay/src/mock.rs | 19 +- frame/bridge/ethereum/relay/Cargo.toml | 24 +- frame/bridge/ethereum/relay/src/lib.rs | 1 - frame/bridge/oldetp/backing/Cargo.toml | 8 +- frame/bridge/oldetp/backing/src/lib.rs | 13 +- frame/bridge/oldetp/issuing/Cargo.toml | 22 +- frame/bridge/oldetp/issuing/src/lib.rs | 29 +- frame/bridge/oldetp/issuing/src/mock.rs | 54 +- frame/bridge/oldetp/issuing/src/tests.rs | 4 +- frame/bridge/oldetp/issuing/src/weights.rs | 2 + frame/bridge/oldna/backing/Cargo.toml | 8 +- frame/bridge/oldna/backing/src/lib.rs | 13 +- frame/bridge/relay-authorities/Cargo.toml | 14 +- frame/bridge/relay-authorities/src/test.rs | 4 +- frame/bridge/relayer-game/Cargo.toml | 14 +- frame/claims/Cargo.toml | 20 +- frame/claims/src/address.rs | 5 +- frame/claims/src/lib.rs | 87 +- frame/democracy/Cargo.toml | 20 +- frame/dvm-dynamic-fee/Cargo.toml | 35 + frame/dvm-dynamic-fee/src/lib.rs | 132 ++ frame/dvm/Cargo.toml | 29 +- frame/dvm/rpc/Cargo.toml | 18 +- frame/dvm/rpc/runtime-api/Cargo.toml | 19 +- frame/dvm/rpc/runtime-api/src/lib.rs | 8 +- frame/dvm/rpc/src/eth.rs | 16 +- frame/dvm/rpc/src/eth_pubsub.rs | 2 +- frame/dvm/rpc/src/lib.rs | 2 +- frame/dvm/rpc/src/web3.rs | 2 +- frame/dvm/src/account_basic.rs | 4 +- frame/dvm/src/lib.rs | 101 +- frame/dvm/src/mock.rs | 3 +- frame/elections-phragmen/Cargo.toml | 18 +- frame/elections-phragmen/src/lib.rs | 2 +- .../src/migrations_2_0_0.rs | 191 +++ frame/evm/Cargo.toml | 28 +- frame/evm/precompile/Cargo.toml | 2 +- .../precompile/contracts/blake2/Cargo.toml | 12 +- .../precompile/contracts/blake2/src/lib.rs | 2 +- .../evm/precompile/contracts/bn128/Cargo.toml | 14 +- .../evm/precompile/contracts/bn128/src/lib.rs | 2 +- .../precompile/contracts/dispatch/Cargo.toml | 18 +- .../precompile/contracts/dispatch/src/lib.rs | 2 +- frame/evm/precompile/contracts/dna/Cargo.toml | 27 +- frame/evm/precompile/contracts/dna/src/lib.rs | 2 +- .../precompile/contracts/ed25519/Cargo.toml | 14 +- .../precompile/contracts/ed25519/src/lib.rs | 2 +- .../evm/precompile/contracts/empty/Cargo.toml | 8 +- .../evm/precompile/contracts/empty/src/lib.rs | 2 +- .../precompile/contracts/modexp/Cargo.toml | 14 +- .../precompile/contracts/modexp/src/lib.rs | 2 +- .../precompile/contracts/simple/Cargo.toml | 14 +- .../precompile/contracts/simple/src/lib.rs | 2 +- .../precompile/contracts/withdraw/Cargo.toml | 26 +- .../precompile/contracts/withdraw/src/lib.rs | 2 +- frame/evm/src/lib.rs | 53 +- frame/evm/src/runner/mod.rs | 2 +- frame/evm/src/runner/stack.rs | 28 +- frame/header-mmr/Cargo.toml | 18 +- frame/header-mmr/rpc/Cargo.toml | 8 +- frame/header-mmr/rpc/runtime-api/Cargo.toml | 8 +- frame/header-mmr/src/lib.rs | 8 +- frame/header-mmr/src/tests.rs | 1 - frame/staking/Cargo.toml | 32 +- frame/staking/rpc/Cargo.toml | 8 +- frame/staking/rpc/runtime-api/Cargo.toml | 6 +- frame/staking/src/lib.rs | 25 +- frame/staking/src/substrate_tests.rs | 2 +- frame/support/Cargo.toml | 8 +- frame/treasury/Cargo.toml | 16 +- frame/vesting/Cargo.toml | 16 +- primitives/consensus/Cargo.toml | 19 +- primitives/consensus/src/lib.rs | 149 ++- primitives/ethereum-primitives/Cargo.toml | 16 +- .../ethereum-primitives/src/ethashproof.rs | 1 - primitives/ethereum-primitives/src/header.rs | 9 +- primitives/ethereum-primitives/src/receipt.rs | 1 - primitives/evm/Cargo.toml | 10 +- primitives/merkle-patricia-trie/Cargo.toml | 8 +- primitives/merkle-patricia-trie/src/tests.rs | 7 +- primitives/relay/Cargo.toml | 8 +- primitives/rpc/Cargo.toml | 21 + primitives/rpc/src/account_info.rs | 78 ++ primitives/rpc/src/block.rs | 177 +++ primitives/rpc/src/block_number.rs | 210 ++++ primitives/rpc/src/bytes.rs | 134 ++ primitives/rpc/src/call_request.rs | 40 + primitives/rpc/src/filter.rs | 348 ++++++ primitives/rpc/src/index.rs | 91 ++ primitives/rpc/src/lib.rs | 58 + primitives/rpc/src/log.rs | 46 + primitives/rpc/src/pubsub.rs | 105 ++ primitives/rpc/src/receipt.rs | 55 + primitives/rpc/src/sync.rs | 144 +++ primitives/rpc/src/transaction.rs | 175 +++ primitives/rpc/src/transaction_request.rs | 42 + primitives/rpc/src/work.rs | 51 + primitives/storage/Cargo.toml | 16 + primitives/storage/src/lib.rs | 21 + 173 files changed, 6810 insertions(+), 2494 deletions(-) create mode 100644 bin/node/runtime/hyperspace/src/authority_discovery.rs create mode 100644 bin/node/runtime/hyperspace/src/authorship.rs create mode 100644 bin/node/runtime/hyperspace/src/babe.rs create mode 100644 bin/node/runtime/hyperspace/src/balances.rs create mode 100644 bin/node/runtime/hyperspace/src/claims.rs create mode 100644 bin/node/runtime/hyperspace/src/collective.rs create mode 100644 bin/node/runtime/hyperspace/src/democracy.rs create mode 100644 bin/node/runtime/hyperspace/src/dvm.rs create mode 100644 bin/node/runtime/hyperspace/src/elections_phragmen.rs create mode 100644 bin/node/runtime/hyperspace/src/ethereum_backing.rs create mode 100644 bin/node/runtime/hyperspace/src/ethereum_relay.rs create mode 100644 bin/node/runtime/hyperspace/src/evm.rs create mode 100644 bin/node/runtime/hyperspace/src/grandpa.rs create mode 100644 bin/node/runtime/hyperspace/src/header_mmr.rs create mode 100644 bin/node/runtime/hyperspace/src/identity.rs create mode 100644 bin/node/runtime/hyperspace/src/im_online.rs create mode 100644 bin/node/runtime/hyperspace/src/membership.rs create mode 100644 bin/node/runtime/hyperspace/src/multisig.rs create mode 100644 bin/node/runtime/hyperspace/src/offences.rs create mode 100644 bin/node/runtime/hyperspace/src/oldetp_backing.rs create mode 100644 bin/node/runtime/hyperspace/src/oldetp_issuing.rs create mode 100644 bin/node/runtime/hyperspace/src/oldna_backing.rs create mode 100644 bin/node/runtime/hyperspace/src/proxy.rs create mode 100644 bin/node/runtime/hyperspace/src/recovery.rs create mode 100644 bin/node/runtime/hyperspace/src/relay_authorities.rs create mode 100644 bin/node/runtime/hyperspace/src/relayer_game.rs create mode 100644 bin/node/runtime/hyperspace/src/scheduler.rs create mode 100644 bin/node/runtime/hyperspace/src/session.rs create mode 100644 bin/node/runtime/hyperspace/src/session_historical.rs create mode 100644 bin/node/runtime/hyperspace/src/society.rs create mode 100644 bin/node/runtime/hyperspace/src/staking.rs create mode 100644 bin/node/runtime/hyperspace/src/sudo.rs create mode 100644 bin/node/runtime/hyperspace/src/system.rs create mode 100644 bin/node/runtime/hyperspace/src/timestamp.rs create mode 100644 bin/node/runtime/hyperspace/src/transaction_payment.rs create mode 100644 bin/node/runtime/hyperspace/src/treasury.rs create mode 100644 bin/node/runtime/hyperspace/src/utility.rs create mode 100644 bin/node/runtime/hyperspace/src/vesting.rs create mode 100644 client/dvm/db/Cargo.toml create mode 100644 client/dvm/db/src/lib.rs create mode 100644 client/dvm/db/src/utils.rs create mode 100644 client/dvm/mapping-sync/Cargo.toml create mode 100644 client/dvm/mapping-sync/src/lib.rs create mode 100644 client/dvm/mapping-sync/src/worker.rs create mode 100644 client/dvm/rpc/src/overrides/mod.rs create mode 100644 client/dvm/rpc/src/overrides/schema_v1_override.rs create mode 100644 frame/bridge/oldetp/issuing/src/weights.rs create mode 100644 frame/dvm-dynamic-fee/Cargo.toml create mode 100644 frame/dvm-dynamic-fee/src/lib.rs create mode 100644 frame/elections-phragmen/src/migrations_2_0_0.rs create mode 100644 primitives/rpc/Cargo.toml create mode 100644 primitives/rpc/src/account_info.rs create mode 100644 primitives/rpc/src/block.rs create mode 100644 primitives/rpc/src/block_number.rs create mode 100644 primitives/rpc/src/bytes.rs create mode 100644 primitives/rpc/src/call_request.rs create mode 100644 primitives/rpc/src/filter.rs create mode 100644 primitives/rpc/src/index.rs create mode 100644 primitives/rpc/src/lib.rs create mode 100644 primitives/rpc/src/log.rs create mode 100644 primitives/rpc/src/pubsub.rs create mode 100644 primitives/rpc/src/receipt.rs create mode 100644 primitives/rpc/src/sync.rs create mode 100644 primitives/rpc/src/transaction.rs create mode 100644 primitives/rpc/src/transaction_request.rs create mode 100644 primitives/rpc/src/work.rs create mode 100644 primitives/storage/Cargo.toml create mode 100644 primitives/storage/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 4f8edb4..254d021 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -306,9 +306,9 @@ checksum = "e91831deabf0d6d7ec49552e489aed63b7456a7a3c46cff62adad428110b0af0" [[package]] name = "async-trait" -version = "0.1.45" +version = "0.1.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3340571769500ddef1e94b45055fabed6b08a881269b7570c830b8f32ef84ef" +checksum = "36ea56748e10732c49404c153638a15ec3d6211ec5ff35d9bb20e13b93576adf" dependencies = [ "proc-macro2", "quote", @@ -600,9 +600,9 @@ checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" [[package]] name = "byteorder" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae44d1a3d5a19df61dd0c8beb138458ac2a53a7ac09eba97d55592540004306b" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "bytes" @@ -1083,9 +1083,9 @@ dependencies = [ [[package]] name = "csv" -version = "1.1.5" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9d58633299b24b515ac72a3f869f8b91306a3cec616a602843a383acd6f9e97" +checksum = "22813a6dc45b335f9bade10bf7271dc477e81113e89eb251a0bc2a8a81c536e1" dependencies = [ "bstr", "csv-core", @@ -1165,6 +1165,98 @@ version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ee2393c4a91429dffb4bedf19f4d6abf27d8a732c8ce4980305d782e5426d57" +[[package]] +name = "dc-consensus" +version = "2.0.0" +dependencies = [ + "dc-db", + "derive_more", + "dp_consensus", + "dvm-rpc-runtime-api", + "futures 0.3.13", + "log", + "parity-scale-codec 1.3.7", + "sc-client-api", + "sp-api", + "sp-block-builder", + "sp-blockchain", + "sp-consensus", + "sp-core", + "sp-inherents", + "sp-runtime", + "sp-timestamp", + "substrate-prometheus-endpoint", +] + +[[package]] +name = "dc-db" +version = "2.0.0" +dependencies = [ + "kvdb", + "kvdb-rocksdb", + "parity-scale-codec 1.3.7", + "parking_lot 0.11.1", + "sp-core", + "sp-database", + "sp-runtime", +] + +[[package]] +name = "dc-mapping-sync" +version = "2.0.0" +dependencies = [ + "dc-consensus", + "dc-db", + "dp_consensus", + "dvm-rpc-runtime-api", + "futures 0.3.13", + "futures-timer 3.0.2", + "log", + "sc-client-api", + "sp-api", + "sp-blockchain", + "sp-runtime", +] + +[[package]] +name = "dc-rpc" +version = "2.0.0" +dependencies = [ + "array-bytes", + "dc-consensus", + "dc-db", + "dp-rpc", + "dp-storage", + "dp_consensus", + "dvm-ethereum", + "dvm-rpc-core", + "dvm-rpc-runtime-api", + "ethereum", + "ethereum-types 0.10.0", + "futures 0.3.13", + "hyperspace-evm", + "jsonrpc-core", + "jsonrpc-core-client", + "jsonrpc-derive", + "jsonrpc-pubsub", + "libsecp256k1", + "log", + "parity-scale-codec 1.3.7", + "rand 0.7.3", + "rlp 0.5.0", + "sc-client-api", + "sc-network", + "sc-rpc", + "sc-service", + "sha3 0.8.2", + "sp-api", + "sp-blockchain", + "sp-io", + "sp-runtime", + "sp-storage", + "sp-transaction-pool", +] + [[package]] name = "derive_more" version = "0.99.11" @@ -1235,43 +1327,70 @@ dependencies = [ ] [[package]] -name = "dvm-consensus" -version = "1.4.0" +name = "dp-evm" +version = "2.0.0" +dependencies = [ + "evm", + "impl-trait-for-tuples 0.2.1", + "parity-scale-codec 1.3.7", + "serde", + "sp-core", + "sp-std", +] + +[[package]] +name = "dp-rpc" +version = "2.0.0" +dependencies = [ + "ethereum-types 0.10.0", + "jsonrpc-core", + "jsonrpc-core-client", + "jsonrpc-derive", + "jsonrpc-pubsub", + "rustc-hex", + "serde", + "serde_json", +] + +[[package]] +name = "dp-storage" +version = "2.0.0" + +[[package]] +name = "dp_consensus" +version = "2.0.0" dependencies = [ - "derive_more", - "dvm-consensus-primitives", "ethereum", - "futures 0.3.13", - "log", "parity-scale-codec 1.3.7", - "sc-client-api", - "sp-api", - "sp-block-builder", - "sp-blockchain", - "sp-consensus", + "rlp 0.5.0", + "sha3 0.8.2", "sp-core", - "sp-inherents", "sp-runtime", - "sp-timestamp", - "substrate-prometheus-endpoint", + "sp-std", ] [[package]] -name = "dvm-consensus-primitives" -version = "1.4.0" +name = "dvm-dynamic-fee" +version = "2.0.0" dependencies = [ + "frame-support", + "frame-system", "parity-scale-codec 1.3.7", + "serde", "sp-core", + "sp-inherents", "sp-runtime", - "sp-std 2.0.1", + "sp-std", ] [[package]] name = "dvm-ethereum" -version = "1.4.0" +version = "2.0.0" dependencies = [ "array-bytes", - "dvm-consensus-primitives", + "dp-evm", + "dp-storage", + "dp_consensus", "dvm-rpc-runtime-api", "ethereum", "ethereum-types 0.10.0", @@ -1281,7 +1400,6 @@ dependencies = [ "hyperspace-balances", "hyperspace-evm", "hyperspace-evm-precompile", - "hyperspace-evm-primitives", "hyperspace-support", "libsecp256k1", "pallet-timestamp", @@ -1292,54 +1410,18 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 2.0.1", -] - -[[package]] -name = "dvm-rpc" -version = "1.4.0" -dependencies = [ - "array-bytes", - "dvm-consensus", - "dvm-ethereum", - "dvm-rpc-core", - "dvm-rpc-core-primitives", - "dvm-rpc-runtime-api", - "ethereum", - "ethereum-types 0.10.0", - "futures 0.3.13", - "hyperspace-evm", - "jsonrpc-core", - "jsonrpc-core-client", - "jsonrpc-derive", - "jsonrpc-pubsub", - "libsecp256k1", - "log", - "parity-scale-codec 1.3.7", - "rand 0.7.3", - "rlp 0.5.0", - "sc-client-api", - "sc-network", - "sc-rpc", - "sc-service", - "sha3 0.8.2", - "sp-api", - "sp-blockchain", - "sp-io", - "sp-runtime", - "sp-storage", - "sp-transaction-pool", + "sp-std", ] [[package]] name = "dvm-rpc-core" -version = "1.4.0" +version = "2.0.0" dependencies = [ - "dvm-rpc-core-primitives", + "dp-evm", + "dp-rpc", "ethereum", "ethereum-types 0.10.0", "hyperspace-evm", - "hyperspace-evm-primitives", "jsonrpc-core", "jsonrpc-derive", "jsonrpc-pubsub", @@ -1347,37 +1429,23 @@ dependencies = [ "sp-api", "sp-core", "sp-runtime", - "sp-std 2.0.1", -] - -[[package]] -name = "dvm-rpc-core-primitives" -version = "1.4.0" -dependencies = [ - "ethereum-types 0.10.0", - "jsonrpc-core", - "jsonrpc-core-client", - "jsonrpc-derive", - "jsonrpc-pubsub", - "rustc-hex", - "serde", - "serde_json", + "sp-std", ] [[package]] name = "dvm-rpc-runtime-api" -version = "1.4.0" +version = "2.0.0" dependencies = [ + "dp-evm", "ethereum", "ethereum-types 0.10.0", "hyperspace-evm", - "hyperspace-evm-primitives", "parity-scale-codec 1.3.7", "sp-api", "sp-core", "sp-io", "sp-runtime", - "sp-std 2.0.1", + "sp-std", ] [[package]] @@ -1521,27 +1589,27 @@ dependencies = [ [[package]] name = "ethabi" version = "9.0.1" -source = "git+https://github.com/new-mvs/ethabi.git?branch=with_no_std#a1ca6a94e8af4a42eca8e18ea1a9d1bf0d0db442" +source = "git+https://github.com/new-mvs/ethabi.git?branch=with_no_std#064722995e72a58b54fde5cbb6bfe2ee75d7f7ee" dependencies = [ "ethereum-types 0.8.0", "rustc-hex", "serde", "serde_derive", "serde_json", - "sp-std 2.0.0-rc2", + "sp-std", "tiny-keccak 1.5.0", ] [[package]] name = "ethash" version = "0.4.0" -source = "git+https://github.com/new-mvs/rust-ethash#d5aad9cbb8280723b95ca0c7d9c8d7a83dee1bd9" +source = "git+https://github.com/new-mvs/ethash?branch=v1#701a26756a0d0f973c2327a4bc1e6b74187cd9b7" dependencies = [ "byteorder", "ethereum-types 0.8.0", "primitive-types 0.6.2", - "rlp 0.4.6", - "sha3 0.8.2", + "rlp 0.4.4", + "sha3 0.9.1", ] [[package]] @@ -1603,7 +1671,7 @@ dependencies = [ [[package]] name = "ethereum-primitives" -version = "1.4.0" +version = "2.0.0" dependencies = [ "array-bytes", "ethash", @@ -1624,7 +1692,7 @@ dependencies = [ "serde_json", "sp-io", "sp-runtime", - "sp-std 2.0.1", + "sp-std", "triehash 0.8.2", ] @@ -1688,9 +1756,9 @@ checksum = "f7531096570974c3a9dcf9e4b8e1cede1ec26cf5046219fb3b9d897503b9be59" [[package]] name = "evm" -version = "0.22.1" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd540113f54cb8f20c74a594e3dc4422d69cb3df7c425ed7ed33c0383f780df0" +checksum = "3b46f945d7548bea2affc1a48168f6d7e832bae914e0d90627a2ea2a7ba63001" dependencies = [ "ethereum", "evm-core", @@ -1706,9 +1774,9 @@ dependencies = [ [[package]] name = "evm-core" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa225f553e9380c498f5beb4ba6e5d455b147a133d371b550f0326b92c95cc17" +checksum = "cc372feb219651f8ae872e6ec0f84b346053c058bd0e8408b1f44a2a796bfecd" dependencies = [ "parity-scale-codec 1.3.7", "primitive-types 0.8.0", @@ -1717,9 +1785,9 @@ dependencies = [ [[package]] name = "evm-gasometer" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08bdd70b8a66727a77b991eb8374374f38b076fd9d539244751c59ebac9c3082" +checksum = "5737059b7a570b3e28a0126b02e0e36e218cc828b29dddbbae73d0b97fce1e0a" dependencies = [ "evm-core", "evm-runtime", @@ -1728,9 +1796,9 @@ dependencies = [ [[package]] name = "evm-runtime" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25ab3a3ea8ab273ef0f9237e13f5fa271b6deb19d604766b88325d8d807afcaf" +checksum = "95726118dbc5f76ed1ee300e685950e58e52a1c4db454a7635aba636c7002186" dependencies = [ "evm-core", "primitive-types 0.8.0", @@ -1887,7 +1955,7 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "fork-tree" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "parity-scale-codec 1.3.7", ] @@ -1905,7 +1973,7 @@ dependencies = [ [[package]] name = "frame-benchmarking" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "frame-support", "frame-system", @@ -1916,14 +1984,14 @@ dependencies = [ "sp-io", "sp-runtime", "sp-runtime-interface", - "sp-std 2.0.1", + "sp-std", "sp-storage", ] [[package]] name = "frame-executive" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "frame-support", "frame-system", @@ -1932,25 +2000,25 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 2.0.1", + "sp-std", "sp-tracing", ] [[package]] name = "frame-metadata" version = "12.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "parity-scale-codec 1.3.7", "serde", "sp-core", - "sp-std 2.0.1", + "sp-std", ] [[package]] name = "frame-support" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "bitflags", "frame-metadata", @@ -1968,14 +2036,14 @@ dependencies = [ "sp-io", "sp-runtime", "sp-state-machine", - "sp-std 2.0.1", + "sp-std", "sp-tracing", ] [[package]] name = "frame-support-procedural" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "Inflector", "frame-support-procedural-tools", @@ -1987,7 +2055,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate", @@ -1999,7 +2067,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "proc-macro2", "quote", @@ -2009,7 +2077,7 @@ dependencies = [ [[package]] name = "frame-system" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "frame-support", "impl-trait-for-tuples 0.2.1", @@ -2018,14 +2086,14 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 2.0.1", + "sp-std", "sp-version", ] [[package]] name = "frame-system-rpc-runtime-api" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "parity-scale-codec 1.3.7", "sp-api", @@ -2441,9 +2509,9 @@ dependencies = [ [[package]] name = "hex" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "644f9158b2f133fd50f5fb3242878846d9eb792e445c893805ff0e3824006e35" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hex-literal" @@ -2633,11 +2701,16 @@ dependencies = [ [[package]] name = "hyperspace" -version = "1.0.13" +version = "2.0.0" dependencies = [ "array-bytes", - "dvm-consensus", - "dvm-rpc", + "dc-consensus", + "dc-db", + "dc-mapping-sync", + "dc-rpc", + "dp-rpc", + "dp_consensus", + "dvm-ethereum", "dvm-rpc-runtime-api", "frame-system-rpc-runtime-api", "futures 0.3.13", @@ -2706,7 +2779,7 @@ dependencies = [ [[package]] name = "hyperspace-balances" -version = "1.4.0" +version = "2.0.0" dependencies = [ "frame-support", "frame-system", @@ -2718,12 +2791,12 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 2.0.1", + "sp-std", ] [[package]] name = "hyperspace-balances-rpc" -version = "1.4.0" +version = "2.0.0" dependencies = [ "hyperspace-balances-rpc-runtime-api", "jsonrpc-core", @@ -2737,7 +2810,7 @@ dependencies = [ [[package]] name = "hyperspace-balances-rpc-runtime-api" -version = "1.4.0" +version = "2.0.0" dependencies = [ "hyperspace-support", "parity-scale-codec 1.3.7", @@ -2748,7 +2821,7 @@ dependencies = [ [[package]] name = "hyperspace-claims" -version = "1.4.0" +version = "2.0.0" dependencies = [ "array-bytes", "frame-support", @@ -2762,12 +2835,12 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 2.0.1", + "sp-std", ] [[package]] name = "hyperspace-cli" -version = "1.4.0" +version = "2.0.0" dependencies = [ "sc-cli", "sc-client-api", @@ -2779,7 +2852,7 @@ dependencies = [ [[package]] name = "hyperspace-democracy" -version = "1.4.0" +version = "2.0.0" dependencies = [ "frame-support", "frame-system", @@ -2792,14 +2865,14 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 2.0.1", + "sp-std", "sp-storage", "substrate-test-utils", ] [[package]] name = "hyperspace-elections-phragmen" -version = "1.4.0" +version = "2.0.0" dependencies = [ "frame-support", "frame-system", @@ -2812,13 +2885,13 @@ dependencies = [ "sp-io", "sp-npos-elections", "sp-runtime", - "sp-std 2.0.1", + "sp-std", "substrate-test-utils", ] [[package]] name = "hyperspace-ethereum-backing" -version = "1.4.0" +version = "2.0.0" dependencies = [ "array-bytes", "ethabi", @@ -2842,12 +2915,12 @@ dependencies = [ "sp-io", "sp-runtime", "sp-staking", - "sp-std 2.0.1", + "sp-std", ] [[package]] name = "hyperspace-ethereum-linear-relay" -version = "1.4.0" +version = "2.0.0" dependencies = [ "array-bytes", "ethereum-primitives", @@ -2863,12 +2936,12 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 2.0.1", + "sp-std", ] [[package]] name = "hyperspace-ethereum-relay" -version = "1.4.0" +version = "2.0.0" dependencies = [ "array-bytes", "blake2-rfc", @@ -2888,20 +2961,20 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 2.0.1", + "sp-std", ] [[package]] name = "hyperspace-evm" -version = "1.4.0" +version = "2.0.0" dependencies = [ + "dp-evm", "evm", "evm-gasometer", "evm-runtime", "frame-support", "frame-system", "hyperspace-balances", - "hyperspace-evm-primitives", "hyperspace-support", "pallet-timestamp", "parity-scale-codec 1.3.7", @@ -2912,12 +2985,12 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 2.0.1", + "sp-std", ] [[package]] name = "hyperspace-evm-precompile" -version = "1.4.0" +version = "2.0.0" dependencies = [ "hyperspace-evm-precompile-dna", "hyperspace-evm-precompile-empty", @@ -2927,20 +3000,20 @@ dependencies = [ [[package]] name = "hyperspace-evm-precompile-blake2" -version = "1.4.0" +version = "2.0.0" dependencies = [ + "dp-evm", "evm", - "hyperspace-evm-primitives", "sp-core", "sp-io", ] [[package]] name = "hyperspace-evm-precompile-bn128" -version = "1.4.0" +version = "2.0.0" dependencies = [ + "dp-evm", "evm", - "hyperspace-evm-primitives", "sp-core", "sp-io", "substrate-bn", @@ -2948,12 +3021,12 @@ dependencies = [ [[package]] name = "hyperspace-evm-precompile-dispatch" -version = "1.4.0" +version = "2.0.0" dependencies = [ + "dp-evm", "evm", "frame-support", "hyperspace-evm", - "hyperspace-evm-primitives", "parity-scale-codec 1.3.7", "sp-core", "sp-io", @@ -2961,16 +3034,17 @@ dependencies = [ [[package]] name = "hyperspace-evm-precompile-dna" -version = "1.4.0" +version = "2.0.0" dependencies = [ "array-bytes", + "dp-evm", "ethabi", "ethereum-types 0.8.0", "evm", "frame-support", "frame-system", + "hex", "hyperspace-evm", - "hyperspace-evm-primitives", "pallet-timestamp", "parity-scale-codec 1.3.7", "ripemd160", @@ -2978,35 +3052,35 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 2.0.1", + "sp-std", ] [[package]] name = "hyperspace-evm-precompile-ed25519" -version = "1.4.0" +version = "2.0.0" dependencies = [ + "dp-evm", "ed25519-dalek", "evm", - "hyperspace-evm-primitives", "sp-core", "sp-io", ] [[package]] name = "hyperspace-evm-precompile-empty" -version = "1.4.0" +version = "2.0.0" dependencies = [ + "dp-evm", "evm", - "hyperspace-evm-primitives", ] [[package]] name = "hyperspace-evm-precompile-modexp" -version = "1.4.0" +version = "2.0.0" dependencies = [ + "dp-evm", "evm", "hex", - "hyperspace-evm-primitives", "num", "sp-core", "sp-io", @@ -3014,10 +3088,10 @@ dependencies = [ [[package]] name = "hyperspace-evm-precompile-simple" -version = "1.4.0" +version = "2.0.0" dependencies = [ + "dp-evm", "evm", - "hyperspace-evm-primitives", "ripemd160", "sp-core", "sp-io", @@ -3025,37 +3099,25 @@ dependencies = [ [[package]] name = "hyperspace-evm-precompile-withdraw" -version = "1.4.0" +version = "2.0.0" dependencies = [ + "dp-evm", "evm", "frame-support", "frame-system", "hyperspace-evm", - "hyperspace-evm-primitives", "pallet-timestamp", "parity-scale-codec 1.3.7", "ripemd160", "sp-core", "sp-io", "sp-runtime", - "sp-std 2.0.1", -] - -[[package]] -name = "hyperspace-evm-primitives" -version = "1.4.0" -dependencies = [ - "evm", - "impl-trait-for-tuples 0.2.1", - "parity-scale-codec 1.3.7", - "serde", - "sp-core", - "sp-std 2.0.1", + "sp-std", ] [[package]] name = "hyperspace-header-mmr" -version = "1.4.0" +version = "2.0.0" dependencies = [ "array-bytes", "ckb-merkle-mountain-range", @@ -3070,12 +3132,12 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 2.0.1", + "sp-std", ] [[package]] name = "hyperspace-header-mmr-rpc" -version = "1.4.0" +version = "2.0.0" dependencies = [ "hyperspace-header-mmr-rpc-runtime-api", "jsonrpc-core", @@ -3089,19 +3151,19 @@ dependencies = [ [[package]] name = "hyperspace-header-mmr-rpc-runtime-api" -version = "1.4.0" +version = "2.0.0" dependencies = [ "hyperspace-support", "parity-scale-codec 1.3.7", "serde", "sp-api", "sp-runtime", - "sp-std 2.0.1", + "sp-std", ] [[package]] name = "hyperspace-oldetp-backing" -version = "1.4.0" +version = "2.0.0" dependencies = [ "frame-support", "frame-system", @@ -3111,34 +3173,34 @@ dependencies = [ ] [[package]] -name = "hyperspace-oldna-backing" -version = "1.4.0" +name = "hyperspace-oldetp-issuing" +version = "2.0.0" dependencies = [ "frame-support", "frame-system", + "hyperspace-balances", + "hyperspace-support", "parity-scale-codec 1.3.7", "serde", + "serde_json", + "sp-io", "sp-runtime", ] [[package]] -name = "hyperspace-oldna-issuing" -version = "1.4.0" +name = "hyperspace-oldna-backing" +version = "2.0.0" dependencies = [ "frame-support", "frame-system", - "hyperspace-balances", - "hyperspace-support", "parity-scale-codec 1.3.7", "serde", - "serde_json", - "sp-io", "sp-runtime", ] [[package]] name = "hyperspace-primitives" -version = "1.0.13" +version = "2.0.0" dependencies = [ "sp-core", "sp-runtime", @@ -3146,7 +3208,7 @@ dependencies = [ [[package]] name = "hyperspace-relay-authorities" -version = "1.4.0" +version = "2.0.0" dependencies = [ "array-bytes", "frame-support", @@ -3159,22 +3221,22 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 2.0.1", + "sp-std", ] [[package]] name = "hyperspace-relay-primitives" -version = "1.4.0" +version = "2.0.0" dependencies = [ "frame-support", "parity-scale-codec 1.3.7", "sp-runtime", - "sp-std 2.0.1", + "sp-std", ] [[package]] name = "hyperspace-relayer-game" -version = "1.4.0" +version = "2.0.0" dependencies = [ "env_logger 0.8.3", "frame-support", @@ -3187,12 +3249,12 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 2.0.1", + "sp-std", ] [[package]] name = "hyperspace-runtime" -version = "1.0.13" +version = "2.0.0" dependencies = [ "dvm-ethereum", "dvm-rpc-runtime-api", @@ -3213,8 +3275,8 @@ dependencies = [ "hyperspace-header-mmr", "hyperspace-header-mmr-rpc-runtime-api", "hyperspace-oldetp-backing", + "hyperspace-oldetp-issuing", "hyperspace-oldna-backing", - "hyperspace-oldna-issuing", "hyperspace-primitives", "hyperspace-relay-authorities", "hyperspace-relay-primitives", @@ -3229,18 +3291,22 @@ dependencies = [ "pallet-babe", "pallet-collective", "pallet-grandpa", + "pallet-identity", "pallet-im-online", "pallet-membership", "pallet-multisig", "pallet-offences", "pallet-proxy", "pallet-randomness-collective-flip", + "pallet-recovery", "pallet-scheduler", "pallet-session", + "pallet-society", "pallet-sudo", "pallet-timestamp", "pallet-transaction-payment", "pallet-transaction-payment-rpc-runtime-api", + "pallet-utility", "parity-scale-codec 1.3.7", "serde", "smallvec 1.6.1", @@ -3256,7 +3322,7 @@ dependencies = [ "sp-runtime", "sp-session", "sp-staking", - "sp-std 2.0.1", + "sp-std", "sp-transaction-pool", "sp-version", "static_assertions 1.1.0", @@ -3265,7 +3331,7 @@ dependencies = [ [[package]] name = "hyperspace-staking" -version = "1.4.0" +version = "2.0.0" dependencies = [ "frame-support", "frame-system", @@ -3284,7 +3350,7 @@ dependencies = [ "sp-npos-elections", "sp-runtime", "sp-staking", - "sp-std 2.0.1", + "sp-std", "sp-storage", "sp-tracing", "static_assertions 1.1.0", @@ -3294,7 +3360,7 @@ dependencies = [ [[package]] name = "hyperspace-staking-rpc" -version = "1.4.0" +version = "2.0.0" dependencies = [ "hyperspace-staking-rpc-runtime-api", "jsonrpc-core", @@ -3308,7 +3374,7 @@ dependencies = [ [[package]] name = "hyperspace-staking-rpc-runtime-api" -version = "1.4.0" +version = "2.0.0" dependencies = [ "hyperspace-support", "parity-scale-codec 1.3.7", @@ -3319,7 +3385,7 @@ dependencies = [ [[package]] name = "hyperspace-support" -version = "1.4.0" +version = "2.0.0" dependencies = [ "ethereum-primitives", "frame-support", @@ -3327,12 +3393,12 @@ dependencies = [ "num-traits", "parity-scale-codec 1.3.7", "sp-runtime", - "sp-std 2.0.1", + "sp-std", ] [[package]] name = "hyperspace-treasury" -version = "1.4.0" +version = "2.0.0" dependencies = [ "frame-support", "frame-system", @@ -3343,13 +3409,13 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 2.0.1", + "sp-std", "sp-storage", ] [[package]] name = "hyperspace-vesting" -version = "1.4.0" +version = "2.0.0" dependencies = [ "enumflags2", "frame-support", @@ -3362,7 +3428,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 2.0.1", + "sp-std", "sp-storage", ] @@ -3518,9 +3584,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.6.1" +version = "1.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb1fa934250de4de8aef298d81c729a7d33d8c239daa3a7575e6b92bfc7313b" +checksum = "824845a0bf897a9042383849b02c1bc219c2383772efcd5c6f9766fa4b81aef3" dependencies = [ "autocfg", "hashbrown", @@ -4476,7 +4542,7 @@ checksum = "71d96e3f3c0b6325d8ccd83c33b28acb183edcb6c67938ba104ec546854b0882" [[package]] name = "merkle-patricia-trie" -version = "1.4.0" +version = "2.0.0" dependencies = [ "array-bytes", "criterion", @@ -4486,7 +4552,7 @@ dependencies = [ "keccak-hash", "rand 0.7.3", "rlp 0.4.4", - "sp-std 2.0.1", + "sp-std", "uuid", ] @@ -4919,7 +4985,7 @@ dependencies = [ [[package]] name = "pallet-authority-discovery" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "frame-support", "frame-system", @@ -4929,13 +4995,13 @@ dependencies = [ "sp-application-crypto", "sp-authority-discovery", "sp-runtime", - "sp-std 2.0.1", + "sp-std", ] [[package]] name = "pallet-authorship" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "frame-support", "frame-system", @@ -4944,13 +5010,13 @@ dependencies = [ "sp-authorship", "sp-inherents", "sp-runtime", - "sp-std 2.0.1", + "sp-std", ] [[package]] name = "pallet-babe" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "frame-benchmarking", "frame-support", @@ -4968,14 +5034,14 @@ dependencies = [ "sp-runtime", "sp-session", "sp-staking", - "sp-std 2.0.1", + "sp-std", "sp-timestamp", ] [[package]] name = "pallet-balances" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "frame-benchmarking", "frame-support", @@ -4983,13 +5049,13 @@ dependencies = [ "parity-scale-codec 1.3.7", "serde", "sp-runtime", - "sp-std 2.0.1", + "sp-std", ] [[package]] name = "pallet-collective" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "frame-support", "frame-system", @@ -4998,13 +5064,13 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 2.0.1", + "sp-std", ] [[package]] name = "pallet-grandpa" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "frame-benchmarking", "frame-support", @@ -5019,13 +5085,29 @@ dependencies = [ "sp-runtime", "sp-session", "sp-staking", - "sp-std 2.0.1", + "sp-std", +] + +[[package]] +name = "pallet-identity" +version = "2.0.1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +dependencies = [ + "enumflags2", + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec 1.3.7", + "serde", + "sp-io", + "sp-runtime", + "sp-std", ] [[package]] name = "pallet-im-online" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "frame-support", "frame-system", @@ -5038,13 +5120,13 @@ dependencies = [ "sp-io", "sp-runtime", "sp-staking", - "sp-std 2.0.1", + "sp-std", ] [[package]] name = "pallet-membership" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "frame-support", "frame-system", @@ -5052,13 +5134,13 @@ dependencies = [ "serde", "sp-io", "sp-runtime", - "sp-std 2.0.1", + "sp-std", ] [[package]] name = "pallet-multisig" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "frame-support", "frame-system", @@ -5067,13 +5149,13 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 2.0.1", + "sp-std", ] [[package]] name = "pallet-offences" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "frame-support", "frame-system", @@ -5082,13 +5164,13 @@ dependencies = [ "serde", "sp-runtime", "sp-staking", - "sp-std 2.0.1", + "sp-std", ] [[package]] name = "pallet-proxy" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "frame-support", "frame-system", @@ -5097,26 +5179,41 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 2.0.1", + "sp-std", ] [[package]] name = "pallet-randomness-collective-flip" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "frame-support", "frame-system", "parity-scale-codec 1.3.7", "safe-mix", "sp-runtime", - "sp-std 2.0.1", + "sp-std", +] + +[[package]] +name = "pallet-recovery" +version = "2.0.1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +dependencies = [ + "enumflags2", + "frame-support", + "frame-system", + "parity-scale-codec 1.3.7", + "serde", + "sp-io", + "sp-runtime", + "sp-std", ] [[package]] name = "pallet-scheduler" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "frame-benchmarking", "frame-support", @@ -5125,13 +5222,13 @@ dependencies = [ "serde", "sp-io", "sp-runtime", - "sp-std 2.0.1", + "sp-std", ] [[package]] name = "pallet-session" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "frame-support", "frame-system", @@ -5144,14 +5241,28 @@ dependencies = [ "sp-runtime", "sp-session", "sp-staking", - "sp-std 2.0.1", + "sp-std", "sp-trie", ] +[[package]] +name = "pallet-society" +version = "2.0.1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +dependencies = [ + "frame-support", + "frame-system", + "parity-scale-codec 1.3.7", + "rand_chacha 0.2.2", + "serde", + "sp-runtime", + "sp-std", +] + [[package]] name = "pallet-sudo" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "frame-support", "frame-system", @@ -5159,13 +5270,13 @@ dependencies = [ "serde", "sp-io", "sp-runtime", - "sp-std 2.0.1", + "sp-std", ] [[package]] name = "pallet-timestamp" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "frame-benchmarking", "frame-support", @@ -5175,14 +5286,14 @@ dependencies = [ "serde", "sp-inherents", "sp-runtime", - "sp-std 2.0.1", + "sp-std", "sp-timestamp", ] [[package]] name = "pallet-transaction-payment" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "frame-support", "frame-system", @@ -5192,13 +5303,13 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 2.0.1", + "sp-std", ] [[package]] name = "pallet-transaction-payment-rpc" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "jsonrpc-core", "jsonrpc-core-client", @@ -5215,7 +5326,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc-runtime-api" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "pallet-transaction-payment", "parity-scale-codec 1.3.7", @@ -5223,6 +5334,21 @@ dependencies = [ "sp-runtime", ] +[[package]] +name = "pallet-utility" +version = "2.0.1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +dependencies = [ + "frame-support", + "frame-system", + "parity-scale-codec 1.3.7", + "serde", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + [[package]] name = "parity-db" version = "0.1.2" @@ -6159,14 +6285,13 @@ dependencies = [ [[package]] name = "regex" -version = "1.4.3" +version = "1.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9251239e129e16308e70d853559389de218ac275b515068abc96829d05b948a" +checksum = "957056ecddbeba1b26965114e191d2e8589ce74db242b6ea25fc4062427a5c19" dependencies = [ "aho-corasick", "memchr", "regex-syntax", - "thread_local", ] [[package]] @@ -6181,9 +6306,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.22" +version = "0.6.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5eb417147ba9860a96cfe72a0b93bf88fee1744b5636ec99ab20c1aa9376581" +checksum = "24d5f089152e60f62d28b835fbff2cd2e8dc0baf1ac13343bef92ab7eed84548" [[package]] name = "region" @@ -6430,7 +6555,7 @@ dependencies = [ [[package]] name = "sc-authority-discovery" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "async-trait", "derive_more", @@ -6458,7 +6583,7 @@ dependencies = [ [[package]] name = "sc-basic-authorship" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "futures 0.3.13", "futures-timer 3.0.2", @@ -6481,7 +6606,7 @@ dependencies = [ [[package]] name = "sc-block-builder" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "parity-scale-codec 1.3.7", "sc-client-api", @@ -6498,7 +6623,7 @@ dependencies = [ [[package]] name = "sc-chain-spec" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "impl-trait-for-tuples 0.2.1", "parity-scale-codec 1.3.7", @@ -6519,7 +6644,7 @@ dependencies = [ [[package]] name = "sc-chain-spec-derive" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -6530,7 +6655,7 @@ dependencies = [ [[package]] name = "sc-cli" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "chrono", "fdlimit", @@ -6568,7 +6693,7 @@ dependencies = [ [[package]] name = "sc-client-api" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "derive_more", "fnv", @@ -6590,7 +6715,7 @@ dependencies = [ "sp-keystore", "sp-runtime", "sp-state-machine", - "sp-std 2.0.1", + "sp-std", "sp-storage", "sp-transaction-pool", "sp-trie", @@ -6602,7 +6727,7 @@ dependencies = [ [[package]] name = "sc-client-db" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "blake2-rfc", "hash-db", @@ -6632,7 +6757,7 @@ dependencies = [ [[package]] name = "sc-consensus" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "sc-client-api", "sp-blockchain", @@ -6643,7 +6768,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "derive_more", "fork-tree", @@ -6688,7 +6813,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe-rpc" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "derive_more", "futures 0.3.13", @@ -6712,7 +6837,7 @@ dependencies = [ [[package]] name = "sc-consensus-epochs" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "fork-tree", "parity-scale-codec 1.3.7", @@ -6725,7 +6850,7 @@ dependencies = [ [[package]] name = "sc-consensus-slots" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "futures 0.3.13", "futures-timer 3.0.2", @@ -6751,7 +6876,7 @@ dependencies = [ [[package]] name = "sc-consensus-uncles" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "log", "sc-client-api", @@ -6765,7 +6890,7 @@ dependencies = [ [[package]] name = "sc-executor" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "derive_more", "lazy_static", @@ -6794,7 +6919,7 @@ dependencies = [ [[package]] name = "sc-executor-common" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "derive_more", "parity-scale-codec 1.3.7", @@ -6810,7 +6935,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmi" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "log", "parity-scale-codec 1.3.7", @@ -6825,7 +6950,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmtime" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "log", "parity-scale-codec 1.3.7", @@ -6843,7 +6968,7 @@ dependencies = [ [[package]] name = "sc-finality-grandpa" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "derive_more", "finality-grandpa", @@ -6881,7 +7006,7 @@ dependencies = [ [[package]] name = "sc-finality-grandpa-rpc" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "derive_more", "finality-grandpa", @@ -6905,7 +7030,7 @@ dependencies = [ [[package]] name = "sc-finality-grandpa-warp-sync" version = "0.8.0" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "derive_more", "futures 0.3.13", @@ -6925,7 +7050,7 @@ dependencies = [ [[package]] name = "sc-informant" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "ansi_term 0.12.1", "futures 0.3.13", @@ -6943,7 +7068,7 @@ dependencies = [ [[package]] name = "sc-keystore" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "async-trait", "derive_more", @@ -6963,7 +7088,7 @@ dependencies = [ [[package]] name = "sc-light" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "hash-db", "lazy_static", @@ -6982,7 +7107,7 @@ dependencies = [ [[package]] name = "sc-network" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "async-std", "async-trait", @@ -7034,7 +7159,7 @@ dependencies = [ [[package]] name = "sc-network-gossip" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "futures 0.3.13", "futures-timer 3.0.2", @@ -7050,7 +7175,7 @@ dependencies = [ [[package]] name = "sc-offchain" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "bytes 0.5.6", "fnv", @@ -7077,7 +7202,7 @@ dependencies = [ [[package]] name = "sc-peerset" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "futures 0.3.13", "libp2p", @@ -7090,7 +7215,7 @@ dependencies = [ [[package]] name = "sc-proposer-metrics" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "log", "substrate-prometheus-endpoint", @@ -7099,7 +7224,7 @@ dependencies = [ [[package]] name = "sc-rpc" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "futures 0.3.13", "hash-db", @@ -7133,7 +7258,7 @@ dependencies = [ [[package]] name = "sc-rpc-api" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "derive_more", "futures 0.3.13", @@ -7157,7 +7282,7 @@ dependencies = [ [[package]] name = "sc-rpc-server" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "futures 0.1.31", "jsonrpc-core", @@ -7175,7 +7300,7 @@ dependencies = [ [[package]] name = "sc-service" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "directories 3.0.1", "exit-future", @@ -7238,7 +7363,7 @@ dependencies = [ [[package]] name = "sc-state-db" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "log", "parity-scale-codec 1.3.7", @@ -7253,7 +7378,7 @@ dependencies = [ [[package]] name = "sc-sync-state-rpc" version = "0.8.0" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "jsonrpc-core", "jsonrpc-core-client", @@ -7273,7 +7398,7 @@ dependencies = [ [[package]] name = "sc-telemetry" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "chrono", "futures 0.3.13", @@ -7295,7 +7420,7 @@ dependencies = [ [[package]] name = "sc-tracing" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "ansi_term 0.12.1", "atty", @@ -7323,7 +7448,7 @@ dependencies = [ [[package]] name = "sc-tracing-proc-macro" version = "2.0.0" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -7334,7 +7459,7 @@ dependencies = [ [[package]] name = "sc-transaction-graph" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "derive_more", "futures 0.3.13", @@ -7356,7 +7481,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "futures 0.3.13", "futures-diagnose", @@ -7527,9 +7652,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.125" +version = "1.0.124" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "558dc50e1a5a5fa7112ca2ce4effcb321b0300c0d4ccf0776a9f60cd89031171" +checksum = "bd761ff957cb2a45fbb9ab3da6512de9de55872866160b23c25f1a841e99d29f" dependencies = [ "serde_derive", ] @@ -7546,9 +7671,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.125" +version = "1.0.124" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b093b7a2bb58203b5da3056c05b4ec1fed827dcfdb37347a8841695263b3d06d" +checksum = "1800f7693e94e186f5e25a28291ae1570da908aff7d97a095dec1e56ff99069b" dependencies = [ "proc-macro2", "quote", @@ -7658,9 +7783,9 @@ checksum = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2" [[package]] name = "signal-hook" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a7f3f92a1da3d6b1d32245d0cbcbbab0cfc45996d8df619c42bccfa6d2bbb5f" +checksum = "6aa894ef3fade0ee7243422f4fbbd6c2b48e6de767e621d37ef65f2310f53cea" dependencies = [ "libc", "signal-hook-registry", @@ -7762,11 +7887,11 @@ dependencies = [ [[package]] name = "sp-allocator" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "log", "sp-core", - "sp-std 2.0.1", + "sp-std", "sp-wasm-interface", "thiserror", ] @@ -7774,7 +7899,7 @@ dependencies = [ [[package]] name = "sp-api" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "hash-db", "parity-scale-codec 1.3.7", @@ -7782,7 +7907,7 @@ dependencies = [ "sp-core", "sp-runtime", "sp-state-machine", - "sp-std 2.0.1", + "sp-std", "sp-version", "thiserror", ] @@ -7790,7 +7915,7 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "blake2-rfc", "proc-macro-crate", @@ -7802,67 +7927,67 @@ dependencies = [ [[package]] name = "sp-application-crypto" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "parity-scale-codec 1.3.7", "serde", "sp-core", "sp-io", - "sp-std 2.0.1", + "sp-std", ] [[package]] name = "sp-arithmetic" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "integer-sqrt", "num-traits", "parity-scale-codec 1.3.7", "serde", "sp-debug-derive", - "sp-std 2.0.1", + "sp-std", ] [[package]] name = "sp-authority-discovery" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "parity-scale-codec 1.3.7", "sp-api", "sp-application-crypto", "sp-runtime", - "sp-std 2.0.1", + "sp-std", ] [[package]] name = "sp-authorship" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "parity-scale-codec 1.3.7", "sp-inherents", "sp-runtime", - "sp-std 2.0.1", + "sp-std", ] [[package]] name = "sp-block-builder" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "parity-scale-codec 1.3.7", "sp-api", "sp-inherents", "sp-runtime", - "sp-std 2.0.1", + "sp-std", ] [[package]] name = "sp-blockchain" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "futures 0.3.13", "log", @@ -7880,7 +8005,7 @@ dependencies = [ [[package]] name = "sp-chain-spec" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "serde", "serde_json", @@ -7889,7 +8014,7 @@ dependencies = [ [[package]] name = "sp-consensus" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "futures 0.3.13", "futures-timer 3.0.2", @@ -7903,7 +8028,7 @@ dependencies = [ "sp-inherents", "sp-runtime", "sp-state-machine", - "sp-std 2.0.1", + "sp-std", "sp-trie", "sp-utils", "sp-version", @@ -7915,7 +8040,7 @@ dependencies = [ [[package]] name = "sp-consensus-babe" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "merlin", "parity-scale-codec 1.3.7", @@ -7928,14 +8053,14 @@ dependencies = [ "sp-inherents", "sp-keystore", "sp-runtime", - "sp-std 2.0.1", + "sp-std", "sp-timestamp", ] [[package]] name = "sp-consensus-slots" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "parity-scale-codec 1.3.7", "sp-runtime", @@ -7944,19 +8069,19 @@ dependencies = [ [[package]] name = "sp-consensus-vrf" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "parity-scale-codec 1.3.7", "schnorrkel", "sp-core", "sp-runtime", - "sp-std 2.0.1", + "sp-std", ] [[package]] name = "sp-core" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "base58", "blake2-rfc", @@ -7986,7 +8111,7 @@ dependencies = [ "sp-debug-derive", "sp-externalities", "sp-runtime-interface", - "sp-std 2.0.1", + "sp-std", "sp-storage", "substrate-bip39", "thiserror", @@ -8000,7 +8125,7 @@ dependencies = [ [[package]] name = "sp-database" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "kvdb", "parking_lot 0.11.1", @@ -8009,7 +8134,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "proc-macro2", "quote", @@ -8019,18 +8144,18 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "environmental", "parity-scale-codec 1.3.7", - "sp-std 2.0.1", + "sp-std", "sp-storage", ] [[package]] name = "sp-finality-grandpa" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "finality-grandpa", "log", @@ -8041,25 +8166,25 @@ dependencies = [ "sp-core", "sp-keystore", "sp-runtime", - "sp-std 2.0.1", + "sp-std", ] [[package]] name = "sp-inherents" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "parity-scale-codec 1.3.7", "parking_lot 0.11.1", "sp-core", - "sp-std 2.0.1", + "sp-std", "thiserror", ] [[package]] name = "sp-io" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "futures 0.3.13", "hash-db", @@ -8072,7 +8197,7 @@ dependencies = [ "sp-keystore", "sp-runtime-interface", "sp-state-machine", - "sp-std 2.0.1", + "sp-std", "sp-tracing", "sp-trie", "sp-wasm-interface", @@ -8083,7 +8208,7 @@ dependencies = [ [[package]] name = "sp-keyring" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "lazy_static", "sp-core", @@ -8094,7 +8219,7 @@ dependencies = [ [[package]] name = "sp-keystore" version = "0.8.0" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "async-trait", "derive_more", @@ -8111,20 +8236,20 @@ dependencies = [ [[package]] name = "sp-npos-elections" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "parity-scale-codec 1.3.7", "serde", "sp-arithmetic", "sp-core", "sp-npos-elections-compact", - "sp-std 2.0.1", + "sp-std", ] [[package]] name = "sp-npos-elections-compact" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -8135,7 +8260,7 @@ dependencies = [ [[package]] name = "sp-offchain" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "sp-api", "sp-core", @@ -8145,7 +8270,7 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "backtrace", ] @@ -8153,7 +8278,7 @@ dependencies = [ [[package]] name = "sp-rpc" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "serde", "sp-core", @@ -8162,7 +8287,7 @@ dependencies = [ [[package]] name = "sp-runtime" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "either", "hash256-std-hasher", @@ -8177,20 +8302,20 @@ dependencies = [ "sp-arithmetic", "sp-core", "sp-io", - "sp-std 2.0.1", + "sp-std", ] [[package]] name = "sp-runtime-interface" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "impl-trait-for-tuples 0.2.1", "parity-scale-codec 1.3.7", "primitive-types 0.8.0", "sp-externalities", "sp-runtime-interface-proc-macro", - "sp-std 2.0.1", + "sp-std", "sp-storage", "sp-tracing", "sp-wasm-interface", @@ -8200,7 +8325,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "Inflector", "proc-macro-crate", @@ -8212,7 +8337,7 @@ dependencies = [ [[package]] name = "sp-serializer" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "serde", "serde_json", @@ -8221,30 +8346,30 @@ dependencies = [ [[package]] name = "sp-session" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "parity-scale-codec 1.3.7", "sp-api", "sp-core", "sp-runtime", "sp-staking", - "sp-std 2.0.1", + "sp-std", ] [[package]] name = "sp-staking" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "parity-scale-codec 1.3.7", "sp-runtime", - "sp-std 2.0.1", + "sp-std", ] [[package]] name = "sp-state-machine" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "hash-db", "log", @@ -8256,71 +8381,66 @@ dependencies = [ "sp-core", "sp-externalities", "sp-panic-handler", - "sp-std 2.0.1", + "sp-std", "sp-trie", "thiserror", "trie-db", "trie-root", ] -[[package]] -name = "sp-std" -version = "2.0.0-rc2" -source = "git+https://github.com/new-mvs/substrate.git?branch=darwinia-develop#45b9f0a9cbf901abaa9f1fca5fe8baeed029133d" - [[package]] name = "sp-std" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" [[package]] name = "sp-storage" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "impl-serde 0.3.1", "parity-scale-codec 1.3.7", "ref-cast", "serde", "sp-debug-derive", - "sp-std 2.0.1", + "sp-std", ] [[package]] name = "sp-tasks" version = "2.0.0" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "log", "sp-core", "sp-externalities", "sp-io", "sp-runtime-interface", - "sp-std 2.0.1", + "sp-std", ] [[package]] name = "sp-timestamp" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "impl-trait-for-tuples 0.2.1", "parity-scale-codec 1.3.7", "sp-api", "sp-inherents", "sp-runtime", - "sp-std 2.0.1", + "sp-std", "wasm-timer", ] [[package]] name = "sp-tracing" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "log", "parity-scale-codec 1.3.7", - "sp-std 2.0.1", + "sp-std", "tracing", "tracing-core", "tracing-subscriber", @@ -8329,7 +8449,7 @@ dependencies = [ [[package]] name = "sp-transaction-pool" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "derive_more", "futures 0.3.13", @@ -8345,13 +8465,13 @@ dependencies = [ [[package]] name = "sp-trie" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "hash-db", "memory-db", "parity-scale-codec 1.3.7", "sp-core", - "sp-std 2.0.1", + "sp-std", "trie-db", "trie-root", ] @@ -8359,7 +8479,7 @@ dependencies = [ [[package]] name = "sp-utils" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "futures 0.3.13", "futures-core", @@ -8371,23 +8491,23 @@ dependencies = [ [[package]] name = "sp-version" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "impl-serde 0.3.1", "parity-scale-codec 1.3.7", "serde", "sp-runtime", - "sp-std 2.0.1", + "sp-std", ] [[package]] name = "sp-wasm-interface" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "impl-trait-for-tuples 0.2.1", "parity-scale-codec 1.3.7", - "sp-std 2.0.1", + "sp-std", "wasmi", ] @@ -8523,7 +8643,7 @@ dependencies = [ [[package]] name = "substrate-build-script-utils" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "platforms", ] @@ -8540,7 +8660,7 @@ dependencies = [ [[package]] name = "substrate-frame-rpc-system" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "frame-system-rpc-runtime-api", "futures 0.3.13", @@ -8563,7 +8683,7 @@ dependencies = [ [[package]] name = "substrate-prometheus-endpoint" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "async-std", "derive_more", @@ -8577,7 +8697,7 @@ dependencies = [ [[package]] name = "substrate-test-utils" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "futures 0.3.13", "substrate-test-utils-derive", @@ -8587,7 +8707,7 @@ dependencies = [ [[package]] name = "substrate-test-utils-derive" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "proc-macro-crate", "quote", @@ -8597,7 +8717,7 @@ dependencies = [ [[package]] name = "substrate-wasm-builder" version = "3.0.0" -source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" +source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" dependencies = [ "ansi_term 0.12.1", "atty", @@ -8623,9 +8743,9 @@ checksum = "1e81da0851ada1f3e9d4312c704aa4f8806f0f9d69faaf8df2f3464b4a9437c2" [[package]] name = "syn" -version = "1.0.61" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed22b90a0e734a23a7610f4283ac9e5acfb96cbb30dfefa540d66f866f1c09c5" +checksum = "3fd9d1e9976102a03c542daa2eff1b43f9d72306342f3f8b3ed5fb8908195d6f" dependencies = [ "proc-macro2", "quote", @@ -9115,9 +9235,9 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.13" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8a9bd1db7706f2373a190b0d067146caa39350c486f3d455b0e33b431f94c07" +checksum = "c42e6fa53307c8a17e4ccd4dc81cf5ec38db9209f59b222210375b54ee40d1e2" dependencies = [ "proc-macro2", "quote", @@ -9166,9 +9286,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ab8966ac3ca27126141f7999361cc97dd6fb4b71da04c02044fa9045d98bb96" +checksum = "705096c6f83bf68ea5d357a6aa01829ddbdac531b357b45abeca842938085baa" dependencies = [ "ansi_term 0.12.1", "chrono", @@ -9246,9 +9366,9 @@ dependencies = [ [[package]] name = "typenum" -version = "1.12.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33" +checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06" [[package]] name = "ucd-trie" diff --git a/Cargo.toml b/Cargo.toml index 638a4f7..b84a1fd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,28 +1,28 @@ [workspace] members = [ - # node "bin/node/cli", "bin/node/primitives", "bin/node/runtime/hyperspace", - # client "client/cli", "client/dvm/consensus", + "client/dvm/db", + "client/dvm/mapping-sync", "client/dvm/rpc", - # frame "frame/balances", "frame/balances/rpc", "frame/balances/rpc/runtime-api", - "frame/bridge/oldna/backing", - "frame/bridge/oldna/issuing", + "frame/bridge/oldetp/backing", + "frame/bridge/oldetp/issuing", "frame/bridge/ethereum/backing", "frame/bridge/ethereum/linear-relay", "frame/bridge/ethereum/relay", "frame/bridge/relayer-game", "frame/bridge/relay-authorities", - "frame/bridge/oldetp/backing", + "frame/bridge/oldna/backing", "frame/claims", "frame/democracy", "frame/dvm", + "frame/dvm-dynamic-fee", "frame/dvm/rpc", "frame/dvm/rpc/runtime-api", "frame/elections-phragmen", @@ -46,13 +46,13 @@ members = [ "frame/support", "frame/treasury", "frame/vesting", - # primitives "primitives/consensus", - "primitives/dvm-rpc-core", "primitives/ethereum-primitives", "primitives/evm", "primitives/merkle-patricia-trie", "primitives/relay", + "primitives/rpc", + "primitives/storage", ] # The list of dependencies below (which can be both direct and indirect dependencies) are crates diff --git a/bin/node/cli/Cargo.toml b/bin/node/cli/Cargo.toml index 40ec668..1aefb49 100644 --- a/bin/node/cli/Cargo.toml +++ b/bin/node/cli/Cargo.toml @@ -8,7 +8,7 @@ license = "GPL-3.0" name = "hyperspace" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "1.0.13" +version = "2.0.0" # TODO: Consider rename this repo to hyperspace-runtime-module-library [[bin]] @@ -16,6 +16,7 @@ name = "hyperspace" [dependencies] # crates +array-bytes = { version = "1.1.0" } codec = { package = "parity-scale-codec", version = "1.3.7" } futures = { version = "0.3.13" } jsonrpc-core = { version = "15.1.0" } @@ -24,7 +25,6 @@ log = { version = "0.4.14" } structopt = { version = "0.3.21" } tokio = { version = "0.3.6", optional = true, features = ["rt-multi-thread"] } # hyperspace -array-bytes = { version = "1.1.0" } hyperspace-balances-rpc = { path = "../../../frame/balances/rpc" } hyperspace-balances-rpc-runtime-api = { path = "../../../frame/balances/rpc/runtime-api" } hyperspace-claims = { path = "../../../frame/claims" } @@ -36,58 +36,63 @@ hyperspace-header-mmr-rpc-runtime-api = { path = "../../../frame/header-mmr/rpc/ hyperspace-staking = { path = "../../../frame/staking" } hyperspace-staking-rpc = { path = "../../../frame/staking/rpc" } hyperspace-staking-rpc-runtime-api = { path = "../../../frame/staking/rpc/runtime-api" } +dc-consensus = { path = "../../../client/dvm/consensus" } +dc-db = { path = "../../../client/dvm/db" } +dc-mapping-sync = { path = "../../../client/dvm/mapping-sync" } +dc-rpc = { path = "../../../client/dvm/rpc", features = ["rpc_binary_search_estimate"] } +dp-rpc = { path = "../../../primitives/rpc" } +dp_consensus = { path = "../../../primitives/consensus" } hyperspace-primitives = { path = "../primitives" } -dvm-consensus = { path = "../../../client/dvm/consensus" } -dvm-rpc = { path = "../../../client/dvm/rpc" } +dvm-ethereum = { path = "../../../frame/dvm" } dvm-rpc-runtime-api = { path = "../../../frame/dvm/rpc/runtime-api" } hyperspace-runtime = { path = "../runtime/hyperspace" } # substrate -frame-system-rpc-runtime-api = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -pallet-im-online = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -pallet-transaction-payment-rpc = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sc-authority-discovery = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sc-basic-authorship = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sc-chain-spec = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sc-cli = { optional = true, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sc-client-api = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sc-consensus = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sc-consensus-babe = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sc-consensus-babe-rpc = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sc-consensus-epochs = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sc-consensus-slots = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sc-executor = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sc-finality-grandpa = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sc-finality-grandpa-rpc = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sc-finality-grandpa-warp-sync = { optional = true, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sc-keystore = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sc-network = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sc-rpc = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sc-service = { optional = true, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sc-sync-state-rpc = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sc-telemetry = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sc-transaction-pool = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-api = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-authority-discovery = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-block-builder = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-blockchain = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-consensus = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-consensus-babe = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-core = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-finality-grandpa = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-inherents = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-keystore = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-offchain = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-runtime = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-session = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-transaction-pool = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-trie = { features = ["memory-tracker"], git = "https://github.com/new-mvs/substrate", branch = "latest" } -substrate-frame-rpc-system = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -substrate-prometheus-endpoint = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +frame-system-rpc-runtime-api = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +pallet-im-online = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +pallet-transaction-payment-rpc = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sc-authority-discovery = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sc-basic-authorship = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sc-chain-spec = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sc-cli = { optional = true, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sc-client-api = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sc-consensus = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sc-consensus-babe = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sc-consensus-babe-rpc = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sc-consensus-epochs = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sc-consensus-slots = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sc-executor = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sc-finality-grandpa = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sc-finality-grandpa-rpc = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sc-finality-grandpa-warp-sync = { optional = true, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sc-keystore = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sc-network = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sc-rpc = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sc-service = { optional = true, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sc-sync-state-rpc = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sc-telemetry = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sc-transaction-pool = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-api = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-authority-discovery = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-block-builder = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-blockchain = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-consensus = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-consensus-babe = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-core = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-finality-grandpa = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-inherents = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-keystore = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-offchain = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-runtime = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-session = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-transaction-pool = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-trie = { features = ["memory-tracker"], git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +substrate-frame-rpc-system = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +substrate-prometheus-endpoint = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [build-dependencies] # substrate -substrate-build-script-utils = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +substrate-build-script-utils = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [features] default = [ diff --git a/bin/node/cli/src/chain_spec.rs b/bin/node/cli/src/chain_spec.rs index da9ee68..0653254 100644 --- a/bin/node/cli/src/chain_spec.rs +++ b/bin/node/cli/src/chain_spec.rs @@ -41,7 +41,7 @@ pub type HyperspaceChainSpec = sc_service::GenericChainSpec; type AccountPublic = ::Signer; -const PANGOLIN_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/"; +const HYPERSPACE_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/"; pub fn hyperspace_config() -> Result { HyperspaceChainSpec::from_json_bytes(&include_bytes!("../../../res/hyperspace/hyperspace.json")[..]) @@ -64,9 +64,9 @@ pub fn hyperspace_session_keys( pub fn properties() -> Properties { let mut properties = Properties::new(); - properties.insert("ss58Format".into(),150.into()); - properties.insert("tokenDecimals".into(), vec![8, 8].into()); - properties.insert("tokenSymbol".into(), vec!["ETP", "DNA"].into()); + properties.insert("ss58Format".into(), 18.into()); + properties.insert("tokenDecimals".into(), vec![9, 9].into()); + properties.insert("tokenSymbol".into(), vec!["PETP", "PDNA"].into()); properties } @@ -112,7 +112,7 @@ pub fn hyperspace_build_spec_config() -> HyperspaceChainSpec { hyperspace_build_spec_genesis, vec![], Some( - TelemetryEndpoints::new(vec![(PANGOLIN_TELEMETRY_URL.to_string(), 0)]) + TelemetryEndpoints::new(vec![(HYPERSPACE_TELEMETRY_URL.to_string(), 0)]) .expect("Hyperspace telemetry url is valid; qed"), ), None, @@ -196,10 +196,10 @@ fn hyperspace_build_spec_genesis() -> GenesisConfig { hyperspace_claims: Some(Default::default()), hyperspace_vesting: Some(Default::default()), pallet_sudo: Some(SudoConfig { key: root.clone() }), - hyperspace_oldna_issuing: Some(OldnaIssuingConfig { + hyperspace_oldetp_issuing: Some(OldetpIssuingConfig { total_mapped_etp: 1 << 56 }), - hyperspace_oldna_backing: Some(OldnaBackingConfig { + hyperspace_oldetp_backing: Some(OldetpBackingConfig { backed_etp: 1 << 56 }), hyperspace_ethereum_backing: Some(EthereumBackingConfig { @@ -222,7 +222,7 @@ fn hyperspace_build_spec_genesis() -> GenesisConfig { ), ..Default::default() }), - hyperspace_oldetp_backing: Some(OldetpBackingConfig { + hyperspace_oldna_backing: Some(OldnaBackingConfig { backed_etp: 1 << 56, backed_dna: 1 << 56, }), @@ -367,10 +367,10 @@ fn hyperspace_development_genesis( }), hyperspace_vesting: Some(Default::default()), pallet_sudo: Some(SudoConfig { key: root_key.clone() }), - hyperspace_oldna_issuing: Some(OldnaIssuingConfig { + hyperspace_oldetp_issuing: Some(OldetpIssuingConfig { total_mapped_etp: 1 << 56 }), - hyperspace_oldna_backing: Some(OldnaBackingConfig { + hyperspace_oldetp_backing: Some(OldetpBackingConfig { backed_etp: 1 << 56 }), hyperspace_ethereum_backing: Some(EthereumBackingConfig { @@ -393,7 +393,7 @@ fn hyperspace_development_genesis( ), ..Default::default() }), - hyperspace_oldetp_backing: Some(OldetpBackingConfig { + hyperspace_oldna_backing: Some(OldnaBackingConfig { backed_etp: 1 << 56, backed_dna: 1 << 56, }), diff --git a/bin/node/cli/src/command.rs b/bin/node/cli/src/command.rs index 98cd1f8..90af112 100644 --- a/bin/node/cli/src/command.rs +++ b/bin/node/cli/src/command.rs @@ -30,7 +30,7 @@ use hyperspace_cli::{Configuration, HyperspaceCli}; impl SubstrateCli for Cli { fn impl_name() -> String { - "Hyperspace Node".into() + "Hyperspace Runtime Module Library".into() } fn impl_version() -> String { @@ -46,7 +46,7 @@ impl SubstrateCli for Cli { } fn support_url() -> String { - "https://github.com/mvs/Hyperspace/issues/new".into() + "https://github.com/mvs-org/Hyperspaceissues/new".into() } fn copyright_start_year() -> i32 { diff --git a/bin/node/cli/src/rpc.rs b/bin/node/cli/src/rpc.rs index 7c0feac..e56c263 100644 --- a/bin/node/cli/src/rpc.rs +++ b/bin/node/cli/src/rpc.rs @@ -22,7 +22,7 @@ //! about the modules used inside the runtime, so do //! RPC methods defined in `sc-rpc` crate. //! It means that `client/rpc` can't have any methods that -//! need some soldetpg assumptions about the particular runtime. +//! need some soldnag assumptions about the particular runtime. //! //! The RPCs available in this crate however can make some assumptions //! about how the runtime is constructed and what FRAME pallets @@ -35,9 +35,11 @@ pub use sc_rpc::{DenyUnsafe, SubscriptionTaskExecutor}; // --- std --- -use std::sync::Arc; +use std::{collections::BTreeMap, sync::Arc}; // --- hyperspace --- +use dp_rpc::{FilterPool, PendingTransactions}; use hyperspace_primitives::{AccountId, Balance, BlockNumber, Hash, Nonce, OpaqueBlock as Block, Power}; +use dvm_ethereum::EthereumStorageSchema; /// A type representing all RPC extensions. pub type RpcExtension = jsonrpc_core::IoHandler; @@ -87,6 +89,12 @@ pub struct FullDeps { pub babe: BabeDeps, /// GRANDPA specific dependencies. pub grandpa: GrandpaDeps, + /// Ethereum pending transactions. + pub pending_transactions: PendingTransactions, + /// EthFilterApi pool. + pub filter_pool: Option, + /// Backend. + pub backend: Arc>, } /// Light client extra dependencies. @@ -142,9 +150,10 @@ where use hyperspace_balances_rpc::{Balances, BalancesApi}; use hyperspace_header_mmr_rpc::{HeaderMMR, HeaderMMRApi}; use hyperspace_staking_rpc::{Staking, StakingApi}; - use dvm_rpc::{ - EthApi, EthApiServer, EthPubSubApi, EthPubSubApiServer, HexEncodedIdProvider, NetApi, - NetApiServer, Web3Api, Web3ApiServer, + use dc_rpc::{ + EthApi, EthApiServer, EthFilterApi, EthFilterApiServer, EthPubSubApi, EthPubSubApiServer, + HexEncodedIdProvider, NetApi, NetApiServer, SchemaV1Override, StorageOverride, Web3Api, + Web3ApiServer, }; use hyperspace_runtime::TransactionConverter; @@ -158,6 +167,9 @@ where network, babe, grandpa, + pending_transactions, + filter_pool, + backend, } = deps; let mut io = jsonrpc_core::IoHandler::default(); @@ -206,13 +218,30 @@ where io.extend_with(BalancesApi::to_delegate(Balances::new(client.clone()))); io.extend_with(HeaderMMRApi::to_delegate(HeaderMMR::new(client.clone()))); io.extend_with(StakingApi::to_delegate(Staking::new(client.clone()))); + + let mut overrides = BTreeMap::new(); + overrides.insert( + EthereumStorageSchema::V1, + Box::new(SchemaV1Override::new(client.clone())) + as Box + Send + Sync>, + ); io.extend_with(EthApiServer::to_delegate(EthApi::new( client.clone(), pool.clone(), TransactionConverter, network.clone(), + overrides, + pending_transactions.clone(), + backend, is_authority, ))); + if let Some(filter_pool) = filter_pool { + io.extend_with(EthFilterApiServer::to_delegate(EthFilterApi::new( + client.clone(), + filter_pool.clone(), + 500 as usize, // max stored filters + ))); + } io.extend_with(EthPubSubApiServer::to_delegate(EthPubSubApi::new( pool, client.clone(), diff --git a/bin/node/cli/src/service.rs b/bin/node/cli/src/service.rs index 6045257..709dfef 100644 --- a/bin/node/cli/src/service.rs +++ b/bin/node/cli/src/service.rs @@ -24,10 +24,17 @@ pub use sc_executor::NativeExecutor; pub use hyperspace_runtime; // --- std --- -use std::{sync::Arc, time::Duration}; +use std::{ + collections::{BTreeMap, HashMap}, + sync::{Arc, Mutex}, + time::Duration, +}; +// --- crates.io --- +use futures::StreamExt; // --- substrate --- use sc_basic_authorship::ProposerFactory; -use sc_client_api::{ExecutorProvider, RemoteBackend, StateBackendFor}; +use sc_cli::SubstrateCli; +use sc_client_api::{BlockchainEvents, ExecutorProvider, RemoteBackend, StateBackendFor}; use sc_consensus::LongestChain; use sc_consensus_babe::{BabeBlockImport, BabeLink, BabeParams, Config as BabeConfig}; use sc_executor::{native_executor_instance, NativeExecutionDispatch}; @@ -40,7 +47,7 @@ use sc_keystore::LocalKeystore; use sc_network::NetworkService; use sc_service::{ config::{KeystoreConfig, PrometheusConfig}, - BuildNetworkParams, Configuration, Error as ServiceError, NoopRpcExtensionBuilder, + BasePath, BuildNetworkParams, Configuration, Error as ServiceError, NoopRpcExtensionBuilder, PartialComponents, RpcHandlers, SpawnTasksParams, TaskManager, }; use sc_telemetry::{TelemetryConnectionNotifier, TelemetrySpan}; @@ -58,8 +65,12 @@ use crate::rpc::{ self, BabeDeps, DenyUnsafe, FullDeps, GrandpaDeps, LightDeps, RpcExtension, SubscriptionTaskExecutor, }; +use dc_consensus::FrontierBlockImport; +use dc_db::{Backend, DatabaseSettings, DatabaseSettingsSrc}; +use dc_mapping_sync::MappingSyncWorker; +use dc_rpc::EthTask; +use dp_rpc::{FilterPool, PendingTransactions}; use hyperspace_primitives::{AccountId, Balance, Hash, Nonce, OpaqueBlock as Block, Power}; -use dvm_consensus::FrontierBlockImport; type FullBackend = sc_service::TFullBackend; type FullSelectChain = sc_consensus::LongestChain; @@ -122,9 +133,9 @@ where { } -/// DRML client abstraction, this super trait only pulls in functionality required for -/// DRML internal crates like DRML-collator. -pub trait DRMLClient: +/// HYPERSPACE client abstraction, this super trait only pulls in functionality required for +/// HYPERSPACE internal crates like HYPERSPACE-collator. +pub trait HYPERSPACEClient: Sized + Send + Sync @@ -138,7 +149,7 @@ where Runtime: sp_api::ConstructRuntimeApi, { } -impl DRMLClient for Client +impl HYPERSPACEClient for Client where Backend: sc_client_api::Backend, Block: sp_runtime::traits::Block, @@ -155,12 +166,31 @@ where fn set_prometheus_registry(config: &mut Configuration) -> Result<(), ServiceError> { if let Some(PrometheusConfig { registry, .. }) = config.prometheus_config.as_mut() { - *registry = Registry::new_custom(Some("DRML".into()), None)?; + *registry = Registry::new_custom(Some("HYPERSPACE".into()), None)?; } Ok(()) } +fn open_frontier_backend(config: &Configuration) -> Result>, String> { + let config_dir = config + .base_path + .as_ref() + .map(|base_path| base_path.config_dir(config.chain_spec.id())) + .unwrap_or_else(|| { + BasePath::from_project("", "", &crate::cli::Cli::executable_name()) + .config_dir(config.chain_spec.id()) + }); + let database_dir = config_dir.join("dvm").join("db"); + + Ok(Arc::new(Backend::::new(&DatabaseSettings { + source: DatabaseSettingsSrc::RocksDb { + path: database_dir, + cache_size: 0, + }, + })?)) +} + #[cfg(feature = "full-node")] fn new_partial( config: &mut Configuration, @@ -193,6 +223,9 @@ fn new_partial( ), GrandpaSharedVoterState, Option, + PendingTransactions, + Arc>, + Option, ), >, ServiceError, @@ -224,6 +257,7 @@ where task_manager.spawn_handle(), client.clone(), ); + let frontier_backend = open_frontier_backend(config)?; let grandpa_hard_forks = vec![]; let (grandpa_block_import, grandpa_link) = sc_finality_grandpa::block_import_with_authority_set_hard_forks( @@ -233,8 +267,11 @@ where grandpa_hard_forks, )?; let justification_import = grandpa_block_import.clone(); - let frontier_block_import = - FrontierBlockImport::new(grandpa_block_import.clone(), client.clone(), true); + let frontier_block_import = FrontierBlockImport::new( + grandpa_block_import.clone(), + client.clone(), + frontier_backend.clone(), + ); let (babe_import, babe_link) = sc_consensus_babe::block_import( BabeConfig::get_or_compute(&*client)?, frontier_block_import, @@ -263,12 +300,17 @@ where let babe_config = babe_link.config().clone(); let shared_epoch_changes = babe_link.epoch_changes().clone(); let subscription_task_executor = SubscriptionTaskExecutor::new(task_manager.spawn_handle()); + let pending_transactions: PendingTransactions = Some(Arc::new(Mutex::new(HashMap::new()))); + let filter_pool: Option = Some(Arc::new(Mutex::new(BTreeMap::new()))); let rpc_extensions_builder = { let client = client.clone(); let keystore = keystore_container.sync_keystore(); let transaction_pool = transaction_pool.clone(); let select_chain = select_chain.clone(); let chain_spec = config.chain_spec.cloned_box(); + let pending_transactions = pending_transactions.clone(); + let frontier_backend = frontier_backend.clone(); + let filter_pool = filter_pool.clone(); move |deny_unsafe, is_authority, network, subscription_executor| -> RpcExtension { let deps = FullDeps { @@ -291,6 +333,9 @@ where subscription_executor, finality_provider: finality_proof_provider.clone(), }, + pending_transactions: pending_transactions.clone(), + backend: frontier_backend.clone(), + filter_pool: filter_pool.clone(), }; rpc::create_full(deps, subscription_task_executor.clone()) @@ -311,6 +356,9 @@ where import_setup, rpc_setup, telemetry_span, + pending_transactions, + frontier_backend, + filter_pool, ), }) } @@ -357,7 +405,16 @@ where import_queue, transaction_pool, inherent_data_providers, - other: (rpc_extensions_builder, import_setup, rpc_setup, telemetry_span), + other: + ( + rpc_extensions_builder, + import_setup, + rpc_setup, + telemetry_span, + pending_transactions, + frontier_backend, + filter_pool, + ), } = new_partial::(&mut config)?; if let Some(url) = &config.keystore_remote { @@ -506,7 +563,6 @@ where } if role.is_authority() && !authority_discovery_disabled { - use futures::StreamExt; use sc_network::Event; let authority_discovery_role = @@ -534,6 +590,41 @@ where ); } + // Spawn Frontier pending transactions maintenance task (as essential, otherwise we leak). + if let Some(pending_transactions) = pending_transactions { + const TRANSACTION_RETAIN_THRESHOLD: u64 = 5; + task_manager.spawn_essential_handle().spawn( + "frontier-pending-transactions", + EthTask::pending_transaction_task( + Arc::clone(&client), + pending_transactions, + TRANSACTION_RETAIN_THRESHOLD, + ), + ); + } + + task_manager.spawn_essential_handle().spawn( + "frontier-mapping-sync-worker", + MappingSyncWorker::new( + client.import_notification_stream(), + Duration::new(6, 0), + client.clone(), + backend.clone(), + frontier_backend.clone(), + ) + .for_each(|()| futures::future::ready(())), + ); + + // Spawn Frontier EthFilterApi maintenance task. + if let Some(filter_pool) = filter_pool { + // Each filter is allowed to stay in the pool for 100 blocks. + const FILTER_RETAIN_THRESHOLD: u64 = 100; + task_manager.spawn_essential_handle().spawn( + "frontier-filter-pool", + EthTask::filter_pool_task(Arc::clone(&client), filter_pool, FILTER_RETAIN_THRESHOLD), + ); + } + network_starter.start_network(); Ok((task_manager, client, rpc_handlers)) @@ -680,7 +771,7 @@ where Ok((client, backend, import_queue, task_manager)) } -/// Create a new DRML service for a full node. +/// Create a new HYPERSPACE service for a full node. #[cfg(feature = "full-node")] pub fn hyperspace_new_full( config: Configuration, @@ -688,7 +779,7 @@ pub fn hyperspace_new_full( ) -> Result< ( TaskManager, - Arc>, + Arc>, RpcHandlers, ), ServiceError, @@ -701,7 +792,7 @@ pub fn hyperspace_new_full( Ok((components, client, rpc_handlers)) } -/// Create a new DRML service for a light client. +/// Create a new HYPERSPACE service for a light client. pub fn hyperspace_new_light( config: Configuration, ) -> Result< diff --git a/bin/node/primitives/Cargo.toml b/bin/node/primitives/Cargo.toml index f6d2f99..1bbd6dd 100644 --- a/bin/node/primitives/Cargo.toml +++ b/bin/node/primitives/Cargo.toml @@ -1,18 +1,18 @@ [package] authors = ["Hyperspace Network "] -description = "DRML node runtime primitives" +description = "HYPERSPACE node runtime primitives" edition = "2018" homepage = "https://mvs.org/" license = "GPL-3.0" name = "hyperspace-primitives" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "1.0.13" +version = "2.0.0" [dependencies] # substrate -sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [features] default = ["std"] diff --git a/bin/node/primitives/src/lib.rs b/bin/node/primitives/src/lib.rs index 30ba107..4188cc9 100644 --- a/bin/node/primitives/src/lib.rs +++ b/bin/node/primitives/src/lib.rs @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License // along with Hyperspace. If not, see . -//! DRML types shared between the runtime and the Node-side code. +//! HYPERSPACE types shared between the runtime and the Node-side code. #![cfg_attr(not(feature = "std"), no_std)] #![warn(missing_docs)] diff --git a/bin/node/runtime/hyperspace/Cargo.toml b/bin/node/runtime/hyperspace/Cargo.toml index bca743e..f99987e 100644 --- a/bin/node/runtime/hyperspace/Cargo.toml +++ b/bin/node/runtime/hyperspace/Cargo.toml @@ -6,8 +6,8 @@ homepage = "https://mvs.org/" license = "Unlicense" name = "hyperspace-runtime" readme = "README.md" -repository = "https://github.com/new-mvs/darwinia-common/" -version = "1.0.13" +repository = "https://github.com/mvs-org/Hyperspace" +version = "2.0.0" [dependencies] # crates @@ -19,8 +19,8 @@ static_assertions = { version = "1.1.0" } hyperspace-balances = { default-features = false, path = "../../../../frame/balances" } hyperspace-balances-rpc-runtime-api = { default-features = false, path = "../../../../frame/balances/rpc/runtime-api" } hyperspace-claims = { default-features = false, path = "../../../../frame/claims" } -hyperspace-oldna-backing = { default-features = false, path = "../../../../frame/bridge/oldna/backing" } -hyperspace-oldna-issuing = { default-features = false, path = "../../../../frame/bridge/oldna/issuing" } +hyperspace-oldetp-backing = { default-features = false, path = "../../../../frame/bridge/oldetp/backing" } +hyperspace-oldetp-issuing = { default-features = false, path = "../../../../frame/bridge/oldetp/issuing" } hyperspace-democracy = { default-features = false, path = "../../../../frame/democracy" } hyperspace-elections-phragmen = { default-features = false, path = "../../../../frame/elections-phragmen" } hyperspace-ethereum-backing = { default-features = false, path = "../../../../frame/bridge/ethereum/backing" } @@ -36,54 +36,57 @@ hyperspace-staking = { default-features = false, path = "../. hyperspace-staking-rpc-runtime-api = { default-features = false, path = "../../../../frame/staking/rpc/runtime-api" } hyperspace-support = { default-features = false, path = "../../../../frame/support" } hyperspace-treasury = { default-features = false, path = "../../../../frame/treasury" } -hyperspace-oldetp-backing = { default-features = false, path = "../../../../frame/bridge/oldetp/backing" } +hyperspace-oldna-backing = { default-features = false, path = "../../../../frame/bridge/oldna/backing" } hyperspace-vesting = { default-features = false, path = "../../../../frame/vesting" } hyperspace-primitives = { default-features = false, path = "../../primitives" } dvm-ethereum = { default-features = false, path = "../../../../frame/dvm" } dvm-rpc-runtime-api = { default-features = false, path = "../../../../frame/dvm/rpc/runtime-api" } ethereum-primitives = { default-features = false, path = "../../../../primitives/ethereum-primitives" } # substrate -frame-executive = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -frame-system-rpc-runtime-api = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -pallet-authority-discovery = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -pallet-authorship = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -pallet-babe = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -pallet-collective = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -pallet-grandpa = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -pallet-im-online = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -pallet-membership = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -# Multisig -pallet-multisig = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -pallet-offences = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -pallet-proxy = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -pallet-randomness-collective-flip = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -pallet-scheduler = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -pallet-session = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -pallet-sudo = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -pallet-timestamp = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -pallet-transaction-payment = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -pallet-transaction-payment-rpc-runtime-api = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-api = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-application-crypto = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-authority-discovery = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-block-builder = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-consensus-babe = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-inherents = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-offchain = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-session = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-staking = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-transaction-pool = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-version = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +frame-executive = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +frame-system-rpc-runtime-api = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +pallet-authority-discovery = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +pallet-authorship = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +pallet-babe = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +pallet-collective = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +pallet-grandpa = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +pallet-identity = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +pallet-im-online = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +pallet-membership = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +pallet-multisig = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +pallet-offences = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +pallet-proxy = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +pallet-randomness-collective-flip = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +pallet-recovery = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +pallet-scheduler = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +pallet-session = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +pallet-society = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +pallet-sudo = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +pallet-timestamp = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +pallet-transaction-payment = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +pallet-transaction-payment-rpc-runtime-api = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +pallet-utility = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-api = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-application-crypto = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-authority-discovery = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-block-builder = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-consensus-babe = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-inherents = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-offchain = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-session = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-staking = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-transaction-pool = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-version = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [build-dependencies] # substrate -substrate-wasm-builder = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +substrate-wasm-builder = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [features] default = ["std"] @@ -93,8 +96,8 @@ std = [ "hyperspace-balances/std", "hyperspace-balances-rpc-runtime-api/std", "hyperspace-claims/std", - "hyperspace-oldna-backing/std", - "hyperspace-oldna-issuing/std", + "hyperspace-oldetp-backing/std", + "hyperspace-oldetp-issuing/std", "hyperspace-democracy/std", "hyperspace-elections-phragmen/std", "hyperspace-ethereum-backing/std", @@ -110,7 +113,7 @@ std = [ "hyperspace-staking-rpc-runtime-api/std", "hyperspace-support/std", "hyperspace-treasury/std", - "hyperspace-oldetp-backing/std", + "hyperspace-oldna-backing/std", "hyperspace-vesting/std", "hyperspace-primitives/std", "dvm-ethereum/std", @@ -125,18 +128,22 @@ std = [ "pallet-babe/std", "pallet-collective/std", "pallet-grandpa/std", + "pallet-identity/std", "pallet-im-online/std", "pallet-membership/std", "pallet-multisig/std", "pallet-offences/std", "pallet-proxy/std", "pallet-randomness-collective-flip/std", + "pallet-recovery/std", "pallet-scheduler/std", "pallet-session/std", + "pallet-society/std", "pallet-sudo/std", "pallet-timestamp/std", "pallet-transaction-payment/std", "pallet-transaction-payment-rpc-runtime-api/std", + "pallet-utility/std", "sp-api/std", "sp-application-crypto/std", "sp-authority-discovery/std", diff --git a/bin/node/runtime/hyperspace/src/authority_discovery.rs b/bin/node/runtime/hyperspace/src/authority_discovery.rs new file mode 100644 index 0000000..332ab36 --- /dev/null +++ b/bin/node/runtime/hyperspace/src/authority_discovery.rs @@ -0,0 +1,6 @@ +// --- substrate --- +use pallet_authority_discovery::Config; +// --- hyperspace --- +use crate::*; + +impl Config for Runtime {} diff --git a/bin/node/runtime/hyperspace/src/authorship.rs b/bin/node/runtime/hyperspace/src/authorship.rs new file mode 100644 index 0000000..6476ce7 --- /dev/null +++ b/bin/node/runtime/hyperspace/src/authorship.rs @@ -0,0 +1,15 @@ +// --- substrate --- +use pallet_authorship::Config; +use pallet_session::FindAccountFromAuthorIndex; +// --- hyperspace --- +use crate::*; + +frame_support::parameter_types! { + pub const UncleGenerations: BlockNumber = 5; +} +impl Config for Runtime { + type FindAuthor = FindAccountFromAuthorIndex; + type UncleGenerations = UncleGenerations; + type FilterUncle = (); + type EventHandler = (Staking, ImOnline); +} diff --git a/bin/node/runtime/hyperspace/src/babe.rs b/bin/node/runtime/hyperspace/src/babe.rs new file mode 100644 index 0000000..394a5f8 --- /dev/null +++ b/bin/node/runtime/hyperspace/src/babe.rs @@ -0,0 +1,25 @@ +// --- substrate --- +use frame_support::traits::KeyOwnerProofSystem; +use pallet_babe::{AuthorityId, Config, EquivocationHandler, ExternalTrigger}; +use sp_core::crypto::KeyTypeId; +// --- hyperspace --- +use crate::*; + +frame_support::parameter_types! { + pub const EpochDuration: u64 = BLOCKS_PER_SESSION as _; + pub const ExpectedBlockTime: Moment = MILLISECS_PER_BLOCK; +} +impl Config for Runtime { + type EpochDuration = EpochDuration; + type ExpectedBlockTime = ExpectedBlockTime; + type EpochChangeTrigger = ExternalTrigger; + type KeyOwnerProofSystem = Historical; + type KeyOwnerProof = + >::Proof; + type KeyOwnerIdentification = >::IdentificationTuple; + type HandleEquivocation = EquivocationHandler; + type WeightInfo = (); +} diff --git a/bin/node/runtime/hyperspace/src/balances.rs b/bin/node/runtime/hyperspace/src/balances.rs new file mode 100644 index 0000000..16277e2 --- /dev/null +++ b/bin/node/runtime/hyperspace/src/balances.rs @@ -0,0 +1,40 @@ +// --- hyperspace --- +pub use hyperspace_balances::{Instance0 as EtpInstance, Instance1 as DnaInstance}; + +// --- substrate --- +use frame_support::traits::Currency; +use frame_system::Config as SystemConfig; +// --- hyperspace --- +use crate::*; +use hyperspace_balances::{weights::SubstrateWeight, Config, Module}; + +pub type NegativeImbalance = as Currency< + ::AccountId, +>>::NegativeImbalance; + +frame_support::parameter_types! { + pub const ExistentialDeposit: Balance = 0; + pub const MaxLocks: u32 = 50; +} +impl Config for Runtime { + type Balance = Balance; + type DustRemoval = (); + type Event = Event; + type ExistentialDeposit = ExistentialDeposit; + type BalanceInfo = AccountData; + type AccountStore = System; + type MaxLocks = MaxLocks; + type OtherCurrencies = (Dna,); + type WeightInfo = SubstrateWeight; +} +impl Config for Runtime { + type Balance = Balance; + type DustRemoval = (); + type Event = Event; + type ExistentialDeposit = ExistentialDeposit; + type BalanceInfo = AccountData; + type AccountStore = System; + type MaxLocks = MaxLocks; + type OtherCurrencies = (Etp,); + type WeightInfo = SubstrateWeight; +} diff --git a/bin/node/runtime/hyperspace/src/claims.rs b/bin/node/runtime/hyperspace/src/claims.rs new file mode 100644 index 0000000..658bbd4 --- /dev/null +++ b/bin/node/runtime/hyperspace/src/claims.rs @@ -0,0 +1,17 @@ +// --- substrate --- +use sp_runtime::ModuleId; +// --- hyperspace --- +use crate::*; +use hyperspace_claims::Config; + +frame_support::parameter_types! { + pub const ClaimsModuleId: ModuleId = ModuleId(*b"da/claim"); + pub Prefix: &'static [u8] = b"Pay PETPs to the Hyperspace account:"; +} +impl Config for Runtime { + type Event = Event; + type ModuleId = ClaimsModuleId; + type Prefix = Prefix; + type EtpCurrency = Etp; + type MoveClaimOrigin = EnsureRootOrMoreThanHalfCouncil; +} diff --git a/bin/node/runtime/hyperspace/src/collective.rs b/bin/node/runtime/hyperspace/src/collective.rs new file mode 100644 index 0000000..396523f --- /dev/null +++ b/bin/node/runtime/hyperspace/src/collective.rs @@ -0,0 +1,65 @@ +// --- substrate --- +pub use pallet_collective::{Instance0 as CouncilCollective, Instance1 as TechnicalCollective}; + +// --- substrate --- +use frame_system::{EnsureOneOf, EnsureRoot}; +use pallet_collective::{ + weights::SubstrateWeight, Config, EnsureProportionAtLeast, EnsureProportionMoreThan, + PrimeDefaultVote, +}; +use sp_core::u32_trait::{_1, _2, _3, _5}; +// --- hyperspace --- +use crate::*; + +pub type EnsureRootOrHalfCouncil = EnsureOneOf< + AccountId, + EnsureRoot, + EnsureProportionAtLeast<_1, _2, AccountId, CouncilCollective>, +>; +pub type EnsureRootOrMoreThanHalfCouncil = EnsureOneOf< + AccountId, + EnsureRoot, + EnsureProportionMoreThan<_1, _2, AccountId, CouncilCollective>, +>; +pub type EnsureRootOrHalfTechnicalComittee = EnsureOneOf< + AccountId, + EnsureRoot, + EnsureProportionMoreThan<_1, _2, AccountId, TechnicalCollective>, +>; + +pub type ApproveOrigin = EnsureOneOf< + AccountId, + EnsureRoot, + EnsureProportionAtLeast<_3, _5, AccountId, CouncilCollective>, +>; + +frame_support::parameter_types! { + pub const CouncilMotionDuration: BlockNumber = 3 * MINUTES; + pub const CouncilMaxProposals: u32 = 100; + pub const CouncilMaxMembers: u32 = 100; + pub const TechnicalMotionDuration: BlockNumber = 3 * MINUTES; + pub const TechnicalMaxProposals: u32 = 100; + pub const TechnicalMaxMembers: u32 = 100; +} +// Make sure that there are no more than `MaxMembers` members elected via elections-phragmen. +static_assertions::const_assert!(DesiredMembers::get() <= CouncilMaxMembers::get()); +impl Config for Runtime { + type Origin = Origin; + type Proposal = Call; + type Event = Event; + type MotionDuration = CouncilMotionDuration; + type MaxProposals = CouncilMaxProposals; + type MaxMembers = CouncilMaxMembers; + type DefaultVote = PrimeDefaultVote; + type WeightInfo = SubstrateWeight; +} +impl Config for Runtime { + type Origin = Origin; + type Proposal = Call; + type Event = Event; + type MotionDuration = TechnicalMotionDuration; + type MaxProposals = TechnicalMaxProposals; + type MaxMembers = TechnicalMaxMembers; + type DefaultVote = PrimeDefaultVote; + type WeightInfo = SubstrateWeight; +} diff --git a/bin/node/runtime/hyperspace/src/democracy.rs b/bin/node/runtime/hyperspace/src/democracy.rs new file mode 100644 index 0000000..56d9d97 --- /dev/null +++ b/bin/node/runtime/hyperspace/src/democracy.rs @@ -0,0 +1,64 @@ +// --- substrate --- +use frame_system::{EnsureOneOf, EnsureRoot}; +use pallet_collective::{EnsureMember, EnsureProportionAtLeast}; +use sp_core::u32_trait::{_1, _2, _3}; +// --- hyperspace --- +use crate::*; +use hyperspace_democracy::{weights::SubstrateWeight, Config}; + +frame_support::parameter_types! { + pub const LaunchPeriod: BlockNumber = 3 * MINUTES; + pub const VotingPeriod: BlockNumber = 3 * MINUTES; + pub const FastTrackVotingPeriod: BlockNumber = 3 * MINUTES; + pub const MinimumDeposit: Balance = 1 * COIN; + pub const EnactmentPeriod: BlockNumber = 3 * MINUTES; + pub const CooloffPeriod: BlockNumber = 3 * MINUTES; + pub const PreimageByteDeposit: Balance = 1 * MILLI; + pub const InstantAllowed: bool = true; + pub const MaxVotes: u32 = 100; + pub const MaxProposals: u32 = 100; +} +impl Config for Runtime { + type Proposal = Call; + type Event = Event; + type Currency = Etp; + type EnactmentPeriod = EnactmentPeriod; + type LaunchPeriod = LaunchPeriod; + type VotingPeriod = VotingPeriod; + type MinimumDeposit = MinimumDeposit; + /// A straight majority of the council can decide what their next motion is. + type ExternalOrigin = EnsureRootOrHalfCouncil; + /// A majority can have the next scheduled referendum be a straight majority-carries vote. + type ExternalMajorityOrigin = EnsureRootOrHalfCouncil; + /// A unanimous council can have the next scheduled referendum be a straight default-carries + /// (NTB) vote. + type ExternalDefaultOrigin = EnsureProportionAtLeast<_1, _1, AccountId, CouncilCollective>; + /// Two thirds of the technical committee can have an ExternalMajority/ExternalDefault vote + /// be tabled immediately and with a shorter voting/enactment period. + type FastTrackOrigin = EnsureProportionAtLeast<_2, _3, AccountId, TechnicalCollective>; + type InstantOrigin = EnsureProportionAtLeast<_1, _1, AccountId, TechnicalCollective>; + 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 = EnsureProportionAtLeast<_2, _3, AccountId, CouncilCollective>; + // To cancel a proposal before it has been passed, the technical committee must be unanimous or + // Root must agree. + type CancelProposalOrigin = EnsureOneOf< + AccountId, + EnsureRoot, + EnsureProportionAtLeast<_1, _1, AccountId, TechnicalCollective>, + >; + 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 = EnsureMember; + type CooloffPeriod = CooloffPeriod; + type PreimageByteDeposit = PreimageByteDeposit; + type Slash = Treasury; + type Scheduler = Scheduler; + type PalletsOrigin = OriginCaller; + type MaxVotes = MaxVotes; + type OperationalPreimageOrigin = EnsureMember; + type MaxProposals = MaxProposals; + type WeightInfo = SubstrateWeight; +} diff --git a/bin/node/runtime/hyperspace/src/dvm.rs b/bin/node/runtime/hyperspace/src/dvm.rs new file mode 100644 index 0000000..e62fc5b --- /dev/null +++ b/bin/node/runtime/hyperspace/src/dvm.rs @@ -0,0 +1,31 @@ +// --- substrate --- +use frame_support::{traits::FindAuthor, ConsensusEngineId}; +use sp_core::{crypto::Public, H160, U256}; +// --- hyperspace --- +use crate::*; + +use dvm_ethereum::{Config, IntermediateStateRoot}; + +pub struct EthereumFindAuthor(sp_std::marker::PhantomData); +impl> FindAuthor for EthereumFindAuthor { + fn find_author<'a, I>(digests: I) -> Option + where + I: 'a + IntoIterator, + { + if let Some(author_index) = F::find_author(digests) { + let authority_id = Babe::authorities()[author_index as usize].clone(); + return Some(H160::from_slice(&authority_id.0.to_raw_vec()[4..24])); + } + None + } +} +frame_support::parameter_types! { + pub BlockGasLimit: U256 = U256::from(u32::max_value()); +} +impl Config for Runtime { + type Event = Event; + type FindAuthor = EthereumFindAuthor; + type StateRoot = IntermediateStateRoot; + type BlockGasLimit = BlockGasLimit; + type EtpCurrency = Etp; +} diff --git a/bin/node/runtime/hyperspace/src/elections_phragmen.rs b/bin/node/runtime/hyperspace/src/elections_phragmen.rs new file mode 100644 index 0000000..ba3b5eb --- /dev/null +++ b/bin/node/runtime/hyperspace/src/elections_phragmen.rs @@ -0,0 +1,38 @@ +// --- substrate --- +use frame_support::traits::{LockIdentifier, U128CurrencyToVote}; +// --- hyperspace --- +use crate::*; +use hyperspace_elections_phragmen::{weights::SubstrateWeight, Config}; + +frame_support::parameter_types! { + pub const ElectionsPhragmenModuleId: LockIdentifier = *b"da/phrel"; + pub const CandidacyBond: Balance = 1 * COIN; + // 1 storage item created, key size is 32 bytes, value size is 16+16. + pub const VotingBondBase: Balance = constants::deposit(1, 64); + // additional data per vote is 32 bytes (account id). + pub const VotingBondFactor: Balance = constants::deposit(0, 32); + pub const DesiredMembers: u32 = 13; + pub const DesiredRunnersUp: u32 = 7; + /// Daily council elections. + pub const TermDuration: BlockNumber = 3 * MINUTES; +} + +impl Config for Runtime { + type Event = Event; + type ModuleId = ElectionsPhragmenModuleId; + type Currency = Etp; + type ChangeMembers = Council; + // NOTE: this implies that council's genesis members cannot be set directly and must come from + // this module. + type InitializeMembers = Council; + type CurrencyToVote = U128CurrencyToVote; + type CandidacyBond = CandidacyBond; + type VotingBondBase = VotingBondBase; + type VotingBondFactor = VotingBondFactor; + type LoserCandidate = Treasury; + type KickedMember = Treasury; + type DesiredMembers = DesiredMembers; + type DesiredRunnersUp = DesiredRunnersUp; + type TermDuration = TermDuration; + type WeightInfo = SubstrateWeight; +} diff --git a/bin/node/runtime/hyperspace/src/ethereum_backing.rs b/bin/node/runtime/hyperspace/src/ethereum_backing.rs new file mode 100644 index 0000000..cc2f1d9 --- /dev/null +++ b/bin/node/runtime/hyperspace/src/ethereum_backing.rs @@ -0,0 +1,30 @@ +// --- substrate --- +use sp_runtime::ModuleId; +// --- hyperspace --- +use crate::*; +use hyperspace_ethereum_backing::Config; + +frame_support::parameter_types! { + pub const EthereumBackingModuleId: ModuleId = ModuleId(*b"da/ethbk"); + pub const EthereumBackingFeeModuleId: ModuleId = ModuleId(*b"da/ethfe"); + pub const EtpLockLimit: Balance = 10_000_000 * COIN; + pub const DnaLockLimit: Balance = 1000 * COIN; + pub const AdvancedFee: Balance = 50 * COIN; + pub const SyncReward: Balance = 1000 * COIN; +} +impl Config for Runtime { + type ModuleId = EthereumBackingModuleId; + type FeeModuleId = EthereumBackingFeeModuleId; + type Event = Event; + type RedeemAccountId = AccountId; + type EthereumRelay = EthereumRelay; + type OnDepositRedeem = Staking; + type EtpCurrency = Etp; + type DnaCurrency = Dna; + type EtpLockLimit = EtpLockLimit; + type DnaLockLimit = DnaLockLimit; + type AdvancedFee = AdvancedFee; + type SyncReward = SyncReward; + type EcdsaAuthorities = EthereumRelayAuthorities; + type WeightInfo = (); +} diff --git a/bin/node/runtime/hyperspace/src/ethereum_relay.rs b/bin/node/runtime/hyperspace/src/ethereum_relay.rs new file mode 100644 index 0000000..eaec29e --- /dev/null +++ b/bin/node/runtime/hyperspace/src/ethereum_relay.rs @@ -0,0 +1,29 @@ +// --- substrate --- +use sp_runtime::{ModuleId, Perbill}; +// --- hyperspace --- +use crate::*; +use hyperspace_ethereum_relay::Config; +use ethereum_primitives::EthereumNetworkType; + +frame_support::parameter_types! { + pub const EthereumRelayModuleId: ModuleId = ModuleId(*b"da/ethrl"); + pub const EthereumNetwork: EthereumNetworkType = EthereumNetworkType::Ropsten; + pub const ConfirmPeriod: BlockNumber = 30; + pub const ApproveThreshold: Perbill = Perbill::from_percent(60); + pub const RejectThreshold: Perbill = Perbill::from_percent(1); +} +impl Config for Runtime { + type ModuleId = EthereumRelayModuleId; + type Event = Event; + type EthereumNetwork = EthereumNetwork; + type Call = Call; + type Currency = Etp; + type RelayerGame = EthereumRelayerGame; + type ApproveOrigin = ApproveOrigin; + type RejectOrigin = EnsureRootOrHalfTechnicalComittee; + type ConfirmPeriod = ConfirmPeriod; + type TechnicalMembership = TechnicalMembership; + type ApproveThreshold = ApproveThreshold; + type RejectThreshold = RejectThreshold; + type WeightInfo = (); +} diff --git a/bin/node/runtime/hyperspace/src/evm.rs b/bin/node/runtime/hyperspace/src/evm.rs new file mode 100644 index 0000000..38667cb --- /dev/null +++ b/bin/node/runtime/hyperspace/src/evm.rs @@ -0,0 +1,35 @@ +// --- substrate --- +use sp_core::U256; +// --- hyperspace --- +use crate::*; +use hyperspace_evm::{ + runner::stack::Runner, ConcatAddressMapping, Config, EnsureAddressTruncated, FeeCalculator, +}; +use hyperspace_evm_precompile::HyperspacePrecompiles; +use dvm_ethereum::account_basic::DVMAccountBasicMapping; + +/// Fixed gas price of `1`. +pub struct FixedGasPrice; +impl FeeCalculator for FixedGasPrice { + fn min_gas_price() -> U256 { + // Gas price is always one token per gas. + 10_000_000_000u64.into() + } +} +frame_support::parameter_types! { + pub const ChainId: u64 mc= 23; +} +impl Config for Runtime { + type FeeCalculator = FixedGasPrice; + type GasWeightMapping = (); + type CallOrigin = EnsureAddressTruncated; + type WithdrawOrigin = EnsureAddressTruncated; + type AddressMapping = ConcatAddressMapping; + type EtpCurrency = Etp; + type DnaCurrency = Dna; + type Event = Event; + type Precompiles = HyperspacePrecompiles; + type ChainId = ChainId; + type AccountBasicMapping = DVMAccountBasicMapping; + type Runner = Runner; +} diff --git a/bin/node/runtime/hyperspace/src/grandpa.rs b/bin/node/runtime/hyperspace/src/grandpa.rs new file mode 100644 index 0000000..8046c13 --- /dev/null +++ b/bin/node/runtime/hyperspace/src/grandpa.rs @@ -0,0 +1,20 @@ +// --- substrate --- +use frame_support::traits::KeyOwnerProofSystem; +use pallet_grandpa::{AuthorityId, Config, EquivocationHandler}; +use sp_core::crypto::KeyTypeId; +// --- hyperspace --- +use crate::*; + +impl Config for Runtime { + type Event = Event; + type Call = Call; + type KeyOwnerProof = + >::Proof; + type KeyOwnerIdentification = >::IdentificationTuple; + type KeyOwnerProofSystem = Historical; + type HandleEquivocation = EquivocationHandler; + type WeightInfo = (); +} diff --git a/bin/node/runtime/hyperspace/src/header_mmr.rs b/bin/node/runtime/hyperspace/src/header_mmr.rs new file mode 100644 index 0000000..1cf0c01 --- /dev/null +++ b/bin/node/runtime/hyperspace/src/header_mmr.rs @@ -0,0 +1,5 @@ +// --- hyperspace --- +use crate::*; +use hyperspace_header_mmr::Config; + +impl Config for Runtime {} diff --git a/bin/node/runtime/hyperspace/src/identity.rs b/bin/node/runtime/hyperspace/src/identity.rs new file mode 100644 index 0000000..ed4567c --- /dev/null +++ b/bin/node/runtime/hyperspace/src/identity.rs @@ -0,0 +1,28 @@ +// --- substrate --- +use pallet_identity::Config; +// --- hyperspace --- +use crate::*; + +frame_support::parameter_types! { + // Minimum 100 bytes/PETP deposited (1 MILLI/byte) + pub const BasicDeposit: Balance = 10 * COIN; // 258 bytes on-chain + pub const FieldDeposit: Balance = 250 * MILLI; // 66 bytes on-chain + pub const SubAccountDeposit: Balance = 2 * COIN; // 53 bytes on-chain + pub const MaxSubAccounts: u32 = 100; + pub const MaxAdditionalFields: u32 = 100; + pub const MaxRegistrars: u32 = 20; +} +impl Config for Runtime { + type Event = Event; + type Currency = Etp; + type BasicDeposit = BasicDeposit; + type FieldDeposit = FieldDeposit; + type SubAccountDeposit = SubAccountDeposit; + type MaxSubAccounts = MaxSubAccounts; + type MaxAdditionalFields = MaxAdditionalFields; + type MaxRegistrars = MaxRegistrars; + type Slashed = Treasury; + type ForceOrigin = EnsureRootOrMoreThanHalfCouncil; + type RegistrarOrigin = EnsureRootOrMoreThanHalfCouncil; + type WeightInfo = (); +} diff --git a/bin/node/runtime/hyperspace/src/im_online.rs b/bin/node/runtime/hyperspace/src/im_online.rs new file mode 100644 index 0000000..811128f --- /dev/null +++ b/bin/node/runtime/hyperspace/src/im_online.rs @@ -0,0 +1,18 @@ +// --- substrate --- +use pallet_im_online::{sr25519::AuthorityId, weights::SubstrateWeight, Config}; +use sp_runtime::transaction_validity::TransactionPriority; +// --- hyperspace --- +use crate::*; + +frame_support::parameter_types! { + pub const SessionDuration: BlockNumber = BLOCKS_PER_SESSION as _; + pub const ImOnlineUnsignedPriority: TransactionPriority = TransactionPriority::max_value(); +} +impl Config for Runtime { + type AuthorityId = AuthorityId; + type Event = Event; + type SessionDuration = SessionDuration; + type ReportUnresponsiveness = Offences; + type UnsignedPriority = ImOnlineUnsignedPriority; + type WeightInfo = SubstrateWeight; +} diff --git a/bin/node/runtime/hyperspace/src/lib.rs b/bin/node/runtime/hyperspace/src/lib.rs index 1cd7985..079e250 100644 --- a/bin/node/runtime/hyperspace/src/lib.rs +++ b/bin/node/runtime/hyperspace/src/lib.rs @@ -23,6 +23,8 @@ #![recursion_limit = "256"] pub mod constants { + // --- substrate --- + use sp_staking::SessionIndex; // --- hyperspace --- use crate::*; @@ -34,16 +36,16 @@ pub mod constants { pub const CAP: Balance = 10_000_000_000 * COIN; pub const TOTAL_POWER: Power = 1_000_000_000; - pub const MILLISECS_PER_BLOCK: Moment = 23000; - pub const SLOT_DURATION: Moment = MILLISECS_PER_BLOCK; - pub const BLOCKS_PER_SESSION: BlockNumber = 2057 * MINUTES; - pub const SESSIONS_PER_ERA: SessionIndex = 6; - // Time is measured by number of blocks. pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber); pub const HOURS: BlockNumber = 60 * MINUTES; pub const DAYS: BlockNumber = 24 * HOURS; + pub const MILLISECS_PER_BLOCK: Moment = 23000; + pub const SLOT_DURATION: Moment = MILLISECS_PER_BLOCK; + pub const BLOCKS_PER_SESSION: BlockNumber = 2057 * MINUTES; + pub const SESSIONS_PER_ERA: SessionIndex = 6; + // 1 in 4 blocks (on average, not counting collisions) will be primary babe blocks. pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4); @@ -164,6 +166,7 @@ pub mod impls { impl WeightToFeePolynomial for WeightToFee { type Balance = Balance; fn polynomial() -> WeightToFeeCoefficients { + // in Oldetp, extrinsic base weight (smallest non-zero weight) is mapped to 100 MILLI: let p = 100 * MILLI; let q = Balance::from(ExtrinsicBaseWeight::get()); smallvec![WeightToFeeCoefficient { @@ -201,74 +204,160 @@ pub mod wasm { } } +pub mod system; +pub use system::*; + +pub mod babe; +pub use babe::*; + +pub mod timestamp; +pub use timestamp::*; + +pub mod balances; +pub use balances::*; + +pub mod transaction_payment; +pub use transaction_payment::*; + +pub mod authorship; +pub use authorship::*; + +pub mod staking; +pub use staking::*; + +pub mod offences; +pub use offences::*; + +pub mod session_historical; +pub use session_historical::*; + +pub mod session; +pub use session::*; + +pub mod grandpa; +pub use grandpa::*; + +pub mod im_online; +pub use im_online::*; + +pub mod authority_discovery; +pub use authority_discovery::*; + +pub mod democracy; +pub use democracy::*; + +pub mod collective; +pub use collective::*; + +pub mod elections_phragmen; +pub use elections_phragmen::*; + +pub mod membership; +pub use membership::*; + +pub mod treasury; +pub use treasury::*; + +pub mod sudo; +pub use sudo::*; + +pub mod claims; +pub use claims::*; + +pub mod vesting; +pub use vesting::*; + +pub mod utility; +pub use utility::*; + +pub mod identity; +pub use identity::*; + +pub mod society; +pub use society::*; + +pub mod recovery; +pub use recovery::*; + +pub mod scheduler; +pub use scheduler::*; + +pub mod proxy; +pub use proxy::*; + +pub mod multisig; +pub use multisig::*; + +pub mod header_mmr; +pub use header_mmr::*; + +pub mod oldetp_issuing; +pub use oldetp_issuing::*; + +pub mod oldetp_backing; +pub use oldetp_backing::*; + +pub mod ethereum_relay; +pub use ethereum_relay::*; + +pub mod ethereum_backing; +pub use ethereum_backing::*; + +pub mod relayer_game; +pub use relayer_game::*; + +pub mod relay_authorities; +pub use relay_authorities::*; + +pub mod oldna_backing; +pub use oldna_backing::*; + +pub mod evm; +pub use evm::*; + +pub mod dvm; +pub use dvm::*; + // --- hyperspace --- -use hyperspace_evm::{ - Account as EVMAccount, AccountBasicMapping, EnsureAddressTruncated, FeeCalculator, -}; +pub use constants::*; +use hyperspace_evm::{Account as EVMAccount, FeeCalculator}; pub use hyperspace_staking::StakerStatus; +pub use hyperspace_primitives::*; +pub use impls::*; pub use wasm::*; // --- crates --- use codec::{Decode, Encode}; -use static_assertions::const_assert; // --- substrate --- use frame_support::{ - construct_runtime, debug, parameter_types, - traits::{ - ChangeMembers, Currency, FindAuthor, InstanceFilter, KeyOwnerProofSystem, LockIdentifier, - Randomness, U128CurrencyToVote, - }, - weights::{ - constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND}, - DispatchClass, Weight, - }, - ConsensusEngineId, -}; -use frame_system::{ - limits::{BlockLength, BlockWeights}, - EnsureOneOf, EnsureRoot, + debug, + traits::{KeyOwnerProofSystem, Randomness}, + weights::constants::ExtrinsicBaseWeight, }; use pallet_grandpa::{ fg_primitives, AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList, }; -use pallet_im_online::sr25519::AuthorityId as ImOnlineId; -use pallet_session::historical as pallet_session_historical; -use pallet_transaction_payment::{CurrencyAdapter, FeeDetails, Multiplier, TargetedFeeAdjustment}; +use pallet_transaction_payment::FeeDetails; use pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo as TransactionPaymentRuntimeDispatchInfo; use sp_api::impl_runtime_apis; use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; -use sp_core::{ - crypto::{KeyTypeId, Public}, - u32_trait::{_1, _2, _3, _5}, - OpaqueMetadata, H160, H256, U256, -}; +use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H160, H256, U256}; use sp_runtime::{ - create_runtime_str, generic, impl_opaque_keys, - traits::{ - AccountIdLookup, BlakeTwo256, Block as BlockT, ConvertInto, NumberFor, OpaqueKeys, - SaturatedConversion, StaticLookup, - }, - transaction_validity::{TransactionPriority, TransactionSource, TransactionValidity}, - ApplyExtrinsicResult, FixedPointNumber, ModuleId, MultiAddress, OpaqueExtrinsic, Perbill, - Percent, Permill, Perquintill, RuntimeDebug, + create_runtime_str, generic, + traits::{Block as BlockT, NumberFor, SaturatedConversion, StaticLookup}, + transaction_validity::{TransactionSource, TransactionValidity}, + ApplyExtrinsicResult, MultiAddress, OpaqueExtrinsic, Perbill, RuntimeDebug, }; -use sp_staking::SessionIndex; use sp_std::prelude::*; #[cfg(feature = "std")] use sp_version::NativeVersion; use sp_version::RuntimeVersion; // --- hyperspace --- -use constants::*; use hyperspace_balances_rpc_runtime_api::RuntimeDispatchInfo as BalancesRuntimeDispatchInfo; -use hyperspace_evm::{ConcatAddressMapping, Runner}; +use hyperspace_evm::Runner; use hyperspace_header_mmr_rpc_runtime_api::RuntimeDispatchInfo as HeaderMMRRuntimeDispatchInfo; -use hyperspace_relay_primitives::relay_authorities::OpCode; -use hyperspace_staking::EraIndex; use hyperspace_staking_rpc_runtime_api::RuntimeDispatchInfo as StakingRuntimeDispatchInfo; -use hyperspace_primitives::*; -use dvm_ethereum::account_basic::DVMAccountBasicMapping; use dvm_rpc_runtime_api::TransactionStatus; -use impls::*; /// The address format for describing accounts. type Address = MultiAddress; @@ -302,19 +391,15 @@ type SignedPayload = generic::SignedPayload; type Etp = Balances; -type NegativeImbalance = as Currency< - ::AccountId, ->>::NegativeImbalance; - /// This runtime version. pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("Hyperspace"), impl_name: create_runtime_str!("Hyperspace"), authoring_version: 1, - spec_version: 19, + spec_version: 200, impl_version: 1, apis: RUNTIME_API_VERSIONS, - transaction_version: 2, + transaction_version: 1, }; /// The version information used to identify this runtime when compiled natively. @@ -326,843 +411,7 @@ pub fn native_version() -> NativeVersion { } } -/// We assume that an on-initialize consumes 2.5% of the weight on average, hence a single extrinsic -/// will not be allowed to consume more than `AvailableBlockRatio - 2.5%`. -const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(25); -/// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used -/// by Operational extrinsics. -const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); -/// We allow for 2 seconds of compute with a 6 second average block time. -const MAXIMUM_BLOCK_WEIGHT: Weight = 2 * WEIGHT_PER_SECOND; -const_assert!(NORMAL_DISPATCH_RATIO.deconstruct() >= AVERAGE_ON_INITIALIZE_RATIO.deconstruct()); -parameter_types! { - pub const BlockHashCount: BlockNumber = 2400; - pub const Version: RuntimeVersion = VERSION; - pub RuntimeBlockLength: BlockLength = - BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO); - pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder() - .base_block(BlockExecutionWeight::get()) - .for_class(DispatchClass::all(), |weights| { - weights.base_extrinsic = ExtrinsicBaseWeight::get(); - }) - .for_class(DispatchClass::Normal, |weights| { - weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT); - }) - .for_class(DispatchClass::Operational, |weights| { - weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT); - // Operational transactions have some extra reserved space, so that they - // are included even if block reached `MAXIMUM_BLOCK_WEIGHT`. - weights.reserved = Some( - MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT - ); - }) - .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO) - .build_or_panic(); - pub const SS58Prefix: u8 = 150; -} -impl frame_system::Config for Runtime { - type BaseCallFilter = (); - type BlockWeights = RuntimeBlockWeights; - type BlockLength = RuntimeBlockLength; - type DbWeight = RocksDbWeight; - type Origin = Origin; - type Call = Call; - type Index = Nonce; - type BlockNumber = BlockNumber; - type Hash = Hash; - type Hashing = BlakeTwo256; - type AccountId = AccountId; - type Lookup = AccountIdLookup; - type Header = Header; - type Event = Event; - type BlockHashCount = BlockHashCount; - type Version = Version; - type PalletInfo = PalletInfo; - type AccountData = AccountData; - type OnNewAccount = (); - type OnKilledAccount = (); - type SystemWeightInfo = frame_system::weights::SubstrateWeight; - type SS58Prefix = SS58Prefix; -} - -parameter_types! { - pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) * - RuntimeBlockWeights::get().max_block; - pub const MaxScheduledPerBlock: u32 = 50; -} -impl pallet_scheduler::Config for Runtime { - type Event = Event; - type Origin = Origin; - type PalletsOrigin = OriginCaller; - type Call = Call; - type MaximumWeight = MaximumSchedulerWeight; - type ScheduleOrigin = EnsureRoot; - type MaxScheduledPerBlock = MaxScheduledPerBlock; - type WeightInfo = pallet_scheduler::weights::SubstrateWeight; -} - -/// The type used to represent the kinds of proxying allowed. -#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, RuntimeDebug)] -pub enum ProxyType { - Any, - NonTransfer, - Governance, - Staking, - EthereumBridge, -} -impl Default for ProxyType { - fn default() -> Self { - Self::Any - } -} -impl InstanceFilter for ProxyType { - fn filter(&self, c: &Call) -> bool { - match self { - ProxyType::Any => true, - ProxyType::NonTransfer => matches!( - c, - Call::System(..) | - Call::Babe(..) | - Call::Timestamp(..) | - // Specifically omitting the entire Balances pallet - Call::Authorship(..) | - Call::Staking(..) | - Call::Offences(..) | - Call::Session(..) | - Call::Grandpa(..) | - Call::ImOnline(..) | - Call::AuthorityDiscovery(..) | - Call::Democracy(..) | - Call::Council(..) | - Call::TechnicalCommittee(..) | - Call::ElectionsPhragmen(..) | - Call::TechnicalMembership(..) | - Call::Treasury(..) | - Call::Claims(..) | - Call::Scheduler(..) | - Call::Proxy(..) | - Call::Multisig(..) | - // Specifically omitting the entire Sudo pallet - // Specifically omitting the entire OldnaIssuing pallet - // Specifically omitting the entire OldnaBacking pallet - Call::EthereumRelay(..) // Specifically omitting the entire EthereumBacking pallet - // Specifically omitting the entire OldetpBacking pallet - // Specifically omitting the entire OldnaIssuing pallet - // Specifically omitting the entire EthereumRelayAuthorities pallet - ), - ProxyType::Governance => matches!( - c, - Call::Democracy(..) - | Call::Council(..) | Call::TechnicalCommittee(..) - | Call::ElectionsPhragmen(..) - | Call::Treasury(..) - ), - ProxyType::Staking => matches!(c, Call::Staking(..)), - ProxyType::EthereumBridge => matches!( - c, - Call::EthereumBacking(..) - | Call::EthereumRelay(..) - | Call::EthereumRelayAuthorities(..) - ), - } - } - fn is_superset(&self, o: &Self) -> bool { - match (self, o) { - (x, y) if x == y => true, - (ProxyType::Any, _) => true, - (_, ProxyType::Any) => false, - (ProxyType::NonTransfer, _) => true, - _ => false, - } - } -} -parameter_types! { - // One storage item; key size 32, value size 8; . - pub const ProxyDepositBase: Balance = deposit(1, 8); - // Additional storage item size of 33 bytes. - pub const ProxyDepositFactor: Balance = deposit(0, 33); - pub const MaxProxies: u16 = 32; - pub const AnnouncementDepositBase: Balance = deposit(1, 8); - pub const AnnouncementDepositFactor: Balance = deposit(0, 66); - pub const MaxPending: u16 = 32; -} -impl pallet_proxy::Config for Runtime { - type Event = Event; - type Call = Call; - type Currency = Balances; - type ProxyType = ProxyType; - type ProxyDepositBase = ProxyDepositBase; - type ProxyDepositFactor = ProxyDepositFactor; - type MaxProxies = MaxProxies; - type MaxPending = MaxPending; - type CallHasher = BlakeTwo256; - type AnnouncementDepositBase = AnnouncementDepositBase; - type AnnouncementDepositFactor = AnnouncementDepositFactor; - type WeightInfo = pallet_proxy::weights::SubstrateWeight; -} - -parameter_types! { - pub const EpochDuration: u64 = BLOCKS_PER_SESSION as _; - pub const ExpectedBlockTime: Moment = MILLISECS_PER_BLOCK; -} -impl pallet_babe::Config for Runtime { - type EpochDuration = EpochDuration; - type ExpectedBlockTime = ExpectedBlockTime; - type EpochChangeTrigger = pallet_babe::ExternalTrigger; - type KeyOwnerProofSystem = Historical; - type KeyOwnerProof = >::Proof; - type KeyOwnerIdentification = >::IdentificationTuple; - type HandleEquivocation = - pallet_babe::EquivocationHandler; - type WeightInfo = (); -} - -parameter_types! { - // One storage item; key size is 32; value is size 4+4+16+32 bytes = 56 bytes. - pub const DepositBase: Balance = deposit(1, 88); - // Additional storage item size of 32 bytes. - pub const DepositFactor: Balance = deposit(0, 32); - pub const MaxSignatories: u16 = 100; -} - -impl pallet_multisig::Config for Runtime { - type Event = Event; - type Call = Call; - type Currency = Balances; - type DepositBase = DepositBase; - type DepositFactor = DepositFactor; - type MaxSignatories = MaxSignatories; - type WeightInfo = pallet_multisig::weights::SubstrateWeight; -} - -parameter_types! { - pub const MinimumPeriod: Moment = SLOT_DURATION / 2; -} -impl pallet_timestamp::Config for Runtime { - type Moment = Moment; - type OnTimestampSet = Babe; - type MinimumPeriod = MinimumPeriod; - type WeightInfo = pallet_timestamp::weights::SubstrateWeight; -} - -type EtpInstance = hyperspace_balances::Instance0; -parameter_types! { - //pub const ExistentialDeposit: Balance = 1 * COIN; - pub const ExistentialDeposit: Balance = 0; - pub const MaxLocks: u32 = 50; -} -impl hyperspace_balances::Config for Runtime { - type Balance = Balance; - type DustRemoval = (); - type Event = Event; - type ExistentialDeposit = ExistentialDeposit; - type BalanceInfo = AccountData; - type AccountStore = System; - type MaxLocks = MaxLocks; - type OtherCurrencies = (Dna,); - type WeightInfo = hyperspace_balances::weights::SubstrateWeight; -} -type DnaInstance = hyperspace_balances::Instance1; -impl hyperspace_balances::Config for Runtime { - type Balance = Balance; - type DustRemoval = (); - type Event = Event; - type ExistentialDeposit = ExistentialDeposit; - type BalanceInfo = AccountData; - type AccountStore = System; - type MaxLocks = MaxLocks; - type OtherCurrencies = (Etp,); - type WeightInfo = hyperspace_balances::weights::SubstrateWeight; -} - -/// Parameterized slow adjusting fee updated based on -/// https://w3f-research.readthedocs.io/en/latest/polkadot/Token%20Economics.html#-2.-slow-adjusting-mechanism -pub type SlowAdjustingFeeUpdate = - TargetedFeeAdjustment; -parameter_types! { - pub const TransactionByteFee: Balance = 10 * MICRO; - /// The portion of the `AvailableBlockRatio` that we adjust the fees with. Blocks filled less - /// than this will decrease the weight and more will increase. - pub const TargetBlockFullness: Perquintill = Perquintill::from_percent(25); - /// The adjustment variable of the runtime. Higher values will cause `TargetBlockFullness` to - /// change the fees more rapidly. - pub AdjustmentVariable: Multiplier = Multiplier::saturating_from_rational(3, 100_000); - /// Minimum amount of the multiplier. This value cannot be too low. A test case should ensure - /// that combined with `AdjustmentVariable`, we can recover from the minimum. - /// See `multiplier_can_grow_from_zero`. - pub MinimumMultiplier: Multiplier = Multiplier::saturating_from_rational(1, 1_000_000_000u128); -} -impl pallet_transaction_payment::Config for Runtime { - type OnChargeTransaction = CurrencyAdapter; - type TransactionByteFee = TransactionByteFee; - type WeightToFee = WeightToFee; - type FeeMultiplierUpdate = SlowAdjustingFeeUpdate; -} - -parameter_types! { - pub const UncleGenerations: BlockNumber = 5; -} -impl pallet_authorship::Config for Runtime { - type FindAuthor = pallet_session::FindAccountFromAuthorIndex; - type UncleGenerations = UncleGenerations; - type FilterUncle = (); - type EventHandler = (Staking, ImOnline); -} - -parameter_types! { - pub const StakingModuleId: ModuleId = ModuleId(*b"da/staki"); - pub const SessionsPerEra: SessionIndex = SESSIONS_PER_ERA; - pub const BondingDurationInEra: EraIndex = 14 * DAYS - / (SESSIONS_PER_ERA as BlockNumber * BLOCKS_PER_SESSION); - pub const BondingDurationInBlockNumber: BlockNumber = 14 * DAYS; - pub const SlashDeferDuration: EraIndex = 14 * DAYS - / (SESSIONS_PER_ERA as BlockNumber * BLOCKS_PER_SESSION) - 1; - // quarter of the last session will be for election. - pub const ElectionLookahead: BlockNumber = BLOCKS_PER_SESSION / 4; - pub const MaxIterations: u32 = 5; - pub MinSolutionScoreBump: Perbill = Perbill::from_rational_approximation(5u32, 10_000); - pub const MaxNominatorRewardedPerValidator: u32 = 128; - pub const StakingUnsignedPriority: TransactionPriority = TransactionPriority::max_value() / 2; - pub OffchainSolutionWeightLimit: Weight = RuntimeBlockWeights::get() - .get(DispatchClass::Normal) - .max_extrinsic.expect("Normal extrinsics have a weight limit configured; qed") - .saturating_sub(BlockExecutionWeight::get()); - pub const Cap: Balance = CAP; - pub const TotalPower: Power = TOTAL_POWER; -} -impl hyperspace_staking::Config for Runtime { - type Event = Event; - type ModuleId = StakingModuleId; - type UnixTime = Timestamp; - type SessionsPerEra = SessionsPerEra; - type BondingDurationInEra = BondingDurationInEra; - type BondingDurationInBlockNumber = BondingDurationInBlockNumber; - type SlashDeferDuration = SlashDeferDuration; - /// A super-majority of the council can cancel the slash. - type SlashCancelOrigin = EnsureRootOrHalfCouncil; - type SessionInterface = Self; - type NextNewSession = Session; - type ElectionLookahead = ElectionLookahead; - type Call = Call; - type MaxIterations = MaxIterations; - type MinSolutionScoreBump = MinSolutionScoreBump; - type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator; - type UnsignedPriority = StakingUnsignedPriority; - // The unsigned solution weight targeted by the OCW. We set it to the maximum possible value of - // a single extrinsic. - type OffchainSolutionWeightLimit = OffchainSolutionWeightLimit; - type EtpCurrency = Etp; - type EtpRewardRemainder = Treasury; - // send the slashed funds to the treasury. - type EtpSlash = Treasury; - // rewards are minted from the void - type EtpReward = (); - type DnaCurrency = Dna; - // send the slashed funds to the treasury. - type DnaSlash = Treasury; - // rewards are minted from the void - type DnaReward = (); - type Cap = Cap; - type TotalPower = TotalPower; - type WeightInfo = hyperspace_staking::weights::SubstrateWeight; -} - -parameter_types! { - pub OffencesWeightSoftLimit: Weight = Perbill::from_percent(60) * - RuntimeBlockWeights::get().max_block; -} -impl pallet_offences::Config for Runtime { - type Event = Event; - type IdentificationTuple = pallet_session::historical::IdentificationTuple; - type OnOffenceHandler = Staking; - type WeightSoftLimit = OffencesWeightSoftLimit; -} - -impl pallet_session::historical::Config for Runtime { - type FullIdentification = hyperspace_staking::Exposure; - type FullIdentificationOf = hyperspace_staking::ExposureOf; -} - -impl_opaque_keys! { - pub struct SessionKeys { - pub babe: Babe, - pub grandpa: Grandpa, - pub im_online: ImOnline, - pub authority_discovery: AuthorityDiscovery, - } -} -parameter_types! { - pub const DisabledValidatorsThreshold: Perbill = Perbill::from_percent(17); -} -impl pallet_session::Config for Runtime { - type Event = Event; - type ValidatorId = AccountId; - type ValidatorIdOf = hyperspace_staking::StashOf; - type ShouldEndSession = Babe; - type NextSessionRotation = Babe; - type SessionManager = pallet_session::historical::NoteHistoricalRoot; - type SessionHandler = ::KeyTypeIdProviders; - type Keys = SessionKeys; - type DisabledValidatorsThreshold = DisabledValidatorsThreshold; - type WeightInfo = pallet_session::weights::SubstrateWeight; -} - -impl pallet_grandpa::Config for Runtime { - type Event = Event; - type Call = Call; - type KeyOwnerProof = - >::Proof; - type KeyOwnerIdentification = >::IdentificationTuple; - type KeyOwnerProofSystem = Historical; - type HandleEquivocation = - pallet_grandpa::EquivocationHandler; - type WeightInfo = (); -} - -parameter_types! { - pub const SessionDuration: BlockNumber = BLOCKS_PER_SESSION as _; - pub const ImOnlineUnsignedPriority: TransactionPriority = TransactionPriority::max_value(); -} -impl pallet_im_online::Config for Runtime { - type AuthorityId = ImOnlineId; - type Event = Event; - type SessionDuration = SessionDuration; - type ReportUnresponsiveness = Offences; - type UnsignedPriority = ImOnlineUnsignedPriority; - type WeightInfo = pallet_im_online::weights::SubstrateWeight; -} - -impl pallet_authority_discovery::Config for Runtime {} - -type EnsureRootOrHalfCouncil = EnsureOneOf< - AccountId, - EnsureRoot, - pallet_collective::EnsureProportionAtLeast<_1, _2, AccountId, CouncilCollective>, ->; -parameter_types! { - pub const LaunchPeriod: BlockNumber = 7 * DAYS; - pub const VotingPeriod: BlockNumber = 7 * DAYS; - pub const FastTrackVotingPeriod: BlockNumber = 3 * HOURS; - pub const MinimumDeposit: Balance = 1 * MILLI; - pub const EnactmentPeriod: BlockNumber = 8 * DAYS; - pub const CooloffPeriod: BlockNumber = 7 * DAYS; - pub const PreimageByteDeposit: Balance = 10 * NANO; - pub const InstantAllowed: bool = true; - pub const MaxVotes: u32 = 100; - pub const MaxProposals: u32 = 100; -} -impl hyperspace_democracy::Config for Runtime { - type Proposal = Call; - type Event = Event; - type Currency = Etp; - type EnactmentPeriod = EnactmentPeriod; - type LaunchPeriod = LaunchPeriod; - type VotingPeriod = VotingPeriod; - type MinimumDeposit = MinimumDeposit; - /// A straight majority of the council can decide what their next motion is. - type ExternalOrigin = EnsureRootOrHalfCouncil; - /// A majority can have the next scheduled referendum be a straight majority-carries vote. - type ExternalMajorityOrigin = EnsureRootOrHalfCouncil; - /// A unanimous council can have the next scheduled referendum be a straight default-carries - /// (NTB) vote. - type ExternalDefaultOrigin = - pallet_collective::EnsureProportionAtLeast<_1, _1, AccountId, CouncilCollective>; - /// Two thirds of the technical committee can have an ExternalMajority/ExternalDefault vote - /// be tabled immediately and with a shorter voting/enactment period. - type FastTrackOrigin = - pallet_collective::EnsureProportionAtLeast<_2, _3, AccountId, TechnicalCollective>; - type InstantOrigin = - pallet_collective::EnsureProportionAtLeast<_1, _1, AccountId, TechnicalCollective>; - 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 = - pallet_collective::EnsureProportionAtLeast<_2, _3, AccountId, CouncilCollective>; - // To cancel a proposal before it has been passed, the technical committee must be unanimous or - // Root must agree. - type CancelProposalOrigin = EnsureOneOf< - AccountId, - EnsureRoot, - pallet_collective::EnsureProportionAtLeast<_1, _1, AccountId, TechnicalCollective>, - >; - 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 PreimageByteDeposit = PreimageByteDeposit; - type Slash = Treasury; - type Scheduler = Scheduler; - type PalletsOrigin = OriginCaller; - type MaxVotes = MaxVotes; - type OperationalPreimageOrigin = pallet_collective::EnsureMember; - type MaxProposals = MaxProposals; - type WeightInfo = hyperspace_democracy::weights::SubstrateWeight; -} - -parameter_types! { - pub const CouncilMotionDuration: BlockNumber = 3 * DAYS; - pub const CouncilMaxProposals: u32 = 100; - pub const CouncilMaxMembers: u32 = 100; - pub const TechnicalMotionDuration: BlockNumber = 3 * DAYS; - pub const TechnicalMaxProposals: u32 = 100; - pub const TechnicalMaxMembers: u32 = 100; -} -// Make sure that there are no more than `MaxMembers` members elected via elections-phragmen. -const_assert!(DesiredMembers::get() <= CouncilMaxMembers::get()); -type CouncilCollective = pallet_collective::Instance0; -impl pallet_collective::Config for Runtime { - type Origin = Origin; - type Proposal = Call; - type Event = Event; - type MotionDuration = CouncilMotionDuration; - type MaxProposals = CouncilMaxProposals; - type MaxMembers = CouncilMaxMembers; - type DefaultVote = pallet_collective::PrimeDefaultVote; - type WeightInfo = pallet_collective::weights::SubstrateWeight; -} -type TechnicalCollective = pallet_collective::Instance1; -impl pallet_collective::Config for Runtime { - type Origin = Origin; - type Proposal = Call; - type Event = Event; - type MotionDuration = TechnicalMotionDuration; - type MaxProposals = TechnicalMaxProposals; - type MaxMembers = TechnicalMaxMembers; - type DefaultVote = pallet_collective::PrimeDefaultVote; - type WeightInfo = pallet_collective::weights::SubstrateWeight; -} - -parameter_types! { - pub const ElectionsPhragmenModuleId: LockIdentifier = *b"da/phrel"; - pub const CandidacyBond: Balance = 1 * COIN; - // 1 storage item created, key size is 32 bytes, value size is 16+16. - pub const VotingBondBase: Balance = deposit(1, 64); - // additional data per vote is 32 bytes (account id). - pub const VotingBondFactor: Balance = deposit(0, 32); - pub const DesiredMembers: u32 = 13; - pub const DesiredRunnersUp: u32 = 7; - /// Daily council elections. - pub const TermDuration: BlockNumber = 24 * HOURS; -} -impl hyperspace_elections_phragmen::Config for Runtime { - type Event = Event; - type ModuleId = ElectionsPhragmenModuleId; - type Currency = Etp; - type ChangeMembers = Council; - // NOTE: this implies that council's genesis members cannot be set directly and must come from - // this module. - type InitializeMembers = Council; - type CurrencyToVote = U128CurrencyToVote; - type CandidacyBond = CandidacyBond; - type VotingBondBase = VotingBondBase; - type VotingBondFactor = VotingBondFactor; - type LoserCandidate = Treasury; - type KickedMember = Treasury; - type DesiredMembers = DesiredMembers; - type DesiredRunnersUp = DesiredRunnersUp; - type TermDuration = TermDuration; - type WeightInfo = hyperspace_elections_phragmen::weights::SubstrateWeight; -} - -pub struct MembershipChangedGroup; -impl ChangeMembers for MembershipChangedGroup { - fn change_members_sorted( - incoming: &[AccountId], - outgoing: &[AccountId], - sorted_new: &[AccountId], - ) { - TechnicalCommittee::change_members_sorted(incoming, outgoing, sorted_new); - EthereumRelay::change_members_sorted(incoming, outgoing, sorted_new); - } -} -type EnsureRootOrMoreThanHalfCouncil = EnsureOneOf< - AccountId, - EnsureRoot, - pallet_collective::EnsureProportionMoreThan<_1, _2, AccountId, CouncilCollective>, ->; -impl pallet_membership::Config for Runtime { - type Event = Event; - type AddOrigin = EnsureRootOrMoreThanHalfCouncil; - type RemoveOrigin = EnsureRootOrMoreThanHalfCouncil; - type SwapOrigin = EnsureRootOrMoreThanHalfCouncil; - type ResetOrigin = EnsureRootOrMoreThanHalfCouncil; - type PrimeOrigin = EnsureRootOrMoreThanHalfCouncil; - type MembershipInitialized = TechnicalCommittee; - type MembershipChanged = MembershipChangedGroup; -} - -type ApproveOrigin = EnsureOneOf< - AccountId, - EnsureRoot, - pallet_collective::EnsureProportionAtLeast<_3, _5, AccountId, CouncilCollective>, ->; -parameter_types! { - pub const TreasuryModuleId: ModuleId = ModuleId(*b"da/trsry"); - pub const ProposalBond: Permill = Permill::from_percent(5); - pub const EtpProposalBondMinimum: Balance = 20 * COIN; - pub const DnaProposalBondMinimum: Balance = 20 * COIN; - pub const SpendPeriod: BlockNumber = 6 * DAYS; - pub const Burn: Permill = Permill::from_percent(0); - pub const TipCountdown: BlockNumber = 1 * DAYS; - pub const TipFindersFee: Percent = Percent::from_percent(20); - pub const TipReportDepositBase: Balance = 1 * COIN; - pub const DataDepositPerByte: Balance = 1 * MILLI; - pub const BountyDepositBase: Balance = 1 * COIN; - pub const BountyDepositPayoutDelay: BlockNumber = 4 * DAYS; - pub const BountyUpdatePeriod: BlockNumber = 90 * DAYS; - pub const MaximumReasonLength: u32 = 16384; - pub const BountyCuratorDeposit: Permill = Permill::from_percent(50); - pub const BountyValueMinimum: Balance = 2 * COIN; -} -impl hyperspace_treasury::Config for Runtime { - type ModuleId = TreasuryModuleId; - type EtpCurrency = Etp; - type DnaCurrency = Dna; - type ApproveOrigin = ApproveOrigin; - type RejectOrigin = EnsureRootOrMoreThanHalfCouncil; - type Tippers = ElectionsPhragmen; - type TipCountdown = TipCountdown; - type TipFindersFee = TipFindersFee; - type TipReportDepositBase = TipReportDepositBase; - type DataDepositPerByte = DataDepositPerByte; - type Event = Event; - type OnSlashEtp = Treasury; - type OnSlashDna = Treasury; - type ProposalBond = ProposalBond; - type EtpProposalBondMinimum = EtpProposalBondMinimum; - type DnaProposalBondMinimum = DnaProposalBondMinimum; - type SpendPeriod = SpendPeriod; - type Burn = Burn; - type BountyDepositBase = BountyDepositBase; - type BountyDepositPayoutDelay = BountyDepositPayoutDelay; - type BountyUpdatePeriod = BountyUpdatePeriod; - type MaximumReasonLength = MaximumReasonLength; - type BountyCuratorDeposit = BountyCuratorDeposit; - type BountyValueMinimum = BountyValueMinimum; - type EtpBurnDestination = (); - type DnaBurnDestination = (); - type WeightInfo = hyperspace_treasury::weights::SubstrateWeight; -} - -parameter_types! { - pub const ClaimsModuleId: ModuleId = ModuleId(*b"da/claim"); - pub Prefix: &'static [u8] = b"Pay ETPs to the template account:"; -} -impl hyperspace_claims::Config for Runtime { - type Event = Event; - type ModuleId = ClaimsModuleId; - type Prefix = Prefix; - type EtpCurrency = Etp; - type MoveClaimOrigin = EnsureRootOrMoreThanHalfCouncil; -} - -parameter_types! { - pub const MinVestedTransfer: Balance = 100 * MILLI; -} -impl hyperspace_vesting::Config for Runtime { - type Event = Event; - type Currency = Etp; - type BlockNumberToBalance = ConvertInto; - type MinVestedTransfer = MinVestedTransfer; - type WeightInfo = (); -} - -impl pallet_sudo::Config for Runtime { - type Event = Event; - type Call = Call; -} - -parameter_types! { - pub const OldnaIssuingModuleId: ModuleId = ModuleId(*b"da/crais"); -} -impl hyperspace_oldna_issuing::Config for Runtime { - type Event = Event; - type ModuleId = OldnaIssuingModuleId; - type EtpCurrency = Etp; - type WeightInfo = (); -} - -parameter_types! { - pub const OldnaBackingModuleId: ModuleId = ModuleId(*b"da/oldnk"); -} -impl hyperspace_oldna_backing::Config for Runtime { - type ModuleId = OldnaBackingModuleId; - type EtpCurrency = Etp; - type WeightInfo = (); -} - -parameter_types! { - pub const EthereumBackingModuleId: ModuleId = ModuleId(*b"da/ethbk"); - pub const EthereumBackingFeeModuleId: ModuleId = ModuleId(*b"da/ethfe"); - pub const EtpLockLimit: Balance = 10_000_000 * COIN; - pub const DnaLockLimit: Balance = 1000 * COIN; - pub const AdvancedFee: Balance = 50 * COIN; - pub const SyncReward: Balance = 1000 * COIN; -} -impl hyperspace_ethereum_backing::Config for Runtime { - type ModuleId = EthereumBackingModuleId; - type FeeModuleId = EthereumBackingFeeModuleId; - type Event = Event; - type RedeemAccountId = AccountId; - type EthereumRelay = EthereumRelay; - type OnDepositRedeem = Staking; - type EtpCurrency = Etp; - type DnaCurrency = Dna; - type EtpLockLimit = EtpLockLimit; - type DnaLockLimit = DnaLockLimit; - type AdvancedFee = AdvancedFee; - type SyncReward = SyncReward; - type EcdsaAuthorities = EthereumRelayAuthorities; - type WeightInfo = (); -} - -type EnsureRootOrHalfTechnicalComittee = EnsureOneOf< - AccountId, - EnsureRoot, - pallet_collective::EnsureProportionMoreThan<_1, _2, AccountId, TechnicalCollective>, ->; -parameter_types! { - pub const EthereumRelayModuleId: ModuleId = ModuleId(*b"da/ethrl"); - pub const EthereumNetwork: ethereum_primitives::EthereumNetworkType = ethereum_primitives::EthereumNetworkType::Ropsten; - pub const ConfirmPeriod: BlockNumber = 200; - pub const ApproveThreshold: Perbill = Perbill::from_percent(60); - pub const RejectThreshold: Perbill = Perbill::from_percent(1); -} -impl hyperspace_ethereum_relay::Config for Runtime { - type ModuleId = EthereumRelayModuleId; - type Event = Event; - type EthereumNetwork = EthereumNetwork; - type Call = Call; - type Currency = Etp; - type RelayerGame = EthereumRelayerGame; - type ApproveOrigin = ApproveOrigin; - type RejectOrigin = EnsureRootOrHalfTechnicalComittee; - type ConfirmPeriod = ConfirmPeriod; - type TechnicalMembership = TechnicalMembership; - type ApproveThreshold = ApproveThreshold; - type RejectThreshold = RejectThreshold; - type WeightInfo = (); -} - -type EthereumRelayerGameInstance = hyperspace_relayer_game::Instance0; -parameter_types! { - pub const EthereumRelayerGameLockId: LockIdentifier = *b"ethrgame"; -} -impl hyperspace_relayer_game::Config for Runtime { - type EtpCurrency = Etp; - type LockId = EthereumRelayerGameLockId; - type EtpSlash = Treasury; - type RelayerGameAdjustor = relay::EthereumRelayerGameAdjustor; - type RelayableChain = EthereumRelay; - type WeightInfo = (); -} - -parameter_types! { - pub const OldetpBackingModuleId: ModuleId = ModuleId(*b"da/trobk"); -} -impl hyperspace_oldetp_backing::Config for Runtime { - type ModuleId = OldetpBackingModuleId; - type EtpCurrency = Etp; - type DnaCurrency = Dna; - type WeightInfo = (); -} - -impl hyperspace_header_mmr::Config for Runtime {} - -/// Fixed gas price of `1`. -pub struct FixedGasPrice; -impl FeeCalculator for FixedGasPrice { - fn min_gas_price() -> U256 { - // Gas price is always one token per gas. - //1.into() - 10_000_000_000u64.into() - } -} - -parameter_types! { - pub const ChainId: u64 = 23; -} -impl hyperspace_evm::Config for Runtime { - type FeeCalculator = FixedGasPrice; - type GasWeightMapping = (); - type CallOrigin = EnsureAddressTruncated; - type WithdrawOrigin = EnsureAddressTruncated; - type AddressMapping = ConcatAddressMapping; - type EtpCurrency = Etp; - type DnaCurrency = Dna; - type Event = Event; - type Precompiles = hyperspace_evm_precompile::HyperspacePrecompiles; - type ChainId = ChainId; - type AccountBasicMapping = DVMAccountBasicMapping; - type Runner = hyperspace_evm::runner::stack::Runner; -} - -type EthereumRelayAuthoritiesInstance = hyperspace_relay_authorities::Instance0; -parameter_types! { - pub const EthereumRelayAuthoritiesLockId: LockIdentifier = *b"ethrauth"; - pub const EthereumRelayAuthoritiesTermDuration: BlockNumber = 30 * DAYS; - pub const MaxCandidates: usize = 7; - pub const OpCodes: (OpCode, OpCode) = ( - [71, 159, 189, 249], - [180, 188, 244, 151] - ); - pub const SignThreshold: Perbill = Perbill::from_percent(60); - pub const SubmitDuration: BlockNumber = 100; -} -impl hyperspace_relay_authorities::Config for Runtime { - type Event = Event; - type EtpCurrency = Etp; - type LockId = EthereumRelayAuthoritiesLockId; - type TermDuration = EthereumRelayAuthoritiesTermDuration; - type MaxCandidates = MaxCandidates; - type AddOrigin = ApproveOrigin; - type RemoveOrigin = ApproveOrigin; - type ResetOrigin = ApproveOrigin; - type HyperspaceMMR = HeaderMMR; - type Sign = EthereumBacking; - type OpCodes = OpCodes; - type SignThreshold = SignThreshold; - type SubmitDuration = SubmitDuration; - type WeightInfo = (); -} - -pub struct EthereumFindAuthor(sp_std::marker::PhantomData); -impl> FindAuthor for EthereumFindAuthor { - fn find_author<'a, I>(digests: I) -> Option - where - I: 'a + IntoIterator, - { - if let Some(author_index) = F::find_author(digests) { - let authority_id = Babe::authorities()[author_index as usize].clone(); - return Some(H160::from_slice(&authority_id.0.to_raw_vec()[4..24])); - } - None - } -} - -parameter_types! { - pub BlockGasLimit: U256 = U256::from(u32::max_value()); -} -impl dvm_ethereum::Config for Runtime { - type Event = Event; - type FindAuthor = EthereumFindAuthor; - type StateRoot = dvm_ethereum::IntermediateStateRoot; - type BlockGasLimit = BlockGasLimit; - type AddressMapping = ConcatAddressMapping; - type EtpCurrency = Etp; -} - -construct_runtime! { +frame_support::construct_runtime! { pub enum Runtime where Block = Block, @@ -1199,36 +448,49 @@ construct_runtime! { TechnicalMembership: pallet_membership::::{Module, Call, Storage, Config, Event} = 19, Treasury: hyperspace_treasury::{Module, Call, Storage, Event} = 20, + Sudo: pallet_sudo::{Module, Call, Storage, Config, Event} = 21, + // Claims. Usable initially. - Claims: hyperspace_claims::{Module, Call, Storage, Config, Event, ValidateUnsigned} = 21, + Claims: hyperspace_claims::{Module, Call, Storage, Config, Event, ValidateUnsigned} = 22, // Vesting. Usable initially, but removed once all vesting is finished. - Vesting: hyperspace_vesting::{Module, Call, Storage, Event, Config} = 22, + Vesting: hyperspace_vesting::{Module, Call, Storage, Event, Config} = 23, + + // Utility module. + Utility: pallet_utility::{Module, Call, Event} = 24, + + // Less simple identity module. + Identity: pallet_identity::{Module, Call, Storage, Event} = 25, + + // Society module. + Society: pallet_society::{Module, Call, Storage, Event} = 26, + + // Social recovery module. + Recovery: pallet_recovery::{Module, Call, Storage, Event} = 27, // System scheduler. - Scheduler: pallet_scheduler::{Module, Call, Storage, Event} = 23, + Scheduler: pallet_scheduler::{Module, Call, Storage, Event} = 28, // Proxy module. Late addition. - Proxy: pallet_proxy::{Module, Call, Storage, Event} = 24, + Proxy: pallet_proxy::{Module, Call, Storage, Event} = 29, - Sudo: pallet_sudo::{Module, Call, Storage, Config, Event} = 25, + // Multisig module. Late addition. + Multisig: pallet_multisig::{Module, Call, Storage, Event} = 30, - HeaderMMR: hyperspace_header_mmr::{Module, Call, Storage} = 26, + HeaderMMR: hyperspace_header_mmr::{Module, Call, Storage} = 31, - OldnaIssuing: hyperspace_oldna_issuing::{Module, Call, Storage, Config, Event} = 27, - OldnaBacking: hyperspace_oldna_backing::{Module, Storage, Config} = 28, + OldetpIssuing: hyperspace_oldetp_issuing::{Module, Call, Storage, Config, Event} = 32, + OldetpBacking: hyperspace_oldetp_backing::{Module, Storage, Config} = 33, - EthereumRelay: hyperspace_ethereum_relay::{Module, Call, Storage, Config, Event} = 29, - EthereumBacking: hyperspace_ethereum_backing::{Module, Call, Storage, Config, Event} = 30, - EthereumRelayerGame: hyperspace_relayer_game::::{Module, Storage} = 31, - EthereumRelayAuthorities: hyperspace_relay_authorities::::{Module, Call, Storage, Config, Event} = 32, + EthereumRelay: hyperspace_ethereum_relay::{Module, Call, Storage, Config, Event} = 34, + EthereumBacking: hyperspace_ethereum_backing::{Module, Call, Storage, Config, Event} = 35, + EthereumRelayerGame: hyperspace_relayer_game::::{Module, Storage} = 36, + EthereumRelayAuthorities: hyperspace_relay_authorities::::{Module, Call, Storage, Config, Event} = 37, - OldetpBacking: hyperspace_oldetp_backing::{Module, Storage, Config} = 33, + OldnaBacking: hyperspace_oldna_backing::{Module, Storage, Config} = 38, - EVM: hyperspace_evm::{Module, Call, Storage, Config, Event} = 34, - Ethereum: dvm_ethereum::{Module, Call, Storage, Config, Event, ValidateUnsigned} = 35, - // Multisig module. - Multisig: pallet_multisig::{Module, Call, Storage, Event} = 36, + EVM: hyperspace_evm::{Module, Call, Storage, Config, Event} = 39, + Ethereum: dvm_ethereum::{Module, Call, Storage, Config, Event, ValidateUnsigned} = 40, } } @@ -1504,6 +766,9 @@ impl_runtime_apis! { } fn account_basic(address: H160) -> EVMAccount { + // --- hyperspace --- + use hyperspace_evm::AccountBasicMapping; + ::AccountBasicMapping::account_basic(&address) } @@ -1636,15 +901,13 @@ impl dvm_rpc_runtime_api::ConvertTransaction for TransactionCon // } pub struct PhragmenElectionDepositRuntimeUpgrade; -impl hyperspace_elections_phragmen::migrations_3_0_0::V2ToV3 - for PhragmenElectionDepositRuntimeUpgrade -{ +impl hyperspace_elections_phragmen::migrations_2_0_0::ToV2 for PhragmenElectionDepositRuntimeUpgrade { type AccountId = AccountId; type Balance = Balance; type Module = ElectionsPhragmen; } impl frame_support::traits::OnRuntimeUpgrade for PhragmenElectionDepositRuntimeUpgrade { fn on_runtime_upgrade() -> frame_support::weights::Weight { - hyperspace_elections_phragmen::migrations_3_0_0::apply::(5 * MILLI, COIN) + hyperspace_elections_phragmen::migrations_2_0_0::apply::(5 * MILLI, COIN) } } diff --git a/bin/node/runtime/hyperspace/src/membership.rs b/bin/node/runtime/hyperspace/src/membership.rs new file mode 100644 index 0000000..38c774a --- /dev/null +++ b/bin/node/runtime/hyperspace/src/membership.rs @@ -0,0 +1,27 @@ +// --- substrate --- +use frame_support::traits::ChangeMembers; +use pallet_membership::{Config, Instance0}; +// --- hyperspace --- +use crate::*; + +pub struct MembershipChangedGroup; +impl ChangeMembers for MembershipChangedGroup { + fn change_members_sorted( + incoming: &[AccountId], + outgoing: &[AccountId], + sorted_new: &[AccountId], + ) { + TechnicalCommittee::change_members_sorted(incoming, outgoing, sorted_new); + EthereumRelay::change_members_sorted(incoming, outgoing, sorted_new); + } +} +impl Config for Runtime { + type Event = Event; + type AddOrigin = EnsureRootOrMoreThanHalfCouncil; + type RemoveOrigin = EnsureRootOrMoreThanHalfCouncil; + type SwapOrigin = EnsureRootOrMoreThanHalfCouncil; + type ResetOrigin = EnsureRootOrMoreThanHalfCouncil; + type PrimeOrigin = EnsureRootOrMoreThanHalfCouncil; + type MembershipInitialized = TechnicalCommittee; + type MembershipChanged = MembershipChangedGroup; +} diff --git a/bin/node/runtime/hyperspace/src/multisig.rs b/bin/node/runtime/hyperspace/src/multisig.rs new file mode 100644 index 0000000..dc79ab8 --- /dev/null +++ b/bin/node/runtime/hyperspace/src/multisig.rs @@ -0,0 +1,21 @@ +// --- substrate --- +use pallet_multisig::Config; +// --- hyperspace --- +use crate::*; + +frame_support::parameter_types! { + // One storage item; key size is 32; value is size 4+4+16+32 bytes = 56 bytes. + pub const DepositBase: Balance = constants::deposit(1, 88); + // Additional storage item size of 32 bytes. + pub const DepositFactor: Balance = constants::deposit(0, 32); + pub const MaxSignatories: u16 = 100; +} +impl Config for Runtime { + type Event = Event; + type Call = Call; + type Currency = Etp; + type DepositBase = DepositBase; + type DepositFactor = DepositFactor; + type MaxSignatories = MaxSignatories; + type WeightInfo = (); +} diff --git a/bin/node/runtime/hyperspace/src/offences.rs b/bin/node/runtime/hyperspace/src/offences.rs new file mode 100644 index 0000000..9875619 --- /dev/null +++ b/bin/node/runtime/hyperspace/src/offences.rs @@ -0,0 +1,18 @@ +// --- substrate --- +use frame_support::weights::Weight; +use pallet_offences::Config; +use pallet_session::historical::IdentificationTuple; +use sp_runtime::Perbill; +// --- hyperspace --- +use crate::*; + +frame_support::parameter_types! { + pub OffencesWeightSoftLimit: Weight = Perbill::from_percent(60) * + RuntimeBlockWeights::get().max_block; +} +impl Config for Runtime { + type Event = Event; + type IdentificationTuple = IdentificationTuple; + type OnOffenceHandler = Staking; + type WeightSoftLimit = OffencesWeightSoftLimit; +} diff --git a/bin/node/runtime/hyperspace/src/oldetp_backing.rs b/bin/node/runtime/hyperspace/src/oldetp_backing.rs new file mode 100644 index 0000000..14d2142 --- /dev/null +++ b/bin/node/runtime/hyperspace/src/oldetp_backing.rs @@ -0,0 +1,14 @@ +// --- substrate --- +use sp_runtime::ModuleId; +// --- hyperspace --- +use crate::*; +use hyperspace_oldetp_backing::Config; + +frame_support::parameter_types! { + pub const OldetpBackingModuleId: ModuleId = ModuleId(*b"da/oldek"); +} +impl Config for Runtime { + type ModuleId = OldetpBackingModuleId; + type EtpCurrency = Etp; + type WeightInfo = (); +} diff --git a/bin/node/runtime/hyperspace/src/oldetp_issuing.rs b/bin/node/runtime/hyperspace/src/oldetp_issuing.rs new file mode 100644 index 0000000..be52d58 --- /dev/null +++ b/bin/node/runtime/hyperspace/src/oldetp_issuing.rs @@ -0,0 +1,15 @@ +// --- substrate --- +use sp_runtime::ModuleId; +// --- hyperspace --- +use crate::*; +use hyperspace_oldetp_issuing::Config; + +frame_support::parameter_types! { + pub const OldetpIssuingModuleId: ModuleId = ModuleId(*b"da/crais"); +} +impl Config for Runtime { + type Event = Event; + type ModuleId = OldetpIssuingModuleId; + type EtpCurrency = Etp; + type WeightInfo = (); +} diff --git a/bin/node/runtime/hyperspace/src/oldna_backing.rs b/bin/node/runtime/hyperspace/src/oldna_backing.rs new file mode 100644 index 0000000..7efadde --- /dev/null +++ b/bin/node/runtime/hyperspace/src/oldna_backing.rs @@ -0,0 +1,15 @@ +// --- substrate --- +use sp_runtime::ModuleId; +// --- hyperspace --- +use crate::*; +use hyperspace_oldna_backing::Config; + +frame_support::parameter_types! { + pub const OldnaBackingModuleId: ModuleId = ModuleId(*b"da/trobk"); +} +impl Config for Runtime { + type ModuleId = OldnaBackingModuleId; + type EtpCurrency = Etp; + type DnaCurrency = Dna; + type WeightInfo = (); +} diff --git a/bin/node/runtime/hyperspace/src/proxy.rs b/bin/node/runtime/hyperspace/src/proxy.rs new file mode 100644 index 0000000..df01be0 --- /dev/null +++ b/bin/node/runtime/hyperspace/src/proxy.rs @@ -0,0 +1,122 @@ +// --- crates.io --- +use codec::{Decode, Encode}; +// --- substrate --- +use frame_support::traits::InstanceFilter; +use pallet_proxy::{weights::SubstrateWeight, Config}; +use sp_runtime::{traits::BlakeTwo256, RuntimeDebug}; +// --- hyperspace --- +use crate::*; + +/// The type used to represent the kinds of proxying allowed. +#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, RuntimeDebug)] +pub enum ProxyType { + Any, + NonTransfer, + Governance, + Staking, + EthereumBridge, +} +impl Default for ProxyType { + fn default() -> Self { + Self::Any + } +} +impl InstanceFilter for ProxyType { + fn filter(&self, c: &Call) -> bool { + match self { + ProxyType::Any => true, + ProxyType::NonTransfer => matches!( + c, + Call::System(..) | + Call::Babe(..) | + Call::Timestamp(..) | + // Specifically omitting the entire Balances pallet + Call::Authorship(..) | + Call::Staking(..) | + Call::Offences(..) | + Call::Session(..) | + Call::Grandpa(..) | + Call::ImOnline(..) | + Call::AuthorityDiscovery(..) | + Call::Democracy(..) | + Call::Council(..) | + Call::TechnicalCommittee(..) | + Call::ElectionsPhragmen(..) | + Call::TechnicalMembership(..) | + Call::Treasury(..) | + Call::Sudo(..) | + // Specifically omitting Vesting `vested_transfer`, and `force_vested_transfer` + Call::Vesting(hyperspace_vesting::Call::vest(..)) | + Call::Vesting(hyperspace_vesting::Call::vest_other(..)) | + Call::Utility(..)| + Call::Identity(..)| + Call::Society(..)| + // Specifically omitting Recovery `create_recovery`, `initiate_recovery` + Call::Recovery(pallet_recovery::Call::as_recovered(..)) | + Call::Recovery(pallet_recovery::Call::vouch_recovery(..)) | + Call::Recovery(pallet_recovery::Call::claim_recovery(..)) | + Call::Recovery(pallet_recovery::Call::close_recovery(..)) | + Call::Recovery(pallet_recovery::Call::remove_recovery(..)) | + Call::Recovery(pallet_recovery::Call::cancel_recovered(..)) | + Call::Scheduler(..)| + Call::Proxy(..)| + Call::Multisig(..)| + Call::HeaderMMR(..)| + // Specifically omitting the entire OldetpIssuing pallet + // Specifically omitting the entire OldetpBacking pallet + Call::EthereumRelay(..) | + // Specifically omitting the entire EthereumBacking pallet + Call::EthereumRelayAuthorities(..) // Specifically omitting the entire OldnaBacking pallet + // Specifically omitting the entire EVM pallet + // Specifically omitting the entire Ethereum pallet + ), + ProxyType::Governance => matches!( + c, + Call::Democracy(..) + | Call::Council(..) | Call::TechnicalCommittee(..) + | Call::ElectionsPhragmen(..) + | Call::Treasury(..) + ), + ProxyType::Staking => matches!(c, Call::Staking(..)), + ProxyType::EthereumBridge => matches!( + c, + Call::EthereumBacking(..) + | Call::EthereumRelay(..) + | Call::EthereumRelayAuthorities(..) + ), + } + } + fn is_superset(&self, o: &Self) -> bool { + match (self, o) { + (x, y) if x == y => true, + (ProxyType::Any, _) => true, + (_, ProxyType::Any) => false, + (ProxyType::NonTransfer, _) => true, + _ => false, + } + } +} +frame_support::parameter_types! { + // One storage item; key size 32, value size 8; . + pub const ProxyDepositBase: Balance = constants::deposit(1, 8); + // Additional storage item size of 33 bytes. + pub const ProxyDepositFactor: Balance = constants::deposit(0, 33); + pub const MaxProxies: u16 = 32; + pub const AnnouncementDepositBase: Balance = constants::deposit(1, 8); + pub const AnnouncementDepositFactor: Balance = constants::deposit(0, 66); + pub const MaxPending: u16 = 32; +} +impl Config for Runtime { + type Event = Event; + type Call = Call; + type Currency = Etp; + type ProxyType = ProxyType; + type ProxyDepositBase = ProxyDepositBase; + type ProxyDepositFactor = ProxyDepositFactor; + type MaxProxies = MaxProxies; + type MaxPending = MaxPending; + type CallHasher = BlakeTwo256; + type AnnouncementDepositBase = AnnouncementDepositBase; + type AnnouncementDepositFactor = AnnouncementDepositFactor; + type WeightInfo = SubstrateWeight; +} diff --git a/bin/node/runtime/hyperspace/src/recovery.rs b/bin/node/runtime/hyperspace/src/recovery.rs new file mode 100644 index 0000000..84fe8d1 --- /dev/null +++ b/bin/node/runtime/hyperspace/src/recovery.rs @@ -0,0 +1,20 @@ +// --- substrate --- +use pallet_recovery::Config; +// --- hyperspace --- +use crate::*; + +frame_support::parameter_types! { + pub const ConfigDepositBase: Balance = 5 * COIN; + pub const FriendDepositFactor: Balance = 50 * MILLI; + pub const MaxFriends: u16 = 9; + pub const RecoveryDeposit: Balance = 5 * COIN; +} +impl Config for Runtime { + type Event = Event; + type Call = Call; + type Currency = Etp; + type ConfigDepositBase = ConfigDepositBase; + type FriendDepositFactor = FriendDepositFactor; + type MaxFriends = MaxFriends; + type RecoveryDeposit = RecoveryDeposit; +} diff --git a/bin/node/runtime/hyperspace/src/relay_authorities.rs b/bin/node/runtime/hyperspace/src/relay_authorities.rs new file mode 100644 index 0000000..c6702d6 --- /dev/null +++ b/bin/node/runtime/hyperspace/src/relay_authorities.rs @@ -0,0 +1,38 @@ +// --- hyperspace --- +pub use hyperspace_relay_authorities::Instance0 as EthereumRelayAuthoritiesInstance; + +// --- substrate --- +use frame_support::traits::LockIdentifier; +use sp_runtime::Perbill; +// --- hyperspace --- +use crate::*; +use hyperspace_relay_authorities::Config; +use hyperspace_relay_primitives::relay_authorities::OpCode; + +frame_support::parameter_types! { + pub const EthereumRelayAuthoritiesLockId: LockIdentifier = *b"ethrauth"; + pub const EthereumRelayAuthoritiesTermDuration: BlockNumber = 3 * MINUTES; + pub const MaxCandidates: usize = 7; + pub const OpCodes: (OpCode, OpCode) = ( + [71, 159, 189, 249], + [180, 188, 244, 151] + ); + pub const SignThreshold: Perbill = Perbill::from_percent(60); + pub const SubmitDuration: BlockNumber = 30; +} +impl Config for Runtime { + type Event = Event; + type EtpCurrency = Etp; + type LockId = EthereumRelayAuthoritiesLockId; + type TermDuration = EthereumRelayAuthoritiesTermDuration; + type MaxCandidates = MaxCandidates; + type AddOrigin = ApproveOrigin; + type RemoveOrigin = ApproveOrigin; + type ResetOrigin = ApproveOrigin; + type HyperspaceMMR = HeaderMMR; + type Sign = EthereumBacking; + type OpCodes = OpCodes; + type SignThreshold = SignThreshold; + type SubmitDuration = SubmitDuration; + type WeightInfo = (); +} diff --git a/bin/node/runtime/hyperspace/src/relayer_game.rs b/bin/node/runtime/hyperspace/src/relayer_game.rs new file mode 100644 index 0000000..c59a84d --- /dev/null +++ b/bin/node/runtime/hyperspace/src/relayer_game.rs @@ -0,0 +1,20 @@ +// --- hyperspace --- +pub use hyperspace_relayer_game::Instance0 as EthereumRelayerGameInstance; + +// --- substrate --- +use frame_support::traits::LockIdentifier; +// --- hyperspace --- +use crate::*; +use hyperspace_relayer_game::Config; + +frame_support::parameter_types! { + pub const EthereumRelayerGameLockId: LockIdentifier = *b"ethrgame"; +} +impl Config for Runtime { + type EtpCurrency = Etp; + type LockId = EthereumRelayerGameLockId; + type EtpSlash = Treasury; + type RelayerGameAdjustor = relay::EthereumRelayerGameAdjustor; + type RelayableChain = EthereumRelay; + type WeightInfo = (); +} diff --git a/bin/node/runtime/hyperspace/src/scheduler.rs b/bin/node/runtime/hyperspace/src/scheduler.rs new file mode 100644 index 0000000..51e0ace --- /dev/null +++ b/bin/node/runtime/hyperspace/src/scheduler.rs @@ -0,0 +1,23 @@ +// --- substrate --- +use frame_support::weights::Weight; +use frame_system::EnsureRoot; +use pallet_scheduler::{weights::SubstrateWeight, Config}; +use sp_runtime::Perbill; +// --- hyperspace --- +use crate::*; + +frame_support::parameter_types! { + pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) * + RuntimeBlockWeights::get().max_block; + pub const MaxScheduledPerBlock: u32 = 50; +} +impl Config for Runtime { + type Event = Event; + type Origin = Origin; + type PalletsOrigin = OriginCaller; + type Call = Call; + type MaximumWeight = MaximumSchedulerWeight; + type ScheduleOrigin = EnsureRoot; + type MaxScheduledPerBlock = MaxScheduledPerBlock; + type WeightInfo = SubstrateWeight; +} diff --git a/bin/node/runtime/hyperspace/src/session.rs b/bin/node/runtime/hyperspace/src/session.rs new file mode 100644 index 0000000..1d94de8 --- /dev/null +++ b/bin/node/runtime/hyperspace/src/session.rs @@ -0,0 +1,31 @@ +// --- substrate --- +use pallet_session::{historical::NoteHistoricalRoot, weights::SubstrateWeight, Config}; +use sp_runtime::{impl_opaque_keys, traits::OpaqueKeys, Perbill}; +use sp_std::prelude::*; +// --- hyperspace --- +use crate::*; +use hyperspace_staking::StashOf; + +impl_opaque_keys! { + pub struct SessionKeys { + pub babe: Babe, + pub grandpa: Grandpa, + pub im_online: ImOnline, + pub authority_discovery: AuthorityDiscovery, + } +} +frame_support::parameter_types! { + pub const DisabledValidatorsThreshold: Perbill = Perbill::from_percent(17); +} +impl Config for Runtime { + type Event = Event; + type ValidatorId = AccountId; + type ValidatorIdOf = StashOf; + type ShouldEndSession = Babe; + type NextSessionRotation = Babe; + type SessionManager = NoteHistoricalRoot; + type SessionHandler = ::KeyTypeIdProviders; + type Keys = SessionKeys; + type DisabledValidatorsThreshold = DisabledValidatorsThreshold; + type WeightInfo = SubstrateWeight; +} diff --git a/bin/node/runtime/hyperspace/src/session_historical.rs b/bin/node/runtime/hyperspace/src/session_historical.rs new file mode 100644 index 0000000..5ca3a9e --- /dev/null +++ b/bin/node/runtime/hyperspace/src/session_historical.rs @@ -0,0 +1,13 @@ +// --- substrate --- +pub use pallet_session::historical as pallet_session_historical; + +// --- substrate --- +use pallet_session_historical::Config; +// --- hyperspace --- +use crate::*; +use hyperspace_staking::{Exposure, ExposureOf}; + +impl Config for Runtime { + type FullIdentification = Exposure; + type FullIdentificationOf = ExposureOf; +} diff --git a/bin/node/runtime/hyperspace/src/society.rs b/bin/node/runtime/hyperspace/src/society.rs new file mode 100644 index 0000000..9bdd802 --- /dev/null +++ b/bin/node/runtime/hyperspace/src/society.rs @@ -0,0 +1,32 @@ +// --- substrate --- +use pallet_society::{Config, EnsureFounder}; +use sp_runtime::ModuleId; +// --- hyperspace --- +use crate::*; + +frame_support::parameter_types! { + pub const SocietyModuleId: ModuleId = ModuleId(*b"da/socie"); + pub const CandidateDeposit: Balance = 10 * COIN; + pub const WrongSideDeduction: Balance = 2 * COIN; + pub const MaxStrikes: u32 = 10; + pub const RotationPeriod: BlockNumber = 3 * MINUTES; + pub const PeriodSpend: Balance = 500 * COIN; + pub const MaxLockDuration: BlockNumber = 3 * MINUTES; + pub const ChallengePeriod: BlockNumber = 3 * MINUTES; +} +impl Config for Runtime { + type Event = Event; + type ModuleId = SocietyModuleId; + type Currency = Etp; + type Randomness = RandomnessCollectiveFlip; + type CandidateDeposit = CandidateDeposit; + type WrongSideDeduction = WrongSideDeduction; + type MaxStrikes = MaxStrikes; + type PeriodSpend = PeriodSpend; + type MembershipChanged = (); + type RotationPeriod = RotationPeriod; + type MaxLockDuration = MaxLockDuration; + type FounderSetOrigin = EnsureRootOrMoreThanHalfCouncil; + type SuspensionJudgementOrigin = EnsureFounder; + type ChallengePeriod = ChallengePeriod; +} diff --git a/bin/node/runtime/hyperspace/src/staking.rs b/bin/node/runtime/hyperspace/src/staking.rs new file mode 100644 index 0000000..bd829b4 --- /dev/null +++ b/bin/node/runtime/hyperspace/src/staking.rs @@ -0,0 +1,63 @@ +// --- substrate --- +use frame_support::weights::{constants::BlockExecutionWeight, DispatchClass, Weight}; +use sp_runtime::{transaction_validity::TransactionPriority, ModuleId, Perbill}; +use sp_staking::SessionIndex; +// --- hyperspace --- +use crate::*; +use hyperspace_staking::{weights::SubstrateWeight, Config, EraIndex}; + +frame_support::parameter_types! { + pub const StakingModuleId: ModuleId = ModuleId(*b"da/staki"); + pub const SessionsPerEra: SessionIndex = SESSIONS_PER_ERA; + pub const BondingDurationInEra: EraIndex = 2; + pub const BondingDurationInBlockNumber: BlockNumber = 2 * BLOCKS_PER_SESSION * SESSIONS_PER_ERA; + pub const SlashDeferDuration: EraIndex = 1; + // quarter of the last session will be for election. + pub const ElectionLookahead: BlockNumber = BLOCKS_PER_SESSION / 2; + pub const MaxIterations: u32 = 5; + pub MinSolutionScoreBump: Perbill = Perbill::from_rational_approximation(5u32, 10_000); + pub const MaxNominatorRewardedPerValidator: u32 = 128; + pub const StakingUnsignedPriority: TransactionPriority = TransactionPriority::max_value() / 2; + pub OffchainSolutionWeightLimit: Weight = RuntimeBlockWeights::get() + .get(DispatchClass::Normal) + .max_extrinsic.expect("Normal extrinsics have a weight limit configured; qed") + .saturating_sub(BlockExecutionWeight::get()); + pub const Cap: Balance = CAP; + pub const TotalPower: Power = TOTAL_POWER; +} +impl Config for Runtime { + type Event = Event; + type ModuleId = StakingModuleId; + type UnixTime = Timestamp; + type SessionsPerEra = SessionsPerEra; + type BondingDurationInEra = BondingDurationInEra; + type BondingDurationInBlockNumber = BondingDurationInBlockNumber; + type SlashDeferDuration = SlashDeferDuration; + /// A super-majority of the council can cancel the slash. + type SlashCancelOrigin = EnsureRootOrHalfCouncil; + type SessionInterface = Self; + type NextNewSession = Session; + type ElectionLookahead = ElectionLookahead; + type Call = Call; + type MaxIterations = MaxIterations; + type MinSolutionScoreBump = MinSolutionScoreBump; + type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator; + type UnsignedPriority = StakingUnsignedPriority; + // The unsigned solution weight targeted by the OCW. We set it to the maximum possible value of + // a single extrinsic. + type OffchainSolutionWeightLimit = OffchainSolutionWeightLimit; + type EtpCurrency = Etp; + type EtpRewardRemainder = Treasury; + // send the slashed funds to the treasury. + type EtpSlash = Treasury; + // rewards are minted from the void + type EtpReward = (); + type DnaCurrency = Dna; + // send the slashed funds to the treasury. + type DnaSlash = Treasury; + // rewards are minted from the void + type DnaReward = (); + type Cap = Cap; + type TotalPower = TotalPower; + type WeightInfo = SubstrateWeight; +} diff --git a/bin/node/runtime/hyperspace/src/sudo.rs b/bin/node/runtime/hyperspace/src/sudo.rs new file mode 100644 index 0000000..6eface7 --- /dev/null +++ b/bin/node/runtime/hyperspace/src/sudo.rs @@ -0,0 +1,9 @@ +// --- substrate --- +use pallet_sudo::Config; +// --- hyperspace --- +use crate::*; + +impl Config for Runtime { + type Event = Event; + type Call = Call; +} diff --git a/bin/node/runtime/hyperspace/src/system.rs b/bin/node/runtime/hyperspace/src/system.rs new file mode 100644 index 0000000..da38c12 --- /dev/null +++ b/bin/node/runtime/hyperspace/src/system.rs @@ -0,0 +1,78 @@ +// --- substrate --- +use frame_support::weights::{ + constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND}, + DispatchClass, Weight, +}; +use frame_system::{ + limits::{BlockLength, BlockWeights}, + weights::SubstrateWeight, + Config, +}; +use sp_runtime::{ + traits::{AccountIdLookup, BlakeTwo256}, + Perbill, +}; +use sp_version::RuntimeVersion; +// --- hyperspace --- +use crate::*; + +/// We assume that an on-initialize consumes 2.5% of the weight on average, hence a single extrinsic +/// will not be allowed to consume more than `AvailableBlockRatio - 2.5%`. +const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(25); +/// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used +/// by Operational extrinsics. +const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); +/// We allow for 2 seconds of compute with a 6 second average block time. +const MAXIMUM_BLOCK_WEIGHT: Weight = 2 * WEIGHT_PER_SECOND; +static_assertions::const_assert!( + NORMAL_DISPATCH_RATIO.deconstruct() >= AVERAGE_ON_INITIALIZE_RATIO.deconstruct() +); +frame_support::parameter_types! { + pub const BlockHashCount: BlockNumber = 2400; + pub const Version: RuntimeVersion = VERSION; + pub RuntimeBlockLength: BlockLength = + BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO); + pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder() + .base_block(BlockExecutionWeight::get()) + .for_class(DispatchClass::all(), |weights| { + weights.base_extrinsic = ExtrinsicBaseWeight::get(); + }) + .for_class(DispatchClass::Normal, |weights| { + weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT); + }) + .for_class(DispatchClass::Operational, |weights| { + weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT); + // Operational transactions have some extra reserved space, so that they + // are included even if block reached `MAXIMUM_BLOCK_WEIGHT`. + weights.reserved = Some( + MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT + ); + }) + .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO) + .build_or_panic(); + pub const SS58Prefix: u8 = 18; +} +impl Config for Runtime { + type BaseCallFilter = (); + type BlockWeights = RuntimeBlockWeights; + type BlockLength = RuntimeBlockLength; + type DbWeight = RocksDbWeight; + type Origin = Origin; + type Call = Call; + type Index = Nonce; + type BlockNumber = BlockNumber; + type Hash = Hash; + type Hashing = BlakeTwo256; + type AccountId = AccountId; + type Lookup = AccountIdLookup; + type Header = Header; + type Event = Event; + type BlockHashCount = BlockHashCount; + type Version = Version; + type PalletInfo = PalletInfo; + type AccountData = AccountData; + type OnNewAccount = (); + type OnKilledAccount = (); + type SystemWeightInfo = SubstrateWeight; + type SS58Prefix = SS58Prefix; +} diff --git a/bin/node/runtime/hyperspace/src/timestamp.rs b/bin/node/runtime/hyperspace/src/timestamp.rs new file mode 100644 index 0000000..06a4fb6 --- /dev/null +++ b/bin/node/runtime/hyperspace/src/timestamp.rs @@ -0,0 +1,14 @@ +// --- substrate --- +use pallet_timestamp::{weights::SubstrateWeight, Config}; +// --- hyperspace --- +use crate::*; + +frame_support::parameter_types! { + pub const MinimumPeriod: Moment = SLOT_DURATION / 2; +} +impl Config for Runtime { + type Moment = Moment; + type OnTimestampSet = Babe; + type MinimumPeriod = MinimumPeriod; + type WeightInfo = SubstrateWeight; +} diff --git a/bin/node/runtime/hyperspace/src/transaction_payment.rs b/bin/node/runtime/hyperspace/src/transaction_payment.rs new file mode 100644 index 0000000..a3b9264 --- /dev/null +++ b/bin/node/runtime/hyperspace/src/transaction_payment.rs @@ -0,0 +1,29 @@ +// --- substrate --- +use pallet_transaction_payment::{Config, CurrencyAdapter, Multiplier, TargetedFeeAdjustment}; +use sp_runtime::{FixedPointNumber, Perquintill}; +// --- hyperspace --- +use crate::*; + +/// Parameterized slow adjusting fee updated based on +/// https://w3f-research.readthedocs.io/en/latest/polkadot/Token%20Economics.html#-2.-slow-adjusting-mechanism +pub type SlowAdjustingFeeUpdate = + TargetedFeeAdjustment; +frame_support::parameter_types! { + pub const TransactionByteFee: Balance = 10 * MICRO; + /// The portion of the `AvailableBlockRatio` that we adjust the fees with. Blocks filled less + /// than this will decrease the weight and more will increase. + pub const TargetBlockFullness: Perquintill = Perquintill::from_percent(25); + /// The adjustment variable of the runtime. Higher values will cause `TargetBlockFullness` to + /// change the fees more rapidly. + pub AdjustmentVariable: Multiplier = Multiplier::saturating_from_rational(3, 100_000); + /// Minimum amount of the multiplier. This value cannot be too low. A test case should ensure + /// that combined with `AdjustmentVariable`, we can recover from the minimum. + /// See `multiplier_can_grow_from_zero`. + pub MinimumMultiplier: Multiplier = Multiplier::saturating_from_rational(1, 1_000_000_000u128); +} +impl Config for Runtime { + type OnChargeTransaction = CurrencyAdapter; + type TransactionByteFee = TransactionByteFee; + type WeightToFee = WeightToFee; + type FeeMultiplierUpdate = SlowAdjustingFeeUpdate; +} diff --git a/bin/node/runtime/hyperspace/src/treasury.rs b/bin/node/runtime/hyperspace/src/treasury.rs new file mode 100644 index 0000000..37b3579 --- /dev/null +++ b/bin/node/runtime/hyperspace/src/treasury.rs @@ -0,0 +1,53 @@ +// --- substrate --- +use sp_runtime::{ModuleId, Percent, Permill}; +// --- hyperspace --- +use crate::*; +use hyperspace_treasury::{weights::SubstrateWeight, Config}; + +frame_support::parameter_types! { + pub const TreasuryModuleId: ModuleId = ModuleId(*b"da/trsry"); + pub const ProposalBond: Permill = Permill::from_percent(5); + pub const EtpProposalBondMinimum: Balance = 20 * COIN; + pub const DnaProposalBondMinimum: Balance = 20 * COIN; + pub const SpendPeriod: BlockNumber = 3 * MINUTES; + pub const Burn: Permill = Permill::from_percent(0); + pub const TipCountdown: BlockNumber = 3 * MINUTES; + pub const TipFindersFee: Percent = Percent::from_percent(20); + pub const TipReportDepositBase: Balance = 1 * COIN; + pub const DataDepositPerByte: Balance = 1 * MILLI; + pub const BountyDepositBase: Balance = 1 * COIN; + pub const BountyDepositPayoutDelay: BlockNumber = 3 * MINUTES; + pub const BountyUpdatePeriod: BlockNumber = 3 * MINUTES; + pub const MaximumReasonLength: u32 = 16384; + pub const BountyCuratorDeposit: Permill = Permill::from_percent(50); + pub const BountyValueMinimum: Balance = 2 * COIN; +} +impl Config for Runtime { + type ModuleId = TreasuryModuleId; + type EtpCurrency = Etp; + type DnaCurrency = Dna; + type ApproveOrigin = ApproveOrigin; + type RejectOrigin = EnsureRootOrMoreThanHalfCouncil; + type Tippers = ElectionsPhragmen; + type TipCountdown = TipCountdown; + type TipFindersFee = TipFindersFee; + type TipReportDepositBase = TipReportDepositBase; + type DataDepositPerByte = DataDepositPerByte; + type Event = Event; + type OnSlashEtp = Treasury; + type OnSlashDna = Treasury; + type ProposalBond = ProposalBond; + type EtpProposalBondMinimum = EtpProposalBondMinimum; + type DnaProposalBondMinimum = DnaProposalBondMinimum; + type SpendPeriod = SpendPeriod; + type Burn = Burn; + type BountyDepositBase = BountyDepositBase; + type BountyDepositPayoutDelay = BountyDepositPayoutDelay; + type BountyUpdatePeriod = BountyUpdatePeriod; + type MaximumReasonLength = MaximumReasonLength; + type BountyCuratorDeposit = BountyCuratorDeposit; + type BountyValueMinimum = BountyValueMinimum; + type EtpBurnDestination = (); + type DnaBurnDestination = (); + type WeightInfo = SubstrateWeight; +} diff --git a/bin/node/runtime/hyperspace/src/utility.rs b/bin/node/runtime/hyperspace/src/utility.rs new file mode 100644 index 0000000..cc21869 --- /dev/null +++ b/bin/node/runtime/hyperspace/src/utility.rs @@ -0,0 +1,10 @@ +// --- substrate --- +use pallet_utility::Config; +// --- hyperspace --- +use crate::*; + +impl Config for Runtime { + type Event = Event; + type Call = Call; + type WeightInfo = (); +} diff --git a/bin/node/runtime/hyperspace/src/vesting.rs b/bin/node/runtime/hyperspace/src/vesting.rs new file mode 100644 index 0000000..ca553ac --- /dev/null +++ b/bin/node/runtime/hyperspace/src/vesting.rs @@ -0,0 +1,16 @@ +// --- substrate --- +use sp_runtime::traits::ConvertInto; +// --- hyperspace --- +use crate::*; +use hyperspace_vesting::Config; + +frame_support::parameter_types! { + pub const MinVestedTransfer: Balance = 100 * MILLI; +} +impl Config for Runtime { + type Event = Event; + type Currency = Etp; + type BlockNumberToBalance = ConvertInto; + type MinVestedTransfer = MinVestedTransfer; + type WeightInfo = (); +} diff --git a/client/cli/Cargo.toml b/client/cli/Cargo.toml index 0e3d284..cf41af0 100644 --- a/client/cli/Cargo.toml +++ b/client/cli/Cargo.toml @@ -7,14 +7,14 @@ license = "GPL-3.0" name = "hyperspace-cli" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "1.4.0" +version = "2.0.0" [dependencies] # crates serde = { version = "1.0.124", features = ["derive"] } toml = { version = "0.5.7" } # substrate -sc-cli = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sc-client-api = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sc-service = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sc-tracing = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sc-cli = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sc-client-api = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sc-service = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sc-tracing = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } diff --git a/client/dvm/consensus/Cargo.toml b/client/dvm/consensus/Cargo.toml index 4b19e28..35ffce6 100644 --- a/client/dvm/consensus/Cargo.toml +++ b/client/dvm/consensus/Cargo.toml @@ -4,28 +4,29 @@ description = "Consensus for hyperspace dvm" edition = "2018" homepage = "https://mvs.org/" license = "GPL-3.0" -name = "dvm-consensus" +name = "dc-consensus" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "1.4.0" +version = "2.0.0" [dependencies] # crates codec = { package = "parity-scale-codec", version = "1.3.7", features = ["derive"] } +dc-db = { path = "../db" } derive_more = { version = "0.99.11" } -ethereum = { version = "0.6.0", features = ["with-codec"] } futures = { version = "0.3.13", features = ["compat"] } log = { version = "0.4.14" } # hyperspace -dvm-consensus-primitives = { path = "../../../primitives/consensus/" } +dp_consensus = { path = "../../../primitives/consensus/" } +dvm-rpc-runtime-api = { path = "../../../frame/dvm/rpc/runtime-api"} # substrate -prometheus-endpoint = { package = "substrate-prometheus-endpoint", git = "https://github.com/new-mvs/substrate", branch = "latest" } -sc-client-api = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-api = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-block-builder = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-blockchain = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-consensus = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-core = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-inherents = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-runtime = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-timestamp = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +prometheus-endpoint = { package = "substrate-prometheus-endpoint", git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sc-client-api = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-api = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-block-builder = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-blockchain = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-consensus = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-core = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-inherents = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-runtime = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-timestamp = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } diff --git a/client/dvm/consensus/src/lib.rs b/client/dvm/consensus/src/lib.rs index 689efe3..86ff6ac 100644 --- a/client/dvm/consensus/src/lib.rs +++ b/client/dvm/consensus/src/lib.rs @@ -16,13 +16,10 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -mod aux_schema; - -pub use crate::aux_schema::{load_block_hash, load_transaction_metadata}; - -use dvm_consensus_primitives::{ConsensusLog, FRONTIER_ENGINE_ID}; -use log::*; -use sc_client_api; +// --- hyperspace --- +use dp_consensus::{ensure_log, FindLogError}; +use dvm_rpc_runtime_api::EthereumRuntimeRPCApi; +// --- substrate --- use sc_client_api::{backend::AuxStore, BlockOf}; use sp_api::ProvideRuntimeApi; use sp_block_builder::BlockBuilder as BlockBuilderApi; @@ -30,18 +27,20 @@ use sp_blockchain::{well_known_cache_keys::Id as CacheKeyId, HeaderBackend, Prov use sp_consensus::{ BlockCheckParams, BlockImport, BlockImportParams, Error as ConsensusError, ImportResult, }; -use sp_runtime::generic::OpaqueDigestItemId; use sp_runtime::traits::{Block as BlockT, Header as HeaderT}; +// --- std --- use std::collections::HashMap; use std::marker::PhantomData; use std::sync::Arc; #[derive(derive_more::Display, Debug)] pub enum Error { - #[display(fmt = "Multiple post-runtime Ethereum blocks, rejecting!")] - MultiplePostRuntimeLogs, - #[display(fmt = "Post-runtime Ethereum block not found, rejecting!")] - NoPostRuntimeLog, + #[display(fmt = "Multiple runtime Ethereum blocks, rejecting!")] + MultipleRuntimeLogs, + #[display(fmt = "Runtime Ethereum block not found, rejecting!")] + NoRuntimeLog, + #[display(fmt = "Cannot access the runtime at genesis, rejecting!")] + RuntimeApiCallFailed, } impl From for String { @@ -50,7 +49,16 @@ impl From for String { } } -impl std::convert::From for ConsensusError { +impl From for Error { + fn from(error: FindLogError) -> Error { + match error { + FindLogError::NotFound => Error::NoRuntimeLog, + FindLogError::MultipleLogs => Error::MultipleRuntimeLogs, + } + } +} + +impl From for ConsensusError { fn from(error: Error) -> ConsensusError { ConsensusError::ClientImport(error.to_string()) } @@ -59,7 +67,7 @@ impl std::convert::From for ConsensusError { pub struct FrontierBlockImport { inner: I, client: Arc, - enabled: bool, + backend: Arc>, _marker: PhantomData, } @@ -68,7 +76,7 @@ impl, C> Clone for FrontierBlockImp FrontierBlockImport { inner: self.inner.clone(), client: self.client.clone(), - enabled: self.enabled, + backend: self.backend.clone(), _marker: PhantomData, } } @@ -80,13 +88,14 @@ where I: BlockImport> + Send + Sync, I::Error: Into, C: ProvideRuntimeApi + Send + Sync + HeaderBackend + AuxStore + ProvideCache + BlockOf, + C::Api: EthereumRuntimeRPCApi, C::Api: BlockBuilderApi, { - pub fn new(inner: I, client: Arc, enabled: bool) -> Self { + pub fn new(inner: I, client: Arc, backend: Arc>) -> Self { Self { inner, client, - enabled, + backend, _marker: PhantomData, } } @@ -98,6 +107,7 @@ where I: BlockImport> + Send + Sync, I::Error: Into, C: ProvideRuntimeApi + Send + Sync + HeaderBackend + AuxStore + ProvideCache + BlockOf, + C::Api: EthereumRuntimeRPCApi, C::Api: BlockBuilderApi, { type Error = ConsensusError; @@ -109,65 +119,16 @@ where fn import_block( &mut self, - mut block: BlockImportParams, + block: BlockImportParams, new_cache: HashMap>, ) -> Result { - macro_rules! insert_closure { - () => { - |insert| { - block - .auxiliary - .extend(insert.iter().map(|(k, v)| (k.to_vec(), Some(v.to_vec())))) - } - }; - } - - let client = self.client.clone(); - - if self.enabled { - let log = find_frontier_log::(&block.header)?; - let hash = block.post_hash(); - - match log { - ConsensusLog::EndBlock { - block_hash, - transaction_hashes, - } => { - aux_schema::write_block_hash( - client.as_ref(), - block_hash, - hash, - insert_closure!(), - ); - - for (index, transaction_hash) in transaction_hashes.into_iter().enumerate() { - aux_schema::write_transaction_metadata( - transaction_hash, - (block_hash, index as u32), - insert_closure!(), - ); - } - } - } - } + // We validate that there are only one frontier log. No other + // actions are needed and mapping syncing is delegated to a separate + // worker. + ensure_log(&block.header.digest()).map_err(|e| Error::from(e))?; self.inner .import_block(block, new_cache) .map_err(Into::into) } } - -fn find_frontier_log(header: &B::Header) -> Result { - let mut frontier_log: Option<_> = None; - for log in header.digest().logs() { - trace!(target: "dvm-consensus", "Checking log {:?}, looking for ethereum block.", log); - let log = log.try_to::(OpaqueDigestItemId::Consensus(&FRONTIER_ENGINE_ID)); - match (log, frontier_log.is_some()) { - (Some(_), true) => return Err(Error::MultiplePostRuntimeLogs), - (Some(log), false) => frontier_log = Some(log), - _ => trace!(target: "dvm-consensus", "Ignoring digest not meant for us"), - } - } - - Ok(frontier_log.ok_or(Error::NoPostRuntimeLog)?) -} diff --git a/client/dvm/db/Cargo.toml b/client/dvm/db/Cargo.toml new file mode 100644 index 0000000..ed17c66 --- /dev/null +++ b/client/dvm/db/Cargo.toml @@ -0,0 +1,21 @@ +[package] +authors = ["Hyperspace Network "] +description = "Dvm database backend" +edition = "2018" +homepage = "https://mvs.org/" +license = "GPL-3.0" +name = "dc-db" +readme = "README.md" +repository = "https://github.com/mvs-org/Hyperspace" +version = "2.0.0" + +[dependencies] +# crates +codec = { package = "parity-scale-codec", version = "1.3.7", features = ["derive"] } +kvdb = "0.8.0" +kvdb-rocksdb = "0.10.0" +parking_lot = "0.11.1" +# substrate +sp-core = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-database = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-runtime = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } diff --git a/client/dvm/db/src/lib.rs b/client/dvm/db/src/lib.rs new file mode 100644 index 0000000..453e5e7 --- /dev/null +++ b/client/dvm/db/src/lib.rs @@ -0,0 +1,227 @@ +// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 +// This file is part of Frontier. +// +// Copyright (c) 2021 Parity Technologies (UK) Ltd. +// +// This program 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. +// +// This program 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 this program. If not, see . + +mod utils; + +// --- substrate --- +pub use sp_database::Database; +// --- hyperspace --- +use codec::{Decode, Encode}; +use parking_lot::Mutex; +use sp_core::H256; +use sp_runtime::traits::Block as BlockT; +// --- std --- +use std::{ + marker::PhantomData, + path::{Path, PathBuf}, + sync::Arc, +}; + +const DB_HASH_LEN: usize = 32; +/// Hash type that this backend uses for the database. +pub type DbHash = [u8; DB_HASH_LEN]; + +/// Database settings. +pub struct DatabaseSettings { + /// Where to find the database. + pub source: DatabaseSettingsSrc, +} + +/// Where to find the database. +#[derive(Debug, Clone)] +pub enum DatabaseSettingsSrc { + /// Load a RocksDB database from a given path. Recommended for most uses. + RocksDb { + /// Path to the database. + path: PathBuf, + /// Cache size in MiB. + cache_size: usize, + }, +} + +impl DatabaseSettingsSrc { + /// Return dabase path for databases that are on the disk. + pub fn path(&self) -> Option<&Path> { + match self { + DatabaseSettingsSrc::RocksDb { path, .. } => Some(path.as_path()), + } + } +} + +pub(crate) mod columns { + pub const NUM_COLUMNS: u32 = 3; + + pub const META: u32 = 0; + pub const BLOCK_MAPPING: u32 = 1; + pub const TRANSACTION_MAPPING: u32 = 2; +} + +pub(crate) mod static_keys { + pub const CURRENT_SYNCING_TIPS: &[u8] = b"CURRENT_SYNCING_TIPS"; +} + +pub struct Backend { + meta: Arc>, + mapping: Arc>, +} + +impl Backend { + pub fn new(config: &DatabaseSettings) -> Result { + let db = utils::open_database(config)?; + + Ok(Self { + mapping: Arc::new(MappingDb { + db: db.clone(), + write_lock: Arc::new(Mutex::new(())), + _marker: PhantomData, + }), + meta: Arc::new(MetaDb { + db: db.clone(), + _marker: PhantomData, + }), + }) + } + + pub fn mapping(&self) -> &Arc> { + &self.mapping + } + + pub fn meta(&self) -> &Arc> { + &self.meta + } +} + +pub struct MetaDb { + db: Arc>, + _marker: PhantomData, +} + +impl MetaDb { + pub fn current_syncing_tips(&self) -> Result, String> { + match self.db.get( + crate::columns::META, + &crate::static_keys::CURRENT_SYNCING_TIPS, + ) { + Some(raw) => { + Ok(Vec::::decode(&mut &raw[..]).map_err(|e| format!("{:?}", e))?) + } + None => Ok(Vec::new()), + } + } + + pub fn write_current_syncing_tips(&self, tips: Vec) -> Result<(), String> { + let mut transaction = sp_database::Transaction::new(); + + transaction.set( + crate::columns::META, + crate::static_keys::CURRENT_SYNCING_TIPS, + &tips.encode(), + ); + + self.db + .commit(transaction) + .map_err(|e| format!("{:?}", e))?; + + Ok(()) + } +} + +pub struct MappingCommitment { + pub block_hash: Block::Hash, + pub ethereum_block_hash: H256, + pub ethereum_transaction_hashes: Vec, +} + +#[derive(Clone, Encode, Decode)] +pub struct TransactionMetadata { + pub block_hash: Block::Hash, + pub ethereum_block_hash: H256, + pub ethereum_index: u32, +} + +pub struct MappingDb { + db: Arc>, + write_lock: Arc>, + _marker: PhantomData, +} + +impl MappingDb { + pub fn block_hashes(&self, ethereum_block_hash: &H256) -> Result, String> { + match self + .db + .get(crate::columns::BLOCK_MAPPING, ðereum_block_hash.encode()) + { + Some(raw) => { + Ok(Vec::::decode(&mut &raw[..]).map_err(|e| format!("{:?}", e))?) + } + None => Ok(Vec::new()), + } + } + + pub fn transaction_metadata( + &self, + ethereum_transaction_hash: &H256, + ) -> Result>, String> { + match self.db.get( + crate::columns::TRANSACTION_MAPPING, + ðereum_transaction_hash.encode(), + ) { + Some(raw) => Ok(Vec::>::decode(&mut &raw[..]) + .map_err(|e| format!("{:?}", e))?), + None => Ok(Vec::new()), + } + } + + pub fn write_hashes(&self, commitment: MappingCommitment) -> Result<(), String> { + let _lock = self.write_lock.lock(); + + let mut transaction = sp_database::Transaction::new(); + + let mut block_hashes = self.block_hashes(&commitment.ethereum_block_hash)?; + block_hashes.push(commitment.block_hash); + transaction.set( + crate::columns::BLOCK_MAPPING, + &commitment.ethereum_block_hash.encode(), + &block_hashes.encode(), + ); + + for (i, ethereum_transaction_hash) in commitment + .ethereum_transaction_hashes + .into_iter() + .enumerate() + { + let mut metadata = self.transaction_metadata(ðereum_transaction_hash)?; + metadata.push(TransactionMetadata:: { + block_hash: commitment.block_hash, + ethereum_block_hash: commitment.ethereum_block_hash, + ethereum_index: i as u32, + }); + transaction.set( + crate::columns::TRANSACTION_MAPPING, + ðereum_transaction_hash.encode(), + &metadata.encode(), + ); + } + + self.db + .commit(transaction) + .map_err(|e| format!("{:?}", e))?; + + Ok(()) + } +} diff --git a/client/dvm/db/src/utils.rs b/client/dvm/db/src/utils.rs new file mode 100644 index 0000000..8a07487 --- /dev/null +++ b/client/dvm/db/src/utils.rs @@ -0,0 +1,40 @@ +// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 +// This file is part of Frontier. +// +// Copyright (c) 2020 Parity Technologies (UK) Ltd. +// +// This program 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. +// +// This program 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 this program. If not, see . + +use crate::{Database, DatabaseSettings, DatabaseSettingsSrc, DbHash}; +use std::sync::Arc; + +pub fn open_database(config: &DatabaseSettings) -> Result>, String> { + let db: Arc> = match &config.source { + DatabaseSettingsSrc::RocksDb { + path, + cache_size: _, + } => { + let db_config = kvdb_rocksdb::DatabaseConfig::with_columns(crate::columns::NUM_COLUMNS); + let path = path + .to_str() + .ok_or_else(|| "Invalid database path".to_string())?; + + let db = kvdb_rocksdb::Database::open(&db_config, &path) + .map_err(|err| format!("{}", err))?; + sp_database::as_database(db) + } + }; + + Ok(db) +} diff --git a/client/dvm/mapping-sync/Cargo.toml b/client/dvm/mapping-sync/Cargo.toml new file mode 100644 index 0000000..2c8964f --- /dev/null +++ b/client/dvm/mapping-sync/Cargo.toml @@ -0,0 +1,26 @@ +[package] +authors = ["Hyperspace Network "] +description = "Mapping sync logic for dvm." +edition = "2018" +homepage = "https://mvs.org/" +license = "GPL-3.0" +name = "dc-mapping-sync" +readme = "README.md" +repository = "https://github.com/mvs-org/Hyperspace" +version = "2.0.0" + +[dependencies] +# substrate +sp-api = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-blockchain = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sc-client-api = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-runtime = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +# hyperspace +dc-consensus = { path = "../consensus" } +dc-db = { path = "../db" } +dp_consensus = { path = "../../../primitives/consensus/" } +dvm-rpc-runtime-api = { path = "../../../frame/dvm/rpc/runtime-api"} +# crates +futures = { version = "0.3.1", features = ["compat"] } +futures-timer = "3.0.1" +log = "0.4.8" \ No newline at end of file diff --git a/client/dvm/mapping-sync/src/lib.rs b/client/dvm/mapping-sync/src/lib.rs new file mode 100644 index 0000000..367ee87 --- /dev/null +++ b/client/dvm/mapping-sync/src/lib.rs @@ -0,0 +1,162 @@ +// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 +// This file is part of Frontier. +// +// Copyright (c) 2020 Parity Technologies (UK) Ltd. +// +// This program 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. +// +// This program 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 this program. If not, see . + +mod worker; + +pub use worker::MappingSyncWorker; + +// --- hyperspace --- +use dvm_rpc_runtime_api::EthereumRuntimeRPCApi; +// --- substrate --- +use sc_client_api::BlockOf; +use sp_api::ProvideRuntimeApi; +use sp_blockchain::HeaderBackend; +use sp_runtime::{ + generic::BlockId, + traits::{Block as BlockT, Header as HeaderT, Zero}, +}; + +pub fn sync_block( + backend: &dc_db::Backend, + header: &Block::Header, +) -> Result<(), String> { + let log = dp_consensus::find_log(header.digest()).map_err(|e| format!("{:?}", e))?; + let post_hashes = log.into_hashes(); + + let mapping_commitment = dc_db::MappingCommitment { + block_hash: header.hash(), + ethereum_block_hash: post_hashes.block_hash, + ethereum_transaction_hashes: post_hashes.transaction_hashes, + }; + backend.mapping().write_hashes(mapping_commitment)?; + + Ok(()) +} + +pub fn sync_genesis_block( + client: &C, + backend: &dc_db::Backend, + header: &Block::Header, +) -> Result<(), String> +where + C: ProvideRuntimeApi + Send + Sync + HeaderBackend + BlockOf, + C::Api: EthereumRuntimeRPCApi, +{ + let id = BlockId::Hash(header.hash()); + + let block = client + .runtime_api() + .current_block(&id) + .map_err(|e| format!("{:?}", e))?; + let block_hash = block + .ok_or("Ethereum genesis block not found".to_string())? + .header + .hash(); + let mapping_commitment = dc_db::MappingCommitment:: { + block_hash: header.hash(), + ethereum_block_hash: block_hash, + ethereum_transaction_hashes: Vec::new(), + }; + backend.mapping().write_hashes(mapping_commitment)?; + + Ok(()) +} + +pub fn sync_one_level( + client: &C, + substrate_backend: &B, + frontier_backend: &dc_db::Backend, +) -> Result +where + C: ProvideRuntimeApi + Send + Sync + HeaderBackend + BlockOf, + C::Api: EthereumRuntimeRPCApi, + B: sp_blockchain::HeaderBackend + sp_blockchain::Backend, +{ + let mut current_syncing_tips = frontier_backend.meta().current_syncing_tips()?; + + if current_syncing_tips.len() == 0 { + // Sync genesis block. + + let header = substrate_backend + .header(BlockId::Number(Zero::zero())) + .map_err(|e| format!("{:?}", e))? + .ok_or("Genesis header not found".to_string())?; + sync_genesis_block(client, frontier_backend, &header)?; + + current_syncing_tips.push(header.hash()); + frontier_backend + .meta() + .write_current_syncing_tips(current_syncing_tips)?; + + Ok(true) + } else { + let mut syncing_tip_and_children = None; + + for tip in ¤t_syncing_tips { + let children = substrate_backend + .children(*tip) + .map_err(|e| format!("{:?}", e))?; + + if children.len() > 0 { + syncing_tip_and_children = Some((*tip, children)); + break; + } + } + + if let Some((syncing_tip, children)) = syncing_tip_and_children { + current_syncing_tips.retain(|tip| tip != &syncing_tip); + + for child in children { + let header = substrate_backend + .header(BlockId::Hash(child)) + .map_err(|e| format!("{:?}", e))? + .ok_or("Header not found".to_string())?; + + sync_block(frontier_backend, &header)?; + current_syncing_tips.push(child); + } + frontier_backend + .meta() + .write_current_syncing_tips(current_syncing_tips)?; + + Ok(true) + } else { + Ok(false) + } + } +} + +pub fn sync_blocks( + client: &C, + substrate_backend: &B, + frontier_backend: &dc_db::Backend, + limit: usize, +) -> Result +where + C: ProvideRuntimeApi + Send + Sync + HeaderBackend + BlockOf, + C::Api: EthereumRuntimeRPCApi, + B: sp_blockchain::HeaderBackend + sp_blockchain::Backend, +{ + let mut synced_any = false; + + for _ in 0..limit { + synced_any = synced_any || sync_one_level(client, substrate_backend, frontier_backend)?; + } + + Ok(synced_any) +} diff --git a/client/dvm/mapping-sync/src/worker.rs b/client/dvm/mapping-sync/src/worker.rs new file mode 100644 index 0000000..47eef15 --- /dev/null +++ b/client/dvm/mapping-sync/src/worker.rs @@ -0,0 +1,129 @@ +// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 +// This file is part of Frontier. +// +// Copyright (c) 2020 Parity Technologies (UK) Ltd. +// +// This program 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. +// +// This program 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 this program. If not, see . + +// --- hyperspace --- +use dvm_rpc_runtime_api::EthereumRuntimeRPCApi; +// --- substrate --- +use sc_client_api::{BlockOf, ImportNotifications}; +use sp_api::ProvideRuntimeApi; +use sp_blockchain::HeaderBackend; +use sp_runtime::traits::Block as BlockT; +use std::{pin::Pin, sync::Arc, time::Duration}; +// --- std --- +use futures::{ + prelude::*, + task::{Context, Poll}, +}; +use futures_timer::Delay; +use log::warn; + +const LIMIT: usize = 8; + +pub struct MappingSyncWorker { + import_notifications: ImportNotifications, + timeout: Duration, + inner_delay: Option, + + client: Arc, + substrate_backend: Arc, + frontier_backend: Arc>, + + have_next: bool, +} + +impl MappingSyncWorker { + pub fn new( + import_notifications: ImportNotifications, + timeout: Duration, + client: Arc, + substrate_backend: Arc, + frontier_backend: Arc>, + ) -> Self { + Self { + import_notifications, + timeout, + inner_delay: None, + + client, + substrate_backend, + frontier_backend, + + have_next: true, + } + } +} + +impl Stream for MappingSyncWorker +where + C: ProvideRuntimeApi + Send + Sync + HeaderBackend + BlockOf, + C::Api: EthereumRuntimeRPCApi, + B: sc_client_api::Backend, +{ + type Item = (); + + fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll> { + let mut fire = false; + + loop { + match Stream::poll_next(Pin::new(&mut self.import_notifications), cx) { + Poll::Pending => break, + Poll::Ready(Some(_)) => { + fire = true; + } + Poll::Ready(None) => return Poll::Ready(None), + } + } + + let timeout = self.timeout.clone(); + let inner_delay = self.inner_delay.get_or_insert_with(|| Delay::new(timeout)); + + match Future::poll(Pin::new(inner_delay), cx) { + Poll::Pending => (), + Poll::Ready(()) => { + fire = true; + } + } + + if self.have_next { + fire = true; + } + + if fire { + self.inner_delay = None; + + match crate::sync_blocks( + self.client.as_ref(), + self.substrate_backend.blockchain(), + self.frontier_backend.as_ref(), + LIMIT, + ) { + Ok(have_next) => { + self.have_next = have_next; + Poll::Ready(Some(())) + } + Err(e) => { + self.have_next = false; + warn!(target: "mapping-sync", "Syncing failed with error {:?}, retrying.", e); + Poll::Ready(Some(())) + } + } + } else { + Poll::Pending + } + } +} diff --git a/client/dvm/rpc/Cargo.toml b/client/dvm/rpc/Cargo.toml index 16f453c..fd65a4d 100644 --- a/client/dvm/rpc/Cargo.toml +++ b/client/dvm/rpc/Cargo.toml @@ -4,13 +4,14 @@ description = "Ethereum RPC (web3) compatibility layer for Hyperspace." edition = "2018" homepage = "https://mvs.org/" license = "GPL-3.0" -name = "dvm-rpc" +name = "dc-rpc" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "1.4.0" +version = "2.0.0" [dependencies] # crates +array-bytes = { version = "1.1.0" } codec = { package = "parity-scale-codec", version = "1.3.7" } ethereum = { version = "0.6.0", features = ["with-codec"] } ethereum-types = { version = "0.10.0" } @@ -24,25 +25,27 @@ log = { version = "0.4.14" } rand = { version = "0.7" } rlp = { version = "0.5.0" } sha3 = { version = "0.8" } -array-bytes = { version = "1.1.0" } # hyperspace -hyperspace-evm = { path = "../../../frame/evm" } -dvm-consensus = { path = "../consensus" } -dvm-ethereum = { path = "../../../frame/dvm" } -dvm-rpc-core = { path = "../../../frame/dvm/rpc" } -dvm-rpc-core-primitives = { path = "../../../primitives/dvm-rpc-core" } -dvm-rpc-runtime-api = { path = "../../../frame/dvm/rpc/runtime-api" } +hyperspace-evm = { path = "../../../frame/evm" } +dc-consensus = { path = "../consensus" } +dc-db = { path = "../db" } +dp_consensus = { path = "../../../primitives/consensus/" } +dp-storage = { path = "../../../primitives/storage/" } +dvm-ethereum = { path = "../../../frame/dvm" } +dvm-rpc-core = { path = "../../../frame/dvm/rpc" } +dvm-rpc-runtime-api = { path = "../../../frame/dvm/rpc/runtime-api" } +dp-rpc = { path = "../../../primitives/rpc" } # substrate -sc-client-api = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sc-network = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sc-rpc = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sc-service = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-api = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-blockchain = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-io = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-runtime = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-storage = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-transaction-pool = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sc-client-api = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sc-network = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sc-rpc = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sc-service = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-api = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-blockchain = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-io = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-runtime = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-storage = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-transaction-pool = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [features] rpc_binary_search_estimate = [] diff --git a/client/dvm/rpc/src/eth.rs b/client/dvm/rpc/src/eth.rs index 9a2885d..2945896 100644 --- a/client/dvm/rpc/src/eth.rs +++ b/client/dvm/rpc/src/eth.rs @@ -14,61 +14,91 @@ // You should have received a copy of the GNU General Public License // along with Substrate. If not, see . -use crate::{error_on_execution_failure, internal_err, EthSigner}; -use codec::{self, Encode}; -use dvm_rpc_core::{EthApi as EthApiT, NetApi as NetApiT, Web3Api as Web3ApiT}; -use dvm_rpc_core_primitives::{ - Block, BlockNumber, BlockTransactions, Bytes, CallRequest, Filter, FilteredParams, Index, Log, - Receipt, Rich, RichBlock, SyncInfo, SyncStatus, Transaction, TransactionRequest, Work, +use crate::overrides::{RuntimeApiStorageOverride, StorageOverride}; +use crate::{error_on_execution_failure, internal_err, public_key, EthSigner}; +// --- hyperspace --- +use dp_rpc::{ + Block, BlockNumber, BlockTransactions, Bytes, CallRequest, Filter, FilterChanges, FilterPool, + FilterPoolItem, FilterType, FilteredParams, Index, Log, PendingTransaction, + PendingTransactions, Receipt, Rich, RichBlock, SyncInfo, SyncStatus, Transaction, + TransactionRequest, Work, }; -use dvm_rpc_runtime_api::{ConvertTransaction, EthereumRuntimeRPCApi, TransactionStatus}; -use ethereum::{ - Block as EthereumBlock, Transaction as EthereumTransaction, - TransactionMessage as EthereumTransactionMessage, +use dp_storage::PALLET_ETHEREUM_SCHEMA; +use dvm_ethereum::EthereumStorageSchema; +use dvm_rpc_core::{ + EthApi as EthApiT, EthFilterApi as EthFilterApiT, NetApi as NetApiT, Web3Api as Web3ApiT, }; -use ethereum_types::{H160, H256, H512, H64, U256, U64}; -use futures::future::TryFutureExt; -use jsonrpc_core::{ - futures::future::{self, Future}, - BoxFuture, Result, +pub use dvm_rpc_core::{EthApiServer, EthFilterApiServer, NetApiServer, Web3ApiServer}; +use dvm_rpc_runtime_api::{ConvertTransaction, EthereumRuntimeRPCApi, TransactionStatus}; +// --- substrate --- +use sc_client_api::{ + backend::{AuxStore, Backend, StateBackend, StorageProvider}, + client::BlockchainEvents, }; -use sc_client_api::backend::{AuxStore, Backend, StateBackend, StorageProvider}; use sc_network::{ExHashT, NetworkService}; -use sha3::{Digest, Keccak256}; -use sp_api::{BlockId, Core, ProvideRuntimeApi}; +use sp_api::{BlockId, Core, HeaderT, ProvideRuntimeApi}; use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata}; use sp_runtime::traits::BlakeTwo256; use sp_runtime::traits::{Block as BlockT, One, Saturating, UniqueSaturatedInto, Zero}; use sp_runtime::transaction_validity::TransactionSource; +use sp_storage::StorageKey; use sp_transaction_pool::{InPoolTransaction, TransactionPool}; -use std::collections::BTreeMap; -use std::{marker::PhantomData, sync::Arc}; - -pub use dvm_rpc_core::{EthApiServer, NetApiServer, Web3ApiServer}; +// --- std --- +use codec::{self, Decode, Encode}; +use ethereum::{Block as EthereumBlock, Transaction as EthereumTransaction}; +use ethereum_types::{H160, H256, H512, H64, U256, U64}; +use futures::{future::TryFutureExt, StreamExt}; +use jsonrpc_core::{ + futures::future::{self, Future}, + BoxFuture, Result, +}; +use sha3::{Digest, Keccak256}; +use std::collections::{BTreeMap, HashMap}; +use std::{ + marker::PhantomData, + sync::{Arc, Mutex}, +}; pub struct EthApi { pool: Arc

, client: Arc, convert_transaction: CT, network: Arc>, + overrides: BTreeMap + Send + Sync>>, + fallback: Box + Send + Sync>, + pending_transactions: PendingTransactions, + backend: Arc>, is_authority: bool, signers: Vec>, _marker: PhantomData<(B, BE)>, } -impl EthApi { +impl EthApi +where + C: ProvideRuntimeApi, + C::Api: EthereumRuntimeRPCApi, + B: BlockT + Send + Sync + 'static, + C: Send + Sync + 'static, +{ pub fn new( client: Arc, pool: Arc

, convert_transaction: CT, network: Arc>, + overrides: BTreeMap + Send + Sync>>, + pending_transactions: PendingTransactions, + backend: Arc>, is_authority: bool, ) -> Self { Self { - client, + client: client.clone(), pool, convert_transaction, network, + overrides, + fallback: Box::new(RuntimeApiStorageOverride::new(client)), + pending_transactions, + backend, is_authority, signers: Vec::new(), _marker: PhantomData, @@ -101,7 +131,7 @@ fn rich_block_build( logs_bloom: Some(block.header.logs_bloom), timestamp: U256::from(block.header.timestamp / 1000), difficulty: block.header.difficulty, - total_difficulty: None, + total_difficulty: U256::zero(), seal_fields: vec![ Bytes(block.header.mix_hash.as_bytes().to_vec()), Bytes(block.header.nonce.as_bytes().to_vec()), @@ -117,8 +147,8 @@ fn rich_block_build( .map(|(index, transaction)| { transaction_build( transaction.clone(), - block.clone(), - statuses[index].clone().unwrap_or_default(), + Some(block.clone()), + Some(statuses[index].clone().unwrap_or_default()), ) }) .collect(), @@ -146,40 +176,55 @@ fn rich_block_build( fn transaction_build( transaction: EthereumTransaction, - block: EthereumBlock, - status: TransactionStatus, + block: Option, + status: Option, ) -> Transaction { - let mut sig = [0u8; 65]; - let mut msg = [0u8; 32]; - sig[0..32].copy_from_slice(&transaction.signature.r()[..]); - sig[32..64].copy_from_slice(&transaction.signature.s()[..]); - sig[64] = transaction.signature.standard_v(); - msg.copy_from_slice(&EthereumTransactionMessage::from(transaction.clone()).hash()[..]); - - let pubkey = match sp_io::crypto::secp256k1_ecdsa_recover(&sig, &msg) { - Ok(p) => Some(H512::from(p)), + let pubkey = match public_key(&transaction) { + Ok(p) => Some(p), Err(_e) => None, }; Transaction { hash: H256::from_slice(Keccak256::digest(&rlp::encode(&transaction)).as_slice()), nonce: transaction.nonce, - block_hash: Some(H256::from_slice( - Keccak256::digest(&rlp::encode(&block.header)).as_slice(), - )), - block_number: Some(block.header.number), - transaction_index: Some(U256::from( - UniqueSaturatedInto::::unique_saturated_into(status.transaction_index), - )), - from: status.from, - to: status.to, + block_hash: block.as_ref().map_or(None, |block| { + Some(H256::from_slice( + Keccak256::digest(&rlp::encode(&block.header)).as_slice(), + )) + }), + block_number: block.as_ref().map(|block| block.header.number), + transaction_index: status.as_ref().map(|status| { + U256::from(UniqueSaturatedInto::::unique_saturated_into( + status.transaction_index, + )) + }), + from: status.as_ref().map_or( + { + match pubkey { + Some(pk) => H160::from(H256::from_slice(Keccak256::digest(&pk).as_slice())), + _ => H160::default(), + } + }, + |status| status.from, + ), + to: status.as_ref().map_or( + { + match transaction.action { + ethereum::TransactionAction::Call(to) => Some(to), + _ => None, + } + }, + |status| status.to, + ), value: transaction.value, gas_price: transaction.gas_price, gas: transaction.gas_limit, input: Bytes(transaction.clone().input), - creates: status.contract_address, + creates: status + .as_ref() + .map_or(None, |status| status.contract_address), raw: Bytes(rlp::encode(&transaction).to_vec()), - public_key: pubkey, + public_key: pubkey.as_ref().map(|pk| H512::from(pk)), chain_id: transaction.signature.chain_id().map(U64::from), standard_v: U256::from(transaction.signature.standard_v()), v: U256::from(transaction.signature.v()), @@ -188,8 +233,67 @@ fn transaction_build( } } +fn logs_build( + filter: Filter, + blocks_and_statuses: Vec<(EthereumBlock, Vec)>, +) -> Vec { + let params = FilteredParams::new(Some(filter.clone())); + let mut ret = Vec::new(); + for (block, statuses) in blocks_and_statuses { + let mut block_log_index: u32 = 0; + let block_hash = + H256::from_slice(Keccak256::digest(&rlp::encode(&block.header)).as_slice()); + for status in statuses.iter() { + let logs = status.logs.clone(); + let mut transaction_log_index: u32 = 0; + let transaction_hash = status.transaction_hash; + for ethereum_log in logs { + let mut log = Log { + address: ethereum_log.address.clone(), + topics: ethereum_log.topics.clone(), + data: Bytes(ethereum_log.data.clone()), + block_hash: None, + block_number: None, + transaction_hash: None, + transaction_index: None, + log_index: None, + transaction_log_index: None, + removed: false, + }; + let mut add: bool = true; + if let (Some(_), Some(_)) = (filter.address.clone(), filter.topics.clone()) { + if !params.filter_address(&log) || !params.filter_topics(&log) { + add = false; + } + } else if let Some(_) = filter.address { + if !params.filter_address(&log) { + add = false; + } + } else if let Some(_) = &filter.topics { + if !params.filter_topics(&log) { + add = false; + } + } + if add { + log.block_hash = Some(block_hash); + log.block_number = Some(block.header.number.clone()); + log.transaction_hash = Some(transaction_hash); + log.transaction_index = Some(U256::from(status.transaction_index)); + log.log_index = Some(U256::from(block_log_index)); + log.transaction_log_index = Some(U256::from(transaction_log_index)); + ret.push(log); + } + transaction_log_index += 1; + block_log_index += 1; + } + } + } + ret +} + impl EthApi where + B: BlockT, C: ProvideRuntimeApi + StorageProvider + AuxStore, C: HeaderBackend + HeaderMetadata + 'static, C::Api: EthereumRuntimeRPCApi, @@ -212,21 +316,14 @@ where // Asumes there is only one mapped canonical block in the AuxStore, otherwise something is wrong fn load_hash(&self, hash: H256) -> Result>> { - let hashes = match dvm_consensus::load_block_hash::(self.client.as_ref(), hash) - .map_err(|err| internal_err(format!("fetch aux store failed: {:?}", err)))? - { - Some(hashes) => hashes, - None => return Ok(None), - }; + let hashes = self + .backend + .mapping() + .block_hashes(&hash) + .map_err(|err| internal_err(format!("fetch aux store failed: {:?}", err)))?; let out: Vec = hashes .into_iter() - .filter_map(|h| { - if let Ok(Some(_)) = self.client.header(BlockId::Hash(h)) { - Some(h) - } else { - None - } - }) + .filter_map(|h| if self.is_canon(h) { Some(h) } else { None }) .collect(); if out.len() == 1 { @@ -234,6 +331,44 @@ where } Ok(None) } + + fn onchain_storage_schema(&self, at: BlockId) -> EthereumStorageSchema { + match self + .client + .storage(&at, &StorageKey(PALLET_ETHEREUM_SCHEMA.to_vec())) + { + Ok(Some(bytes)) => Decode::decode(&mut &bytes.0[..]) + .ok() + .unwrap_or(EthereumStorageSchema::Undefined), + _ => EthereumStorageSchema::Undefined, + } + } + + fn is_canon(&self, target_hash: H256) -> bool { + if let Ok(Some(number)) = self.client.number(target_hash) { + if let Ok(Some(header)) = self.client.header(BlockId::Number(number)) { + return header.hash() == target_hash; + } + } + false + } + + fn load_transactions(&self, transaction_hash: H256) -> Result> { + let transaction_metadata = self + .backend + .mapping() + .transaction_metadata(&transaction_hash) + .map_err(|err| internal_err(format!("fetch aux store failed: {:?}", err)))?; + + if transaction_metadata.len() == 1 { + Ok(Some(( + transaction_metadata[0].ethereum_block_hash, + transaction_metadata[0].ethereum_index, + ))) + } else { + Ok(None) + } + } } impl EthApiT for EthApi @@ -277,14 +412,17 @@ where } fn author(&self) -> Result { - let hash = self.client.info().best_hash; + let block = BlockId::Hash(self.client.info().best_hash); + let schema = self.onchain_storage_schema(block); Ok(self - .client - .runtime_api() - .author(&BlockId::Hash(hash)) - .map_err(|err| internal_err(format!("fetch runtime chain id failed: {:?}", err)))? - .into()) + .overrides + .get(&schema) + .unwrap_or(&self.fallback) + .current_block(&block) + .ok_or(internal_err("fetching author through override failed"))? + .header + .beneficiary) } fn is_mining(&self) -> Result { @@ -303,11 +441,11 @@ where } fn gas_price(&self) -> Result { - let hash = self.client.info().best_hash; + let block = BlockId::Hash(self.client.info().best_hash); Ok(self .client .runtime_api() - .gas_price(&BlockId::Hash(hash)) + .gas_price(&block) .map_err(|err| internal_err(format!("fetch runtime chain id failed: {:?}", err)))? .into()) } @@ -343,12 +481,13 @@ where fn storage_at(&self, address: H160, index: U256, number: Option) -> Result { if let Ok(Some(id)) = self.native_block_id(number) { + let schema = self.onchain_storage_schema(id); return Ok(self - .client - .runtime_api() + .overrides + .get(&schema) + .unwrap_or(&self.fallback) .storage_at(&id, address, index) - .map_err(|err| internal_err(format!("fetch runtime chain id failed: {:?}", err)))? - .into()); + .unwrap_or_default()); } Ok(H256::default()) } @@ -362,16 +501,11 @@ where _ => return Ok(None), }; - let block = self - .client - .runtime_api() - .current_block(&id) - .map_err(|err| internal_err(format!("call runtime failed: {:?}", err)))?; - let statuses = self - .client - .runtime_api() - .current_transaction_statuses(&id) - .map_err(|err| internal_err(format!("call runtime failed: {:?}", err)))?; + let schema = self.onchain_storage_schema(id); + let handler = self.overrides.get(&schema).unwrap_or(&self.fallback); + + let block = handler.current_block(&id); + let statuses = handler.current_transaction_statuses(&id); match (block, statuses) { (Some(block), Some(statuses)) => Ok(Some(rich_block_build( @@ -390,16 +524,11 @@ where None => return Ok(None), }; - let block = self - .client - .runtime_api() - .current_block(&id) - .map_err(|err| internal_err(format!("call runtime failed: {:?}", err)))?; - let statuses = self - .client - .runtime_api() - .current_transaction_statuses(&id) - .map_err(|err| internal_err(format!("call runtime failed: {:?}", err)))?; + let schema = self.onchain_storage_schema(id); + let handler = self.overrides.get(&schema).unwrap_or(&self.fallback); + + let block = handler.current_block(&id); + let statuses = handler.current_transaction_statuses(&id); match (block, statuses) { (Some(block), Some(statuses)) => { @@ -419,12 +548,11 @@ where fn transaction_count(&self, address: H160, number: Option) -> Result { if let Some(BlockNumber::Pending) = number { - // Find future nonce - let id = BlockId::hash(self.client.info().best_hash); - let nonce: U256 = self + let block = BlockId::Hash(self.client.info().best_hash); + let nonce = self .client .runtime_api() - .account_basic(&id, address) + .account_basic(&block, address) .map_err(|err| { internal_err(format!("fetch runtime account basic failed: {:?}", err)) })? @@ -469,13 +597,12 @@ where _ => return Ok(None), }; + let schema = self.onchain_storage_schema(id); let block = self - .client - .runtime_api() - .current_block(&id) - .map_err(|err| { - internal_err(format!("fetch runtime account basic failed: {:?}", err)) - })?; + .overrides + .get(&schema) + .unwrap_or(&self.fallback) + .current_block(&id); match block { Some(block) => Ok(Some(U256::from(block.transactions.len()))), @@ -489,13 +616,12 @@ where None => return Ok(None), }; + let schema = self.onchain_storage_schema(id); let block = self - .client - .runtime_api() - .current_block(&id) - .map_err(|err| { - internal_err(format!("fetch runtime account basic failed: {:?}", err)) - })?; + .overrides + .get(&schema) + .unwrap_or(&self.fallback) + .current_block(&id); match block { Some(block) => Ok(Some(U256::from(block.transactions.len()))), @@ -513,11 +639,13 @@ where fn code_at(&self, address: H160, number: Option) -> Result { if let Ok(Some(id)) = self.native_block_id(number) { + let schema = self.onchain_storage_schema(id); return Ok(self - .client - .runtime_api() + .overrides + .get(&schema) + .unwrap_or(&self.fallback) .account_code_at(&id, address) - .map_err(|err| internal_err(format!("fetch runtime chain id failed: {:?}", err)))? + .unwrap_or(vec![]) .into()); } Ok(Bytes(vec![])) @@ -586,15 +714,31 @@ where let transaction_hash = H256::from_slice(Keccak256::digest(&rlp::encode(&transaction)).as_slice()); let hash = self.client.info().best_hash; + let number = self.client.info().best_number; + let pending = self.pending_transactions.clone(); Box::new( self.pool .submit_one( &BlockId::hash(hash), TransactionSource::Local, - self.convert_transaction.convert_transaction(transaction), + self.convert_transaction + .convert_transaction(transaction.clone()), ) .compat() - .map(move |_| transaction_hash) + .map(move |_| { + if let Some(pending) = pending { + if let Ok(locked) = &mut pending.lock() { + locked.insert( + transaction_hash, + PendingTransaction::new( + transaction_build(transaction, None, None), + UniqueSaturatedInto::::unique_saturated_into(number), + ), + ); + } + } + transaction_hash + }) .map_err(|err| { internal_err(format!("submit transaction to pool failed: {:?}", err)) }), @@ -613,15 +757,31 @@ where let transaction_hash = H256::from_slice(Keccak256::digest(&rlp::encode(&transaction)).as_slice()); let hash = self.client.info().best_hash; + let number = self.client.info().best_number; + let pending = self.pending_transactions.clone(); Box::new( self.pool .submit_one( &BlockId::hash(hash), TransactionSource::Local, - self.convert_transaction.convert_transaction(transaction), + self.convert_transaction + .convert_transaction(transaction.clone()), ) .compat() - .map(move |_| transaction_hash) + .map(move |_| { + if let Some(pending) = pending { + if let Ok(locked) = &mut pending.lock() { + locked.insert( + transaction_hash, + PendingTransaction::new( + transaction_build(transaction, None, None), + UniqueSaturatedInto::::unique_saturated_into(number), + ), + ); + } + } + transaction_hash + }) .map_err(|err| { internal_err(format!("submit transaction to pool failed: {:?}", err)) }), @@ -785,6 +945,10 @@ where Err(_) => { lower = mid; mid = (lower + upper + 1) / 2; + + if mid == lower { + break; + } } } } @@ -795,13 +959,22 @@ where } fn transaction_by_hash(&self, hash: H256) -> Result> { - let (hash, index) = - match dvm_consensus::load_transaction_metadata(self.client.as_ref(), hash) - .map_err(|err| internal_err(format!("fetch aux store failed: {:?})", err)))? - { - Some((hash, index)) => (hash, index as usize), - None => return Ok(None), - }; + let (hash, index) = match self + .load_transactions(hash) + .map_err(|err| internal_err(format!("{:?}", err)))? + { + Some((hash, index)) => (hash, index as usize), + None => { + if let Some(pending) = &self.pending_transactions { + if let Ok(locked) = &mut pending.lock() { + if let Some(pending_transaction) = locked.get(&hash) { + return Ok(Some(pending_transaction.transaction.clone())); + } + } + } + return Ok(None); + } + }; let id = match self .load_hash(hash) @@ -810,23 +983,17 @@ where Some(hash) => hash, _ => return Ok(None), }; + let schema = self.onchain_storage_schema(id); + let handler = self.overrides.get(&schema).unwrap_or(&self.fallback); - let block = self - .client - .runtime_api() - .current_block(&id) - .map_err(|err| internal_err(format!("call runtime failed: {:?}", err)))?; - let statuses = self - .client - .runtime_api() - .current_transaction_statuses(&id) - .map_err(|err| internal_err(format!("call runtime failed: {:?}", err)))?; + let block = handler.current_block(&id); + let statuses = handler.current_transaction_statuses(&id); match (block, statuses) { (Some(block), Some(statuses)) => Ok(Some(transaction_build( block.transactions[index].clone(), - block, - statuses[index].clone(), + Some(block), + Some(statuses[index].clone()), ))), _ => Ok(None), } @@ -846,22 +1013,17 @@ where }; let index = index.value(); - let block = self - .client - .runtime_api() - .current_block(&id) - .map_err(|err| internal_err(format!("call runtime failed: {:?}", err)))?; - let statuses = self - .client - .runtime_api() - .current_transaction_statuses(&id) - .map_err(|err| internal_err(format!("call runtime failed: {:?}", err)))?; + let schema = self.onchain_storage_schema(id); + let handler = self.overrides.get(&schema).unwrap_or(&self.fallback); + + let block = handler.current_block(&id); + let statuses = handler.current_transaction_statuses(&id); match (block, statuses) { (Some(block), Some(statuses)) => Ok(Some(transaction_build( block.transactions[index].clone(), - block, - statuses[index].clone(), + Some(block), + Some(statuses[index].clone()), ))), _ => Ok(None), } @@ -877,36 +1039,30 @@ where None => return Ok(None), }; let index = index.value(); + let schema = self.onchain_storage_schema(id); + let handler = self.overrides.get(&schema).unwrap_or(&self.fallback); - let block = self - .client - .runtime_api() - .current_block(&id) - .map_err(|err| internal_err(format!("call runtime failed: {:?}", err)))?; - let statuses = self - .client - .runtime_api() - .current_transaction_statuses(&id) - .map_err(|err| internal_err(format!("call runtime failed: {:?}", err)))?; + let block = handler.current_block(&id); + let statuses = handler.current_transaction_statuses(&id); match (block, statuses) { (Some(block), Some(statuses)) => Ok(Some(transaction_build( block.transactions[index].clone(), - block, - statuses[index].clone(), + Some(block), + Some(statuses[index].clone()), ))), _ => Ok(None), } } fn transaction_receipt(&self, hash: H256) -> Result> { - let (hash, index) = - match dvm_consensus::load_transaction_metadata(self.client.as_ref(), hash) - .map_err(|err| internal_err(format!("fetch aux store failed : {:?}", err)))? - { - Some((hash, index)) => (hash, index as usize), - None => return Ok(None), - }; + let (hash, index) = match self + .load_transactions(hash) + .map_err(|err| internal_err(format!("{:?}", err)))? + { + Some((hash, index)) => (hash, index as usize), + None => return Ok(None), + }; let id = match self .load_hash(hash) @@ -916,21 +1072,12 @@ where _ => return Ok(None), }; - let block = self - .client - .runtime_api() - .current_block(&id) - .map_err(|err| internal_err(format!("call runtime failed: {:?}", err)))?; - let receipts = self - .client - .runtime_api() - .current_receipts(&id) - .map_err(|err| internal_err(format!("call runtime failed: {:?}", err)))?; - let statuses = self - .client - .runtime_api() - .current_transaction_statuses(&id) - .map_err(|err| internal_err(format!("call runtime failed: {:?}", err)))?; + let schema = self.onchain_storage_schema(id); + let handler = self.overrides.get(&schema).unwrap_or(&self.fallback); + + let block = handler.current_block(&id); + let statuses = handler.current_transaction_statuses(&id); + let receipts = handler.current_receipts(&id); match (block, statuses, receipts) { (Some(block), Some(statuses), Some(receipts)) => { @@ -978,7 +1125,7 @@ where data: Bytes(log.data.clone()), block_hash: Some(block_hash), block_number: Some(block.header.number), - transaction_hash: Some(hash), + transaction_hash: Some(status.transaction_hash), transaction_index: Some(status.transaction_index.into()), log_index: Some(U256::from( (pre_receipts_log_index.unwrap_or(0)) + i as u32, @@ -1011,10 +1158,7 @@ where fn logs(&self, filter: Filter) -> Result> { let mut blocks_and_statuses = Vec::new(); - let mut ret = Vec::new(); - let params = FilteredParams::new(Some(filter.clone())); - - if let Some(hash) = filter.block_hash { + if let Some(hash) = filter.block_hash.clone() { let id = match self .load_hash(hash) .map_err(|err| internal_err(format!("{:?}", err)))? @@ -1032,14 +1176,20 @@ where blocks_and_statuses.push((block, statuses)); } } else { + let best_number = self.client.info().best_number; let mut current_number = filter .to_block + .clone() .and_then(|v| v.to_min_block_num()) .map(|s| s.unique_saturated_into()) - .unwrap_or(self.client.info().best_number); + .unwrap_or(best_number); + if current_number > best_number { + current_number = best_number; + } let from_number = filter .from_block + .clone() .and_then(|v| v.to_min_block_num()) .map(|s| s.unique_saturated_into()) .unwrap_or(self.client.info().best_number); @@ -1063,58 +1213,7 @@ where } } - for (block, statuses) in blocks_and_statuses { - let mut block_log_index: u32 = 0; - let block_hash = - H256::from_slice(Keccak256::digest(&rlp::encode(&block.header)).as_slice()); - for status in statuses.iter() { - let logs = status.logs.clone(); - let mut transaction_log_index: u32 = 0; - let transaction_hash = status.transaction_hash; - // for log in logs { - for ethereum_log in logs { - let mut log = Log { - address: ethereum_log.address.clone(), - topics: ethereum_log.topics.clone(), - data: Bytes(ethereum_log.data.clone()), - block_hash: None, - block_number: None, - transaction_hash: None, - transaction_index: None, - log_index: None, - transaction_log_index: None, - removed: false, - }; - let mut add: bool = true; - if let (Some(_), Some(_)) = (filter.address.clone(), filter.topics.clone()) { - if !params.filter_address(&log) || !params.filter_topics(&log) { - add = false; - } - } else if let Some(_) = filter.address { - if !params.filter_address(&log) { - add = false; - } - } else if let Some(_) = &filter.topics { - if !params.filter_topics(&log) { - add = false; - } - } - if add { - log.block_hash = Some(block_hash); - log.block_number = Some(block.header.number.clone()); - log.transaction_hash = Some(transaction_hash); - log.transaction_index = Some(U256::from(status.transaction_index)); - log.log_index = Some(U256::from(block_log_index)); - log.transaction_log_index = Some(U256::from(transaction_log_index)); - ret.push(log); - } - transaction_log_index += 1; - block_log_index += 1; - } - } - } - - Ok(ret) + Ok(logs_build(filter, blocks_and_statuses)) } fn work(&self) -> Result { @@ -1226,3 +1325,366 @@ where )) } } + +pub struct EthFilterApi { + client: Arc, + filter_pool: FilterPool, + max_stored_filters: usize, + _marker: PhantomData, +} + +impl EthFilterApi { + pub fn new(client: Arc, filter_pool: FilterPool, max_stored_filters: usize) -> Self { + Self { + client, + filter_pool, + max_stored_filters, + _marker: PhantomData, + } + } +} + +impl EthFilterApi +where + C: ProvideRuntimeApi + AuxStore, + C::Api: EthereumRuntimeRPCApi, + C: HeaderBackend + HeaderMetadata + 'static, + C: Send + Sync + 'static, + B: BlockT + Send + Sync + 'static, +{ + fn create_filter(&self, filter_type: FilterType) -> Result { + let block_number = + UniqueSaturatedInto::::unique_saturated_into(self.client.info().best_number); + let pool = self.filter_pool.clone(); + let response = if let Ok(locked) = &mut pool.lock() { + if locked.len() >= self.max_stored_filters { + return Err(internal_err(format!( + "Filter pool is full (limit {:?}).", + self.max_stored_filters + ))); + } + let last_key = match locked.iter().next_back() { + Some((k, _)) => *k, + None => U256::zero(), + }; + // Assume `max_stored_filters` is always < U256::max. + let key = last_key.checked_add(U256::one()).unwrap(); + locked.insert( + key, + FilterPoolItem { + last_poll: BlockNumber::Num(block_number), + filter_type, + at_block: block_number, + }, + ); + Ok(key) + } else { + Err(internal_err("Filter pool is not available.")) + }; + response + } +} + +impl EthFilterApiT for EthFilterApi +where + C: ProvideRuntimeApi + AuxStore, + C::Api: EthereumRuntimeRPCApi, + C: HeaderBackend + HeaderMetadata + 'static, + C: Send + Sync + 'static, + B: BlockT + Send + Sync + 'static, +{ + fn new_filter(&self, filter: Filter) -> Result { + self.create_filter(FilterType::Log(filter)) + } + + fn new_block_filter(&self) -> Result { + self.create_filter(FilterType::Block) + } + + fn new_pending_transaction_filter(&self) -> Result { + Err(internal_err("Method not available.")) + } + + fn filter_changes(&self, index: Index) -> Result { + let key = U256::from(index.value()); + let block_number = + UniqueSaturatedInto::::unique_saturated_into(self.client.info().best_number); + let pool = self.filter_pool.clone(); + // Try to lock. + let response = + if let Ok(locked) = &mut pool.lock() { + // Try to get key. + if let Some(pool_item) = locked.clone().get(&key) { + match &pool_item.filter_type { + // For each block created since last poll, get a vector of ethereum hashes. + FilterType::Block => { + let last = pool_item.last_poll.to_min_block_num().unwrap(); + let next = block_number + 1; + let mut ethereum_hashes: Vec = Vec::new(); + for n in last..next { + let id = BlockId::Number(n.unique_saturated_into()); + let block = self.client.runtime_api().current_block(&id).map_err( + |err| { + internal_err(format!( + "fetch runtime block failed: {:?}", + err + )) + }, + )?; + if let Some(block) = block { + ethereum_hashes.push(block.header.hash()) + } + } + // Update filter `last_poll`. + locked.insert( + key, + FilterPoolItem { + last_poll: BlockNumber::Num(next), + filter_type: pool_item.clone().filter_type, + at_block: pool_item.at_block, + }, + ); + Ok(FilterChanges::Hashes(ethereum_hashes)) + } + // For each event since last poll, get a vector of ethereum logs. + FilterType::Log(filter) => { + // Either the filter-specific `to` block or best block. + let best_number = self.client.info().best_number; + let mut current_number = filter + .to_block + .clone() + .and_then(|v| v.to_min_block_num()) + .map(|s| s.unique_saturated_into()) + .unwrap_or(best_number); + + if current_number > best_number { + current_number = best_number; + } + + // The from clause is the max(last_poll, filter_from). + let last_poll = pool_item + .last_poll + .to_min_block_num() + .unwrap() + .unique_saturated_into(); + + let filter_from = filter + .from_block + .clone() + .and_then(|v| v.to_min_block_num()) + .map(|s| s.unique_saturated_into()) + .unwrap_or(last_poll); + + let from_number = std::cmp::max(last_poll, filter_from); + // Build the response. + let mut blocks_and_statuses = Vec::new(); + while current_number >= from_number { + let id = BlockId::Number(current_number); + + let (block, _, statuses) = + self.client.runtime_api().current_all(&id).map_err(|err| { + internal_err(format!( + "fetch runtime account basic failed: {:?}", + err + )) + })?; + + if let (Some(block), Some(statuses)) = (block, statuses) { + blocks_and_statuses.push((block, statuses)); + } + + if current_number == Zero::zero() { + break; + } else { + current_number = current_number.saturating_sub(One::one()); + } + } + // Update filter `last_poll`. + locked.insert( + key, + FilterPoolItem { + last_poll: BlockNumber::Num(block_number + 1), + filter_type: pool_item.clone().filter_type, + at_block: pool_item.at_block, + }, + ); + Ok(FilterChanges::Logs(logs_build( + filter.clone(), + blocks_and_statuses, + ))) + } + // Should never reach here. + _ => Err(internal_err("Method not available.")), + } + } else { + Err(internal_err(format!("Filter id {:?} does not exist.", key))) + } + } else { + Err(internal_err("Filter pool is not available.")) + }; + response + } + + fn filter_logs(&self, index: Index) -> Result> { + let key = U256::from(index.value()); + let pool = self.filter_pool.clone(); + // Try to lock. + let response = if let Ok(locked) = &mut pool.lock() { + // Try to get key. + if let Some(pool_item) = locked.clone().get(&key) { + match &pool_item.filter_type { + FilterType::Log(filter) => { + let best_number = self.client.info().best_number; + let mut current_number = filter + .to_block + .clone() + .and_then(|v| v.to_min_block_num()) + .map(|s| s.unique_saturated_into()) + .unwrap_or(best_number); + + if current_number > best_number { + current_number = best_number; + } + + if current_number > self.client.info().best_number { + current_number = self.client.info().best_number; + } + + let from_number = filter + .from_block + .clone() + .and_then(|v| v.to_min_block_num()) + .map(|s| s.unique_saturated_into()) + .unwrap_or(self.client.info().best_number); + + let mut blocks_and_statuses = Vec::new(); + while current_number >= from_number { + let id = BlockId::Number(current_number); + + let (block, _, statuses) = + self.client.runtime_api().current_all(&id).map_err(|err| { + internal_err(format!( + "fetch runtime account basic failed: {:?}", + err + )) + })?; + + if let (Some(block), Some(statuses)) = (block, statuses) { + blocks_and_statuses.push((block, statuses)); + } + + if current_number == Zero::zero() { + break; + } else { + current_number = current_number.saturating_sub(One::one()); + } + } + Ok(logs_build(filter.clone(), blocks_and_statuses)) + } + _ => Err(internal_err(format!( + "Filter id {:?} is not a Log filter.", + key + ))), + } + } else { + Err(internal_err(format!("Filter id {:?} does not exist.", key))) + } + } else { + Err(internal_err("Filter pool is not available.")) + }; + response + } + + fn uninstall_filter(&self, index: Index) -> Result { + let key = U256::from(index.value()); + let pool = self.filter_pool.clone(); + // Try to lock. + let response = if let Ok(locked) = &mut pool.lock() { + if let Some(_) = locked.remove(&key) { + Ok(true) + } else { + Err(internal_err(format!("Filter id {:?} does not exist.", key))) + } + } else { + Err(internal_err("Filter pool is not available.")) + }; + response + } +} + +pub struct EthTask(PhantomData<(B, C)>); + +impl EthTask +where + C: ProvideRuntimeApi + BlockchainEvents, + B: BlockT, +{ + pub async fn pending_transaction_task( + client: Arc, + pending_transactions: Arc>>, + retain_threshold: u64, + ) { + let mut notification_st = client.import_notification_stream(); + + while let Some(notification) = notification_st.next().await { + if let Ok(mut pending_transactions) = pending_transactions.lock() { + // As pending transactions have a finite lifespan anyway + // we can ignore MultiplePostRuntimeLogs error checks. + let log = dp_consensus::find_log(¬ification.header.digest()).ok(); + let post_hashes = log.map(|log| log.into_hashes()); + + if let Some(post_hashes) = post_hashes { + // Retain all pending transactions that were not + // processed in the current block. + pending_transactions + .retain(|&k, _| !post_hashes.transaction_hashes.contains(&k)); + } + + let imported_number: u64 = UniqueSaturatedInto::::unique_saturated_into( + *notification.header.number(), + ); + + pending_transactions.retain(|_, v| { + // Drop all the transactions that exceeded the given lifespan. + let lifespan_limit = v.at_block + retain_threshold; + lifespan_limit > imported_number + }); + } + } + } + + pub async fn filter_pool_task( + client: Arc, + filter_pool: Arc>>, + retain_threshold: u64, + ) { + let mut notification_st = client.import_notification_stream(); + + while let Some(notification) = notification_st.next().await { + if let Ok(filter_pool) = &mut filter_pool.lock() { + let imported_number: u64 = UniqueSaturatedInto::::unique_saturated_into( + *notification.header.number(), + ); + + // BTreeMap::retain is unstable :c. + // 1. We collect all keys to remove. + // 2. We remove them. + let remove_list: Vec<_> = filter_pool + .iter() + .filter_map(|(&k, v)| { + let lifespan_limit = v.at_block + retain_threshold; + if lifespan_limit <= imported_number { + Some(k) + } else { + None + } + }) + .collect(); + + for key in remove_list { + filter_pool.remove(&key); + } + } + } + } +} diff --git a/client/dvm/rpc/src/eth_pubsub.rs b/client/dvm/rpc/src/eth_pubsub.rs index fa556fd..d8be35a 100644 --- a/client/dvm/rpc/src/eth_pubsub.rs +++ b/client/dvm/rpc/src/eth_pubsub.rs @@ -1,8 +1,18 @@ -use log::warn; +pub use dvm_rpc_core::EthPubSubApiServer; +// --- hyperspace --- +use dp_rpc::{ + pubsub::{Kind, Params, PubSubSyncStatus, Result as PubSubResult}, + Bytes, FilteredParams, Header, Log, Rich, +}; +use dvm_rpc_core::EthPubSubApi::{self as EthPubSubApiT}; +use dvm_rpc_runtime_api::{EthereumRuntimeRPCApi, TransactionStatus}; + +// --- substrate --- use sc_client_api::{ backend::{AuxStore, Backend, StateBackend, StorageProvider}, client::BlockchainEvents, }; +use sc_network::{ExHashT, NetworkService}; use sc_rpc::Metadata; use sp_api::{BlockId, ProvideRuntimeApi}; use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata}; @@ -10,35 +20,25 @@ use sp_io::hashing::twox_128; use sp_runtime::traits::{BlakeTwo256, Block as BlockT, UniqueSaturatedInto}; use sp_storage::{StorageData, StorageKey}; use sp_transaction_pool::TransactionPool; -use std::collections::BTreeMap; -use std::{iter, marker::PhantomData, sync::Arc}; - +// --- std --- use codec::Decode; -use dvm_rpc_core::EthPubSubApi::{self as EthPubSubApiT}; -use dvm_rpc_core_primitives::{ - pubsub::{Kind, Params, PubSubSyncStatus, Result as PubSubResult}, - Bytes, FilteredParams, Header, Log, Rich, -}; use ethereum_types::{H256, U256}; +use futures::{StreamExt as _, TryStreamExt as _}; +use jsonrpc_core::{ + futures::{Future, Sink}, + Result as JsonRpcResult, +}; use jsonrpc_pubsub::{ manager::{IdProvider, SubscriptionManager}, typed::Subscriber, SubscriptionId, }; +use log::warn; use rand::distributions::Alphanumeric; use rand::{thread_rng, Rng}; use sha3::{Digest, Keccak256}; - -pub use dvm_rpc_core::EthPubSubApiServer; -use futures::{StreamExt as _, TryStreamExt as _}; - -use dvm_rpc_runtime_api::{EthereumRuntimeRPCApi, TransactionStatus}; -use jsonrpc_core::{ - futures::{Future, Sink}, - Result as JsonRpcResult, -}; - -use sc_network::{ExHashT, NetworkService}; +use std::collections::BTreeMap; +use std::{iter, marker::PhantomData, sync::Arc}; #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] pub struct HexEncodedIdProvider { @@ -59,7 +59,8 @@ impl IdProvider for HexEncodedIdProvider { .map(|()| rng.sample(Alphanumeric)) .take(self.len) .collect(); - array_bytes::bytes2hex("0x", id.as_bytes()) + + array_bytes::bytes2hex("0x", id.as_bytes()) } } @@ -201,19 +202,6 @@ fn storage_prefix_build(module: &[u8], storage: &[u8]) -> Vec { [twox_128(module), twox_128(storage)].concat().to_vec() } -macro_rules! stream_build { - ($context:expr => $module:expr, $storage:expr) => {{ - let key: StorageKey = StorageKey(storage_prefix_build($module, $storage)); - match $context - .client - .storage_changes_notification_stream(Some(&[key]), None) - { - Ok(stream) => Some(stream), - Err(_err) => None, - } - }}; -} - impl EthPubSubApiT for EthPubSubApi where B: BlockT + Send + Sync + 'static, @@ -241,61 +229,71 @@ where let network = self.network.clone(); match kind { Kind::Logs => { - if let Some(stream) = stream_build!( - self => b"Ethereum", b"CurrentReceipts" - ) { - self.subscriptions.add(subscriber, |sink| { - let stream = stream - .flat_map(move |(block_hash, changes)| { - let id = BlockId::Hash(block_hash); - let data = changes.iter().last().unwrap().2.unwrap(); - let receipts: Vec = - Decode::decode(&mut &data.0[..]).unwrap(); - let block: ethereum::Block = - client.runtime_api().current_block(&id).unwrap().unwrap(); - futures::stream::iter(SubscriptionResult::new().logs( - block, - receipts, - &filtered_params, - )) - }) - .map(|x| { - return Ok::< - Result, - (), - >(Ok(PubSubResult::Log(Box::new(x)))); - }) - .compat(); - - sink.sink_map_err(|e| warn!("Error sending notifications: {:?}", e)) - .send_all(stream) - .map(|_| ()) - }); - } + self.subscriptions.add(subscriber, |sink| { + let stream = client + .import_notification_stream() + .filter_map(move |notification| { + if notification.is_new_best { + let id = BlockId::Hash(notification.hash); + let receipts = client.runtime_api().current_receipts(&id); + let block = client.runtime_api().current_block(&id); + match (receipts, block) { + (Ok(Some(receipts)), Ok(Some(block))) => { + futures::future::ready(Some((block, receipts))) + } + _ => futures::future::ready(None), + } + } else { + futures::future::ready(None) + } + }) + .flat_map(move |(block, receipts)| { + futures::stream::iter(SubscriptionResult::new().logs( + block, + receipts, + &filtered_params, + )) + }) + .map(|x| { + return Ok::, ()>( + Ok(PubSubResult::Log(Box::new(x))), + ); + }) + .compat(); + sink.sink_map_err(|e| warn!("Error sending notifications: {:?}", e)) + .send_all(stream) + .map(|_| ()) + }); } Kind::NewHeads => { - if let Some(stream) = stream_build!( - self => b"Ethereum", b"CurrentBlock" - ) { - self.subscriptions.add(subscriber, |sink| { - let stream = stream - .map(|(_block, changes)| { - let data = changes.iter().last().unwrap().2.unwrap(); - let block: ethereum::Block = - Decode::decode(&mut &data.0[..]).unwrap(); - return Ok::<_, ()>(Ok(SubscriptionResult::new().new_heads(block))); - }) - .compat(); - - sink.sink_map_err(|e| warn!("Error sending notifications: {:?}", e)) - .send_all(stream) - .map(|_| ()) - }); - } + self.subscriptions.add(subscriber, |sink| { + let stream = client + .import_notification_stream() + .filter_map(move |notification| { + if notification.is_new_best { + let id = BlockId::Hash(notification.hash); + let block = client.runtime_api().current_block(&id); + match block { + Ok(Some(block)) => futures::future::ready(Some(block)), + _ => futures::future::ready(None), + } + } else { + futures::future::ready(None) + } + }) + .map(|block| { + return Ok::<_, ()>(Ok(SubscriptionResult::new().new_heads(block))); + }) + .compat(); + sink.sink_map_err(|e| warn!("Error sending notifications: {:?}", e)) + .send_all(stream) + .map(|_| ()) + }); } Kind::NewPendingTransactions => { - if let Some(stream) = stream_build!( - self => b"Ethereum", b"Pending" + if let Ok(stream) = client.storage_changes_notification_stream( + Some(&[StorageKey(storage_prefix_build(b"Ethereum", b"Pending"))]), + None, ) { self.subscriptions.add(subscriber, |sink| { let stream = stream @@ -342,35 +340,29 @@ where } } Kind::Syncing => { - if let Some(stream) = stream_build!( - self => b"Ethereum", b"CurrentBlock" - ) { - self.subscriptions.add(subscriber, |sink| { - let mut previous_syncing = network.is_major_syncing(); - let stream = stream - .filter_map(move |(_, _)| { - let syncing = network.is_major_syncing(); - if previous_syncing != syncing { - previous_syncing = syncing; - futures::future::ready(Some(syncing)) - } else { - futures::future::ready(None) - } - }) - .map(|syncing| { - return Ok::< - Result, - (), - >(Ok(PubSubResult::SyncState(PubSubSyncStatus { - syncing, - }))); - }) - .compat(); - sink.sink_map_err(|e| warn!("Error sending notifications: {:?}", e)) - .send_all(stream) - .map(|_| ()) - }); - } + self.subscriptions.add(subscriber, |sink| { + let mut previous_syncing = network.is_major_syncing(); + let stream = client + .import_notification_stream() + .filter_map(move |notification| { + let syncing = network.is_major_syncing(); + if notification.is_new_best && previous_syncing != syncing { + previous_syncing = syncing; + futures::future::ready(Some(syncing)) + } else { + futures::future::ready(None) + } + }) + .map(|syncing| { + return Ok::, ()>( + Ok(PubSubResult::SyncState(PubSubSyncStatus { syncing })), + ); + }) + .compat(); + sink.sink_map_err(|e| warn!("Error sending notifications: {:?}", e)) + .send_all(stream) + .map(|_| ()) + }); } } } diff --git a/client/dvm/rpc/src/lib.rs b/client/dvm/rpc/src/lib.rs index f1fcd61..9a3983c 100644 --- a/client/dvm/rpc/src/lib.rs +++ b/client/dvm/rpc/src/lib.rs @@ -16,12 +16,21 @@ mod eth; mod eth_pubsub; +mod overrides; -pub use eth::{EthApi, EthApiServer, NetApi, NetApiServer, Web3Api, Web3ApiServer}; +pub use overrides::{SchemaV1Override, StorageOverride}; +// --- hyperspace --- +use hyperspace_evm::ExitReason; +// --- std --- +pub use eth::{ + EthApi, EthApiServer, EthFilterApi, EthFilterApiServer, EthTask, NetApi, NetApiServer, Web3Api, + Web3ApiServer, +}; pub use eth_pubsub::{EthPubSubApi, EthPubSubApiServer, HexEncodedIdProvider}; +use ethereum::{ + Transaction as EthereumTransaction, TransactionMessage as EthereumTransactionMessage, +}; use ethereum_types::H160; - -use hyperspace_evm::ExitReason; use jsonrpc_core::{Error, ErrorCode, Value}; pub fn internal_err(message: T) -> Error { @@ -65,6 +74,17 @@ pub fn error_on_execution_failure(reason: &ExitReason, data: &[u8]) -> Result<() } } +pub fn public_key(transaction: &EthereumTransaction) -> Result<[u8; 64], sp_io::EcdsaVerifyError> { + let mut sig = [0u8; 65]; + let mut msg = [0u8; 32]; + sig[0..32].copy_from_slice(&transaction.signature.r()[..]); + sig[32..64].copy_from_slice(&transaction.signature.s()[..]); + sig[64] = transaction.signature.standard_v(); + msg.copy_from_slice(&EthereumTransactionMessage::from(transaction.clone()).hash()[..]); + + sp_io::crypto::secp256k1_ecdsa_recover(&sig, &msg) +} + /// A generic Ethereum signer. pub trait EthSigner: Send + Sync { /// Available accounts from this signer. diff --git a/client/dvm/rpc/src/overrides/mod.rs b/client/dvm/rpc/src/overrides/mod.rs new file mode 100644 index 0000000..b167c5c --- /dev/null +++ b/client/dvm/rpc/src/overrides/mod.rs @@ -0,0 +1,136 @@ +// Copyright 2017-2020 Parity Technologies (UK) Ltd. +// This file is part of Frontier. + +// Substrate 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. + +// Substrate 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 Substrate. If not, see . + +// Something you need to know +// Once the runtime upgrade that involves changes to the dvm pallet storage schema, you should: +// 1. Add a new `EthereumStorageSchema` variant. +// 2. Put it in the well known `Schema` substrate storage. +// 3. Add a new `StorageOverride` implementor. (i.e. SchemaV2verride), DO NOT delete the previous `StorageOverride` implementor. +// 4. Insert the new implementor to the `overrides` BTreeMap and upgrade the node client. + +mod schema_v1_override; + +pub use schema_v1_override::SchemaV1Override; +// --- hyperspace --- +pub use dvm_rpc_core::{EthApiServer, NetApiServer}; +use dvm_rpc_runtime_api::EthereumRuntimeRPCApi; +use dvm_rpc_runtime_api::TransactionStatus; +// --- substrate --- +use sp_api::{BlockId, ProvideRuntimeApi}; +use sp_io::hashing::{blake2_128, twox_128}; +use sp_runtime::traits::Block as BlockT; +// --- std --- +use ethereum::Block as EthereumBlock; +use ethereum_types::{H160, H256, U256}; +use std::{marker::PhantomData, sync::Arc}; + +/// Something that can fetch Ethereum-related data. This trait is quite similar to the runtime API, +/// and indeed oe implementation of it uses the runtime API. +/// Having this trait is useful because it allows optimized implementations that fetch data from a +/// State Backend with some assumptions about pallet-ethereum's storage schema. Using such an +/// optimized implementation avoids spawning a runtime and the overhead associated with it. +pub trait StorageOverride { + /// For a given account address, returns pallet_evm::AccountCodes. + fn account_code_at(&self, block: &BlockId, address: H160) -> Option>; + /// For a given account address and index, returns pallet_evm::AccountStorages. + fn storage_at(&self, block: &BlockId, address: H160, index: U256) -> Option; + /// Return the current block. + fn current_block(&self, block: &BlockId) -> Option; + /// Return the current receipt. + fn current_receipts(&self, block: &BlockId) -> Option>; + /// Return the current transaction status. + fn current_transaction_statuses( + &self, + block: &BlockId, + ) -> Option>; +} + +fn storage_prefix_build(module: &[u8], storage: &[u8]) -> Vec { + [twox_128(module), twox_128(storage)].concat().to_vec() +} + +fn blake2_128_extend(bytes: &[u8]) -> Vec { + let mut ext: Vec = blake2_128(bytes).to_vec(); + ext.extend_from_slice(bytes); + ext +} + +/// A wrapper type for the Runtime API. This type implements `StorageOverride`, so it can be used +/// when calling the runtime API is desired but a `dyn StorageOverride` is required. +pub struct RuntimeApiStorageOverride { + client: Arc, + _marker: PhantomData, +} + +impl RuntimeApiStorageOverride +where + C: ProvideRuntimeApi, + C::Api: EthereumRuntimeRPCApi, + B: BlockT + Send + Sync + 'static, + C: Send + Sync + 'static, +{ + pub fn new(client: Arc) -> Self { + Self { + client, + _marker: PhantomData, + } + } +} + +impl StorageOverride for RuntimeApiStorageOverride +where + C: ProvideRuntimeApi, + C::Api: EthereumRuntimeRPCApi, + Block: BlockT + Send + Sync + 'static, + C: Send + Sync + 'static, +{ + /// For a given account address, returns pallet_evm::AccountCodes. + fn account_code_at(&self, block: &BlockId, address: H160) -> Option> { + self.client + .runtime_api() + .account_code_at(&block, address) + .ok() + } + + /// For a given account address and index, returns pallet_evm::AccountStorages. + fn storage_at(&self, block: &BlockId, address: H160, index: U256) -> Option { + self.client + .runtime_api() + .storage_at(&block, address, index) + .ok() + } + + /// Return the current block. + fn current_block(&self, block: &BlockId) -> Option { + self.client.runtime_api().current_block(&block).ok()? + } + + /// Return the current receipt. + fn current_receipts(&self, block: &BlockId) -> Option> { + self.client.runtime_api().current_receipts(&block).ok()? + } + + /// Return the current transaction status. + fn current_transaction_statuses( + &self, + block: &BlockId, + ) -> Option> { + self.client + .runtime_api() + .current_transaction_statuses(&block) + .ok()? + } +} diff --git a/client/dvm/rpc/src/overrides/schema_v1_override.rs b/client/dvm/rpc/src/overrides/schema_v1_override.rs new file mode 100644 index 0000000..501a057 --- /dev/null +++ b/client/dvm/rpc/src/overrides/schema_v1_override.rs @@ -0,0 +1,133 @@ +// Copyright 2017-2020 Parity Technologies (UK) Ltd. +// This file is part of Frontier. + +// Substrate 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. + +// Substrate 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 Substrate. If not, see . + +use super::{blake2_128_extend, storage_prefix_build, StorageOverride}; +// --- hyperspace --- +use dvm_rpc_runtime_api::TransactionStatus; +// --- substrate --- +use sc_client_api::backend::{AuxStore, Backend, StateBackend, StorageProvider}; +use sp_api::BlockId; +use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata}; +use sp_runtime::traits::{BlakeTwo256, Block as BlockT}; +use sp_storage::StorageKey; +// --- std --- +use codec::Decode; +use ethereum::Block as EthereumBlock; +use ethereum_types::{H160, H256, U256}; +use std::{marker::PhantomData, sync::Arc}; + +/// An override for runtimes that use Schema V1 +pub struct SchemaV1Override { + client: Arc, + _marker: PhantomData<(B, BE)>, +} + +impl SchemaV1Override { + pub fn new(client: Arc) -> Self { + Self { + client, + _marker: PhantomData, + } + } +} + +impl SchemaV1Override +where + C: StorageProvider + AuxStore, + C: HeaderBackend + HeaderMetadata + 'static, + BE: Backend + 'static, + BE::State: StateBackend, + B: BlockT + Send + Sync + 'static, + C: Send + Sync + 'static, +{ + // My attempt using result + // fn query_storage(&self, id: &BlockId, key: &StorageKey) -> Result { + // let raw_data = self.client.storage(id, key)? + // .ok_or("Storage provider returned Ok(None)")?; + // + // Decode::decode(&mut &raw_data.0[..]).map_err(|_| "Could not decode data".into()) + // } + + fn query_storage(&self, id: &BlockId, key: &StorageKey) -> Option { + if let Ok(Some(data)) = self.client.storage(id, key) { + if let Ok(result) = Decode::decode(&mut &data.0[..]) { + return Some(result); + } + } + None + } +} + +impl StorageOverride for SchemaV1Override +where + C: StorageProvider, + C: AuxStore, + C: HeaderBackend, + C: HeaderMetadata + 'static, + BE: Backend + 'static, + BE::State: StateBackend, + Block: BlockT + Send + Sync + 'static, + C: Send + Sync + 'static, +{ + /// For a given account address, returns pallet_evm::AccountCodes. + fn account_code_at(&self, block: &BlockId, address: H160) -> Option> { + let mut key: Vec = storage_prefix_build(b"EVM", b"AccountCodes"); + key.extend(blake2_128_extend(address.as_bytes())); + self.query_storage::>(block, &StorageKey(key)) + } + + /// For a given account address and index, returns pallet_evm::AccountStorages. + fn storage_at(&self, block: &BlockId, address: H160, index: U256) -> Option { + let tmp: &mut [u8; 32] = &mut [0; 32]; + index.to_little_endian(tmp); + + let mut key: Vec = storage_prefix_build(b"EVM", b"AccountStorages"); + key.extend(blake2_128_extend(address.as_bytes())); + key.extend(blake2_128_extend(tmp)); + + self.query_storage::(block, &StorageKey(key)) + } + + /// Return the current block. + fn current_block(&self, block: &BlockId) -> Option { + self.query_storage::( + block, + &StorageKey(storage_prefix_build(b"Ethereum", b"CurrentBlock")), + ) + } + + /// Return the current receipt. + fn current_receipts(&self, block: &BlockId) -> Option> { + self.query_storage::>( + block, + &StorageKey(storage_prefix_build(b"Ethereum", b"CurrentReceipts")), + ) + } + + /// Return the current transaction status. + fn current_transaction_statuses( + &self, + block: &BlockId, + ) -> Option> { + self.query_storage::>( + block, + &StorageKey(storage_prefix_build( + b"Ethereum", + b"CurrentTransactionStatuses", + )), + ) + } +} diff --git a/frame/balances/Cargo.toml b/frame/balances/Cargo.toml index ce1f453..a8bd12e 100644 --- a/frame/balances/Cargo.toml +++ b/frame/balances/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0" name = "hyperspace-balances" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "1.4.0" +version = "2.0.0" [dependencies] # crates @@ -17,16 +17,16 @@ serde = { version = "1.0.124", optional = true } hyperspace-balances-rpc-runtime-api = { default-features = false, path = "./rpc/runtime-api" } hyperspace-support = { default-features = false, path = "../support" } # substrate -frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [dev-dependencies] # substrate -pallet-transaction-payment = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-core = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-io = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +pallet-transaction-payment = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-core = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-io = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [features] default = ["std"] diff --git a/frame/balances/rpc/Cargo.toml b/frame/balances/rpc/Cargo.toml index f9ec6a9..64ecf7a 100644 --- a/frame/balances/rpc/Cargo.toml +++ b/frame/balances/rpc/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0" name = "hyperspace-balances-rpc" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "1.4.0" +version = "2.0.0" [dependencies] # crates @@ -18,6 +18,6 @@ jsonrpc-derive = { version = "15.1.0" } # hyperspace hyperspace-balances-rpc-runtime-api = { path = "./runtime-api" } # substrate -sp-api = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-blockchain = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-runtime = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-api = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-blockchain = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-runtime = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } diff --git a/frame/balances/rpc/runtime-api/Cargo.toml b/frame/balances/rpc/runtime-api/Cargo.toml index d364508..5bfcde7 100644 --- a/frame/balances/rpc/runtime-api/Cargo.toml +++ b/frame/balances/rpc/runtime-api/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0" name = "hyperspace-balances-rpc-runtime-api" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "1.4.0" +version = "2.0.0" [dependencies] # crates @@ -16,8 +16,8 @@ serde = { version = "1.0.124", optional = true, features = ["derive"] } # hyperspace hyperspace-support = { default-features = false, path = "../../../support" } # substrate -sp-api = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-api = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [features] default = ["std"] diff --git a/frame/balances/src/tests.rs b/frame/balances/src/tests.rs index 767068c..5cd5a9c 100644 --- a/frame/balances/src/tests.rs +++ b/frame/balances/src/tests.rs @@ -403,10 +403,10 @@ macro_rules! decl_tests { #[test] fn balance_works() { <$ext_builder>::default().build().execute_with(|| { - let _ = Etp::deposit_creating(&1, 150); - assert_eq!(Etp::free_balance(1), 150); + let _ = Etp::deposit_creating(&1, 42); + assert_eq!(Etp::free_balance(1), 42); assert_eq!(Etp::reserved_balance(1), 0); - assert_eq!(Etp::total_balance(&1), 150); + assert_eq!(Etp::total_balance(&1), 42); assert_eq!(Etp::free_balance(2), 0); assert_eq!(Etp::reserved_balance(2), 0); assert_eq!(Etp::total_balance(&2), 0); @@ -418,7 +418,7 @@ macro_rules! decl_tests { <$ext_builder>::default().build().execute_with(|| { let _ = Etp::deposit_creating(&1, 111); assert_ok!(Etp::transfer(Some(1).into(), 2, 69)); - assert_eq!(Etp::total_balance(&1), 150); + assert_eq!(Etp::total_balance(&1), 42); assert_eq!(Etp::total_balance(&2), 69); }); } @@ -429,7 +429,7 @@ macro_rules! decl_tests { let _ = Etp::deposit_creating(&1, 111); assert_noop!(Etp::force_transfer(Some(2).into(), 1, 2, 69), BadOrigin,); assert_ok!(Etp::force_transfer(RawOrigin::Root.into(), 1, 2, 69)); - assert_eq!(Etp::total_balance(&1), 150); + assert_eq!(Etp::total_balance(&1), 42); assert_eq!(Etp::total_balance(&2), 69); }); } diff --git a/frame/bridge/ethereum/backing/Cargo.toml b/frame/bridge/ethereum/backing/Cargo.toml index de97381..9931074 100644 --- a/frame/bridge/ethereum/backing/Cargo.toml +++ b/frame/bridge/ethereum/backing/Cargo.toml @@ -7,14 +7,14 @@ license = "GPL-3.0" name = "hyperspace-ethereum-backing" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "1.4.0" +version = "2.0.0" [dependencies] # crates array-bytes = { version = "1.1.0" } -codec = { package = "parity-scale-codec", version = "1.3.7", default-features = false, features = ["derive"] } -serde = { version = "1.0.124", optional = true } -serde_json = { version = "1.0.62", optional = true } +codec = { package = "parity-scale-codec", version = "1.3.7", default-features = false, features = ["derive"] } +serde = { version = "1.0.124", optional = true } +serde_json = { version = "1.0.62", optional = true } # hyperspace hyperspace-relay-primitives = { default-features = false, path = "../../../../primitives/relay" } hyperspace-support = { default-features = false, path = "../../../support" } @@ -22,11 +22,11 @@ ethereum-primitives = { default-features = false, path = "../../../../prim # github ethabi = { default-features = false, git = "https://github.com/new-mvs/ethabi.git", branch = "with_no_std" } # substrate -frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [dev-dependencies] # hyperspace @@ -40,10 +40,10 @@ ethereum-primitives = { features = ["deserialize"], path = "../../../ # github rlp = { package = "rlp", git = "https://github.com/new-mvs/parity-common.git" } # substrate -pallet-session = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -pallet-timestamp = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-core = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-staking = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +pallet-session = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +pallet-timestamp = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-core = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-staking = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [features] default = ["std"] diff --git a/frame/bridge/ethereum/backing/src/lib.rs b/frame/bridge/ethereum/backing/src/lib.rs index b831014..26a4f40 100644 --- a/frame/bridge/ethereum/backing/src/lib.rs +++ b/frame/bridge/ethereum/backing/src/lib.rs @@ -18,7 +18,7 @@ //! Prototype module for cross chain assets backing. -// TODO: https://github.com/new-mvs/darwinia-common/issues/372 +// TODO: https://github.com/mvs-org/Hyperspaceissues/372 #![allow(unused)] #![cfg_attr(not(feature = "std"), no_std)] #![recursion_limit = "128"] @@ -74,7 +74,6 @@ use sp_runtime::{ use sp_std::borrow::ToOwned; use sp_std::{convert::TryFrom, prelude::*}; // --- hyperspace --- - use hyperspace_relay_primitives::relay_authorities::*; use hyperspace_support::{ balance::lock::*, @@ -269,7 +268,7 @@ decl_module! { let fee_account = Self::fee_account_id(); let locked = utilities::with_transaction_result(|| { // 50 Etp for fee - // https://github.com/new-mvs/darwinia-common/pull/377#issuecomment-730369387 + // https://github.com/mvs-org/Hyperspacepull/377#issuecomment-730369387 T::EtpCurrency::transfer(&user, &fee_account, T::AdvancedFee::get(), KeepAlive)?; let mut locked = false; @@ -367,11 +366,11 @@ decl_module! { } } - /// Set a new redeem address. + /// Set a new ring redeem address. /// /// The dispatch origin of this call must be _Root_. /// - /// - `new`: The new redeem address. + /// - `new`: The new ring redeem address. /// /// # /// - `O(1)`. @@ -666,7 +665,7 @@ impl Module { } // event SetAuthritiesEvent(uint32 nonce, address[] authorities, bytes32 benifit); - // https://github.com/new-mvs/hyperspace-bridge-on-ethereum/blob/51839e614c0575e431eabfd5c70b84f6aa37826a/contracts/Relay.sol#L22 + // https://github.com/hyperspace-network/hyperspace-bridge-on-ethereum/blob/51839e614c0575e431eabfd5c70b84f6aa37826a/contracts/Relay.sol#L22 // https://ropsten.etherscan.io/tx/0x652528b9421ecb495610a734a4ab70d054b5510dbbf3a9d5c7879c43c7dde4e9#eventlog fn parse_authorities_set_proof( proof_record: &EthereumReceiptProofThing, diff --git a/frame/bridge/ethereum/backing/src/mock.rs b/frame/bridge/ethereum/backing/src/mock.rs index 37e0f63..85a664d 100644 --- a/frame/bridge/ethereum/backing/src/mock.rs +++ b/frame/bridge/ethereum/backing/src/mock.rs @@ -32,7 +32,6 @@ macro_rules! decl_tests { ModuleId, {KeyTypeId, MultiSignature, Perbill}, }; // --- hyperspace --- - use hyperspace_staking::{EraIndex, Exposure, ExposureOf}; type Balance = u128; diff --git a/frame/bridge/ethereum/backing/src/test_with_linear_relay.rs b/frame/bridge/ethereum/backing/src/test_with_linear_relay.rs index 1c8b4ec..ec57cd4 100644 --- a/frame/bridge/ethereum/backing/src/test_with_linear_relay.rs +++ b/frame/bridge/ethereum/backing/src/test_with_linear_relay.rs @@ -24,7 +24,6 @@ use frame_system::RawOrigin; use sp_runtime::{traits::Dispatchable, AccountId32}; // --- hyperspace --- use crate::*; -use array_bytes::array_bytes::hex2bytes_unchecked; use hyperspace_staking::{RewardDestination, StakingBalance, StakingLedger, TimeDepositItem}; use hyperspace_support::balance::lock::StakingLock; use ethereum_primitives::{ @@ -235,7 +234,7 @@ fn verify_linear_redeem_deposit() { .execute_with(|| { assert_ok!(EthereumRelay::set_number_of_blocks_safe(RawOrigin::Root.into(), 0)); - // 1234 -> 0.1234dna + // 1234ring -> 0.1234dna // _depositID 2 // 0: address: 0xcC5E48BEb33b83b8bD0D9d9A85A8F6a27C51F5C5 _depositor diff --git a/frame/bridge/ethereum/backing/src/test_with_relay.rs b/frame/bridge/ethereum/backing/src/test_with_relay.rs index cd36e79..a1ffdb6 100644 --- a/frame/bridge/ethereum/backing/src/test_with_relay.rs +++ b/frame/bridge/ethereum/backing/src/test_with_relay.rs @@ -24,7 +24,6 @@ use frame_system::EnsureRoot; use sp_runtime::{traits::Dispatchable, AccountId32}; // --- hyperspace --- use crate::*; - use hyperspace_ethereum_relay::{EthereumRelayHeaderParcel, EthereumRelayProofs, MMRProof}; use hyperspace_relay_primitives::relayer_game::*; use hyperspace_staking::{RewardDestination, StakingBalance, StakingLedger, TimeDepositItem}; @@ -284,7 +283,7 @@ fn verify_redeem_deposit() { ExtBuilder::default() .build() .execute_with(|| { - // 1234 -> 0.1234dna + // 1234ring -> 0.1234dna // _depositID 2 // 0: address: 0xcC5E48BEb33b83b8bD0D9d9A85A8F6a27C51F5C5 _depositor diff --git a/frame/bridge/ethereum/linear-relay/Cargo.toml b/frame/bridge/ethereum/linear-relay/Cargo.toml index 5af1f68..9815bc2 100644 --- a/frame/bridge/ethereum/linear-relay/Cargo.toml +++ b/frame/bridge/ethereum/linear-relay/Cargo.toml @@ -8,7 +8,7 @@ license = "GPL-3.0" name = "hyperspace-ethereum-linear-relay" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "1.4.0" +version = "2.0.0" [dependencies] # crates @@ -22,10 +22,10 @@ ethereum-primitives = { default-features = false, path = "../../../../primitives ethereum-types = { default-features = false, git = "https://github.com/new-mvs/parity-common.git" } rlp = { default-features = false, git = "https://github.com/new-mvs/parity-common.git" } # substrate -frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [dev-dependencies] # crates @@ -34,8 +34,8 @@ array-bytes = { version = "1.1.0" } hyperspace-balances = { path = "../../../../frame/balances" } ethereum-primitives = { features = ["deserialize"], path = "../../../../primitives/ethereum-primitives" } # substrate -sp-core = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-io = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-core = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-io = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [features] default = ["std"] diff --git a/frame/bridge/ethereum/linear-relay/src/mock.rs b/frame/bridge/ethereum/linear-relay/src/mock.rs index d95d54f..58f9cbb 100644 --- a/frame/bridge/ethereum/linear-relay/src/mock.rs +++ b/frame/bridge/ethereum/linear-relay/src/mock.rs @@ -149,14 +149,16 @@ impl BlockWithProof { BlockWithProof { proof_length: raw_block_with_proof.proof_length, - merkle_root: array_bytes::hex2array_unchecked!(&raw_block_with_proof.merkle_root, 16).into(), + merkle_root: array_bytes::hex2array_unchecked!(&raw_block_with_proof.merkle_root, 16) + .into(), header_rlp: array_bytes::hex2bytes_unchecked(&raw_block_with_proof.header_rlp), merkle_proofs: raw_block_with_proof .merkle_proofs .iter() .cloned() .map(|raw_merkle_proof| { - array_bytes::hex2array_unchecked!(&zero_padding(raw_merkle_proof, 16), 16).into() + array_bytes::hex2array_unchecked!(&zero_padding(raw_merkle_proof, 16), 16) + .into() }) .collect(), elements: raw_block_with_proof @@ -222,7 +224,9 @@ impl HeaderWithProof { serde_json::from_reader(File::open(path).unwrap()).unwrap(); Self { header: Decode::decode::<&[u8]>( - &mut &array_bytes::hex2bytes_unchecked(raw_shadow_service_response.result.eth_header)[..], + &mut &array_bytes::hex2bytes_unchecked( + raw_shadow_service_response.result.eth_header, + )[..], ) .unwrap(), proof: Decode::decode::<&[u8]>( @@ -319,8 +323,11 @@ pub fn mock_canonical_receipt() -> EthereumReceiptProof { .parse() .unwrap(), proof: array_bytes::hex2bytes_unchecked(receipt["proof"].as_str().unwrap()), - header_hash: array_bytes::hex2array_unchecked!(receipt["header_hash"].as_str().unwrap(), 32) - .into(), + header_hash: array_bytes::hex2array_unchecked!( + receipt["header_hash"].as_str().unwrap(), + 32 + ) + .into(), } } @@ -353,7 +360,7 @@ pub const MAINNET_GENESIS_HEADER: &'static str = r#" "gasUsed": "0x0", "hash": "0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "miner": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa", + "miner": "0x0000000000000000000000000000000000000000", "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", "nonce": "0x0000000000000042", "number": "0x0", diff --git a/frame/bridge/ethereum/relay/Cargo.toml b/frame/bridge/ethereum/relay/Cargo.toml index 5223e1e..93a5886 100644 --- a/frame/bridge/ethereum/relay/Cargo.toml +++ b/frame/bridge/ethereum/relay/Cargo.toml @@ -8,15 +8,15 @@ license = "GPL-3.0" name = "hyperspace-ethereum-relay" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "1.4.0" +version = "2.0.0" [dependencies] # crates array-bytes = { version = "1.1.0" } -blake2-rfc = { version = "0.2.18", default-features = false } -codec = { package = "parity-scale-codec", version = "1.3.7", default-features = false } -serde = { version = "1.0.124", optional = true } -serde_json = { version = "1.0.62", optional = true } +blake2-rfc = { version = "0.2.18", default-features = false } +codec = { package = "parity-scale-codec", version = "1.3.7", default-features = false } +serde = { version = "1.0.124", optional = true } +serde_json = { version = "1.0.62", optional = true } # hyperspace hyperspace-relay-primitives = { default-features = false, path = "../../../../primitives/relay" } hyperspace-relayer-game = { default-features = false, path = "../../../bridge/relayer-game" } @@ -27,19 +27,19 @@ ckb-merkle-mountain-range = { default-features = false, git = "https://github.co ethereum-types = { default-features = false, git = "https://github.com/new-mvs/parity-common.git" } rlp = { default-features = false, git = "https://github.com/new-mvs/parity-common.git" } # substrate -frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [dev-dependencies] # hyperspace hyperspace-balances = { path = "../../../../frame/balances" } ethereum-primitives = { features = ["deserialize"], path = "../../../../primitives/ethereum-primitives" } # substrate -sp-core = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-io = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-core = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-io = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [features] default = ["std"] diff --git a/frame/bridge/ethereum/relay/src/lib.rs b/frame/bridge/ethereum/relay/src/lib.rs index bee33e7..f41535d 100644 --- a/frame/bridge/ethereum/relay/src/lib.rs +++ b/frame/bridge/ethereum/relay/src/lib.rs @@ -72,7 +72,6 @@ use sp_std::borrow::ToOwned; use sp_std::{convert::From, marker::PhantomData, prelude::*}; // --- hyperspace --- use crate::mmr::{leaf_index_to_mmr_size, leaf_index_to_pos, MMRMerge, MerkleProof}; - use hyperspace_relay_primitives::relayer_game::*; use hyperspace_support::{ balance::lock::LockableCurrency, traits::EthereumReceipt as EthereumReceiptT, diff --git a/frame/bridge/oldetp/backing/Cargo.toml b/frame/bridge/oldetp/backing/Cargo.toml index 7d55c61..b9cc485 100644 --- a/frame/bridge/oldetp/backing/Cargo.toml +++ b/frame/bridge/oldetp/backing/Cargo.toml @@ -7,16 +7,16 @@ license = "GPL-3.0" name = "hyperspace-oldetp-backing" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "1.4.0" +version = "2.0.0" [dependencies] # crates codec = { package = "parity-scale-codec", version = "1.3.7", default-features = false } serde = { version = "1.0.124", optional = true } # substrate -frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [features] default = ["std"] diff --git a/frame/bridge/oldetp/backing/src/lib.rs b/frame/bridge/oldetp/backing/src/lib.rs index a7be653..bb8df67 100644 --- a/frame/bridge/oldetp/backing/src/lib.rs +++ b/frame/bridge/oldetp/backing/src/lib.rs @@ -33,13 +33,9 @@ mod types { #[cfg(feature = "std")] pub type EtpBalance = as Currency>>::Balance; - #[cfg(feature = "std")] - pub type DnaBalance = as Currency>>::Balance; #[cfg(feature = "std")] type EtpCurrency = ::EtpCurrency; - #[cfg(feature = "std")] - type DnaCurrency = ::DnaCurrency; } // --- substrate --- @@ -55,7 +51,6 @@ pub trait Config: frame_system::Config { type ModuleId: Get; type EtpCurrency: Currency>; - type DnaCurrency: Currency>; type WeightInfo: WeightInfo; } @@ -65,17 +60,11 @@ decl_storage! { add_extra_genesis { config(backed_etp): EtpBalance; - config(backed_dna): DnaBalance; build(|config| { - let module_account = >::account_id(); let _ = T::EtpCurrency::make_free_balance_be( - &module_account, + &>::account_id(), T::EtpCurrency::minimum_balance() + config.backed_etp ); - let _ = T::DnaCurrency::make_free_balance_be( - &module_account, - config.backed_dna - ); }); } } diff --git a/frame/bridge/oldetp/issuing/Cargo.toml b/frame/bridge/oldetp/issuing/Cargo.toml index 50d9a6a..d284a90 100644 --- a/frame/bridge/oldetp/issuing/Cargo.toml +++ b/frame/bridge/oldetp/issuing/Cargo.toml @@ -1,29 +1,29 @@ [package] -authors = ["Metaverse "] +authors = ["Hyperspace Network "] description = "FRAME to issue CETP" edition = "2018" homepage = "https://mvs.org/" license = "GPL-3.0" -name = "hyperspace-oldETP-issuing" +name = "hyperspace-oldetp-issuing" readme = "README.md" -repository = "https://github.com/hyperspace-network/hyperspace-common/" -version = "1.4.0" +repository = "https://github.com/mvs-org/Hyperspace" +version = "2.0.0" [dependencies] # crates -codec = { package = "parity-scale-codec", version = "1.3.5", default-features = false } -serde = { version = "1.0.118", optional = true } -serde_json = { version = "1.0.61", optional = true } +codec = { package = "parity-scale-codec", version = "1.3.7", default-features = false } +serde = { version = "1.0.124", optional = true } +serde_json = { version = "1.0.62", optional = true } # substrate -frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", branch = "common-library" } -frame-system = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", branch = "common-library" } -sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", branch = "common-library" } +frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } # hyperspace hyperspace-support = { optional = true, path = "../../../support" } [dev-dependencies] # substrate -sp-io = { git = "https://github.com/darwinia-network/substrate.git", branch = "common-library" } +sp-io = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } # hyperspace hyperspace-balances = { path = "../../../balances" } hyperspace-support = { path = "../../../support" } diff --git a/frame/bridge/oldetp/issuing/src/lib.rs b/frame/bridge/oldetp/issuing/src/lib.rs index bceeb32..92f2b2a 100644 --- a/frame/bridge/oldetp/issuing/src/lib.rs +++ b/frame/bridge/oldetp/issuing/src/lib.rs @@ -1,6 +1,6 @@ // This file is part of Hyperspace. // -// Copyright (C) 2018-2021 Metaverse +// Copyright (C) 2018-2021 Hyperspace Network // SPDX-License-Identifier: GPL-3.0 // // Hyperspace is free software: you can redistribute it and/or modify @@ -10,16 +10,20 @@ // // Hyperspace 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 +// 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 Hyperspace. If not, see . -//! # oldETP Issuing Module +//! # Oldetp Issuing Module #![cfg_attr(not(feature = "std"), no_std)] +pub mod weights; +// --- hyperspace --- +pub use weights::WeightInfo; + #[cfg(test)] mod mock; #[cfg(test)] @@ -31,11 +35,11 @@ mod types { pub type MappedEtp = u128; - pub type AccountId = ::AccountId; + pub type AccountId = ::AccountId; pub type EtpBalance = as Currency>>::Balance; - type EtpCurrency = ::EtpCurrency; + type EtpCurrency = ::EtpCurrency; } // --- substrate --- @@ -47,8 +51,8 @@ use sp_runtime::{traits::AccountIdConversion, ModuleId}; // --- hyperspace --- use types::*; -pub trait Trait: frame_system::Trait { - type Event: From> + Into<::Event>; +pub trait Config: frame_system::Config { + type Event: From> + Into<::Event>; type ModuleId: Get; @@ -57,9 +61,6 @@ pub trait Trait: frame_system::Trait { type WeightInfo: WeightInfo; } -pub trait WeightInfo {} -impl WeightInfo for () {} - decl_event! { pub enum Event where @@ -72,12 +73,12 @@ decl_event! { } decl_error! { - pub enum Error for Module { + pub enum Error for Module { } } decl_storage! { - trait Store for Module as HyperspaceoldETPIssuing { + trait Store for Module as HyperspaceOldetpIssuing { pub TotalMappedEtp get(fn total_mapped_etp) config(): MappedEtp; } @@ -94,7 +95,7 @@ decl_storage! { } decl_module! { - pub struct Module for enum Call + pub struct Module for enum Call where origin: T::Origin { @@ -106,7 +107,7 @@ decl_module! { } } -impl Module { +impl Module { pub fn account_id() -> T::AccountId { T::ModuleId::get().into_account() } diff --git a/frame/bridge/oldetp/issuing/src/mock.rs b/frame/bridge/oldetp/issuing/src/mock.rs index 6569c6b..4eee039 100644 --- a/frame/bridge/oldetp/issuing/src/mock.rs +++ b/frame/bridge/oldetp/issuing/src/mock.rs @@ -1,6 +1,6 @@ // This file is part of Hyperspace. // -// Copyright (C) 2018-2021 Metaverse +// Copyright (C) 2018-2021 Hyperspace Network // SPDX-License-Identifier: GPL-3.0 // // Hyperspace is free software: you can redistribute it and/or modify @@ -10,7 +10,7 @@ // // Hyperspace 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 +// 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 @@ -18,7 +18,7 @@ #![allow(dead_code)] -pub mod oldETP_issuing { +pub mod oldetp_issuing { // --- hyperspace --- pub use crate::Event; } @@ -26,12 +26,12 @@ pub mod oldETP_issuing { // --- crates --- use codec::{Decode, Encode}; // --- substrate --- -use frame_support::{impl_outer_event, impl_outer_origin, parameter_types, weights::Weight}; +use frame_support::{impl_outer_event, impl_outer_origin, parameter_types}; use sp_io::TestExternalities; use sp_runtime::{ testing::{Header, H256}, traits::{BlakeTwo256, IdentityLookup}, - Perbill, RuntimeDebug, + RuntimeDebug, }; // --- hyperspace --- use crate::*; @@ -40,11 +40,9 @@ pub type AccountId = u64; pub type Balance = u128; pub type System = frame_system::Module; -pub type Etp = hyperspace_balances::Module; -pub type oldETPIssuing = Module; +pub type OldetpIssuing = Module; -pub type oldETPIssuingError = Error; -pub type EtpError = hyperspace_balances::Error; +pub type OldetpIssuingError = Error; impl_outer_origin! { pub enum Origin for Test where system = frame_system {} @@ -54,33 +52,29 @@ impl_outer_event! { pub enum Event for Test { frame_system , hyperspace_balances Instance0, - oldETP_issuing , + oldetp_issuing , } } -hyperspace_support::impl_test_account_data! {} +hyperspace_support::impl_test_account_data! { deprecated } #[derive(Clone, Eq, PartialEq)] pub struct Test; parameter_types! { - pub const oldETPIssuingModuleId: ModuleId = ModuleId(*b"da/oldETPi"); + pub const OldetpIssuingModuleId: ModuleId = ModuleId(*b"da/oldetpi"); } -impl Trait for Test { +impl Config for Test { type Event = Event; - type ModuleId = oldETPIssuingModuleId; + type ModuleId = OldetpIssuingModuleId; type EtpCurrency = Etp; type WeightInfo = (); } -parameter_types! { - pub const BlockHashCount: u64 = 250; - pub const MaximumBlockWeight: Weight = 1024; - pub const MaximumBlockLength: u32 = 2 * 1024; - pub const MinimumPeriod: u64 = 5; - pub const AvailableBlockRatio: Perbill = Perbill::one(); -} -impl frame_system::Trait for Test { +impl frame_system::Config for Test { type BaseCallFilter = (); + type BlockWeights = (); + type BlockLength = (); + type DbWeight = (); type Origin = Origin; type Call = (); type Index = u64; @@ -92,25 +86,19 @@ impl frame_system::Trait for Test { type Header = Header; type Event = Event; type BlockHashCount = (); - type MaximumBlockWeight = (); - type DbWeight = (); - type BlockExecutionWeight = (); - type ExtrinsicBaseWeight = (); - type MaximumExtrinsicWeight = (); - type MaximumBlockLength = (); - type AvailableBlockRatio = (); type Version = (); type PalletInfo = (); type AccountData = AccountData; type OnNewAccount = (); type OnKilledAccount = (); type SystemWeightInfo = (); + type SS58Prefix = (); } parameter_types! { pub const ExistentialDeposit: Balance = 0; } -impl hyperspace_balances::Trait for Test { +impl hyperspace_balances::Config for Test { type Balance = Balance; type DustRemoval = (); type Event = Event; @@ -127,7 +115,7 @@ pub fn new_test_ext() -> TestExternalities { .build_storage::() .unwrap(); - hyperspace_balances::GenesisConfig:: { + EtpConfig { balances: (1..10) .map(|i: AccountId| vec![(i, 100 * i as Balance), (10 * i, 1000 * i as Balance)]) .flatten() @@ -155,9 +143,9 @@ pub fn events() -> Vec { events } -pub fn oldETP_issuing_events() -> Vec { +pub fn oldetp_issuing_events() -> Vec { events() .into_iter() - .filter(|e| matches!(e, Event::oldETP_issuing(_))) + .filter(|e| matches!(e, Event::oldetp_issuing(_))) .collect() } diff --git a/frame/bridge/oldetp/issuing/src/tests.rs b/frame/bridge/oldetp/issuing/src/tests.rs index 96c033d..48a0fe7 100644 --- a/frame/bridge/oldetp/issuing/src/tests.rs +++ b/frame/bridge/oldetp/issuing/src/tests.rs @@ -1,6 +1,6 @@ // This file is part of Hyperspace. // -// Copyright (C) 2018-2021 Metaverse +// Copyright (C) 2018-2021 Hyperspace Network // SPDX-License-Identifier: GPL-3.0 // // Hyperspace is free software: you can redistribute it and/or modify @@ -10,7 +10,7 @@ // // Hyperspace 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 +// 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 diff --git a/frame/bridge/oldetp/issuing/src/weights.rs b/frame/bridge/oldetp/issuing/src/weights.rs new file mode 100644 index 0000000..aadf2f9 --- /dev/null +++ b/frame/bridge/oldetp/issuing/src/weights.rs @@ -0,0 +1,2 @@ +pub trait WeightInfo {} +impl WeightInfo for () {} diff --git a/frame/bridge/oldna/backing/Cargo.toml b/frame/bridge/oldna/backing/Cargo.toml index 86f83f0..6df1b70 100644 --- a/frame/bridge/oldna/backing/Cargo.toml +++ b/frame/bridge/oldna/backing/Cargo.toml @@ -7,16 +7,16 @@ license = "GPL-3.0" name = "hyperspace-oldna-backing" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "1.4.0" +version = "2.0.0" [dependencies] # crates codec = { package = "parity-scale-codec", version = "1.3.7", default-features = false } serde = { version = "1.0.124", optional = true } # substrate -frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [features] default = ["std"] diff --git a/frame/bridge/oldna/backing/src/lib.rs b/frame/bridge/oldna/backing/src/lib.rs index cedade0..1d4f283 100644 --- a/frame/bridge/oldna/backing/src/lib.rs +++ b/frame/bridge/oldna/backing/src/lib.rs @@ -33,9 +33,13 @@ mod types { #[cfg(feature = "std")] pub type EtpBalance = as Currency>>::Balance; + #[cfg(feature = "std")] + pub type DnaBalance = as Currency>>::Balance; #[cfg(feature = "std")] type EtpCurrency = ::EtpCurrency; + #[cfg(feature = "std")] + type DnaCurrency = ::DnaCurrency; } // --- substrate --- @@ -51,6 +55,7 @@ pub trait Config: frame_system::Config { type ModuleId: Get; type EtpCurrency: Currency>; + type DnaCurrency: Currency>; type WeightInfo: WeightInfo; } @@ -60,11 +65,17 @@ decl_storage! { add_extra_genesis { config(backed_etp): EtpBalance; + config(backed_dna): DnaBalance; build(|config| { + let module_account = >::account_id(); let _ = T::EtpCurrency::make_free_balance_be( - &>::account_id(), + &module_account, T::EtpCurrency::minimum_balance() + config.backed_etp ); + let _ = T::DnaCurrency::make_free_balance_be( + &module_account, + config.backed_dna + ); }); } } diff --git a/frame/bridge/relay-authorities/Cargo.toml b/frame/bridge/relay-authorities/Cargo.toml index 596cc51..ffbfd95 100644 --- a/frame/bridge/relay-authorities/Cargo.toml +++ b/frame/bridge/relay-authorities/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0" name = "hyperspace-relay-authorities" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "1.4.0" +version = "2.0.0" [dependencies] # crates @@ -17,10 +17,10 @@ serde = { version = "1.0.124", optional = true } hyperspace-relay-primitives = { default-features = false, path = "../../../primitives/relay" } hyperspace-support = { default-features = false, path = "../../support" } # substrate -frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [dev-dependencies] # crates @@ -29,8 +29,8 @@ array-bytes = { version = "1.1.0" } hyperspace-balances = { path = "../../balances" } hyperspace-support = { path = "../../support" } # substrate -sp-core = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-io = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-core = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-io = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [features] default = ["std"] diff --git a/frame/bridge/relay-authorities/src/test.rs b/frame/bridge/relay-authorities/src/test.rs index b62621f..cdb5a3b 100644 --- a/frame/bridge/relay-authorities/src/test.rs +++ b/frame/bridge/relay-authorities/src/test.rs @@ -338,7 +338,7 @@ fn encode_message_should_work() { // ) let message = { _S { - _1: RuntimeString::from("DRML"), + _1: RuntimeString::from("HYPERSPACE"), _2: array_bytes::hex2array_unchecked!("0x479fbdf9", 4), _3: 789u32, _4: [0u8; 32], @@ -360,7 +360,7 @@ fn encode_message_should_work() { // ) let message = { _S { - _1: RuntimeString::from("DRML"), + _1: RuntimeString::from("HYPERSPACE"), _2: array_bytes::hex2array_unchecked!("0xb4bcf497", 4), _3: 789u32, _4: vec![[7u8; 20], [8u8; 20], [9u8; 20]], diff --git a/frame/bridge/relayer-game/Cargo.toml b/frame/bridge/relayer-game/Cargo.toml index 575411f..2ad45be 100644 --- a/frame/bridge/relayer-game/Cargo.toml +++ b/frame/bridge/relayer-game/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0" name = "hyperspace-relayer-game" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "1.4.0" +version = "2.0.0" [dependencies] # crates @@ -17,10 +17,10 @@ serde = { version = "1.0.124", optional = true } hyperspace-relay-primitives = { default-features = false, path = "../../../primitives/relay" } hyperspace-support = { default-features = false, path = "../../support" } # substrate -frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [dev-dependencies] # crates @@ -28,8 +28,8 @@ env_logger = { version = "0.8.2" } # hyperspace hyperspace-balances = { path = "../../balances" } # substrate -sp-core = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-io = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-core = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-io = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [features] default = ["std"] diff --git a/frame/claims/Cargo.toml b/frame/claims/Cargo.toml index 922ffe2..b61ba79 100644 --- a/frame/claims/Cargo.toml +++ b/frame/claims/Cargo.toml @@ -7,22 +7,22 @@ license = "GPL-3.0" name = "hyperspace-claims" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "1.4.0" +version = "2.0.0" [dependencies] # crates array-bytes = { version = "1.1.0" } -codec = { package = "parity-scale-codec", version = "1.3.7", default-features = false, features = ["derive"] } -serde = { version = "1.0.124", optional = true } -serde_json = { version = "1.0.62", optional = true } +codec = { package = "parity-scale-codec", version = "1.3.7", default-features = false, features = ["derive"] } +serde = { version = "1.0.124", optional = true } +serde_json = { version = "1.0.62", optional = true } # hyperspace hyperspace-support = { default-features = false, path = "../support" } # substrate -frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [dev-dependencies] # crates @@ -30,7 +30,7 @@ libsecp256k1 = { version = "0.3.5" } # hyperspace hyperspace-balances = { path = "../balances" } # substrate -sp-core = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-core = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [features] default = ["std"] diff --git a/frame/claims/src/address.rs b/frame/claims/src/address.rs index f57c39d..adb76bb 100644 --- a/frame/claims/src/address.rs +++ b/frame/claims/src/address.rs @@ -21,7 +21,6 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer}; // --- hyperspace --- use crate::AddressT; - macro_rules! impl_address { ($name:ident, $sname:expr, $prefix:expr) => { #[doc = "An "] @@ -79,9 +78,9 @@ hyperspace_support::impl_genesis! { struct ClaimsList { dot: Vec>, eth: Vec>, - oldetp: Vec> + oldna: Vec> } } impl_address!(EthereumAddress, "Ethereum", "0x"); -impl_address!(OldetpAddress, "Oldetp", "41"); +impl_address!(OldnaAddress, "Oldna", "41"); diff --git a/frame/claims/src/lib.rs b/frame/claims/src/lib.rs index 7002f64..51e99cc 100644 --- a/frame/claims/src/lib.rs +++ b/frame/claims/src/lib.rs @@ -110,8 +110,8 @@ decl_storage! { ClaimsFromEth get(fn claims_from_eth) : map hasher(identity) AddressT => Option>; - ClaimsFromOldetp - get(fn claims_from_oldetp) + ClaimsFromOldna + get(fn claims_from_oldna) : map hasher(identity) AddressT => Option>; } add_extra_genesis { @@ -120,11 +120,11 @@ decl_storage! { let ClaimsList { dot, eth, - oldetp, + oldna, } = &config.claims_list; let mut total = >::zero(); - if dot.is_empty() && eth.is_empty() && oldetp.is_empty() { + if dot.is_empty() && eth.is_empty() && oldna.is_empty() { error!("[hyperspace-claims] Genesis Claims List is Set to EMPTY"); } else { // Eth Address @@ -140,10 +140,10 @@ decl_storage! { total += backed_etp; } - // Oldetp Address - for Account { address, backed_etp } in oldetp { + // Oldna Address + for Account { address, backed_etp } in oldna { let backed_etp = (*backed_etp).saturated_into(); - >::insert(address.0, backed_etp); + >::insert(address.0, backed_etp); total += backed_etp; } } @@ -241,10 +241,10 @@ decl_module! { Self::deposit_event(RawEvent::Claimed(dest, signer, balance_due)); } - OtherSignature::Oldetp(signature) => { - let signer = Self::oldetp_recover(&signature, &data) + OtherSignature::Oldna(signature) => { + let signer = Self::oldna_recover(&signature, &data) .ok_or(>::InvalidSignature)?; - let balance_due = >::get(&signer) + let balance_due = >::get(&signer) .ok_or(>::SignerHasNoClaim)?; ensure!( @@ -258,7 +258,7 @@ decl_module! { KeepAlive, )?; - >::remove(&signer); + >::remove(&signer); Self::deposit_event(RawEvent::Claimed(dest, signer, balance_due)); } @@ -300,9 +300,9 @@ decl_module! { T::EtpCurrency::deposit_creating(&Self::account_id(), value); >::insert(who, value); } - OtherAddress::Oldetp(who) => { + OtherAddress::Oldna(who) => { T::EtpCurrency::deposit_creating(&Self::account_id(), value); - >::insert(who, value); + >::insert(who, value); } } } @@ -329,13 +329,13 @@ decl_module! { } else { Err(>::NewAddressTypeMis)?; }, - OtherAddress::Oldetp(old) => if let OtherAddress::Oldetp(new) = new { + OtherAddress::Oldna(old) => if let OtherAddress::Oldna(new) = new { ensure!( - !>::contains_key(&new), + !>::contains_key(&new), >::MoveToExistedAddress ); - >::take(&old).map(|c| >::insert(&new, c)); + >::take(&old).map(|c| >::insert(&new, c)); } else { Err(>::NewAddressTypeMis)?; } @@ -371,8 +371,8 @@ impl Module { } // Constructs the message that RPC's `personal_sign` and `sign` would sign. - // Oldetp have different signing specs: https://github.com/oldetpprotocol/tips/issues/104 - fn oldetp_signable_message(what: &[u8], signed_message: &[u8]) -> Vec { + // Oldna have different signing specs: https://github.com/oldnaprotocol/tips/issues/104 + fn oldna_signable_message(what: &[u8], signed_message: &[u8]) -> Vec { let prefix = T::Prefix::get(); let mut l = 32; let mut rev = Vec::new(); @@ -399,12 +399,12 @@ impl Module { Some(res) } - // Attempts to recover the Oldetp address from a message signature signed by using - // the Oldetp RPC's `personal_sign` and `oldetp_sign`. - fn oldetp_recover(s: &EcdsaSignature, what: &[u8]) -> Option { - let msg = keccak_256(&Self::oldetp_signable_message( + // Attempts to recover the Oldna address from a message signature signed by using + // the Oldna RPC's `personal_sign` and `oldna_sign`. + fn oldna_recover(s: &EcdsaSignature, what: &[u8]) -> Option { + let msg = keccak_256(&Self::oldna_signable_message( what, - b"\x19OLDETP Signed Message:\n", + b"\x19OLDNA Signed Message:\n", )); let mut res = AddressT::default(); res.copy_from_slice(&keccak_256(&secp256k1_ecdsa_recover(&s.0, &msg).ok()?[..])[12..]); @@ -449,8 +449,8 @@ impl sp_runtime::traits::ValidateUnsigned for Module { propagate: true, }) } - OtherSignature::Oldetp(signature) => { - let maybe_signer = Self::oldetp_recover(&signature, &data); + OtherSignature::Oldna(signature) => { + let maybe_signer = Self::oldna_recover(&signature, &data); let signer = if let Some(s) = maybe_signer { s } else { @@ -460,7 +460,7 @@ impl sp_runtime::traits::ValidateUnsigned for Module { .into(); }; - if !>::contains_key(&signer) { + if !>::contains_key(&signer) { return Err(InvalidTransaction::Custom( ValidityError::SignerHasNoClaim as _, ) @@ -493,13 +493,13 @@ enum ValidityError { #[derive(Clone, PartialEq, Encode, Decode, RuntimeDebug)] pub enum OtherSignature { Eth(EcdsaSignature), - Oldetp(EcdsaSignature), + Oldna(EcdsaSignature), } #[derive(Clone, PartialEq, Encode, Decode, RuntimeDebug)] pub enum OtherAddress { Eth(AddressT), - Oldetp(AddressT), + Oldna(AddressT), } #[derive(Clone, Encode, Decode)] @@ -559,12 +559,12 @@ mod secp_utils { EcdsaSignature(r) } - pub fn oldetp_sig( + pub fn oldna_sig( secret: &secp256k1::SecretKey, what: &[u8], signed_message: &[u8], ) -> EcdsaSignature { - let msg = keccak_256(&>::oldetp_signable_message( + let msg = keccak_256(&>::oldna_signable_message( &to_ascii_hex(what)[..], signed_message, )); @@ -593,7 +593,6 @@ mod tests { }; // --- hyperspace --- use crate::{self as hyperspace_claims, secp_utils::*, *}; - type Balance = u64; @@ -601,7 +600,7 @@ mod tests { type UncheckedExtrinsic = MockUncheckedExtrinsic; const ETHEREUM_SIGNED_MESSAGE: &'static [u8] = b"\x19Ethereum Signed Message:\n"; - const OLDETP_SIGNED_MESSAGE: &'static [u8] = b"\x19OLDETP Signed Message:\n"; + const OLDNA_SIGNED_MESSAGE: &'static [u8] = b"\x19OLDNA Signed Message:\n"; hyperspace_support::impl_test_account_data! {} @@ -703,8 +702,8 @@ mod tests { address: EthereumAddress(addr(&bob())), backed_etp: 200, }], - oldetp: vec![Account { - address: OldetpAddress(addr(&carol())), + oldna: vec![Account { + address: OldnaAddress(addr(&carol())), backed_etp: 300, }], }, @@ -724,13 +723,13 @@ mod tests { assert_eq!(Etp::usable_balance(&Claims::account_id()), 600); assert_eq!(Claims::claims_from_eth(&addr(&alice())), Some(100)); - assert_eq!(Claims::claims_from_oldetp(&addr(&alice())), None); + assert_eq!(Claims::claims_from_oldna(&addr(&alice())), None); assert_eq!(Claims::claims_from_eth(&addr(&bob())), Some(200)); - assert_eq!(Claims::claims_from_oldetp(&addr(&bob())), None); + assert_eq!(Claims::claims_from_oldna(&addr(&bob())), None); assert_eq!(Claims::claims_from_eth(&addr(&carol())), None); - assert_eq!(Claims::claims_from_oldetp(&addr(&carol())), Some(300)); + assert_eq!(Claims::claims_from_oldna(&addr(&carol())), Some(300)); }); } @@ -745,13 +744,13 @@ mod tests { let z: EthereumAddress = serde_json::from_str(&y).unwrap(); assert_eq!(x.0, z.0); - let x = OldetpAddress(array_bytes::hex2array_unchecked!( + let x = OldnaAddress(array_bytes::hex2array_unchecked!( "0x0123456789abcdef0123456789abcdef01234567", 20 )); let y = serde_json::to_string(&x).unwrap(); assert_eq!(y, "\"410123456789abcdef0123456789abcdef01234567\""); - let z: OldetpAddress = serde_json::from_str(&y).unwrap(); + let z: OldnaAddress = serde_json::from_str(&y).unwrap(); assert_eq!(x.0, z.0); } @@ -788,10 +787,10 @@ mod tests { assert_ok!(Claims::claim( Origin::none(), 3, - OtherSignature::Oldetp(oldetp_sig::( + OtherSignature::Oldna(oldna_sig::( &carol(), &3u64.encode(), - OLDETP_SIGNED_MESSAGE + OLDNA_SIGNED_MESSAGE )), )); assert_eq!(Etp::free_balance(&3), 300); @@ -815,7 +814,7 @@ mod tests { Claims::move_claim( Origin::signed(6), OtherAddress::Eth(addr(&alice())), - OtherAddress::Oldetp(addr(&carol())), + OtherAddress::Oldna(addr(&carol())), ), >::NewAddressTypeMis ); @@ -999,13 +998,13 @@ mod tests { } #[test] - fn real_oldetp_sig_works() { + fn real_oldna_sig_works() { new_test_ext().execute_with(|| { // "Pay RUSTs to the TEST account:0c0529c66a44e1861e5e1502b4a87009f23c792518a7a2091363f5a0e38abd57" let sig = array_bytes::hex2array_unchecked!("0x34c3d5afc7f8fa08f9d00a1ec4ac274c63ebce99460b556de85258c94f41ab2f52ad5188bd9fc51251cf5dcdd53751b1bd577828db3f2e8fe8ef77907d7f3f6a1b", 65); let sig = EcdsaSignature(sig); let who = array_bytes::hex2array_unchecked!("0x0c0529c66a44e1861e5e1502b4a87009f23c792518a7a2091363f5a0e38abd57", 32).using_encoded(to_ascii_hex); - let signer = Claims::oldetp_recover(&sig, &who).unwrap(); + let signer = Claims::oldna_recover(&sig, &who).unwrap(); assert_eq!(signer, array_bytes::hex2array_unchecked!("0x11974bce18a43243ede78beec2fd8e0ba4fe17ae", 20)); }); } diff --git a/frame/democracy/Cargo.toml b/frame/democracy/Cargo.toml index 4d59163..a36ce47 100644 --- a/frame/democracy/Cargo.toml +++ b/frame/democracy/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0" name = "hyperspace-democracy" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "1.4.0" +version = "2.0.0" [dependencies] # crates @@ -16,11 +16,11 @@ serde = { version = "1.0.124", optional = true, features = ["derive"] } # hyperspace hyperspace-support = { default-features = false, path = "../support" } # substrate -frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [dev-dependencies] # crates @@ -29,10 +29,10 @@ hex-literal = "0.3.1" hyperspace-balances = { path = "../balances" } hyperspace-support = { features = ["easy-testing"], path = "../support" } # substrate -pallet-scheduler = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-core = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-storage = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -substrate-test-utils = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +pallet-scheduler = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-core = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-storage = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +substrate-test-utils = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [features] default = ["std"] diff --git a/frame/dvm-dynamic-fee/Cargo.toml b/frame/dvm-dynamic-fee/Cargo.toml new file mode 100644 index 0000000..b0849c0 --- /dev/null +++ b/frame/dvm-dynamic-fee/Cargo.toml @@ -0,0 +1,35 @@ +[package] +authors = ["Hyperspace Network "] +description = "Dynamic fee handling for EVM." +edition = "2018" +homepage = "https://mvs.org/" +license = "GPL-3.0" +name = "dvm-dynamic-fee" +readme = "README.md" +repository = "https://github.com/mvs-org/Hyperspace" +version = "2.0.0" + + +[dependencies] +codec = { default-features = false, version = "1.3.7", package = "parity-scale-codec" } +serde = { default-features = false, version = "1.0.123", optional = true, features = ["derive"] } + +frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-inherents = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } + +[features] +default = ["std"] +std = [ + "codec/std", + "serde", + "frame-support/std", + "frame-system/std", + "sp-core/std", + "sp-inherents/std", + "sp-runtime/std", + "sp-std/std", +] \ No newline at end of file diff --git a/frame/dvm-dynamic-fee/src/lib.rs b/frame/dvm-dynamic-fee/src/lib.rs new file mode 100644 index 0000000..da7a27e --- /dev/null +++ b/frame/dvm-dynamic-fee/src/lib.rs @@ -0,0 +1,132 @@ +// SPDX-License-Identifier: Apache-2.0 +// This file is part of Frontier. +// +// Copyright (c) 2021 Parity Technologies (UK) Ltd. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Ensure we're `no_std` when compiling for Wasm. +#![cfg_attr(not(feature = "std"), no_std)] + +use codec::{Decode, Encode}; +use frame_support::{decl_event, decl_module, decl_storage, traits::Get}; +use frame_system::ensure_none; +use sp_core::U256; +#[cfg(feature = "std")] +use sp_inherents::ProvideInherentData; +use sp_inherents::{InherentData, InherentIdentifier, IsFatalError, ProvideInherent}; +use sp_runtime::RuntimeDebug; +use sp_std::{ + cmp::{max, min}, + result, +}; + +pub trait Config: frame_system::Config { + /// The overarching event type. + type Event: From + Into<::Event>; + /// Bound divisor for min gas price. + type MinGasPriceBoundDivisor: Get; +} + +decl_storage! { + trait Store for Module as DynamicFee { + MinGasPrice get(fn min_gas_price) config(): U256; + TargetMinGasPrice: Option; + } +} + +decl_event!( + pub enum Event { + TargetMinGasPriceSet(U256), + } +); + +decl_module! { + pub struct Module for enum Call where origin: T::Origin { + fn deposit_event() = default; + + fn on_finalize(_block_number: T::BlockNumber) { + if let Some(target) = TargetMinGasPrice::get() { + let bound = MinGasPrice::get() / T::MinGasPriceBoundDivisor::get() + U256::one(); + + let upper_limit = MinGasPrice::get().saturating_add(bound); + let lower_limit = MinGasPrice::get().saturating_sub(bound); + + MinGasPrice::set(min(upper_limit, max(lower_limit, target))); + } + + TargetMinGasPrice::kill(); + } + + #[weight = 0] + fn note_min_gas_price_target( + origin, + target: U256, + ) { + ensure_none(origin)?; + + TargetMinGasPrice::set(Some(target)); + Self::deposit_event(Event::TargetMinGasPriceSet(target)); + } + } +} + +#[derive(Encode, Decode, RuntimeDebug)] +pub enum InherentError {} + +impl IsFatalError for InherentError { + fn is_fatal_error(&self) -> bool { + match *self {} + } +} + +pub const INHERENT_IDENTIFIER: InherentIdentifier = *b"dynfee0_"; + +pub type InherentType = U256; + +#[cfg(feature = "std")] +pub struct InherentDataProvider(pub InherentType); + +#[cfg(feature = "std")] +impl ProvideInherentData for InherentDataProvider { + fn inherent_identifier(&self) -> &'static InherentIdentifier { + &INHERENT_IDENTIFIER + } + + fn provide_inherent_data( + &self, + inherent_data: &mut InherentData, + ) -> Result<(), sp_inherents::Error> { + inherent_data.put_data(INHERENT_IDENTIFIER, &self.0) + } + + fn error_to_string(&self, _: &[u8]) -> Option { + None + } +} + +impl ProvideInherent for Module { + type Call = Call; + type Error = InherentError; + const INHERENT_IDENTIFIER: InherentIdentifier = INHERENT_IDENTIFIER; + + fn create_inherent(data: &InherentData) -> Option { + let target = data.get_data::(&INHERENT_IDENTIFIER).ok()??; + + Some(Call::note_min_gas_price_target(target)) + } + + fn check_inherent(_call: &Self::Call, _data: &InherentData) -> result::Result<(), Self::Error> { + Ok(()) + } +} diff --git a/frame/dvm/Cargo.toml b/frame/dvm/Cargo.toml index f16377e..9c53422 100644 --- a/frame/dvm/Cargo.toml +++ b/frame/dvm/Cargo.toml @@ -7,34 +7,35 @@ license = "GPL-3.0" name = "dvm-ethereum" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "1.4.0" +version = "2.0.0" [dependencies] # crates +array-bytes = { version = "1.1.0" } codec = { package = "parity-scale-codec", version = "1.3.7", default-features = false } ethereum = { version = "0.6.0", default-features = false, features = ["with-codec"] } ethereum-types = { version = "0.10.0", default-features = false } -evm = { version = "0.22.0", default-features = false, features = ["with-codec"] } +evm = { version = "0.23.0", default-features = false, features = ["with-codec"] } libsecp256k1 = { version = "0.3", default-features = false } rlp = { version = "0.5.0", default-features = false } serde = { version = "1.0.124", optional = true, default-features = false } sha3 = { version = "0.8", default-features = false } -array-bytes = { version = "1.1.0" } # hyperspace hyperspace-balances = { default-features = false, path = "../balances" } hyperspace-evm = { default-features = false, path = "../evm" } -hyperspace-evm-primitives = { default-features = false, path = "../../primitives/evm" } hyperspace-support = { default-features = false, path = "../support" } -dvm-consensus-primitives = { default-features = false, path = "../../primitives/consensus" } +dp_consensus = { default-features = false, path = "../../primitives/consensus" } +dp-evm = { default-features = false, path = "../../primitives/evm" } +dp-storage = { default-features = false, path = "../../primitives/storage" } dvm-rpc-runtime-api = { default-features = false, path = "./rpc/runtime-api" } # substrate -frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -pallet-timestamp = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +pallet-timestamp = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [dev-dependencies] # crates @@ -62,9 +63,9 @@ crates-std = [ hyperspace-std = [ "hyperspace-balances/std", "hyperspace-evm/std", - "hyperspace-evm-primitives/std", "hyperspace-support/std", - "dvm-consensus-primitives/std", + "dp-evm/std", + "dp_consensus/std", "dvm-rpc-runtime-api/std", ] substrate-std = [ diff --git a/frame/dvm/rpc/Cargo.toml b/frame/dvm/rpc/Cargo.toml index e804283..6444671 100644 --- a/frame/dvm/rpc/Cargo.toml +++ b/frame/dvm/rpc/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0" name = "dvm-rpc-core" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "1.4.0" +version = "2.0.0" [dependencies] # crates @@ -19,14 +19,14 @@ jsonrpc-derive = { version = "15.1.0" } jsonrpc-pubsub = { version = "15.1.0" } # hyperspace -hyperspace-evm = { default-features = false, path = "../../evm" } -hyperspace-evm-primitives = { default-features = false, path = "../../../primitives/evm" } -dvm-rpc-core-primitives = { default-features = false, path = "../../../primitives/dvm-rpc-core" } +hyperspace-evm = { default-features = false, path = "../../evm" } +dp-evm = { default-features = false, path = "../../../primitives/evm" } +dp-rpc = { default-features = false, path = "../../../primitives/rpc" } # substrate -sp-api = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-api = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [features] default = ["std"] @@ -44,7 +44,7 @@ crates-std = [ ] hyperspace-std = [ "hyperspace-evm/std", - "hyperspace-evm-primitives/std", + "dp-evm/std", ] substrate-std = [ "sp-api/std", diff --git a/frame/dvm/rpc/runtime-api/Cargo.toml b/frame/dvm/rpc/runtime-api/Cargo.toml index 034caf0..b2a824d 100644 --- a/frame/dvm/rpc/runtime-api/Cargo.toml +++ b/frame/dvm/rpc/runtime-api/Cargo.toml @@ -7,23 +7,22 @@ license = "GPL-3.0" name = "dvm-rpc-runtime-api" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "1.4.0" +version = "2.0.0" [dependencies] # crates codec = { package = "parity-scale-codec", version = "1.3.7", default-features = false } ethereum = { version = "0.6.0", default-features = false, features = ["with-codec"] } ethereum-types = { version = "0.10.0", default-features = false } - # hyperspace -hyperspace-evm = { default-features = false, path = "../../../evm" } -hyperspace-evm-primitives = { default-features = false, path = "../../../../primitives/evm" } +hyperspace-evm = { default-features = false, path = "../../../evm" } +dp-evm = { default-features = false, path = "../../../../primitives/evm" } # substrate -sp-api = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-api = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [features] default = ["std"] @@ -36,7 +35,7 @@ std = [ hyperspace-std = [ "hyperspace-evm/std", - "hyperspace-evm-primitives/std", + "dp-evm/std", ] crates-std = [ diff --git a/frame/dvm/rpc/runtime-api/src/lib.rs b/frame/dvm/rpc/runtime-api/src/lib.rs index c08b723..8ba2df1 100644 --- a/frame/dvm/rpc/runtime-api/src/lib.rs +++ b/frame/dvm/rpc/runtime-api/src/lib.rs @@ -53,7 +53,7 @@ sp_api::decl_runtime_apis! { /// Returns runtime defined hyperspace_evm::ChainId. fn chain_id() -> u64; /// Returns hyperspace_evm::Accounts by address. - fn account_basic(address: H160) -> hyperspace_evm_primitives::Account; + fn account_basic(address: H160) -> dp_evm::Account; /// Returns FixedGasPrice::min_gas_price fn gas_price() -> U256; /// For a given account address, returns hyperspace_evm::AccountCodes. @@ -62,7 +62,7 @@ sp_api::decl_runtime_apis! { fn author() -> H160; /// For a given account address and index, returns hyperspace_evm::AccountStorages. fn storage_at(address: H160, index: U256) -> H256; - /// Returns a pallet_ethereum::call response. + /// Returns a dvm_ethereum::call response. fn call( from: H160, to: H160, @@ -72,7 +72,7 @@ sp_api::decl_runtime_apis! { gas_price: Option, nonce: Option, estimate: bool, - ) -> Result; + ) -> Result; /// Returns a frame_ethereum::create response. fn create( from: H160, @@ -82,7 +82,7 @@ sp_api::decl_runtime_apis! { gas_price: Option, nonce: Option, estimate: bool, - ) -> Result; + ) -> Result; /// Return the current block. fn current_block() -> Option; /// Return the current receipt. diff --git a/frame/dvm/rpc/src/eth.rs b/frame/dvm/rpc/src/eth.rs index 3e31f8b..d135be5 100644 --- a/frame/dvm/rpc/src/eth.rs +++ b/frame/dvm/rpc/src/eth.rs @@ -16,15 +16,17 @@ //! Eth rpc interface. -use ethereum_types::{H160, H256, H64, U256, U64}; -use jsonrpc_core::{BoxFuture, Result}; -use jsonrpc_derive::rpc; - -use dvm_rpc_core_primitives::{ +// --- hyperspace --- +use dp_rpc::{ BlockNumber, Bytes, CallRequest, Filter, FilterChanges, Index, Log, Receipt, RichBlock, SyncStatus, Transaction, TransactionRequest, Work, }; pub use rpc_impl_EthApi::gen_server::EthApi as EthApiServer; +pub use rpc_impl_EthFilterApi::gen_server::EthFilterApi as EthFilterApiServer; +// --- std --- +use ethereum_types::{H160, H256, H64, U256, U64}; +use jsonrpc_core::{BoxFuture, Result}; +use jsonrpc_derive::rpc; /// Eth rpc interface. #[rpc(server)] @@ -191,11 +193,11 @@ pub trait EthFilterApi { /// Returns filter changes since last poll. #[rpc(name = "eth_getFilterChanges")] - fn filter_changes(&self, _: Index) -> BoxFuture; + fn filter_changes(&self, _: Index) -> Result; /// Returns all logs matching given filter (in a range 'from' - 'to'). #[rpc(name = "eth_getFilterLogs")] - fn filter_logs(&self, _: Index) -> BoxFuture>; + fn filter_logs(&self, _: Index) -> Result>; /// Uninstalls filter. #[rpc(name = "eth_uninstallFilter")] diff --git a/frame/dvm/rpc/src/eth_pubsub.rs b/frame/dvm/rpc/src/eth_pubsub.rs index 4754220..de0f8a6 100644 --- a/frame/dvm/rpc/src/eth_pubsub.rs +++ b/frame/dvm/rpc/src/eth_pubsub.rs @@ -20,7 +20,7 @@ use jsonrpc_core::Result; use jsonrpc_derive::rpc; use jsonrpc_pubsub::{typed, SubscriptionId}; -use dvm_rpc_core_primitives::pubsub; +use dp_rpc::pubsub; pub use rpc_impl_EthPubSubApi::gen_server::EthPubSubApi as EthPubSubApiServer; diff --git a/frame/dvm/rpc/src/lib.rs b/frame/dvm/rpc/src/lib.rs index 26fa4cc..78bb772 100644 --- a/frame/dvm/rpc/src/lib.rs +++ b/frame/dvm/rpc/src/lib.rs @@ -3,7 +3,7 @@ mod eth_pubsub; mod net; mod web3; -pub use eth::{EthApi, EthApiServer, EthFilterApi}; +pub use eth::{EthApi, EthApiServer, EthFilterApi, EthFilterApiServer}; pub use eth_pubsub::{EthPubSubApi, EthPubSubApiServer}; pub use net::{NetApi, NetApiServer}; pub use web3::{Web3Api, Web3ApiServer}; diff --git a/frame/dvm/rpc/src/web3.rs b/frame/dvm/rpc/src/web3.rs index 9dff7b7..522aea4 100644 --- a/frame/dvm/rpc/src/web3.rs +++ b/frame/dvm/rpc/src/web3.rs @@ -19,7 +19,7 @@ use ethereum_types::H256; use jsonrpc_core::Result; use jsonrpc_derive::rpc; -use dvm_rpc_core_primitives::Bytes; +use dp_rpc::Bytes; pub use rpc_impl_Web3Api::gen_server::Web3Api as Web3ApiServer; diff --git a/frame/dvm/src/account_basic.rs b/frame/dvm/src/account_basic.rs index 0bd9b49..2caacf5 100644 --- a/frame/dvm/src/account_basic.rs +++ b/frame/dvm/src/account_basic.rs @@ -85,7 +85,7 @@ impl>::Balance::unique_saturated_from( diff_remaining_balance.low_u128(), ); - crate::Module::::dec_remain_balance(&account_id, value); + crate::Module::::dec_remaining_balance(&account_id, value); } } else if current.balance < new.balance { let diff = new.balance - current.balance; @@ -111,7 +111,7 @@ impl>::Balance::unique_saturated_from( diff_remaining_balance.low_u128(), ); - crate::Module::::inc_remain_balance(&account_id, value); + crate::Module::::inc_remaining_balance(&account_id, value); } } } diff --git a/frame/dvm/src/lib.rs b/frame/dvm/src/lib.rs index 85a4777..764cbb5 100644 --- a/frame/dvm/src/lib.rs +++ b/frame/dvm/src/lib.rs @@ -22,16 +22,20 @@ // Ensure we're `no_std` when compiling for Wasm. #![cfg_attr(not(feature = "std"), no_std)] -use codec::{Decode, Encode}; -use dvm_consensus_primitives::{ConsensusLog, FRONTIER_ENGINE_ID}; -use ethereum_types::{Bloom, BloomInput, H160, H256, H64, U256}; -use evm::ExitReason; +// --- hyperspace --- +use hyperspace_evm::{AccountBasicMapping, FeeCalculator, GasWeightMapping, Runner}; +use dp_consensus::{PostLog, PreLog, FRONTIER_ENGINE_ID}; +use dp_evm::CallOrCreateInfo; +use dp_storage::PALLET_ETHEREUM_SCHEMA; +pub use dvm_rpc_runtime_api::TransactionStatus; +// --- substrate --- +use frame_support::traits::Currency; use frame_support::{ decl_error, decl_event, decl_module, decl_storage, dispatch::DispatchResultWithPostInfo, traits::FindAuthor, traits::Get, weights::Weight, }; -use frame_system::ensure_none; -use sha3::{Digest, Keccak256}; +use frame_support::{ensure, traits::UnfilteredDispatchable}; +use frame_system::{ensure_none, RawOrigin}; use sp_runtime::{ generic::DigestItem, traits::{Saturating, UniqueSaturatedInto}, @@ -41,12 +45,12 @@ use sp_runtime::{ DispatchError, }; use sp_std::prelude::*; - -use hyperspace_evm::{AccountBasicMapping, AddressMapping, GasWeightMapping, Runner}; -use hyperspace_evm_primitives::CallOrCreateInfo; -pub use dvm_rpc_runtime_api::TransactionStatus; +// --- std --- +use codec::{Decode, Encode}; pub use ethereum::{Block, Log, Receipt, Transaction, TransactionAction, TransactionMessage}; -use frame_support::traits::Currency; +use ethereum_types::{Bloom, BloomInput, H160, H256, H64, U256}; +use evm::ExitReason; +use sha3::{Digest, Keccak256}; #[cfg(all(feature = "std", test))] mod tests; @@ -61,8 +65,20 @@ pub enum ReturnValue { Hash(H160), } +/// The schema version for Pallet Ethereum's storage +#[derive(Clone, Debug, Encode, Decode, PartialEq, Eq, PartialOrd, Ord)] +pub enum EthereumStorageSchema { + Undefined, + V1, +} + +impl Default for EthereumStorageSchema { + fn default() -> Self { + Self::Undefined + } +} + /// A type alias for the balance type from this pallet's point of view. -pub type BalanceOf = ::Balance; type EtpInstance = hyperspace_balances::Instance0; pub struct IntermediateStateRoot; @@ -89,8 +105,6 @@ pub trait Config: type StateRoot: Get; /// The block gas limit. Can be a simple constant, or an adjustment algorithm in another pallet. type BlockGasLimit: Get; - // How evm address convert to hyperspace address - type AddressMapping: AddressMapping; // Balance module type EtpCurrency: Currency; } @@ -111,7 +125,10 @@ decl_storage! { } add_extra_genesis { build(|_config: &GenesisConfig| { - >::store_block(); + >::store_block(false); + + // Initialize the storage schema at the well known key. + frame_support::storage::unhashed::put::(&PALLET_ETHEREUM_SCHEMA, &EthereumStorageSchema::V1); }); } } @@ -129,6 +146,8 @@ decl_error! { pub enum Error for Module { /// Signature is invalid. InvalidSignature, + /// Pre-log is present, therefore transact is not allowed. + PreLogExists, } } @@ -143,6 +162,11 @@ decl_module! { fn transact(origin, transaction: ethereum::Transaction) -> DispatchResultWithPostInfo { ensure_none(origin)?; + ensure!( + dp_consensus::find_pre_log(&frame_system::Module::::digest()).is_err(), + Error::::PreLogExists, + ); + let source = Self::recover_signer(&transaction) .ok_or_else(|| Error::::InvalidSignature)?; @@ -220,11 +244,20 @@ decl_module! { } fn on_finalize(_block_number: T::BlockNumber) { - >::store_block(); + >::store_block( + dp_consensus::find_pre_log(&frame_system::Module::::digest()).is_err(), + ); } fn on_initialize(_block_number: T::BlockNumber) -> Weight { Pending::kill(); + if let Ok(log) = dp_consensus::find_pre_log(&frame_system::Module::::digest()) { + let PreLog::Block(block) = log; + + for transaction in block.transactions { + let _ = Call::::transact(transaction).dispatch_bypass_filter(RawOrigin::None.into()); + } + } 0 } } @@ -264,7 +297,12 @@ impl frame_support::unsigned::ValidateUnsigned for Module { } let fee = transaction.gas_price.saturating_mul(transaction.gas_limit); - if account_data.balance < fee { + let total_payment = transaction.value.saturating_add(fee); + if account_data.balance < total_payment { + return InvalidTransaction::Payment.into(); + } + + if transaction.gas_price < T::FeeCalculator::min_gas_price() { return InvalidTransaction::Payment.into(); } @@ -299,7 +337,7 @@ impl Module { ))) } - fn store_block() { + fn store_block(post_log: bool) { let mut transactions = Vec::new(); let mut statuses = Vec::new(); let mut receipts = Vec::new(); @@ -340,26 +378,17 @@ impl Module { let mut block = ethereum::Block::new(partial_header, transactions.clone(), ommers); block.header.state_root = T::StateRoot::get(); - let mut transaction_hashes = Vec::new(); - - for t in &transactions { - let transaction_hash = H256::from_slice(Keccak256::digest(&rlp::encode(t)).as_slice()); - transaction_hashes.push(transaction_hash); - } - CurrentBlock::put(block.clone()); CurrentReceipts::put(receipts.clone()); CurrentTransactionStatuses::put(statuses.clone()); - let digest = DigestItem::::Consensus( - FRONTIER_ENGINE_ID, - ConsensusLog::EndBlock { - block_hash: block.header.hash(), - transaction_hashes, - } - .encode(), - ); - frame_system::Module::::deposit_log(digest.into()); + if post_log { + let digest = DigestItem::::Consensus( + FRONTIER_ENGINE_ID, + PostLog::Hashes(dp_consensus::Hashes::from_block(block)).encode(), + ); + frame_system::Module::::deposit_log(digest.into()); + } } /// Get the remaining balance for evm address @@ -373,14 +402,14 @@ impl Module { } /// Inc remaining balance - pub fn inc_remain_balance(account_id: &T::AccountId, value: T::Balance) { + pub fn inc_remaining_balance(account_id: &T::AccountId, value: T::Balance) { let remain_balance = Self::remaining_balance(account_id); let updated_balance = remain_balance.saturating_add(value); >::insert(account_id, updated_balance); } /// Dec remaining balance - pub fn dec_remain_balance(account_id: &T::AccountId, value: T::Balance) { + pub fn dec_remaining_balance(account_id: &T::AccountId, value: T::Balance) { let remain_balance = Self::remaining_balance(account_id); let updated_balance = remain_balance.saturating_sub(value); >::insert(account_id, updated_balance); diff --git a/frame/dvm/src/mock.rs b/frame/dvm/src/mock.rs index 7e8c766..59b9e86 100644 --- a/frame/dvm/src/mock.rs +++ b/frame/dvm/src/mock.rs @@ -138,7 +138,7 @@ impl FindAuthor for EthereumFindAuthor { parameter_types! { pub const TransactionByteFee: u64 = 1; - pub const ChainId: u64 = 22; + pub const ChainId: u64 = 42; pub const EVMModuleId: ModuleId = ModuleId(*b"py/evmpa"); } @@ -176,7 +176,6 @@ impl Config for Test { type FindAuthor = EthereumFindAuthor; type StateRoot = IntermediateStateRoot; type BlockGasLimit = BlockGasLimit; - type AddressMapping = HashedAddressMapping; type EtpCurrency = Etp; } diff --git a/frame/elections-phragmen/Cargo.toml b/frame/elections-phragmen/Cargo.toml index 236873a..9d084f8 100644 --- a/frame/elections-phragmen/Cargo.toml +++ b/frame/elections-phragmen/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0" name = "hyperspace-elections-phragmen" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "1.4.0" +version = "2.0.0" [dependencies] # crates @@ -16,11 +16,11 @@ serde = { version = "1.0.124", optional = true } # hyperspace hyperspace-support = { default-features = false, path = "../support" } # substrate -frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-npos-elections = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-npos-elections = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [dev-dependencies] # crates @@ -29,9 +29,9 @@ hex-literal = { version = "0.3.1" } hyperspace-balances = { path = "../balances" } hyperspace-support = { path = "../support", features = ["easy-testing"] } # substrate -sp-core = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-io = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -substrate-test-utils = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-core = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-io = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +substrate-test-utils = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [features] default = ["std"] diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index 9f152cf..fe2ce46 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -106,7 +106,7 @@ use hyperspace_support::balance::lock::*; pub mod weights; pub use weights::WeightInfo; -pub mod migrations_3_0_0; +pub mod migrations_2_0_0; /// The maximum votes allowed per voter. pub const MAXIMUM_VOTE: usize = 16; diff --git a/frame/elections-phragmen/src/migrations_2_0_0.rs b/frame/elections-phragmen/src/migrations_2_0_0.rs new file mode 100644 index 0000000..1101b82 --- /dev/null +++ b/frame/elections-phragmen/src/migrations_2_0_0.rs @@ -0,0 +1,191 @@ +// This file is part of Substrate. + +// Copyright (C) 2019-2020 Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! Migrations to version [`3.0.0`], as denoted by the changelog. + +use codec::{Decode, Encode, FullCodec}; +use frame_support::{ + storage::types::{StorageMap, StorageValue}, + traits::{GetPalletVersion, PalletVersion}, + weights::Weight, + RuntimeDebug, Twox64Concat, +}; +use sp_std::prelude::*; + +#[derive(Encode, Decode, Clone, Default, RuntimeDebug, PartialEq)] +struct SeatHolder { + who: AccountId, + stake: Balance, + deposit: Balance, +} + +#[derive(Encode, Decode, Clone, Default, RuntimeDebug, PartialEq)] +struct Voter { + votes: Vec, + stake: Balance, + deposit: Balance, +} + +/// Trait to implement to give information about types used for migration +pub trait ToV2 { + /// elections-phragmen module, used to check storage version. + type Module: GetPalletVersion; + + /// System config account id + type AccountId: 'static + FullCodec; + + /// Elections-phragmen currency balance. + type Balance: 'static + FullCodec + Copy; +} + +struct __Candidates; +impl frame_support::traits::StorageInstance for __Candidates { + fn pallet_prefix() -> &'static str { + "HyperspacePhragmenElection" + } + const STORAGE_PREFIX: &'static str = "Candidates"; +} + +#[allow(type_alias_bounds)] +type Candidates = StorageValue<__Candidates, Vec<(T::AccountId, T::Balance)>>; + +struct __Members; +impl frame_support::traits::StorageInstance for __Members { + fn pallet_prefix() -> &'static str { + "HyperspacePhragmenElection" + } + const STORAGE_PREFIX: &'static str = "Members"; +} +#[allow(type_alias_bounds)] +type Members = StorageValue<__Members, Vec>>; + +struct __RunnersUp; +impl frame_support::traits::StorageInstance for __RunnersUp { + fn pallet_prefix() -> &'static str { + "HyperspacePhragmenElection" + } + const STORAGE_PREFIX: &'static str = "RunnersUp"; +} +#[allow(type_alias_bounds)] +type RunnersUp = StorageValue<__RunnersUp, Vec>>; + +struct __Voting; +impl frame_support::traits::StorageInstance for __Voting { + fn pallet_prefix() -> &'static str { + "HyperspacePhragmenElection" + } + const STORAGE_PREFIX: &'static str = "Voting"; +} +#[allow(type_alias_bounds)] +type Voting = + StorageMap<__Voting, Twox64Concat, T::AccountId, Voter>; + +/// Apply all of the migrations 2_0_0. +/// +/// ### Warning +/// +/// This code will **ONLY** check that the storage version is less than 2_0_0 or `None`. +/// Further check might be needed at the user runtime. +/// +/// Be aware that this migration is intended to be used only for the mentioned versions. Use +/// with care and run at your own risk. +pub fn apply(old_voter_bond: T::Balance, old_candidacy_bond: T::Balance) -> Weight { + let maybe_storage_version = ::storage_version(); + + frame_support::debug::info!( + "Running migration for elections-phragmen with storage version {:?}", + maybe_storage_version + ); + + if let Some(storage_version) = maybe_storage_version { + if storage_version >= PalletVersion::new(2, 0, 0) { + frame_support::debug::info!("Skipped"); + + return 0; + } + } + + migrate_voters_to_recorded_deposit::(old_voter_bond); + migrate_candidates_to_recorded_deposit::(old_candidacy_bond); + migrate_runners_up_to_recorded_deposit::(old_candidacy_bond); + migrate_members_to_recorded_deposit::(old_candidacy_bond); + Weight::max_value() +} + +/// Migrate from the old legacy voting bond (fixed) to the new one (per-vote dynamic). +pub fn migrate_voters_to_recorded_deposit(old_deposit: T::Balance) { + >::translate::<(T::Balance, Vec), _>(|_who, (stake, votes)| { + Some(Voter { + votes, + stake, + deposit: old_deposit, + }) + }); + + frame_support::debug::info!("migrated {} voter accounts.", >::iter().count(),); +} + +/// Migrate all candidates to recorded deposit. +pub fn migrate_candidates_to_recorded_deposit(old_deposit: T::Balance) { + let _ = >::translate::, _>(|maybe_old_candidates| { + maybe_old_candidates.map(|old_candidates| { + frame_support::debug::info!("migrated {} candidate accounts.", old_candidates.len()); + old_candidates + .into_iter() + .map(|c| (c, old_deposit)) + .collect::>() + }) + }); +} + +/// Migrate all members to recorded deposit. +pub fn migrate_members_to_recorded_deposit(old_deposit: T::Balance) { + let _ = >::translate::, _>(|maybe_old_members| { + maybe_old_members.map(|old_members| { + frame_support::debug::info!("migrated {} member accounts.", old_members.len()); + old_members + .into_iter() + .map(|(who, stake)| SeatHolder { + who, + stake, + deposit: old_deposit, + }) + .collect::>() + }) + }); +} + +/// Migrate all runners-up to recorded deposit. +pub fn migrate_runners_up_to_recorded_deposit(old_deposit: T::Balance) { + let _ = + >::translate::, _>(|maybe_old_runners_up| { + maybe_old_runners_up.map(|old_runners_up| { + frame_support::debug::info!( + "migrated {} runner-up accounts.", + old_runners_up.len() + ); + old_runners_up + .into_iter() + .map(|(who, stake)| SeatHolder { + who, + stake, + deposit: old_deposit, + }) + .collect::>() + }) + }); +} diff --git a/frame/evm/Cargo.toml b/frame/evm/Cargo.toml index af0ab48..f3337c9 100644 --- a/frame/evm/Cargo.toml +++ b/frame/evm/Cargo.toml @@ -7,29 +7,29 @@ license = "GPL-3.0" name = "hyperspace-evm" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "1.4.0" +version = "2.0.0" [dependencies] # crates codec = { package = "parity-scale-codec", version = "1.3.7", default-features = false } -evm = { version = "0.22.0", default-features = false, features = ["with-codec"] } -evm-gasometer = { version = "0.22.0", default-features = false } -evm-runtime = { version = "0.22.0", default-features = false } +evm = { version = "0.23.0", default-features = false, features = ["with-codec"] } +evm-gasometer = { version = "0.23.0", default-features = false } +evm-runtime = { version = "0.23.0", default-features = false } primitive-types = { version = "0.8.0", default-features = false, features = ["rlp", "byteorder"] } rlp = { version = "0.5.0", default-features = false } serde = { version = "1.0.124", optional = true, default-features = false, features = ["derive"] } sha3 = { version = "0.8", default-features = false } # hyperspace -hyperspace-balances = { default-features = false, path = "../balances" } -hyperspace-evm-primitives = { default-features = false, path = "../../primitives/evm" } +hyperspace-balances = { default-features = false, path = "../balances" } +dp-evm = { default-features = false, path = "../../primitives/evm" } # substrate -frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -pallet-timestamp = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +pallet-timestamp = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [dev-dependencies] hyperspace-support = { features = ["easy-testing"], path = "../support" } @@ -49,7 +49,7 @@ crates-std = [ ] hyperspace-std = [ "hyperspace-balances/std", - "hyperspace-evm-primitives/std", + "dp-evm/std", ] substrate-std = [ "evm/std", diff --git a/frame/evm/precompile/Cargo.toml b/frame/evm/precompile/Cargo.toml index c194685..290d6f4 100644 --- a/frame/evm/precompile/Cargo.toml +++ b/frame/evm/precompile/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0" name = "hyperspace-evm-precompile" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "1.4.0" +version = "2.0.0" [dependencies] # hyperspace diff --git a/frame/evm/precompile/contracts/blake2/Cargo.toml b/frame/evm/precompile/contracts/blake2/Cargo.toml index d9b80ed..1cbebbf 100644 --- a/frame/evm/precompile/contracts/blake2/Cargo.toml +++ b/frame/evm/precompile/contracts/blake2/Cargo.toml @@ -7,16 +7,16 @@ license = "GPL-3.0" name = "hyperspace-evm-precompile-blake2" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "1.4.0" +version = "2.0.0" [dependencies] # crates -hyperspace-evm-primitives = { default-features = false, path = "../../../../../primitives/evm" } -evm = { version = "0.22.0", default-features = false, features = ["with-codec"] } +evm = { default-features = false, version = "0.23.0", features = ["with-codec"] } +dp-evm = { default-features = false, path = "../../../../../primitives/evm" } # substrate -sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [features] default = ["std"] @@ -28,7 +28,7 @@ std = [ crates-std = [ "evm/std", - "hyperspace-evm-primitives/std", + "dp-evm/std", ] substrate-std = [ diff --git a/frame/evm/precompile/contracts/blake2/src/lib.rs b/frame/evm/precompile/contracts/blake2/src/lib.rs index 6f88d32..d828d7d 100644 --- a/frame/evm/precompile/contracts/blake2/src/lib.rs +++ b/frame/evm/precompile/contracts/blake2/src/lib.rs @@ -23,7 +23,7 @@ mod eip_152; use alloc::vec::Vec; use core::mem::size_of; -use hyperspace_evm_primitives::LinearCostPrecompile; +use dp_evm::LinearCostPrecompile; use evm::{ExitError, ExitSucceed}; pub struct Blake2F; diff --git a/frame/evm/precompile/contracts/bn128/Cargo.toml b/frame/evm/precompile/contracts/bn128/Cargo.toml index 15e3b48..d1eb3a7 100644 --- a/frame/evm/precompile/contracts/bn128/Cargo.toml +++ b/frame/evm/precompile/contracts/bn128/Cargo.toml @@ -7,17 +7,17 @@ license = "GPL-3.0" name = "hyperspace-evm-precompile-bn128" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "1.4.0" +version = "2.0.0" [dependencies] # crates -bn = { package = "substrate-bn", version = "0.5", default-features = false } -hyperspace-evm-primitives = { default-features = false, path = "../../../../../primitives/evm" } -evm = { version = "0.22.0", default-features = false, features = ["with-codec"] } +bn = { default-features = false, package = "substrate-bn", version = "0.5" } +dp-evm = { default-features = false, path = "../../../../../primitives/evm" } +evm = { default-features = false, version = "0.23.0", features = ["with-codec"] } # substrate -sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [features] default = ["std"] @@ -28,7 +28,7 @@ std = [ ] crates-std = [ - "hyperspace-evm-primitives/std", + "dp-evm/std", "evm/std", ] diff --git a/frame/evm/precompile/contracts/bn128/src/lib.rs b/frame/evm/precompile/contracts/bn128/src/lib.rs index 267a4a3..d63e32a 100644 --- a/frame/evm/precompile/contracts/bn128/src/lib.rs +++ b/frame/evm/precompile/contracts/bn128/src/lib.rs @@ -20,7 +20,7 @@ extern crate alloc; use alloc::vec::Vec; -use hyperspace_evm_primitives::LinearCostPrecompile; +use dp_evm::LinearCostPrecompile; use evm::{ExitError, ExitSucceed}; use sp_core::U256; diff --git a/frame/evm/precompile/contracts/dispatch/Cargo.toml b/frame/evm/precompile/contracts/dispatch/Cargo.toml index e807bc4..dd54171 100644 --- a/frame/evm/precompile/contracts/dispatch/Cargo.toml +++ b/frame/evm/precompile/contracts/dispatch/Cargo.toml @@ -7,19 +7,19 @@ license = "GPL-3.0" name = "hyperspace-evm-precompile-dispatch" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "1.4.0" +version = "2.0.0" [dependencies] # crates -codec = { package = "parity-scale-codec", version = "1.3.7", default-features = false } -hyperspace-evm = { default-features = false, path = "../../../../evm" } -hyperspace-evm-primitives = { default-features = false, path = "../../../../../primitives/evm" } -evm = { version = "0.22.0", features = ["with-codec"], default-features = false } +codec = { default-features = false, package = "parity-scale-codec", version = "1.3.7" } +hyperspace-evm = { default-features = false, path = "../../../../evm" } +dp-evm = { default-features = false, path = "../../../../../primitives/evm" } +evm = { default-features = false, version = "0.23.0", features = ["with-codec"] } # substrate -frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [features] default = ["std"] @@ -32,7 +32,7 @@ std = [ crates-std = [ "codec/std", "hyperspace-evm/std", - "hyperspace-evm-primitives/std", + "dp-evm/std", "evm/std", ] diff --git a/frame/evm/precompile/contracts/dispatch/src/lib.rs b/frame/evm/precompile/contracts/dispatch/src/lib.rs index 654353f..7d686ed 100644 --- a/frame/evm/precompile/contracts/dispatch/src/lib.rs +++ b/frame/evm/precompile/contracts/dispatch/src/lib.rs @@ -23,7 +23,7 @@ use alloc::vec::Vec; use codec::Decode; use core::marker::PhantomData; use hyperspace_evm::{AddressMapping, GasWeightMapping}; -use hyperspace_evm_primitives::Precompile; +use dp_evm::Precompile; use evm::{Context, ExitError, ExitSucceed}; use frame_support::{ dispatch::{Dispatchable, GetDispatchInfo, PostDispatchInfo}, diff --git a/frame/evm/precompile/contracts/dna/Cargo.toml b/frame/evm/precompile/contracts/dna/Cargo.toml index 4bbf7c6..e05eb62 100644 --- a/frame/evm/precompile/contracts/dna/Cargo.toml +++ b/frame/evm/precompile/contracts/dna/Cargo.toml @@ -7,28 +7,29 @@ license = "GPL-3.0" name = "hyperspace-evm-precompile-dna" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "1.4.0" +version = "2.0.0" [dependencies] # crates -codec = { package = "parity-scale-codec", version = "1.3.7", default-features = false } -hyperspace-evm-primitives = { default-features = false, path = "../../../../../primitives/evm" } +array-bytes = { version = "1.1.0" } +codec = { default-features = false, package = "parity-scale-codec", version = "1.3.7" } ethabi = { default-features = false, git = "https://github.com/new-mvs/ethabi.git", branch = "with_no_std" } ethereum-types = { default-features = false, git = "https://github.com/new-mvs/parity-common.git" } -evm = { version = "0.22.0", default-features = false, features = ["with-codec"] } +evm = { version = "0.23.0", default-features = false, features = ["with-codec"] } +hex = { version = "0.4", default-features = false } ripemd160 = { version = "0.9", default-features = false } sha3 = { version = "0.8", default-features = false } -array-bytes = { version = "1.1.0" } # hyperspace hyperspace-evm = { default-features = false, path = "../../../" } +dp-evm = { default-features = false, path = "../../../../../primitives/evm" } # substrate -frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -pallet-timestamp = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +pallet-timestamp = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [features] default = ["std"] @@ -41,7 +42,7 @@ std = [ crates-std = [ "codec/std", - "hyperspace-evm-primitives/std", + "dp-evm/std", "ethabi/std", "ethereum-types/std", "evm/std", diff --git a/frame/evm/precompile/contracts/dna/src/lib.rs b/frame/evm/precompile/contracts/dna/src/lib.rs index 2f71e32..861e8df 100644 --- a/frame/evm/precompile/contracts/dna/src/lib.rs +++ b/frame/evm/precompile/contracts/dna/src/lib.rs @@ -37,7 +37,7 @@ use sp_std::prelude::*; use sp_std::vec::Vec; use hyperspace_evm::{AddressMapping, Config, Runner}; -use hyperspace_evm_primitives::Precompile; +use dp_evm::Precompile; type AccountId = ::AccountId; diff --git a/frame/evm/precompile/contracts/ed25519/Cargo.toml b/frame/evm/precompile/contracts/ed25519/Cargo.toml index bd134db..0992f44 100644 --- a/frame/evm/precompile/contracts/ed25519/Cargo.toml +++ b/frame/evm/precompile/contracts/ed25519/Cargo.toml @@ -7,16 +7,16 @@ license = "GPL-3.0" name = "hyperspace-evm-precompile-ed25519" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "1.4.0" +version = "2.0.0" [dependencies] # crates -hyperspace-evm-primitives = { default-features = false, path = "../../../../../primitives/evm" } -ed25519-dalek = { version = "1.0.0", default-features = false, features = ["alloc", "u64_backend"] } -evm = { version = "0.22.0", default-features = false, features = ["with-codec"] } +dp-evm = { default-features = false, path = "../../../../../primitives/evm" } +ed25519-dalek = { default-features = false, version = "1.0.0", features = ["alloc", "u64_backend"] } +evm = { default-features = false, version = "0.23.0", features = ["with-codec"] } # substrate -sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [features] default = ["std"] @@ -27,7 +27,7 @@ std = [ ] crates-std = [ - "hyperspace-evm-primitives/std", + "dp-evm/std", "ed25519-dalek/std", "evm/std", ] diff --git a/frame/evm/precompile/contracts/ed25519/src/lib.rs b/frame/evm/precompile/contracts/ed25519/src/lib.rs index 6d17df1..aae19e7 100644 --- a/frame/evm/precompile/contracts/ed25519/src/lib.rs +++ b/frame/evm/precompile/contracts/ed25519/src/lib.rs @@ -21,7 +21,7 @@ extern crate alloc; use alloc::vec::Vec; use core::convert::TryFrom; -use hyperspace_evm_primitives::LinearCostPrecompile; +use dp_evm::LinearCostPrecompile; use ed25519_dalek::{PublicKey, Signature, Verifier}; use evm::{ExitError, ExitSucceed}; diff --git a/frame/evm/precompile/contracts/empty/Cargo.toml b/frame/evm/precompile/contracts/empty/Cargo.toml index 809adaa..ddb2696 100644 --- a/frame/evm/precompile/contracts/empty/Cargo.toml +++ b/frame/evm/precompile/contracts/empty/Cargo.toml @@ -7,12 +7,12 @@ license = "GPL-3.0" name = "hyperspace-evm-precompile-empty" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "1.4.0" +version = "2.0.0" [dependencies] # crates -hyperspace-evm-primitives = { default-features = false, path = "../../../../../primitives/evm" } -evm = { version = "0.22.0", default-features = false, features = ["with-codec"] } +dp-evm = { default-features = false, path = "../../../../../primitives/evm" } +evm = { default-features = false, version = "0.23.0", features = ["with-codec"] } [features] default = ["std"] @@ -22,6 +22,6 @@ std = [ ] crates-std = [ - "hyperspace-evm-primitives/std", + "dp-evm/std", "evm/std", ] diff --git a/frame/evm/precompile/contracts/empty/src/lib.rs b/frame/evm/precompile/contracts/empty/src/lib.rs index 6f45126..c594fde 100644 --- a/frame/evm/precompile/contracts/empty/src/lib.rs +++ b/frame/evm/precompile/contracts/empty/src/lib.rs @@ -20,7 +20,7 @@ extern crate alloc; use alloc::vec::Vec; -use hyperspace_evm_primitives::LinearCostPrecompile; +use dp_evm::LinearCostPrecompile; use evm::{ExitError, ExitSucceed}; /// The empty precompile. diff --git a/frame/evm/precompile/contracts/modexp/Cargo.toml b/frame/evm/precompile/contracts/modexp/Cargo.toml index 9561b1e..d7be154 100644 --- a/frame/evm/precompile/contracts/modexp/Cargo.toml +++ b/frame/evm/precompile/contracts/modexp/Cargo.toml @@ -7,17 +7,17 @@ license = "GPL-3.0" name = "hyperspace-evm-precompile-modexp" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "1.4.0" +version = "2.0.0" [dependencies] # crates -hyperspace-evm-primitives = { default-features = false, path = "../../../../../primitives/evm" } -evm = { version = "0.22.0", default-features = false, features = ["with-codec"] } -num = { version = "0.3", default-features = false, features = ["alloc"] } +dp-evm = { default-features = false, path = "../../../../../primitives/evm" } +evm = { default-features = false, version = "0.23.0", features = ["with-codec"] } +num = { default-features = false, version = "0.3", features = ["alloc"] } # substrate -sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [dev-dependencies] hex = "0.4.0" @@ -31,7 +31,7 @@ std = [ ] crates-std = [ - "hyperspace-evm-primitives/std", + "dp-evm/std", "evm/std", "num/std", ] diff --git a/frame/evm/precompile/contracts/modexp/src/lib.rs b/frame/evm/precompile/contracts/modexp/src/lib.rs index d3e9da1..2f68ae4 100644 --- a/frame/evm/precompile/contracts/modexp/src/lib.rs +++ b/frame/evm/precompile/contracts/modexp/src/lib.rs @@ -20,7 +20,7 @@ extern crate alloc; use alloc::vec::Vec; -use hyperspace_evm_primitives::LinearCostPrecompile; +use dp_evm::LinearCostPrecompile; use evm::{ExitError, ExitSucceed}; use num::{BigUint, FromPrimitive, One, ToPrimitive, Zero}; diff --git a/frame/evm/precompile/contracts/simple/Cargo.toml b/frame/evm/precompile/contracts/simple/Cargo.toml index c59aa89..752e07e 100644 --- a/frame/evm/precompile/contracts/simple/Cargo.toml +++ b/frame/evm/precompile/contracts/simple/Cargo.toml @@ -7,16 +7,16 @@ license = "GPL-3.0" name = "hyperspace-evm-precompile-simple" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "1.4.0" +version = "2.0.0" [dependencies] # crates -hyperspace-evm-primitives = { default-features = false, path = "../../../../../primitives/evm" } -evm = { version = "0.22.0", default-features = false, features = ["with-codec"] } -ripemd160 = { version = "0.9", default-features = false } +dp-evm = { default-features = false, path = "../../../../../primitives/evm" } +evm = { default-features = false, version = "0.23.0", features = ["with-codec"] } +ripemd160 = { default-features = false, version = "0.9" } # substrate -sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [features] default = ["std"] @@ -27,7 +27,7 @@ std = [ ] crates-std = [ - "hyperspace-evm-primitives/std", + "dp-evm/std", "evm/std", "ripemd160/std", ] diff --git a/frame/evm/precompile/contracts/simple/src/lib.rs b/frame/evm/precompile/contracts/simple/src/lib.rs index 9b5dc99..02b94df 100644 --- a/frame/evm/precompile/contracts/simple/src/lib.rs +++ b/frame/evm/precompile/contracts/simple/src/lib.rs @@ -21,7 +21,7 @@ extern crate alloc; use alloc::vec::Vec; use core::cmp::min; -use hyperspace_evm_primitives::LinearCostPrecompile; +use dp_evm::LinearCostPrecompile; use evm::{ExitError, ExitSucceed}; /// The identity precompile. diff --git a/frame/evm/precompile/contracts/withdraw/Cargo.toml b/frame/evm/precompile/contracts/withdraw/Cargo.toml index 8f9f61a..1622e46 100644 --- a/frame/evm/precompile/contracts/withdraw/Cargo.toml +++ b/frame/evm/precompile/contracts/withdraw/Cargo.toml @@ -7,24 +7,24 @@ license = "GPL-3.0" name = "hyperspace-evm-precompile-withdraw" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "1.4.0" +version = "2.0.0" [dependencies] # crates -codec = { package = "parity-scale-codec", version = "1.3.7", default-features = false } -hyperspace-evm-primitives = { default-features = false, path = "../../../../../primitives/evm" } -evm = { version = "0.22.0", default-features = false, features = ["with-codec"] } -ripemd160 = { version = "0.9", default-features = false } +codec = { default-features = false, package = "parity-scale-codec", version = "1.3.7" } +evm = { default-features = false, version = "0.23.0", features = ["with-codec"] } +ripemd160 = { default-features = false, version = "0.9" } # hyperspace hyperspace-evm = { default-features = false, path = "../../../" } +dp-evm = { default-features = false, path = "../../../../../primitives/evm" } # substrate -frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -pallet-timestamp = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +pallet-timestamp = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [features] default = ["std"] @@ -37,13 +37,13 @@ std = [ crates-std = [ "codec/std", - "hyperspace-evm-primitives/std", "evm/std", "ripemd160/std", ] hyperspace-std = [ "hyperspace-evm/std", + "dp-evm/std", ] substrate-std = [ diff --git a/frame/evm/precompile/contracts/withdraw/src/lib.rs b/frame/evm/precompile/contracts/withdraw/src/lib.rs index 93f3ca0..e96ff5a 100644 --- a/frame/evm/precompile/contracts/withdraw/src/lib.rs +++ b/frame/evm/precompile/contracts/withdraw/src/lib.rs @@ -27,7 +27,7 @@ use sp_std::vec::Vec; use codec::Decode; use hyperspace_evm::{AddressMapping, Config}; -use hyperspace_evm_primitives::Precompile; +use dp_evm::Precompile; use evm::{Context, ExitError, ExitSucceed}; type AccountId = ::AccountId; diff --git a/frame/evm/src/lib.rs b/frame/evm/src/lib.rs index a83999e..fb81de0 100644 --- a/frame/evm/src/lib.rs +++ b/frame/evm/src/lib.rs @@ -24,28 +24,32 @@ pub mod runner; mod tests; pub use crate::runner::Runner; -pub use hyperspace_evm_primitives::{ +// --- hyperspace --- +pub use dp_evm::{ Account, CallInfo, CreateInfo, ExecutionInfo, LinearCostPrecompile, Log, Precompile, PrecompileSet, Vicinity, }; -pub use evm::{ExitError, ExitFatal, ExitReason, ExitRevert, ExitSucceed}; - -#[cfg(feature = "std")] -use codec::{Decode, Encode}; -use evm::Config as EvmConfig; -use frame_support::dispatch::DispatchResultWithPostInfo; -use frame_support::traits::{Currency, Get}; -use frame_support::weights::{Pays, PostDispatchInfo, Weight}; -use frame_support::{decl_error, decl_event, decl_module, decl_storage}; +// --- substrate --- +use frame_support::{ + decl_error, decl_event, decl_module, decl_storage, + dispatch::DispatchResultWithPostInfo, + traits::{Currency, Get}, + weights::{Pays, PostDispatchInfo, Weight}, +}; use frame_system::RawOrigin; -#[cfg(feature = "std")] -use serde::{Deserialize, Serialize}; use sp_core::{Hasher, H160, H256, U256}; use sp_runtime::{ traits::{BadOrigin, UniqueSaturatedInto}, AccountId32, }; use sp_std::vec::Vec; +// --- std --- +#[cfg(feature = "std")] +use codec::{Decode, Encode}; +use evm::Config as EvmConfig; +pub use evm::{ExitError, ExitFatal, ExitReason, ExitRevert, ExitSucceed}; +#[cfg(feature = "std")] +use serde::{Deserialize, Serialize}; /// Type alias for currency balance. pub type BalanceOf = @@ -303,9 +307,9 @@ pub struct GenesisAccount { } decl_storage! { - trait Store for Module as HyperspaceEVM { - AccountCodes get(fn account_codes): map hasher(blake2_128_concat) H160 => Vec; - AccountStorages get(fn account_storages): + trait Store for Module as EVM { + pub AccountCodes get(fn account_codes): map hasher(blake2_128_concat) H160 => Vec; + pub AccountStorages get(fn account_storages): double_map hasher(blake2_128_concat) H160, hasher(blake2_128_concat) H256 => H256; } @@ -509,10 +513,29 @@ decl_module! { impl Module { fn remove_account(address: &H160) { + if AccountCodes::contains_key(address) { + let account_id = T::AddressMapping::into_account_id(*address); + let _ = frame_system::Module::::dec_consumers(&account_id); + } + AccountCodes::remove(address); AccountStorages::remove_prefix(address); } + /// Create an account. + pub fn create_account(address: H160, code: Vec) { + if code.is_empty() { + return; + } + + if !AccountCodes::contains_key(&address) { + let account_id = T::AddressMapping::into_account_id(address); + let _ = frame_system::Module::::inc_consumers(&account_id); + } + + AccountCodes::insert(address, code); + } + /// Check whether an account is empty. pub fn is_account_empty(address: &H160) -> bool { let account = T::AccountBasicMapping::account_basic(address); diff --git a/frame/evm/src/runner/mod.rs b/frame/evm/src/runner/mod.rs index 8956cfb..b475b66 100644 --- a/frame/evm/src/runner/mod.rs +++ b/frame/evm/src/runner/mod.rs @@ -18,7 +18,7 @@ pub mod stack; use crate::Config; -use hyperspace_evm_primitives::{CallInfo, CreateInfo}; +use dp_evm::{CallInfo, CreateInfo}; use sp_core::{H160, H256, U256}; use sp_std::vec::Vec; diff --git a/frame/evm/src/runner/stack.rs b/frame/evm/src/runner/stack.rs index 07142dc..1924cdc 100644 --- a/frame/evm/src/runner/stack.rs +++ b/frame/evm/src/runner/stack.rs @@ -22,19 +22,23 @@ use crate::{ AccountBasicMapping, AccountCodes, AccountStorages, AddressMapping, Config, Error, Event, FeeCalculator, Module, PrecompileSet, }; -use hyperspace_evm_primitives::{Account, CallInfo, CreateInfo, ExecutionInfo, Log, Vicinity}; -use evm::backend::Backend as BackendT; -use evm::executor::{StackExecutor, StackState as StackStateT, StackSubstateMetadata}; -use evm::{ExitError, ExitReason, Transfer}; + +// --- hyperspace --- +use dp_evm::{Account, CallInfo, CreateInfo, ExecutionInfo, Log, Vicinity}; +// --- substrate --- use frame_support::{ debug, ensure, storage::{StorageDoubleMap, StorageMap}, traits::Get, }; -use sha3::{Digest, Keccak256}; use sp_core::{H160, H256, U256}; use sp_runtime::traits::UniqueSaturatedInto; use sp_std::{boxed::Box, collections::btree_set::BTreeSet, marker::PhantomData, mem, vec::Vec}; +// --- std --- +use evm::backend::Backend as BackendT; +use evm::executor::{StackExecutor, StackState as StackStateT, StackSubstateMetadata}; +use evm::{ExitError, ExitReason, Transfer}; +use sha3::{Digest, Keccak256}; #[derive(Default)] pub struct Runner { @@ -91,12 +95,11 @@ impl Runner { Error::::BalanceLow ); - Module::::withdraw_fee(&source, total_fee); - if let Some(nonce) = nonce { ensure!(source_account.nonce == nonce, Error::::InvalidNonce); } + Module::::withdraw_fee(&source, total_fee); let (reason, retv) = f(&mut executor); let used_gas = U256::from(executor.used_gas()); @@ -491,22 +494,16 @@ impl<'vicinity, 'config, T: Config> StackStateT<'config> code.len(), address ); - AccountCodes::insert(address, code); + Module::::create_account(address, code); } fn transfer(&mut self, transfer: Transfer) -> Result<(), ExitError> { - //EVM double transfer issue let source_account = T::AccountBasicMapping::account_basic(&transfer.source); - - //let target_account = T::AccountBasicMapping::account_basic(&transfer.target); - ensure!( source_account.balance >= transfer.value, ExitError::Other("Insufficient balance".into()) ); let new_source_balance = source_account.balance.saturating_sub(transfer.value); - //let new_target_balance = target_account.balance.saturating_add(transfer.value); - T::AccountBasicMapping::mutate_account_basic( &transfer.source, Account { @@ -514,10 +511,9 @@ impl<'vicinity, 'config, T: Config> StackStateT<'config> balance: new_source_balance, }, ); - + let target_account = T::AccountBasicMapping::account_basic(&transfer.target); let new_target_balance = target_account.balance.saturating_add(transfer.value); - T::AccountBasicMapping::mutate_account_basic( &transfer.target, Account { diff --git a/frame/header-mmr/Cargo.toml b/frame/header-mmr/Cargo.toml index 4afd870..890c4de 100644 --- a/frame/header-mmr/Cargo.toml +++ b/frame/header-mmr/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0" name = "hyperspace-header-mmr" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "1.4.0" +version = "2.0.0" [dependencies] # crates @@ -20,20 +20,18 @@ hyperspace-support = { default-features = false, path = "../s # github merkle-mountain-range = { package = "ckb-merkle-mountain-range", default-features = false, git = "https://github.com/new-mvs/merkle-mountain-range.git" } # substrate -frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [dev-dependencies] # crates array-bytes = { version = "1.1.0" } -serde_json = { version = "1.0.62" } - - +serde_json = { version = "1.0.62" } # substrate -sp-core = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-io = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-core = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-io = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [features] default = ["std"] diff --git a/frame/header-mmr/rpc/Cargo.toml b/frame/header-mmr/rpc/Cargo.toml index 43fed95..cdb98c0 100644 --- a/frame/header-mmr/rpc/Cargo.toml +++ b/frame/header-mmr/rpc/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0" name = "hyperspace-header-mmr-rpc" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "1.4.0" +version = "2.0.0" [dependencies] # crates @@ -18,6 +18,6 @@ jsonrpc-derive = { version = "15.1.0" } # hyperspace hyperspace-header-mmr-rpc-runtime-api = { path = "./runtime-api" } # substrate -sp-api = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-blockchain = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-runtime = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-api = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-blockchain = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-runtime = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } diff --git a/frame/header-mmr/rpc/runtime-api/Cargo.toml b/frame/header-mmr/rpc/runtime-api/Cargo.toml index 0664cd9..72505d8 100644 --- a/frame/header-mmr/rpc/runtime-api/Cargo.toml +++ b/frame/header-mmr/rpc/runtime-api/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0" name = "hyperspace-header-mmr-rpc-runtime-api" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "1.4.0" +version = "2.0.0" [dependencies] # crates @@ -16,9 +16,9 @@ serde = { version = "1.0.124", optional = true, features = ["derive"] } # hyperspace hyperspace-support = { default-features = false, path = "../../../support" } # substrate -sp-api = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-api = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [features] default = ["std"] diff --git a/frame/header-mmr/src/lib.rs b/frame/header-mmr/src/lib.rs index 0f1e72f..57263c8 100644 --- a/frame/header-mmr/src/lib.rs +++ b/frame/header-mmr/src/lib.rs @@ -37,16 +37,16 @@ //! //! ### Digest Item //! The is a ```MerkleMountainRangeRoot(Hash)``` digest item pre-subscribed in Digest. -//! This is implemented in Hyperspace's fork of substrate: https://github.com/new-mvs/substrate -//! The Pull request link is https://github.com/new-mvs/substrate/pull/1 +//! This is implemented in Hyperspace's fork of substrate: https://github.com/hyperspace-network/substrate +//! The Pull request link is https://github.com/hyperspace-network/substrate/pull/1 //! //! ## Implementation //! We are using the MMR library from https://github.com/nervosnetwork/merkle-mountain-range -//! Pull request: https://github.com/new-mvs/hyperspace/pull/358 +//! Pull request: https://github.com/hyperspace-network/hyperspace/pull/358 //! //! ## References //! Hyperspace Relay's Technical Paper: -//! https://github.com/new-mvs/rfcs/blob/master/paper/Hyperspace_Relay_Sublinear_Optimistic_Relay_for_Interoperable_Blockchains_v0.7.pdf +//! https://github.com/hyperspace-network/rfcs/blob/master/paper/Hyperspace_Relay_Sublinear_Optimistic_Relay_for_Interoperable_Blockchains_v0.7.pdf //! //! https://github.com/mimblewimble/grin/blob/master/doc/mmr.md#structure //! https://github.com/mimblewimble/grin/blob/0ff6763ee64e5a14e70ddd4642b99789a1648a32/core/src/core/pmmr.rs#L606 diff --git a/frame/header-mmr/src/tests.rs b/frame/header-mmr/src/tests.rs index afe5a50..43725fc 100644 --- a/frame/header-mmr/src/tests.rs +++ b/frame/header-mmr/src/tests.rs @@ -25,7 +25,6 @@ use frame_support::traits::OnFinalize; use sp_runtime::testing::{Digest, H256}; // --- hyperspace --- use crate::{mock::*, *}; - use merkle_mountain_range::{leaf_index_to_pos, Merge}; #[test] diff --git a/frame/staking/Cargo.toml b/frame/staking/Cargo.toml index cde7c03..faad038 100644 --- a/frame/staking/Cargo.toml +++ b/frame/staking/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0" name = "hyperspace-staking" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "1.4.0" +version = "2.0.0" [dependencies] # crates @@ -21,17 +21,17 @@ hyperspace-support = { default-features = false, path = "../supp # github substrate-fixed = { default-features = false, git = "https://github.com/encointer/substrate-fixed", branch = "master" } # substrate -frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -pallet-authorship = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -pallet-session = { default-features = false, features = ["historical"], git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-arithmetic = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-npos-elections = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-staking = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +pallet-authorship = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +pallet-session = { default-features = false, features = ["historical"], git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-arithmetic = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-npos-elections = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-staking = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [dev-dependencies] # crates @@ -40,10 +40,10 @@ rand_chacha = { version = "0.2" } hyperspace-balances = { path = "../../frame/balances" } hyperspace-support = { features = ["easy-testing"], path = "../support" } # substrate -pallet-timestamp = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-storage = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-tracing = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -substrate-test-utils = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +pallet-timestamp = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-storage = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-tracing = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +substrate-test-utils = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [features] default = ["std"] diff --git a/frame/staking/rpc/Cargo.toml b/frame/staking/rpc/Cargo.toml index efe1268..489e080 100644 --- a/frame/staking/rpc/Cargo.toml +++ b/frame/staking/rpc/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0" name = "hyperspace-staking-rpc" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "1.4.0" +version = "2.0.0" [dependencies] # crates @@ -18,6 +18,6 @@ jsonrpc-derive = { version = "15.1.0" } # hyperspace hyperspace-staking-rpc-runtime-api = { path = "./runtime-api" } # substrate -sp-api = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-blockchain = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-runtime = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-api = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-blockchain = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-runtime = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } diff --git a/frame/staking/rpc/runtime-api/Cargo.toml b/frame/staking/rpc/runtime-api/Cargo.toml index 5137a62..c963e60 100644 --- a/frame/staking/rpc/runtime-api/Cargo.toml +++ b/frame/staking/rpc/runtime-api/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0" name = "hyperspace-staking-rpc-runtime-api" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "1.4.0" +version = "2.0.0" [dependencies] # crates @@ -16,8 +16,8 @@ serde = { version = "1.0.124", optional = true, features = ["derive"] } # hyperspace hyperspace-support = { default-features = false, path = "../../../support" } # substrate -sp-api = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-api = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [features] default = ["std"] diff --git a/frame/staking/src/lib.rs b/frame/staking/src/lib.rs index 531e983..e9bc2b5 100644 --- a/frame/staking/src/lib.rs +++ b/frame/staking/src/lib.rs @@ -269,7 +269,7 @@ #![feature(drain_filter)] #![recursion_limit = "128"] -// TODO: offchain phragmen test https://github.com/new-mvs/darwinia-common/issues/97 +// TODO: offchain phragmen test https://github.com/mvs-org/Hyperspaceissues/97 // #[cfg(features = "testing-utils")] // pub mod testing_utils; #[cfg(test)] @@ -1040,7 +1040,7 @@ decl_module! { fn on_runtime_upgrade() -> frame_support::weights::Weight { if StorageVersion::get() == Releases::V4_0_0 || !StorageVersion::exists() { log!(info, "Migrating Staking..."); - + StorageVersion::put(Releases::V5_0_0); migrations::migrate_to_blockable::() } else { @@ -1527,8 +1527,8 @@ decl_module! { Self::update_ledger(&controller, &mut ledger); - // TODO: https://github.com/new-mvs/darwinia-common/issues/96 - // FIXME: https://github.com/new-mvs/darwinia-common/issues/121 + // TODO: https://github.com/mvs-org/Hyperspaceissues/96 + // FIXME: https://github.com/mvs-org/Hyperspaceissues/121 // let StakingLedger { // active_etp, // active_dna, @@ -3084,14 +3084,14 @@ impl Module { } /// Compute payout for era. - #[allow(unused_variables, unused_mut)] + #[allow(dead_code)] fn end_era(active_era: ActiveEraInfo, _session_index: SessionIndex) { - // Temporary Disable era reward payout // Note: active_era_start can be None if end era is called during genesis config. - //if let Some(active_era_start) = active_era.start { - //let now = T::UnixTime::now().as_millis().saturated_into::(); - //let living_time = Self::living_time(); - //let era_duration = now - active_era_start; + // Temporary Disable era reward + if let Some(active_era_start) = active_era.start { + let now = T::UnixTime::now().as_millis().saturated_into::(); + let living_time = Self::living_time(); + let era_duration = now - active_era_start; //let (validator_payout, max_payout) = inflation::compute_total_payout::( // era_duration, @@ -3107,13 +3107,12 @@ impl Module { // rest, //)); - //LivingTime::put(living_time + era_duration); + LivingTime::put(living_time + era_duration); // Set ending era reward. - //>::insert(&active_era.index, validator_payout); //T::EtpCurrency::deposit_creating(&Self::account_id(), validator_payout); //T::EtpRewardRemainder::on_unbalanced(T::EtpCurrency::issue(rest)); - //} + } } /// Plan a new era. Return the potential new staking set. diff --git a/frame/staking/src/substrate_tests.rs b/frame/staking/src/substrate_tests.rs index ff91bb2..258f10f 100644 --- a/frame/staking/src/substrate_tests.rs +++ b/frame/staking/src/substrate_tests.rs @@ -2125,7 +2125,7 @@ fn bond_with_no_staked_value() { Origin::signed(2), StakingBalance::EtpBalance(1) )); - // FIXME: https://github.com/new-mvs/darwinia-common/issues/121 + // FIXME: https://github.com/mvs-org/Hyperspaceissues/121 // assert!(Staking::ledger(2).is_none()); }); } diff --git a/frame/support/Cargo.toml b/frame/support/Cargo.toml index c9825e8..e5896d9 100644 --- a/frame/support/Cargo.toml +++ b/frame/support/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0" name = "hyperspace-support" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "1.4.0" +version = "2.0.0" [dependencies] # crates @@ -17,9 +17,9 @@ num-traits = { version = "0.2.14", default-features = false } # hyperspace ethereum-primitives = { default-features = false, path = "../../primitives/ethereum-primitives" } # substrate -frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [features] diff --git a/frame/treasury/Cargo.toml b/frame/treasury/Cargo.toml index a398080..456c21d 100644 --- a/frame/treasury/Cargo.toml +++ b/frame/treasury/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0" name = "hyperspace-treasury" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "1.4.0" +version = "2.0.0" [dependencies] # crates @@ -16,18 +16,18 @@ serde = { version = "1.0.124", optional = true, features = ["derive"] } # hyperspace hyperspace-support = { default-features = false, path = "../support" } # substrate -frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [dev-dependencies] # hyperspace hyperspace-balances = { path = "../balances" } # substrate -sp-core = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-io = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-storage = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-core = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-io = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-storage = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [features] default = ["std"] diff --git a/frame/vesting/Cargo.toml b/frame/vesting/Cargo.toml index 1b58dbb..f18969a 100644 --- a/frame/vesting/Cargo.toml +++ b/frame/vesting/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0" name = "hyperspace-vesting" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "1.4.0" +version = "2.0.0" [dependencies] # crates @@ -15,10 +15,10 @@ codec = { package = "parity-scale-codec", version = "1.3.7", default-featur enumflags2 = { version = "0.6.2" } serde = { version = "1.0.124", optional = true } # substrate -frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } # hyperspace hyperspace-support = { default-features = false, path = "../support" } @@ -26,9 +26,9 @@ hyperspace-support = { default-features = false, path = "../support" } # crates hex-literal = "0.3.1" # substrate -sp-core = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-io = { git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-storage = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-core = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-io = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-storage = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } # hyperspace hyperspace-balances = { path = "../balances" } diff --git a/primitives/consensus/Cargo.toml b/primitives/consensus/Cargo.toml index 082ac38..93d2431 100644 --- a/primitives/consensus/Cargo.toml +++ b/primitives/consensus/Cargo.toml @@ -4,28 +4,35 @@ description = "Primitives for DVM consensus" edition = "2018" homepage = "https://substrate.dev" license = "Apache-2.0" -name = "dvm-consensus-primitives" +name = "dp_consensus" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "1.4.0" +version = "2.0.0" [dependencies] # crates -codec = { package = "parity-scale-codec", version = "1.3.7", default-features = false, features = ["derive"] } +codec = { default-features = false, package = "parity-scale-codec", version = "1.3.7", features = ["derive"] } +ethereum = { default-features = false, version = "0.6.0", features = ["with-codec"] } +rlp = { default-features = false, version = "0.5" } +sha3 = { default-features = false, version = "0.8" } # substrate -sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [features] default = ["std"] std = [ "crates-std", + "ethereum/std", + "rlp/std", + "sha3/std", "substrate-std", ] crates-std = ["codec/std"] + substrate-std = [ "sp-std/std", "sp-runtime/std", diff --git a/primitives/consensus/src/lib.rs b/primitives/consensus/src/lib.rs index 6166185..bba6e19 100644 --- a/primitives/consensus/src/lib.rs +++ b/primitives/consensus/src/lib.rs @@ -18,19 +18,152 @@ #![cfg_attr(not(feature = "std"), no_std)] use codec::{Decode, Encode}; +use sha3::{Digest as Sha3Digest, Keccak256}; use sp_core::H256; -use sp_runtime::ConsensusEngineId; +use sp_runtime::{ + generic::{Digest, OpaqueDigestItemId}, + ConsensusEngineId, +}; use sp_std::vec::Vec; pub const FRONTIER_ENGINE_ID: ConsensusEngineId = [b'f', b'r', b'o', b'n']; +#[derive(Clone, PartialEq, Eq)] +pub enum Log { + Pre(PreLog), + Post(PostLog), +} + +impl Log { + pub fn into_hashes(self) -> Hashes { + match self { + Log::Post(PostLog::Hashes(post_hashes)) => post_hashes, + Log::Post(PostLog::Block(block)) => Hashes::from_block(block), + Log::Pre(PreLog::Block(block)) => Hashes::from_block(block), + } + } +} + #[derive(Decode, Encode, Clone, PartialEq, Eq)] -pub enum ConsensusLog { +pub enum PreLog { + #[codec(index = "3")] + Block(ethereum::Block), +} + +#[derive(Decode, Encode, Clone, PartialEq, Eq)] +pub enum PostLog { #[codec(index = "1")] - EndBlock { - /// Ethereum block hash. - block_hash: H256, - /// Transaction hashes of the Ethereum block. - transaction_hashes: Vec, - }, + Hashes(Hashes), + #[codec(index = "2")] + Block(ethereum::Block), +} + +#[derive(Decode, Encode, Clone, PartialEq, Eq)] +pub struct Hashes { + /// Ethereum block hash. + pub block_hash: H256, + /// Transaction hashes of the Ethereum block. + pub transaction_hashes: Vec, +} + +impl Hashes { + pub fn from_block(block: ethereum::Block) -> Self { + let mut transaction_hashes = Vec::new(); + + for t in &block.transactions { + let transaction_hash = H256::from_slice(Keccak256::digest(&rlp::encode(t)).as_slice()); + transaction_hashes.push(transaction_hash); + } + + let block_hash = block.header.hash(); + + Hashes { + transaction_hashes, + block_hash, + } + } +} + +#[derive(Clone, Debug)] +pub enum FindLogError { + NotFound, + MultipleLogs, +} + +pub fn find_pre_log(digest: &Digest) -> Result { + let mut found = None; + + for log in digest.logs() { + let log = log.try_to::(OpaqueDigestItemId::PreRuntime(&FRONTIER_ENGINE_ID)); + match (log, found.is_some()) { + (Some(_), true) => return Err(FindLogError::MultipleLogs), + (Some(log), false) => found = Some(log), + (None, _) => (), + } + } + + found.ok_or(FindLogError::NotFound) +} + +pub fn find_post_log(digest: &Digest) -> Result { + let mut found = None; + + for log in digest.logs() { + let log = log.try_to::(OpaqueDigestItemId::Consensus(&FRONTIER_ENGINE_ID)); + match (log, found.is_some()) { + (Some(_), true) => return Err(FindLogError::MultipleLogs), + (Some(log), false) => found = Some(log), + (None, _) => (), + } + } + + found.ok_or(FindLogError::NotFound) +} + +pub fn find_log(digest: &Digest) -> Result { + let mut found = None; + + for log in digest.logs() { + let pre_log = log.try_to::(OpaqueDigestItemId::PreRuntime(&FRONTIER_ENGINE_ID)); + match (pre_log, found.is_some()) { + (Some(_), true) => return Err(FindLogError::MultipleLogs), + (Some(pre_log), false) => found = Some(Log::Pre(pre_log)), + (None, _) => (), + } + + let post_log = log.try_to::(OpaqueDigestItemId::Consensus(&FRONTIER_ENGINE_ID)); + match (post_log, found.is_some()) { + (Some(_), true) => return Err(FindLogError::MultipleLogs), + (Some(post_log), false) => found = Some(Log::Post(post_log)), + (None, _) => (), + } + } + + found.ok_or(FindLogError::NotFound) +} + +pub fn ensure_log(digest: &Digest) -> Result<(), FindLogError> { + let mut found = false; + + for log in digest.logs() { + let pre_log = log.try_to::(OpaqueDigestItemId::PreRuntime(&FRONTIER_ENGINE_ID)); + match (pre_log, found) { + (Some(_), true) => return Err(FindLogError::MultipleLogs), + (Some(_), false) => found = true, + (None, _) => (), + } + + let post_log = log.try_to::(OpaqueDigestItemId::Consensus(&FRONTIER_ENGINE_ID)); + match (post_log, found) { + (Some(_), true) => return Err(FindLogError::MultipleLogs), + (Some(_), false) => found = true, + (None, _) => (), + } + } + + if found { + Ok(()) + } else { + Err(FindLogError::NotFound) + } } diff --git a/primitives/ethereum-primitives/Cargo.toml b/primitives/ethereum-primitives/Cargo.toml index 55fb2c3..7af225d 100644 --- a/primitives/ethereum-primitives/Cargo.toml +++ b/primitives/ethereum-primitives/Cargo.toml @@ -7,14 +7,14 @@ license = "GPL-3.0" name = "ethereum-primitives" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "1.4.0" +version = "2.0.0" [dependencies] # crates array-bytes = { version = "1.1.0" } -codec = { package = "parity-scale-codec", version = "1.3.7", default-features = false, features = ["derive"] } -ethash = { default-features = false, git = "https://github.com/new-mvs/rust-ethash" } -serde = { version = "1.0.124", optional = true, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "1.3.7", default-features = false, features = ["derive"] } +ethash = { default-features = false, git = "https://github.com/new-mvs/ethash", branch = "v1" } +serde = { version = "1.0.124", optional = true, features = ["derive"] } # hyperspace merkle-patricia-trie = { default-features = false, path = "../merkle-patricia-trie" } # github @@ -28,9 +28,9 @@ primitive-types = { default-features = false, features = ["codec", "rlp"], git = rlp = { default-features = false, git = "https://github.com/new-mvs/parity-common.git" } rlp-derive = { git = "https://github.com/new-mvs/parity-common.git" } # substrate -sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [dev-dependencies] # crates @@ -39,7 +39,7 @@ serde_json = { version = "1.0.62" } # github triehash = { git = "https://github.com/new-mvs/parity-common.git" } # substrate -frame-support = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +frame-support = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [features] default = ["std"] diff --git a/primitives/ethereum-primitives/src/ethashproof.rs b/primitives/ethereum-primitives/src/ethashproof.rs index 718ae1f..e1e9ccf 100644 --- a/primitives/ethereum-primitives/src/ethashproof.rs +++ b/primitives/ethereum-primitives/src/ethashproof.rs @@ -16,7 +16,6 @@ // You should have received a copy of the GNU General Public License // along with Hyperspace. If not, see . - use codec::{Decode, Encode}; pub use ethereum_types::{H128, H512}; use sp_io::hashing::sha2_256; diff --git a/primitives/ethereum-primitives/src/header.rs b/primitives/ethereum-primitives/src/header.rs index 5b874b7..6e41780 100644 --- a/primitives/ethereum-primitives/src/header.rs +++ b/primitives/ethereum-primitives/src/header.rs @@ -30,9 +30,6 @@ use sp_std::prelude::*; // --- hyperspace --- use crate::*; - - - #[derive(Clone, Copy, PartialEq, Eq, Encode, Decode, RuntimeDebug)] enum Seal { /// The seal/signature is included. @@ -96,8 +93,6 @@ impl EthereumHeader { pub fn from_str_unchecked(s: &str) -> Self { // --- std --- use std::str::FromStr; - - fn parse_value_unchecked(s: &str) -> &str { s.splitn(2, ':') @@ -152,7 +147,8 @@ impl EthereumHeader { let s = if s.starts_with("0x") { &s[2..] } else { s }; eth_header.log_bloom = Bloom::from_str(s).unwrap_or_default(); } else if s.starts_with("\"miner") { - eth_header.author = array_bytes::hex2array_unchecked!(parse_value_unchecked(s), 20).into(); + eth_header.author = + array_bytes::hex2array_unchecked!(parse_value_unchecked(s), 20).into(); } else if s.starts_with("\"mixHash") { mix_hash = array_bytes::hex2array_unchecked!(parse_value_unchecked(s), 32).into(); } else if s.starts_with("\"nonce") { @@ -555,7 +551,6 @@ mod tests { use std::str::FromStr; // --- hyperspace --- use super::*; - use error::EthereumError; use pow::EthashPartial; diff --git a/primitives/ethereum-primitives/src/receipt.rs b/primitives/ethereum-primitives/src/receipt.rs index 6ef5059..72b20bf 100644 --- a/primitives/ethereum-primitives/src/receipt.rs +++ b/primitives/ethereum-primitives/src/receipt.rs @@ -176,7 +176,6 @@ mod tests { use keccak_hasher::KeccakHasher; // --- hyperspace --- use super::*; - #[inline] fn construct_receipts( diff --git a/primitives/evm/Cargo.toml b/primitives/evm/Cargo.toml index 93537fd..c8131ba 100644 --- a/primitives/evm/Cargo.toml +++ b/primitives/evm/Cargo.toml @@ -4,20 +4,20 @@ description = "Primitives for Hyperspace EVM" edition = "2018" homepage = "https://substrate.dev" license = "Apache-2.0" -name = "hyperspace-evm-primitives" +name = "dp-evm" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "1.4.0" +version = "2.0.0" [dependencies] # crates codec = { package = "parity-scale-codec", version = "1.3.7", default-features = false } -evm = { version = "0.22.0", default-features = false, features = ["with-codec"] } +evm = { version = "0.23.0", default-features = false, features = ["with-codec"] } impl-trait-for-tuples = { version = "0.2.0" } serde = { version = "1.0.124", optional = true, features = ["derive"] } # substrate -sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [features] default = ["std"] diff --git a/primitives/merkle-patricia-trie/Cargo.toml b/primitives/merkle-patricia-trie/Cargo.toml index 892ab17..aaddd66 100644 --- a/primitives/merkle-patricia-trie/Cargo.toml +++ b/primitives/merkle-patricia-trie/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0" name = "merkle-patricia-trie" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "1.4.0" +version = "2.0.0" [[bench]] harness = false @@ -15,13 +15,13 @@ name = "trie" [dependencies] # crates -hashbrown = { version = "0.9.1" } -array-bytes = { version = "1.1.0" } +array-bytes = { version = "1.1.0" } +hashbrown = { version = "0.9.1" } # github hash = { package = "keccak-hash", default-features = false, git = "https://github.com/new-mvs/parity-common.git" } rlp = { default-features = false, git = "https://github.com/new-mvs/parity-common.git" } # substrate -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [dev-dependencies] # crates diff --git a/primitives/merkle-patricia-trie/src/tests.rs b/primitives/merkle-patricia-trie/src/tests.rs index 2bfd662..e53bd6e 100644 --- a/primitives/merkle-patricia-trie/src/tests.rs +++ b/primitives/merkle-patricia-trie/src/tests.rs @@ -685,9 +685,10 @@ mod trie_tests { fn test_ethereum_receipts_proof() { let rlp_proof: Vec = array_bytes::hex2bytes("f9016ef9016bb853f851a009b67a67265063da0dd6a7abad695edb2c439f6b458f2a2ee48a21442fef8a2680808080808080a0a7d4f8b974d21b7244014729b07e9c9f19fdc445da2ceddc089d90cead74be618080808080808080b90113f9011031b9010cf9010901835cdb6eb9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0").unwrap(); let expected: Vec = array_bytes::hex2bytes("f9010901835cdb6eb9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0").unwrap(); - let root = - array_bytes::hex2bytes("7fa081e3e33e53c4d09ae691af3853bb73a7e02c856104fe843172abab85df7b") - .unwrap(); + let root = array_bytes::hex2bytes( + "7fa081e3e33e53c4d09ae691af3853bb73a7e02c856104fe843172abab85df7b", + ) + .unwrap(); let proof: Proof = rlp::decode(&rlp_proof).unwrap(); let key = rlp::encode(&1usize); diff --git a/primitives/relay/Cargo.toml b/primitives/relay/Cargo.toml index 9224fad..8c161aa 100644 --- a/primitives/relay/Cargo.toml +++ b/primitives/relay/Cargo.toml @@ -7,15 +7,15 @@ license = "GPL-3.0" name = "hyperspace-relay-primitives" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "1.4.0" +version = "2.0.0" [dependencies] # crates codec = { package = "parity-scale-codec", version = "1.3.7", default-features = false } # substrate -frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } [features] default = ["std"] diff --git a/primitives/rpc/Cargo.toml b/primitives/rpc/Cargo.toml new file mode 100644 index 0000000..8bdfbcd --- /dev/null +++ b/primitives/rpc/Cargo.toml @@ -0,0 +1,21 @@ +[package] +authors = ["Hyperspace Network "] +description = "RPC traits of Ethereum." +edition = "2018" +homepage = "https://mvs.org/" +license = "GPL-3.0" +name = "dp-rpc" +readme = "README.md" +repository = "https://github.com/mvs-org/Hyperspace" +version = "2.0.0" + +[dependencies] +# crates +ethereum-types = { version = "0.10.0" } +jsonrpc-core = { version = "15.1.0" } +jsonrpc-core-client = { version = "15.1.0" } +jsonrpc-derive = { version = "15.1.0" } +jsonrpc-pubsub = { version = "15.1.0" } +rustc-hex = { version = "2.1.0" } +serde = { version = "1.0", features = ["derive"] } +serde_json = { version = "1.0" } diff --git a/primitives/rpc/src/account_info.rs b/primitives/rpc/src/account_info.rs new file mode 100644 index 0000000..52dbb08 --- /dev/null +++ b/primitives/rpc/src/account_info.rs @@ -0,0 +1,78 @@ +// Copyright 2015-2020 Parity Technologies (UK) Ltd. +// This file is part of Frontier. + +// Open Ethereum 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. + +// Open Ethereum 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 Open Ethereum. If not, see . + +//! Return types for RPC calls + +use crate::Bytes; +use ethereum_types::{Address, Public, H160, H256, U256}; +use serde::Serialize; + +/// Account information. +#[derive(Debug, Default, Clone, PartialEq, Serialize)] +pub struct AccountInfo { + /// Account name + pub name: String, +} + +/// Data structure with proof for one single storage-entry +#[derive(Debug, Default, Clone, PartialEq, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct StorageProof { + pub key: U256, + pub value: U256, + pub proof: Vec, +} + +/// Account information. +#[derive(Debug, Default, Clone, PartialEq, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct EthAccount { + pub address: H160, + pub balance: U256, + pub nonce: U256, + pub code_hash: H256, + pub storage_hash: H256, + pub account_proof: Vec, + pub storage_proof: Vec, +} + +/// Extended account information (used by `parity_allAccountInfo`). +#[derive(Debug, Default, Clone, PartialEq, Serialize)] +pub struct ExtAccountInfo { + /// Account name + pub name: String, + /// Account meta JSON + pub meta: String, + /// Account UUID (`None` for address book entries) + #[serde(skip_serializing_if = "Option::is_none")] + pub uuid: Option, +} + +/// account derived from a signature +/// as well as information that tells if it is valid for +/// the current chain +#[derive(Debug, Clone, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct RecoveredAccount { + /// address of the recovered account + pub address: Address, + /// public key of the recovered account + pub public_key: Public, + /// If the signature contains chain replay protection, + /// And the chain_id encoded within the signature + /// matches the current chain this would be true, otherwise false. + pub is_valid_for_current_chain: bool, +} diff --git a/primitives/rpc/src/block.rs b/primitives/rpc/src/block.rs new file mode 100644 index 0000000..f8445c2 --- /dev/null +++ b/primitives/rpc/src/block.rs @@ -0,0 +1,177 @@ +// Copyright 2015-2020 Parity Technologies (UK) Ltd. +// This file is part of Frontier. + +// Open Ethereum 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. + +// Open Ethereum 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 Open Ethereum. If not, see . + +use std::collections::BTreeMap; +use std::ops::Deref; + +use crate::{Bytes, Transaction}; +use ethereum_types::{Bloom as H2048, H160, H256, U256}; +use serde::ser::Error; +use serde::{Serialize, Serializer}; + +/// Block Transactions +#[derive(Debug)] +pub enum BlockTransactions { + /// Only hashes + Hashes(Vec), + /// Full transactions + Full(Vec), +} + +impl Serialize for BlockTransactions { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match *self { + BlockTransactions::Hashes(ref hashes) => hashes.serialize(serializer), + BlockTransactions::Full(ref ts) => ts.serialize(serializer), + } + } +} + +/// Block representation +#[derive(Debug, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct Block { + /// Hash of the block + pub hash: Option, + /// Hash of the parent + pub parent_hash: H256, + /// Hash of the uncles + #[serde(rename = "sha3Uncles")] + pub uncles_hash: H256, + /// Authors address + pub author: H160, + /// Alias of `author` + pub miner: H160, + /// State root hash + pub state_root: H256, + /// Transactions root hash + pub transactions_root: H256, + /// Transactions receipts root hash + pub receipts_root: H256, + /// Block number + pub number: Option, + /// Gas Used + pub gas_used: U256, + /// Gas Limit + pub gas_limit: U256, + /// Extra data + pub extra_data: Bytes, + /// Logs bloom + pub logs_bloom: Option, + /// Timestamp + pub timestamp: U256, + /// Difficulty + pub difficulty: U256, + /// Total difficulty + pub total_difficulty: U256, + /// Seal fields + pub seal_fields: Vec, + /// Uncles' hashes + pub uncles: Vec, + /// Transactions + pub transactions: BlockTransactions, + /// Size in bytes + pub size: Option, +} + +/// Block header representation. +#[derive(Debug, Clone, Serialize, PartialEq, Eq)] +#[serde(rename_all = "camelCase")] +pub struct Header { + /// Hash of the block + pub hash: Option, + /// Hash of the parent + pub parent_hash: H256, + /// Hash of the uncles + #[serde(rename = "sha3Uncles")] + pub uncles_hash: H256, + /// Authors address + pub author: H160, + /// Alias of `author` + pub miner: H160, + /// State root hash + pub state_root: H256, + /// Transactions root hash + pub transactions_root: H256, + /// Transactions receipts root hash + pub receipts_root: H256, + /// Block number + pub number: Option, + /// Gas Used + pub gas_used: U256, + /// Gas Limit + pub gas_limit: U256, + /// Extra data + pub extra_data: Bytes, + /// Logs bloom + pub logs_bloom: H2048, + /// Timestamp + pub timestamp: U256, + /// Difficulty + pub difficulty: U256, + /// Seal fields + pub seal_fields: Vec, + /// Size in bytes + pub size: Option, +} + +/// Block representation with additional info. +pub type RichBlock = Rich; + +/// Header representation with additional info. +pub type RichHeader = Rich

; + +/// Value representation with additional info +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct Rich { + /// Standard value. + pub inner: T, + /// Engine-specific fields with additional description. + /// Should be included directly to serialized block object. + // TODO [ToDr] #[serde(skip_serializing)] + pub extra_info: BTreeMap, +} + +impl Deref for Rich { + type Target = T; + fn deref(&self) -> &Self::Target { + &self.inner + } +} + +impl Serialize for Rich { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + use serde_json::{to_value, Value}; + + let serialized = (to_value(&self.inner), to_value(&self.extra_info)); + if let (Ok(Value::Object(mut value)), Ok(Value::Object(extras))) = serialized { + // join two objects + value.extend(extras); + // and serialize + value.serialize(serializer) + } else { + Err(S::Error::custom( + "Unserializable structures: expected objects", + )) + } + } +} diff --git a/primitives/rpc/src/block_number.rs b/primitives/rpc/src/block_number.rs new file mode 100644 index 0000000..e0379b9 --- /dev/null +++ b/primitives/rpc/src/block_number.rs @@ -0,0 +1,210 @@ +// Copyright 2015-2020 Parity Technologies (UK) Ltd. +// This file is part of Frontier. + +// Open Ethereum 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. + +// Open Ethereum 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 Open Ethereum. If not, see . + +use ethereum_types::H256; +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize, Serializer}; +use std::fmt; + +/// Represents rpc api block number param. +#[derive(Debug, PartialEq, Clone, Hash, Eq)] +pub enum BlockNumber { + /// Hash + Hash { + /// block hash + hash: H256, + /// only return blocks part of the canon chain + require_canonical: bool, + }, + /// Number + Num(u64), + /// Latest block + Latest, + /// Earliest block (genesis) + Earliest, + /// Pending block (being mined) + Pending, +} + +impl Default for BlockNumber { + fn default() -> Self { + BlockNumber::Latest + } +} + +impl<'a> Deserialize<'a> for BlockNumber { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'a>, + { + deserializer.deserialize_any(BlockNumberVisitor) + } +} + +impl BlockNumber { + /// Convert block number to min block target. + pub fn to_min_block_num(&self) -> Option { + match *self { + BlockNumber::Num(ref x) => Some(*x), + _ => None, + } + } +} + +impl Serialize for BlockNumber { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match *self { + BlockNumber::Hash { + hash, + require_canonical, + } => serializer.serialize_str(&format!( + "{{ 'hash': '{}', 'requireCanonical': '{}' }}", + hash, require_canonical + )), + BlockNumber::Num(ref x) => serializer.serialize_str(&format!("0x{:x}", x)), + BlockNumber::Latest => serializer.serialize_str("latest"), + BlockNumber::Earliest => serializer.serialize_str("earliest"), + BlockNumber::Pending => serializer.serialize_str("pending"), + } + } +} + +struct BlockNumberVisitor; + +impl<'a> Visitor<'a> for BlockNumberVisitor { + type Value = BlockNumber; + + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + write!( + formatter, + "a block number or 'latest', 'earliest' or 'pending'" + ) + } + + fn visit_map(self, mut visitor: V) -> Result + where + V: MapAccess<'a>, + { + let (mut require_canonical, mut block_number, mut block_hash) = + (false, None::, None::); + + loop { + let key_str: Option = visitor.next_key()?; + + match key_str { + Some(key) => match key.as_str() { + "blockNumber" => { + let value: String = visitor.next_value()?; + if value.starts_with("0x") { + let number = u64::from_str_radix(&value[2..], 16).map_err(|e| { + Error::custom(format!("Invalid block number: {}", e)) + })?; + + block_number = Some(number); + break; + } else { + return Err(Error::custom( + "Invalid block number: missing 0x prefix".to_string(), + )); + } + } + "blockHash" => { + block_hash = Some(visitor.next_value()?); + } + "requireCanonical" => { + require_canonical = visitor.next_value()?; + } + key => return Err(Error::custom(format!("Unknown key: {}", key))), + }, + None => break, + }; + } + + if let Some(number) = block_number { + return Ok(BlockNumber::Num(number)); + } + + if let Some(hash) = block_hash { + return Ok(BlockNumber::Hash { + hash, + require_canonical, + }); + } + + return Err(Error::custom("Invalid input")); + } + + fn visit_str(self, value: &str) -> Result + where + E: Error, + { + match value { + "latest" => Ok(BlockNumber::Latest), + "earliest" => Ok(BlockNumber::Earliest), + "pending" => Ok(BlockNumber::Pending), + _ if value.starts_with("0x") => u64::from_str_radix(&value[2..], 16) + .map(BlockNumber::Num) + .map_err(|e| Error::custom(format!("Invalid block number: {}", e))), + _ => u64::from_str_radix(&value, 10) + .map(BlockNumber::Num) + .map_err(|_| { + Error::custom( + "Invalid block number: non-decimal or missing 0x prefix".to_string(), + ) + }), + } + } + + fn visit_string(self, value: String) -> Result + where + E: Error, + { + self.visit_str(value.as_ref()) + } + + fn visit_u64(self, value: u64) -> Result + where + E: Error, + { + Ok(BlockNumber::Num(value)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + fn match_block_number(block_number: BlockNumber) -> Option { + match block_number { + BlockNumber::Num(number) => Some(number), + _ => None, + } + } + + #[test] + fn block_number_deserialize() { + let bn_dec: BlockNumber = serde_json::from_str(r#""42""#).unwrap(); + let bn_hex: BlockNumber = serde_json::from_str(r#""0x45""#).unwrap(); + let bn_u64: BlockNumber = serde_json::from_str(r#"420"#).unwrap(); + + assert_eq!(match_block_number(bn_dec).unwrap(), 42 as u64); + assert_eq!(match_block_number(bn_hex).unwrap(), 69 as u64); + assert_eq!(match_block_number(bn_u64).unwrap(), 420 as u64); + } +} diff --git a/primitives/rpc/src/bytes.rs b/primitives/rpc/src/bytes.rs new file mode 100644 index 0000000..0a1cd34 --- /dev/null +++ b/primitives/rpc/src/bytes.rs @@ -0,0 +1,134 @@ +// Copyright 2015-2020 Parity Technologies (UK) Ltd. +// This file is part of Frontier. + +// Open Ethereum 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. + +// Open Ethereum 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 Open Ethereum. If not, see . + +//! Serializable wrapper around vector of bytes + +use rustc_hex::{FromHex, ToHex}; +use serde::de::{Error, Visitor}; +use serde::{Deserialize, Deserializer, Serialize, Serializer}; +use std::fmt; + +/// Wrapper structure around vector of bytes. +#[derive(Debug, PartialEq, Eq, Default, Hash, Clone)] +pub struct Bytes(pub Vec); + +impl Bytes { + /// Simple constructor. + pub fn new(bytes: Vec) -> Bytes { + Bytes(bytes) + } + /// Convert back to vector + pub fn into_vec(self) -> Vec { + self.0 + } +} + +impl From> for Bytes { + fn from(bytes: Vec) -> Bytes { + Bytes(bytes) + } +} + +impl Into> for Bytes { + fn into(self) -> Vec { + self.0 + } +} + +impl Serialize for Bytes { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut serialized = "0x".to_owned(); + serialized.push_str(self.0.to_hex::().as_ref()); + serializer.serialize_str(serialized.as_ref()) + } +} + +impl<'a> Deserialize<'a> for Bytes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'a>, + { + deserializer.deserialize_any(BytesVisitor) + } +} + +struct BytesVisitor; + +impl<'a> Visitor<'a> for BytesVisitor { + type Value = Bytes; + + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + write!(formatter, "a 0x-prefixed, hex-encoded vector of bytes") + } + + fn visit_str(self, value: &str) -> Result + where + E: Error, + { + if value.len() >= 2 && value.starts_with("0x") && value.len() & 1 == 0 { + Ok(Bytes::new(FromHex::from_hex(&value[2..]).map_err(|e| { + Error::custom(format!("Invalid hex: {}", e)) + })?)) + } else { + Err(Error::custom( + "Invalid bytes format. Expected a 0x-prefixed hex string with even length", + )) + } + } + + fn visit_string(self, value: String) -> Result + where + E: Error, + { + self.visit_str(value.as_ref()) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use rustc_hex::FromHex; + + #[test] + fn test_bytes_serialize() { + let bytes = Bytes("0123456789abcdef".from_hex().unwrap()); + let serialized = serde_json::to_string(&bytes).unwrap(); + assert_eq!(serialized, r#""0x0123456789abcdef""#); + } + + #[test] + fn test_bytes_deserialize() { + let bytes0: Result = serde_json::from_str(r#""∀∂""#); + let bytes1: Result = serde_json::from_str(r#""""#); + let bytes2: Result = serde_json::from_str(r#""0x123""#); + let bytes3: Result = serde_json::from_str(r#""0xgg""#); + + let bytes4: Bytes = serde_json::from_str(r#""0x""#).unwrap(); + let bytes5: Bytes = serde_json::from_str(r#""0x12""#).unwrap(); + let bytes6: Bytes = serde_json::from_str(r#""0x0123""#).unwrap(); + + assert!(bytes0.is_err()); + assert!(bytes1.is_err()); + assert!(bytes2.is_err()); + assert!(bytes3.is_err()); + assert_eq!(bytes4, Bytes(vec![])); + assert_eq!(bytes5, Bytes(vec![0x12])); + assert_eq!(bytes6, Bytes(vec![0x1, 0x23])); + } +} diff --git a/primitives/rpc/src/call_request.rs b/primitives/rpc/src/call_request.rs new file mode 100644 index 0000000..3dcd26f --- /dev/null +++ b/primitives/rpc/src/call_request.rs @@ -0,0 +1,40 @@ +// Copyright 2015-2020 Parity Technologies (UK) Ltd. +// This file is part of Frontier. + +// Open Ethereum 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. + +// Open Ethereum 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 Open Ethereum. If not, see . + +use crate::Bytes; +use ethereum_types::{H160, U256}; +use serde::Deserialize; + +/// Call request +#[derive(Debug, Default, PartialEq, Deserialize, Clone)] +#[serde(deny_unknown_fields)] +#[serde(rename_all = "camelCase")] +pub struct CallRequest { + /// From + pub from: Option, + /// To + pub to: Option, + /// Gas Price + pub gas_price: Option, + /// Gas + pub gas: Option, + /// Value + pub value: Option, + /// Data + pub data: Option, + /// Nonce + pub nonce: Option, +} diff --git a/primitives/rpc/src/filter.rs b/primitives/rpc/src/filter.rs new file mode 100644 index 0000000..3814cdc --- /dev/null +++ b/primitives/rpc/src/filter.rs @@ -0,0 +1,348 @@ +// Copyright 2015-2020 Parity Technologies (UK) Ltd. +// This file is part of Frontier. + +// Open Ethereum 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. + +// Open Ethereum 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 Open Ethereum. If not, see . + +use ethereum_types::{H160, H256, U256}; +use serde::de::{DeserializeOwned, Error}; +use serde::{Deserialize, Deserializer, Serialize, Serializer}; +use serde_json::{from_value, Value}; +use std::{ + collections::BTreeMap, + sync::{Arc, Mutex}, +}; + +use crate::{BlockNumber, Log}; + +/// Variadic value +#[derive(Debug, PartialEq, Eq, Clone, Hash)] +pub enum VariadicValue +where + T: DeserializeOwned, +{ + /// Single + Single(T), + /// List + Multiple(Vec), + /// None + Null, +} + +impl<'a, T> Deserialize<'a> for VariadicValue +where + T: DeserializeOwned, +{ + fn deserialize(deserializer: D) -> Result, D::Error> + where + D: Deserializer<'a>, + { + let v: Value = Deserialize::deserialize(deserializer)?; + + if v.is_null() { + return Ok(VariadicValue::Null); + } + + from_value(v.clone()) + .map(VariadicValue::Single) + .or_else(|_| from_value(v).map(VariadicValue::Multiple)) + .map_err(|err| D::Error::custom(format!("Invalid variadic value type: {}", err))) + } +} + +/// Filter Address +pub type FilterAddress = VariadicValue; +/// Topic, supports `A` | `null` | `[A,B,C]` | `[A,[B,C]]` | [null,[B,C]] | [null,[null,C]] +pub type Topic = VariadicValue>>>; +/// FlatTopic, simplifies the matching logic. +pub type FlatTopic = VariadicValue>; + +/// Filter +#[derive(Debug, PartialEq, Clone, Deserialize, Eq, Hash)] +#[serde(deny_unknown_fields)] +#[serde(rename_all = "camelCase")] +pub struct Filter { + /// From Block + pub from_block: Option, + /// To Block + pub to_block: Option, + /// Block hash + pub block_hash: Option, + /// Address + pub address: Option, + /// Topics + pub topics: Option, +} + +/// Helper for Filter matching. +/// Supports conditional indexed parameters and wildcards. +#[derive(Debug)] +pub struct FilteredParams { + pub filter: Option, + flat_topics: Vec, +} + +impl Default for FilteredParams { + fn default() -> Self { + FilteredParams { + filter: None, + flat_topics: Vec::new(), + } + } +} + +impl FilteredParams { + pub fn new(f: Option) -> Self { + if let Some(f) = f { + return FilteredParams { + filter: Some(f.clone()), + flat_topics: { + if let Some(t) = f.clone().topics { + Self::flatten(&t) + } else { + Vec::new() + } + }, + }; + } + Self::default() + } + /// Cartesian product for VariadicValue conditional indexed parameters. + /// Executed once on struct instance. + /// i.e. `[A,[B,C]]` to `[[A,B],[A,C]]`. + fn flatten(topic: &Topic) -> Vec { + fn cartesian(lists: &Vec>>) -> Vec>> { + let mut res = vec![]; + let mut list_iter = lists.iter(); + if let Some(first_list) = list_iter.next() { + for &i in first_list { + res.push(vec![i]); + } + } + for l in list_iter { + let mut tmp = vec![]; + for r in res { + for &el in l { + let mut tmp_el = r.clone(); + tmp_el.push(el); + tmp.push(tmp_el); + } + } + res = tmp; + } + res + } + let mut out: Vec = Vec::new(); + match topic { + VariadicValue::Multiple(multi) => { + let mut foo: Vec>> = Vec::new(); + for v in multi { + foo.push({ + if let Some(v) = v { + match v { + VariadicValue::Single(s) => vec![s.clone()], + VariadicValue::Multiple(s) => s.clone(), + VariadicValue::Null => vec![None], + } + } else { + vec![None] + } + }); + } + for permut in cartesian(&foo) { + out.push(FlatTopic::Multiple(permut)); + } + } + VariadicValue::Single(single) => { + if let Some(single) = single { + out.push(single.clone()); + } + } + VariadicValue::Null => { + out.push(FlatTopic::Null); + } + } + out + } + + /// Replace None values - aka wildcards - for the log input value in that position. + pub fn replace(&self, log: &Log, topic: FlatTopic) -> Option> { + let mut out: Vec = Vec::new(); + match topic { + VariadicValue::Single(value) => { + if let Some(value) = value { + out.push(value); + } + } + VariadicValue::Multiple(value) => { + for (k, v) in value.into_iter().enumerate() { + if let Some(v) = v { + out.push(v); + } else { + out.push(log.topics[k].clone()); + } + } + } + _ => {} + }; + if out.len() == 0 { + return None; + } + Some(out) + } + + pub fn filter_block_range(&self, block_number: u64) -> bool { + let mut out = true; + let filter = self.filter.clone().unwrap(); + if let Some(from) = filter.from_block { + match from { + BlockNumber::Num(_) => { + if from.to_min_block_num().unwrap_or(0 as u64) > block_number { + out = false; + } + } + _ => {} + } + } + if let Some(to) = filter.to_block { + match to { + BlockNumber::Num(_) => { + if to.to_min_block_num().unwrap_or(0 as u64) < block_number { + out = false; + } + } + BlockNumber::Earliest => { + out = false; + } + _ => {} + } + } + out + } + + pub fn filter_block_hash(&self, block_hash: H256) -> bool { + if let Some(h) = self.filter.clone().unwrap().block_hash { + if h != block_hash { + return false; + } + } + true + } + + pub fn filter_address(&self, log: &Log) -> bool { + if let Some(input_address) = &self.filter.clone().unwrap().address { + match input_address { + VariadicValue::Single(x) => { + if log.address != *x { + return false; + } + } + VariadicValue::Multiple(x) => { + if !x.contains(&log.address) { + return false; + } + } + _ => { + return true; + } + } + } + true + } + + pub fn filter_topics(&self, log: &Log) -> bool { + let mut out: bool = true; + for topic in self.flat_topics.clone() { + match topic { + VariadicValue::Single(single) => { + if let Some(single) = single { + if !log.topics.starts_with(&vec![single]) { + out = false; + } + } + } + VariadicValue::Multiple(multi) => { + // Shrink the topics until the last item is Some. + let mut new_multi = multi; + while new_multi + .iter() + .last() + .unwrap_or(&Some(H256::default())) + .is_none() + { + new_multi.pop(); + } + // We can discard right away any logs with lesser topics than the filter. + if new_multi.len() > log.topics.len() { + out = false; + break; + } + let replaced: Option> = + self.replace(log, VariadicValue::Multiple(new_multi)); + if let Some(replaced) = replaced { + out = false; + if log.topics.starts_with(&replaced[..]) { + out = true; + break; + } + } + } + _ => { + out = true; + } + } + } + out + } +} + +/// Results of the filter_changes RPC. +#[derive(Debug, PartialEq)] +pub enum FilterChanges { + /// New logs. + Logs(Vec), + /// New hashes (block or transactions) + Hashes(Vec), + /// Empty result, + Empty, +} + +impl Serialize for FilterChanges { + fn serialize(&self, s: S) -> Result + where + S: Serializer, + { + match *self { + FilterChanges::Logs(ref logs) => logs.serialize(s), + FilterChanges::Hashes(ref hashes) => hashes.serialize(s), + FilterChanges::Empty => (&[] as &[Value]).serialize(s), + } + } +} + +#[derive(Debug, Clone)] +pub enum FilterType { + Block, + PendingTransaction, + Log(Filter), +} + +#[derive(Debug, Clone)] +pub struct FilterPoolItem { + pub last_poll: BlockNumber, + pub filter_type: FilterType, + pub at_block: u64, +} + +/// On-memory stored filters created through the `eth_newFilter` RPC. +pub type FilterPool = Arc>>; diff --git a/primitives/rpc/src/index.rs b/primitives/rpc/src/index.rs new file mode 100644 index 0000000..65dd67d --- /dev/null +++ b/primitives/rpc/src/index.rs @@ -0,0 +1,91 @@ +// Copyright 2015-2020 Parity Technologies (UK) Ltd. +// This file is part of Frontier. + +// Open Ethereum 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. + +// Open Ethereum 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 Open Ethereum. If not, see . + +use serde::de::{Error, Visitor}; +use serde::{Deserialize, Deserializer}; +use std::fmt; + +/// Represents usize. +#[derive(Debug, PartialEq)] +pub struct Index(usize); + +impl Index { + /// Convert to usize + pub fn value(&self) -> usize { + self.0 + } +} + +impl<'a> Deserialize<'a> for Index { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'a>, + { + deserializer.deserialize_any(IndexVisitor) + } +} + +struct IndexVisitor; + +impl<'a> Visitor<'a> for IndexVisitor { + type Value = Index; + + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + write!(formatter, "a hex-encoded or decimal index") + } + + fn visit_str(self, value: &str) -> Result + where + E: Error, + { + match value { + _ if value.starts_with("0x") => usize::from_str_radix(&value[2..], 16) + .map(Index) + .map_err(|e| Error::custom(format!("Invalid index: {}", e))), + _ => value + .parse::() + .map(Index) + .map_err(|e| Error::custom(format!("Invalid index: {}", e))), + } + } + + fn visit_string(self, value: String) -> Result + where + E: Error, + { + self.visit_str(value.as_ref()) + } + + fn visit_u64(self, value: u64) -> Result + where + E: Error, + { + Ok(Index(value as usize)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use serde_json; + + #[test] + fn index_deserialization() { + let s = r#"["0xa", "10", 42]"#; + let deserialized: Vec = serde_json::from_str(s).unwrap(); + assert_eq!(deserialized, vec![Index(10), Index(10), Index(42)]); + } +} diff --git a/primitives/rpc/src/lib.rs b/primitives/rpc/src/lib.rs new file mode 100644 index 0000000..ac7cca5 --- /dev/null +++ b/primitives/rpc/src/lib.rs @@ -0,0 +1,58 @@ +// Copyright 2015-2020 Parity Technologies (UK) Ltd. +// This file is part of Frontier. + +// Open Ethereum 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. + +// Open Ethereum 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 Open Ethereum. If not, see . + +//! RPC types + +mod account_info; +mod block; +mod block_number; +mod bytes; +mod call_request; +mod filter; +mod index; +mod log; +mod receipt; +mod sync; +mod transaction; +mod transaction_request; +mod work; + +pub mod pubsub; + +pub use self::account_info::{ + AccountInfo, EthAccount, ExtAccountInfo, RecoveredAccount, StorageProof, +}; +pub use self::block::{Block, BlockTransactions, Header, Rich, RichBlock, RichHeader}; +pub use self::block_number::BlockNumber; +pub use self::bytes::Bytes; +pub use self::call_request::CallRequest; +pub use self::filter::{ + Filter, FilterAddress, FilterChanges, FilterPool, FilterPoolItem, FilterType, FilteredParams, + Topic, VariadicValue, +}; +pub use self::index::Index; +pub use self::log::Log; +pub use self::receipt::Receipt; +pub use self::sync::{ + ChainStatus, EthProtocolInfo, PeerInfo, PeerNetworkInfo, PeerProtocolsInfo, Peers, + PipProtocolInfo, SyncInfo, SyncStatus, TransactionStats, +}; +pub use self::transaction::{ + LocalTransactionStatus, PendingTransaction, PendingTransactions, RichRawTransaction, + Transaction, +}; +pub use self::transaction_request::TransactionRequest; +pub use self::work::Work; diff --git a/primitives/rpc/src/log.rs b/primitives/rpc/src/log.rs new file mode 100644 index 0000000..76017fd --- /dev/null +++ b/primitives/rpc/src/log.rs @@ -0,0 +1,46 @@ +// Copyright 2015-2020 Parity Technologies (UK) Ltd. +// This file is part of Frontier. + +// Open Ethereum 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. + +// Open Ethereum 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 Open Ethereum. If not, see . + +use crate::Bytes; +use ethereum_types::{H160, H256, U256}; +use serde::Serialize; + +/// Log +#[derive(Debug, Serialize, PartialEq, Eq, Hash, Clone)] +#[serde(rename_all = "camelCase")] +pub struct Log { + /// H160 + pub address: H160, + /// Topics + pub topics: Vec, + /// Data + pub data: Bytes, + /// Block Hash + pub block_hash: Option, + /// Block Number + pub block_number: Option, + /// Transaction Hash + pub transaction_hash: Option, + /// Transaction Index + pub transaction_index: Option, + /// Log Index in Block + pub log_index: Option, + /// Log Index in Transaction + pub transaction_log_index: Option, + /// Whether Log Type is Removed (Geth Compatibility Field) + #[serde(default)] + pub removed: bool, +} diff --git a/primitives/rpc/src/pubsub.rs b/primitives/rpc/src/pubsub.rs new file mode 100644 index 0000000..edf2083 --- /dev/null +++ b/primitives/rpc/src/pubsub.rs @@ -0,0 +1,105 @@ +// Copyright 2015-2020 Parity Technologies (UK) Ltd. +// This file is part of Frontier. + +// Open Ethereum 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. + +// Open Ethereum 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 Open Ethereum. If not, see . + +//! Pub-Sub types. + +use crate::{Filter, Log, RichHeader}; +use ethereum_types::H256; +use serde::de::Error; +use serde::{Deserialize, Deserializer, Serialize, Serializer}; +use serde_json::{from_value, Value}; + +/// Subscription result. +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum Result { + /// New block header. + Header(Box), + /// Log + Log(Box), + /// Transaction hash + TransactionHash(H256), + /// SyncStatus + SyncState(PubSubSyncStatus), +} + +/// PubSbub sync status +#[derive(Debug, Serialize, Eq, PartialEq, Clone)] +#[serde(rename_all = "camelCase")] +pub struct PubSubSyncStatus { + /// is_major_syncing? + pub syncing: bool, +} + +impl Serialize for Result { + fn serialize(&self, serializer: S) -> ::std::result::Result + where + S: Serializer, + { + match *self { + Result::Header(ref header) => header.serialize(serializer), + Result::Log(ref log) => log.serialize(serializer), + Result::TransactionHash(ref hash) => hash.serialize(serializer), + Result::SyncState(ref sync) => sync.serialize(serializer), + } + } +} + +/// Subscription kind. +#[derive(Debug, Deserialize, PartialEq, Eq, Hash, Clone)] +#[serde(deny_unknown_fields)] +#[serde(rename_all = "camelCase")] +pub enum Kind { + /// New block headers subscription. + NewHeads, + /// Logs subscription. + Logs, + /// New Pending Transactions subscription. + NewPendingTransactions, + /// Node syncing status subscription. + Syncing, +} + +/// Subscription kind. +#[derive(Debug, PartialEq, Eq, Hash, Clone)] +pub enum Params { + /// No parameters passed. + None, + /// Log parameters. + Logs(Filter), +} + +impl Default for Params { + fn default() -> Self { + Params::None + } +} + +impl<'a> Deserialize<'a> for Params { + fn deserialize(deserializer: D) -> ::std::result::Result + where + D: Deserializer<'a>, + { + let v: Value = Deserialize::deserialize(deserializer)?; + + if v.is_null() { + return Ok(Params::None); + } + + from_value(v.clone()) + .map(Params::Logs) + .map_err(|e| D::Error::custom(format!("Invalid Pub-Sub parameters: {}", e))) + } +} diff --git a/primitives/rpc/src/receipt.rs b/primitives/rpc/src/receipt.rs new file mode 100644 index 0000000..f65f131 --- /dev/null +++ b/primitives/rpc/src/receipt.rs @@ -0,0 +1,55 @@ +// Copyright 2015-2020 Parity Technologies (UK) Ltd. +// This file is part of Frontier. + +// Open Ethereum 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. + +// Open Ethereum 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 Open Ethereum. If not, see . + +use crate::Log; +use ethereum_types::{Bloom as H2048, H160, H256, U256, U64}; +use serde::Serialize; + +/// Receipt +#[derive(Debug, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct Receipt { + /// Transaction Hash + pub transaction_hash: Option, + /// Transaction index + pub transaction_index: Option, + /// Block hash + pub block_hash: Option, + /// Sender + pub from: Option, + /// Recipient + pub to: Option, + /// Block number + pub block_number: Option, + /// Cumulative gas used + pub cumulative_gas_used: U256, + /// Gas used + pub gas_used: Option, + /// Contract address + pub contract_address: Option, + /// Logs + pub logs: Vec, + /// State Root + // NOTE(niklasad1): EIP98 makes this optional field, if it's missing then skip serializing it + #[serde(skip_serializing_if = "Option::is_none", rename = "root")] + pub state_root: Option, + /// Logs bloom + pub logs_bloom: H2048, + /// Status code + // NOTE(niklasad1): Unknown after EIP98 rules, if it's missing then skip serializing it + #[serde(skip_serializing_if = "Option::is_none", rename = "status")] + pub status_code: Option, +} diff --git a/primitives/rpc/src/sync.rs b/primitives/rpc/src/sync.rs new file mode 100644 index 0000000..a613ea4 --- /dev/null +++ b/primitives/rpc/src/sync.rs @@ -0,0 +1,144 @@ +// Copyright 2015-2020 Parity Technologies (UK) Ltd. +// This file is part of Frontier. + +// Open Ethereum 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. + +// Open Ethereum 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 Open Ethereum. If not, see . + +use std::collections::BTreeMap; + +use ethereum_types::{H512, U256}; +use serde::{Serialize, Serializer}; + +/// Sync info +#[derive(Default, Debug, Serialize, PartialEq)] +#[serde(rename_all = "camelCase")] +pub struct SyncInfo { + /// Starting block + pub starting_block: U256, + /// Current block + pub current_block: U256, + /// Highest block seen so far + pub highest_block: U256, + /// Warp sync snapshot chunks total. + pub warp_chunks_amount: Option, + /// Warp sync snpashot chunks processed. + pub warp_chunks_processed: Option, +} + +/// Peers info +#[derive(Default, Debug, Serialize)] +pub struct Peers { + /// Number of active peers + pub active: usize, + /// Number of connected peers + pub connected: usize, + /// Max number of peers + pub max: u32, + /// Detailed information on peers + pub peers: Vec, +} + +/// Peer connection information +#[derive(Default, Debug, Serialize)] +pub struct PeerInfo { + /// Public node id + pub id: Option, + /// Node client ID + pub name: String, + /// Capabilities + pub caps: Vec, + /// Network information + pub network: PeerNetworkInfo, + /// Protocols information + pub protocols: PeerProtocolsInfo, +} + +/// Peer network information +#[derive(Default, Debug, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct PeerNetworkInfo { + /// Remote endpoint address + pub remote_address: String, + /// Local endpoint address + pub local_address: String, +} + +/// Peer protocols information +#[derive(Default, Debug, Serialize)] +pub struct PeerProtocolsInfo { + /// Ethereum protocol information + pub eth: Option, + /// PIP protocol information. + pub pip: Option, +} + +/// Peer Ethereum protocol information +#[derive(Default, Debug, Serialize)] +pub struct EthProtocolInfo { + /// Negotiated ethereum protocol version + pub version: u32, + /// Peer total difficulty if known + pub difficulty: Option, + /// SHA3 of peer best block hash + pub head: String, +} + +/// Peer PIP protocol information +#[derive(Default, Debug, Serialize)] +pub struct PipProtocolInfo { + /// Negotiated PIP protocol version + pub version: u32, + /// Peer total difficulty + pub difficulty: U256, + /// SHA3 of peer best block hash + pub head: String, +} + +/// Sync status +#[derive(Debug, PartialEq)] +pub enum SyncStatus { + /// Info when syncing + Info(SyncInfo), + /// Not syncing + None, +} + +impl Serialize for SyncStatus { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match *self { + SyncStatus::Info(ref info) => info.serialize(serializer), + SyncStatus::None => false.serialize(serializer), + } + } +} + +/// Propagation statistics for pending transaction. +#[derive(Default, Debug, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct TransactionStats { + /// Block no this transaction was first seen. + pub first_seen: u64, + /// Peers this transaction was propagated to with count. + pub propagated_to: BTreeMap, +} + +/// Chain status. +#[derive(Default, Debug, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct ChainStatus { + /// Describes the gap in the blockchain, if there is one: (first, last) + pub block_gap: Option<(U256, U256)>, +} diff --git a/primitives/rpc/src/transaction.rs b/primitives/rpc/src/transaction.rs new file mode 100644 index 0000000..d5bdfeb --- /dev/null +++ b/primitives/rpc/src/transaction.rs @@ -0,0 +1,175 @@ +// Copyright 2015-2020 Parity Technologies (UK) Ltd. +// This file is part of Frontier. + +// Open Ethereum 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. + +// Open Ethereum 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 Open Ethereum. If not, see . + +use crate::Bytes; +use ethereum_types::{H160, H256, H512, U256, U64}; +use serde::ser::SerializeStruct; +use serde::{Serialize, Serializer}; +use std::{ + collections::HashMap, + sync::{Arc, Mutex}, +}; + +/// Transaction +#[derive(Debug, Default, Clone, PartialEq, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct Transaction { + /// Hash + pub hash: H256, + /// Nonce + pub nonce: U256, + /// Block hash + pub block_hash: Option, + /// Block number + pub block_number: Option, + /// Transaction Index + pub transaction_index: Option, + /// Sender + pub from: H160, + /// Recipient + pub to: Option, + /// Transfered value + pub value: U256, + /// Gas Price + pub gas_price: U256, + /// Gas + pub gas: U256, + /// Data + pub input: Bytes, + /// Creates contract + pub creates: Option, + /// Raw transaction data + pub raw: Bytes, + /// Public key of the signer. + pub public_key: Option, + /// The network id of the transaction, if any. + pub chain_id: Option, + /// The standardised V field of the signature (0 or 1). + pub standard_v: U256, + /// The standardised V field of the signature. + pub v: U256, + /// The R field of the signature. + pub r: U256, + /// The S field of the signature. + pub s: U256, +} + +/// Local Transaction Status +#[derive(Debug)] +pub enum LocalTransactionStatus { + /// Transaction is pending + Pending, + /// Transaction is in future part of the queue + Future, + /// Transaction was mined. + Mined(Transaction), + /// Transaction was removed from the queue, but not mined. + Culled(Transaction), + /// Transaction was dropped because of limit. + Dropped(Transaction), + /// Transaction was replaced by transaction with higher gas price. + Replaced(Transaction, U256, H256), + /// Transaction never got into the queue. + Rejected(Transaction, String), + /// Transaction is invalid. + Invalid(Transaction), + /// Transaction was canceled. + Canceled(Transaction), +} + +impl Serialize for LocalTransactionStatus { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + use self::LocalTransactionStatus::*; + + let elems = match *self { + Pending | Future => 1, + Mined(..) | Culled(..) | Dropped(..) | Invalid(..) | Canceled(..) => 2, + Rejected(..) => 3, + Replaced(..) => 4, + }; + + let status = "status"; + let transaction = "transaction"; + + let mut struc = serializer.serialize_struct("LocalTransactionStatus", elems)?; + match *self { + Pending => struc.serialize_field(status, "pending")?, + Future => struc.serialize_field(status, "future")?, + Mined(ref tx) => { + struc.serialize_field(status, "mined")?; + struc.serialize_field(transaction, tx)?; + } + Culled(ref tx) => { + struc.serialize_field(status, "culled")?; + struc.serialize_field(transaction, tx)?; + } + Dropped(ref tx) => { + struc.serialize_field(status, "dropped")?; + struc.serialize_field(transaction, tx)?; + } + Canceled(ref tx) => { + struc.serialize_field(status, "canceled")?; + struc.serialize_field(transaction, tx)?; + } + Invalid(ref tx) => { + struc.serialize_field(status, "invalid")?; + struc.serialize_field(transaction, tx)?; + } + Rejected(ref tx, ref reason) => { + struc.serialize_field(status, "rejected")?; + struc.serialize_field(transaction, tx)?; + struc.serialize_field("error", reason)?; + } + Replaced(ref tx, ref gas_price, ref hash) => { + struc.serialize_field(status, "replaced")?; + struc.serialize_field(transaction, tx)?; + struc.serialize_field("hash", hash)?; + struc.serialize_field("gasPrice", gas_price)?; + } + } + + struc.end() + } +} + +/// Geth-compatible output for eth_signTransaction method +#[derive(Debug, Default, Clone, PartialEq, Serialize)] +pub struct RichRawTransaction { + /// Raw transaction RLP + pub raw: Bytes, + /// Transaction details + #[serde(rename = "tx")] + pub transaction: Transaction, +} + +pub struct PendingTransaction { + pub transaction: Transaction, + pub at_block: u64, +} + +impl PendingTransaction { + pub fn new(transaction: Transaction, at_block: u64) -> Self { + Self { + transaction, + at_block, + } + } +} + +pub type PendingTransactions = Option>>>; diff --git a/primitives/rpc/src/transaction_request.rs b/primitives/rpc/src/transaction_request.rs new file mode 100644 index 0000000..dbb3767 --- /dev/null +++ b/primitives/rpc/src/transaction_request.rs @@ -0,0 +1,42 @@ +// Copyright 2015-2020 Parity Technologies (UK) Ltd. +// This file is part of Frontier. + +// Open Ethereum 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. + +// Open Ethereum 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 Open Ethereum. If not, see . + +//! `TransactionRequest` type + +use crate::Bytes; +use ethereum_types::{H160, U256}; +use serde::{Deserialize, Serialize}; + +/// Transaction request coming from RPC +#[derive(Debug, Clone, Default, Eq, PartialEq, Hash, Serialize, Deserialize)] +#[serde(deny_unknown_fields)] +#[serde(rename_all = "camelCase")] +pub struct TransactionRequest { + /// Sender + pub from: Option, + /// Recipient + pub to: Option, + /// Gas Price + pub gas_price: Option, + /// Gas + pub gas: Option, + /// Value of transaction in wei + pub value: Option, + /// Additional data sent with transaction + pub data: Option, + /// Transaction's nonce + pub nonce: Option, +} diff --git a/primitives/rpc/src/work.rs b/primitives/rpc/src/work.rs new file mode 100644 index 0000000..af98e16 --- /dev/null +++ b/primitives/rpc/src/work.rs @@ -0,0 +1,51 @@ +// Copyright 2015-2020 Parity Technologies (UK) Ltd. +// This file is part of Frontier. + +// Open Ethereum 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. + +// Open Ethereum 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 Open Ethereum. If not, see . + +use ethereum_types::{H256, U256}; + +use serde::{Serialize, Serializer}; + +/// The result of an `eth_getWork` call: it differs based on an option +/// whether to send the block number. +#[derive(Debug, PartialEq, Eq)] +pub struct Work { + /// The proof-of-work hash. + pub pow_hash: H256, + /// The seed hash. + pub seed_hash: H256, + /// The target. + pub target: H256, + /// The block number: this isn't always stored. + pub number: Option, +} + +impl Serialize for Work { + fn serialize(&self, s: S) -> Result + where + S: Serializer, + { + match self.number.as_ref() { + Some(num) => ( + &self.pow_hash, + &self.seed_hash, + &self.target, + U256::from(*num), + ) + .serialize(s), + None => (&self.pow_hash, &self.seed_hash, &self.target).serialize(s), + } + } +} diff --git a/primitives/storage/Cargo.toml b/primitives/storage/Cargo.toml new file mode 100644 index 0000000..d93f5d9 --- /dev/null +++ b/primitives/storage/Cargo.toml @@ -0,0 +1,16 @@ +[package] +authors = ["Hyperspace Network "] +description = "Storage key for ethereum schema" +edition = "2018" +homepage = "https://mvs.org/" +license = "GPL-3.0" +name = "dp-storage" +readme = "README.md" +repository = "https://github.com/mvs-org/Hyperspace" +version = "2.0.0" + +[dependencies] + +[features] +default = ["std"] +std = [] diff --git a/primitives/storage/src/lib.rs b/primitives/storage/src/lib.rs new file mode 100644 index 0000000..d2382d0 --- /dev/null +++ b/primitives/storage/src/lib.rs @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: Apache-2.0 +// This file is part of Frontier. +// +// Copyright (c) 2020 Parity Technologies (UK) Ltd. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#![cfg_attr(not(feature = "std"), no_std)] + +/// Current version of pallet Ethereum's storage schema is stored under this key. +pub const PALLET_ETHEREUM_SCHEMA: &'static [u8] = b":ethereum_schema"; From 18e633a7404afb74cd3a5d311b54dc753a734d75 Mon Sep 17 00:00:00 2001 From: inodelisia <63119441+inodelisia@users.noreply.github.com> Date: Mon, 14 Jun 2021 12:33:03 +0300 Subject: [PATCH 2/4] Revert "hyperspace-specversion-200" This reverts commit 913bacf217cb2dbe627d95a268883236facb5c51. --- Cargo.lock | 900 ++++++-------- Cargo.toml | 16 +- bin/node/cli/Cargo.toml | 99 +- bin/node/cli/src/chain_spec.rs | 22 +- bin/node/cli/src/command.rs | 4 +- bin/node/cli/src/rpc.rs | 39 +- bin/node/cli/src/service.rs | 123 +- bin/node/primitives/Cargo.toml | 8 +- bin/node/primitives/src/lib.rs | 2 +- bin/node/runtime/hyperspace/Cargo.toml | 99 +- .../hyperspace/src/authority_discovery.rs | 6 - bin/node/runtime/hyperspace/src/authorship.rs | 15 - bin/node/runtime/hyperspace/src/babe.rs | 25 - bin/node/runtime/hyperspace/src/balances.rs | 40 - bin/node/runtime/hyperspace/src/claims.rs | 17 - bin/node/runtime/hyperspace/src/collective.rs | 65 - bin/node/runtime/hyperspace/src/democracy.rs | 64 - bin/node/runtime/hyperspace/src/dvm.rs | 31 - .../hyperspace/src/elections_phragmen.rs | 38 - .../hyperspace/src/ethereum_backing.rs | 30 - .../runtime/hyperspace/src/ethereum_relay.rs | 29 - bin/node/runtime/hyperspace/src/evm.rs | 35 - bin/node/runtime/hyperspace/src/grandpa.rs | 20 - bin/node/runtime/hyperspace/src/header_mmr.rs | 5 - bin/node/runtime/hyperspace/src/identity.rs | 28 - bin/node/runtime/hyperspace/src/im_online.rs | 18 - bin/node/runtime/hyperspace/src/lib.rs | 1085 ++++++++++++++--- bin/node/runtime/hyperspace/src/membership.rs | 27 - bin/node/runtime/hyperspace/src/multisig.rs | 21 - bin/node/runtime/hyperspace/src/offences.rs | 18 - .../runtime/hyperspace/src/oldetp_backing.rs | 14 - .../runtime/hyperspace/src/oldetp_issuing.rs | 15 - .../runtime/hyperspace/src/oldna_backing.rs | 15 - bin/node/runtime/hyperspace/src/proxy.rs | 122 -- bin/node/runtime/hyperspace/src/recovery.rs | 20 - .../hyperspace/src/relay_authorities.rs | 38 - .../runtime/hyperspace/src/relayer_game.rs | 20 - bin/node/runtime/hyperspace/src/scheduler.rs | 23 - bin/node/runtime/hyperspace/src/session.rs | 31 - .../hyperspace/src/session_historical.rs | 13 - bin/node/runtime/hyperspace/src/society.rs | 32 - bin/node/runtime/hyperspace/src/staking.rs | 63 - bin/node/runtime/hyperspace/src/sudo.rs | 9 - bin/node/runtime/hyperspace/src/system.rs | 78 -- bin/node/runtime/hyperspace/src/timestamp.rs | 14 - .../hyperspace/src/transaction_payment.rs | 29 - bin/node/runtime/hyperspace/src/treasury.rs | 53 - bin/node/runtime/hyperspace/src/utility.rs | 10 - bin/node/runtime/hyperspace/src/vesting.rs | 16 - client/cli/Cargo.toml | 10 +- client/dvm/consensus/Cargo.toml | 29 +- client/dvm/consensus/src/lib.rs | 103 +- client/dvm/db/Cargo.toml | 21 - client/dvm/db/src/lib.rs | 227 ---- client/dvm/db/src/utils.rs | 40 - client/dvm/mapping-sync/Cargo.toml | 26 - client/dvm/mapping-sync/src/lib.rs | 162 --- client/dvm/mapping-sync/src/worker.rs | 129 -- client/dvm/rpc/Cargo.toml | 41 +- client/dvm/rpc/src/eth.rs | 942 ++++---------- client/dvm/rpc/src/eth_pubsub.rs | 220 ++-- client/dvm/rpc/src/lib.rs | 26 +- client/dvm/rpc/src/overrides/mod.rs | 136 --- .../rpc/src/overrides/schema_v1_override.rs | 133 -- frame/balances/Cargo.toml | 16 +- frame/balances/rpc/Cargo.toml | 8 +- frame/balances/rpc/runtime-api/Cargo.toml | 6 +- frame/balances/src/tests.rs | 10 +- frame/bridge/ethereum/backing/Cargo.toml | 26 +- frame/bridge/ethereum/backing/src/lib.rs | 11 +- frame/bridge/ethereum/backing/src/mock.rs | 1 + .../backing/src/test_with_linear_relay.rs | 3 +- .../ethereum/backing/src/test_with_relay.rs | 3 +- frame/bridge/ethereum/linear-relay/Cargo.toml | 14 +- .../bridge/ethereum/linear-relay/src/mock.rs | 19 +- frame/bridge/ethereum/relay/Cargo.toml | 24 +- frame/bridge/ethereum/relay/src/lib.rs | 1 + frame/bridge/oldetp/backing/Cargo.toml | 8 +- frame/bridge/oldetp/backing/src/lib.rs | 13 +- frame/bridge/oldetp/issuing/Cargo.toml | 22 +- frame/bridge/oldetp/issuing/src/lib.rs | 29 +- frame/bridge/oldetp/issuing/src/mock.rs | 54 +- frame/bridge/oldetp/issuing/src/tests.rs | 4 +- frame/bridge/oldetp/issuing/src/weights.rs | 2 - frame/bridge/oldna/backing/Cargo.toml | 8 +- frame/bridge/oldna/backing/src/lib.rs | 13 +- frame/bridge/relay-authorities/Cargo.toml | 14 +- frame/bridge/relay-authorities/src/test.rs | 4 +- frame/bridge/relayer-game/Cargo.toml | 14 +- frame/claims/Cargo.toml | 20 +- frame/claims/src/address.rs | 5 +- frame/claims/src/lib.rs | 87 +- frame/democracy/Cargo.toml | 20 +- frame/dvm-dynamic-fee/Cargo.toml | 35 - frame/dvm-dynamic-fee/src/lib.rs | 132 -- frame/dvm/Cargo.toml | 29 +- frame/dvm/rpc/Cargo.toml | 18 +- frame/dvm/rpc/runtime-api/Cargo.toml | 19 +- frame/dvm/rpc/runtime-api/src/lib.rs | 8 +- frame/dvm/rpc/src/eth.rs | 16 +- frame/dvm/rpc/src/eth_pubsub.rs | 2 +- frame/dvm/rpc/src/lib.rs | 2 +- frame/dvm/rpc/src/web3.rs | 2 +- frame/dvm/src/account_basic.rs | 4 +- frame/dvm/src/lib.rs | 101 +- frame/dvm/src/mock.rs | 3 +- frame/elections-phragmen/Cargo.toml | 18 +- frame/elections-phragmen/src/lib.rs | 2 +- .../src/migrations_2_0_0.rs | 191 --- frame/evm/Cargo.toml | 28 +- frame/evm/precompile/Cargo.toml | 2 +- .../precompile/contracts/blake2/Cargo.toml | 12 +- .../precompile/contracts/blake2/src/lib.rs | 2 +- .../evm/precompile/contracts/bn128/Cargo.toml | 14 +- .../evm/precompile/contracts/bn128/src/lib.rs | 2 +- .../precompile/contracts/dispatch/Cargo.toml | 18 +- .../precompile/contracts/dispatch/src/lib.rs | 2 +- frame/evm/precompile/contracts/dna/Cargo.toml | 27 +- frame/evm/precompile/contracts/dna/src/lib.rs | 2 +- .../precompile/contracts/ed25519/Cargo.toml | 14 +- .../precompile/contracts/ed25519/src/lib.rs | 2 +- .../evm/precompile/contracts/empty/Cargo.toml | 8 +- .../evm/precompile/contracts/empty/src/lib.rs | 2 +- .../precompile/contracts/modexp/Cargo.toml | 14 +- .../precompile/contracts/modexp/src/lib.rs | 2 +- .../precompile/contracts/simple/Cargo.toml | 14 +- .../precompile/contracts/simple/src/lib.rs | 2 +- .../precompile/contracts/withdraw/Cargo.toml | 26 +- .../precompile/contracts/withdraw/src/lib.rs | 2 +- frame/evm/src/lib.rs | 53 +- frame/evm/src/runner/mod.rs | 2 +- frame/evm/src/runner/stack.rs | 28 +- frame/header-mmr/Cargo.toml | 18 +- frame/header-mmr/rpc/Cargo.toml | 8 +- frame/header-mmr/rpc/runtime-api/Cargo.toml | 8 +- frame/header-mmr/src/lib.rs | 8 +- frame/header-mmr/src/tests.rs | 1 + frame/staking/Cargo.toml | 32 +- frame/staking/rpc/Cargo.toml | 8 +- frame/staking/rpc/runtime-api/Cargo.toml | 6 +- frame/staking/src/lib.rs | 25 +- frame/staking/src/substrate_tests.rs | 2 +- frame/support/Cargo.toml | 8 +- frame/treasury/Cargo.toml | 16 +- frame/vesting/Cargo.toml | 16 +- primitives/consensus/Cargo.toml | 19 +- primitives/consensus/src/lib.rs | 149 +-- primitives/ethereum-primitives/Cargo.toml | 16 +- .../ethereum-primitives/src/ethashproof.rs | 1 + primitives/ethereum-primitives/src/header.rs | 9 +- primitives/ethereum-primitives/src/receipt.rs | 1 + primitives/evm/Cargo.toml | 10 +- primitives/merkle-patricia-trie/Cargo.toml | 8 +- primitives/merkle-patricia-trie/src/tests.rs | 7 +- primitives/relay/Cargo.toml | 8 +- primitives/rpc/Cargo.toml | 21 - primitives/rpc/src/account_info.rs | 78 -- primitives/rpc/src/block.rs | 177 --- primitives/rpc/src/block_number.rs | 210 ---- primitives/rpc/src/bytes.rs | 134 -- primitives/rpc/src/call_request.rs | 40 - primitives/rpc/src/filter.rs | 348 ------ primitives/rpc/src/index.rs | 91 -- primitives/rpc/src/lib.rs | 58 - primitives/rpc/src/log.rs | 46 - primitives/rpc/src/pubsub.rs | 105 -- primitives/rpc/src/receipt.rs | 55 - primitives/rpc/src/sync.rs | 144 --- primitives/rpc/src/transaction.rs | 175 --- primitives/rpc/src/transaction_request.rs | 42 - primitives/rpc/src/work.rs | 51 - primitives/storage/Cargo.toml | 16 - primitives/storage/src/lib.rs | 21 - 173 files changed, 2494 insertions(+), 6810 deletions(-) delete mode 100644 bin/node/runtime/hyperspace/src/authority_discovery.rs delete mode 100644 bin/node/runtime/hyperspace/src/authorship.rs delete mode 100644 bin/node/runtime/hyperspace/src/babe.rs delete mode 100644 bin/node/runtime/hyperspace/src/balances.rs delete mode 100644 bin/node/runtime/hyperspace/src/claims.rs delete mode 100644 bin/node/runtime/hyperspace/src/collective.rs delete mode 100644 bin/node/runtime/hyperspace/src/democracy.rs delete mode 100644 bin/node/runtime/hyperspace/src/dvm.rs delete mode 100644 bin/node/runtime/hyperspace/src/elections_phragmen.rs delete mode 100644 bin/node/runtime/hyperspace/src/ethereum_backing.rs delete mode 100644 bin/node/runtime/hyperspace/src/ethereum_relay.rs delete mode 100644 bin/node/runtime/hyperspace/src/evm.rs delete mode 100644 bin/node/runtime/hyperspace/src/grandpa.rs delete mode 100644 bin/node/runtime/hyperspace/src/header_mmr.rs delete mode 100644 bin/node/runtime/hyperspace/src/identity.rs delete mode 100644 bin/node/runtime/hyperspace/src/im_online.rs delete mode 100644 bin/node/runtime/hyperspace/src/membership.rs delete mode 100644 bin/node/runtime/hyperspace/src/multisig.rs delete mode 100644 bin/node/runtime/hyperspace/src/offences.rs delete mode 100644 bin/node/runtime/hyperspace/src/oldetp_backing.rs delete mode 100644 bin/node/runtime/hyperspace/src/oldetp_issuing.rs delete mode 100644 bin/node/runtime/hyperspace/src/oldna_backing.rs delete mode 100644 bin/node/runtime/hyperspace/src/proxy.rs delete mode 100644 bin/node/runtime/hyperspace/src/recovery.rs delete mode 100644 bin/node/runtime/hyperspace/src/relay_authorities.rs delete mode 100644 bin/node/runtime/hyperspace/src/relayer_game.rs delete mode 100644 bin/node/runtime/hyperspace/src/scheduler.rs delete mode 100644 bin/node/runtime/hyperspace/src/session.rs delete mode 100644 bin/node/runtime/hyperspace/src/session_historical.rs delete mode 100644 bin/node/runtime/hyperspace/src/society.rs delete mode 100644 bin/node/runtime/hyperspace/src/staking.rs delete mode 100644 bin/node/runtime/hyperspace/src/sudo.rs delete mode 100644 bin/node/runtime/hyperspace/src/system.rs delete mode 100644 bin/node/runtime/hyperspace/src/timestamp.rs delete mode 100644 bin/node/runtime/hyperspace/src/transaction_payment.rs delete mode 100644 bin/node/runtime/hyperspace/src/treasury.rs delete mode 100644 bin/node/runtime/hyperspace/src/utility.rs delete mode 100644 bin/node/runtime/hyperspace/src/vesting.rs delete mode 100644 client/dvm/db/Cargo.toml delete mode 100644 client/dvm/db/src/lib.rs delete mode 100644 client/dvm/db/src/utils.rs delete mode 100644 client/dvm/mapping-sync/Cargo.toml delete mode 100644 client/dvm/mapping-sync/src/lib.rs delete mode 100644 client/dvm/mapping-sync/src/worker.rs delete mode 100644 client/dvm/rpc/src/overrides/mod.rs delete mode 100644 client/dvm/rpc/src/overrides/schema_v1_override.rs delete mode 100644 frame/bridge/oldetp/issuing/src/weights.rs delete mode 100644 frame/dvm-dynamic-fee/Cargo.toml delete mode 100644 frame/dvm-dynamic-fee/src/lib.rs delete mode 100644 frame/elections-phragmen/src/migrations_2_0_0.rs delete mode 100644 primitives/rpc/Cargo.toml delete mode 100644 primitives/rpc/src/account_info.rs delete mode 100644 primitives/rpc/src/block.rs delete mode 100644 primitives/rpc/src/block_number.rs delete mode 100644 primitives/rpc/src/bytes.rs delete mode 100644 primitives/rpc/src/call_request.rs delete mode 100644 primitives/rpc/src/filter.rs delete mode 100644 primitives/rpc/src/index.rs delete mode 100644 primitives/rpc/src/lib.rs delete mode 100644 primitives/rpc/src/log.rs delete mode 100644 primitives/rpc/src/pubsub.rs delete mode 100644 primitives/rpc/src/receipt.rs delete mode 100644 primitives/rpc/src/sync.rs delete mode 100644 primitives/rpc/src/transaction.rs delete mode 100644 primitives/rpc/src/transaction_request.rs delete mode 100644 primitives/rpc/src/work.rs delete mode 100644 primitives/storage/Cargo.toml delete mode 100644 primitives/storage/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 254d021..4f8edb4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -306,9 +306,9 @@ checksum = "e91831deabf0d6d7ec49552e489aed63b7456a7a3c46cff62adad428110b0af0" [[package]] name = "async-trait" -version = "0.1.48" +version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36ea56748e10732c49404c153638a15ec3d6211ec5ff35d9bb20e13b93576adf" +checksum = "d3340571769500ddef1e94b45055fabed6b08a881269b7570c830b8f32ef84ef" dependencies = [ "proc-macro2", "quote", @@ -600,9 +600,9 @@ checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" [[package]] name = "byteorder" -version = "1.4.3" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +checksum = "ae44d1a3d5a19df61dd0c8beb138458ac2a53a7ac09eba97d55592540004306b" [[package]] name = "bytes" @@ -1083,9 +1083,9 @@ dependencies = [ [[package]] name = "csv" -version = "1.1.6" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22813a6dc45b335f9bade10bf7271dc477e81113e89eb251a0bc2a8a81c536e1" +checksum = "f9d58633299b24b515ac72a3f869f8b91306a3cec616a602843a383acd6f9e97" dependencies = [ "bstr", "csv-core", @@ -1165,98 +1165,6 @@ version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ee2393c4a91429dffb4bedf19f4d6abf27d8a732c8ce4980305d782e5426d57" -[[package]] -name = "dc-consensus" -version = "2.0.0" -dependencies = [ - "dc-db", - "derive_more", - "dp_consensus", - "dvm-rpc-runtime-api", - "futures 0.3.13", - "log", - "parity-scale-codec 1.3.7", - "sc-client-api", - "sp-api", - "sp-block-builder", - "sp-blockchain", - "sp-consensus", - "sp-core", - "sp-inherents", - "sp-runtime", - "sp-timestamp", - "substrate-prometheus-endpoint", -] - -[[package]] -name = "dc-db" -version = "2.0.0" -dependencies = [ - "kvdb", - "kvdb-rocksdb", - "parity-scale-codec 1.3.7", - "parking_lot 0.11.1", - "sp-core", - "sp-database", - "sp-runtime", -] - -[[package]] -name = "dc-mapping-sync" -version = "2.0.0" -dependencies = [ - "dc-consensus", - "dc-db", - "dp_consensus", - "dvm-rpc-runtime-api", - "futures 0.3.13", - "futures-timer 3.0.2", - "log", - "sc-client-api", - "sp-api", - "sp-blockchain", - "sp-runtime", -] - -[[package]] -name = "dc-rpc" -version = "2.0.0" -dependencies = [ - "array-bytes", - "dc-consensus", - "dc-db", - "dp-rpc", - "dp-storage", - "dp_consensus", - "dvm-ethereum", - "dvm-rpc-core", - "dvm-rpc-runtime-api", - "ethereum", - "ethereum-types 0.10.0", - "futures 0.3.13", - "hyperspace-evm", - "jsonrpc-core", - "jsonrpc-core-client", - "jsonrpc-derive", - "jsonrpc-pubsub", - "libsecp256k1", - "log", - "parity-scale-codec 1.3.7", - "rand 0.7.3", - "rlp 0.5.0", - "sc-client-api", - "sc-network", - "sc-rpc", - "sc-service", - "sha3 0.8.2", - "sp-api", - "sp-blockchain", - "sp-io", - "sp-runtime", - "sp-storage", - "sp-transaction-pool", -] - [[package]] name = "derive_more" version = "0.99.11" @@ -1327,70 +1235,43 @@ dependencies = [ ] [[package]] -name = "dp-evm" -version = "2.0.0" -dependencies = [ - "evm", - "impl-trait-for-tuples 0.2.1", - "parity-scale-codec 1.3.7", - "serde", - "sp-core", - "sp-std", -] - -[[package]] -name = "dp-rpc" -version = "2.0.0" -dependencies = [ - "ethereum-types 0.10.0", - "jsonrpc-core", - "jsonrpc-core-client", - "jsonrpc-derive", - "jsonrpc-pubsub", - "rustc-hex", - "serde", - "serde_json", -] - -[[package]] -name = "dp-storage" -version = "2.0.0" - -[[package]] -name = "dp_consensus" -version = "2.0.0" +name = "dvm-consensus" +version = "1.4.0" dependencies = [ + "derive_more", + "dvm-consensus-primitives", "ethereum", + "futures 0.3.13", + "log", "parity-scale-codec 1.3.7", - "rlp 0.5.0", - "sha3 0.8.2", + "sc-client-api", + "sp-api", + "sp-block-builder", + "sp-blockchain", + "sp-consensus", "sp-core", + "sp-inherents", "sp-runtime", - "sp-std", + "sp-timestamp", + "substrate-prometheus-endpoint", ] [[package]] -name = "dvm-dynamic-fee" -version = "2.0.0" +name = "dvm-consensus-primitives" +version = "1.4.0" dependencies = [ - "frame-support", - "frame-system", "parity-scale-codec 1.3.7", - "serde", "sp-core", - "sp-inherents", "sp-runtime", - "sp-std", + "sp-std 2.0.1", ] [[package]] name = "dvm-ethereum" -version = "2.0.0" +version = "1.4.0" dependencies = [ "array-bytes", - "dp-evm", - "dp-storage", - "dp_consensus", + "dvm-consensus-primitives", "dvm-rpc-runtime-api", "ethereum", "ethereum-types 0.10.0", @@ -1400,6 +1281,7 @@ dependencies = [ "hyperspace-balances", "hyperspace-evm", "hyperspace-evm-precompile", + "hyperspace-evm-primitives", "hyperspace-support", "libsecp256k1", "pallet-timestamp", @@ -1410,18 +1292,54 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 2.0.1", +] + +[[package]] +name = "dvm-rpc" +version = "1.4.0" +dependencies = [ + "array-bytes", + "dvm-consensus", + "dvm-ethereum", + "dvm-rpc-core", + "dvm-rpc-core-primitives", + "dvm-rpc-runtime-api", + "ethereum", + "ethereum-types 0.10.0", + "futures 0.3.13", + "hyperspace-evm", + "jsonrpc-core", + "jsonrpc-core-client", + "jsonrpc-derive", + "jsonrpc-pubsub", + "libsecp256k1", + "log", + "parity-scale-codec 1.3.7", + "rand 0.7.3", + "rlp 0.5.0", + "sc-client-api", + "sc-network", + "sc-rpc", + "sc-service", + "sha3 0.8.2", + "sp-api", + "sp-blockchain", + "sp-io", + "sp-runtime", + "sp-storage", + "sp-transaction-pool", ] [[package]] name = "dvm-rpc-core" -version = "2.0.0" +version = "1.4.0" dependencies = [ - "dp-evm", - "dp-rpc", + "dvm-rpc-core-primitives", "ethereum", "ethereum-types 0.10.0", "hyperspace-evm", + "hyperspace-evm-primitives", "jsonrpc-core", "jsonrpc-derive", "jsonrpc-pubsub", @@ -1429,23 +1347,37 @@ dependencies = [ "sp-api", "sp-core", "sp-runtime", - "sp-std", + "sp-std 2.0.1", +] + +[[package]] +name = "dvm-rpc-core-primitives" +version = "1.4.0" +dependencies = [ + "ethereum-types 0.10.0", + "jsonrpc-core", + "jsonrpc-core-client", + "jsonrpc-derive", + "jsonrpc-pubsub", + "rustc-hex", + "serde", + "serde_json", ] [[package]] name = "dvm-rpc-runtime-api" -version = "2.0.0" +version = "1.4.0" dependencies = [ - "dp-evm", "ethereum", "ethereum-types 0.10.0", "hyperspace-evm", + "hyperspace-evm-primitives", "parity-scale-codec 1.3.7", "sp-api", "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 2.0.1", ] [[package]] @@ -1589,27 +1521,27 @@ dependencies = [ [[package]] name = "ethabi" version = "9.0.1" -source = "git+https://github.com/new-mvs/ethabi.git?branch=with_no_std#064722995e72a58b54fde5cbb6bfe2ee75d7f7ee" +source = "git+https://github.com/new-mvs/ethabi.git?branch=with_no_std#a1ca6a94e8af4a42eca8e18ea1a9d1bf0d0db442" dependencies = [ "ethereum-types 0.8.0", "rustc-hex", "serde", "serde_derive", "serde_json", - "sp-std", + "sp-std 2.0.0-rc2", "tiny-keccak 1.5.0", ] [[package]] name = "ethash" version = "0.4.0" -source = "git+https://github.com/new-mvs/ethash?branch=v1#701a26756a0d0f973c2327a4bc1e6b74187cd9b7" +source = "git+https://github.com/new-mvs/rust-ethash#d5aad9cbb8280723b95ca0c7d9c8d7a83dee1bd9" dependencies = [ "byteorder", "ethereum-types 0.8.0", "primitive-types 0.6.2", - "rlp 0.4.4", - "sha3 0.9.1", + "rlp 0.4.6", + "sha3 0.8.2", ] [[package]] @@ -1671,7 +1603,7 @@ dependencies = [ [[package]] name = "ethereum-primitives" -version = "2.0.0" +version = "1.4.0" dependencies = [ "array-bytes", "ethash", @@ -1692,7 +1624,7 @@ dependencies = [ "serde_json", "sp-io", "sp-runtime", - "sp-std", + "sp-std 2.0.1", "triehash 0.8.2", ] @@ -1756,9 +1688,9 @@ checksum = "f7531096570974c3a9dcf9e4b8e1cede1ec26cf5046219fb3b9d897503b9be59" [[package]] name = "evm" -version = "0.23.0" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b46f945d7548bea2affc1a48168f6d7e832bae914e0d90627a2ea2a7ba63001" +checksum = "fd540113f54cb8f20c74a594e3dc4422d69cb3df7c425ed7ed33c0383f780df0" dependencies = [ "ethereum", "evm-core", @@ -1774,9 +1706,9 @@ dependencies = [ [[package]] name = "evm-core" -version = "0.23.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc372feb219651f8ae872e6ec0f84b346053c058bd0e8408b1f44a2a796bfecd" +checksum = "aa225f553e9380c498f5beb4ba6e5d455b147a133d371b550f0326b92c95cc17" dependencies = [ "parity-scale-codec 1.3.7", "primitive-types 0.8.0", @@ -1785,9 +1717,9 @@ dependencies = [ [[package]] name = "evm-gasometer" -version = "0.23.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5737059b7a570b3e28a0126b02e0e36e218cc828b29dddbbae73d0b97fce1e0a" +checksum = "08bdd70b8a66727a77b991eb8374374f38b076fd9d539244751c59ebac9c3082" dependencies = [ "evm-core", "evm-runtime", @@ -1796,9 +1728,9 @@ dependencies = [ [[package]] name = "evm-runtime" -version = "0.23.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95726118dbc5f76ed1ee300e685950e58e52a1c4db454a7635aba636c7002186" +checksum = "25ab3a3ea8ab273ef0f9237e13f5fa271b6deb19d604766b88325d8d807afcaf" dependencies = [ "evm-core", "primitive-types 0.8.0", @@ -1955,7 +1887,7 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "fork-tree" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "parity-scale-codec 1.3.7", ] @@ -1973,7 +1905,7 @@ dependencies = [ [[package]] name = "frame-benchmarking" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "frame-support", "frame-system", @@ -1984,14 +1916,14 @@ dependencies = [ "sp-io", "sp-runtime", "sp-runtime-interface", - "sp-std", + "sp-std 2.0.1", "sp-storage", ] [[package]] name = "frame-executive" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "frame-support", "frame-system", @@ -2000,25 +1932,25 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 2.0.1", "sp-tracing", ] [[package]] name = "frame-metadata" version = "12.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "parity-scale-codec 1.3.7", "serde", "sp-core", - "sp-std", + "sp-std 2.0.1", ] [[package]] name = "frame-support" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "bitflags", "frame-metadata", @@ -2036,14 +1968,14 @@ dependencies = [ "sp-io", "sp-runtime", "sp-state-machine", - "sp-std", + "sp-std 2.0.1", "sp-tracing", ] [[package]] name = "frame-support-procedural" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "Inflector", "frame-support-procedural-tools", @@ -2055,7 +1987,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate", @@ -2067,7 +1999,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "proc-macro2", "quote", @@ -2077,7 +2009,7 @@ dependencies = [ [[package]] name = "frame-system" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "frame-support", "impl-trait-for-tuples 0.2.1", @@ -2086,14 +2018,14 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 2.0.1", "sp-version", ] [[package]] name = "frame-system-rpc-runtime-api" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "parity-scale-codec 1.3.7", "sp-api", @@ -2509,9 +2441,9 @@ dependencies = [ [[package]] name = "hex" -version = "0.4.3" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +checksum = "644f9158b2f133fd50f5fb3242878846d9eb792e445c893805ff0e3824006e35" [[package]] name = "hex-literal" @@ -2701,16 +2633,11 @@ dependencies = [ [[package]] name = "hyperspace" -version = "2.0.0" +version = "1.0.13" dependencies = [ "array-bytes", - "dc-consensus", - "dc-db", - "dc-mapping-sync", - "dc-rpc", - "dp-rpc", - "dp_consensus", - "dvm-ethereum", + "dvm-consensus", + "dvm-rpc", "dvm-rpc-runtime-api", "frame-system-rpc-runtime-api", "futures 0.3.13", @@ -2779,7 +2706,7 @@ dependencies = [ [[package]] name = "hyperspace-balances" -version = "2.0.0" +version = "1.4.0" dependencies = [ "frame-support", "frame-system", @@ -2791,12 +2718,12 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 2.0.1", ] [[package]] name = "hyperspace-balances-rpc" -version = "2.0.0" +version = "1.4.0" dependencies = [ "hyperspace-balances-rpc-runtime-api", "jsonrpc-core", @@ -2810,7 +2737,7 @@ dependencies = [ [[package]] name = "hyperspace-balances-rpc-runtime-api" -version = "2.0.0" +version = "1.4.0" dependencies = [ "hyperspace-support", "parity-scale-codec 1.3.7", @@ -2821,7 +2748,7 @@ dependencies = [ [[package]] name = "hyperspace-claims" -version = "2.0.0" +version = "1.4.0" dependencies = [ "array-bytes", "frame-support", @@ -2835,12 +2762,12 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 2.0.1", ] [[package]] name = "hyperspace-cli" -version = "2.0.0" +version = "1.4.0" dependencies = [ "sc-cli", "sc-client-api", @@ -2852,7 +2779,7 @@ dependencies = [ [[package]] name = "hyperspace-democracy" -version = "2.0.0" +version = "1.4.0" dependencies = [ "frame-support", "frame-system", @@ -2865,14 +2792,14 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 2.0.1", "sp-storage", "substrate-test-utils", ] [[package]] name = "hyperspace-elections-phragmen" -version = "2.0.0" +version = "1.4.0" dependencies = [ "frame-support", "frame-system", @@ -2885,13 +2812,13 @@ dependencies = [ "sp-io", "sp-npos-elections", "sp-runtime", - "sp-std", + "sp-std 2.0.1", "substrate-test-utils", ] [[package]] name = "hyperspace-ethereum-backing" -version = "2.0.0" +version = "1.4.0" dependencies = [ "array-bytes", "ethabi", @@ -2915,12 +2842,12 @@ dependencies = [ "sp-io", "sp-runtime", "sp-staking", - "sp-std", + "sp-std 2.0.1", ] [[package]] name = "hyperspace-ethereum-linear-relay" -version = "2.0.0" +version = "1.4.0" dependencies = [ "array-bytes", "ethereum-primitives", @@ -2936,12 +2863,12 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 2.0.1", ] [[package]] name = "hyperspace-ethereum-relay" -version = "2.0.0" +version = "1.4.0" dependencies = [ "array-bytes", "blake2-rfc", @@ -2961,20 +2888,20 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 2.0.1", ] [[package]] name = "hyperspace-evm" -version = "2.0.0" +version = "1.4.0" dependencies = [ - "dp-evm", "evm", "evm-gasometer", "evm-runtime", "frame-support", "frame-system", "hyperspace-balances", + "hyperspace-evm-primitives", "hyperspace-support", "pallet-timestamp", "parity-scale-codec 1.3.7", @@ -2985,12 +2912,12 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 2.0.1", ] [[package]] name = "hyperspace-evm-precompile" -version = "2.0.0" +version = "1.4.0" dependencies = [ "hyperspace-evm-precompile-dna", "hyperspace-evm-precompile-empty", @@ -3000,20 +2927,20 @@ dependencies = [ [[package]] name = "hyperspace-evm-precompile-blake2" -version = "2.0.0" +version = "1.4.0" dependencies = [ - "dp-evm", "evm", + "hyperspace-evm-primitives", "sp-core", "sp-io", ] [[package]] name = "hyperspace-evm-precompile-bn128" -version = "2.0.0" +version = "1.4.0" dependencies = [ - "dp-evm", "evm", + "hyperspace-evm-primitives", "sp-core", "sp-io", "substrate-bn", @@ -3021,12 +2948,12 @@ dependencies = [ [[package]] name = "hyperspace-evm-precompile-dispatch" -version = "2.0.0" +version = "1.4.0" dependencies = [ - "dp-evm", "evm", "frame-support", "hyperspace-evm", + "hyperspace-evm-primitives", "parity-scale-codec 1.3.7", "sp-core", "sp-io", @@ -3034,17 +2961,16 @@ dependencies = [ [[package]] name = "hyperspace-evm-precompile-dna" -version = "2.0.0" +version = "1.4.0" dependencies = [ "array-bytes", - "dp-evm", "ethabi", "ethereum-types 0.8.0", "evm", "frame-support", "frame-system", - "hex", "hyperspace-evm", + "hyperspace-evm-primitives", "pallet-timestamp", "parity-scale-codec 1.3.7", "ripemd160", @@ -3052,35 +2978,35 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 2.0.1", ] [[package]] name = "hyperspace-evm-precompile-ed25519" -version = "2.0.0" +version = "1.4.0" dependencies = [ - "dp-evm", "ed25519-dalek", "evm", + "hyperspace-evm-primitives", "sp-core", "sp-io", ] [[package]] name = "hyperspace-evm-precompile-empty" -version = "2.0.0" +version = "1.4.0" dependencies = [ - "dp-evm", "evm", + "hyperspace-evm-primitives", ] [[package]] name = "hyperspace-evm-precompile-modexp" -version = "2.0.0" +version = "1.4.0" dependencies = [ - "dp-evm", "evm", "hex", + "hyperspace-evm-primitives", "num", "sp-core", "sp-io", @@ -3088,10 +3014,10 @@ dependencies = [ [[package]] name = "hyperspace-evm-precompile-simple" -version = "2.0.0" +version = "1.4.0" dependencies = [ - "dp-evm", "evm", + "hyperspace-evm-primitives", "ripemd160", "sp-core", "sp-io", @@ -3099,25 +3025,37 @@ dependencies = [ [[package]] name = "hyperspace-evm-precompile-withdraw" -version = "2.0.0" +version = "1.4.0" dependencies = [ - "dp-evm", "evm", "frame-support", "frame-system", "hyperspace-evm", + "hyperspace-evm-primitives", "pallet-timestamp", "parity-scale-codec 1.3.7", "ripemd160", "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 2.0.1", +] + +[[package]] +name = "hyperspace-evm-primitives" +version = "1.4.0" +dependencies = [ + "evm", + "impl-trait-for-tuples 0.2.1", + "parity-scale-codec 1.3.7", + "serde", + "sp-core", + "sp-std 2.0.1", ] [[package]] name = "hyperspace-header-mmr" -version = "2.0.0" +version = "1.4.0" dependencies = [ "array-bytes", "ckb-merkle-mountain-range", @@ -3132,12 +3070,12 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 2.0.1", ] [[package]] name = "hyperspace-header-mmr-rpc" -version = "2.0.0" +version = "1.4.0" dependencies = [ "hyperspace-header-mmr-rpc-runtime-api", "jsonrpc-core", @@ -3151,19 +3089,19 @@ dependencies = [ [[package]] name = "hyperspace-header-mmr-rpc-runtime-api" -version = "2.0.0" +version = "1.4.0" dependencies = [ "hyperspace-support", "parity-scale-codec 1.3.7", "serde", "sp-api", "sp-runtime", - "sp-std", + "sp-std 2.0.1", ] [[package]] name = "hyperspace-oldetp-backing" -version = "2.0.0" +version = "1.4.0" dependencies = [ "frame-support", "frame-system", @@ -3173,34 +3111,34 @@ dependencies = [ ] [[package]] -name = "hyperspace-oldetp-issuing" -version = "2.0.0" +name = "hyperspace-oldna-backing" +version = "1.4.0" dependencies = [ "frame-support", "frame-system", - "hyperspace-balances", - "hyperspace-support", "parity-scale-codec 1.3.7", "serde", - "serde_json", - "sp-io", "sp-runtime", ] [[package]] -name = "hyperspace-oldna-backing" -version = "2.0.0" +name = "hyperspace-oldna-issuing" +version = "1.4.0" dependencies = [ "frame-support", "frame-system", + "hyperspace-balances", + "hyperspace-support", "parity-scale-codec 1.3.7", "serde", + "serde_json", + "sp-io", "sp-runtime", ] [[package]] name = "hyperspace-primitives" -version = "2.0.0" +version = "1.0.13" dependencies = [ "sp-core", "sp-runtime", @@ -3208,7 +3146,7 @@ dependencies = [ [[package]] name = "hyperspace-relay-authorities" -version = "2.0.0" +version = "1.4.0" dependencies = [ "array-bytes", "frame-support", @@ -3221,22 +3159,22 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 2.0.1", ] [[package]] name = "hyperspace-relay-primitives" -version = "2.0.0" +version = "1.4.0" dependencies = [ "frame-support", "parity-scale-codec 1.3.7", "sp-runtime", - "sp-std", + "sp-std 2.0.1", ] [[package]] name = "hyperspace-relayer-game" -version = "2.0.0" +version = "1.4.0" dependencies = [ "env_logger 0.8.3", "frame-support", @@ -3249,12 +3187,12 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 2.0.1", ] [[package]] name = "hyperspace-runtime" -version = "2.0.0" +version = "1.0.13" dependencies = [ "dvm-ethereum", "dvm-rpc-runtime-api", @@ -3275,8 +3213,8 @@ dependencies = [ "hyperspace-header-mmr", "hyperspace-header-mmr-rpc-runtime-api", "hyperspace-oldetp-backing", - "hyperspace-oldetp-issuing", "hyperspace-oldna-backing", + "hyperspace-oldna-issuing", "hyperspace-primitives", "hyperspace-relay-authorities", "hyperspace-relay-primitives", @@ -3291,22 +3229,18 @@ dependencies = [ "pallet-babe", "pallet-collective", "pallet-grandpa", - "pallet-identity", "pallet-im-online", "pallet-membership", "pallet-multisig", "pallet-offences", "pallet-proxy", "pallet-randomness-collective-flip", - "pallet-recovery", "pallet-scheduler", "pallet-session", - "pallet-society", "pallet-sudo", "pallet-timestamp", "pallet-transaction-payment", "pallet-transaction-payment-rpc-runtime-api", - "pallet-utility", "parity-scale-codec 1.3.7", "serde", "smallvec 1.6.1", @@ -3322,7 +3256,7 @@ dependencies = [ "sp-runtime", "sp-session", "sp-staking", - "sp-std", + "sp-std 2.0.1", "sp-transaction-pool", "sp-version", "static_assertions 1.1.0", @@ -3331,7 +3265,7 @@ dependencies = [ [[package]] name = "hyperspace-staking" -version = "2.0.0" +version = "1.4.0" dependencies = [ "frame-support", "frame-system", @@ -3350,7 +3284,7 @@ dependencies = [ "sp-npos-elections", "sp-runtime", "sp-staking", - "sp-std", + "sp-std 2.0.1", "sp-storage", "sp-tracing", "static_assertions 1.1.0", @@ -3360,7 +3294,7 @@ dependencies = [ [[package]] name = "hyperspace-staking-rpc" -version = "2.0.0" +version = "1.4.0" dependencies = [ "hyperspace-staking-rpc-runtime-api", "jsonrpc-core", @@ -3374,7 +3308,7 @@ dependencies = [ [[package]] name = "hyperspace-staking-rpc-runtime-api" -version = "2.0.0" +version = "1.4.0" dependencies = [ "hyperspace-support", "parity-scale-codec 1.3.7", @@ -3385,7 +3319,7 @@ dependencies = [ [[package]] name = "hyperspace-support" -version = "2.0.0" +version = "1.4.0" dependencies = [ "ethereum-primitives", "frame-support", @@ -3393,12 +3327,12 @@ dependencies = [ "num-traits", "parity-scale-codec 1.3.7", "sp-runtime", - "sp-std", + "sp-std 2.0.1", ] [[package]] name = "hyperspace-treasury" -version = "2.0.0" +version = "1.4.0" dependencies = [ "frame-support", "frame-system", @@ -3409,13 +3343,13 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 2.0.1", "sp-storage", ] [[package]] name = "hyperspace-vesting" -version = "2.0.0" +version = "1.4.0" dependencies = [ "enumflags2", "frame-support", @@ -3428,7 +3362,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 2.0.1", "sp-storage", ] @@ -3584,9 +3518,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.6.2" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "824845a0bf897a9042383849b02c1bc219c2383772efcd5c6f9766fa4b81aef3" +checksum = "4fb1fa934250de4de8aef298d81c729a7d33d8c239daa3a7575e6b92bfc7313b" dependencies = [ "autocfg", "hashbrown", @@ -4542,7 +4476,7 @@ checksum = "71d96e3f3c0b6325d8ccd83c33b28acb183edcb6c67938ba104ec546854b0882" [[package]] name = "merkle-patricia-trie" -version = "2.0.0" +version = "1.4.0" dependencies = [ "array-bytes", "criterion", @@ -4552,7 +4486,7 @@ dependencies = [ "keccak-hash", "rand 0.7.3", "rlp 0.4.4", - "sp-std", + "sp-std 2.0.1", "uuid", ] @@ -4985,7 +4919,7 @@ dependencies = [ [[package]] name = "pallet-authority-discovery" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "frame-support", "frame-system", @@ -4995,13 +4929,13 @@ dependencies = [ "sp-application-crypto", "sp-authority-discovery", "sp-runtime", - "sp-std", + "sp-std 2.0.1", ] [[package]] name = "pallet-authorship" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "frame-support", "frame-system", @@ -5010,13 +4944,13 @@ dependencies = [ "sp-authorship", "sp-inherents", "sp-runtime", - "sp-std", + "sp-std 2.0.1", ] [[package]] name = "pallet-babe" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "frame-benchmarking", "frame-support", @@ -5034,14 +4968,14 @@ dependencies = [ "sp-runtime", "sp-session", "sp-staking", - "sp-std", + "sp-std 2.0.1", "sp-timestamp", ] [[package]] name = "pallet-balances" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "frame-benchmarking", "frame-support", @@ -5049,13 +4983,13 @@ dependencies = [ "parity-scale-codec 1.3.7", "serde", "sp-runtime", - "sp-std", + "sp-std 2.0.1", ] [[package]] name = "pallet-collective" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "frame-support", "frame-system", @@ -5064,13 +4998,13 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 2.0.1", ] [[package]] name = "pallet-grandpa" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "frame-benchmarking", "frame-support", @@ -5085,29 +5019,13 @@ dependencies = [ "sp-runtime", "sp-session", "sp-staking", - "sp-std", -] - -[[package]] -name = "pallet-identity" -version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" -dependencies = [ - "enumflags2", - "frame-benchmarking", - "frame-support", - "frame-system", - "parity-scale-codec 1.3.7", - "serde", - "sp-io", - "sp-runtime", - "sp-std", + "sp-std 2.0.1", ] [[package]] name = "pallet-im-online" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "frame-support", "frame-system", @@ -5120,13 +5038,13 @@ dependencies = [ "sp-io", "sp-runtime", "sp-staking", - "sp-std", + "sp-std 2.0.1", ] [[package]] name = "pallet-membership" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "frame-support", "frame-system", @@ -5134,13 +5052,13 @@ dependencies = [ "serde", "sp-io", "sp-runtime", - "sp-std", + "sp-std 2.0.1", ] [[package]] name = "pallet-multisig" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "frame-support", "frame-system", @@ -5149,13 +5067,13 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 2.0.1", ] [[package]] name = "pallet-offences" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "frame-support", "frame-system", @@ -5164,13 +5082,13 @@ dependencies = [ "serde", "sp-runtime", "sp-staking", - "sp-std", + "sp-std 2.0.1", ] [[package]] name = "pallet-proxy" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "frame-support", "frame-system", @@ -5179,41 +5097,26 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 2.0.1", ] [[package]] name = "pallet-randomness-collective-flip" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "frame-support", "frame-system", "parity-scale-codec 1.3.7", "safe-mix", "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-recovery" -version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" -dependencies = [ - "enumflags2", - "frame-support", - "frame-system", - "parity-scale-codec 1.3.7", - "serde", - "sp-io", - "sp-runtime", - "sp-std", + "sp-std 2.0.1", ] [[package]] name = "pallet-scheduler" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "frame-benchmarking", "frame-support", @@ -5222,13 +5125,13 @@ dependencies = [ "serde", "sp-io", "sp-runtime", - "sp-std", + "sp-std 2.0.1", ] [[package]] name = "pallet-session" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "frame-support", "frame-system", @@ -5241,28 +5144,14 @@ dependencies = [ "sp-runtime", "sp-session", "sp-staking", - "sp-std", + "sp-std 2.0.1", "sp-trie", ] -[[package]] -name = "pallet-society" -version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" -dependencies = [ - "frame-support", - "frame-system", - "parity-scale-codec 1.3.7", - "rand_chacha 0.2.2", - "serde", - "sp-runtime", - "sp-std", -] - [[package]] name = "pallet-sudo" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "frame-support", "frame-system", @@ -5270,13 +5159,13 @@ dependencies = [ "serde", "sp-io", "sp-runtime", - "sp-std", + "sp-std 2.0.1", ] [[package]] name = "pallet-timestamp" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "frame-benchmarking", "frame-support", @@ -5286,14 +5175,14 @@ dependencies = [ "serde", "sp-inherents", "sp-runtime", - "sp-std", + "sp-std 2.0.1", "sp-timestamp", ] [[package]] name = "pallet-transaction-payment" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "frame-support", "frame-system", @@ -5303,13 +5192,13 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 2.0.1", ] [[package]] name = "pallet-transaction-payment-rpc" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "jsonrpc-core", "jsonrpc-core-client", @@ -5326,7 +5215,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc-runtime-api" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "pallet-transaction-payment", "parity-scale-codec 1.3.7", @@ -5334,21 +5223,6 @@ dependencies = [ "sp-runtime", ] -[[package]] -name = "pallet-utility" -version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" -dependencies = [ - "frame-support", - "frame-system", - "parity-scale-codec 1.3.7", - "serde", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", -] - [[package]] name = "parity-db" version = "0.1.2" @@ -6285,13 +6159,14 @@ dependencies = [ [[package]] name = "regex" -version = "1.4.5" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "957056ecddbeba1b26965114e191d2e8589ce74db242b6ea25fc4062427a5c19" +checksum = "d9251239e129e16308e70d853559389de218ac275b515068abc96829d05b948a" dependencies = [ "aho-corasick", "memchr", "regex-syntax", + "thread_local", ] [[package]] @@ -6306,9 +6181,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.23" +version = "0.6.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d5f089152e60f62d28b835fbff2cd2e8dc0baf1ac13343bef92ab7eed84548" +checksum = "b5eb417147ba9860a96cfe72a0b93bf88fee1744b5636ec99ab20c1aa9376581" [[package]] name = "region" @@ -6555,7 +6430,7 @@ dependencies = [ [[package]] name = "sc-authority-discovery" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "async-trait", "derive_more", @@ -6583,7 +6458,7 @@ dependencies = [ [[package]] name = "sc-basic-authorship" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "futures 0.3.13", "futures-timer 3.0.2", @@ -6606,7 +6481,7 @@ dependencies = [ [[package]] name = "sc-block-builder" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "parity-scale-codec 1.3.7", "sc-client-api", @@ -6623,7 +6498,7 @@ dependencies = [ [[package]] name = "sc-chain-spec" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "impl-trait-for-tuples 0.2.1", "parity-scale-codec 1.3.7", @@ -6644,7 +6519,7 @@ dependencies = [ [[package]] name = "sc-chain-spec-derive" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -6655,7 +6530,7 @@ dependencies = [ [[package]] name = "sc-cli" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "chrono", "fdlimit", @@ -6693,7 +6568,7 @@ dependencies = [ [[package]] name = "sc-client-api" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "derive_more", "fnv", @@ -6715,7 +6590,7 @@ dependencies = [ "sp-keystore", "sp-runtime", "sp-state-machine", - "sp-std", + "sp-std 2.0.1", "sp-storage", "sp-transaction-pool", "sp-trie", @@ -6727,7 +6602,7 @@ dependencies = [ [[package]] name = "sc-client-db" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "blake2-rfc", "hash-db", @@ -6757,7 +6632,7 @@ dependencies = [ [[package]] name = "sc-consensus" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "sc-client-api", "sp-blockchain", @@ -6768,7 +6643,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "derive_more", "fork-tree", @@ -6813,7 +6688,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe-rpc" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "derive_more", "futures 0.3.13", @@ -6837,7 +6712,7 @@ dependencies = [ [[package]] name = "sc-consensus-epochs" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "fork-tree", "parity-scale-codec 1.3.7", @@ -6850,7 +6725,7 @@ dependencies = [ [[package]] name = "sc-consensus-slots" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "futures 0.3.13", "futures-timer 3.0.2", @@ -6876,7 +6751,7 @@ dependencies = [ [[package]] name = "sc-consensus-uncles" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "log", "sc-client-api", @@ -6890,7 +6765,7 @@ dependencies = [ [[package]] name = "sc-executor" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "derive_more", "lazy_static", @@ -6919,7 +6794,7 @@ dependencies = [ [[package]] name = "sc-executor-common" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "derive_more", "parity-scale-codec 1.3.7", @@ -6935,7 +6810,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmi" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "log", "parity-scale-codec 1.3.7", @@ -6950,7 +6825,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmtime" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "log", "parity-scale-codec 1.3.7", @@ -6968,7 +6843,7 @@ dependencies = [ [[package]] name = "sc-finality-grandpa" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "derive_more", "finality-grandpa", @@ -7006,7 +6881,7 @@ dependencies = [ [[package]] name = "sc-finality-grandpa-rpc" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "derive_more", "finality-grandpa", @@ -7030,7 +6905,7 @@ dependencies = [ [[package]] name = "sc-finality-grandpa-warp-sync" version = "0.8.0" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "derive_more", "futures 0.3.13", @@ -7050,7 +6925,7 @@ dependencies = [ [[package]] name = "sc-informant" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "ansi_term 0.12.1", "futures 0.3.13", @@ -7068,7 +6943,7 @@ dependencies = [ [[package]] name = "sc-keystore" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "async-trait", "derive_more", @@ -7088,7 +6963,7 @@ dependencies = [ [[package]] name = "sc-light" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "hash-db", "lazy_static", @@ -7107,7 +6982,7 @@ dependencies = [ [[package]] name = "sc-network" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "async-std", "async-trait", @@ -7159,7 +7034,7 @@ dependencies = [ [[package]] name = "sc-network-gossip" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "futures 0.3.13", "futures-timer 3.0.2", @@ -7175,7 +7050,7 @@ dependencies = [ [[package]] name = "sc-offchain" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "bytes 0.5.6", "fnv", @@ -7202,7 +7077,7 @@ dependencies = [ [[package]] name = "sc-peerset" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "futures 0.3.13", "libp2p", @@ -7215,7 +7090,7 @@ dependencies = [ [[package]] name = "sc-proposer-metrics" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "log", "substrate-prometheus-endpoint", @@ -7224,7 +7099,7 @@ dependencies = [ [[package]] name = "sc-rpc" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "futures 0.3.13", "hash-db", @@ -7258,7 +7133,7 @@ dependencies = [ [[package]] name = "sc-rpc-api" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "derive_more", "futures 0.3.13", @@ -7282,7 +7157,7 @@ dependencies = [ [[package]] name = "sc-rpc-server" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "futures 0.1.31", "jsonrpc-core", @@ -7300,7 +7175,7 @@ dependencies = [ [[package]] name = "sc-service" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "directories 3.0.1", "exit-future", @@ -7363,7 +7238,7 @@ dependencies = [ [[package]] name = "sc-state-db" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "log", "parity-scale-codec 1.3.7", @@ -7378,7 +7253,7 @@ dependencies = [ [[package]] name = "sc-sync-state-rpc" version = "0.8.0" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "jsonrpc-core", "jsonrpc-core-client", @@ -7398,7 +7273,7 @@ dependencies = [ [[package]] name = "sc-telemetry" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "chrono", "futures 0.3.13", @@ -7420,7 +7295,7 @@ dependencies = [ [[package]] name = "sc-tracing" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "ansi_term 0.12.1", "atty", @@ -7448,7 +7323,7 @@ dependencies = [ [[package]] name = "sc-tracing-proc-macro" version = "2.0.0" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -7459,7 +7334,7 @@ dependencies = [ [[package]] name = "sc-transaction-graph" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "derive_more", "futures 0.3.13", @@ -7481,7 +7356,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "futures 0.3.13", "futures-diagnose", @@ -7652,9 +7527,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.124" +version = "1.0.125" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd761ff957cb2a45fbb9ab3da6512de9de55872866160b23c25f1a841e99d29f" +checksum = "558dc50e1a5a5fa7112ca2ce4effcb321b0300c0d4ccf0776a9f60cd89031171" dependencies = [ "serde_derive", ] @@ -7671,9 +7546,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.124" +version = "1.0.125" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1800f7693e94e186f5e25a28291ae1570da908aff7d97a095dec1e56ff99069b" +checksum = "b093b7a2bb58203b5da3056c05b4ec1fed827dcfdb37347a8841695263b3d06d" dependencies = [ "proc-macro2", "quote", @@ -7783,9 +7658,9 @@ checksum = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2" [[package]] name = "signal-hook" -version = "0.3.7" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6aa894ef3fade0ee7243422f4fbbd6c2b48e6de767e621d37ef65f2310f53cea" +checksum = "8a7f3f92a1da3d6b1d32245d0cbcbbab0cfc45996d8df619c42bccfa6d2bbb5f" dependencies = [ "libc", "signal-hook-registry", @@ -7887,11 +7762,11 @@ dependencies = [ [[package]] name = "sp-allocator" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "log", "sp-core", - "sp-std", + "sp-std 2.0.1", "sp-wasm-interface", "thiserror", ] @@ -7899,7 +7774,7 @@ dependencies = [ [[package]] name = "sp-api" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "hash-db", "parity-scale-codec 1.3.7", @@ -7907,7 +7782,7 @@ dependencies = [ "sp-core", "sp-runtime", "sp-state-machine", - "sp-std", + "sp-std 2.0.1", "sp-version", "thiserror", ] @@ -7915,7 +7790,7 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "blake2-rfc", "proc-macro-crate", @@ -7927,67 +7802,67 @@ dependencies = [ [[package]] name = "sp-application-crypto" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "parity-scale-codec 1.3.7", "serde", "sp-core", "sp-io", - "sp-std", + "sp-std 2.0.1", ] [[package]] name = "sp-arithmetic" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "integer-sqrt", "num-traits", "parity-scale-codec 1.3.7", "serde", "sp-debug-derive", - "sp-std", + "sp-std 2.0.1", ] [[package]] name = "sp-authority-discovery" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "parity-scale-codec 1.3.7", "sp-api", "sp-application-crypto", "sp-runtime", - "sp-std", + "sp-std 2.0.1", ] [[package]] name = "sp-authorship" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "parity-scale-codec 1.3.7", "sp-inherents", "sp-runtime", - "sp-std", + "sp-std 2.0.1", ] [[package]] name = "sp-block-builder" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "parity-scale-codec 1.3.7", "sp-api", "sp-inherents", "sp-runtime", - "sp-std", + "sp-std 2.0.1", ] [[package]] name = "sp-blockchain" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "futures 0.3.13", "log", @@ -8005,7 +7880,7 @@ dependencies = [ [[package]] name = "sp-chain-spec" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "serde", "serde_json", @@ -8014,7 +7889,7 @@ dependencies = [ [[package]] name = "sp-consensus" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "futures 0.3.13", "futures-timer 3.0.2", @@ -8028,7 +7903,7 @@ dependencies = [ "sp-inherents", "sp-runtime", "sp-state-machine", - "sp-std", + "sp-std 2.0.1", "sp-trie", "sp-utils", "sp-version", @@ -8040,7 +7915,7 @@ dependencies = [ [[package]] name = "sp-consensus-babe" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "merlin", "parity-scale-codec 1.3.7", @@ -8053,14 +7928,14 @@ dependencies = [ "sp-inherents", "sp-keystore", "sp-runtime", - "sp-std", + "sp-std 2.0.1", "sp-timestamp", ] [[package]] name = "sp-consensus-slots" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "parity-scale-codec 1.3.7", "sp-runtime", @@ -8069,19 +7944,19 @@ dependencies = [ [[package]] name = "sp-consensus-vrf" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "parity-scale-codec 1.3.7", "schnorrkel", "sp-core", "sp-runtime", - "sp-std", + "sp-std 2.0.1", ] [[package]] name = "sp-core" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "base58", "blake2-rfc", @@ -8111,7 +7986,7 @@ dependencies = [ "sp-debug-derive", "sp-externalities", "sp-runtime-interface", - "sp-std", + "sp-std 2.0.1", "sp-storage", "substrate-bip39", "thiserror", @@ -8125,7 +8000,7 @@ dependencies = [ [[package]] name = "sp-database" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "kvdb", "parking_lot 0.11.1", @@ -8134,7 +8009,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "proc-macro2", "quote", @@ -8144,18 +8019,18 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "environmental", "parity-scale-codec 1.3.7", - "sp-std", + "sp-std 2.0.1", "sp-storage", ] [[package]] name = "sp-finality-grandpa" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "finality-grandpa", "log", @@ -8166,25 +8041,25 @@ dependencies = [ "sp-core", "sp-keystore", "sp-runtime", - "sp-std", + "sp-std 2.0.1", ] [[package]] name = "sp-inherents" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "parity-scale-codec 1.3.7", "parking_lot 0.11.1", "sp-core", - "sp-std", + "sp-std 2.0.1", "thiserror", ] [[package]] name = "sp-io" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "futures 0.3.13", "hash-db", @@ -8197,7 +8072,7 @@ dependencies = [ "sp-keystore", "sp-runtime-interface", "sp-state-machine", - "sp-std", + "sp-std 2.0.1", "sp-tracing", "sp-trie", "sp-wasm-interface", @@ -8208,7 +8083,7 @@ dependencies = [ [[package]] name = "sp-keyring" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "lazy_static", "sp-core", @@ -8219,7 +8094,7 @@ dependencies = [ [[package]] name = "sp-keystore" version = "0.8.0" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "async-trait", "derive_more", @@ -8236,20 +8111,20 @@ dependencies = [ [[package]] name = "sp-npos-elections" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "parity-scale-codec 1.3.7", "serde", "sp-arithmetic", "sp-core", "sp-npos-elections-compact", - "sp-std", + "sp-std 2.0.1", ] [[package]] name = "sp-npos-elections-compact" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -8260,7 +8135,7 @@ dependencies = [ [[package]] name = "sp-offchain" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "sp-api", "sp-core", @@ -8270,7 +8145,7 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "backtrace", ] @@ -8278,7 +8153,7 @@ dependencies = [ [[package]] name = "sp-rpc" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "serde", "sp-core", @@ -8287,7 +8162,7 @@ dependencies = [ [[package]] name = "sp-runtime" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "either", "hash256-std-hasher", @@ -8302,20 +8177,20 @@ dependencies = [ "sp-arithmetic", "sp-core", "sp-io", - "sp-std", + "sp-std 2.0.1", ] [[package]] name = "sp-runtime-interface" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "impl-trait-for-tuples 0.2.1", "parity-scale-codec 1.3.7", "primitive-types 0.8.0", "sp-externalities", "sp-runtime-interface-proc-macro", - "sp-std", + "sp-std 2.0.1", "sp-storage", "sp-tracing", "sp-wasm-interface", @@ -8325,7 +8200,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "Inflector", "proc-macro-crate", @@ -8337,7 +8212,7 @@ dependencies = [ [[package]] name = "sp-serializer" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "serde", "serde_json", @@ -8346,30 +8221,30 @@ dependencies = [ [[package]] name = "sp-session" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "parity-scale-codec 1.3.7", "sp-api", "sp-core", "sp-runtime", "sp-staking", - "sp-std", + "sp-std 2.0.1", ] [[package]] name = "sp-staking" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "parity-scale-codec 1.3.7", "sp-runtime", - "sp-std", + "sp-std 2.0.1", ] [[package]] name = "sp-state-machine" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "hash-db", "log", @@ -8381,66 +8256,71 @@ dependencies = [ "sp-core", "sp-externalities", "sp-panic-handler", - "sp-std", + "sp-std 2.0.1", "sp-trie", "thiserror", "trie-db", "trie-root", ] +[[package]] +name = "sp-std" +version = "2.0.0-rc2" +source = "git+https://github.com/new-mvs/substrate.git?branch=darwinia-develop#45b9f0a9cbf901abaa9f1fca5fe8baeed029133d" + [[package]] name = "sp-std" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" [[package]] name = "sp-storage" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "impl-serde 0.3.1", "parity-scale-codec 1.3.7", "ref-cast", "serde", "sp-debug-derive", - "sp-std", + "sp-std 2.0.1", ] [[package]] name = "sp-tasks" version = "2.0.0" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "log", "sp-core", "sp-externalities", "sp-io", "sp-runtime-interface", - "sp-std", + "sp-std 2.0.1", ] [[package]] name = "sp-timestamp" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "impl-trait-for-tuples 0.2.1", "parity-scale-codec 1.3.7", "sp-api", "sp-inherents", "sp-runtime", - "sp-std", + "sp-std 2.0.1", "wasm-timer", ] [[package]] name = "sp-tracing" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "log", "parity-scale-codec 1.3.7", - "sp-std", + "sp-std 2.0.1", "tracing", "tracing-core", "tracing-subscriber", @@ -8449,7 +8329,7 @@ dependencies = [ [[package]] name = "sp-transaction-pool" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "derive_more", "futures 0.3.13", @@ -8465,13 +8345,13 @@ dependencies = [ [[package]] name = "sp-trie" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "hash-db", "memory-db", "parity-scale-codec 1.3.7", "sp-core", - "sp-std", + "sp-std 2.0.1", "trie-db", "trie-root", ] @@ -8479,7 +8359,7 @@ dependencies = [ [[package]] name = "sp-utils" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "futures 0.3.13", "futures-core", @@ -8491,23 +8371,23 @@ dependencies = [ [[package]] name = "sp-version" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "impl-serde 0.3.1", "parity-scale-codec 1.3.7", "serde", "sp-runtime", - "sp-std", + "sp-std 2.0.1", ] [[package]] name = "sp-wasm-interface" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "impl-trait-for-tuples 0.2.1", "parity-scale-codec 1.3.7", - "sp-std", + "sp-std 2.0.1", "wasmi", ] @@ -8643,7 +8523,7 @@ dependencies = [ [[package]] name = "substrate-build-script-utils" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "platforms", ] @@ -8660,7 +8540,7 @@ dependencies = [ [[package]] name = "substrate-frame-rpc-system" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "frame-system-rpc-runtime-api", "futures 0.3.13", @@ -8683,7 +8563,7 @@ dependencies = [ [[package]] name = "substrate-prometheus-endpoint" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "async-std", "derive_more", @@ -8697,7 +8577,7 @@ dependencies = [ [[package]] name = "substrate-test-utils" version = "2.0.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "futures 0.3.13", "substrate-test-utils-derive", @@ -8707,7 +8587,7 @@ dependencies = [ [[package]] name = "substrate-test-utils-derive" version = "0.8.1" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "proc-macro-crate", "quote", @@ -8717,7 +8597,7 @@ dependencies = [ [[package]] name = "substrate-wasm-builder" version = "3.0.0" -source = "git+https://github.com/new-mvs/substrate.git?branch=latest#481479797f9245040e0b944a6ba83f893eb6a56d" +source = "git+https://github.com/new-mvs/substrate?branch=latest#466ac62ecd1f096606691f0ed24a0851cc7a2ac1" dependencies = [ "ansi_term 0.12.1", "atty", @@ -8743,9 +8623,9 @@ checksum = "1e81da0851ada1f3e9d4312c704aa4f8806f0f9d69faaf8df2f3464b4a9437c2" [[package]] name = "syn" -version = "1.0.64" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fd9d1e9976102a03c542daa2eff1b43f9d72306342f3f8b3ed5fb8908195d6f" +checksum = "ed22b90a0e734a23a7610f4283ac9e5acfb96cbb30dfefa540d66f866f1c09c5" dependencies = [ "proc-macro2", "quote", @@ -9235,9 +9115,9 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.15" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c42e6fa53307c8a17e4ccd4dc81cf5ec38db9209f59b222210375b54ee40d1e2" +checksum = "a8a9bd1db7706f2373a190b0d067146caa39350c486f3d455b0e33b431f94c07" dependencies = [ "proc-macro2", "quote", @@ -9286,9 +9166,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.2.17" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "705096c6f83bf68ea5d357a6aa01829ddbdac531b357b45abeca842938085baa" +checksum = "8ab8966ac3ca27126141f7999361cc97dd6fb4b71da04c02044fa9045d98bb96" dependencies = [ "ansi_term 0.12.1", "chrono", @@ -9366,9 +9246,9 @@ dependencies = [ [[package]] name = "typenum" -version = "1.13.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06" +checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33" [[package]] name = "ucd-trie" diff --git a/Cargo.toml b/Cargo.toml index b84a1fd..638a4f7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,28 +1,28 @@ [workspace] members = [ + # node "bin/node/cli", "bin/node/primitives", "bin/node/runtime/hyperspace", + # client "client/cli", "client/dvm/consensus", - "client/dvm/db", - "client/dvm/mapping-sync", "client/dvm/rpc", + # frame "frame/balances", "frame/balances/rpc", "frame/balances/rpc/runtime-api", - "frame/bridge/oldetp/backing", - "frame/bridge/oldetp/issuing", + "frame/bridge/oldna/backing", + "frame/bridge/oldna/issuing", "frame/bridge/ethereum/backing", "frame/bridge/ethereum/linear-relay", "frame/bridge/ethereum/relay", "frame/bridge/relayer-game", "frame/bridge/relay-authorities", - "frame/bridge/oldna/backing", + "frame/bridge/oldetp/backing", "frame/claims", "frame/democracy", "frame/dvm", - "frame/dvm-dynamic-fee", "frame/dvm/rpc", "frame/dvm/rpc/runtime-api", "frame/elections-phragmen", @@ -46,13 +46,13 @@ members = [ "frame/support", "frame/treasury", "frame/vesting", + # primitives "primitives/consensus", + "primitives/dvm-rpc-core", "primitives/ethereum-primitives", "primitives/evm", "primitives/merkle-patricia-trie", "primitives/relay", - "primitives/rpc", - "primitives/storage", ] # The list of dependencies below (which can be both direct and indirect dependencies) are crates diff --git a/bin/node/cli/Cargo.toml b/bin/node/cli/Cargo.toml index 1aefb49..40ec668 100644 --- a/bin/node/cli/Cargo.toml +++ b/bin/node/cli/Cargo.toml @@ -8,7 +8,7 @@ license = "GPL-3.0" name = "hyperspace" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" +version = "1.0.13" # TODO: Consider rename this repo to hyperspace-runtime-module-library [[bin]] @@ -16,7 +16,6 @@ name = "hyperspace" [dependencies] # crates -array-bytes = { version = "1.1.0" } codec = { package = "parity-scale-codec", version = "1.3.7" } futures = { version = "0.3.13" } jsonrpc-core = { version = "15.1.0" } @@ -25,6 +24,7 @@ log = { version = "0.4.14" } structopt = { version = "0.3.21" } tokio = { version = "0.3.6", optional = true, features = ["rt-multi-thread"] } # hyperspace +array-bytes = { version = "1.1.0" } hyperspace-balances-rpc = { path = "../../../frame/balances/rpc" } hyperspace-balances-rpc-runtime-api = { path = "../../../frame/balances/rpc/runtime-api" } hyperspace-claims = { path = "../../../frame/claims" } @@ -36,63 +36,58 @@ hyperspace-header-mmr-rpc-runtime-api = { path = "../../../frame/header-mmr/rpc/ hyperspace-staking = { path = "../../../frame/staking" } hyperspace-staking-rpc = { path = "../../../frame/staking/rpc" } hyperspace-staking-rpc-runtime-api = { path = "../../../frame/staking/rpc/runtime-api" } -dc-consensus = { path = "../../../client/dvm/consensus" } -dc-db = { path = "../../../client/dvm/db" } -dc-mapping-sync = { path = "../../../client/dvm/mapping-sync" } -dc-rpc = { path = "../../../client/dvm/rpc", features = ["rpc_binary_search_estimate"] } -dp-rpc = { path = "../../../primitives/rpc" } -dp_consensus = { path = "../../../primitives/consensus" } hyperspace-primitives = { path = "../primitives" } -dvm-ethereum = { path = "../../../frame/dvm" } +dvm-consensus = { path = "../../../client/dvm/consensus" } +dvm-rpc = { path = "../../../client/dvm/rpc" } dvm-rpc-runtime-api = { path = "../../../frame/dvm/rpc/runtime-api" } hyperspace-runtime = { path = "../runtime/hyperspace" } # substrate -frame-system-rpc-runtime-api = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -pallet-im-online = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -pallet-transaction-payment-rpc = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sc-authority-discovery = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sc-basic-authorship = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sc-chain-spec = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sc-cli = { optional = true, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sc-client-api = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sc-consensus = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sc-consensus-babe = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sc-consensus-babe-rpc = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sc-consensus-epochs = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sc-consensus-slots = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sc-executor = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sc-finality-grandpa = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sc-finality-grandpa-rpc = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sc-finality-grandpa-warp-sync = { optional = true, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sc-keystore = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sc-network = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sc-rpc = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sc-service = { optional = true, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sc-sync-state-rpc = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sc-telemetry = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sc-transaction-pool = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-api = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-authority-discovery = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-block-builder = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-blockchain = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-consensus = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-consensus-babe = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-core = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-finality-grandpa = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-inherents = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-keystore = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-offchain = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-runtime = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-session = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-transaction-pool = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-trie = { features = ["memory-tracker"], git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -substrate-frame-rpc-system = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -substrate-prometheus-endpoint = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +frame-system-rpc-runtime-api = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +pallet-im-online = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +pallet-transaction-payment-rpc = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sc-authority-discovery = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sc-basic-authorship = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sc-chain-spec = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sc-cli = { optional = true, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sc-client-api = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sc-consensus = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sc-consensus-babe = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sc-consensus-babe-rpc = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sc-consensus-epochs = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sc-consensus-slots = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sc-executor = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sc-finality-grandpa = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sc-finality-grandpa-rpc = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sc-finality-grandpa-warp-sync = { optional = true, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sc-keystore = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sc-network = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sc-rpc = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sc-service = { optional = true, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sc-sync-state-rpc = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sc-telemetry = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sc-transaction-pool = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-api = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-authority-discovery = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-block-builder = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-blockchain = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-consensus = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-consensus-babe = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-core = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-finality-grandpa = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-inherents = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-keystore = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-offchain = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-runtime = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-session = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-transaction-pool = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-trie = { features = ["memory-tracker"], git = "https://github.com/new-mvs/substrate", branch = "latest" } +substrate-frame-rpc-system = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +substrate-prometheus-endpoint = { git = "https://github.com/new-mvs/substrate", branch = "latest" } [build-dependencies] # substrate -substrate-build-script-utils = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +substrate-build-script-utils = { git = "https://github.com/new-mvs/substrate", branch = "latest" } [features] default = [ diff --git a/bin/node/cli/src/chain_spec.rs b/bin/node/cli/src/chain_spec.rs index 0653254..da9ee68 100644 --- a/bin/node/cli/src/chain_spec.rs +++ b/bin/node/cli/src/chain_spec.rs @@ -41,7 +41,7 @@ pub type HyperspaceChainSpec = sc_service::GenericChainSpec; type AccountPublic = ::Signer; -const HYPERSPACE_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/"; +const PANGOLIN_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/"; pub fn hyperspace_config() -> Result { HyperspaceChainSpec::from_json_bytes(&include_bytes!("../../../res/hyperspace/hyperspace.json")[..]) @@ -64,9 +64,9 @@ pub fn hyperspace_session_keys( pub fn properties() -> Properties { let mut properties = Properties::new(); - properties.insert("ss58Format".into(), 18.into()); - properties.insert("tokenDecimals".into(), vec![9, 9].into()); - properties.insert("tokenSymbol".into(), vec!["PETP", "PDNA"].into()); + properties.insert("ss58Format".into(),150.into()); + properties.insert("tokenDecimals".into(), vec![8, 8].into()); + properties.insert("tokenSymbol".into(), vec!["ETP", "DNA"].into()); properties } @@ -112,7 +112,7 @@ pub fn hyperspace_build_spec_config() -> HyperspaceChainSpec { hyperspace_build_spec_genesis, vec![], Some( - TelemetryEndpoints::new(vec![(HYPERSPACE_TELEMETRY_URL.to_string(), 0)]) + TelemetryEndpoints::new(vec![(PANGOLIN_TELEMETRY_URL.to_string(), 0)]) .expect("Hyperspace telemetry url is valid; qed"), ), None, @@ -196,10 +196,10 @@ fn hyperspace_build_spec_genesis() -> GenesisConfig { hyperspace_claims: Some(Default::default()), hyperspace_vesting: Some(Default::default()), pallet_sudo: Some(SudoConfig { key: root.clone() }), - hyperspace_oldetp_issuing: Some(OldetpIssuingConfig { + hyperspace_oldna_issuing: Some(OldnaIssuingConfig { total_mapped_etp: 1 << 56 }), - hyperspace_oldetp_backing: Some(OldetpBackingConfig { + hyperspace_oldna_backing: Some(OldnaBackingConfig { backed_etp: 1 << 56 }), hyperspace_ethereum_backing: Some(EthereumBackingConfig { @@ -222,7 +222,7 @@ fn hyperspace_build_spec_genesis() -> GenesisConfig { ), ..Default::default() }), - hyperspace_oldna_backing: Some(OldnaBackingConfig { + hyperspace_oldetp_backing: Some(OldetpBackingConfig { backed_etp: 1 << 56, backed_dna: 1 << 56, }), @@ -367,10 +367,10 @@ fn hyperspace_development_genesis( }), hyperspace_vesting: Some(Default::default()), pallet_sudo: Some(SudoConfig { key: root_key.clone() }), - hyperspace_oldetp_issuing: Some(OldetpIssuingConfig { + hyperspace_oldna_issuing: Some(OldnaIssuingConfig { total_mapped_etp: 1 << 56 }), - hyperspace_oldetp_backing: Some(OldetpBackingConfig { + hyperspace_oldna_backing: Some(OldnaBackingConfig { backed_etp: 1 << 56 }), hyperspace_ethereum_backing: Some(EthereumBackingConfig { @@ -393,7 +393,7 @@ fn hyperspace_development_genesis( ), ..Default::default() }), - hyperspace_oldna_backing: Some(OldnaBackingConfig { + hyperspace_oldetp_backing: Some(OldetpBackingConfig { backed_etp: 1 << 56, backed_dna: 1 << 56, }), diff --git a/bin/node/cli/src/command.rs b/bin/node/cli/src/command.rs index 90af112..98cd1f8 100644 --- a/bin/node/cli/src/command.rs +++ b/bin/node/cli/src/command.rs @@ -30,7 +30,7 @@ use hyperspace_cli::{Configuration, HyperspaceCli}; impl SubstrateCli for Cli { fn impl_name() -> String { - "Hyperspace Runtime Module Library".into() + "Hyperspace Node".into() } fn impl_version() -> String { @@ -46,7 +46,7 @@ impl SubstrateCli for Cli { } fn support_url() -> String { - "https://github.com/mvs-org/Hyperspaceissues/new".into() + "https://github.com/mvs/Hyperspace/issues/new".into() } fn copyright_start_year() -> i32 { diff --git a/bin/node/cli/src/rpc.rs b/bin/node/cli/src/rpc.rs index e56c263..7c0feac 100644 --- a/bin/node/cli/src/rpc.rs +++ b/bin/node/cli/src/rpc.rs @@ -22,7 +22,7 @@ //! about the modules used inside the runtime, so do //! RPC methods defined in `sc-rpc` crate. //! It means that `client/rpc` can't have any methods that -//! need some soldnag assumptions about the particular runtime. +//! need some soldetpg assumptions about the particular runtime. //! //! The RPCs available in this crate however can make some assumptions //! about how the runtime is constructed and what FRAME pallets @@ -35,11 +35,9 @@ pub use sc_rpc::{DenyUnsafe, SubscriptionTaskExecutor}; // --- std --- -use std::{collections::BTreeMap, sync::Arc}; +use std::sync::Arc; // --- hyperspace --- -use dp_rpc::{FilterPool, PendingTransactions}; use hyperspace_primitives::{AccountId, Balance, BlockNumber, Hash, Nonce, OpaqueBlock as Block, Power}; -use dvm_ethereum::EthereumStorageSchema; /// A type representing all RPC extensions. pub type RpcExtension = jsonrpc_core::IoHandler; @@ -89,12 +87,6 @@ pub struct FullDeps { pub babe: BabeDeps, /// GRANDPA specific dependencies. pub grandpa: GrandpaDeps, - /// Ethereum pending transactions. - pub pending_transactions: PendingTransactions, - /// EthFilterApi pool. - pub filter_pool: Option, - /// Backend. - pub backend: Arc>, } /// Light client extra dependencies. @@ -150,10 +142,9 @@ where use hyperspace_balances_rpc::{Balances, BalancesApi}; use hyperspace_header_mmr_rpc::{HeaderMMR, HeaderMMRApi}; use hyperspace_staking_rpc::{Staking, StakingApi}; - use dc_rpc::{ - EthApi, EthApiServer, EthFilterApi, EthFilterApiServer, EthPubSubApi, EthPubSubApiServer, - HexEncodedIdProvider, NetApi, NetApiServer, SchemaV1Override, StorageOverride, Web3Api, - Web3ApiServer, + use dvm_rpc::{ + EthApi, EthApiServer, EthPubSubApi, EthPubSubApiServer, HexEncodedIdProvider, NetApi, + NetApiServer, Web3Api, Web3ApiServer, }; use hyperspace_runtime::TransactionConverter; @@ -167,9 +158,6 @@ where network, babe, grandpa, - pending_transactions, - filter_pool, - backend, } = deps; let mut io = jsonrpc_core::IoHandler::default(); @@ -218,30 +206,13 @@ where io.extend_with(BalancesApi::to_delegate(Balances::new(client.clone()))); io.extend_with(HeaderMMRApi::to_delegate(HeaderMMR::new(client.clone()))); io.extend_with(StakingApi::to_delegate(Staking::new(client.clone()))); - - let mut overrides = BTreeMap::new(); - overrides.insert( - EthereumStorageSchema::V1, - Box::new(SchemaV1Override::new(client.clone())) - as Box + Send + Sync>, - ); io.extend_with(EthApiServer::to_delegate(EthApi::new( client.clone(), pool.clone(), TransactionConverter, network.clone(), - overrides, - pending_transactions.clone(), - backend, is_authority, ))); - if let Some(filter_pool) = filter_pool { - io.extend_with(EthFilterApiServer::to_delegate(EthFilterApi::new( - client.clone(), - filter_pool.clone(), - 500 as usize, // max stored filters - ))); - } io.extend_with(EthPubSubApiServer::to_delegate(EthPubSubApi::new( pool, client.clone(), diff --git a/bin/node/cli/src/service.rs b/bin/node/cli/src/service.rs index 709dfef..6045257 100644 --- a/bin/node/cli/src/service.rs +++ b/bin/node/cli/src/service.rs @@ -24,17 +24,10 @@ pub use sc_executor::NativeExecutor; pub use hyperspace_runtime; // --- std --- -use std::{ - collections::{BTreeMap, HashMap}, - sync::{Arc, Mutex}, - time::Duration, -}; -// --- crates.io --- -use futures::StreamExt; +use std::{sync::Arc, time::Duration}; // --- substrate --- use sc_basic_authorship::ProposerFactory; -use sc_cli::SubstrateCli; -use sc_client_api::{BlockchainEvents, ExecutorProvider, RemoteBackend, StateBackendFor}; +use sc_client_api::{ExecutorProvider, RemoteBackend, StateBackendFor}; use sc_consensus::LongestChain; use sc_consensus_babe::{BabeBlockImport, BabeLink, BabeParams, Config as BabeConfig}; use sc_executor::{native_executor_instance, NativeExecutionDispatch}; @@ -47,7 +40,7 @@ use sc_keystore::LocalKeystore; use sc_network::NetworkService; use sc_service::{ config::{KeystoreConfig, PrometheusConfig}, - BasePath, BuildNetworkParams, Configuration, Error as ServiceError, NoopRpcExtensionBuilder, + BuildNetworkParams, Configuration, Error as ServiceError, NoopRpcExtensionBuilder, PartialComponents, RpcHandlers, SpawnTasksParams, TaskManager, }; use sc_telemetry::{TelemetryConnectionNotifier, TelemetrySpan}; @@ -65,12 +58,8 @@ use crate::rpc::{ self, BabeDeps, DenyUnsafe, FullDeps, GrandpaDeps, LightDeps, RpcExtension, SubscriptionTaskExecutor, }; -use dc_consensus::FrontierBlockImport; -use dc_db::{Backend, DatabaseSettings, DatabaseSettingsSrc}; -use dc_mapping_sync::MappingSyncWorker; -use dc_rpc::EthTask; -use dp_rpc::{FilterPool, PendingTransactions}; use hyperspace_primitives::{AccountId, Balance, Hash, Nonce, OpaqueBlock as Block, Power}; +use dvm_consensus::FrontierBlockImport; type FullBackend = sc_service::TFullBackend; type FullSelectChain = sc_consensus::LongestChain; @@ -133,9 +122,9 @@ where { } -/// HYPERSPACE client abstraction, this super trait only pulls in functionality required for -/// HYPERSPACE internal crates like HYPERSPACE-collator. -pub trait HYPERSPACEClient: +/// DRML client abstraction, this super trait only pulls in functionality required for +/// DRML internal crates like DRML-collator. +pub trait DRMLClient: Sized + Send + Sync @@ -149,7 +138,7 @@ where Runtime: sp_api::ConstructRuntimeApi, { } -impl HYPERSPACEClient for Client +impl DRMLClient for Client where Backend: sc_client_api::Backend, Block: sp_runtime::traits::Block, @@ -166,31 +155,12 @@ where fn set_prometheus_registry(config: &mut Configuration) -> Result<(), ServiceError> { if let Some(PrometheusConfig { registry, .. }) = config.prometheus_config.as_mut() { - *registry = Registry::new_custom(Some("HYPERSPACE".into()), None)?; + *registry = Registry::new_custom(Some("DRML".into()), None)?; } Ok(()) } -fn open_frontier_backend(config: &Configuration) -> Result>, String> { - let config_dir = config - .base_path - .as_ref() - .map(|base_path| base_path.config_dir(config.chain_spec.id())) - .unwrap_or_else(|| { - BasePath::from_project("", "", &crate::cli::Cli::executable_name()) - .config_dir(config.chain_spec.id()) - }); - let database_dir = config_dir.join("dvm").join("db"); - - Ok(Arc::new(Backend::::new(&DatabaseSettings { - source: DatabaseSettingsSrc::RocksDb { - path: database_dir, - cache_size: 0, - }, - })?)) -} - #[cfg(feature = "full-node")] fn new_partial( config: &mut Configuration, @@ -223,9 +193,6 @@ fn new_partial( ), GrandpaSharedVoterState, Option, - PendingTransactions, - Arc>, - Option, ), >, ServiceError, @@ -257,7 +224,6 @@ where task_manager.spawn_handle(), client.clone(), ); - let frontier_backend = open_frontier_backend(config)?; let grandpa_hard_forks = vec![]; let (grandpa_block_import, grandpa_link) = sc_finality_grandpa::block_import_with_authority_set_hard_forks( @@ -267,11 +233,8 @@ where grandpa_hard_forks, )?; let justification_import = grandpa_block_import.clone(); - let frontier_block_import = FrontierBlockImport::new( - grandpa_block_import.clone(), - client.clone(), - frontier_backend.clone(), - ); + let frontier_block_import = + FrontierBlockImport::new(grandpa_block_import.clone(), client.clone(), true); let (babe_import, babe_link) = sc_consensus_babe::block_import( BabeConfig::get_or_compute(&*client)?, frontier_block_import, @@ -300,17 +263,12 @@ where let babe_config = babe_link.config().clone(); let shared_epoch_changes = babe_link.epoch_changes().clone(); let subscription_task_executor = SubscriptionTaskExecutor::new(task_manager.spawn_handle()); - let pending_transactions: PendingTransactions = Some(Arc::new(Mutex::new(HashMap::new()))); - let filter_pool: Option = Some(Arc::new(Mutex::new(BTreeMap::new()))); let rpc_extensions_builder = { let client = client.clone(); let keystore = keystore_container.sync_keystore(); let transaction_pool = transaction_pool.clone(); let select_chain = select_chain.clone(); let chain_spec = config.chain_spec.cloned_box(); - let pending_transactions = pending_transactions.clone(); - let frontier_backend = frontier_backend.clone(); - let filter_pool = filter_pool.clone(); move |deny_unsafe, is_authority, network, subscription_executor| -> RpcExtension { let deps = FullDeps { @@ -333,9 +291,6 @@ where subscription_executor, finality_provider: finality_proof_provider.clone(), }, - pending_transactions: pending_transactions.clone(), - backend: frontier_backend.clone(), - filter_pool: filter_pool.clone(), }; rpc::create_full(deps, subscription_task_executor.clone()) @@ -356,9 +311,6 @@ where import_setup, rpc_setup, telemetry_span, - pending_transactions, - frontier_backend, - filter_pool, ), }) } @@ -405,16 +357,7 @@ where import_queue, transaction_pool, inherent_data_providers, - other: - ( - rpc_extensions_builder, - import_setup, - rpc_setup, - telemetry_span, - pending_transactions, - frontier_backend, - filter_pool, - ), + other: (rpc_extensions_builder, import_setup, rpc_setup, telemetry_span), } = new_partial::(&mut config)?; if let Some(url) = &config.keystore_remote { @@ -563,6 +506,7 @@ where } if role.is_authority() && !authority_discovery_disabled { + use futures::StreamExt; use sc_network::Event; let authority_discovery_role = @@ -590,41 +534,6 @@ where ); } - // Spawn Frontier pending transactions maintenance task (as essential, otherwise we leak). - if let Some(pending_transactions) = pending_transactions { - const TRANSACTION_RETAIN_THRESHOLD: u64 = 5; - task_manager.spawn_essential_handle().spawn( - "frontier-pending-transactions", - EthTask::pending_transaction_task( - Arc::clone(&client), - pending_transactions, - TRANSACTION_RETAIN_THRESHOLD, - ), - ); - } - - task_manager.spawn_essential_handle().spawn( - "frontier-mapping-sync-worker", - MappingSyncWorker::new( - client.import_notification_stream(), - Duration::new(6, 0), - client.clone(), - backend.clone(), - frontier_backend.clone(), - ) - .for_each(|()| futures::future::ready(())), - ); - - // Spawn Frontier EthFilterApi maintenance task. - if let Some(filter_pool) = filter_pool { - // Each filter is allowed to stay in the pool for 100 blocks. - const FILTER_RETAIN_THRESHOLD: u64 = 100; - task_manager.spawn_essential_handle().spawn( - "frontier-filter-pool", - EthTask::filter_pool_task(Arc::clone(&client), filter_pool, FILTER_RETAIN_THRESHOLD), - ); - } - network_starter.start_network(); Ok((task_manager, client, rpc_handlers)) @@ -771,7 +680,7 @@ where Ok((client, backend, import_queue, task_manager)) } -/// Create a new HYPERSPACE service for a full node. +/// Create a new DRML service for a full node. #[cfg(feature = "full-node")] pub fn hyperspace_new_full( config: Configuration, @@ -779,7 +688,7 @@ pub fn hyperspace_new_full( ) -> Result< ( TaskManager, - Arc>, + Arc>, RpcHandlers, ), ServiceError, @@ -792,7 +701,7 @@ pub fn hyperspace_new_full( Ok((components, client, rpc_handlers)) } -/// Create a new HYPERSPACE service for a light client. +/// Create a new DRML service for a light client. pub fn hyperspace_new_light( config: Configuration, ) -> Result< diff --git a/bin/node/primitives/Cargo.toml b/bin/node/primitives/Cargo.toml index 1bbd6dd..f6d2f99 100644 --- a/bin/node/primitives/Cargo.toml +++ b/bin/node/primitives/Cargo.toml @@ -1,18 +1,18 @@ [package] authors = ["Hyperspace Network "] -description = "HYPERSPACE node runtime primitives" +description = "DRML node runtime primitives" edition = "2018" homepage = "https://mvs.org/" license = "GPL-3.0" name = "hyperspace-primitives" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" +version = "1.0.13" [dependencies] # substrate -sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } [features] default = ["std"] diff --git a/bin/node/primitives/src/lib.rs b/bin/node/primitives/src/lib.rs index 4188cc9..30ba107 100644 --- a/bin/node/primitives/src/lib.rs +++ b/bin/node/primitives/src/lib.rs @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License // along with Hyperspace. If not, see . -//! HYPERSPACE types shared between the runtime and the Node-side code. +//! DRML types shared between the runtime and the Node-side code. #![cfg_attr(not(feature = "std"), no_std)] #![warn(missing_docs)] diff --git a/bin/node/runtime/hyperspace/Cargo.toml b/bin/node/runtime/hyperspace/Cargo.toml index f99987e..bca743e 100644 --- a/bin/node/runtime/hyperspace/Cargo.toml +++ b/bin/node/runtime/hyperspace/Cargo.toml @@ -6,8 +6,8 @@ homepage = "https://mvs.org/" license = "Unlicense" name = "hyperspace-runtime" readme = "README.md" -repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" +repository = "https://github.com/new-mvs/darwinia-common/" +version = "1.0.13" [dependencies] # crates @@ -19,8 +19,8 @@ static_assertions = { version = "1.1.0" } hyperspace-balances = { default-features = false, path = "../../../../frame/balances" } hyperspace-balances-rpc-runtime-api = { default-features = false, path = "../../../../frame/balances/rpc/runtime-api" } hyperspace-claims = { default-features = false, path = "../../../../frame/claims" } -hyperspace-oldetp-backing = { default-features = false, path = "../../../../frame/bridge/oldetp/backing" } -hyperspace-oldetp-issuing = { default-features = false, path = "../../../../frame/bridge/oldetp/issuing" } +hyperspace-oldna-backing = { default-features = false, path = "../../../../frame/bridge/oldna/backing" } +hyperspace-oldna-issuing = { default-features = false, path = "../../../../frame/bridge/oldna/issuing" } hyperspace-democracy = { default-features = false, path = "../../../../frame/democracy" } hyperspace-elections-phragmen = { default-features = false, path = "../../../../frame/elections-phragmen" } hyperspace-ethereum-backing = { default-features = false, path = "../../../../frame/bridge/ethereum/backing" } @@ -36,57 +36,54 @@ hyperspace-staking = { default-features = false, path = "../. hyperspace-staking-rpc-runtime-api = { default-features = false, path = "../../../../frame/staking/rpc/runtime-api" } hyperspace-support = { default-features = false, path = "../../../../frame/support" } hyperspace-treasury = { default-features = false, path = "../../../../frame/treasury" } -hyperspace-oldna-backing = { default-features = false, path = "../../../../frame/bridge/oldna/backing" } +hyperspace-oldetp-backing = { default-features = false, path = "../../../../frame/bridge/oldetp/backing" } hyperspace-vesting = { default-features = false, path = "../../../../frame/vesting" } hyperspace-primitives = { default-features = false, path = "../../primitives" } dvm-ethereum = { default-features = false, path = "../../../../frame/dvm" } dvm-rpc-runtime-api = { default-features = false, path = "../../../../frame/dvm/rpc/runtime-api" } ethereum-primitives = { default-features = false, path = "../../../../primitives/ethereum-primitives" } # substrate -frame-executive = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -frame-system-rpc-runtime-api = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -pallet-authority-discovery = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -pallet-authorship = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -pallet-babe = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -pallet-collective = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -pallet-grandpa = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -pallet-identity = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -pallet-im-online = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -pallet-membership = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -pallet-multisig = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -pallet-offences = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -pallet-proxy = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -pallet-randomness-collective-flip = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -pallet-recovery = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -pallet-scheduler = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -pallet-session = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -pallet-society = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -pallet-sudo = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -pallet-timestamp = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -pallet-transaction-payment = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -pallet-transaction-payment-rpc-runtime-api = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -pallet-utility = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-api = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-application-crypto = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-authority-discovery = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-block-builder = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-consensus-babe = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-inherents = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-offchain = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-session = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-staking = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-transaction-pool = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-version = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +frame-executive = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +frame-system-rpc-runtime-api = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +pallet-authority-discovery = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +pallet-authorship = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +pallet-babe = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +pallet-collective = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +pallet-grandpa = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +pallet-im-online = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +pallet-membership = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +# Multisig +pallet-multisig = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +pallet-offences = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +pallet-proxy = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +pallet-randomness-collective-flip = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +pallet-scheduler = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +pallet-session = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +pallet-sudo = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +pallet-timestamp = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +pallet-transaction-payment = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +pallet-transaction-payment-rpc-runtime-api = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-api = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-application-crypto = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-authority-discovery = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-block-builder = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-consensus-babe = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-inherents = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-offchain = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-session = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-staking = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-transaction-pool = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-version = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } [build-dependencies] # substrate -substrate-wasm-builder = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +substrate-wasm-builder = { git = "https://github.com/new-mvs/substrate", branch = "latest" } [features] default = ["std"] @@ -96,8 +93,8 @@ std = [ "hyperspace-balances/std", "hyperspace-balances-rpc-runtime-api/std", "hyperspace-claims/std", - "hyperspace-oldetp-backing/std", - "hyperspace-oldetp-issuing/std", + "hyperspace-oldna-backing/std", + "hyperspace-oldna-issuing/std", "hyperspace-democracy/std", "hyperspace-elections-phragmen/std", "hyperspace-ethereum-backing/std", @@ -113,7 +110,7 @@ std = [ "hyperspace-staking-rpc-runtime-api/std", "hyperspace-support/std", "hyperspace-treasury/std", - "hyperspace-oldna-backing/std", + "hyperspace-oldetp-backing/std", "hyperspace-vesting/std", "hyperspace-primitives/std", "dvm-ethereum/std", @@ -128,22 +125,18 @@ std = [ "pallet-babe/std", "pallet-collective/std", "pallet-grandpa/std", - "pallet-identity/std", "pallet-im-online/std", "pallet-membership/std", "pallet-multisig/std", "pallet-offences/std", "pallet-proxy/std", "pallet-randomness-collective-flip/std", - "pallet-recovery/std", "pallet-scheduler/std", "pallet-session/std", - "pallet-society/std", "pallet-sudo/std", "pallet-timestamp/std", "pallet-transaction-payment/std", "pallet-transaction-payment-rpc-runtime-api/std", - "pallet-utility/std", "sp-api/std", "sp-application-crypto/std", "sp-authority-discovery/std", diff --git a/bin/node/runtime/hyperspace/src/authority_discovery.rs b/bin/node/runtime/hyperspace/src/authority_discovery.rs deleted file mode 100644 index 332ab36..0000000 --- a/bin/node/runtime/hyperspace/src/authority_discovery.rs +++ /dev/null @@ -1,6 +0,0 @@ -// --- substrate --- -use pallet_authority_discovery::Config; -// --- hyperspace --- -use crate::*; - -impl Config for Runtime {} diff --git a/bin/node/runtime/hyperspace/src/authorship.rs b/bin/node/runtime/hyperspace/src/authorship.rs deleted file mode 100644 index 6476ce7..0000000 --- a/bin/node/runtime/hyperspace/src/authorship.rs +++ /dev/null @@ -1,15 +0,0 @@ -// --- substrate --- -use pallet_authorship::Config; -use pallet_session::FindAccountFromAuthorIndex; -// --- hyperspace --- -use crate::*; - -frame_support::parameter_types! { - pub const UncleGenerations: BlockNumber = 5; -} -impl Config for Runtime { - type FindAuthor = FindAccountFromAuthorIndex; - type UncleGenerations = UncleGenerations; - type FilterUncle = (); - type EventHandler = (Staking, ImOnline); -} diff --git a/bin/node/runtime/hyperspace/src/babe.rs b/bin/node/runtime/hyperspace/src/babe.rs deleted file mode 100644 index 394a5f8..0000000 --- a/bin/node/runtime/hyperspace/src/babe.rs +++ /dev/null @@ -1,25 +0,0 @@ -// --- substrate --- -use frame_support::traits::KeyOwnerProofSystem; -use pallet_babe::{AuthorityId, Config, EquivocationHandler, ExternalTrigger}; -use sp_core::crypto::KeyTypeId; -// --- hyperspace --- -use crate::*; - -frame_support::parameter_types! { - pub const EpochDuration: u64 = BLOCKS_PER_SESSION as _; - pub const ExpectedBlockTime: Moment = MILLISECS_PER_BLOCK; -} -impl Config for Runtime { - type EpochDuration = EpochDuration; - type ExpectedBlockTime = ExpectedBlockTime; - type EpochChangeTrigger = ExternalTrigger; - type KeyOwnerProofSystem = Historical; - type KeyOwnerProof = - >::Proof; - type KeyOwnerIdentification = >::IdentificationTuple; - type HandleEquivocation = EquivocationHandler; - type WeightInfo = (); -} diff --git a/bin/node/runtime/hyperspace/src/balances.rs b/bin/node/runtime/hyperspace/src/balances.rs deleted file mode 100644 index 16277e2..0000000 --- a/bin/node/runtime/hyperspace/src/balances.rs +++ /dev/null @@ -1,40 +0,0 @@ -// --- hyperspace --- -pub use hyperspace_balances::{Instance0 as EtpInstance, Instance1 as DnaInstance}; - -// --- substrate --- -use frame_support::traits::Currency; -use frame_system::Config as SystemConfig; -// --- hyperspace --- -use crate::*; -use hyperspace_balances::{weights::SubstrateWeight, Config, Module}; - -pub type NegativeImbalance = as Currency< - ::AccountId, ->>::NegativeImbalance; - -frame_support::parameter_types! { - pub const ExistentialDeposit: Balance = 0; - pub const MaxLocks: u32 = 50; -} -impl Config for Runtime { - type Balance = Balance; - type DustRemoval = (); - type Event = Event; - type ExistentialDeposit = ExistentialDeposit; - type BalanceInfo = AccountData; - type AccountStore = System; - type MaxLocks = MaxLocks; - type OtherCurrencies = (Dna,); - type WeightInfo = SubstrateWeight; -} -impl Config for Runtime { - type Balance = Balance; - type DustRemoval = (); - type Event = Event; - type ExistentialDeposit = ExistentialDeposit; - type BalanceInfo = AccountData; - type AccountStore = System; - type MaxLocks = MaxLocks; - type OtherCurrencies = (Etp,); - type WeightInfo = SubstrateWeight; -} diff --git a/bin/node/runtime/hyperspace/src/claims.rs b/bin/node/runtime/hyperspace/src/claims.rs deleted file mode 100644 index 658bbd4..0000000 --- a/bin/node/runtime/hyperspace/src/claims.rs +++ /dev/null @@ -1,17 +0,0 @@ -// --- substrate --- -use sp_runtime::ModuleId; -// --- hyperspace --- -use crate::*; -use hyperspace_claims::Config; - -frame_support::parameter_types! { - pub const ClaimsModuleId: ModuleId = ModuleId(*b"da/claim"); - pub Prefix: &'static [u8] = b"Pay PETPs to the Hyperspace account:"; -} -impl Config for Runtime { - type Event = Event; - type ModuleId = ClaimsModuleId; - type Prefix = Prefix; - type EtpCurrency = Etp; - type MoveClaimOrigin = EnsureRootOrMoreThanHalfCouncil; -} diff --git a/bin/node/runtime/hyperspace/src/collective.rs b/bin/node/runtime/hyperspace/src/collective.rs deleted file mode 100644 index 396523f..0000000 --- a/bin/node/runtime/hyperspace/src/collective.rs +++ /dev/null @@ -1,65 +0,0 @@ -// --- substrate --- -pub use pallet_collective::{Instance0 as CouncilCollective, Instance1 as TechnicalCollective}; - -// --- substrate --- -use frame_system::{EnsureOneOf, EnsureRoot}; -use pallet_collective::{ - weights::SubstrateWeight, Config, EnsureProportionAtLeast, EnsureProportionMoreThan, - PrimeDefaultVote, -}; -use sp_core::u32_trait::{_1, _2, _3, _5}; -// --- hyperspace --- -use crate::*; - -pub type EnsureRootOrHalfCouncil = EnsureOneOf< - AccountId, - EnsureRoot, - EnsureProportionAtLeast<_1, _2, AccountId, CouncilCollective>, ->; -pub type EnsureRootOrMoreThanHalfCouncil = EnsureOneOf< - AccountId, - EnsureRoot, - EnsureProportionMoreThan<_1, _2, AccountId, CouncilCollective>, ->; -pub type EnsureRootOrHalfTechnicalComittee = EnsureOneOf< - AccountId, - EnsureRoot, - EnsureProportionMoreThan<_1, _2, AccountId, TechnicalCollective>, ->; - -pub type ApproveOrigin = EnsureOneOf< - AccountId, - EnsureRoot, - EnsureProportionAtLeast<_3, _5, AccountId, CouncilCollective>, ->; - -frame_support::parameter_types! { - pub const CouncilMotionDuration: BlockNumber = 3 * MINUTES; - pub const CouncilMaxProposals: u32 = 100; - pub const CouncilMaxMembers: u32 = 100; - pub const TechnicalMotionDuration: BlockNumber = 3 * MINUTES; - pub const TechnicalMaxProposals: u32 = 100; - pub const TechnicalMaxMembers: u32 = 100; -} -// Make sure that there are no more than `MaxMembers` members elected via elections-phragmen. -static_assertions::const_assert!(DesiredMembers::get() <= CouncilMaxMembers::get()); -impl Config for Runtime { - type Origin = Origin; - type Proposal = Call; - type Event = Event; - type MotionDuration = CouncilMotionDuration; - type MaxProposals = CouncilMaxProposals; - type MaxMembers = CouncilMaxMembers; - type DefaultVote = PrimeDefaultVote; - type WeightInfo = SubstrateWeight; -} -impl Config for Runtime { - type Origin = Origin; - type Proposal = Call; - type Event = Event; - type MotionDuration = TechnicalMotionDuration; - type MaxProposals = TechnicalMaxProposals; - type MaxMembers = TechnicalMaxMembers; - type DefaultVote = PrimeDefaultVote; - type WeightInfo = SubstrateWeight; -} diff --git a/bin/node/runtime/hyperspace/src/democracy.rs b/bin/node/runtime/hyperspace/src/democracy.rs deleted file mode 100644 index 56d9d97..0000000 --- a/bin/node/runtime/hyperspace/src/democracy.rs +++ /dev/null @@ -1,64 +0,0 @@ -// --- substrate --- -use frame_system::{EnsureOneOf, EnsureRoot}; -use pallet_collective::{EnsureMember, EnsureProportionAtLeast}; -use sp_core::u32_trait::{_1, _2, _3}; -// --- hyperspace --- -use crate::*; -use hyperspace_democracy::{weights::SubstrateWeight, Config}; - -frame_support::parameter_types! { - pub const LaunchPeriod: BlockNumber = 3 * MINUTES; - pub const VotingPeriod: BlockNumber = 3 * MINUTES; - pub const FastTrackVotingPeriod: BlockNumber = 3 * MINUTES; - pub const MinimumDeposit: Balance = 1 * COIN; - pub const EnactmentPeriod: BlockNumber = 3 * MINUTES; - pub const CooloffPeriod: BlockNumber = 3 * MINUTES; - pub const PreimageByteDeposit: Balance = 1 * MILLI; - pub const InstantAllowed: bool = true; - pub const MaxVotes: u32 = 100; - pub const MaxProposals: u32 = 100; -} -impl Config for Runtime { - type Proposal = Call; - type Event = Event; - type Currency = Etp; - type EnactmentPeriod = EnactmentPeriod; - type LaunchPeriod = LaunchPeriod; - type VotingPeriod = VotingPeriod; - type MinimumDeposit = MinimumDeposit; - /// A straight majority of the council can decide what their next motion is. - type ExternalOrigin = EnsureRootOrHalfCouncil; - /// A majority can have the next scheduled referendum be a straight majority-carries vote. - type ExternalMajorityOrigin = EnsureRootOrHalfCouncil; - /// A unanimous council can have the next scheduled referendum be a straight default-carries - /// (NTB) vote. - type ExternalDefaultOrigin = EnsureProportionAtLeast<_1, _1, AccountId, CouncilCollective>; - /// Two thirds of the technical committee can have an ExternalMajority/ExternalDefault vote - /// be tabled immediately and with a shorter voting/enactment period. - type FastTrackOrigin = EnsureProportionAtLeast<_2, _3, AccountId, TechnicalCollective>; - type InstantOrigin = EnsureProportionAtLeast<_1, _1, AccountId, TechnicalCollective>; - 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 = EnsureProportionAtLeast<_2, _3, AccountId, CouncilCollective>; - // To cancel a proposal before it has been passed, the technical committee must be unanimous or - // Root must agree. - type CancelProposalOrigin = EnsureOneOf< - AccountId, - EnsureRoot, - EnsureProportionAtLeast<_1, _1, AccountId, TechnicalCollective>, - >; - 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 = EnsureMember; - type CooloffPeriod = CooloffPeriod; - type PreimageByteDeposit = PreimageByteDeposit; - type Slash = Treasury; - type Scheduler = Scheduler; - type PalletsOrigin = OriginCaller; - type MaxVotes = MaxVotes; - type OperationalPreimageOrigin = EnsureMember; - type MaxProposals = MaxProposals; - type WeightInfo = SubstrateWeight; -} diff --git a/bin/node/runtime/hyperspace/src/dvm.rs b/bin/node/runtime/hyperspace/src/dvm.rs deleted file mode 100644 index e62fc5b..0000000 --- a/bin/node/runtime/hyperspace/src/dvm.rs +++ /dev/null @@ -1,31 +0,0 @@ -// --- substrate --- -use frame_support::{traits::FindAuthor, ConsensusEngineId}; -use sp_core::{crypto::Public, H160, U256}; -// --- hyperspace --- -use crate::*; - -use dvm_ethereum::{Config, IntermediateStateRoot}; - -pub struct EthereumFindAuthor(sp_std::marker::PhantomData); -impl> FindAuthor for EthereumFindAuthor { - fn find_author<'a, I>(digests: I) -> Option - where - I: 'a + IntoIterator, - { - if let Some(author_index) = F::find_author(digests) { - let authority_id = Babe::authorities()[author_index as usize].clone(); - return Some(H160::from_slice(&authority_id.0.to_raw_vec()[4..24])); - } - None - } -} -frame_support::parameter_types! { - pub BlockGasLimit: U256 = U256::from(u32::max_value()); -} -impl Config for Runtime { - type Event = Event; - type FindAuthor = EthereumFindAuthor; - type StateRoot = IntermediateStateRoot; - type BlockGasLimit = BlockGasLimit; - type EtpCurrency = Etp; -} diff --git a/bin/node/runtime/hyperspace/src/elections_phragmen.rs b/bin/node/runtime/hyperspace/src/elections_phragmen.rs deleted file mode 100644 index ba3b5eb..0000000 --- a/bin/node/runtime/hyperspace/src/elections_phragmen.rs +++ /dev/null @@ -1,38 +0,0 @@ -// --- substrate --- -use frame_support::traits::{LockIdentifier, U128CurrencyToVote}; -// --- hyperspace --- -use crate::*; -use hyperspace_elections_phragmen::{weights::SubstrateWeight, Config}; - -frame_support::parameter_types! { - pub const ElectionsPhragmenModuleId: LockIdentifier = *b"da/phrel"; - pub const CandidacyBond: Balance = 1 * COIN; - // 1 storage item created, key size is 32 bytes, value size is 16+16. - pub const VotingBondBase: Balance = constants::deposit(1, 64); - // additional data per vote is 32 bytes (account id). - pub const VotingBondFactor: Balance = constants::deposit(0, 32); - pub const DesiredMembers: u32 = 13; - pub const DesiredRunnersUp: u32 = 7; - /// Daily council elections. - pub const TermDuration: BlockNumber = 3 * MINUTES; -} - -impl Config for Runtime { - type Event = Event; - type ModuleId = ElectionsPhragmenModuleId; - type Currency = Etp; - type ChangeMembers = Council; - // NOTE: this implies that council's genesis members cannot be set directly and must come from - // this module. - type InitializeMembers = Council; - type CurrencyToVote = U128CurrencyToVote; - type CandidacyBond = CandidacyBond; - type VotingBondBase = VotingBondBase; - type VotingBondFactor = VotingBondFactor; - type LoserCandidate = Treasury; - type KickedMember = Treasury; - type DesiredMembers = DesiredMembers; - type DesiredRunnersUp = DesiredRunnersUp; - type TermDuration = TermDuration; - type WeightInfo = SubstrateWeight; -} diff --git a/bin/node/runtime/hyperspace/src/ethereum_backing.rs b/bin/node/runtime/hyperspace/src/ethereum_backing.rs deleted file mode 100644 index cc2f1d9..0000000 --- a/bin/node/runtime/hyperspace/src/ethereum_backing.rs +++ /dev/null @@ -1,30 +0,0 @@ -// --- substrate --- -use sp_runtime::ModuleId; -// --- hyperspace --- -use crate::*; -use hyperspace_ethereum_backing::Config; - -frame_support::parameter_types! { - pub const EthereumBackingModuleId: ModuleId = ModuleId(*b"da/ethbk"); - pub const EthereumBackingFeeModuleId: ModuleId = ModuleId(*b"da/ethfe"); - pub const EtpLockLimit: Balance = 10_000_000 * COIN; - pub const DnaLockLimit: Balance = 1000 * COIN; - pub const AdvancedFee: Balance = 50 * COIN; - pub const SyncReward: Balance = 1000 * COIN; -} -impl Config for Runtime { - type ModuleId = EthereumBackingModuleId; - type FeeModuleId = EthereumBackingFeeModuleId; - type Event = Event; - type RedeemAccountId = AccountId; - type EthereumRelay = EthereumRelay; - type OnDepositRedeem = Staking; - type EtpCurrency = Etp; - type DnaCurrency = Dna; - type EtpLockLimit = EtpLockLimit; - type DnaLockLimit = DnaLockLimit; - type AdvancedFee = AdvancedFee; - type SyncReward = SyncReward; - type EcdsaAuthorities = EthereumRelayAuthorities; - type WeightInfo = (); -} diff --git a/bin/node/runtime/hyperspace/src/ethereum_relay.rs b/bin/node/runtime/hyperspace/src/ethereum_relay.rs deleted file mode 100644 index eaec29e..0000000 --- a/bin/node/runtime/hyperspace/src/ethereum_relay.rs +++ /dev/null @@ -1,29 +0,0 @@ -// --- substrate --- -use sp_runtime::{ModuleId, Perbill}; -// --- hyperspace --- -use crate::*; -use hyperspace_ethereum_relay::Config; -use ethereum_primitives::EthereumNetworkType; - -frame_support::parameter_types! { - pub const EthereumRelayModuleId: ModuleId = ModuleId(*b"da/ethrl"); - pub const EthereumNetwork: EthereumNetworkType = EthereumNetworkType::Ropsten; - pub const ConfirmPeriod: BlockNumber = 30; - pub const ApproveThreshold: Perbill = Perbill::from_percent(60); - pub const RejectThreshold: Perbill = Perbill::from_percent(1); -} -impl Config for Runtime { - type ModuleId = EthereumRelayModuleId; - type Event = Event; - type EthereumNetwork = EthereumNetwork; - type Call = Call; - type Currency = Etp; - type RelayerGame = EthereumRelayerGame; - type ApproveOrigin = ApproveOrigin; - type RejectOrigin = EnsureRootOrHalfTechnicalComittee; - type ConfirmPeriod = ConfirmPeriod; - type TechnicalMembership = TechnicalMembership; - type ApproveThreshold = ApproveThreshold; - type RejectThreshold = RejectThreshold; - type WeightInfo = (); -} diff --git a/bin/node/runtime/hyperspace/src/evm.rs b/bin/node/runtime/hyperspace/src/evm.rs deleted file mode 100644 index 38667cb..0000000 --- a/bin/node/runtime/hyperspace/src/evm.rs +++ /dev/null @@ -1,35 +0,0 @@ -// --- substrate --- -use sp_core::U256; -// --- hyperspace --- -use crate::*; -use hyperspace_evm::{ - runner::stack::Runner, ConcatAddressMapping, Config, EnsureAddressTruncated, FeeCalculator, -}; -use hyperspace_evm_precompile::HyperspacePrecompiles; -use dvm_ethereum::account_basic::DVMAccountBasicMapping; - -/// Fixed gas price of `1`. -pub struct FixedGasPrice; -impl FeeCalculator for FixedGasPrice { - fn min_gas_price() -> U256 { - // Gas price is always one token per gas. - 10_000_000_000u64.into() - } -} -frame_support::parameter_types! { - pub const ChainId: u64 mc= 23; -} -impl Config for Runtime { - type FeeCalculator = FixedGasPrice; - type GasWeightMapping = (); - type CallOrigin = EnsureAddressTruncated; - type WithdrawOrigin = EnsureAddressTruncated; - type AddressMapping = ConcatAddressMapping; - type EtpCurrency = Etp; - type DnaCurrency = Dna; - type Event = Event; - type Precompiles = HyperspacePrecompiles; - type ChainId = ChainId; - type AccountBasicMapping = DVMAccountBasicMapping; - type Runner = Runner; -} diff --git a/bin/node/runtime/hyperspace/src/grandpa.rs b/bin/node/runtime/hyperspace/src/grandpa.rs deleted file mode 100644 index 8046c13..0000000 --- a/bin/node/runtime/hyperspace/src/grandpa.rs +++ /dev/null @@ -1,20 +0,0 @@ -// --- substrate --- -use frame_support::traits::KeyOwnerProofSystem; -use pallet_grandpa::{AuthorityId, Config, EquivocationHandler}; -use sp_core::crypto::KeyTypeId; -// --- hyperspace --- -use crate::*; - -impl Config for Runtime { - type Event = Event; - type Call = Call; - type KeyOwnerProof = - >::Proof; - type KeyOwnerIdentification = >::IdentificationTuple; - type KeyOwnerProofSystem = Historical; - type HandleEquivocation = EquivocationHandler; - type WeightInfo = (); -} diff --git a/bin/node/runtime/hyperspace/src/header_mmr.rs b/bin/node/runtime/hyperspace/src/header_mmr.rs deleted file mode 100644 index 1cf0c01..0000000 --- a/bin/node/runtime/hyperspace/src/header_mmr.rs +++ /dev/null @@ -1,5 +0,0 @@ -// --- hyperspace --- -use crate::*; -use hyperspace_header_mmr::Config; - -impl Config for Runtime {} diff --git a/bin/node/runtime/hyperspace/src/identity.rs b/bin/node/runtime/hyperspace/src/identity.rs deleted file mode 100644 index ed4567c..0000000 --- a/bin/node/runtime/hyperspace/src/identity.rs +++ /dev/null @@ -1,28 +0,0 @@ -// --- substrate --- -use pallet_identity::Config; -// --- hyperspace --- -use crate::*; - -frame_support::parameter_types! { - // Minimum 100 bytes/PETP deposited (1 MILLI/byte) - pub const BasicDeposit: Balance = 10 * COIN; // 258 bytes on-chain - pub const FieldDeposit: Balance = 250 * MILLI; // 66 bytes on-chain - pub const SubAccountDeposit: Balance = 2 * COIN; // 53 bytes on-chain - pub const MaxSubAccounts: u32 = 100; - pub const MaxAdditionalFields: u32 = 100; - pub const MaxRegistrars: u32 = 20; -} -impl Config for Runtime { - type Event = Event; - type Currency = Etp; - type BasicDeposit = BasicDeposit; - type FieldDeposit = FieldDeposit; - type SubAccountDeposit = SubAccountDeposit; - type MaxSubAccounts = MaxSubAccounts; - type MaxAdditionalFields = MaxAdditionalFields; - type MaxRegistrars = MaxRegistrars; - type Slashed = Treasury; - type ForceOrigin = EnsureRootOrMoreThanHalfCouncil; - type RegistrarOrigin = EnsureRootOrMoreThanHalfCouncil; - type WeightInfo = (); -} diff --git a/bin/node/runtime/hyperspace/src/im_online.rs b/bin/node/runtime/hyperspace/src/im_online.rs deleted file mode 100644 index 811128f..0000000 --- a/bin/node/runtime/hyperspace/src/im_online.rs +++ /dev/null @@ -1,18 +0,0 @@ -// --- substrate --- -use pallet_im_online::{sr25519::AuthorityId, weights::SubstrateWeight, Config}; -use sp_runtime::transaction_validity::TransactionPriority; -// --- hyperspace --- -use crate::*; - -frame_support::parameter_types! { - pub const SessionDuration: BlockNumber = BLOCKS_PER_SESSION as _; - pub const ImOnlineUnsignedPriority: TransactionPriority = TransactionPriority::max_value(); -} -impl Config for Runtime { - type AuthorityId = AuthorityId; - type Event = Event; - type SessionDuration = SessionDuration; - type ReportUnresponsiveness = Offences; - type UnsignedPriority = ImOnlineUnsignedPriority; - type WeightInfo = SubstrateWeight; -} diff --git a/bin/node/runtime/hyperspace/src/lib.rs b/bin/node/runtime/hyperspace/src/lib.rs index 079e250..1cd7985 100644 --- a/bin/node/runtime/hyperspace/src/lib.rs +++ b/bin/node/runtime/hyperspace/src/lib.rs @@ -23,8 +23,6 @@ #![recursion_limit = "256"] pub mod constants { - // --- substrate --- - use sp_staking::SessionIndex; // --- hyperspace --- use crate::*; @@ -36,16 +34,16 @@ pub mod constants { pub const CAP: Balance = 10_000_000_000 * COIN; pub const TOTAL_POWER: Power = 1_000_000_000; - // Time is measured by number of blocks. - pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber); - pub const HOURS: BlockNumber = 60 * MINUTES; - pub const DAYS: BlockNumber = 24 * HOURS; - pub const MILLISECS_PER_BLOCK: Moment = 23000; pub const SLOT_DURATION: Moment = MILLISECS_PER_BLOCK; pub const BLOCKS_PER_SESSION: BlockNumber = 2057 * MINUTES; pub const SESSIONS_PER_ERA: SessionIndex = 6; + // Time is measured by number of blocks. + pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber); + pub const HOURS: BlockNumber = 60 * MINUTES; + pub const DAYS: BlockNumber = 24 * HOURS; + // 1 in 4 blocks (on average, not counting collisions) will be primary babe blocks. pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4); @@ -166,7 +164,6 @@ pub mod impls { impl WeightToFeePolynomial for WeightToFee { type Balance = Balance; fn polynomial() -> WeightToFeeCoefficients { - // in Oldetp, extrinsic base weight (smallest non-zero weight) is mapped to 100 MILLI: let p = 100 * MILLI; let q = Balance::from(ExtrinsicBaseWeight::get()); smallvec![WeightToFeeCoefficient { @@ -204,160 +201,74 @@ pub mod wasm { } } -pub mod system; -pub use system::*; - -pub mod babe; -pub use babe::*; - -pub mod timestamp; -pub use timestamp::*; - -pub mod balances; -pub use balances::*; - -pub mod transaction_payment; -pub use transaction_payment::*; - -pub mod authorship; -pub use authorship::*; - -pub mod staking; -pub use staking::*; - -pub mod offences; -pub use offences::*; - -pub mod session_historical; -pub use session_historical::*; - -pub mod session; -pub use session::*; - -pub mod grandpa; -pub use grandpa::*; - -pub mod im_online; -pub use im_online::*; - -pub mod authority_discovery; -pub use authority_discovery::*; - -pub mod democracy; -pub use democracy::*; - -pub mod collective; -pub use collective::*; - -pub mod elections_phragmen; -pub use elections_phragmen::*; - -pub mod membership; -pub use membership::*; - -pub mod treasury; -pub use treasury::*; - -pub mod sudo; -pub use sudo::*; - -pub mod claims; -pub use claims::*; - -pub mod vesting; -pub use vesting::*; - -pub mod utility; -pub use utility::*; - -pub mod identity; -pub use identity::*; - -pub mod society; -pub use society::*; - -pub mod recovery; -pub use recovery::*; - -pub mod scheduler; -pub use scheduler::*; - -pub mod proxy; -pub use proxy::*; - -pub mod multisig; -pub use multisig::*; - -pub mod header_mmr; -pub use header_mmr::*; - -pub mod oldetp_issuing; -pub use oldetp_issuing::*; - -pub mod oldetp_backing; -pub use oldetp_backing::*; - -pub mod ethereum_relay; -pub use ethereum_relay::*; - -pub mod ethereum_backing; -pub use ethereum_backing::*; - -pub mod relayer_game; -pub use relayer_game::*; - -pub mod relay_authorities; -pub use relay_authorities::*; - -pub mod oldna_backing; -pub use oldna_backing::*; - -pub mod evm; -pub use evm::*; - -pub mod dvm; -pub use dvm::*; - // --- hyperspace --- -pub use constants::*; -use hyperspace_evm::{Account as EVMAccount, FeeCalculator}; +use hyperspace_evm::{ + Account as EVMAccount, AccountBasicMapping, EnsureAddressTruncated, FeeCalculator, +}; pub use hyperspace_staking::StakerStatus; -pub use hyperspace_primitives::*; -pub use impls::*; pub use wasm::*; // --- crates --- use codec::{Decode, Encode}; +use static_assertions::const_assert; // --- substrate --- use frame_support::{ - debug, - traits::{KeyOwnerProofSystem, Randomness}, - weights::constants::ExtrinsicBaseWeight, + construct_runtime, debug, parameter_types, + traits::{ + ChangeMembers, Currency, FindAuthor, InstanceFilter, KeyOwnerProofSystem, LockIdentifier, + Randomness, U128CurrencyToVote, + }, + weights::{ + constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND}, + DispatchClass, Weight, + }, + ConsensusEngineId, +}; +use frame_system::{ + limits::{BlockLength, BlockWeights}, + EnsureOneOf, EnsureRoot, }; use pallet_grandpa::{ fg_primitives, AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList, }; -use pallet_transaction_payment::FeeDetails; +use pallet_im_online::sr25519::AuthorityId as ImOnlineId; +use pallet_session::historical as pallet_session_historical; +use pallet_transaction_payment::{CurrencyAdapter, FeeDetails, Multiplier, TargetedFeeAdjustment}; use pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo as TransactionPaymentRuntimeDispatchInfo; use sp_api::impl_runtime_apis; use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; -use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H160, H256, U256}; +use sp_core::{ + crypto::{KeyTypeId, Public}, + u32_trait::{_1, _2, _3, _5}, + OpaqueMetadata, H160, H256, U256, +}; use sp_runtime::{ - create_runtime_str, generic, - traits::{Block as BlockT, NumberFor, SaturatedConversion, StaticLookup}, - transaction_validity::{TransactionSource, TransactionValidity}, - ApplyExtrinsicResult, MultiAddress, OpaqueExtrinsic, Perbill, RuntimeDebug, + create_runtime_str, generic, impl_opaque_keys, + traits::{ + AccountIdLookup, BlakeTwo256, Block as BlockT, ConvertInto, NumberFor, OpaqueKeys, + SaturatedConversion, StaticLookup, + }, + transaction_validity::{TransactionPriority, TransactionSource, TransactionValidity}, + ApplyExtrinsicResult, FixedPointNumber, ModuleId, MultiAddress, OpaqueExtrinsic, Perbill, + Percent, Permill, Perquintill, RuntimeDebug, }; +use sp_staking::SessionIndex; use sp_std::prelude::*; #[cfg(feature = "std")] use sp_version::NativeVersion; use sp_version::RuntimeVersion; // --- hyperspace --- +use constants::*; use hyperspace_balances_rpc_runtime_api::RuntimeDispatchInfo as BalancesRuntimeDispatchInfo; -use hyperspace_evm::Runner; +use hyperspace_evm::{ConcatAddressMapping, Runner}; use hyperspace_header_mmr_rpc_runtime_api::RuntimeDispatchInfo as HeaderMMRRuntimeDispatchInfo; +use hyperspace_relay_primitives::relay_authorities::OpCode; +use hyperspace_staking::EraIndex; use hyperspace_staking_rpc_runtime_api::RuntimeDispatchInfo as StakingRuntimeDispatchInfo; +use hyperspace_primitives::*; +use dvm_ethereum::account_basic::DVMAccountBasicMapping; use dvm_rpc_runtime_api::TransactionStatus; +use impls::*; /// The address format for describing accounts. type Address = MultiAddress; @@ -391,15 +302,19 @@ type SignedPayload = generic::SignedPayload; type Etp = Balances; +type NegativeImbalance = as Currency< + ::AccountId, +>>::NegativeImbalance; + /// This runtime version. pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("Hyperspace"), impl_name: create_runtime_str!("Hyperspace"), authoring_version: 1, - spec_version: 200, + spec_version: 19, impl_version: 1, apis: RUNTIME_API_VERSIONS, - transaction_version: 1, + transaction_version: 2, }; /// The version information used to identify this runtime when compiled natively. @@ -411,7 +326,843 @@ pub fn native_version() -> NativeVersion { } } -frame_support::construct_runtime! { +/// We assume that an on-initialize consumes 2.5% of the weight on average, hence a single extrinsic +/// will not be allowed to consume more than `AvailableBlockRatio - 2.5%`. +const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(25); +/// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used +/// by Operational extrinsics. +const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); +/// We allow for 2 seconds of compute with a 6 second average block time. +const MAXIMUM_BLOCK_WEIGHT: Weight = 2 * WEIGHT_PER_SECOND; +const_assert!(NORMAL_DISPATCH_RATIO.deconstruct() >= AVERAGE_ON_INITIALIZE_RATIO.deconstruct()); +parameter_types! { + pub const BlockHashCount: BlockNumber = 2400; + pub const Version: RuntimeVersion = VERSION; + pub RuntimeBlockLength: BlockLength = + BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO); + pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder() + .base_block(BlockExecutionWeight::get()) + .for_class(DispatchClass::all(), |weights| { + weights.base_extrinsic = ExtrinsicBaseWeight::get(); + }) + .for_class(DispatchClass::Normal, |weights| { + weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT); + }) + .for_class(DispatchClass::Operational, |weights| { + weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT); + // Operational transactions have some extra reserved space, so that they + // are included even if block reached `MAXIMUM_BLOCK_WEIGHT`. + weights.reserved = Some( + MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT + ); + }) + .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO) + .build_or_panic(); + pub const SS58Prefix: u8 = 150; +} +impl frame_system::Config for Runtime { + type BaseCallFilter = (); + type BlockWeights = RuntimeBlockWeights; + type BlockLength = RuntimeBlockLength; + type DbWeight = RocksDbWeight; + type Origin = Origin; + type Call = Call; + type Index = Nonce; + type BlockNumber = BlockNumber; + type Hash = Hash; + type Hashing = BlakeTwo256; + type AccountId = AccountId; + type Lookup = AccountIdLookup; + type Header = Header; + type Event = Event; + type BlockHashCount = BlockHashCount; + type Version = Version; + type PalletInfo = PalletInfo; + type AccountData = AccountData; + type OnNewAccount = (); + type OnKilledAccount = (); + type SystemWeightInfo = frame_system::weights::SubstrateWeight; + type SS58Prefix = SS58Prefix; +} + +parameter_types! { + pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) * + RuntimeBlockWeights::get().max_block; + pub const MaxScheduledPerBlock: u32 = 50; +} +impl pallet_scheduler::Config for Runtime { + type Event = Event; + type Origin = Origin; + type PalletsOrigin = OriginCaller; + type Call = Call; + type MaximumWeight = MaximumSchedulerWeight; + type ScheduleOrigin = EnsureRoot; + type MaxScheduledPerBlock = MaxScheduledPerBlock; + type WeightInfo = pallet_scheduler::weights::SubstrateWeight; +} + +/// The type used to represent the kinds of proxying allowed. +#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, RuntimeDebug)] +pub enum ProxyType { + Any, + NonTransfer, + Governance, + Staking, + EthereumBridge, +} +impl Default for ProxyType { + fn default() -> Self { + Self::Any + } +} +impl InstanceFilter for ProxyType { + fn filter(&self, c: &Call) -> bool { + match self { + ProxyType::Any => true, + ProxyType::NonTransfer => matches!( + c, + Call::System(..) | + Call::Babe(..) | + Call::Timestamp(..) | + // Specifically omitting the entire Balances pallet + Call::Authorship(..) | + Call::Staking(..) | + Call::Offences(..) | + Call::Session(..) | + Call::Grandpa(..) | + Call::ImOnline(..) | + Call::AuthorityDiscovery(..) | + Call::Democracy(..) | + Call::Council(..) | + Call::TechnicalCommittee(..) | + Call::ElectionsPhragmen(..) | + Call::TechnicalMembership(..) | + Call::Treasury(..) | + Call::Claims(..) | + Call::Scheduler(..) | + Call::Proxy(..) | + Call::Multisig(..) | + // Specifically omitting the entire Sudo pallet + // Specifically omitting the entire OldnaIssuing pallet + // Specifically omitting the entire OldnaBacking pallet + Call::EthereumRelay(..) // Specifically omitting the entire EthereumBacking pallet + // Specifically omitting the entire OldetpBacking pallet + // Specifically omitting the entire OldnaIssuing pallet + // Specifically omitting the entire EthereumRelayAuthorities pallet + ), + ProxyType::Governance => matches!( + c, + Call::Democracy(..) + | Call::Council(..) | Call::TechnicalCommittee(..) + | Call::ElectionsPhragmen(..) + | Call::Treasury(..) + ), + ProxyType::Staking => matches!(c, Call::Staking(..)), + ProxyType::EthereumBridge => matches!( + c, + Call::EthereumBacking(..) + | Call::EthereumRelay(..) + | Call::EthereumRelayAuthorities(..) + ), + } + } + fn is_superset(&self, o: &Self) -> bool { + match (self, o) { + (x, y) if x == y => true, + (ProxyType::Any, _) => true, + (_, ProxyType::Any) => false, + (ProxyType::NonTransfer, _) => true, + _ => false, + } + } +} +parameter_types! { + // One storage item; key size 32, value size 8; . + pub const ProxyDepositBase: Balance = deposit(1, 8); + // Additional storage item size of 33 bytes. + pub const ProxyDepositFactor: Balance = deposit(0, 33); + pub const MaxProxies: u16 = 32; + pub const AnnouncementDepositBase: Balance = deposit(1, 8); + pub const AnnouncementDepositFactor: Balance = deposit(0, 66); + pub const MaxPending: u16 = 32; +} +impl pallet_proxy::Config for Runtime { + type Event = Event; + type Call = Call; + type Currency = Balances; + type ProxyType = ProxyType; + type ProxyDepositBase = ProxyDepositBase; + type ProxyDepositFactor = ProxyDepositFactor; + type MaxProxies = MaxProxies; + type MaxPending = MaxPending; + type CallHasher = BlakeTwo256; + type AnnouncementDepositBase = AnnouncementDepositBase; + type AnnouncementDepositFactor = AnnouncementDepositFactor; + type WeightInfo = pallet_proxy::weights::SubstrateWeight; +} + +parameter_types! { + pub const EpochDuration: u64 = BLOCKS_PER_SESSION as _; + pub const ExpectedBlockTime: Moment = MILLISECS_PER_BLOCK; +} +impl pallet_babe::Config for Runtime { + type EpochDuration = EpochDuration; + type ExpectedBlockTime = ExpectedBlockTime; + type EpochChangeTrigger = pallet_babe::ExternalTrigger; + type KeyOwnerProofSystem = Historical; + type KeyOwnerProof = >::Proof; + type KeyOwnerIdentification = >::IdentificationTuple; + type HandleEquivocation = + pallet_babe::EquivocationHandler; + type WeightInfo = (); +} + +parameter_types! { + // One storage item; key size is 32; value is size 4+4+16+32 bytes = 56 bytes. + pub const DepositBase: Balance = deposit(1, 88); + // Additional storage item size of 32 bytes. + pub const DepositFactor: Balance = deposit(0, 32); + pub const MaxSignatories: u16 = 100; +} + +impl pallet_multisig::Config for Runtime { + type Event = Event; + type Call = Call; + type Currency = Balances; + type DepositBase = DepositBase; + type DepositFactor = DepositFactor; + type MaxSignatories = MaxSignatories; + type WeightInfo = pallet_multisig::weights::SubstrateWeight; +} + +parameter_types! { + pub const MinimumPeriod: Moment = SLOT_DURATION / 2; +} +impl pallet_timestamp::Config for Runtime { + type Moment = Moment; + type OnTimestampSet = Babe; + type MinimumPeriod = MinimumPeriod; + type WeightInfo = pallet_timestamp::weights::SubstrateWeight; +} + +type EtpInstance = hyperspace_balances::Instance0; +parameter_types! { + //pub const ExistentialDeposit: Balance = 1 * COIN; + pub const ExistentialDeposit: Balance = 0; + pub const MaxLocks: u32 = 50; +} +impl hyperspace_balances::Config for Runtime { + type Balance = Balance; + type DustRemoval = (); + type Event = Event; + type ExistentialDeposit = ExistentialDeposit; + type BalanceInfo = AccountData; + type AccountStore = System; + type MaxLocks = MaxLocks; + type OtherCurrencies = (Dna,); + type WeightInfo = hyperspace_balances::weights::SubstrateWeight; +} +type DnaInstance = hyperspace_balances::Instance1; +impl hyperspace_balances::Config for Runtime { + type Balance = Balance; + type DustRemoval = (); + type Event = Event; + type ExistentialDeposit = ExistentialDeposit; + type BalanceInfo = AccountData; + type AccountStore = System; + type MaxLocks = MaxLocks; + type OtherCurrencies = (Etp,); + type WeightInfo = hyperspace_balances::weights::SubstrateWeight; +} + +/// Parameterized slow adjusting fee updated based on +/// https://w3f-research.readthedocs.io/en/latest/polkadot/Token%20Economics.html#-2.-slow-adjusting-mechanism +pub type SlowAdjustingFeeUpdate = + TargetedFeeAdjustment; +parameter_types! { + pub const TransactionByteFee: Balance = 10 * MICRO; + /// The portion of the `AvailableBlockRatio` that we adjust the fees with. Blocks filled less + /// than this will decrease the weight and more will increase. + pub const TargetBlockFullness: Perquintill = Perquintill::from_percent(25); + /// The adjustment variable of the runtime. Higher values will cause `TargetBlockFullness` to + /// change the fees more rapidly. + pub AdjustmentVariable: Multiplier = Multiplier::saturating_from_rational(3, 100_000); + /// Minimum amount of the multiplier. This value cannot be too low. A test case should ensure + /// that combined with `AdjustmentVariable`, we can recover from the minimum. + /// See `multiplier_can_grow_from_zero`. + pub MinimumMultiplier: Multiplier = Multiplier::saturating_from_rational(1, 1_000_000_000u128); +} +impl pallet_transaction_payment::Config for Runtime { + type OnChargeTransaction = CurrencyAdapter; + type TransactionByteFee = TransactionByteFee; + type WeightToFee = WeightToFee; + type FeeMultiplierUpdate = SlowAdjustingFeeUpdate; +} + +parameter_types! { + pub const UncleGenerations: BlockNumber = 5; +} +impl pallet_authorship::Config for Runtime { + type FindAuthor = pallet_session::FindAccountFromAuthorIndex; + type UncleGenerations = UncleGenerations; + type FilterUncle = (); + type EventHandler = (Staking, ImOnline); +} + +parameter_types! { + pub const StakingModuleId: ModuleId = ModuleId(*b"da/staki"); + pub const SessionsPerEra: SessionIndex = SESSIONS_PER_ERA; + pub const BondingDurationInEra: EraIndex = 14 * DAYS + / (SESSIONS_PER_ERA as BlockNumber * BLOCKS_PER_SESSION); + pub const BondingDurationInBlockNumber: BlockNumber = 14 * DAYS; + pub const SlashDeferDuration: EraIndex = 14 * DAYS + / (SESSIONS_PER_ERA as BlockNumber * BLOCKS_PER_SESSION) - 1; + // quarter of the last session will be for election. + pub const ElectionLookahead: BlockNumber = BLOCKS_PER_SESSION / 4; + pub const MaxIterations: u32 = 5; + pub MinSolutionScoreBump: Perbill = Perbill::from_rational_approximation(5u32, 10_000); + pub const MaxNominatorRewardedPerValidator: u32 = 128; + pub const StakingUnsignedPriority: TransactionPriority = TransactionPriority::max_value() / 2; + pub OffchainSolutionWeightLimit: Weight = RuntimeBlockWeights::get() + .get(DispatchClass::Normal) + .max_extrinsic.expect("Normal extrinsics have a weight limit configured; qed") + .saturating_sub(BlockExecutionWeight::get()); + pub const Cap: Balance = CAP; + pub const TotalPower: Power = TOTAL_POWER; +} +impl hyperspace_staking::Config for Runtime { + type Event = Event; + type ModuleId = StakingModuleId; + type UnixTime = Timestamp; + type SessionsPerEra = SessionsPerEra; + type BondingDurationInEra = BondingDurationInEra; + type BondingDurationInBlockNumber = BondingDurationInBlockNumber; + type SlashDeferDuration = SlashDeferDuration; + /// A super-majority of the council can cancel the slash. + type SlashCancelOrigin = EnsureRootOrHalfCouncil; + type SessionInterface = Self; + type NextNewSession = Session; + type ElectionLookahead = ElectionLookahead; + type Call = Call; + type MaxIterations = MaxIterations; + type MinSolutionScoreBump = MinSolutionScoreBump; + type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator; + type UnsignedPriority = StakingUnsignedPriority; + // The unsigned solution weight targeted by the OCW. We set it to the maximum possible value of + // a single extrinsic. + type OffchainSolutionWeightLimit = OffchainSolutionWeightLimit; + type EtpCurrency = Etp; + type EtpRewardRemainder = Treasury; + // send the slashed funds to the treasury. + type EtpSlash = Treasury; + // rewards are minted from the void + type EtpReward = (); + type DnaCurrency = Dna; + // send the slashed funds to the treasury. + type DnaSlash = Treasury; + // rewards are minted from the void + type DnaReward = (); + type Cap = Cap; + type TotalPower = TotalPower; + type WeightInfo = hyperspace_staking::weights::SubstrateWeight; +} + +parameter_types! { + pub OffencesWeightSoftLimit: Weight = Perbill::from_percent(60) * + RuntimeBlockWeights::get().max_block; +} +impl pallet_offences::Config for Runtime { + type Event = Event; + type IdentificationTuple = pallet_session::historical::IdentificationTuple; + type OnOffenceHandler = Staking; + type WeightSoftLimit = OffencesWeightSoftLimit; +} + +impl pallet_session::historical::Config for Runtime { + type FullIdentification = hyperspace_staking::Exposure; + type FullIdentificationOf = hyperspace_staking::ExposureOf; +} + +impl_opaque_keys! { + pub struct SessionKeys { + pub babe: Babe, + pub grandpa: Grandpa, + pub im_online: ImOnline, + pub authority_discovery: AuthorityDiscovery, + } +} +parameter_types! { + pub const DisabledValidatorsThreshold: Perbill = Perbill::from_percent(17); +} +impl pallet_session::Config for Runtime { + type Event = Event; + type ValidatorId = AccountId; + type ValidatorIdOf = hyperspace_staking::StashOf; + type ShouldEndSession = Babe; + type NextSessionRotation = Babe; + type SessionManager = pallet_session::historical::NoteHistoricalRoot; + type SessionHandler = ::KeyTypeIdProviders; + type Keys = SessionKeys; + type DisabledValidatorsThreshold = DisabledValidatorsThreshold; + type WeightInfo = pallet_session::weights::SubstrateWeight; +} + +impl pallet_grandpa::Config for Runtime { + type Event = Event; + type Call = Call; + type KeyOwnerProof = + >::Proof; + type KeyOwnerIdentification = >::IdentificationTuple; + type KeyOwnerProofSystem = Historical; + type HandleEquivocation = + pallet_grandpa::EquivocationHandler; + type WeightInfo = (); +} + +parameter_types! { + pub const SessionDuration: BlockNumber = BLOCKS_PER_SESSION as _; + pub const ImOnlineUnsignedPriority: TransactionPriority = TransactionPriority::max_value(); +} +impl pallet_im_online::Config for Runtime { + type AuthorityId = ImOnlineId; + type Event = Event; + type SessionDuration = SessionDuration; + type ReportUnresponsiveness = Offences; + type UnsignedPriority = ImOnlineUnsignedPriority; + type WeightInfo = pallet_im_online::weights::SubstrateWeight; +} + +impl pallet_authority_discovery::Config for Runtime {} + +type EnsureRootOrHalfCouncil = EnsureOneOf< + AccountId, + EnsureRoot, + pallet_collective::EnsureProportionAtLeast<_1, _2, AccountId, CouncilCollective>, +>; +parameter_types! { + pub const LaunchPeriod: BlockNumber = 7 * DAYS; + pub const VotingPeriod: BlockNumber = 7 * DAYS; + pub const FastTrackVotingPeriod: BlockNumber = 3 * HOURS; + pub const MinimumDeposit: Balance = 1 * MILLI; + pub const EnactmentPeriod: BlockNumber = 8 * DAYS; + pub const CooloffPeriod: BlockNumber = 7 * DAYS; + pub const PreimageByteDeposit: Balance = 10 * NANO; + pub const InstantAllowed: bool = true; + pub const MaxVotes: u32 = 100; + pub const MaxProposals: u32 = 100; +} +impl hyperspace_democracy::Config for Runtime { + type Proposal = Call; + type Event = Event; + type Currency = Etp; + type EnactmentPeriod = EnactmentPeriod; + type LaunchPeriod = LaunchPeriod; + type VotingPeriod = VotingPeriod; + type MinimumDeposit = MinimumDeposit; + /// A straight majority of the council can decide what their next motion is. + type ExternalOrigin = EnsureRootOrHalfCouncil; + /// A majority can have the next scheduled referendum be a straight majority-carries vote. + type ExternalMajorityOrigin = EnsureRootOrHalfCouncil; + /// A unanimous council can have the next scheduled referendum be a straight default-carries + /// (NTB) vote. + type ExternalDefaultOrigin = + pallet_collective::EnsureProportionAtLeast<_1, _1, AccountId, CouncilCollective>; + /// Two thirds of the technical committee can have an ExternalMajority/ExternalDefault vote + /// be tabled immediately and with a shorter voting/enactment period. + type FastTrackOrigin = + pallet_collective::EnsureProportionAtLeast<_2, _3, AccountId, TechnicalCollective>; + type InstantOrigin = + pallet_collective::EnsureProportionAtLeast<_1, _1, AccountId, TechnicalCollective>; + 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 = + pallet_collective::EnsureProportionAtLeast<_2, _3, AccountId, CouncilCollective>; + // To cancel a proposal before it has been passed, the technical committee must be unanimous or + // Root must agree. + type CancelProposalOrigin = EnsureOneOf< + AccountId, + EnsureRoot, + pallet_collective::EnsureProportionAtLeast<_1, _1, AccountId, TechnicalCollective>, + >; + 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 PreimageByteDeposit = PreimageByteDeposit; + type Slash = Treasury; + type Scheduler = Scheduler; + type PalletsOrigin = OriginCaller; + type MaxVotes = MaxVotes; + type OperationalPreimageOrigin = pallet_collective::EnsureMember; + type MaxProposals = MaxProposals; + type WeightInfo = hyperspace_democracy::weights::SubstrateWeight; +} + +parameter_types! { + pub const CouncilMotionDuration: BlockNumber = 3 * DAYS; + pub const CouncilMaxProposals: u32 = 100; + pub const CouncilMaxMembers: u32 = 100; + pub const TechnicalMotionDuration: BlockNumber = 3 * DAYS; + pub const TechnicalMaxProposals: u32 = 100; + pub const TechnicalMaxMembers: u32 = 100; +} +// Make sure that there are no more than `MaxMembers` members elected via elections-phragmen. +const_assert!(DesiredMembers::get() <= CouncilMaxMembers::get()); +type CouncilCollective = pallet_collective::Instance0; +impl pallet_collective::Config for Runtime { + type Origin = Origin; + type Proposal = Call; + type Event = Event; + type MotionDuration = CouncilMotionDuration; + type MaxProposals = CouncilMaxProposals; + type MaxMembers = CouncilMaxMembers; + type DefaultVote = pallet_collective::PrimeDefaultVote; + type WeightInfo = pallet_collective::weights::SubstrateWeight; +} +type TechnicalCollective = pallet_collective::Instance1; +impl pallet_collective::Config for Runtime { + type Origin = Origin; + type Proposal = Call; + type Event = Event; + type MotionDuration = TechnicalMotionDuration; + type MaxProposals = TechnicalMaxProposals; + type MaxMembers = TechnicalMaxMembers; + type DefaultVote = pallet_collective::PrimeDefaultVote; + type WeightInfo = pallet_collective::weights::SubstrateWeight; +} + +parameter_types! { + pub const ElectionsPhragmenModuleId: LockIdentifier = *b"da/phrel"; + pub const CandidacyBond: Balance = 1 * COIN; + // 1 storage item created, key size is 32 bytes, value size is 16+16. + pub const VotingBondBase: Balance = deposit(1, 64); + // additional data per vote is 32 bytes (account id). + pub const VotingBondFactor: Balance = deposit(0, 32); + pub const DesiredMembers: u32 = 13; + pub const DesiredRunnersUp: u32 = 7; + /// Daily council elections. + pub const TermDuration: BlockNumber = 24 * HOURS; +} +impl hyperspace_elections_phragmen::Config for Runtime { + type Event = Event; + type ModuleId = ElectionsPhragmenModuleId; + type Currency = Etp; + type ChangeMembers = Council; + // NOTE: this implies that council's genesis members cannot be set directly and must come from + // this module. + type InitializeMembers = Council; + type CurrencyToVote = U128CurrencyToVote; + type CandidacyBond = CandidacyBond; + type VotingBondBase = VotingBondBase; + type VotingBondFactor = VotingBondFactor; + type LoserCandidate = Treasury; + type KickedMember = Treasury; + type DesiredMembers = DesiredMembers; + type DesiredRunnersUp = DesiredRunnersUp; + type TermDuration = TermDuration; + type WeightInfo = hyperspace_elections_phragmen::weights::SubstrateWeight; +} + +pub struct MembershipChangedGroup; +impl ChangeMembers for MembershipChangedGroup { + fn change_members_sorted( + incoming: &[AccountId], + outgoing: &[AccountId], + sorted_new: &[AccountId], + ) { + TechnicalCommittee::change_members_sorted(incoming, outgoing, sorted_new); + EthereumRelay::change_members_sorted(incoming, outgoing, sorted_new); + } +} +type EnsureRootOrMoreThanHalfCouncil = EnsureOneOf< + AccountId, + EnsureRoot, + pallet_collective::EnsureProportionMoreThan<_1, _2, AccountId, CouncilCollective>, +>; +impl pallet_membership::Config for Runtime { + type Event = Event; + type AddOrigin = EnsureRootOrMoreThanHalfCouncil; + type RemoveOrigin = EnsureRootOrMoreThanHalfCouncil; + type SwapOrigin = EnsureRootOrMoreThanHalfCouncil; + type ResetOrigin = EnsureRootOrMoreThanHalfCouncil; + type PrimeOrigin = EnsureRootOrMoreThanHalfCouncil; + type MembershipInitialized = TechnicalCommittee; + type MembershipChanged = MembershipChangedGroup; +} + +type ApproveOrigin = EnsureOneOf< + AccountId, + EnsureRoot, + pallet_collective::EnsureProportionAtLeast<_3, _5, AccountId, CouncilCollective>, +>; +parameter_types! { + pub const TreasuryModuleId: ModuleId = ModuleId(*b"da/trsry"); + pub const ProposalBond: Permill = Permill::from_percent(5); + pub const EtpProposalBondMinimum: Balance = 20 * COIN; + pub const DnaProposalBondMinimum: Balance = 20 * COIN; + pub const SpendPeriod: BlockNumber = 6 * DAYS; + pub const Burn: Permill = Permill::from_percent(0); + pub const TipCountdown: BlockNumber = 1 * DAYS; + pub const TipFindersFee: Percent = Percent::from_percent(20); + pub const TipReportDepositBase: Balance = 1 * COIN; + pub const DataDepositPerByte: Balance = 1 * MILLI; + pub const BountyDepositBase: Balance = 1 * COIN; + pub const BountyDepositPayoutDelay: BlockNumber = 4 * DAYS; + pub const BountyUpdatePeriod: BlockNumber = 90 * DAYS; + pub const MaximumReasonLength: u32 = 16384; + pub const BountyCuratorDeposit: Permill = Permill::from_percent(50); + pub const BountyValueMinimum: Balance = 2 * COIN; +} +impl hyperspace_treasury::Config for Runtime { + type ModuleId = TreasuryModuleId; + type EtpCurrency = Etp; + type DnaCurrency = Dna; + type ApproveOrigin = ApproveOrigin; + type RejectOrigin = EnsureRootOrMoreThanHalfCouncil; + type Tippers = ElectionsPhragmen; + type TipCountdown = TipCountdown; + type TipFindersFee = TipFindersFee; + type TipReportDepositBase = TipReportDepositBase; + type DataDepositPerByte = DataDepositPerByte; + type Event = Event; + type OnSlashEtp = Treasury; + type OnSlashDna = Treasury; + type ProposalBond = ProposalBond; + type EtpProposalBondMinimum = EtpProposalBondMinimum; + type DnaProposalBondMinimum = DnaProposalBondMinimum; + type SpendPeriod = SpendPeriod; + type Burn = Burn; + type BountyDepositBase = BountyDepositBase; + type BountyDepositPayoutDelay = BountyDepositPayoutDelay; + type BountyUpdatePeriod = BountyUpdatePeriod; + type MaximumReasonLength = MaximumReasonLength; + type BountyCuratorDeposit = BountyCuratorDeposit; + type BountyValueMinimum = BountyValueMinimum; + type EtpBurnDestination = (); + type DnaBurnDestination = (); + type WeightInfo = hyperspace_treasury::weights::SubstrateWeight; +} + +parameter_types! { + pub const ClaimsModuleId: ModuleId = ModuleId(*b"da/claim"); + pub Prefix: &'static [u8] = b"Pay ETPs to the template account:"; +} +impl hyperspace_claims::Config for Runtime { + type Event = Event; + type ModuleId = ClaimsModuleId; + type Prefix = Prefix; + type EtpCurrency = Etp; + type MoveClaimOrigin = EnsureRootOrMoreThanHalfCouncil; +} + +parameter_types! { + pub const MinVestedTransfer: Balance = 100 * MILLI; +} +impl hyperspace_vesting::Config for Runtime { + type Event = Event; + type Currency = Etp; + type BlockNumberToBalance = ConvertInto; + type MinVestedTransfer = MinVestedTransfer; + type WeightInfo = (); +} + +impl pallet_sudo::Config for Runtime { + type Event = Event; + type Call = Call; +} + +parameter_types! { + pub const OldnaIssuingModuleId: ModuleId = ModuleId(*b"da/crais"); +} +impl hyperspace_oldna_issuing::Config for Runtime { + type Event = Event; + type ModuleId = OldnaIssuingModuleId; + type EtpCurrency = Etp; + type WeightInfo = (); +} + +parameter_types! { + pub const OldnaBackingModuleId: ModuleId = ModuleId(*b"da/oldnk"); +} +impl hyperspace_oldna_backing::Config for Runtime { + type ModuleId = OldnaBackingModuleId; + type EtpCurrency = Etp; + type WeightInfo = (); +} + +parameter_types! { + pub const EthereumBackingModuleId: ModuleId = ModuleId(*b"da/ethbk"); + pub const EthereumBackingFeeModuleId: ModuleId = ModuleId(*b"da/ethfe"); + pub const EtpLockLimit: Balance = 10_000_000 * COIN; + pub const DnaLockLimit: Balance = 1000 * COIN; + pub const AdvancedFee: Balance = 50 * COIN; + pub const SyncReward: Balance = 1000 * COIN; +} +impl hyperspace_ethereum_backing::Config for Runtime { + type ModuleId = EthereumBackingModuleId; + type FeeModuleId = EthereumBackingFeeModuleId; + type Event = Event; + type RedeemAccountId = AccountId; + type EthereumRelay = EthereumRelay; + type OnDepositRedeem = Staking; + type EtpCurrency = Etp; + type DnaCurrency = Dna; + type EtpLockLimit = EtpLockLimit; + type DnaLockLimit = DnaLockLimit; + type AdvancedFee = AdvancedFee; + type SyncReward = SyncReward; + type EcdsaAuthorities = EthereumRelayAuthorities; + type WeightInfo = (); +} + +type EnsureRootOrHalfTechnicalComittee = EnsureOneOf< + AccountId, + EnsureRoot, + pallet_collective::EnsureProportionMoreThan<_1, _2, AccountId, TechnicalCollective>, +>; +parameter_types! { + pub const EthereumRelayModuleId: ModuleId = ModuleId(*b"da/ethrl"); + pub const EthereumNetwork: ethereum_primitives::EthereumNetworkType = ethereum_primitives::EthereumNetworkType::Ropsten; + pub const ConfirmPeriod: BlockNumber = 200; + pub const ApproveThreshold: Perbill = Perbill::from_percent(60); + pub const RejectThreshold: Perbill = Perbill::from_percent(1); +} +impl hyperspace_ethereum_relay::Config for Runtime { + type ModuleId = EthereumRelayModuleId; + type Event = Event; + type EthereumNetwork = EthereumNetwork; + type Call = Call; + type Currency = Etp; + type RelayerGame = EthereumRelayerGame; + type ApproveOrigin = ApproveOrigin; + type RejectOrigin = EnsureRootOrHalfTechnicalComittee; + type ConfirmPeriod = ConfirmPeriod; + type TechnicalMembership = TechnicalMembership; + type ApproveThreshold = ApproveThreshold; + type RejectThreshold = RejectThreshold; + type WeightInfo = (); +} + +type EthereumRelayerGameInstance = hyperspace_relayer_game::Instance0; +parameter_types! { + pub const EthereumRelayerGameLockId: LockIdentifier = *b"ethrgame"; +} +impl hyperspace_relayer_game::Config for Runtime { + type EtpCurrency = Etp; + type LockId = EthereumRelayerGameLockId; + type EtpSlash = Treasury; + type RelayerGameAdjustor = relay::EthereumRelayerGameAdjustor; + type RelayableChain = EthereumRelay; + type WeightInfo = (); +} + +parameter_types! { + pub const OldetpBackingModuleId: ModuleId = ModuleId(*b"da/trobk"); +} +impl hyperspace_oldetp_backing::Config for Runtime { + type ModuleId = OldetpBackingModuleId; + type EtpCurrency = Etp; + type DnaCurrency = Dna; + type WeightInfo = (); +} + +impl hyperspace_header_mmr::Config for Runtime {} + +/// Fixed gas price of `1`. +pub struct FixedGasPrice; +impl FeeCalculator for FixedGasPrice { + fn min_gas_price() -> U256 { + // Gas price is always one token per gas. + //1.into() + 10_000_000_000u64.into() + } +} + +parameter_types! { + pub const ChainId: u64 = 23; +} +impl hyperspace_evm::Config for Runtime { + type FeeCalculator = FixedGasPrice; + type GasWeightMapping = (); + type CallOrigin = EnsureAddressTruncated; + type WithdrawOrigin = EnsureAddressTruncated; + type AddressMapping = ConcatAddressMapping; + type EtpCurrency = Etp; + type DnaCurrency = Dna; + type Event = Event; + type Precompiles = hyperspace_evm_precompile::HyperspacePrecompiles; + type ChainId = ChainId; + type AccountBasicMapping = DVMAccountBasicMapping; + type Runner = hyperspace_evm::runner::stack::Runner; +} + +type EthereumRelayAuthoritiesInstance = hyperspace_relay_authorities::Instance0; +parameter_types! { + pub const EthereumRelayAuthoritiesLockId: LockIdentifier = *b"ethrauth"; + pub const EthereumRelayAuthoritiesTermDuration: BlockNumber = 30 * DAYS; + pub const MaxCandidates: usize = 7; + pub const OpCodes: (OpCode, OpCode) = ( + [71, 159, 189, 249], + [180, 188, 244, 151] + ); + pub const SignThreshold: Perbill = Perbill::from_percent(60); + pub const SubmitDuration: BlockNumber = 100; +} +impl hyperspace_relay_authorities::Config for Runtime { + type Event = Event; + type EtpCurrency = Etp; + type LockId = EthereumRelayAuthoritiesLockId; + type TermDuration = EthereumRelayAuthoritiesTermDuration; + type MaxCandidates = MaxCandidates; + type AddOrigin = ApproveOrigin; + type RemoveOrigin = ApproveOrigin; + type ResetOrigin = ApproveOrigin; + type HyperspaceMMR = HeaderMMR; + type Sign = EthereumBacking; + type OpCodes = OpCodes; + type SignThreshold = SignThreshold; + type SubmitDuration = SubmitDuration; + type WeightInfo = (); +} + +pub struct EthereumFindAuthor(sp_std::marker::PhantomData); +impl> FindAuthor for EthereumFindAuthor { + fn find_author<'a, I>(digests: I) -> Option + where + I: 'a + IntoIterator, + { + if let Some(author_index) = F::find_author(digests) { + let authority_id = Babe::authorities()[author_index as usize].clone(); + return Some(H160::from_slice(&authority_id.0.to_raw_vec()[4..24])); + } + None + } +} + +parameter_types! { + pub BlockGasLimit: U256 = U256::from(u32::max_value()); +} +impl dvm_ethereum::Config for Runtime { + type Event = Event; + type FindAuthor = EthereumFindAuthor; + type StateRoot = dvm_ethereum::IntermediateStateRoot; + type BlockGasLimit = BlockGasLimit; + type AddressMapping = ConcatAddressMapping; + type EtpCurrency = Etp; +} + +construct_runtime! { pub enum Runtime where Block = Block, @@ -448,49 +1199,36 @@ frame_support::construct_runtime! { TechnicalMembership: pallet_membership::::{Module, Call, Storage, Config, Event} = 19, Treasury: hyperspace_treasury::{Module, Call, Storage, Event} = 20, - Sudo: pallet_sudo::{Module, Call, Storage, Config, Event} = 21, - // Claims. Usable initially. - Claims: hyperspace_claims::{Module, Call, Storage, Config, Event, ValidateUnsigned} = 22, + Claims: hyperspace_claims::{Module, Call, Storage, Config, Event, ValidateUnsigned} = 21, // Vesting. Usable initially, but removed once all vesting is finished. - Vesting: hyperspace_vesting::{Module, Call, Storage, Event, Config} = 23, - - // Utility module. - Utility: pallet_utility::{Module, Call, Event} = 24, - - // Less simple identity module. - Identity: pallet_identity::{Module, Call, Storage, Event} = 25, - - // Society module. - Society: pallet_society::{Module, Call, Storage, Event} = 26, - - // Social recovery module. - Recovery: pallet_recovery::{Module, Call, Storage, Event} = 27, + Vesting: hyperspace_vesting::{Module, Call, Storage, Event, Config} = 22, // System scheduler. - Scheduler: pallet_scheduler::{Module, Call, Storage, Event} = 28, + Scheduler: pallet_scheduler::{Module, Call, Storage, Event} = 23, // Proxy module. Late addition. - Proxy: pallet_proxy::{Module, Call, Storage, Event} = 29, + Proxy: pallet_proxy::{Module, Call, Storage, Event} = 24, - // Multisig module. Late addition. - Multisig: pallet_multisig::{Module, Call, Storage, Event} = 30, + Sudo: pallet_sudo::{Module, Call, Storage, Config, Event} = 25, - HeaderMMR: hyperspace_header_mmr::{Module, Call, Storage} = 31, + HeaderMMR: hyperspace_header_mmr::{Module, Call, Storage} = 26, - OldetpIssuing: hyperspace_oldetp_issuing::{Module, Call, Storage, Config, Event} = 32, - OldetpBacking: hyperspace_oldetp_backing::{Module, Storage, Config} = 33, + OldnaIssuing: hyperspace_oldna_issuing::{Module, Call, Storage, Config, Event} = 27, + OldnaBacking: hyperspace_oldna_backing::{Module, Storage, Config} = 28, - EthereumRelay: hyperspace_ethereum_relay::{Module, Call, Storage, Config, Event} = 34, - EthereumBacking: hyperspace_ethereum_backing::{Module, Call, Storage, Config, Event} = 35, - EthereumRelayerGame: hyperspace_relayer_game::::{Module, Storage} = 36, - EthereumRelayAuthorities: hyperspace_relay_authorities::::{Module, Call, Storage, Config, Event} = 37, + EthereumRelay: hyperspace_ethereum_relay::{Module, Call, Storage, Config, Event} = 29, + EthereumBacking: hyperspace_ethereum_backing::{Module, Call, Storage, Config, Event} = 30, + EthereumRelayerGame: hyperspace_relayer_game::::{Module, Storage} = 31, + EthereumRelayAuthorities: hyperspace_relay_authorities::::{Module, Call, Storage, Config, Event} = 32, - OldnaBacking: hyperspace_oldna_backing::{Module, Storage, Config} = 38, + OldetpBacking: hyperspace_oldetp_backing::{Module, Storage, Config} = 33, - EVM: hyperspace_evm::{Module, Call, Storage, Config, Event} = 39, - Ethereum: dvm_ethereum::{Module, Call, Storage, Config, Event, ValidateUnsigned} = 40, + EVM: hyperspace_evm::{Module, Call, Storage, Config, Event} = 34, + Ethereum: dvm_ethereum::{Module, Call, Storage, Config, Event, ValidateUnsigned} = 35, + // Multisig module. + Multisig: pallet_multisig::{Module, Call, Storage, Event} = 36, } } @@ -766,9 +1504,6 @@ impl_runtime_apis! { } fn account_basic(address: H160) -> EVMAccount { - // --- hyperspace --- - use hyperspace_evm::AccountBasicMapping; - ::AccountBasicMapping::account_basic(&address) } @@ -901,13 +1636,15 @@ impl dvm_rpc_runtime_api::ConvertTransaction for TransactionCon // } pub struct PhragmenElectionDepositRuntimeUpgrade; -impl hyperspace_elections_phragmen::migrations_2_0_0::ToV2 for PhragmenElectionDepositRuntimeUpgrade { +impl hyperspace_elections_phragmen::migrations_3_0_0::V2ToV3 + for PhragmenElectionDepositRuntimeUpgrade +{ type AccountId = AccountId; type Balance = Balance; type Module = ElectionsPhragmen; } impl frame_support::traits::OnRuntimeUpgrade for PhragmenElectionDepositRuntimeUpgrade { fn on_runtime_upgrade() -> frame_support::weights::Weight { - hyperspace_elections_phragmen::migrations_2_0_0::apply::(5 * MILLI, COIN) + hyperspace_elections_phragmen::migrations_3_0_0::apply::(5 * MILLI, COIN) } } diff --git a/bin/node/runtime/hyperspace/src/membership.rs b/bin/node/runtime/hyperspace/src/membership.rs deleted file mode 100644 index 38c774a..0000000 --- a/bin/node/runtime/hyperspace/src/membership.rs +++ /dev/null @@ -1,27 +0,0 @@ -// --- substrate --- -use frame_support::traits::ChangeMembers; -use pallet_membership::{Config, Instance0}; -// --- hyperspace --- -use crate::*; - -pub struct MembershipChangedGroup; -impl ChangeMembers for MembershipChangedGroup { - fn change_members_sorted( - incoming: &[AccountId], - outgoing: &[AccountId], - sorted_new: &[AccountId], - ) { - TechnicalCommittee::change_members_sorted(incoming, outgoing, sorted_new); - EthereumRelay::change_members_sorted(incoming, outgoing, sorted_new); - } -} -impl Config for Runtime { - type Event = Event; - type AddOrigin = EnsureRootOrMoreThanHalfCouncil; - type RemoveOrigin = EnsureRootOrMoreThanHalfCouncil; - type SwapOrigin = EnsureRootOrMoreThanHalfCouncil; - type ResetOrigin = EnsureRootOrMoreThanHalfCouncil; - type PrimeOrigin = EnsureRootOrMoreThanHalfCouncil; - type MembershipInitialized = TechnicalCommittee; - type MembershipChanged = MembershipChangedGroup; -} diff --git a/bin/node/runtime/hyperspace/src/multisig.rs b/bin/node/runtime/hyperspace/src/multisig.rs deleted file mode 100644 index dc79ab8..0000000 --- a/bin/node/runtime/hyperspace/src/multisig.rs +++ /dev/null @@ -1,21 +0,0 @@ -// --- substrate --- -use pallet_multisig::Config; -// --- hyperspace --- -use crate::*; - -frame_support::parameter_types! { - // One storage item; key size is 32; value is size 4+4+16+32 bytes = 56 bytes. - pub const DepositBase: Balance = constants::deposit(1, 88); - // Additional storage item size of 32 bytes. - pub const DepositFactor: Balance = constants::deposit(0, 32); - pub const MaxSignatories: u16 = 100; -} -impl Config for Runtime { - type Event = Event; - type Call = Call; - type Currency = Etp; - type DepositBase = DepositBase; - type DepositFactor = DepositFactor; - type MaxSignatories = MaxSignatories; - type WeightInfo = (); -} diff --git a/bin/node/runtime/hyperspace/src/offences.rs b/bin/node/runtime/hyperspace/src/offences.rs deleted file mode 100644 index 9875619..0000000 --- a/bin/node/runtime/hyperspace/src/offences.rs +++ /dev/null @@ -1,18 +0,0 @@ -// --- substrate --- -use frame_support::weights::Weight; -use pallet_offences::Config; -use pallet_session::historical::IdentificationTuple; -use sp_runtime::Perbill; -// --- hyperspace --- -use crate::*; - -frame_support::parameter_types! { - pub OffencesWeightSoftLimit: Weight = Perbill::from_percent(60) * - RuntimeBlockWeights::get().max_block; -} -impl Config for Runtime { - type Event = Event; - type IdentificationTuple = IdentificationTuple; - type OnOffenceHandler = Staking; - type WeightSoftLimit = OffencesWeightSoftLimit; -} diff --git a/bin/node/runtime/hyperspace/src/oldetp_backing.rs b/bin/node/runtime/hyperspace/src/oldetp_backing.rs deleted file mode 100644 index 14d2142..0000000 --- a/bin/node/runtime/hyperspace/src/oldetp_backing.rs +++ /dev/null @@ -1,14 +0,0 @@ -// --- substrate --- -use sp_runtime::ModuleId; -// --- hyperspace --- -use crate::*; -use hyperspace_oldetp_backing::Config; - -frame_support::parameter_types! { - pub const OldetpBackingModuleId: ModuleId = ModuleId(*b"da/oldek"); -} -impl Config for Runtime { - type ModuleId = OldetpBackingModuleId; - type EtpCurrency = Etp; - type WeightInfo = (); -} diff --git a/bin/node/runtime/hyperspace/src/oldetp_issuing.rs b/bin/node/runtime/hyperspace/src/oldetp_issuing.rs deleted file mode 100644 index be52d58..0000000 --- a/bin/node/runtime/hyperspace/src/oldetp_issuing.rs +++ /dev/null @@ -1,15 +0,0 @@ -// --- substrate --- -use sp_runtime::ModuleId; -// --- hyperspace --- -use crate::*; -use hyperspace_oldetp_issuing::Config; - -frame_support::parameter_types! { - pub const OldetpIssuingModuleId: ModuleId = ModuleId(*b"da/crais"); -} -impl Config for Runtime { - type Event = Event; - type ModuleId = OldetpIssuingModuleId; - type EtpCurrency = Etp; - type WeightInfo = (); -} diff --git a/bin/node/runtime/hyperspace/src/oldna_backing.rs b/bin/node/runtime/hyperspace/src/oldna_backing.rs deleted file mode 100644 index 7efadde..0000000 --- a/bin/node/runtime/hyperspace/src/oldna_backing.rs +++ /dev/null @@ -1,15 +0,0 @@ -// --- substrate --- -use sp_runtime::ModuleId; -// --- hyperspace --- -use crate::*; -use hyperspace_oldna_backing::Config; - -frame_support::parameter_types! { - pub const OldnaBackingModuleId: ModuleId = ModuleId(*b"da/trobk"); -} -impl Config for Runtime { - type ModuleId = OldnaBackingModuleId; - type EtpCurrency = Etp; - type DnaCurrency = Dna; - type WeightInfo = (); -} diff --git a/bin/node/runtime/hyperspace/src/proxy.rs b/bin/node/runtime/hyperspace/src/proxy.rs deleted file mode 100644 index df01be0..0000000 --- a/bin/node/runtime/hyperspace/src/proxy.rs +++ /dev/null @@ -1,122 +0,0 @@ -// --- crates.io --- -use codec::{Decode, Encode}; -// --- substrate --- -use frame_support::traits::InstanceFilter; -use pallet_proxy::{weights::SubstrateWeight, Config}; -use sp_runtime::{traits::BlakeTwo256, RuntimeDebug}; -// --- hyperspace --- -use crate::*; - -/// The type used to represent the kinds of proxying allowed. -#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, RuntimeDebug)] -pub enum ProxyType { - Any, - NonTransfer, - Governance, - Staking, - EthereumBridge, -} -impl Default for ProxyType { - fn default() -> Self { - Self::Any - } -} -impl InstanceFilter for ProxyType { - fn filter(&self, c: &Call) -> bool { - match self { - ProxyType::Any => true, - ProxyType::NonTransfer => matches!( - c, - Call::System(..) | - Call::Babe(..) | - Call::Timestamp(..) | - // Specifically omitting the entire Balances pallet - Call::Authorship(..) | - Call::Staking(..) | - Call::Offences(..) | - Call::Session(..) | - Call::Grandpa(..) | - Call::ImOnline(..) | - Call::AuthorityDiscovery(..) | - Call::Democracy(..) | - Call::Council(..) | - Call::TechnicalCommittee(..) | - Call::ElectionsPhragmen(..) | - Call::TechnicalMembership(..) | - Call::Treasury(..) | - Call::Sudo(..) | - // Specifically omitting Vesting `vested_transfer`, and `force_vested_transfer` - Call::Vesting(hyperspace_vesting::Call::vest(..)) | - Call::Vesting(hyperspace_vesting::Call::vest_other(..)) | - Call::Utility(..)| - Call::Identity(..)| - Call::Society(..)| - // Specifically omitting Recovery `create_recovery`, `initiate_recovery` - Call::Recovery(pallet_recovery::Call::as_recovered(..)) | - Call::Recovery(pallet_recovery::Call::vouch_recovery(..)) | - Call::Recovery(pallet_recovery::Call::claim_recovery(..)) | - Call::Recovery(pallet_recovery::Call::close_recovery(..)) | - Call::Recovery(pallet_recovery::Call::remove_recovery(..)) | - Call::Recovery(pallet_recovery::Call::cancel_recovered(..)) | - Call::Scheduler(..)| - Call::Proxy(..)| - Call::Multisig(..)| - Call::HeaderMMR(..)| - // Specifically omitting the entire OldetpIssuing pallet - // Specifically omitting the entire OldetpBacking pallet - Call::EthereumRelay(..) | - // Specifically omitting the entire EthereumBacking pallet - Call::EthereumRelayAuthorities(..) // Specifically omitting the entire OldnaBacking pallet - // Specifically omitting the entire EVM pallet - // Specifically omitting the entire Ethereum pallet - ), - ProxyType::Governance => matches!( - c, - Call::Democracy(..) - | Call::Council(..) | Call::TechnicalCommittee(..) - | Call::ElectionsPhragmen(..) - | Call::Treasury(..) - ), - ProxyType::Staking => matches!(c, Call::Staking(..)), - ProxyType::EthereumBridge => matches!( - c, - Call::EthereumBacking(..) - | Call::EthereumRelay(..) - | Call::EthereumRelayAuthorities(..) - ), - } - } - fn is_superset(&self, o: &Self) -> bool { - match (self, o) { - (x, y) if x == y => true, - (ProxyType::Any, _) => true, - (_, ProxyType::Any) => false, - (ProxyType::NonTransfer, _) => true, - _ => false, - } - } -} -frame_support::parameter_types! { - // One storage item; key size 32, value size 8; . - pub const ProxyDepositBase: Balance = constants::deposit(1, 8); - // Additional storage item size of 33 bytes. - pub const ProxyDepositFactor: Balance = constants::deposit(0, 33); - pub const MaxProxies: u16 = 32; - pub const AnnouncementDepositBase: Balance = constants::deposit(1, 8); - pub const AnnouncementDepositFactor: Balance = constants::deposit(0, 66); - pub const MaxPending: u16 = 32; -} -impl Config for Runtime { - type Event = Event; - type Call = Call; - type Currency = Etp; - type ProxyType = ProxyType; - type ProxyDepositBase = ProxyDepositBase; - type ProxyDepositFactor = ProxyDepositFactor; - type MaxProxies = MaxProxies; - type MaxPending = MaxPending; - type CallHasher = BlakeTwo256; - type AnnouncementDepositBase = AnnouncementDepositBase; - type AnnouncementDepositFactor = AnnouncementDepositFactor; - type WeightInfo = SubstrateWeight; -} diff --git a/bin/node/runtime/hyperspace/src/recovery.rs b/bin/node/runtime/hyperspace/src/recovery.rs deleted file mode 100644 index 84fe8d1..0000000 --- a/bin/node/runtime/hyperspace/src/recovery.rs +++ /dev/null @@ -1,20 +0,0 @@ -// --- substrate --- -use pallet_recovery::Config; -// --- hyperspace --- -use crate::*; - -frame_support::parameter_types! { - pub const ConfigDepositBase: Balance = 5 * COIN; - pub const FriendDepositFactor: Balance = 50 * MILLI; - pub const MaxFriends: u16 = 9; - pub const RecoveryDeposit: Balance = 5 * COIN; -} -impl Config for Runtime { - type Event = Event; - type Call = Call; - type Currency = Etp; - type ConfigDepositBase = ConfigDepositBase; - type FriendDepositFactor = FriendDepositFactor; - type MaxFriends = MaxFriends; - type RecoveryDeposit = RecoveryDeposit; -} diff --git a/bin/node/runtime/hyperspace/src/relay_authorities.rs b/bin/node/runtime/hyperspace/src/relay_authorities.rs deleted file mode 100644 index c6702d6..0000000 --- a/bin/node/runtime/hyperspace/src/relay_authorities.rs +++ /dev/null @@ -1,38 +0,0 @@ -// --- hyperspace --- -pub use hyperspace_relay_authorities::Instance0 as EthereumRelayAuthoritiesInstance; - -// --- substrate --- -use frame_support::traits::LockIdentifier; -use sp_runtime::Perbill; -// --- hyperspace --- -use crate::*; -use hyperspace_relay_authorities::Config; -use hyperspace_relay_primitives::relay_authorities::OpCode; - -frame_support::parameter_types! { - pub const EthereumRelayAuthoritiesLockId: LockIdentifier = *b"ethrauth"; - pub const EthereumRelayAuthoritiesTermDuration: BlockNumber = 3 * MINUTES; - pub const MaxCandidates: usize = 7; - pub const OpCodes: (OpCode, OpCode) = ( - [71, 159, 189, 249], - [180, 188, 244, 151] - ); - pub const SignThreshold: Perbill = Perbill::from_percent(60); - pub const SubmitDuration: BlockNumber = 30; -} -impl Config for Runtime { - type Event = Event; - type EtpCurrency = Etp; - type LockId = EthereumRelayAuthoritiesLockId; - type TermDuration = EthereumRelayAuthoritiesTermDuration; - type MaxCandidates = MaxCandidates; - type AddOrigin = ApproveOrigin; - type RemoveOrigin = ApproveOrigin; - type ResetOrigin = ApproveOrigin; - type HyperspaceMMR = HeaderMMR; - type Sign = EthereumBacking; - type OpCodes = OpCodes; - type SignThreshold = SignThreshold; - type SubmitDuration = SubmitDuration; - type WeightInfo = (); -} diff --git a/bin/node/runtime/hyperspace/src/relayer_game.rs b/bin/node/runtime/hyperspace/src/relayer_game.rs deleted file mode 100644 index c59a84d..0000000 --- a/bin/node/runtime/hyperspace/src/relayer_game.rs +++ /dev/null @@ -1,20 +0,0 @@ -// --- hyperspace --- -pub use hyperspace_relayer_game::Instance0 as EthereumRelayerGameInstance; - -// --- substrate --- -use frame_support::traits::LockIdentifier; -// --- hyperspace --- -use crate::*; -use hyperspace_relayer_game::Config; - -frame_support::parameter_types! { - pub const EthereumRelayerGameLockId: LockIdentifier = *b"ethrgame"; -} -impl Config for Runtime { - type EtpCurrency = Etp; - type LockId = EthereumRelayerGameLockId; - type EtpSlash = Treasury; - type RelayerGameAdjustor = relay::EthereumRelayerGameAdjustor; - type RelayableChain = EthereumRelay; - type WeightInfo = (); -} diff --git a/bin/node/runtime/hyperspace/src/scheduler.rs b/bin/node/runtime/hyperspace/src/scheduler.rs deleted file mode 100644 index 51e0ace..0000000 --- a/bin/node/runtime/hyperspace/src/scheduler.rs +++ /dev/null @@ -1,23 +0,0 @@ -// --- substrate --- -use frame_support::weights::Weight; -use frame_system::EnsureRoot; -use pallet_scheduler::{weights::SubstrateWeight, Config}; -use sp_runtime::Perbill; -// --- hyperspace --- -use crate::*; - -frame_support::parameter_types! { - pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) * - RuntimeBlockWeights::get().max_block; - pub const MaxScheduledPerBlock: u32 = 50; -} -impl Config for Runtime { - type Event = Event; - type Origin = Origin; - type PalletsOrigin = OriginCaller; - type Call = Call; - type MaximumWeight = MaximumSchedulerWeight; - type ScheduleOrigin = EnsureRoot; - type MaxScheduledPerBlock = MaxScheduledPerBlock; - type WeightInfo = SubstrateWeight; -} diff --git a/bin/node/runtime/hyperspace/src/session.rs b/bin/node/runtime/hyperspace/src/session.rs deleted file mode 100644 index 1d94de8..0000000 --- a/bin/node/runtime/hyperspace/src/session.rs +++ /dev/null @@ -1,31 +0,0 @@ -// --- substrate --- -use pallet_session::{historical::NoteHistoricalRoot, weights::SubstrateWeight, Config}; -use sp_runtime::{impl_opaque_keys, traits::OpaqueKeys, Perbill}; -use sp_std::prelude::*; -// --- hyperspace --- -use crate::*; -use hyperspace_staking::StashOf; - -impl_opaque_keys! { - pub struct SessionKeys { - pub babe: Babe, - pub grandpa: Grandpa, - pub im_online: ImOnline, - pub authority_discovery: AuthorityDiscovery, - } -} -frame_support::parameter_types! { - pub const DisabledValidatorsThreshold: Perbill = Perbill::from_percent(17); -} -impl Config for Runtime { - type Event = Event; - type ValidatorId = AccountId; - type ValidatorIdOf = StashOf; - type ShouldEndSession = Babe; - type NextSessionRotation = Babe; - type SessionManager = NoteHistoricalRoot; - type SessionHandler = ::KeyTypeIdProviders; - type Keys = SessionKeys; - type DisabledValidatorsThreshold = DisabledValidatorsThreshold; - type WeightInfo = SubstrateWeight; -} diff --git a/bin/node/runtime/hyperspace/src/session_historical.rs b/bin/node/runtime/hyperspace/src/session_historical.rs deleted file mode 100644 index 5ca3a9e..0000000 --- a/bin/node/runtime/hyperspace/src/session_historical.rs +++ /dev/null @@ -1,13 +0,0 @@ -// --- substrate --- -pub use pallet_session::historical as pallet_session_historical; - -// --- substrate --- -use pallet_session_historical::Config; -// --- hyperspace --- -use crate::*; -use hyperspace_staking::{Exposure, ExposureOf}; - -impl Config for Runtime { - type FullIdentification = Exposure; - type FullIdentificationOf = ExposureOf; -} diff --git a/bin/node/runtime/hyperspace/src/society.rs b/bin/node/runtime/hyperspace/src/society.rs deleted file mode 100644 index 9bdd802..0000000 --- a/bin/node/runtime/hyperspace/src/society.rs +++ /dev/null @@ -1,32 +0,0 @@ -// --- substrate --- -use pallet_society::{Config, EnsureFounder}; -use sp_runtime::ModuleId; -// --- hyperspace --- -use crate::*; - -frame_support::parameter_types! { - pub const SocietyModuleId: ModuleId = ModuleId(*b"da/socie"); - pub const CandidateDeposit: Balance = 10 * COIN; - pub const WrongSideDeduction: Balance = 2 * COIN; - pub const MaxStrikes: u32 = 10; - pub const RotationPeriod: BlockNumber = 3 * MINUTES; - pub const PeriodSpend: Balance = 500 * COIN; - pub const MaxLockDuration: BlockNumber = 3 * MINUTES; - pub const ChallengePeriod: BlockNumber = 3 * MINUTES; -} -impl Config for Runtime { - type Event = Event; - type ModuleId = SocietyModuleId; - type Currency = Etp; - type Randomness = RandomnessCollectiveFlip; - type CandidateDeposit = CandidateDeposit; - type WrongSideDeduction = WrongSideDeduction; - type MaxStrikes = MaxStrikes; - type PeriodSpend = PeriodSpend; - type MembershipChanged = (); - type RotationPeriod = RotationPeriod; - type MaxLockDuration = MaxLockDuration; - type FounderSetOrigin = EnsureRootOrMoreThanHalfCouncil; - type SuspensionJudgementOrigin = EnsureFounder; - type ChallengePeriod = ChallengePeriod; -} diff --git a/bin/node/runtime/hyperspace/src/staking.rs b/bin/node/runtime/hyperspace/src/staking.rs deleted file mode 100644 index bd829b4..0000000 --- a/bin/node/runtime/hyperspace/src/staking.rs +++ /dev/null @@ -1,63 +0,0 @@ -// --- substrate --- -use frame_support::weights::{constants::BlockExecutionWeight, DispatchClass, Weight}; -use sp_runtime::{transaction_validity::TransactionPriority, ModuleId, Perbill}; -use sp_staking::SessionIndex; -// --- hyperspace --- -use crate::*; -use hyperspace_staking::{weights::SubstrateWeight, Config, EraIndex}; - -frame_support::parameter_types! { - pub const StakingModuleId: ModuleId = ModuleId(*b"da/staki"); - pub const SessionsPerEra: SessionIndex = SESSIONS_PER_ERA; - pub const BondingDurationInEra: EraIndex = 2; - pub const BondingDurationInBlockNumber: BlockNumber = 2 * BLOCKS_PER_SESSION * SESSIONS_PER_ERA; - pub const SlashDeferDuration: EraIndex = 1; - // quarter of the last session will be for election. - pub const ElectionLookahead: BlockNumber = BLOCKS_PER_SESSION / 2; - pub const MaxIterations: u32 = 5; - pub MinSolutionScoreBump: Perbill = Perbill::from_rational_approximation(5u32, 10_000); - pub const MaxNominatorRewardedPerValidator: u32 = 128; - pub const StakingUnsignedPriority: TransactionPriority = TransactionPriority::max_value() / 2; - pub OffchainSolutionWeightLimit: Weight = RuntimeBlockWeights::get() - .get(DispatchClass::Normal) - .max_extrinsic.expect("Normal extrinsics have a weight limit configured; qed") - .saturating_sub(BlockExecutionWeight::get()); - pub const Cap: Balance = CAP; - pub const TotalPower: Power = TOTAL_POWER; -} -impl Config for Runtime { - type Event = Event; - type ModuleId = StakingModuleId; - type UnixTime = Timestamp; - type SessionsPerEra = SessionsPerEra; - type BondingDurationInEra = BondingDurationInEra; - type BondingDurationInBlockNumber = BondingDurationInBlockNumber; - type SlashDeferDuration = SlashDeferDuration; - /// A super-majority of the council can cancel the slash. - type SlashCancelOrigin = EnsureRootOrHalfCouncil; - type SessionInterface = Self; - type NextNewSession = Session; - type ElectionLookahead = ElectionLookahead; - type Call = Call; - type MaxIterations = MaxIterations; - type MinSolutionScoreBump = MinSolutionScoreBump; - type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator; - type UnsignedPriority = StakingUnsignedPriority; - // The unsigned solution weight targeted by the OCW. We set it to the maximum possible value of - // a single extrinsic. - type OffchainSolutionWeightLimit = OffchainSolutionWeightLimit; - type EtpCurrency = Etp; - type EtpRewardRemainder = Treasury; - // send the slashed funds to the treasury. - type EtpSlash = Treasury; - // rewards are minted from the void - type EtpReward = (); - type DnaCurrency = Dna; - // send the slashed funds to the treasury. - type DnaSlash = Treasury; - // rewards are minted from the void - type DnaReward = (); - type Cap = Cap; - type TotalPower = TotalPower; - type WeightInfo = SubstrateWeight; -} diff --git a/bin/node/runtime/hyperspace/src/sudo.rs b/bin/node/runtime/hyperspace/src/sudo.rs deleted file mode 100644 index 6eface7..0000000 --- a/bin/node/runtime/hyperspace/src/sudo.rs +++ /dev/null @@ -1,9 +0,0 @@ -// --- substrate --- -use pallet_sudo::Config; -// --- hyperspace --- -use crate::*; - -impl Config for Runtime { - type Event = Event; - type Call = Call; -} diff --git a/bin/node/runtime/hyperspace/src/system.rs b/bin/node/runtime/hyperspace/src/system.rs deleted file mode 100644 index da38c12..0000000 --- a/bin/node/runtime/hyperspace/src/system.rs +++ /dev/null @@ -1,78 +0,0 @@ -// --- substrate --- -use frame_support::weights::{ - constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND}, - DispatchClass, Weight, -}; -use frame_system::{ - limits::{BlockLength, BlockWeights}, - weights::SubstrateWeight, - Config, -}; -use sp_runtime::{ - traits::{AccountIdLookup, BlakeTwo256}, - Perbill, -}; -use sp_version::RuntimeVersion; -// --- hyperspace --- -use crate::*; - -/// We assume that an on-initialize consumes 2.5% of the weight on average, hence a single extrinsic -/// will not be allowed to consume more than `AvailableBlockRatio - 2.5%`. -const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(25); -/// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used -/// by Operational extrinsics. -const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); -/// We allow for 2 seconds of compute with a 6 second average block time. -const MAXIMUM_BLOCK_WEIGHT: Weight = 2 * WEIGHT_PER_SECOND; -static_assertions::const_assert!( - NORMAL_DISPATCH_RATIO.deconstruct() >= AVERAGE_ON_INITIALIZE_RATIO.deconstruct() -); -frame_support::parameter_types! { - pub const BlockHashCount: BlockNumber = 2400; - pub const Version: RuntimeVersion = VERSION; - pub RuntimeBlockLength: BlockLength = - BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO); - pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder() - .base_block(BlockExecutionWeight::get()) - .for_class(DispatchClass::all(), |weights| { - weights.base_extrinsic = ExtrinsicBaseWeight::get(); - }) - .for_class(DispatchClass::Normal, |weights| { - weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT); - }) - .for_class(DispatchClass::Operational, |weights| { - weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT); - // Operational transactions have some extra reserved space, so that they - // are included even if block reached `MAXIMUM_BLOCK_WEIGHT`. - weights.reserved = Some( - MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT - ); - }) - .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO) - .build_or_panic(); - pub const SS58Prefix: u8 = 18; -} -impl Config for Runtime { - type BaseCallFilter = (); - type BlockWeights = RuntimeBlockWeights; - type BlockLength = RuntimeBlockLength; - type DbWeight = RocksDbWeight; - type Origin = Origin; - type Call = Call; - type Index = Nonce; - type BlockNumber = BlockNumber; - type Hash = Hash; - type Hashing = BlakeTwo256; - type AccountId = AccountId; - type Lookup = AccountIdLookup; - type Header = Header; - type Event = Event; - type BlockHashCount = BlockHashCount; - type Version = Version; - type PalletInfo = PalletInfo; - type AccountData = AccountData; - type OnNewAccount = (); - type OnKilledAccount = (); - type SystemWeightInfo = SubstrateWeight; - type SS58Prefix = SS58Prefix; -} diff --git a/bin/node/runtime/hyperspace/src/timestamp.rs b/bin/node/runtime/hyperspace/src/timestamp.rs deleted file mode 100644 index 06a4fb6..0000000 --- a/bin/node/runtime/hyperspace/src/timestamp.rs +++ /dev/null @@ -1,14 +0,0 @@ -// --- substrate --- -use pallet_timestamp::{weights::SubstrateWeight, Config}; -// --- hyperspace --- -use crate::*; - -frame_support::parameter_types! { - pub const MinimumPeriod: Moment = SLOT_DURATION / 2; -} -impl Config for Runtime { - type Moment = Moment; - type OnTimestampSet = Babe; - type MinimumPeriod = MinimumPeriod; - type WeightInfo = SubstrateWeight; -} diff --git a/bin/node/runtime/hyperspace/src/transaction_payment.rs b/bin/node/runtime/hyperspace/src/transaction_payment.rs deleted file mode 100644 index a3b9264..0000000 --- a/bin/node/runtime/hyperspace/src/transaction_payment.rs +++ /dev/null @@ -1,29 +0,0 @@ -// --- substrate --- -use pallet_transaction_payment::{Config, CurrencyAdapter, Multiplier, TargetedFeeAdjustment}; -use sp_runtime::{FixedPointNumber, Perquintill}; -// --- hyperspace --- -use crate::*; - -/// Parameterized slow adjusting fee updated based on -/// https://w3f-research.readthedocs.io/en/latest/polkadot/Token%20Economics.html#-2.-slow-adjusting-mechanism -pub type SlowAdjustingFeeUpdate = - TargetedFeeAdjustment; -frame_support::parameter_types! { - pub const TransactionByteFee: Balance = 10 * MICRO; - /// The portion of the `AvailableBlockRatio` that we adjust the fees with. Blocks filled less - /// than this will decrease the weight and more will increase. - pub const TargetBlockFullness: Perquintill = Perquintill::from_percent(25); - /// The adjustment variable of the runtime. Higher values will cause `TargetBlockFullness` to - /// change the fees more rapidly. - pub AdjustmentVariable: Multiplier = Multiplier::saturating_from_rational(3, 100_000); - /// Minimum amount of the multiplier. This value cannot be too low. A test case should ensure - /// that combined with `AdjustmentVariable`, we can recover from the minimum. - /// See `multiplier_can_grow_from_zero`. - pub MinimumMultiplier: Multiplier = Multiplier::saturating_from_rational(1, 1_000_000_000u128); -} -impl Config for Runtime { - type OnChargeTransaction = CurrencyAdapter; - type TransactionByteFee = TransactionByteFee; - type WeightToFee = WeightToFee; - type FeeMultiplierUpdate = SlowAdjustingFeeUpdate; -} diff --git a/bin/node/runtime/hyperspace/src/treasury.rs b/bin/node/runtime/hyperspace/src/treasury.rs deleted file mode 100644 index 37b3579..0000000 --- a/bin/node/runtime/hyperspace/src/treasury.rs +++ /dev/null @@ -1,53 +0,0 @@ -// --- substrate --- -use sp_runtime::{ModuleId, Percent, Permill}; -// --- hyperspace --- -use crate::*; -use hyperspace_treasury::{weights::SubstrateWeight, Config}; - -frame_support::parameter_types! { - pub const TreasuryModuleId: ModuleId = ModuleId(*b"da/trsry"); - pub const ProposalBond: Permill = Permill::from_percent(5); - pub const EtpProposalBondMinimum: Balance = 20 * COIN; - pub const DnaProposalBondMinimum: Balance = 20 * COIN; - pub const SpendPeriod: BlockNumber = 3 * MINUTES; - pub const Burn: Permill = Permill::from_percent(0); - pub const TipCountdown: BlockNumber = 3 * MINUTES; - pub const TipFindersFee: Percent = Percent::from_percent(20); - pub const TipReportDepositBase: Balance = 1 * COIN; - pub const DataDepositPerByte: Balance = 1 * MILLI; - pub const BountyDepositBase: Balance = 1 * COIN; - pub const BountyDepositPayoutDelay: BlockNumber = 3 * MINUTES; - pub const BountyUpdatePeriod: BlockNumber = 3 * MINUTES; - pub const MaximumReasonLength: u32 = 16384; - pub const BountyCuratorDeposit: Permill = Permill::from_percent(50); - pub const BountyValueMinimum: Balance = 2 * COIN; -} -impl Config for Runtime { - type ModuleId = TreasuryModuleId; - type EtpCurrency = Etp; - type DnaCurrency = Dna; - type ApproveOrigin = ApproveOrigin; - type RejectOrigin = EnsureRootOrMoreThanHalfCouncil; - type Tippers = ElectionsPhragmen; - type TipCountdown = TipCountdown; - type TipFindersFee = TipFindersFee; - type TipReportDepositBase = TipReportDepositBase; - type DataDepositPerByte = DataDepositPerByte; - type Event = Event; - type OnSlashEtp = Treasury; - type OnSlashDna = Treasury; - type ProposalBond = ProposalBond; - type EtpProposalBondMinimum = EtpProposalBondMinimum; - type DnaProposalBondMinimum = DnaProposalBondMinimum; - type SpendPeriod = SpendPeriod; - type Burn = Burn; - type BountyDepositBase = BountyDepositBase; - type BountyDepositPayoutDelay = BountyDepositPayoutDelay; - type BountyUpdatePeriod = BountyUpdatePeriod; - type MaximumReasonLength = MaximumReasonLength; - type BountyCuratorDeposit = BountyCuratorDeposit; - type BountyValueMinimum = BountyValueMinimum; - type EtpBurnDestination = (); - type DnaBurnDestination = (); - type WeightInfo = SubstrateWeight; -} diff --git a/bin/node/runtime/hyperspace/src/utility.rs b/bin/node/runtime/hyperspace/src/utility.rs deleted file mode 100644 index cc21869..0000000 --- a/bin/node/runtime/hyperspace/src/utility.rs +++ /dev/null @@ -1,10 +0,0 @@ -// --- substrate --- -use pallet_utility::Config; -// --- hyperspace --- -use crate::*; - -impl Config for Runtime { - type Event = Event; - type Call = Call; - type WeightInfo = (); -} diff --git a/bin/node/runtime/hyperspace/src/vesting.rs b/bin/node/runtime/hyperspace/src/vesting.rs deleted file mode 100644 index ca553ac..0000000 --- a/bin/node/runtime/hyperspace/src/vesting.rs +++ /dev/null @@ -1,16 +0,0 @@ -// --- substrate --- -use sp_runtime::traits::ConvertInto; -// --- hyperspace --- -use crate::*; -use hyperspace_vesting::Config; - -frame_support::parameter_types! { - pub const MinVestedTransfer: Balance = 100 * MILLI; -} -impl Config for Runtime { - type Event = Event; - type Currency = Etp; - type BlockNumberToBalance = ConvertInto; - type MinVestedTransfer = MinVestedTransfer; - type WeightInfo = (); -} diff --git a/client/cli/Cargo.toml b/client/cli/Cargo.toml index cf41af0..0e3d284 100644 --- a/client/cli/Cargo.toml +++ b/client/cli/Cargo.toml @@ -7,14 +7,14 @@ license = "GPL-3.0" name = "hyperspace-cli" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" +version = "1.4.0" [dependencies] # crates serde = { version = "1.0.124", features = ["derive"] } toml = { version = "0.5.7" } # substrate -sc-cli = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sc-client-api = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sc-service = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sc-tracing = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sc-cli = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sc-client-api = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sc-service = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sc-tracing = { git = "https://github.com/new-mvs/substrate", branch = "latest" } diff --git a/client/dvm/consensus/Cargo.toml b/client/dvm/consensus/Cargo.toml index 35ffce6..4b19e28 100644 --- a/client/dvm/consensus/Cargo.toml +++ b/client/dvm/consensus/Cargo.toml @@ -4,29 +4,28 @@ description = "Consensus for hyperspace dvm" edition = "2018" homepage = "https://mvs.org/" license = "GPL-3.0" -name = "dc-consensus" +name = "dvm-consensus" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" +version = "1.4.0" [dependencies] # crates codec = { package = "parity-scale-codec", version = "1.3.7", features = ["derive"] } -dc-db = { path = "../db" } derive_more = { version = "0.99.11" } +ethereum = { version = "0.6.0", features = ["with-codec"] } futures = { version = "0.3.13", features = ["compat"] } log = { version = "0.4.14" } # hyperspace -dp_consensus = { path = "../../../primitives/consensus/" } -dvm-rpc-runtime-api = { path = "../../../frame/dvm/rpc/runtime-api"} +dvm-consensus-primitives = { path = "../../../primitives/consensus/" } # substrate -prometheus-endpoint = { package = "substrate-prometheus-endpoint", git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sc-client-api = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-api = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-block-builder = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-blockchain = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-consensus = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-core = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-inherents = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-runtime = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-timestamp = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +prometheus-endpoint = { package = "substrate-prometheus-endpoint", git = "https://github.com/new-mvs/substrate", branch = "latest" } +sc-client-api = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-api = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-block-builder = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-blockchain = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-consensus = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-core = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-inherents = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-runtime = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-timestamp = { git = "https://github.com/new-mvs/substrate", branch = "latest" } diff --git a/client/dvm/consensus/src/lib.rs b/client/dvm/consensus/src/lib.rs index 86ff6ac..689efe3 100644 --- a/client/dvm/consensus/src/lib.rs +++ b/client/dvm/consensus/src/lib.rs @@ -16,10 +16,13 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -// --- hyperspace --- -use dp_consensus::{ensure_log, FindLogError}; -use dvm_rpc_runtime_api::EthereumRuntimeRPCApi; -// --- substrate --- +mod aux_schema; + +pub use crate::aux_schema::{load_block_hash, load_transaction_metadata}; + +use dvm_consensus_primitives::{ConsensusLog, FRONTIER_ENGINE_ID}; +use log::*; +use sc_client_api; use sc_client_api::{backend::AuxStore, BlockOf}; use sp_api::ProvideRuntimeApi; use sp_block_builder::BlockBuilder as BlockBuilderApi; @@ -27,20 +30,18 @@ use sp_blockchain::{well_known_cache_keys::Id as CacheKeyId, HeaderBackend, Prov use sp_consensus::{ BlockCheckParams, BlockImport, BlockImportParams, Error as ConsensusError, ImportResult, }; +use sp_runtime::generic::OpaqueDigestItemId; use sp_runtime::traits::{Block as BlockT, Header as HeaderT}; -// --- std --- use std::collections::HashMap; use std::marker::PhantomData; use std::sync::Arc; #[derive(derive_more::Display, Debug)] pub enum Error { - #[display(fmt = "Multiple runtime Ethereum blocks, rejecting!")] - MultipleRuntimeLogs, - #[display(fmt = "Runtime Ethereum block not found, rejecting!")] - NoRuntimeLog, - #[display(fmt = "Cannot access the runtime at genesis, rejecting!")] - RuntimeApiCallFailed, + #[display(fmt = "Multiple post-runtime Ethereum blocks, rejecting!")] + MultiplePostRuntimeLogs, + #[display(fmt = "Post-runtime Ethereum block not found, rejecting!")] + NoPostRuntimeLog, } impl From for String { @@ -49,16 +50,7 @@ impl From for String { } } -impl From for Error { - fn from(error: FindLogError) -> Error { - match error { - FindLogError::NotFound => Error::NoRuntimeLog, - FindLogError::MultipleLogs => Error::MultipleRuntimeLogs, - } - } -} - -impl From for ConsensusError { +impl std::convert::From for ConsensusError { fn from(error: Error) -> ConsensusError { ConsensusError::ClientImport(error.to_string()) } @@ -67,7 +59,7 @@ impl From for ConsensusError { pub struct FrontierBlockImport { inner: I, client: Arc, - backend: Arc>, + enabled: bool, _marker: PhantomData, } @@ -76,7 +68,7 @@ impl, C> Clone for FrontierBlockImp FrontierBlockImport { inner: self.inner.clone(), client: self.client.clone(), - backend: self.backend.clone(), + enabled: self.enabled, _marker: PhantomData, } } @@ -88,14 +80,13 @@ where I: BlockImport> + Send + Sync, I::Error: Into, C: ProvideRuntimeApi + Send + Sync + HeaderBackend + AuxStore + ProvideCache + BlockOf, - C::Api: EthereumRuntimeRPCApi, C::Api: BlockBuilderApi, { - pub fn new(inner: I, client: Arc, backend: Arc>) -> Self { + pub fn new(inner: I, client: Arc, enabled: bool) -> Self { Self { inner, client, - backend, + enabled, _marker: PhantomData, } } @@ -107,7 +98,6 @@ where I: BlockImport> + Send + Sync, I::Error: Into, C: ProvideRuntimeApi + Send + Sync + HeaderBackend + AuxStore + ProvideCache + BlockOf, - C::Api: EthereumRuntimeRPCApi, C::Api: BlockBuilderApi, { type Error = ConsensusError; @@ -119,16 +109,65 @@ where fn import_block( &mut self, - block: BlockImportParams, + mut block: BlockImportParams, new_cache: HashMap>, ) -> Result { - // We validate that there are only one frontier log. No other - // actions are needed and mapping syncing is delegated to a separate - // worker. - ensure_log(&block.header.digest()).map_err(|e| Error::from(e))?; + macro_rules! insert_closure { + () => { + |insert| { + block + .auxiliary + .extend(insert.iter().map(|(k, v)| (k.to_vec(), Some(v.to_vec())))) + } + }; + } + + let client = self.client.clone(); + + if self.enabled { + let log = find_frontier_log::(&block.header)?; + let hash = block.post_hash(); + + match log { + ConsensusLog::EndBlock { + block_hash, + transaction_hashes, + } => { + aux_schema::write_block_hash( + client.as_ref(), + block_hash, + hash, + insert_closure!(), + ); + + for (index, transaction_hash) in transaction_hashes.into_iter().enumerate() { + aux_schema::write_transaction_metadata( + transaction_hash, + (block_hash, index as u32), + insert_closure!(), + ); + } + } + } + } self.inner .import_block(block, new_cache) .map_err(Into::into) } } + +fn find_frontier_log(header: &B::Header) -> Result { + let mut frontier_log: Option<_> = None; + for log in header.digest().logs() { + trace!(target: "dvm-consensus", "Checking log {:?}, looking for ethereum block.", log); + let log = log.try_to::(OpaqueDigestItemId::Consensus(&FRONTIER_ENGINE_ID)); + match (log, frontier_log.is_some()) { + (Some(_), true) => return Err(Error::MultiplePostRuntimeLogs), + (Some(log), false) => frontier_log = Some(log), + _ => trace!(target: "dvm-consensus", "Ignoring digest not meant for us"), + } + } + + Ok(frontier_log.ok_or(Error::NoPostRuntimeLog)?) +} diff --git a/client/dvm/db/Cargo.toml b/client/dvm/db/Cargo.toml deleted file mode 100644 index ed17c66..0000000 --- a/client/dvm/db/Cargo.toml +++ /dev/null @@ -1,21 +0,0 @@ -[package] -authors = ["Hyperspace Network "] -description = "Dvm database backend" -edition = "2018" -homepage = "https://mvs.org/" -license = "GPL-3.0" -name = "dc-db" -readme = "README.md" -repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" - -[dependencies] -# crates -codec = { package = "parity-scale-codec", version = "1.3.7", features = ["derive"] } -kvdb = "0.8.0" -kvdb-rocksdb = "0.10.0" -parking_lot = "0.11.1" -# substrate -sp-core = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-database = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-runtime = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } diff --git a/client/dvm/db/src/lib.rs b/client/dvm/db/src/lib.rs deleted file mode 100644 index 453e5e7..0000000 --- a/client/dvm/db/src/lib.rs +++ /dev/null @@ -1,227 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 -// This file is part of Frontier. -// -// Copyright (c) 2021 Parity Technologies (UK) Ltd. -// -// This program 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. -// -// This program 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 this program. If not, see . - -mod utils; - -// --- substrate --- -pub use sp_database::Database; -// --- hyperspace --- -use codec::{Decode, Encode}; -use parking_lot::Mutex; -use sp_core::H256; -use sp_runtime::traits::Block as BlockT; -// --- std --- -use std::{ - marker::PhantomData, - path::{Path, PathBuf}, - sync::Arc, -}; - -const DB_HASH_LEN: usize = 32; -/// Hash type that this backend uses for the database. -pub type DbHash = [u8; DB_HASH_LEN]; - -/// Database settings. -pub struct DatabaseSettings { - /// Where to find the database. - pub source: DatabaseSettingsSrc, -} - -/// Where to find the database. -#[derive(Debug, Clone)] -pub enum DatabaseSettingsSrc { - /// Load a RocksDB database from a given path. Recommended for most uses. - RocksDb { - /// Path to the database. - path: PathBuf, - /// Cache size in MiB. - cache_size: usize, - }, -} - -impl DatabaseSettingsSrc { - /// Return dabase path for databases that are on the disk. - pub fn path(&self) -> Option<&Path> { - match self { - DatabaseSettingsSrc::RocksDb { path, .. } => Some(path.as_path()), - } - } -} - -pub(crate) mod columns { - pub const NUM_COLUMNS: u32 = 3; - - pub const META: u32 = 0; - pub const BLOCK_MAPPING: u32 = 1; - pub const TRANSACTION_MAPPING: u32 = 2; -} - -pub(crate) mod static_keys { - pub const CURRENT_SYNCING_TIPS: &[u8] = b"CURRENT_SYNCING_TIPS"; -} - -pub struct Backend { - meta: Arc>, - mapping: Arc>, -} - -impl Backend { - pub fn new(config: &DatabaseSettings) -> Result { - let db = utils::open_database(config)?; - - Ok(Self { - mapping: Arc::new(MappingDb { - db: db.clone(), - write_lock: Arc::new(Mutex::new(())), - _marker: PhantomData, - }), - meta: Arc::new(MetaDb { - db: db.clone(), - _marker: PhantomData, - }), - }) - } - - pub fn mapping(&self) -> &Arc> { - &self.mapping - } - - pub fn meta(&self) -> &Arc> { - &self.meta - } -} - -pub struct MetaDb { - db: Arc>, - _marker: PhantomData, -} - -impl MetaDb { - pub fn current_syncing_tips(&self) -> Result, String> { - match self.db.get( - crate::columns::META, - &crate::static_keys::CURRENT_SYNCING_TIPS, - ) { - Some(raw) => { - Ok(Vec::::decode(&mut &raw[..]).map_err(|e| format!("{:?}", e))?) - } - None => Ok(Vec::new()), - } - } - - pub fn write_current_syncing_tips(&self, tips: Vec) -> Result<(), String> { - let mut transaction = sp_database::Transaction::new(); - - transaction.set( - crate::columns::META, - crate::static_keys::CURRENT_SYNCING_TIPS, - &tips.encode(), - ); - - self.db - .commit(transaction) - .map_err(|e| format!("{:?}", e))?; - - Ok(()) - } -} - -pub struct MappingCommitment { - pub block_hash: Block::Hash, - pub ethereum_block_hash: H256, - pub ethereum_transaction_hashes: Vec, -} - -#[derive(Clone, Encode, Decode)] -pub struct TransactionMetadata { - pub block_hash: Block::Hash, - pub ethereum_block_hash: H256, - pub ethereum_index: u32, -} - -pub struct MappingDb { - db: Arc>, - write_lock: Arc>, - _marker: PhantomData, -} - -impl MappingDb { - pub fn block_hashes(&self, ethereum_block_hash: &H256) -> Result, String> { - match self - .db - .get(crate::columns::BLOCK_MAPPING, ðereum_block_hash.encode()) - { - Some(raw) => { - Ok(Vec::::decode(&mut &raw[..]).map_err(|e| format!("{:?}", e))?) - } - None => Ok(Vec::new()), - } - } - - pub fn transaction_metadata( - &self, - ethereum_transaction_hash: &H256, - ) -> Result>, String> { - match self.db.get( - crate::columns::TRANSACTION_MAPPING, - ðereum_transaction_hash.encode(), - ) { - Some(raw) => Ok(Vec::>::decode(&mut &raw[..]) - .map_err(|e| format!("{:?}", e))?), - None => Ok(Vec::new()), - } - } - - pub fn write_hashes(&self, commitment: MappingCommitment) -> Result<(), String> { - let _lock = self.write_lock.lock(); - - let mut transaction = sp_database::Transaction::new(); - - let mut block_hashes = self.block_hashes(&commitment.ethereum_block_hash)?; - block_hashes.push(commitment.block_hash); - transaction.set( - crate::columns::BLOCK_MAPPING, - &commitment.ethereum_block_hash.encode(), - &block_hashes.encode(), - ); - - for (i, ethereum_transaction_hash) in commitment - .ethereum_transaction_hashes - .into_iter() - .enumerate() - { - let mut metadata = self.transaction_metadata(ðereum_transaction_hash)?; - metadata.push(TransactionMetadata:: { - block_hash: commitment.block_hash, - ethereum_block_hash: commitment.ethereum_block_hash, - ethereum_index: i as u32, - }); - transaction.set( - crate::columns::TRANSACTION_MAPPING, - ðereum_transaction_hash.encode(), - &metadata.encode(), - ); - } - - self.db - .commit(transaction) - .map_err(|e| format!("{:?}", e))?; - - Ok(()) - } -} diff --git a/client/dvm/db/src/utils.rs b/client/dvm/db/src/utils.rs deleted file mode 100644 index 8a07487..0000000 --- a/client/dvm/db/src/utils.rs +++ /dev/null @@ -1,40 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 -// This file is part of Frontier. -// -// Copyright (c) 2020 Parity Technologies (UK) Ltd. -// -// This program 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. -// -// This program 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 this program. If not, see . - -use crate::{Database, DatabaseSettings, DatabaseSettingsSrc, DbHash}; -use std::sync::Arc; - -pub fn open_database(config: &DatabaseSettings) -> Result>, String> { - let db: Arc> = match &config.source { - DatabaseSettingsSrc::RocksDb { - path, - cache_size: _, - } => { - let db_config = kvdb_rocksdb::DatabaseConfig::with_columns(crate::columns::NUM_COLUMNS); - let path = path - .to_str() - .ok_or_else(|| "Invalid database path".to_string())?; - - let db = kvdb_rocksdb::Database::open(&db_config, &path) - .map_err(|err| format!("{}", err))?; - sp_database::as_database(db) - } - }; - - Ok(db) -} diff --git a/client/dvm/mapping-sync/Cargo.toml b/client/dvm/mapping-sync/Cargo.toml deleted file mode 100644 index 2c8964f..0000000 --- a/client/dvm/mapping-sync/Cargo.toml +++ /dev/null @@ -1,26 +0,0 @@ -[package] -authors = ["Hyperspace Network "] -description = "Mapping sync logic for dvm." -edition = "2018" -homepage = "https://mvs.org/" -license = "GPL-3.0" -name = "dc-mapping-sync" -readme = "README.md" -repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" - -[dependencies] -# substrate -sp-api = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-blockchain = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sc-client-api = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-runtime = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -# hyperspace -dc-consensus = { path = "../consensus" } -dc-db = { path = "../db" } -dp_consensus = { path = "../../../primitives/consensus/" } -dvm-rpc-runtime-api = { path = "../../../frame/dvm/rpc/runtime-api"} -# crates -futures = { version = "0.3.1", features = ["compat"] } -futures-timer = "3.0.1" -log = "0.4.8" \ No newline at end of file diff --git a/client/dvm/mapping-sync/src/lib.rs b/client/dvm/mapping-sync/src/lib.rs deleted file mode 100644 index 367ee87..0000000 --- a/client/dvm/mapping-sync/src/lib.rs +++ /dev/null @@ -1,162 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 -// This file is part of Frontier. -// -// Copyright (c) 2020 Parity Technologies (UK) Ltd. -// -// This program 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. -// -// This program 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 this program. If not, see . - -mod worker; - -pub use worker::MappingSyncWorker; - -// --- hyperspace --- -use dvm_rpc_runtime_api::EthereumRuntimeRPCApi; -// --- substrate --- -use sc_client_api::BlockOf; -use sp_api::ProvideRuntimeApi; -use sp_blockchain::HeaderBackend; -use sp_runtime::{ - generic::BlockId, - traits::{Block as BlockT, Header as HeaderT, Zero}, -}; - -pub fn sync_block( - backend: &dc_db::Backend, - header: &Block::Header, -) -> Result<(), String> { - let log = dp_consensus::find_log(header.digest()).map_err(|e| format!("{:?}", e))?; - let post_hashes = log.into_hashes(); - - let mapping_commitment = dc_db::MappingCommitment { - block_hash: header.hash(), - ethereum_block_hash: post_hashes.block_hash, - ethereum_transaction_hashes: post_hashes.transaction_hashes, - }; - backend.mapping().write_hashes(mapping_commitment)?; - - Ok(()) -} - -pub fn sync_genesis_block( - client: &C, - backend: &dc_db::Backend, - header: &Block::Header, -) -> Result<(), String> -where - C: ProvideRuntimeApi + Send + Sync + HeaderBackend + BlockOf, - C::Api: EthereumRuntimeRPCApi, -{ - let id = BlockId::Hash(header.hash()); - - let block = client - .runtime_api() - .current_block(&id) - .map_err(|e| format!("{:?}", e))?; - let block_hash = block - .ok_or("Ethereum genesis block not found".to_string())? - .header - .hash(); - let mapping_commitment = dc_db::MappingCommitment:: { - block_hash: header.hash(), - ethereum_block_hash: block_hash, - ethereum_transaction_hashes: Vec::new(), - }; - backend.mapping().write_hashes(mapping_commitment)?; - - Ok(()) -} - -pub fn sync_one_level( - client: &C, - substrate_backend: &B, - frontier_backend: &dc_db::Backend, -) -> Result -where - C: ProvideRuntimeApi + Send + Sync + HeaderBackend + BlockOf, - C::Api: EthereumRuntimeRPCApi, - B: sp_blockchain::HeaderBackend + sp_blockchain::Backend, -{ - let mut current_syncing_tips = frontier_backend.meta().current_syncing_tips()?; - - if current_syncing_tips.len() == 0 { - // Sync genesis block. - - let header = substrate_backend - .header(BlockId::Number(Zero::zero())) - .map_err(|e| format!("{:?}", e))? - .ok_or("Genesis header not found".to_string())?; - sync_genesis_block(client, frontier_backend, &header)?; - - current_syncing_tips.push(header.hash()); - frontier_backend - .meta() - .write_current_syncing_tips(current_syncing_tips)?; - - Ok(true) - } else { - let mut syncing_tip_and_children = None; - - for tip in ¤t_syncing_tips { - let children = substrate_backend - .children(*tip) - .map_err(|e| format!("{:?}", e))?; - - if children.len() > 0 { - syncing_tip_and_children = Some((*tip, children)); - break; - } - } - - if let Some((syncing_tip, children)) = syncing_tip_and_children { - current_syncing_tips.retain(|tip| tip != &syncing_tip); - - for child in children { - let header = substrate_backend - .header(BlockId::Hash(child)) - .map_err(|e| format!("{:?}", e))? - .ok_or("Header not found".to_string())?; - - sync_block(frontier_backend, &header)?; - current_syncing_tips.push(child); - } - frontier_backend - .meta() - .write_current_syncing_tips(current_syncing_tips)?; - - Ok(true) - } else { - Ok(false) - } - } -} - -pub fn sync_blocks( - client: &C, - substrate_backend: &B, - frontier_backend: &dc_db::Backend, - limit: usize, -) -> Result -where - C: ProvideRuntimeApi + Send + Sync + HeaderBackend + BlockOf, - C::Api: EthereumRuntimeRPCApi, - B: sp_blockchain::HeaderBackend + sp_blockchain::Backend, -{ - let mut synced_any = false; - - for _ in 0..limit { - synced_any = synced_any || sync_one_level(client, substrate_backend, frontier_backend)?; - } - - Ok(synced_any) -} diff --git a/client/dvm/mapping-sync/src/worker.rs b/client/dvm/mapping-sync/src/worker.rs deleted file mode 100644 index 47eef15..0000000 --- a/client/dvm/mapping-sync/src/worker.rs +++ /dev/null @@ -1,129 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 -// This file is part of Frontier. -// -// Copyright (c) 2020 Parity Technologies (UK) Ltd. -// -// This program 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. -// -// This program 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 this program. If not, see . - -// --- hyperspace --- -use dvm_rpc_runtime_api::EthereumRuntimeRPCApi; -// --- substrate --- -use sc_client_api::{BlockOf, ImportNotifications}; -use sp_api::ProvideRuntimeApi; -use sp_blockchain::HeaderBackend; -use sp_runtime::traits::Block as BlockT; -use std::{pin::Pin, sync::Arc, time::Duration}; -// --- std --- -use futures::{ - prelude::*, - task::{Context, Poll}, -}; -use futures_timer::Delay; -use log::warn; - -const LIMIT: usize = 8; - -pub struct MappingSyncWorker { - import_notifications: ImportNotifications, - timeout: Duration, - inner_delay: Option, - - client: Arc, - substrate_backend: Arc, - frontier_backend: Arc>, - - have_next: bool, -} - -impl MappingSyncWorker { - pub fn new( - import_notifications: ImportNotifications, - timeout: Duration, - client: Arc, - substrate_backend: Arc, - frontier_backend: Arc>, - ) -> Self { - Self { - import_notifications, - timeout, - inner_delay: None, - - client, - substrate_backend, - frontier_backend, - - have_next: true, - } - } -} - -impl Stream for MappingSyncWorker -where - C: ProvideRuntimeApi + Send + Sync + HeaderBackend + BlockOf, - C::Api: EthereumRuntimeRPCApi, - B: sc_client_api::Backend, -{ - type Item = (); - - fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll> { - let mut fire = false; - - loop { - match Stream::poll_next(Pin::new(&mut self.import_notifications), cx) { - Poll::Pending => break, - Poll::Ready(Some(_)) => { - fire = true; - } - Poll::Ready(None) => return Poll::Ready(None), - } - } - - let timeout = self.timeout.clone(); - let inner_delay = self.inner_delay.get_or_insert_with(|| Delay::new(timeout)); - - match Future::poll(Pin::new(inner_delay), cx) { - Poll::Pending => (), - Poll::Ready(()) => { - fire = true; - } - } - - if self.have_next { - fire = true; - } - - if fire { - self.inner_delay = None; - - match crate::sync_blocks( - self.client.as_ref(), - self.substrate_backend.blockchain(), - self.frontier_backend.as_ref(), - LIMIT, - ) { - Ok(have_next) => { - self.have_next = have_next; - Poll::Ready(Some(())) - } - Err(e) => { - self.have_next = false; - warn!(target: "mapping-sync", "Syncing failed with error {:?}, retrying.", e); - Poll::Ready(Some(())) - } - } - } else { - Poll::Pending - } - } -} diff --git a/client/dvm/rpc/Cargo.toml b/client/dvm/rpc/Cargo.toml index fd65a4d..16f453c 100644 --- a/client/dvm/rpc/Cargo.toml +++ b/client/dvm/rpc/Cargo.toml @@ -4,14 +4,13 @@ description = "Ethereum RPC (web3) compatibility layer for Hyperspace." edition = "2018" homepage = "https://mvs.org/" license = "GPL-3.0" -name = "dc-rpc" +name = "dvm-rpc" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" +version = "1.4.0" [dependencies] # crates -array-bytes = { version = "1.1.0" } codec = { package = "parity-scale-codec", version = "1.3.7" } ethereum = { version = "0.6.0", features = ["with-codec"] } ethereum-types = { version = "0.10.0" } @@ -25,27 +24,25 @@ log = { version = "0.4.14" } rand = { version = "0.7" } rlp = { version = "0.5.0" } sha3 = { version = "0.8" } +array-bytes = { version = "1.1.0" } # hyperspace -hyperspace-evm = { path = "../../../frame/evm" } -dc-consensus = { path = "../consensus" } -dc-db = { path = "../db" } -dp_consensus = { path = "../../../primitives/consensus/" } -dp-storage = { path = "../../../primitives/storage/" } -dvm-ethereum = { path = "../../../frame/dvm" } -dvm-rpc-core = { path = "../../../frame/dvm/rpc" } -dvm-rpc-runtime-api = { path = "../../../frame/dvm/rpc/runtime-api" } -dp-rpc = { path = "../../../primitives/rpc" } +hyperspace-evm = { path = "../../../frame/evm" } +dvm-consensus = { path = "../consensus" } +dvm-ethereum = { path = "../../../frame/dvm" } +dvm-rpc-core = { path = "../../../frame/dvm/rpc" } +dvm-rpc-core-primitives = { path = "../../../primitives/dvm-rpc-core" } +dvm-rpc-runtime-api = { path = "../../../frame/dvm/rpc/runtime-api" } # substrate -sc-client-api = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sc-network = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sc-rpc = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sc-service = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-api = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-blockchain = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-io = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-runtime = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-storage = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-transaction-pool = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sc-client-api = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sc-network = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sc-rpc = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sc-service = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-api = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-blockchain = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-io = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-runtime = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-storage = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-transaction-pool = { git = "https://github.com/new-mvs/substrate", branch = "latest" } [features] rpc_binary_search_estimate = [] diff --git a/client/dvm/rpc/src/eth.rs b/client/dvm/rpc/src/eth.rs index 2945896..9a2885d 100644 --- a/client/dvm/rpc/src/eth.rs +++ b/client/dvm/rpc/src/eth.rs @@ -14,91 +14,61 @@ // You should have received a copy of the GNU General Public License // along with Substrate. If not, see . -use crate::overrides::{RuntimeApiStorageOverride, StorageOverride}; -use crate::{error_on_execution_failure, internal_err, public_key, EthSigner}; -// --- hyperspace --- -use dp_rpc::{ - Block, BlockNumber, BlockTransactions, Bytes, CallRequest, Filter, FilterChanges, FilterPool, - FilterPoolItem, FilterType, FilteredParams, Index, Log, PendingTransaction, - PendingTransactions, Receipt, Rich, RichBlock, SyncInfo, SyncStatus, Transaction, - TransactionRequest, Work, +use crate::{error_on_execution_failure, internal_err, EthSigner}; +use codec::{self, Encode}; +use dvm_rpc_core::{EthApi as EthApiT, NetApi as NetApiT, Web3Api as Web3ApiT}; +use dvm_rpc_core_primitives::{ + Block, BlockNumber, BlockTransactions, Bytes, CallRequest, Filter, FilteredParams, Index, Log, + Receipt, Rich, RichBlock, SyncInfo, SyncStatus, Transaction, TransactionRequest, Work, }; -use dp_storage::PALLET_ETHEREUM_SCHEMA; -use dvm_ethereum::EthereumStorageSchema; -use dvm_rpc_core::{ - EthApi as EthApiT, EthFilterApi as EthFilterApiT, NetApi as NetApiT, Web3Api as Web3ApiT, -}; -pub use dvm_rpc_core::{EthApiServer, EthFilterApiServer, NetApiServer, Web3ApiServer}; use dvm_rpc_runtime_api::{ConvertTransaction, EthereumRuntimeRPCApi, TransactionStatus}; -// --- substrate --- -use sc_client_api::{ - backend::{AuxStore, Backend, StateBackend, StorageProvider}, - client::BlockchainEvents, +use ethereum::{ + Block as EthereumBlock, Transaction as EthereumTransaction, + TransactionMessage as EthereumTransactionMessage, }; -use sc_network::{ExHashT, NetworkService}; -use sp_api::{BlockId, Core, HeaderT, ProvideRuntimeApi}; -use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata}; -use sp_runtime::traits::BlakeTwo256; -use sp_runtime::traits::{Block as BlockT, One, Saturating, UniqueSaturatedInto, Zero}; -use sp_runtime::transaction_validity::TransactionSource; -use sp_storage::StorageKey; -use sp_transaction_pool::{InPoolTransaction, TransactionPool}; -// --- std --- -use codec::{self, Decode, Encode}; -use ethereum::{Block as EthereumBlock, Transaction as EthereumTransaction}; use ethereum_types::{H160, H256, H512, H64, U256, U64}; -use futures::{future::TryFutureExt, StreamExt}; +use futures::future::TryFutureExt; use jsonrpc_core::{ futures::future::{self, Future}, BoxFuture, Result, }; +use sc_client_api::backend::{AuxStore, Backend, StateBackend, StorageProvider}; +use sc_network::{ExHashT, NetworkService}; use sha3::{Digest, Keccak256}; -use std::collections::{BTreeMap, HashMap}; -use std::{ - marker::PhantomData, - sync::{Arc, Mutex}, -}; +use sp_api::{BlockId, Core, ProvideRuntimeApi}; +use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata}; +use sp_runtime::traits::BlakeTwo256; +use sp_runtime::traits::{Block as BlockT, One, Saturating, UniqueSaturatedInto, Zero}; +use sp_runtime::transaction_validity::TransactionSource; +use sp_transaction_pool::{InPoolTransaction, TransactionPool}; +use std::collections::BTreeMap; +use std::{marker::PhantomData, sync::Arc}; + +pub use dvm_rpc_core::{EthApiServer, NetApiServer, Web3ApiServer}; pub struct EthApi { pool: Arc

, client: Arc, convert_transaction: CT, network: Arc>, - overrides: BTreeMap + Send + Sync>>, - fallback: Box + Send + Sync>, - pending_transactions: PendingTransactions, - backend: Arc>, is_authority: bool, signers: Vec>, _marker: PhantomData<(B, BE)>, } -impl EthApi -where - C: ProvideRuntimeApi, - C::Api: EthereumRuntimeRPCApi, - B: BlockT + Send + Sync + 'static, - C: Send + Sync + 'static, -{ +impl EthApi { pub fn new( client: Arc, pool: Arc

, convert_transaction: CT, network: Arc>, - overrides: BTreeMap + Send + Sync>>, - pending_transactions: PendingTransactions, - backend: Arc>, is_authority: bool, ) -> Self { Self { - client: client.clone(), + client, pool, convert_transaction, network, - overrides, - fallback: Box::new(RuntimeApiStorageOverride::new(client)), - pending_transactions, - backend, is_authority, signers: Vec::new(), _marker: PhantomData, @@ -131,7 +101,7 @@ fn rich_block_build( logs_bloom: Some(block.header.logs_bloom), timestamp: U256::from(block.header.timestamp / 1000), difficulty: block.header.difficulty, - total_difficulty: U256::zero(), + total_difficulty: None, seal_fields: vec![ Bytes(block.header.mix_hash.as_bytes().to_vec()), Bytes(block.header.nonce.as_bytes().to_vec()), @@ -147,8 +117,8 @@ fn rich_block_build( .map(|(index, transaction)| { transaction_build( transaction.clone(), - Some(block.clone()), - Some(statuses[index].clone().unwrap_or_default()), + block.clone(), + statuses[index].clone().unwrap_or_default(), ) }) .collect(), @@ -176,55 +146,40 @@ fn rich_block_build( fn transaction_build( transaction: EthereumTransaction, - block: Option, - status: Option, + block: EthereumBlock, + status: TransactionStatus, ) -> Transaction { - let pubkey = match public_key(&transaction) { - Ok(p) => Some(p), + let mut sig = [0u8; 65]; + let mut msg = [0u8; 32]; + sig[0..32].copy_from_slice(&transaction.signature.r()[..]); + sig[32..64].copy_from_slice(&transaction.signature.s()[..]); + sig[64] = transaction.signature.standard_v(); + msg.copy_from_slice(&EthereumTransactionMessage::from(transaction.clone()).hash()[..]); + + let pubkey = match sp_io::crypto::secp256k1_ecdsa_recover(&sig, &msg) { + Ok(p) => Some(H512::from(p)), Err(_e) => None, }; Transaction { hash: H256::from_slice(Keccak256::digest(&rlp::encode(&transaction)).as_slice()), nonce: transaction.nonce, - block_hash: block.as_ref().map_or(None, |block| { - Some(H256::from_slice( - Keccak256::digest(&rlp::encode(&block.header)).as_slice(), - )) - }), - block_number: block.as_ref().map(|block| block.header.number), - transaction_index: status.as_ref().map(|status| { - U256::from(UniqueSaturatedInto::::unique_saturated_into( - status.transaction_index, - )) - }), - from: status.as_ref().map_or( - { - match pubkey { - Some(pk) => H160::from(H256::from_slice(Keccak256::digest(&pk).as_slice())), - _ => H160::default(), - } - }, - |status| status.from, - ), - to: status.as_ref().map_or( - { - match transaction.action { - ethereum::TransactionAction::Call(to) => Some(to), - _ => None, - } - }, - |status| status.to, - ), + block_hash: Some(H256::from_slice( + Keccak256::digest(&rlp::encode(&block.header)).as_slice(), + )), + block_number: Some(block.header.number), + transaction_index: Some(U256::from( + UniqueSaturatedInto::::unique_saturated_into(status.transaction_index), + )), + from: status.from, + to: status.to, value: transaction.value, gas_price: transaction.gas_price, gas: transaction.gas_limit, input: Bytes(transaction.clone().input), - creates: status - .as_ref() - .map_or(None, |status| status.contract_address), + creates: status.contract_address, raw: Bytes(rlp::encode(&transaction).to_vec()), - public_key: pubkey.as_ref().map(|pk| H512::from(pk)), + public_key: pubkey, chain_id: transaction.signature.chain_id().map(U64::from), standard_v: U256::from(transaction.signature.standard_v()), v: U256::from(transaction.signature.v()), @@ -233,67 +188,8 @@ fn transaction_build( } } -fn logs_build( - filter: Filter, - blocks_and_statuses: Vec<(EthereumBlock, Vec)>, -) -> Vec { - let params = FilteredParams::new(Some(filter.clone())); - let mut ret = Vec::new(); - for (block, statuses) in blocks_and_statuses { - let mut block_log_index: u32 = 0; - let block_hash = - H256::from_slice(Keccak256::digest(&rlp::encode(&block.header)).as_slice()); - for status in statuses.iter() { - let logs = status.logs.clone(); - let mut transaction_log_index: u32 = 0; - let transaction_hash = status.transaction_hash; - for ethereum_log in logs { - let mut log = Log { - address: ethereum_log.address.clone(), - topics: ethereum_log.topics.clone(), - data: Bytes(ethereum_log.data.clone()), - block_hash: None, - block_number: None, - transaction_hash: None, - transaction_index: None, - log_index: None, - transaction_log_index: None, - removed: false, - }; - let mut add: bool = true; - if let (Some(_), Some(_)) = (filter.address.clone(), filter.topics.clone()) { - if !params.filter_address(&log) || !params.filter_topics(&log) { - add = false; - } - } else if let Some(_) = filter.address { - if !params.filter_address(&log) { - add = false; - } - } else if let Some(_) = &filter.topics { - if !params.filter_topics(&log) { - add = false; - } - } - if add { - log.block_hash = Some(block_hash); - log.block_number = Some(block.header.number.clone()); - log.transaction_hash = Some(transaction_hash); - log.transaction_index = Some(U256::from(status.transaction_index)); - log.log_index = Some(U256::from(block_log_index)); - log.transaction_log_index = Some(U256::from(transaction_log_index)); - ret.push(log); - } - transaction_log_index += 1; - block_log_index += 1; - } - } - } - ret -} - impl EthApi where - B: BlockT, C: ProvideRuntimeApi + StorageProvider + AuxStore, C: HeaderBackend + HeaderMetadata + 'static, C::Api: EthereumRuntimeRPCApi, @@ -316,14 +212,21 @@ where // Asumes there is only one mapped canonical block in the AuxStore, otherwise something is wrong fn load_hash(&self, hash: H256) -> Result>> { - let hashes = self - .backend - .mapping() - .block_hashes(&hash) - .map_err(|err| internal_err(format!("fetch aux store failed: {:?}", err)))?; + let hashes = match dvm_consensus::load_block_hash::(self.client.as_ref(), hash) + .map_err(|err| internal_err(format!("fetch aux store failed: {:?}", err)))? + { + Some(hashes) => hashes, + None => return Ok(None), + }; let out: Vec = hashes .into_iter() - .filter_map(|h| if self.is_canon(h) { Some(h) } else { None }) + .filter_map(|h| { + if let Ok(Some(_)) = self.client.header(BlockId::Hash(h)) { + Some(h) + } else { + None + } + }) .collect(); if out.len() == 1 { @@ -331,44 +234,6 @@ where } Ok(None) } - - fn onchain_storage_schema(&self, at: BlockId) -> EthereumStorageSchema { - match self - .client - .storage(&at, &StorageKey(PALLET_ETHEREUM_SCHEMA.to_vec())) - { - Ok(Some(bytes)) => Decode::decode(&mut &bytes.0[..]) - .ok() - .unwrap_or(EthereumStorageSchema::Undefined), - _ => EthereumStorageSchema::Undefined, - } - } - - fn is_canon(&self, target_hash: H256) -> bool { - if let Ok(Some(number)) = self.client.number(target_hash) { - if let Ok(Some(header)) = self.client.header(BlockId::Number(number)) { - return header.hash() == target_hash; - } - } - false - } - - fn load_transactions(&self, transaction_hash: H256) -> Result> { - let transaction_metadata = self - .backend - .mapping() - .transaction_metadata(&transaction_hash) - .map_err(|err| internal_err(format!("fetch aux store failed: {:?}", err)))?; - - if transaction_metadata.len() == 1 { - Ok(Some(( - transaction_metadata[0].ethereum_block_hash, - transaction_metadata[0].ethereum_index, - ))) - } else { - Ok(None) - } - } } impl EthApiT for EthApi @@ -412,17 +277,14 @@ where } fn author(&self) -> Result { - let block = BlockId::Hash(self.client.info().best_hash); - let schema = self.onchain_storage_schema(block); + let hash = self.client.info().best_hash; Ok(self - .overrides - .get(&schema) - .unwrap_or(&self.fallback) - .current_block(&block) - .ok_or(internal_err("fetching author through override failed"))? - .header - .beneficiary) + .client + .runtime_api() + .author(&BlockId::Hash(hash)) + .map_err(|err| internal_err(format!("fetch runtime chain id failed: {:?}", err)))? + .into()) } fn is_mining(&self) -> Result { @@ -441,11 +303,11 @@ where } fn gas_price(&self) -> Result { - let block = BlockId::Hash(self.client.info().best_hash); + let hash = self.client.info().best_hash; Ok(self .client .runtime_api() - .gas_price(&block) + .gas_price(&BlockId::Hash(hash)) .map_err(|err| internal_err(format!("fetch runtime chain id failed: {:?}", err)))? .into()) } @@ -481,13 +343,12 @@ where fn storage_at(&self, address: H160, index: U256, number: Option) -> Result { if let Ok(Some(id)) = self.native_block_id(number) { - let schema = self.onchain_storage_schema(id); return Ok(self - .overrides - .get(&schema) - .unwrap_or(&self.fallback) + .client + .runtime_api() .storage_at(&id, address, index) - .unwrap_or_default()); + .map_err(|err| internal_err(format!("fetch runtime chain id failed: {:?}", err)))? + .into()); } Ok(H256::default()) } @@ -501,11 +362,16 @@ where _ => return Ok(None), }; - let schema = self.onchain_storage_schema(id); - let handler = self.overrides.get(&schema).unwrap_or(&self.fallback); - - let block = handler.current_block(&id); - let statuses = handler.current_transaction_statuses(&id); + let block = self + .client + .runtime_api() + .current_block(&id) + .map_err(|err| internal_err(format!("call runtime failed: {:?}", err)))?; + let statuses = self + .client + .runtime_api() + .current_transaction_statuses(&id) + .map_err(|err| internal_err(format!("call runtime failed: {:?}", err)))?; match (block, statuses) { (Some(block), Some(statuses)) => Ok(Some(rich_block_build( @@ -524,11 +390,16 @@ where None => return Ok(None), }; - let schema = self.onchain_storage_schema(id); - let handler = self.overrides.get(&schema).unwrap_or(&self.fallback); - - let block = handler.current_block(&id); - let statuses = handler.current_transaction_statuses(&id); + let block = self + .client + .runtime_api() + .current_block(&id) + .map_err(|err| internal_err(format!("call runtime failed: {:?}", err)))?; + let statuses = self + .client + .runtime_api() + .current_transaction_statuses(&id) + .map_err(|err| internal_err(format!("call runtime failed: {:?}", err)))?; match (block, statuses) { (Some(block), Some(statuses)) => { @@ -548,11 +419,12 @@ where fn transaction_count(&self, address: H160, number: Option) -> Result { if let Some(BlockNumber::Pending) = number { - let block = BlockId::Hash(self.client.info().best_hash); - let nonce = self + // Find future nonce + let id = BlockId::hash(self.client.info().best_hash); + let nonce: U256 = self .client .runtime_api() - .account_basic(&block, address) + .account_basic(&id, address) .map_err(|err| { internal_err(format!("fetch runtime account basic failed: {:?}", err)) })? @@ -597,12 +469,13 @@ where _ => return Ok(None), }; - let schema = self.onchain_storage_schema(id); let block = self - .overrides - .get(&schema) - .unwrap_or(&self.fallback) - .current_block(&id); + .client + .runtime_api() + .current_block(&id) + .map_err(|err| { + internal_err(format!("fetch runtime account basic failed: {:?}", err)) + })?; match block { Some(block) => Ok(Some(U256::from(block.transactions.len()))), @@ -616,12 +489,13 @@ where None => return Ok(None), }; - let schema = self.onchain_storage_schema(id); let block = self - .overrides - .get(&schema) - .unwrap_or(&self.fallback) - .current_block(&id); + .client + .runtime_api() + .current_block(&id) + .map_err(|err| { + internal_err(format!("fetch runtime account basic failed: {:?}", err)) + })?; match block { Some(block) => Ok(Some(U256::from(block.transactions.len()))), @@ -639,13 +513,11 @@ where fn code_at(&self, address: H160, number: Option) -> Result { if let Ok(Some(id)) = self.native_block_id(number) { - let schema = self.onchain_storage_schema(id); return Ok(self - .overrides - .get(&schema) - .unwrap_or(&self.fallback) + .client + .runtime_api() .account_code_at(&id, address) - .unwrap_or(vec![]) + .map_err(|err| internal_err(format!("fetch runtime chain id failed: {:?}", err)))? .into()); } Ok(Bytes(vec![])) @@ -714,31 +586,15 @@ where let transaction_hash = H256::from_slice(Keccak256::digest(&rlp::encode(&transaction)).as_slice()); let hash = self.client.info().best_hash; - let number = self.client.info().best_number; - let pending = self.pending_transactions.clone(); Box::new( self.pool .submit_one( &BlockId::hash(hash), TransactionSource::Local, - self.convert_transaction - .convert_transaction(transaction.clone()), + self.convert_transaction.convert_transaction(transaction), ) .compat() - .map(move |_| { - if let Some(pending) = pending { - if let Ok(locked) = &mut pending.lock() { - locked.insert( - transaction_hash, - PendingTransaction::new( - transaction_build(transaction, None, None), - UniqueSaturatedInto::::unique_saturated_into(number), - ), - ); - } - } - transaction_hash - }) + .map(move |_| transaction_hash) .map_err(|err| { internal_err(format!("submit transaction to pool failed: {:?}", err)) }), @@ -757,31 +613,15 @@ where let transaction_hash = H256::from_slice(Keccak256::digest(&rlp::encode(&transaction)).as_slice()); let hash = self.client.info().best_hash; - let number = self.client.info().best_number; - let pending = self.pending_transactions.clone(); Box::new( self.pool .submit_one( &BlockId::hash(hash), TransactionSource::Local, - self.convert_transaction - .convert_transaction(transaction.clone()), + self.convert_transaction.convert_transaction(transaction), ) .compat() - .map(move |_| { - if let Some(pending) = pending { - if let Ok(locked) = &mut pending.lock() { - locked.insert( - transaction_hash, - PendingTransaction::new( - transaction_build(transaction, None, None), - UniqueSaturatedInto::::unique_saturated_into(number), - ), - ); - } - } - transaction_hash - }) + .map(move |_| transaction_hash) .map_err(|err| { internal_err(format!("submit transaction to pool failed: {:?}", err)) }), @@ -945,10 +785,6 @@ where Err(_) => { lower = mid; mid = (lower + upper + 1) / 2; - - if mid == lower { - break; - } } } } @@ -959,22 +795,13 @@ where } fn transaction_by_hash(&self, hash: H256) -> Result> { - let (hash, index) = match self - .load_transactions(hash) - .map_err(|err| internal_err(format!("{:?}", err)))? - { - Some((hash, index)) => (hash, index as usize), - None => { - if let Some(pending) = &self.pending_transactions { - if let Ok(locked) = &mut pending.lock() { - if let Some(pending_transaction) = locked.get(&hash) { - return Ok(Some(pending_transaction.transaction.clone())); - } - } - } - return Ok(None); - } - }; + let (hash, index) = + match dvm_consensus::load_transaction_metadata(self.client.as_ref(), hash) + .map_err(|err| internal_err(format!("fetch aux store failed: {:?})", err)))? + { + Some((hash, index)) => (hash, index as usize), + None => return Ok(None), + }; let id = match self .load_hash(hash) @@ -983,17 +810,23 @@ where Some(hash) => hash, _ => return Ok(None), }; - let schema = self.onchain_storage_schema(id); - let handler = self.overrides.get(&schema).unwrap_or(&self.fallback); - let block = handler.current_block(&id); - let statuses = handler.current_transaction_statuses(&id); + let block = self + .client + .runtime_api() + .current_block(&id) + .map_err(|err| internal_err(format!("call runtime failed: {:?}", err)))?; + let statuses = self + .client + .runtime_api() + .current_transaction_statuses(&id) + .map_err(|err| internal_err(format!("call runtime failed: {:?}", err)))?; match (block, statuses) { (Some(block), Some(statuses)) => Ok(Some(transaction_build( block.transactions[index].clone(), - Some(block), - Some(statuses[index].clone()), + block, + statuses[index].clone(), ))), _ => Ok(None), } @@ -1013,17 +846,22 @@ where }; let index = index.value(); - let schema = self.onchain_storage_schema(id); - let handler = self.overrides.get(&schema).unwrap_or(&self.fallback); - - let block = handler.current_block(&id); - let statuses = handler.current_transaction_statuses(&id); + let block = self + .client + .runtime_api() + .current_block(&id) + .map_err(|err| internal_err(format!("call runtime failed: {:?}", err)))?; + let statuses = self + .client + .runtime_api() + .current_transaction_statuses(&id) + .map_err(|err| internal_err(format!("call runtime failed: {:?}", err)))?; match (block, statuses) { (Some(block), Some(statuses)) => Ok(Some(transaction_build( block.transactions[index].clone(), - Some(block), - Some(statuses[index].clone()), + block, + statuses[index].clone(), ))), _ => Ok(None), } @@ -1039,30 +877,36 @@ where None => return Ok(None), }; let index = index.value(); - let schema = self.onchain_storage_schema(id); - let handler = self.overrides.get(&schema).unwrap_or(&self.fallback); - let block = handler.current_block(&id); - let statuses = handler.current_transaction_statuses(&id); + let block = self + .client + .runtime_api() + .current_block(&id) + .map_err(|err| internal_err(format!("call runtime failed: {:?}", err)))?; + let statuses = self + .client + .runtime_api() + .current_transaction_statuses(&id) + .map_err(|err| internal_err(format!("call runtime failed: {:?}", err)))?; match (block, statuses) { (Some(block), Some(statuses)) => Ok(Some(transaction_build( block.transactions[index].clone(), - Some(block), - Some(statuses[index].clone()), + block, + statuses[index].clone(), ))), _ => Ok(None), } } fn transaction_receipt(&self, hash: H256) -> Result> { - let (hash, index) = match self - .load_transactions(hash) - .map_err(|err| internal_err(format!("{:?}", err)))? - { - Some((hash, index)) => (hash, index as usize), - None => return Ok(None), - }; + let (hash, index) = + match dvm_consensus::load_transaction_metadata(self.client.as_ref(), hash) + .map_err(|err| internal_err(format!("fetch aux store failed : {:?}", err)))? + { + Some((hash, index)) => (hash, index as usize), + None => return Ok(None), + }; let id = match self .load_hash(hash) @@ -1072,12 +916,21 @@ where _ => return Ok(None), }; - let schema = self.onchain_storage_schema(id); - let handler = self.overrides.get(&schema).unwrap_or(&self.fallback); - - let block = handler.current_block(&id); - let statuses = handler.current_transaction_statuses(&id); - let receipts = handler.current_receipts(&id); + let block = self + .client + .runtime_api() + .current_block(&id) + .map_err(|err| internal_err(format!("call runtime failed: {:?}", err)))?; + let receipts = self + .client + .runtime_api() + .current_receipts(&id) + .map_err(|err| internal_err(format!("call runtime failed: {:?}", err)))?; + let statuses = self + .client + .runtime_api() + .current_transaction_statuses(&id) + .map_err(|err| internal_err(format!("call runtime failed: {:?}", err)))?; match (block, statuses, receipts) { (Some(block), Some(statuses), Some(receipts)) => { @@ -1125,7 +978,7 @@ where data: Bytes(log.data.clone()), block_hash: Some(block_hash), block_number: Some(block.header.number), - transaction_hash: Some(status.transaction_hash), + transaction_hash: Some(hash), transaction_index: Some(status.transaction_index.into()), log_index: Some(U256::from( (pre_receipts_log_index.unwrap_or(0)) + i as u32, @@ -1158,7 +1011,10 @@ where fn logs(&self, filter: Filter) -> Result> { let mut blocks_and_statuses = Vec::new(); - if let Some(hash) = filter.block_hash.clone() { + let mut ret = Vec::new(); + let params = FilteredParams::new(Some(filter.clone())); + + if let Some(hash) = filter.block_hash { let id = match self .load_hash(hash) .map_err(|err| internal_err(format!("{:?}", err)))? @@ -1176,20 +1032,14 @@ where blocks_and_statuses.push((block, statuses)); } } else { - let best_number = self.client.info().best_number; let mut current_number = filter .to_block - .clone() .and_then(|v| v.to_min_block_num()) .map(|s| s.unique_saturated_into()) - .unwrap_or(best_number); - if current_number > best_number { - current_number = best_number; - } + .unwrap_or(self.client.info().best_number); let from_number = filter .from_block - .clone() .and_then(|v| v.to_min_block_num()) .map(|s| s.unique_saturated_into()) .unwrap_or(self.client.info().best_number); @@ -1213,7 +1063,58 @@ where } } - Ok(logs_build(filter, blocks_and_statuses)) + for (block, statuses) in blocks_and_statuses { + let mut block_log_index: u32 = 0; + let block_hash = + H256::from_slice(Keccak256::digest(&rlp::encode(&block.header)).as_slice()); + for status in statuses.iter() { + let logs = status.logs.clone(); + let mut transaction_log_index: u32 = 0; + let transaction_hash = status.transaction_hash; + // for log in logs { + for ethereum_log in logs { + let mut log = Log { + address: ethereum_log.address.clone(), + topics: ethereum_log.topics.clone(), + data: Bytes(ethereum_log.data.clone()), + block_hash: None, + block_number: None, + transaction_hash: None, + transaction_index: None, + log_index: None, + transaction_log_index: None, + removed: false, + }; + let mut add: bool = true; + if let (Some(_), Some(_)) = (filter.address.clone(), filter.topics.clone()) { + if !params.filter_address(&log) || !params.filter_topics(&log) { + add = false; + } + } else if let Some(_) = filter.address { + if !params.filter_address(&log) { + add = false; + } + } else if let Some(_) = &filter.topics { + if !params.filter_topics(&log) { + add = false; + } + } + if add { + log.block_hash = Some(block_hash); + log.block_number = Some(block.header.number.clone()); + log.transaction_hash = Some(transaction_hash); + log.transaction_index = Some(U256::from(status.transaction_index)); + log.log_index = Some(U256::from(block_log_index)); + log.transaction_log_index = Some(U256::from(transaction_log_index)); + ret.push(log); + } + transaction_log_index += 1; + block_log_index += 1; + } + } + } + + Ok(ret) } fn work(&self) -> Result { @@ -1325,366 +1226,3 @@ where )) } } - -pub struct EthFilterApi { - client: Arc, - filter_pool: FilterPool, - max_stored_filters: usize, - _marker: PhantomData, -} - -impl EthFilterApi { - pub fn new(client: Arc, filter_pool: FilterPool, max_stored_filters: usize) -> Self { - Self { - client, - filter_pool, - max_stored_filters, - _marker: PhantomData, - } - } -} - -impl EthFilterApi -where - C: ProvideRuntimeApi + AuxStore, - C::Api: EthereumRuntimeRPCApi, - C: HeaderBackend + HeaderMetadata + 'static, - C: Send + Sync + 'static, - B: BlockT + Send + Sync + 'static, -{ - fn create_filter(&self, filter_type: FilterType) -> Result { - let block_number = - UniqueSaturatedInto::::unique_saturated_into(self.client.info().best_number); - let pool = self.filter_pool.clone(); - let response = if let Ok(locked) = &mut pool.lock() { - if locked.len() >= self.max_stored_filters { - return Err(internal_err(format!( - "Filter pool is full (limit {:?}).", - self.max_stored_filters - ))); - } - let last_key = match locked.iter().next_back() { - Some((k, _)) => *k, - None => U256::zero(), - }; - // Assume `max_stored_filters` is always < U256::max. - let key = last_key.checked_add(U256::one()).unwrap(); - locked.insert( - key, - FilterPoolItem { - last_poll: BlockNumber::Num(block_number), - filter_type, - at_block: block_number, - }, - ); - Ok(key) - } else { - Err(internal_err("Filter pool is not available.")) - }; - response - } -} - -impl EthFilterApiT for EthFilterApi -where - C: ProvideRuntimeApi + AuxStore, - C::Api: EthereumRuntimeRPCApi, - C: HeaderBackend + HeaderMetadata + 'static, - C: Send + Sync + 'static, - B: BlockT + Send + Sync + 'static, -{ - fn new_filter(&self, filter: Filter) -> Result { - self.create_filter(FilterType::Log(filter)) - } - - fn new_block_filter(&self) -> Result { - self.create_filter(FilterType::Block) - } - - fn new_pending_transaction_filter(&self) -> Result { - Err(internal_err("Method not available.")) - } - - fn filter_changes(&self, index: Index) -> Result { - let key = U256::from(index.value()); - let block_number = - UniqueSaturatedInto::::unique_saturated_into(self.client.info().best_number); - let pool = self.filter_pool.clone(); - // Try to lock. - let response = - if let Ok(locked) = &mut pool.lock() { - // Try to get key. - if let Some(pool_item) = locked.clone().get(&key) { - match &pool_item.filter_type { - // For each block created since last poll, get a vector of ethereum hashes. - FilterType::Block => { - let last = pool_item.last_poll.to_min_block_num().unwrap(); - let next = block_number + 1; - let mut ethereum_hashes: Vec = Vec::new(); - for n in last..next { - let id = BlockId::Number(n.unique_saturated_into()); - let block = self.client.runtime_api().current_block(&id).map_err( - |err| { - internal_err(format!( - "fetch runtime block failed: {:?}", - err - )) - }, - )?; - if let Some(block) = block { - ethereum_hashes.push(block.header.hash()) - } - } - // Update filter `last_poll`. - locked.insert( - key, - FilterPoolItem { - last_poll: BlockNumber::Num(next), - filter_type: pool_item.clone().filter_type, - at_block: pool_item.at_block, - }, - ); - Ok(FilterChanges::Hashes(ethereum_hashes)) - } - // For each event since last poll, get a vector of ethereum logs. - FilterType::Log(filter) => { - // Either the filter-specific `to` block or best block. - let best_number = self.client.info().best_number; - let mut current_number = filter - .to_block - .clone() - .and_then(|v| v.to_min_block_num()) - .map(|s| s.unique_saturated_into()) - .unwrap_or(best_number); - - if current_number > best_number { - current_number = best_number; - } - - // The from clause is the max(last_poll, filter_from). - let last_poll = pool_item - .last_poll - .to_min_block_num() - .unwrap() - .unique_saturated_into(); - - let filter_from = filter - .from_block - .clone() - .and_then(|v| v.to_min_block_num()) - .map(|s| s.unique_saturated_into()) - .unwrap_or(last_poll); - - let from_number = std::cmp::max(last_poll, filter_from); - // Build the response. - let mut blocks_and_statuses = Vec::new(); - while current_number >= from_number { - let id = BlockId::Number(current_number); - - let (block, _, statuses) = - self.client.runtime_api().current_all(&id).map_err(|err| { - internal_err(format!( - "fetch runtime account basic failed: {:?}", - err - )) - })?; - - if let (Some(block), Some(statuses)) = (block, statuses) { - blocks_and_statuses.push((block, statuses)); - } - - if current_number == Zero::zero() { - break; - } else { - current_number = current_number.saturating_sub(One::one()); - } - } - // Update filter `last_poll`. - locked.insert( - key, - FilterPoolItem { - last_poll: BlockNumber::Num(block_number + 1), - filter_type: pool_item.clone().filter_type, - at_block: pool_item.at_block, - }, - ); - Ok(FilterChanges::Logs(logs_build( - filter.clone(), - blocks_and_statuses, - ))) - } - // Should never reach here. - _ => Err(internal_err("Method not available.")), - } - } else { - Err(internal_err(format!("Filter id {:?} does not exist.", key))) - } - } else { - Err(internal_err("Filter pool is not available.")) - }; - response - } - - fn filter_logs(&self, index: Index) -> Result> { - let key = U256::from(index.value()); - let pool = self.filter_pool.clone(); - // Try to lock. - let response = if let Ok(locked) = &mut pool.lock() { - // Try to get key. - if let Some(pool_item) = locked.clone().get(&key) { - match &pool_item.filter_type { - FilterType::Log(filter) => { - let best_number = self.client.info().best_number; - let mut current_number = filter - .to_block - .clone() - .and_then(|v| v.to_min_block_num()) - .map(|s| s.unique_saturated_into()) - .unwrap_or(best_number); - - if current_number > best_number { - current_number = best_number; - } - - if current_number > self.client.info().best_number { - current_number = self.client.info().best_number; - } - - let from_number = filter - .from_block - .clone() - .and_then(|v| v.to_min_block_num()) - .map(|s| s.unique_saturated_into()) - .unwrap_or(self.client.info().best_number); - - let mut blocks_and_statuses = Vec::new(); - while current_number >= from_number { - let id = BlockId::Number(current_number); - - let (block, _, statuses) = - self.client.runtime_api().current_all(&id).map_err(|err| { - internal_err(format!( - "fetch runtime account basic failed: {:?}", - err - )) - })?; - - if let (Some(block), Some(statuses)) = (block, statuses) { - blocks_and_statuses.push((block, statuses)); - } - - if current_number == Zero::zero() { - break; - } else { - current_number = current_number.saturating_sub(One::one()); - } - } - Ok(logs_build(filter.clone(), blocks_and_statuses)) - } - _ => Err(internal_err(format!( - "Filter id {:?} is not a Log filter.", - key - ))), - } - } else { - Err(internal_err(format!("Filter id {:?} does not exist.", key))) - } - } else { - Err(internal_err("Filter pool is not available.")) - }; - response - } - - fn uninstall_filter(&self, index: Index) -> Result { - let key = U256::from(index.value()); - let pool = self.filter_pool.clone(); - // Try to lock. - let response = if let Ok(locked) = &mut pool.lock() { - if let Some(_) = locked.remove(&key) { - Ok(true) - } else { - Err(internal_err(format!("Filter id {:?} does not exist.", key))) - } - } else { - Err(internal_err("Filter pool is not available.")) - }; - response - } -} - -pub struct EthTask(PhantomData<(B, C)>); - -impl EthTask -where - C: ProvideRuntimeApi + BlockchainEvents, - B: BlockT, -{ - pub async fn pending_transaction_task( - client: Arc, - pending_transactions: Arc>>, - retain_threshold: u64, - ) { - let mut notification_st = client.import_notification_stream(); - - while let Some(notification) = notification_st.next().await { - if let Ok(mut pending_transactions) = pending_transactions.lock() { - // As pending transactions have a finite lifespan anyway - // we can ignore MultiplePostRuntimeLogs error checks. - let log = dp_consensus::find_log(¬ification.header.digest()).ok(); - let post_hashes = log.map(|log| log.into_hashes()); - - if let Some(post_hashes) = post_hashes { - // Retain all pending transactions that were not - // processed in the current block. - pending_transactions - .retain(|&k, _| !post_hashes.transaction_hashes.contains(&k)); - } - - let imported_number: u64 = UniqueSaturatedInto::::unique_saturated_into( - *notification.header.number(), - ); - - pending_transactions.retain(|_, v| { - // Drop all the transactions that exceeded the given lifespan. - let lifespan_limit = v.at_block + retain_threshold; - lifespan_limit > imported_number - }); - } - } - } - - pub async fn filter_pool_task( - client: Arc, - filter_pool: Arc>>, - retain_threshold: u64, - ) { - let mut notification_st = client.import_notification_stream(); - - while let Some(notification) = notification_st.next().await { - if let Ok(filter_pool) = &mut filter_pool.lock() { - let imported_number: u64 = UniqueSaturatedInto::::unique_saturated_into( - *notification.header.number(), - ); - - // BTreeMap::retain is unstable :c. - // 1. We collect all keys to remove. - // 2. We remove them. - let remove_list: Vec<_> = filter_pool - .iter() - .filter_map(|(&k, v)| { - let lifespan_limit = v.at_block + retain_threshold; - if lifespan_limit <= imported_number { - Some(k) - } else { - None - } - }) - .collect(); - - for key in remove_list { - filter_pool.remove(&key); - } - } - } - } -} diff --git a/client/dvm/rpc/src/eth_pubsub.rs b/client/dvm/rpc/src/eth_pubsub.rs index d8be35a..fa556fd 100644 --- a/client/dvm/rpc/src/eth_pubsub.rs +++ b/client/dvm/rpc/src/eth_pubsub.rs @@ -1,18 +1,8 @@ -pub use dvm_rpc_core::EthPubSubApiServer; -// --- hyperspace --- -use dp_rpc::{ - pubsub::{Kind, Params, PubSubSyncStatus, Result as PubSubResult}, - Bytes, FilteredParams, Header, Log, Rich, -}; -use dvm_rpc_core::EthPubSubApi::{self as EthPubSubApiT}; -use dvm_rpc_runtime_api::{EthereumRuntimeRPCApi, TransactionStatus}; - -// --- substrate --- +use log::warn; use sc_client_api::{ backend::{AuxStore, Backend, StateBackend, StorageProvider}, client::BlockchainEvents, }; -use sc_network::{ExHashT, NetworkService}; use sc_rpc::Metadata; use sp_api::{BlockId, ProvideRuntimeApi}; use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata}; @@ -20,25 +10,35 @@ use sp_io::hashing::twox_128; use sp_runtime::traits::{BlakeTwo256, Block as BlockT, UniqueSaturatedInto}; use sp_storage::{StorageData, StorageKey}; use sp_transaction_pool::TransactionPool; -// --- std --- +use std::collections::BTreeMap; +use std::{iter, marker::PhantomData, sync::Arc}; + use codec::Decode; -use ethereum_types::{H256, U256}; -use futures::{StreamExt as _, TryStreamExt as _}; -use jsonrpc_core::{ - futures::{Future, Sink}, - Result as JsonRpcResult, +use dvm_rpc_core::EthPubSubApi::{self as EthPubSubApiT}; +use dvm_rpc_core_primitives::{ + pubsub::{Kind, Params, PubSubSyncStatus, Result as PubSubResult}, + Bytes, FilteredParams, Header, Log, Rich, }; +use ethereum_types::{H256, U256}; use jsonrpc_pubsub::{ manager::{IdProvider, SubscriptionManager}, typed::Subscriber, SubscriptionId, }; -use log::warn; use rand::distributions::Alphanumeric; use rand::{thread_rng, Rng}; use sha3::{Digest, Keccak256}; -use std::collections::BTreeMap; -use std::{iter, marker::PhantomData, sync::Arc}; + +pub use dvm_rpc_core::EthPubSubApiServer; +use futures::{StreamExt as _, TryStreamExt as _}; + +use dvm_rpc_runtime_api::{EthereumRuntimeRPCApi, TransactionStatus}; +use jsonrpc_core::{ + futures::{Future, Sink}, + Result as JsonRpcResult, +}; + +use sc_network::{ExHashT, NetworkService}; #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] pub struct HexEncodedIdProvider { @@ -59,8 +59,7 @@ impl IdProvider for HexEncodedIdProvider { .map(|()| rng.sample(Alphanumeric)) .take(self.len) .collect(); - - array_bytes::bytes2hex("0x", id.as_bytes()) + array_bytes::bytes2hex("0x", id.as_bytes()) } } @@ -202,6 +201,19 @@ fn storage_prefix_build(module: &[u8], storage: &[u8]) -> Vec { [twox_128(module), twox_128(storage)].concat().to_vec() } +macro_rules! stream_build { + ($context:expr => $module:expr, $storage:expr) => {{ + let key: StorageKey = StorageKey(storage_prefix_build($module, $storage)); + match $context + .client + .storage_changes_notification_stream(Some(&[key]), None) + { + Ok(stream) => Some(stream), + Err(_err) => None, + } + }}; +} + impl EthPubSubApiT for EthPubSubApi where B: BlockT + Send + Sync + 'static, @@ -229,71 +241,61 @@ where let network = self.network.clone(); match kind { Kind::Logs => { - self.subscriptions.add(subscriber, |sink| { - let stream = client - .import_notification_stream() - .filter_map(move |notification| { - if notification.is_new_best { - let id = BlockId::Hash(notification.hash); - let receipts = client.runtime_api().current_receipts(&id); - let block = client.runtime_api().current_block(&id); - match (receipts, block) { - (Ok(Some(receipts)), Ok(Some(block))) => { - futures::future::ready(Some((block, receipts))) - } - _ => futures::future::ready(None), - } - } else { - futures::future::ready(None) - } - }) - .flat_map(move |(block, receipts)| { - futures::stream::iter(SubscriptionResult::new().logs( - block, - receipts, - &filtered_params, - )) - }) - .map(|x| { - return Ok::, ()>( - Ok(PubSubResult::Log(Box::new(x))), - ); - }) - .compat(); - sink.sink_map_err(|e| warn!("Error sending notifications: {:?}", e)) - .send_all(stream) - .map(|_| ()) - }); + if let Some(stream) = stream_build!( + self => b"Ethereum", b"CurrentReceipts" + ) { + self.subscriptions.add(subscriber, |sink| { + let stream = stream + .flat_map(move |(block_hash, changes)| { + let id = BlockId::Hash(block_hash); + let data = changes.iter().last().unwrap().2.unwrap(); + let receipts: Vec = + Decode::decode(&mut &data.0[..]).unwrap(); + let block: ethereum::Block = + client.runtime_api().current_block(&id).unwrap().unwrap(); + futures::stream::iter(SubscriptionResult::new().logs( + block, + receipts, + &filtered_params, + )) + }) + .map(|x| { + return Ok::< + Result, + (), + >(Ok(PubSubResult::Log(Box::new(x)))); + }) + .compat(); + + sink.sink_map_err(|e| warn!("Error sending notifications: {:?}", e)) + .send_all(stream) + .map(|_| ()) + }); + } } Kind::NewHeads => { - self.subscriptions.add(subscriber, |sink| { - let stream = client - .import_notification_stream() - .filter_map(move |notification| { - if notification.is_new_best { - let id = BlockId::Hash(notification.hash); - let block = client.runtime_api().current_block(&id); - match block { - Ok(Some(block)) => futures::future::ready(Some(block)), - _ => futures::future::ready(None), - } - } else { - futures::future::ready(None) - } - }) - .map(|block| { - return Ok::<_, ()>(Ok(SubscriptionResult::new().new_heads(block))); - }) - .compat(); - sink.sink_map_err(|e| warn!("Error sending notifications: {:?}", e)) - .send_all(stream) - .map(|_| ()) - }); + if let Some(stream) = stream_build!( + self => b"Ethereum", b"CurrentBlock" + ) { + self.subscriptions.add(subscriber, |sink| { + let stream = stream + .map(|(_block, changes)| { + let data = changes.iter().last().unwrap().2.unwrap(); + let block: ethereum::Block = + Decode::decode(&mut &data.0[..]).unwrap(); + return Ok::<_, ()>(Ok(SubscriptionResult::new().new_heads(block))); + }) + .compat(); + + sink.sink_map_err(|e| warn!("Error sending notifications: {:?}", e)) + .send_all(stream) + .map(|_| ()) + }); + } } Kind::NewPendingTransactions => { - if let Ok(stream) = client.storage_changes_notification_stream( - Some(&[StorageKey(storage_prefix_build(b"Ethereum", b"Pending"))]), - None, + if let Some(stream) = stream_build!( + self => b"Ethereum", b"Pending" ) { self.subscriptions.add(subscriber, |sink| { let stream = stream @@ -340,29 +342,35 @@ where } } Kind::Syncing => { - self.subscriptions.add(subscriber, |sink| { - let mut previous_syncing = network.is_major_syncing(); - let stream = client - .import_notification_stream() - .filter_map(move |notification| { - let syncing = network.is_major_syncing(); - if notification.is_new_best && previous_syncing != syncing { - previous_syncing = syncing; - futures::future::ready(Some(syncing)) - } else { - futures::future::ready(None) - } - }) - .map(|syncing| { - return Ok::, ()>( - Ok(PubSubResult::SyncState(PubSubSyncStatus { syncing })), - ); - }) - .compat(); - sink.sink_map_err(|e| warn!("Error sending notifications: {:?}", e)) - .send_all(stream) - .map(|_| ()) - }); + if let Some(stream) = stream_build!( + self => b"Ethereum", b"CurrentBlock" + ) { + self.subscriptions.add(subscriber, |sink| { + let mut previous_syncing = network.is_major_syncing(); + let stream = stream + .filter_map(move |(_, _)| { + let syncing = network.is_major_syncing(); + if previous_syncing != syncing { + previous_syncing = syncing; + futures::future::ready(Some(syncing)) + } else { + futures::future::ready(None) + } + }) + .map(|syncing| { + return Ok::< + Result, + (), + >(Ok(PubSubResult::SyncState(PubSubSyncStatus { + syncing, + }))); + }) + .compat(); + sink.sink_map_err(|e| warn!("Error sending notifications: {:?}", e)) + .send_all(stream) + .map(|_| ()) + }); + } } } } diff --git a/client/dvm/rpc/src/lib.rs b/client/dvm/rpc/src/lib.rs index 9a3983c..f1fcd61 100644 --- a/client/dvm/rpc/src/lib.rs +++ b/client/dvm/rpc/src/lib.rs @@ -16,21 +16,12 @@ mod eth; mod eth_pubsub; -mod overrides; -pub use overrides::{SchemaV1Override, StorageOverride}; -// --- hyperspace --- -use hyperspace_evm::ExitReason; -// --- std --- -pub use eth::{ - EthApi, EthApiServer, EthFilterApi, EthFilterApiServer, EthTask, NetApi, NetApiServer, Web3Api, - Web3ApiServer, -}; +pub use eth::{EthApi, EthApiServer, NetApi, NetApiServer, Web3Api, Web3ApiServer}; pub use eth_pubsub::{EthPubSubApi, EthPubSubApiServer, HexEncodedIdProvider}; -use ethereum::{ - Transaction as EthereumTransaction, TransactionMessage as EthereumTransactionMessage, -}; use ethereum_types::H160; + +use hyperspace_evm::ExitReason; use jsonrpc_core::{Error, ErrorCode, Value}; pub fn internal_err(message: T) -> Error { @@ -74,17 +65,6 @@ pub fn error_on_execution_failure(reason: &ExitReason, data: &[u8]) -> Result<() } } -pub fn public_key(transaction: &EthereumTransaction) -> Result<[u8; 64], sp_io::EcdsaVerifyError> { - let mut sig = [0u8; 65]; - let mut msg = [0u8; 32]; - sig[0..32].copy_from_slice(&transaction.signature.r()[..]); - sig[32..64].copy_from_slice(&transaction.signature.s()[..]); - sig[64] = transaction.signature.standard_v(); - msg.copy_from_slice(&EthereumTransactionMessage::from(transaction.clone()).hash()[..]); - - sp_io::crypto::secp256k1_ecdsa_recover(&sig, &msg) -} - /// A generic Ethereum signer. pub trait EthSigner: Send + Sync { /// Available accounts from this signer. diff --git a/client/dvm/rpc/src/overrides/mod.rs b/client/dvm/rpc/src/overrides/mod.rs deleted file mode 100644 index b167c5c..0000000 --- a/client/dvm/rpc/src/overrides/mod.rs +++ /dev/null @@ -1,136 +0,0 @@ -// Copyright 2017-2020 Parity Technologies (UK) Ltd. -// This file is part of Frontier. - -// Substrate 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. - -// Substrate 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 Substrate. If not, see . - -// Something you need to know -// Once the runtime upgrade that involves changes to the dvm pallet storage schema, you should: -// 1. Add a new `EthereumStorageSchema` variant. -// 2. Put it in the well known `Schema` substrate storage. -// 3. Add a new `StorageOverride` implementor. (i.e. SchemaV2verride), DO NOT delete the previous `StorageOverride` implementor. -// 4. Insert the new implementor to the `overrides` BTreeMap and upgrade the node client. - -mod schema_v1_override; - -pub use schema_v1_override::SchemaV1Override; -// --- hyperspace --- -pub use dvm_rpc_core::{EthApiServer, NetApiServer}; -use dvm_rpc_runtime_api::EthereumRuntimeRPCApi; -use dvm_rpc_runtime_api::TransactionStatus; -// --- substrate --- -use sp_api::{BlockId, ProvideRuntimeApi}; -use sp_io::hashing::{blake2_128, twox_128}; -use sp_runtime::traits::Block as BlockT; -// --- std --- -use ethereum::Block as EthereumBlock; -use ethereum_types::{H160, H256, U256}; -use std::{marker::PhantomData, sync::Arc}; - -/// Something that can fetch Ethereum-related data. This trait is quite similar to the runtime API, -/// and indeed oe implementation of it uses the runtime API. -/// Having this trait is useful because it allows optimized implementations that fetch data from a -/// State Backend with some assumptions about pallet-ethereum's storage schema. Using such an -/// optimized implementation avoids spawning a runtime and the overhead associated with it. -pub trait StorageOverride { - /// For a given account address, returns pallet_evm::AccountCodes. - fn account_code_at(&self, block: &BlockId, address: H160) -> Option>; - /// For a given account address and index, returns pallet_evm::AccountStorages. - fn storage_at(&self, block: &BlockId, address: H160, index: U256) -> Option; - /// Return the current block. - fn current_block(&self, block: &BlockId) -> Option; - /// Return the current receipt. - fn current_receipts(&self, block: &BlockId) -> Option>; - /// Return the current transaction status. - fn current_transaction_statuses( - &self, - block: &BlockId, - ) -> Option>; -} - -fn storage_prefix_build(module: &[u8], storage: &[u8]) -> Vec { - [twox_128(module), twox_128(storage)].concat().to_vec() -} - -fn blake2_128_extend(bytes: &[u8]) -> Vec { - let mut ext: Vec = blake2_128(bytes).to_vec(); - ext.extend_from_slice(bytes); - ext -} - -/// A wrapper type for the Runtime API. This type implements `StorageOverride`, so it can be used -/// when calling the runtime API is desired but a `dyn StorageOverride` is required. -pub struct RuntimeApiStorageOverride { - client: Arc, - _marker: PhantomData, -} - -impl RuntimeApiStorageOverride -where - C: ProvideRuntimeApi, - C::Api: EthereumRuntimeRPCApi, - B: BlockT + Send + Sync + 'static, - C: Send + Sync + 'static, -{ - pub fn new(client: Arc) -> Self { - Self { - client, - _marker: PhantomData, - } - } -} - -impl StorageOverride for RuntimeApiStorageOverride -where - C: ProvideRuntimeApi, - C::Api: EthereumRuntimeRPCApi, - Block: BlockT + Send + Sync + 'static, - C: Send + Sync + 'static, -{ - /// For a given account address, returns pallet_evm::AccountCodes. - fn account_code_at(&self, block: &BlockId, address: H160) -> Option> { - self.client - .runtime_api() - .account_code_at(&block, address) - .ok() - } - - /// For a given account address and index, returns pallet_evm::AccountStorages. - fn storage_at(&self, block: &BlockId, address: H160, index: U256) -> Option { - self.client - .runtime_api() - .storage_at(&block, address, index) - .ok() - } - - /// Return the current block. - fn current_block(&self, block: &BlockId) -> Option { - self.client.runtime_api().current_block(&block).ok()? - } - - /// Return the current receipt. - fn current_receipts(&self, block: &BlockId) -> Option> { - self.client.runtime_api().current_receipts(&block).ok()? - } - - /// Return the current transaction status. - fn current_transaction_statuses( - &self, - block: &BlockId, - ) -> Option> { - self.client - .runtime_api() - .current_transaction_statuses(&block) - .ok()? - } -} diff --git a/client/dvm/rpc/src/overrides/schema_v1_override.rs b/client/dvm/rpc/src/overrides/schema_v1_override.rs deleted file mode 100644 index 501a057..0000000 --- a/client/dvm/rpc/src/overrides/schema_v1_override.rs +++ /dev/null @@ -1,133 +0,0 @@ -// Copyright 2017-2020 Parity Technologies (UK) Ltd. -// This file is part of Frontier. - -// Substrate 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. - -// Substrate 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 Substrate. If not, see . - -use super::{blake2_128_extend, storage_prefix_build, StorageOverride}; -// --- hyperspace --- -use dvm_rpc_runtime_api::TransactionStatus; -// --- substrate --- -use sc_client_api::backend::{AuxStore, Backend, StateBackend, StorageProvider}; -use sp_api::BlockId; -use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata}; -use sp_runtime::traits::{BlakeTwo256, Block as BlockT}; -use sp_storage::StorageKey; -// --- std --- -use codec::Decode; -use ethereum::Block as EthereumBlock; -use ethereum_types::{H160, H256, U256}; -use std::{marker::PhantomData, sync::Arc}; - -/// An override for runtimes that use Schema V1 -pub struct SchemaV1Override { - client: Arc, - _marker: PhantomData<(B, BE)>, -} - -impl SchemaV1Override { - pub fn new(client: Arc) -> Self { - Self { - client, - _marker: PhantomData, - } - } -} - -impl SchemaV1Override -where - C: StorageProvider + AuxStore, - C: HeaderBackend + HeaderMetadata + 'static, - BE: Backend + 'static, - BE::State: StateBackend, - B: BlockT + Send + Sync + 'static, - C: Send + Sync + 'static, -{ - // My attempt using result - // fn query_storage(&self, id: &BlockId, key: &StorageKey) -> Result { - // let raw_data = self.client.storage(id, key)? - // .ok_or("Storage provider returned Ok(None)")?; - // - // Decode::decode(&mut &raw_data.0[..]).map_err(|_| "Could not decode data".into()) - // } - - fn query_storage(&self, id: &BlockId, key: &StorageKey) -> Option { - if let Ok(Some(data)) = self.client.storage(id, key) { - if let Ok(result) = Decode::decode(&mut &data.0[..]) { - return Some(result); - } - } - None - } -} - -impl StorageOverride for SchemaV1Override -where - C: StorageProvider, - C: AuxStore, - C: HeaderBackend, - C: HeaderMetadata + 'static, - BE: Backend + 'static, - BE::State: StateBackend, - Block: BlockT + Send + Sync + 'static, - C: Send + Sync + 'static, -{ - /// For a given account address, returns pallet_evm::AccountCodes. - fn account_code_at(&self, block: &BlockId, address: H160) -> Option> { - let mut key: Vec = storage_prefix_build(b"EVM", b"AccountCodes"); - key.extend(blake2_128_extend(address.as_bytes())); - self.query_storage::>(block, &StorageKey(key)) - } - - /// For a given account address and index, returns pallet_evm::AccountStorages. - fn storage_at(&self, block: &BlockId, address: H160, index: U256) -> Option { - let tmp: &mut [u8; 32] = &mut [0; 32]; - index.to_little_endian(tmp); - - let mut key: Vec = storage_prefix_build(b"EVM", b"AccountStorages"); - key.extend(blake2_128_extend(address.as_bytes())); - key.extend(blake2_128_extend(tmp)); - - self.query_storage::(block, &StorageKey(key)) - } - - /// Return the current block. - fn current_block(&self, block: &BlockId) -> Option { - self.query_storage::( - block, - &StorageKey(storage_prefix_build(b"Ethereum", b"CurrentBlock")), - ) - } - - /// Return the current receipt. - fn current_receipts(&self, block: &BlockId) -> Option> { - self.query_storage::>( - block, - &StorageKey(storage_prefix_build(b"Ethereum", b"CurrentReceipts")), - ) - } - - /// Return the current transaction status. - fn current_transaction_statuses( - &self, - block: &BlockId, - ) -> Option> { - self.query_storage::>( - block, - &StorageKey(storage_prefix_build( - b"Ethereum", - b"CurrentTransactionStatuses", - )), - ) - } -} diff --git a/frame/balances/Cargo.toml b/frame/balances/Cargo.toml index a8bd12e..ce1f453 100644 --- a/frame/balances/Cargo.toml +++ b/frame/balances/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0" name = "hyperspace-balances" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" +version = "1.4.0" [dependencies] # crates @@ -17,16 +17,16 @@ serde = { version = "1.0.124", optional = true } hyperspace-balances-rpc-runtime-api = { default-features = false, path = "./rpc/runtime-api" } hyperspace-support = { default-features = false, path = "../support" } # substrate -frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } [dev-dependencies] # substrate -pallet-transaction-payment = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-core = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-io = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +pallet-transaction-payment = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-core = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-io = { git = "https://github.com/new-mvs/substrate", branch = "latest" } [features] default = ["std"] diff --git a/frame/balances/rpc/Cargo.toml b/frame/balances/rpc/Cargo.toml index 64ecf7a..f9ec6a9 100644 --- a/frame/balances/rpc/Cargo.toml +++ b/frame/balances/rpc/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0" name = "hyperspace-balances-rpc" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" +version = "1.4.0" [dependencies] # crates @@ -18,6 +18,6 @@ jsonrpc-derive = { version = "15.1.0" } # hyperspace hyperspace-balances-rpc-runtime-api = { path = "./runtime-api" } # substrate -sp-api = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-blockchain = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-runtime = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-api = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-blockchain = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-runtime = { git = "https://github.com/new-mvs/substrate", branch = "latest" } diff --git a/frame/balances/rpc/runtime-api/Cargo.toml b/frame/balances/rpc/runtime-api/Cargo.toml index 5bfcde7..d364508 100644 --- a/frame/balances/rpc/runtime-api/Cargo.toml +++ b/frame/balances/rpc/runtime-api/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0" name = "hyperspace-balances-rpc-runtime-api" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" +version = "1.4.0" [dependencies] # crates @@ -16,8 +16,8 @@ serde = { version = "1.0.124", optional = true, features = ["derive"] } # hyperspace hyperspace-support = { default-features = false, path = "../../../support" } # substrate -sp-api = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-api = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } [features] default = ["std"] diff --git a/frame/balances/src/tests.rs b/frame/balances/src/tests.rs index 5cd5a9c..767068c 100644 --- a/frame/balances/src/tests.rs +++ b/frame/balances/src/tests.rs @@ -403,10 +403,10 @@ macro_rules! decl_tests { #[test] fn balance_works() { <$ext_builder>::default().build().execute_with(|| { - let _ = Etp::deposit_creating(&1, 42); - assert_eq!(Etp::free_balance(1), 42); + let _ = Etp::deposit_creating(&1, 150); + assert_eq!(Etp::free_balance(1), 150); assert_eq!(Etp::reserved_balance(1), 0); - assert_eq!(Etp::total_balance(&1), 42); + assert_eq!(Etp::total_balance(&1), 150); assert_eq!(Etp::free_balance(2), 0); assert_eq!(Etp::reserved_balance(2), 0); assert_eq!(Etp::total_balance(&2), 0); @@ -418,7 +418,7 @@ macro_rules! decl_tests { <$ext_builder>::default().build().execute_with(|| { let _ = Etp::deposit_creating(&1, 111); assert_ok!(Etp::transfer(Some(1).into(), 2, 69)); - assert_eq!(Etp::total_balance(&1), 42); + assert_eq!(Etp::total_balance(&1), 150); assert_eq!(Etp::total_balance(&2), 69); }); } @@ -429,7 +429,7 @@ macro_rules! decl_tests { let _ = Etp::deposit_creating(&1, 111); assert_noop!(Etp::force_transfer(Some(2).into(), 1, 2, 69), BadOrigin,); assert_ok!(Etp::force_transfer(RawOrigin::Root.into(), 1, 2, 69)); - assert_eq!(Etp::total_balance(&1), 42); + assert_eq!(Etp::total_balance(&1), 150); assert_eq!(Etp::total_balance(&2), 69); }); } diff --git a/frame/bridge/ethereum/backing/Cargo.toml b/frame/bridge/ethereum/backing/Cargo.toml index 9931074..de97381 100644 --- a/frame/bridge/ethereum/backing/Cargo.toml +++ b/frame/bridge/ethereum/backing/Cargo.toml @@ -7,14 +7,14 @@ license = "GPL-3.0" name = "hyperspace-ethereum-backing" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" +version = "1.4.0" [dependencies] # crates array-bytes = { version = "1.1.0" } -codec = { package = "parity-scale-codec", version = "1.3.7", default-features = false, features = ["derive"] } -serde = { version = "1.0.124", optional = true } -serde_json = { version = "1.0.62", optional = true } +codec = { package = "parity-scale-codec", version = "1.3.7", default-features = false, features = ["derive"] } +serde = { version = "1.0.124", optional = true } +serde_json = { version = "1.0.62", optional = true } # hyperspace hyperspace-relay-primitives = { default-features = false, path = "../../../../primitives/relay" } hyperspace-support = { default-features = false, path = "../../../support" } @@ -22,11 +22,11 @@ ethereum-primitives = { default-features = false, path = "../../../../prim # github ethabi = { default-features = false, git = "https://github.com/new-mvs/ethabi.git", branch = "with_no_std" } # substrate -frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } [dev-dependencies] # hyperspace @@ -40,10 +40,10 @@ ethereum-primitives = { features = ["deserialize"], path = "../../../ # github rlp = { package = "rlp", git = "https://github.com/new-mvs/parity-common.git" } # substrate -pallet-session = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -pallet-timestamp = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-core = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-staking = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +pallet-session = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +pallet-timestamp = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-core = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-staking = { git = "https://github.com/new-mvs/substrate", branch = "latest" } [features] default = ["std"] diff --git a/frame/bridge/ethereum/backing/src/lib.rs b/frame/bridge/ethereum/backing/src/lib.rs index 26a4f40..b831014 100644 --- a/frame/bridge/ethereum/backing/src/lib.rs +++ b/frame/bridge/ethereum/backing/src/lib.rs @@ -18,7 +18,7 @@ //! Prototype module for cross chain assets backing. -// TODO: https://github.com/mvs-org/Hyperspaceissues/372 +// TODO: https://github.com/new-mvs/darwinia-common/issues/372 #![allow(unused)] #![cfg_attr(not(feature = "std"), no_std)] #![recursion_limit = "128"] @@ -74,6 +74,7 @@ use sp_runtime::{ use sp_std::borrow::ToOwned; use sp_std::{convert::TryFrom, prelude::*}; // --- hyperspace --- + use hyperspace_relay_primitives::relay_authorities::*; use hyperspace_support::{ balance::lock::*, @@ -268,7 +269,7 @@ decl_module! { let fee_account = Self::fee_account_id(); let locked = utilities::with_transaction_result(|| { // 50 Etp for fee - // https://github.com/mvs-org/Hyperspacepull/377#issuecomment-730369387 + // https://github.com/new-mvs/darwinia-common/pull/377#issuecomment-730369387 T::EtpCurrency::transfer(&user, &fee_account, T::AdvancedFee::get(), KeepAlive)?; let mut locked = false; @@ -366,11 +367,11 @@ decl_module! { } } - /// Set a new ring redeem address. + /// Set a new redeem address. /// /// The dispatch origin of this call must be _Root_. /// - /// - `new`: The new ring redeem address. + /// - `new`: The new redeem address. /// /// # /// - `O(1)`. @@ -665,7 +666,7 @@ impl Module { } // event SetAuthritiesEvent(uint32 nonce, address[] authorities, bytes32 benifit); - // https://github.com/hyperspace-network/hyperspace-bridge-on-ethereum/blob/51839e614c0575e431eabfd5c70b84f6aa37826a/contracts/Relay.sol#L22 + // https://github.com/new-mvs/hyperspace-bridge-on-ethereum/blob/51839e614c0575e431eabfd5c70b84f6aa37826a/contracts/Relay.sol#L22 // https://ropsten.etherscan.io/tx/0x652528b9421ecb495610a734a4ab70d054b5510dbbf3a9d5c7879c43c7dde4e9#eventlog fn parse_authorities_set_proof( proof_record: &EthereumReceiptProofThing, diff --git a/frame/bridge/ethereum/backing/src/mock.rs b/frame/bridge/ethereum/backing/src/mock.rs index 85a664d..37e0f63 100644 --- a/frame/bridge/ethereum/backing/src/mock.rs +++ b/frame/bridge/ethereum/backing/src/mock.rs @@ -32,6 +32,7 @@ macro_rules! decl_tests { ModuleId, {KeyTypeId, MultiSignature, Perbill}, }; // --- hyperspace --- + use hyperspace_staking::{EraIndex, Exposure, ExposureOf}; type Balance = u128; diff --git a/frame/bridge/ethereum/backing/src/test_with_linear_relay.rs b/frame/bridge/ethereum/backing/src/test_with_linear_relay.rs index ec57cd4..1c8b4ec 100644 --- a/frame/bridge/ethereum/backing/src/test_with_linear_relay.rs +++ b/frame/bridge/ethereum/backing/src/test_with_linear_relay.rs @@ -24,6 +24,7 @@ use frame_system::RawOrigin; use sp_runtime::{traits::Dispatchable, AccountId32}; // --- hyperspace --- use crate::*; +use array_bytes::array_bytes::hex2bytes_unchecked; use hyperspace_staking::{RewardDestination, StakingBalance, StakingLedger, TimeDepositItem}; use hyperspace_support::balance::lock::StakingLock; use ethereum_primitives::{ @@ -234,7 +235,7 @@ fn verify_linear_redeem_deposit() { .execute_with(|| { assert_ok!(EthereumRelay::set_number_of_blocks_safe(RawOrigin::Root.into(), 0)); - // 1234ring -> 0.1234dna + // 1234 -> 0.1234dna // _depositID 2 // 0: address: 0xcC5E48BEb33b83b8bD0D9d9A85A8F6a27C51F5C5 _depositor diff --git a/frame/bridge/ethereum/backing/src/test_with_relay.rs b/frame/bridge/ethereum/backing/src/test_with_relay.rs index a1ffdb6..cd36e79 100644 --- a/frame/bridge/ethereum/backing/src/test_with_relay.rs +++ b/frame/bridge/ethereum/backing/src/test_with_relay.rs @@ -24,6 +24,7 @@ use frame_system::EnsureRoot; use sp_runtime::{traits::Dispatchable, AccountId32}; // --- hyperspace --- use crate::*; + use hyperspace_ethereum_relay::{EthereumRelayHeaderParcel, EthereumRelayProofs, MMRProof}; use hyperspace_relay_primitives::relayer_game::*; use hyperspace_staking::{RewardDestination, StakingBalance, StakingLedger, TimeDepositItem}; @@ -283,7 +284,7 @@ fn verify_redeem_deposit() { ExtBuilder::default() .build() .execute_with(|| { - // 1234ring -> 0.1234dna + // 1234 -> 0.1234dna // _depositID 2 // 0: address: 0xcC5E48BEb33b83b8bD0D9d9A85A8F6a27C51F5C5 _depositor diff --git a/frame/bridge/ethereum/linear-relay/Cargo.toml b/frame/bridge/ethereum/linear-relay/Cargo.toml index 9815bc2..5af1f68 100644 --- a/frame/bridge/ethereum/linear-relay/Cargo.toml +++ b/frame/bridge/ethereum/linear-relay/Cargo.toml @@ -8,7 +8,7 @@ license = "GPL-3.0" name = "hyperspace-ethereum-linear-relay" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" +version = "1.4.0" [dependencies] # crates @@ -22,10 +22,10 @@ ethereum-primitives = { default-features = false, path = "../../../../primitives ethereum-types = { default-features = false, git = "https://github.com/new-mvs/parity-common.git" } rlp = { default-features = false, git = "https://github.com/new-mvs/parity-common.git" } # substrate -frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } [dev-dependencies] # crates @@ -34,8 +34,8 @@ array-bytes = { version = "1.1.0" } hyperspace-balances = { path = "../../../../frame/balances" } ethereum-primitives = { features = ["deserialize"], path = "../../../../primitives/ethereum-primitives" } # substrate -sp-core = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-io = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-core = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-io = { git = "https://github.com/new-mvs/substrate", branch = "latest" } [features] default = ["std"] diff --git a/frame/bridge/ethereum/linear-relay/src/mock.rs b/frame/bridge/ethereum/linear-relay/src/mock.rs index 58f9cbb..d95d54f 100644 --- a/frame/bridge/ethereum/linear-relay/src/mock.rs +++ b/frame/bridge/ethereum/linear-relay/src/mock.rs @@ -149,16 +149,14 @@ impl BlockWithProof { BlockWithProof { proof_length: raw_block_with_proof.proof_length, - merkle_root: array_bytes::hex2array_unchecked!(&raw_block_with_proof.merkle_root, 16) - .into(), + merkle_root: array_bytes::hex2array_unchecked!(&raw_block_with_proof.merkle_root, 16).into(), header_rlp: array_bytes::hex2bytes_unchecked(&raw_block_with_proof.header_rlp), merkle_proofs: raw_block_with_proof .merkle_proofs .iter() .cloned() .map(|raw_merkle_proof| { - array_bytes::hex2array_unchecked!(&zero_padding(raw_merkle_proof, 16), 16) - .into() + array_bytes::hex2array_unchecked!(&zero_padding(raw_merkle_proof, 16), 16).into() }) .collect(), elements: raw_block_with_proof @@ -224,9 +222,7 @@ impl HeaderWithProof { serde_json::from_reader(File::open(path).unwrap()).unwrap(); Self { header: Decode::decode::<&[u8]>( - &mut &array_bytes::hex2bytes_unchecked( - raw_shadow_service_response.result.eth_header, - )[..], + &mut &array_bytes::hex2bytes_unchecked(raw_shadow_service_response.result.eth_header)[..], ) .unwrap(), proof: Decode::decode::<&[u8]>( @@ -323,11 +319,8 @@ pub fn mock_canonical_receipt() -> EthereumReceiptProof { .parse() .unwrap(), proof: array_bytes::hex2bytes_unchecked(receipt["proof"].as_str().unwrap()), - header_hash: array_bytes::hex2array_unchecked!( - receipt["header_hash"].as_str().unwrap(), - 32 - ) - .into(), + header_hash: array_bytes::hex2array_unchecked!(receipt["header_hash"].as_str().unwrap(), 32) + .into(), } } @@ -360,7 +353,7 @@ pub const MAINNET_GENESIS_HEADER: &'static str = r#" "gasUsed": "0x0", "hash": "0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "miner": "0x0000000000000000000000000000000000000000", + "miner": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa", "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", "nonce": "0x0000000000000042", "number": "0x0", diff --git a/frame/bridge/ethereum/relay/Cargo.toml b/frame/bridge/ethereum/relay/Cargo.toml index 93a5886..5223e1e 100644 --- a/frame/bridge/ethereum/relay/Cargo.toml +++ b/frame/bridge/ethereum/relay/Cargo.toml @@ -8,15 +8,15 @@ license = "GPL-3.0" name = "hyperspace-ethereum-relay" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" +version = "1.4.0" [dependencies] # crates array-bytes = { version = "1.1.0" } -blake2-rfc = { version = "0.2.18", default-features = false } -codec = { package = "parity-scale-codec", version = "1.3.7", default-features = false } -serde = { version = "1.0.124", optional = true } -serde_json = { version = "1.0.62", optional = true } +blake2-rfc = { version = "0.2.18", default-features = false } +codec = { package = "parity-scale-codec", version = "1.3.7", default-features = false } +serde = { version = "1.0.124", optional = true } +serde_json = { version = "1.0.62", optional = true } # hyperspace hyperspace-relay-primitives = { default-features = false, path = "../../../../primitives/relay" } hyperspace-relayer-game = { default-features = false, path = "../../../bridge/relayer-game" } @@ -27,19 +27,19 @@ ckb-merkle-mountain-range = { default-features = false, git = "https://github.co ethereum-types = { default-features = false, git = "https://github.com/new-mvs/parity-common.git" } rlp = { default-features = false, git = "https://github.com/new-mvs/parity-common.git" } # substrate -frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } [dev-dependencies] # hyperspace hyperspace-balances = { path = "../../../../frame/balances" } ethereum-primitives = { features = ["deserialize"], path = "../../../../primitives/ethereum-primitives" } # substrate -sp-core = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-io = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-core = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-io = { git = "https://github.com/new-mvs/substrate", branch = "latest" } [features] default = ["std"] diff --git a/frame/bridge/ethereum/relay/src/lib.rs b/frame/bridge/ethereum/relay/src/lib.rs index f41535d..bee33e7 100644 --- a/frame/bridge/ethereum/relay/src/lib.rs +++ b/frame/bridge/ethereum/relay/src/lib.rs @@ -72,6 +72,7 @@ use sp_std::borrow::ToOwned; use sp_std::{convert::From, marker::PhantomData, prelude::*}; // --- hyperspace --- use crate::mmr::{leaf_index_to_mmr_size, leaf_index_to_pos, MMRMerge, MerkleProof}; + use hyperspace_relay_primitives::relayer_game::*; use hyperspace_support::{ balance::lock::LockableCurrency, traits::EthereumReceipt as EthereumReceiptT, diff --git a/frame/bridge/oldetp/backing/Cargo.toml b/frame/bridge/oldetp/backing/Cargo.toml index b9cc485..7d55c61 100644 --- a/frame/bridge/oldetp/backing/Cargo.toml +++ b/frame/bridge/oldetp/backing/Cargo.toml @@ -7,16 +7,16 @@ license = "GPL-3.0" name = "hyperspace-oldetp-backing" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" +version = "1.4.0" [dependencies] # crates codec = { package = "parity-scale-codec", version = "1.3.7", default-features = false } serde = { version = "1.0.124", optional = true } # substrate -frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } [features] default = ["std"] diff --git a/frame/bridge/oldetp/backing/src/lib.rs b/frame/bridge/oldetp/backing/src/lib.rs index bb8df67..a7be653 100644 --- a/frame/bridge/oldetp/backing/src/lib.rs +++ b/frame/bridge/oldetp/backing/src/lib.rs @@ -33,9 +33,13 @@ mod types { #[cfg(feature = "std")] pub type EtpBalance = as Currency>>::Balance; + #[cfg(feature = "std")] + pub type DnaBalance = as Currency>>::Balance; #[cfg(feature = "std")] type EtpCurrency = ::EtpCurrency; + #[cfg(feature = "std")] + type DnaCurrency = ::DnaCurrency; } // --- substrate --- @@ -51,6 +55,7 @@ pub trait Config: frame_system::Config { type ModuleId: Get; type EtpCurrency: Currency>; + type DnaCurrency: Currency>; type WeightInfo: WeightInfo; } @@ -60,11 +65,17 @@ decl_storage! { add_extra_genesis { config(backed_etp): EtpBalance; + config(backed_dna): DnaBalance; build(|config| { + let module_account = >::account_id(); let _ = T::EtpCurrency::make_free_balance_be( - &>::account_id(), + &module_account, T::EtpCurrency::minimum_balance() + config.backed_etp ); + let _ = T::DnaCurrency::make_free_balance_be( + &module_account, + config.backed_dna + ); }); } } diff --git a/frame/bridge/oldetp/issuing/Cargo.toml b/frame/bridge/oldetp/issuing/Cargo.toml index d284a90..50d9a6a 100644 --- a/frame/bridge/oldetp/issuing/Cargo.toml +++ b/frame/bridge/oldetp/issuing/Cargo.toml @@ -1,29 +1,29 @@ [package] -authors = ["Hyperspace Network "] +authors = ["Metaverse "] description = "FRAME to issue CETP" edition = "2018" homepage = "https://mvs.org/" license = "GPL-3.0" -name = "hyperspace-oldetp-issuing" +name = "hyperspace-oldETP-issuing" readme = "README.md" -repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" +repository = "https://github.com/hyperspace-network/hyperspace-common/" +version = "1.4.0" [dependencies] # crates -codec = { package = "parity-scale-codec", version = "1.3.7", default-features = false } -serde = { version = "1.0.124", optional = true } -serde_json = { version = "1.0.62", optional = true } +codec = { package = "parity-scale-codec", version = "1.3.5", default-features = false } +serde = { version = "1.0.118", optional = true } +serde_json = { version = "1.0.61", optional = true } # substrate -frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", branch = "common-library" } +frame-system = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", branch = "common-library" } +sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", branch = "common-library" } # hyperspace hyperspace-support = { optional = true, path = "../../../support" } [dev-dependencies] # substrate -sp-io = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-io = { git = "https://github.com/darwinia-network/substrate.git", branch = "common-library" } # hyperspace hyperspace-balances = { path = "../../../balances" } hyperspace-support = { path = "../../../support" } diff --git a/frame/bridge/oldetp/issuing/src/lib.rs b/frame/bridge/oldetp/issuing/src/lib.rs index 92f2b2a..bceeb32 100644 --- a/frame/bridge/oldetp/issuing/src/lib.rs +++ b/frame/bridge/oldetp/issuing/src/lib.rs @@ -1,6 +1,6 @@ // This file is part of Hyperspace. // -// Copyright (C) 2018-2021 Hyperspace Network +// Copyright (C) 2018-2021 Metaverse // SPDX-License-Identifier: GPL-3.0 // // Hyperspace is free software: you can redistribute it and/or modify @@ -10,20 +10,16 @@ // // Hyperspace 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 +// 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 Hyperspace. If not, see . -//! # Oldetp Issuing Module +//! # oldETP Issuing Module #![cfg_attr(not(feature = "std"), no_std)] -pub mod weights; -// --- hyperspace --- -pub use weights::WeightInfo; - #[cfg(test)] mod mock; #[cfg(test)] @@ -35,11 +31,11 @@ mod types { pub type MappedEtp = u128; - pub type AccountId = ::AccountId; + pub type AccountId = ::AccountId; pub type EtpBalance = as Currency>>::Balance; - type EtpCurrency = ::EtpCurrency; + type EtpCurrency = ::EtpCurrency; } // --- substrate --- @@ -51,8 +47,8 @@ use sp_runtime::{traits::AccountIdConversion, ModuleId}; // --- hyperspace --- use types::*; -pub trait Config: frame_system::Config { - type Event: From> + Into<::Event>; +pub trait Trait: frame_system::Trait { + type Event: From> + Into<::Event>; type ModuleId: Get; @@ -61,6 +57,9 @@ pub trait Config: frame_system::Config { type WeightInfo: WeightInfo; } +pub trait WeightInfo {} +impl WeightInfo for () {} + decl_event! { pub enum Event where @@ -73,12 +72,12 @@ decl_event! { } decl_error! { - pub enum Error for Module { + pub enum Error for Module { } } decl_storage! { - trait Store for Module as HyperspaceOldetpIssuing { + trait Store for Module as HyperspaceoldETPIssuing { pub TotalMappedEtp get(fn total_mapped_etp) config(): MappedEtp; } @@ -95,7 +94,7 @@ decl_storage! { } decl_module! { - pub struct Module for enum Call + pub struct Module for enum Call where origin: T::Origin { @@ -107,7 +106,7 @@ decl_module! { } } -impl Module { +impl Module { pub fn account_id() -> T::AccountId { T::ModuleId::get().into_account() } diff --git a/frame/bridge/oldetp/issuing/src/mock.rs b/frame/bridge/oldetp/issuing/src/mock.rs index 4eee039..6569c6b 100644 --- a/frame/bridge/oldetp/issuing/src/mock.rs +++ b/frame/bridge/oldetp/issuing/src/mock.rs @@ -1,6 +1,6 @@ // This file is part of Hyperspace. // -// Copyright (C) 2018-2021 Hyperspace Network +// Copyright (C) 2018-2021 Metaverse // SPDX-License-Identifier: GPL-3.0 // // Hyperspace is free software: you can redistribute it and/or modify @@ -10,7 +10,7 @@ // // Hyperspace 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 +// 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 @@ -18,7 +18,7 @@ #![allow(dead_code)] -pub mod oldetp_issuing { +pub mod oldETP_issuing { // --- hyperspace --- pub use crate::Event; } @@ -26,12 +26,12 @@ pub mod oldetp_issuing { // --- crates --- use codec::{Decode, Encode}; // --- substrate --- -use frame_support::{impl_outer_event, impl_outer_origin, parameter_types}; +use frame_support::{impl_outer_event, impl_outer_origin, parameter_types, weights::Weight}; use sp_io::TestExternalities; use sp_runtime::{ testing::{Header, H256}, traits::{BlakeTwo256, IdentityLookup}, - RuntimeDebug, + Perbill, RuntimeDebug, }; // --- hyperspace --- use crate::*; @@ -40,9 +40,11 @@ pub type AccountId = u64; pub type Balance = u128; pub type System = frame_system::Module; -pub type OldetpIssuing = Module; +pub type Etp = hyperspace_balances::Module; +pub type oldETPIssuing = Module; -pub type OldetpIssuingError = Error; +pub type oldETPIssuingError = Error; +pub type EtpError = hyperspace_balances::Error; impl_outer_origin! { pub enum Origin for Test where system = frame_system {} @@ -52,29 +54,33 @@ impl_outer_event! { pub enum Event for Test { frame_system , hyperspace_balances Instance0, - oldetp_issuing , + oldETP_issuing , } } -hyperspace_support::impl_test_account_data! { deprecated } +hyperspace_support::impl_test_account_data! {} #[derive(Clone, Eq, PartialEq)] pub struct Test; parameter_types! { - pub const OldetpIssuingModuleId: ModuleId = ModuleId(*b"da/oldetpi"); + pub const oldETPIssuingModuleId: ModuleId = ModuleId(*b"da/oldETPi"); } -impl Config for Test { +impl Trait for Test { type Event = Event; - type ModuleId = OldetpIssuingModuleId; + type ModuleId = oldETPIssuingModuleId; type EtpCurrency = Etp; type WeightInfo = (); } -impl frame_system::Config for Test { +parameter_types! { + pub const BlockHashCount: u64 = 250; + pub const MaximumBlockWeight: Weight = 1024; + pub const MaximumBlockLength: u32 = 2 * 1024; + pub const MinimumPeriod: u64 = 5; + pub const AvailableBlockRatio: Perbill = Perbill::one(); +} +impl frame_system::Trait for Test { type BaseCallFilter = (); - type BlockWeights = (); - type BlockLength = (); - type DbWeight = (); type Origin = Origin; type Call = (); type Index = u64; @@ -86,19 +92,25 @@ impl frame_system::Config for Test { type Header = Header; type Event = Event; type BlockHashCount = (); + type MaximumBlockWeight = (); + type DbWeight = (); + type BlockExecutionWeight = (); + type ExtrinsicBaseWeight = (); + type MaximumExtrinsicWeight = (); + type MaximumBlockLength = (); + type AvailableBlockRatio = (); type Version = (); type PalletInfo = (); type AccountData = AccountData; type OnNewAccount = (); type OnKilledAccount = (); type SystemWeightInfo = (); - type SS58Prefix = (); } parameter_types! { pub const ExistentialDeposit: Balance = 0; } -impl hyperspace_balances::Config for Test { +impl hyperspace_balances::Trait for Test { type Balance = Balance; type DustRemoval = (); type Event = Event; @@ -115,7 +127,7 @@ pub fn new_test_ext() -> TestExternalities { .build_storage::() .unwrap(); - EtpConfig { + hyperspace_balances::GenesisConfig:: { balances: (1..10) .map(|i: AccountId| vec![(i, 100 * i as Balance), (10 * i, 1000 * i as Balance)]) .flatten() @@ -143,9 +155,9 @@ pub fn events() -> Vec { events } -pub fn oldetp_issuing_events() -> Vec { +pub fn oldETP_issuing_events() -> Vec { events() .into_iter() - .filter(|e| matches!(e, Event::oldetp_issuing(_))) + .filter(|e| matches!(e, Event::oldETP_issuing(_))) .collect() } diff --git a/frame/bridge/oldetp/issuing/src/tests.rs b/frame/bridge/oldetp/issuing/src/tests.rs index 48a0fe7..96c033d 100644 --- a/frame/bridge/oldetp/issuing/src/tests.rs +++ b/frame/bridge/oldetp/issuing/src/tests.rs @@ -1,6 +1,6 @@ // This file is part of Hyperspace. // -// Copyright (C) 2018-2021 Hyperspace Network +// Copyright (C) 2018-2021 Metaverse // SPDX-License-Identifier: GPL-3.0 // // Hyperspace is free software: you can redistribute it and/or modify @@ -10,7 +10,7 @@ // // Hyperspace 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 +// 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 diff --git a/frame/bridge/oldetp/issuing/src/weights.rs b/frame/bridge/oldetp/issuing/src/weights.rs deleted file mode 100644 index aadf2f9..0000000 --- a/frame/bridge/oldetp/issuing/src/weights.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub trait WeightInfo {} -impl WeightInfo for () {} diff --git a/frame/bridge/oldna/backing/Cargo.toml b/frame/bridge/oldna/backing/Cargo.toml index 6df1b70..86f83f0 100644 --- a/frame/bridge/oldna/backing/Cargo.toml +++ b/frame/bridge/oldna/backing/Cargo.toml @@ -7,16 +7,16 @@ license = "GPL-3.0" name = "hyperspace-oldna-backing" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" +version = "1.4.0" [dependencies] # crates codec = { package = "parity-scale-codec", version = "1.3.7", default-features = false } serde = { version = "1.0.124", optional = true } # substrate -frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } [features] default = ["std"] diff --git a/frame/bridge/oldna/backing/src/lib.rs b/frame/bridge/oldna/backing/src/lib.rs index 1d4f283..cedade0 100644 --- a/frame/bridge/oldna/backing/src/lib.rs +++ b/frame/bridge/oldna/backing/src/lib.rs @@ -33,13 +33,9 @@ mod types { #[cfg(feature = "std")] pub type EtpBalance = as Currency>>::Balance; - #[cfg(feature = "std")] - pub type DnaBalance = as Currency>>::Balance; #[cfg(feature = "std")] type EtpCurrency = ::EtpCurrency; - #[cfg(feature = "std")] - type DnaCurrency = ::DnaCurrency; } // --- substrate --- @@ -55,7 +51,6 @@ pub trait Config: frame_system::Config { type ModuleId: Get; type EtpCurrency: Currency>; - type DnaCurrency: Currency>; type WeightInfo: WeightInfo; } @@ -65,17 +60,11 @@ decl_storage! { add_extra_genesis { config(backed_etp): EtpBalance; - config(backed_dna): DnaBalance; build(|config| { - let module_account = >::account_id(); let _ = T::EtpCurrency::make_free_balance_be( - &module_account, + &>::account_id(), T::EtpCurrency::minimum_balance() + config.backed_etp ); - let _ = T::DnaCurrency::make_free_balance_be( - &module_account, - config.backed_dna - ); }); } } diff --git a/frame/bridge/relay-authorities/Cargo.toml b/frame/bridge/relay-authorities/Cargo.toml index ffbfd95..596cc51 100644 --- a/frame/bridge/relay-authorities/Cargo.toml +++ b/frame/bridge/relay-authorities/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0" name = "hyperspace-relay-authorities" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" +version = "1.4.0" [dependencies] # crates @@ -17,10 +17,10 @@ serde = { version = "1.0.124", optional = true } hyperspace-relay-primitives = { default-features = false, path = "../../../primitives/relay" } hyperspace-support = { default-features = false, path = "../../support" } # substrate -frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } [dev-dependencies] # crates @@ -29,8 +29,8 @@ array-bytes = { version = "1.1.0" } hyperspace-balances = { path = "../../balances" } hyperspace-support = { path = "../../support" } # substrate -sp-core = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-io = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-core = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-io = { git = "https://github.com/new-mvs/substrate", branch = "latest" } [features] default = ["std"] diff --git a/frame/bridge/relay-authorities/src/test.rs b/frame/bridge/relay-authorities/src/test.rs index cdb5a3b..b62621f 100644 --- a/frame/bridge/relay-authorities/src/test.rs +++ b/frame/bridge/relay-authorities/src/test.rs @@ -338,7 +338,7 @@ fn encode_message_should_work() { // ) let message = { _S { - _1: RuntimeString::from("HYPERSPACE"), + _1: RuntimeString::from("DRML"), _2: array_bytes::hex2array_unchecked!("0x479fbdf9", 4), _3: 789u32, _4: [0u8; 32], @@ -360,7 +360,7 @@ fn encode_message_should_work() { // ) let message = { _S { - _1: RuntimeString::from("HYPERSPACE"), + _1: RuntimeString::from("DRML"), _2: array_bytes::hex2array_unchecked!("0xb4bcf497", 4), _3: 789u32, _4: vec![[7u8; 20], [8u8; 20], [9u8; 20]], diff --git a/frame/bridge/relayer-game/Cargo.toml b/frame/bridge/relayer-game/Cargo.toml index 2ad45be..575411f 100644 --- a/frame/bridge/relayer-game/Cargo.toml +++ b/frame/bridge/relayer-game/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0" name = "hyperspace-relayer-game" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" +version = "1.4.0" [dependencies] # crates @@ -17,10 +17,10 @@ serde = { version = "1.0.124", optional = true } hyperspace-relay-primitives = { default-features = false, path = "../../../primitives/relay" } hyperspace-support = { default-features = false, path = "../../support" } # substrate -frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } [dev-dependencies] # crates @@ -28,8 +28,8 @@ env_logger = { version = "0.8.2" } # hyperspace hyperspace-balances = { path = "../../balances" } # substrate -sp-core = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-io = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-core = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-io = { git = "https://github.com/new-mvs/substrate", branch = "latest" } [features] default = ["std"] diff --git a/frame/claims/Cargo.toml b/frame/claims/Cargo.toml index b61ba79..922ffe2 100644 --- a/frame/claims/Cargo.toml +++ b/frame/claims/Cargo.toml @@ -7,22 +7,22 @@ license = "GPL-3.0" name = "hyperspace-claims" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" +version = "1.4.0" [dependencies] # crates array-bytes = { version = "1.1.0" } -codec = { package = "parity-scale-codec", version = "1.3.7", default-features = false, features = ["derive"] } -serde = { version = "1.0.124", optional = true } -serde_json = { version = "1.0.62", optional = true } +codec = { package = "parity-scale-codec", version = "1.3.7", default-features = false, features = ["derive"] } +serde = { version = "1.0.124", optional = true } +serde_json = { version = "1.0.62", optional = true } # hyperspace hyperspace-support = { default-features = false, path = "../support" } # substrate -frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } [dev-dependencies] # crates @@ -30,7 +30,7 @@ libsecp256k1 = { version = "0.3.5" } # hyperspace hyperspace-balances = { path = "../balances" } # substrate -sp-core = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-core = { git = "https://github.com/new-mvs/substrate", branch = "latest" } [features] default = ["std"] diff --git a/frame/claims/src/address.rs b/frame/claims/src/address.rs index adb76bb..f57c39d 100644 --- a/frame/claims/src/address.rs +++ b/frame/claims/src/address.rs @@ -21,6 +21,7 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer}; // --- hyperspace --- use crate::AddressT; + macro_rules! impl_address { ($name:ident, $sname:expr, $prefix:expr) => { #[doc = "An "] @@ -78,9 +79,9 @@ hyperspace_support::impl_genesis! { struct ClaimsList { dot: Vec>, eth: Vec>, - oldna: Vec> + oldetp: Vec> } } impl_address!(EthereumAddress, "Ethereum", "0x"); -impl_address!(OldnaAddress, "Oldna", "41"); +impl_address!(OldetpAddress, "Oldetp", "41"); diff --git a/frame/claims/src/lib.rs b/frame/claims/src/lib.rs index 51e99cc..7002f64 100644 --- a/frame/claims/src/lib.rs +++ b/frame/claims/src/lib.rs @@ -110,8 +110,8 @@ decl_storage! { ClaimsFromEth get(fn claims_from_eth) : map hasher(identity) AddressT => Option>; - ClaimsFromOldna - get(fn claims_from_oldna) + ClaimsFromOldetp + get(fn claims_from_oldetp) : map hasher(identity) AddressT => Option>; } add_extra_genesis { @@ -120,11 +120,11 @@ decl_storage! { let ClaimsList { dot, eth, - oldna, + oldetp, } = &config.claims_list; let mut total = >::zero(); - if dot.is_empty() && eth.is_empty() && oldna.is_empty() { + if dot.is_empty() && eth.is_empty() && oldetp.is_empty() { error!("[hyperspace-claims] Genesis Claims List is Set to EMPTY"); } else { // Eth Address @@ -140,10 +140,10 @@ decl_storage! { total += backed_etp; } - // Oldna Address - for Account { address, backed_etp } in oldna { + // Oldetp Address + for Account { address, backed_etp } in oldetp { let backed_etp = (*backed_etp).saturated_into(); - >::insert(address.0, backed_etp); + >::insert(address.0, backed_etp); total += backed_etp; } } @@ -241,10 +241,10 @@ decl_module! { Self::deposit_event(RawEvent::Claimed(dest, signer, balance_due)); } - OtherSignature::Oldna(signature) => { - let signer = Self::oldna_recover(&signature, &data) + OtherSignature::Oldetp(signature) => { + let signer = Self::oldetp_recover(&signature, &data) .ok_or(>::InvalidSignature)?; - let balance_due = >::get(&signer) + let balance_due = >::get(&signer) .ok_or(>::SignerHasNoClaim)?; ensure!( @@ -258,7 +258,7 @@ decl_module! { KeepAlive, )?; - >::remove(&signer); + >::remove(&signer); Self::deposit_event(RawEvent::Claimed(dest, signer, balance_due)); } @@ -300,9 +300,9 @@ decl_module! { T::EtpCurrency::deposit_creating(&Self::account_id(), value); >::insert(who, value); } - OtherAddress::Oldna(who) => { + OtherAddress::Oldetp(who) => { T::EtpCurrency::deposit_creating(&Self::account_id(), value); - >::insert(who, value); + >::insert(who, value); } } } @@ -329,13 +329,13 @@ decl_module! { } else { Err(>::NewAddressTypeMis)?; }, - OtherAddress::Oldna(old) => if let OtherAddress::Oldna(new) = new { + OtherAddress::Oldetp(old) => if let OtherAddress::Oldetp(new) = new { ensure!( - !>::contains_key(&new), + !>::contains_key(&new), >::MoveToExistedAddress ); - >::take(&old).map(|c| >::insert(&new, c)); + >::take(&old).map(|c| >::insert(&new, c)); } else { Err(>::NewAddressTypeMis)?; } @@ -371,8 +371,8 @@ impl Module { } // Constructs the message that RPC's `personal_sign` and `sign` would sign. - // Oldna have different signing specs: https://github.com/oldnaprotocol/tips/issues/104 - fn oldna_signable_message(what: &[u8], signed_message: &[u8]) -> Vec { + // Oldetp have different signing specs: https://github.com/oldetpprotocol/tips/issues/104 + fn oldetp_signable_message(what: &[u8], signed_message: &[u8]) -> Vec { let prefix = T::Prefix::get(); let mut l = 32; let mut rev = Vec::new(); @@ -399,12 +399,12 @@ impl Module { Some(res) } - // Attempts to recover the Oldna address from a message signature signed by using - // the Oldna RPC's `personal_sign` and `oldna_sign`. - fn oldna_recover(s: &EcdsaSignature, what: &[u8]) -> Option { - let msg = keccak_256(&Self::oldna_signable_message( + // Attempts to recover the Oldetp address from a message signature signed by using + // the Oldetp RPC's `personal_sign` and `oldetp_sign`. + fn oldetp_recover(s: &EcdsaSignature, what: &[u8]) -> Option { + let msg = keccak_256(&Self::oldetp_signable_message( what, - b"\x19OLDNA Signed Message:\n", + b"\x19OLDETP Signed Message:\n", )); let mut res = AddressT::default(); res.copy_from_slice(&keccak_256(&secp256k1_ecdsa_recover(&s.0, &msg).ok()?[..])[12..]); @@ -449,8 +449,8 @@ impl sp_runtime::traits::ValidateUnsigned for Module { propagate: true, }) } - OtherSignature::Oldna(signature) => { - let maybe_signer = Self::oldna_recover(&signature, &data); + OtherSignature::Oldetp(signature) => { + let maybe_signer = Self::oldetp_recover(&signature, &data); let signer = if let Some(s) = maybe_signer { s } else { @@ -460,7 +460,7 @@ impl sp_runtime::traits::ValidateUnsigned for Module { .into(); }; - if !>::contains_key(&signer) { + if !>::contains_key(&signer) { return Err(InvalidTransaction::Custom( ValidityError::SignerHasNoClaim as _, ) @@ -493,13 +493,13 @@ enum ValidityError { #[derive(Clone, PartialEq, Encode, Decode, RuntimeDebug)] pub enum OtherSignature { Eth(EcdsaSignature), - Oldna(EcdsaSignature), + Oldetp(EcdsaSignature), } #[derive(Clone, PartialEq, Encode, Decode, RuntimeDebug)] pub enum OtherAddress { Eth(AddressT), - Oldna(AddressT), + Oldetp(AddressT), } #[derive(Clone, Encode, Decode)] @@ -559,12 +559,12 @@ mod secp_utils { EcdsaSignature(r) } - pub fn oldna_sig( + pub fn oldetp_sig( secret: &secp256k1::SecretKey, what: &[u8], signed_message: &[u8], ) -> EcdsaSignature { - let msg = keccak_256(&>::oldna_signable_message( + let msg = keccak_256(&>::oldetp_signable_message( &to_ascii_hex(what)[..], signed_message, )); @@ -593,6 +593,7 @@ mod tests { }; // --- hyperspace --- use crate::{self as hyperspace_claims, secp_utils::*, *}; + type Balance = u64; @@ -600,7 +601,7 @@ mod tests { type UncheckedExtrinsic = MockUncheckedExtrinsic; const ETHEREUM_SIGNED_MESSAGE: &'static [u8] = b"\x19Ethereum Signed Message:\n"; - const OLDNA_SIGNED_MESSAGE: &'static [u8] = b"\x19OLDNA Signed Message:\n"; + const OLDETP_SIGNED_MESSAGE: &'static [u8] = b"\x19OLDETP Signed Message:\n"; hyperspace_support::impl_test_account_data! {} @@ -702,8 +703,8 @@ mod tests { address: EthereumAddress(addr(&bob())), backed_etp: 200, }], - oldna: vec![Account { - address: OldnaAddress(addr(&carol())), + oldetp: vec![Account { + address: OldetpAddress(addr(&carol())), backed_etp: 300, }], }, @@ -723,13 +724,13 @@ mod tests { assert_eq!(Etp::usable_balance(&Claims::account_id()), 600); assert_eq!(Claims::claims_from_eth(&addr(&alice())), Some(100)); - assert_eq!(Claims::claims_from_oldna(&addr(&alice())), None); + assert_eq!(Claims::claims_from_oldetp(&addr(&alice())), None); assert_eq!(Claims::claims_from_eth(&addr(&bob())), Some(200)); - assert_eq!(Claims::claims_from_oldna(&addr(&bob())), None); + assert_eq!(Claims::claims_from_oldetp(&addr(&bob())), None); assert_eq!(Claims::claims_from_eth(&addr(&carol())), None); - assert_eq!(Claims::claims_from_oldna(&addr(&carol())), Some(300)); + assert_eq!(Claims::claims_from_oldetp(&addr(&carol())), Some(300)); }); } @@ -744,13 +745,13 @@ mod tests { let z: EthereumAddress = serde_json::from_str(&y).unwrap(); assert_eq!(x.0, z.0); - let x = OldnaAddress(array_bytes::hex2array_unchecked!( + let x = OldetpAddress(array_bytes::hex2array_unchecked!( "0x0123456789abcdef0123456789abcdef01234567", 20 )); let y = serde_json::to_string(&x).unwrap(); assert_eq!(y, "\"410123456789abcdef0123456789abcdef01234567\""); - let z: OldnaAddress = serde_json::from_str(&y).unwrap(); + let z: OldetpAddress = serde_json::from_str(&y).unwrap(); assert_eq!(x.0, z.0); } @@ -787,10 +788,10 @@ mod tests { assert_ok!(Claims::claim( Origin::none(), 3, - OtherSignature::Oldna(oldna_sig::( + OtherSignature::Oldetp(oldetp_sig::( &carol(), &3u64.encode(), - OLDNA_SIGNED_MESSAGE + OLDETP_SIGNED_MESSAGE )), )); assert_eq!(Etp::free_balance(&3), 300); @@ -814,7 +815,7 @@ mod tests { Claims::move_claim( Origin::signed(6), OtherAddress::Eth(addr(&alice())), - OtherAddress::Oldna(addr(&carol())), + OtherAddress::Oldetp(addr(&carol())), ), >::NewAddressTypeMis ); @@ -998,13 +999,13 @@ mod tests { } #[test] - fn real_oldna_sig_works() { + fn real_oldetp_sig_works() { new_test_ext().execute_with(|| { // "Pay RUSTs to the TEST account:0c0529c66a44e1861e5e1502b4a87009f23c792518a7a2091363f5a0e38abd57" let sig = array_bytes::hex2array_unchecked!("0x34c3d5afc7f8fa08f9d00a1ec4ac274c63ebce99460b556de85258c94f41ab2f52ad5188bd9fc51251cf5dcdd53751b1bd577828db3f2e8fe8ef77907d7f3f6a1b", 65); let sig = EcdsaSignature(sig); let who = array_bytes::hex2array_unchecked!("0x0c0529c66a44e1861e5e1502b4a87009f23c792518a7a2091363f5a0e38abd57", 32).using_encoded(to_ascii_hex); - let signer = Claims::oldna_recover(&sig, &who).unwrap(); + let signer = Claims::oldetp_recover(&sig, &who).unwrap(); assert_eq!(signer, array_bytes::hex2array_unchecked!("0x11974bce18a43243ede78beec2fd8e0ba4fe17ae", 20)); }); } diff --git a/frame/democracy/Cargo.toml b/frame/democracy/Cargo.toml index a36ce47..4d59163 100644 --- a/frame/democracy/Cargo.toml +++ b/frame/democracy/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0" name = "hyperspace-democracy" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" +version = "1.4.0" [dependencies] # crates @@ -16,11 +16,11 @@ serde = { version = "1.0.124", optional = true, features = ["derive"] } # hyperspace hyperspace-support = { default-features = false, path = "../support" } # substrate -frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } [dev-dependencies] # crates @@ -29,10 +29,10 @@ hex-literal = "0.3.1" hyperspace-balances = { path = "../balances" } hyperspace-support = { features = ["easy-testing"], path = "../support" } # substrate -pallet-scheduler = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-core = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-storage = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -substrate-test-utils = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +pallet-scheduler = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-core = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-storage = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +substrate-test-utils = { git = "https://github.com/new-mvs/substrate", branch = "latest" } [features] default = ["std"] diff --git a/frame/dvm-dynamic-fee/Cargo.toml b/frame/dvm-dynamic-fee/Cargo.toml deleted file mode 100644 index b0849c0..0000000 --- a/frame/dvm-dynamic-fee/Cargo.toml +++ /dev/null @@ -1,35 +0,0 @@ -[package] -authors = ["Hyperspace Network "] -description = "Dynamic fee handling for EVM." -edition = "2018" -homepage = "https://mvs.org/" -license = "GPL-3.0" -name = "dvm-dynamic-fee" -readme = "README.md" -repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" - - -[dependencies] -codec = { default-features = false, version = "1.3.7", package = "parity-scale-codec" } -serde = { default-features = false, version = "1.0.123", optional = true, features = ["derive"] } - -frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-inherents = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } - -[features] -default = ["std"] -std = [ - "codec/std", - "serde", - "frame-support/std", - "frame-system/std", - "sp-core/std", - "sp-inherents/std", - "sp-runtime/std", - "sp-std/std", -] \ No newline at end of file diff --git a/frame/dvm-dynamic-fee/src/lib.rs b/frame/dvm-dynamic-fee/src/lib.rs deleted file mode 100644 index da7a27e..0000000 --- a/frame/dvm-dynamic-fee/src/lib.rs +++ /dev/null @@ -1,132 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// This file is part of Frontier. -// -// Copyright (c) 2021 Parity Technologies (UK) Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Ensure we're `no_std` when compiling for Wasm. -#![cfg_attr(not(feature = "std"), no_std)] - -use codec::{Decode, Encode}; -use frame_support::{decl_event, decl_module, decl_storage, traits::Get}; -use frame_system::ensure_none; -use sp_core::U256; -#[cfg(feature = "std")] -use sp_inherents::ProvideInherentData; -use sp_inherents::{InherentData, InherentIdentifier, IsFatalError, ProvideInherent}; -use sp_runtime::RuntimeDebug; -use sp_std::{ - cmp::{max, min}, - result, -}; - -pub trait Config: frame_system::Config { - /// The overarching event type. - type Event: From + Into<::Event>; - /// Bound divisor for min gas price. - type MinGasPriceBoundDivisor: Get; -} - -decl_storage! { - trait Store for Module as DynamicFee { - MinGasPrice get(fn min_gas_price) config(): U256; - TargetMinGasPrice: Option; - } -} - -decl_event!( - pub enum Event { - TargetMinGasPriceSet(U256), - } -); - -decl_module! { - pub struct Module for enum Call where origin: T::Origin { - fn deposit_event() = default; - - fn on_finalize(_block_number: T::BlockNumber) { - if let Some(target) = TargetMinGasPrice::get() { - let bound = MinGasPrice::get() / T::MinGasPriceBoundDivisor::get() + U256::one(); - - let upper_limit = MinGasPrice::get().saturating_add(bound); - let lower_limit = MinGasPrice::get().saturating_sub(bound); - - MinGasPrice::set(min(upper_limit, max(lower_limit, target))); - } - - TargetMinGasPrice::kill(); - } - - #[weight = 0] - fn note_min_gas_price_target( - origin, - target: U256, - ) { - ensure_none(origin)?; - - TargetMinGasPrice::set(Some(target)); - Self::deposit_event(Event::TargetMinGasPriceSet(target)); - } - } -} - -#[derive(Encode, Decode, RuntimeDebug)] -pub enum InherentError {} - -impl IsFatalError for InherentError { - fn is_fatal_error(&self) -> bool { - match *self {} - } -} - -pub const INHERENT_IDENTIFIER: InherentIdentifier = *b"dynfee0_"; - -pub type InherentType = U256; - -#[cfg(feature = "std")] -pub struct InherentDataProvider(pub InherentType); - -#[cfg(feature = "std")] -impl ProvideInherentData for InherentDataProvider { - fn inherent_identifier(&self) -> &'static InherentIdentifier { - &INHERENT_IDENTIFIER - } - - fn provide_inherent_data( - &self, - inherent_data: &mut InherentData, - ) -> Result<(), sp_inherents::Error> { - inherent_data.put_data(INHERENT_IDENTIFIER, &self.0) - } - - fn error_to_string(&self, _: &[u8]) -> Option { - None - } -} - -impl ProvideInherent for Module { - type Call = Call; - type Error = InherentError; - const INHERENT_IDENTIFIER: InherentIdentifier = INHERENT_IDENTIFIER; - - fn create_inherent(data: &InherentData) -> Option { - let target = data.get_data::(&INHERENT_IDENTIFIER).ok()??; - - Some(Call::note_min_gas_price_target(target)) - } - - fn check_inherent(_call: &Self::Call, _data: &InherentData) -> result::Result<(), Self::Error> { - Ok(()) - } -} diff --git a/frame/dvm/Cargo.toml b/frame/dvm/Cargo.toml index 9c53422..f16377e 100644 --- a/frame/dvm/Cargo.toml +++ b/frame/dvm/Cargo.toml @@ -7,35 +7,34 @@ license = "GPL-3.0" name = "dvm-ethereum" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" +version = "1.4.0" [dependencies] # crates -array-bytes = { version = "1.1.0" } codec = { package = "parity-scale-codec", version = "1.3.7", default-features = false } ethereum = { version = "0.6.0", default-features = false, features = ["with-codec"] } ethereum-types = { version = "0.10.0", default-features = false } -evm = { version = "0.23.0", default-features = false, features = ["with-codec"] } +evm = { version = "0.22.0", default-features = false, features = ["with-codec"] } libsecp256k1 = { version = "0.3", default-features = false } rlp = { version = "0.5.0", default-features = false } serde = { version = "1.0.124", optional = true, default-features = false } sha3 = { version = "0.8", default-features = false } +array-bytes = { version = "1.1.0" } # hyperspace hyperspace-balances = { default-features = false, path = "../balances" } hyperspace-evm = { default-features = false, path = "../evm" } +hyperspace-evm-primitives = { default-features = false, path = "../../primitives/evm" } hyperspace-support = { default-features = false, path = "../support" } -dp_consensus = { default-features = false, path = "../../primitives/consensus" } -dp-evm = { default-features = false, path = "../../primitives/evm" } -dp-storage = { default-features = false, path = "../../primitives/storage" } +dvm-consensus-primitives = { default-features = false, path = "../../primitives/consensus" } dvm-rpc-runtime-api = { default-features = false, path = "./rpc/runtime-api" } # substrate -frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -pallet-timestamp = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +pallet-timestamp = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } [dev-dependencies] # crates @@ -63,9 +62,9 @@ crates-std = [ hyperspace-std = [ "hyperspace-balances/std", "hyperspace-evm/std", + "hyperspace-evm-primitives/std", "hyperspace-support/std", - "dp-evm/std", - "dp_consensus/std", + "dvm-consensus-primitives/std", "dvm-rpc-runtime-api/std", ] substrate-std = [ diff --git a/frame/dvm/rpc/Cargo.toml b/frame/dvm/rpc/Cargo.toml index 6444671..e804283 100644 --- a/frame/dvm/rpc/Cargo.toml +++ b/frame/dvm/rpc/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0" name = "dvm-rpc-core" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" +version = "1.4.0" [dependencies] # crates @@ -19,14 +19,14 @@ jsonrpc-derive = { version = "15.1.0" } jsonrpc-pubsub = { version = "15.1.0" } # hyperspace -hyperspace-evm = { default-features = false, path = "../../evm" } -dp-evm = { default-features = false, path = "../../../primitives/evm" } -dp-rpc = { default-features = false, path = "../../../primitives/rpc" } +hyperspace-evm = { default-features = false, path = "../../evm" } +hyperspace-evm-primitives = { default-features = false, path = "../../../primitives/evm" } +dvm-rpc-core-primitives = { default-features = false, path = "../../../primitives/dvm-rpc-core" } # substrate -sp-api = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-api = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } [features] default = ["std"] @@ -44,7 +44,7 @@ crates-std = [ ] hyperspace-std = [ "hyperspace-evm/std", - "dp-evm/std", + "hyperspace-evm-primitives/std", ] substrate-std = [ "sp-api/std", diff --git a/frame/dvm/rpc/runtime-api/Cargo.toml b/frame/dvm/rpc/runtime-api/Cargo.toml index b2a824d..034caf0 100644 --- a/frame/dvm/rpc/runtime-api/Cargo.toml +++ b/frame/dvm/rpc/runtime-api/Cargo.toml @@ -7,22 +7,23 @@ license = "GPL-3.0" name = "dvm-rpc-runtime-api" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" +version = "1.4.0" [dependencies] # crates codec = { package = "parity-scale-codec", version = "1.3.7", default-features = false } ethereum = { version = "0.6.0", default-features = false, features = ["with-codec"] } ethereum-types = { version = "0.10.0", default-features = false } + # hyperspace -hyperspace-evm = { default-features = false, path = "../../../evm" } -dp-evm = { default-features = false, path = "../../../../primitives/evm" } +hyperspace-evm = { default-features = false, path = "../../../evm" } +hyperspace-evm-primitives = { default-features = false, path = "../../../../primitives/evm" } # substrate -sp-api = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-api = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } [features] default = ["std"] @@ -35,7 +36,7 @@ std = [ hyperspace-std = [ "hyperspace-evm/std", - "dp-evm/std", + "hyperspace-evm-primitives/std", ] crates-std = [ diff --git a/frame/dvm/rpc/runtime-api/src/lib.rs b/frame/dvm/rpc/runtime-api/src/lib.rs index 8ba2df1..c08b723 100644 --- a/frame/dvm/rpc/runtime-api/src/lib.rs +++ b/frame/dvm/rpc/runtime-api/src/lib.rs @@ -53,7 +53,7 @@ sp_api::decl_runtime_apis! { /// Returns runtime defined hyperspace_evm::ChainId. fn chain_id() -> u64; /// Returns hyperspace_evm::Accounts by address. - fn account_basic(address: H160) -> dp_evm::Account; + fn account_basic(address: H160) -> hyperspace_evm_primitives::Account; /// Returns FixedGasPrice::min_gas_price fn gas_price() -> U256; /// For a given account address, returns hyperspace_evm::AccountCodes. @@ -62,7 +62,7 @@ sp_api::decl_runtime_apis! { fn author() -> H160; /// For a given account address and index, returns hyperspace_evm::AccountStorages. fn storage_at(address: H160, index: U256) -> H256; - /// Returns a dvm_ethereum::call response. + /// Returns a pallet_ethereum::call response. fn call( from: H160, to: H160, @@ -72,7 +72,7 @@ sp_api::decl_runtime_apis! { gas_price: Option, nonce: Option, estimate: bool, - ) -> Result; + ) -> Result; /// Returns a frame_ethereum::create response. fn create( from: H160, @@ -82,7 +82,7 @@ sp_api::decl_runtime_apis! { gas_price: Option, nonce: Option, estimate: bool, - ) -> Result; + ) -> Result; /// Return the current block. fn current_block() -> Option; /// Return the current receipt. diff --git a/frame/dvm/rpc/src/eth.rs b/frame/dvm/rpc/src/eth.rs index d135be5..3e31f8b 100644 --- a/frame/dvm/rpc/src/eth.rs +++ b/frame/dvm/rpc/src/eth.rs @@ -16,17 +16,15 @@ //! Eth rpc interface. -// --- hyperspace --- -use dp_rpc::{ +use ethereum_types::{H160, H256, H64, U256, U64}; +use jsonrpc_core::{BoxFuture, Result}; +use jsonrpc_derive::rpc; + +use dvm_rpc_core_primitives::{ BlockNumber, Bytes, CallRequest, Filter, FilterChanges, Index, Log, Receipt, RichBlock, SyncStatus, Transaction, TransactionRequest, Work, }; pub use rpc_impl_EthApi::gen_server::EthApi as EthApiServer; -pub use rpc_impl_EthFilterApi::gen_server::EthFilterApi as EthFilterApiServer; -// --- std --- -use ethereum_types::{H160, H256, H64, U256, U64}; -use jsonrpc_core::{BoxFuture, Result}; -use jsonrpc_derive::rpc; /// Eth rpc interface. #[rpc(server)] @@ -193,11 +191,11 @@ pub trait EthFilterApi { /// Returns filter changes since last poll. #[rpc(name = "eth_getFilterChanges")] - fn filter_changes(&self, _: Index) -> Result; + fn filter_changes(&self, _: Index) -> BoxFuture; /// Returns all logs matching given filter (in a range 'from' - 'to'). #[rpc(name = "eth_getFilterLogs")] - fn filter_logs(&self, _: Index) -> Result>; + fn filter_logs(&self, _: Index) -> BoxFuture>; /// Uninstalls filter. #[rpc(name = "eth_uninstallFilter")] diff --git a/frame/dvm/rpc/src/eth_pubsub.rs b/frame/dvm/rpc/src/eth_pubsub.rs index de0f8a6..4754220 100644 --- a/frame/dvm/rpc/src/eth_pubsub.rs +++ b/frame/dvm/rpc/src/eth_pubsub.rs @@ -20,7 +20,7 @@ use jsonrpc_core::Result; use jsonrpc_derive::rpc; use jsonrpc_pubsub::{typed, SubscriptionId}; -use dp_rpc::pubsub; +use dvm_rpc_core_primitives::pubsub; pub use rpc_impl_EthPubSubApi::gen_server::EthPubSubApi as EthPubSubApiServer; diff --git a/frame/dvm/rpc/src/lib.rs b/frame/dvm/rpc/src/lib.rs index 78bb772..26fa4cc 100644 --- a/frame/dvm/rpc/src/lib.rs +++ b/frame/dvm/rpc/src/lib.rs @@ -3,7 +3,7 @@ mod eth_pubsub; mod net; mod web3; -pub use eth::{EthApi, EthApiServer, EthFilterApi, EthFilterApiServer}; +pub use eth::{EthApi, EthApiServer, EthFilterApi}; pub use eth_pubsub::{EthPubSubApi, EthPubSubApiServer}; pub use net::{NetApi, NetApiServer}; pub use web3::{Web3Api, Web3ApiServer}; diff --git a/frame/dvm/rpc/src/web3.rs b/frame/dvm/rpc/src/web3.rs index 522aea4..9dff7b7 100644 --- a/frame/dvm/rpc/src/web3.rs +++ b/frame/dvm/rpc/src/web3.rs @@ -19,7 +19,7 @@ use ethereum_types::H256; use jsonrpc_core::Result; use jsonrpc_derive::rpc; -use dp_rpc::Bytes; +use dvm_rpc_core_primitives::Bytes; pub use rpc_impl_Web3Api::gen_server::Web3Api as Web3ApiServer; diff --git a/frame/dvm/src/account_basic.rs b/frame/dvm/src/account_basic.rs index 2caacf5..0bd9b49 100644 --- a/frame/dvm/src/account_basic.rs +++ b/frame/dvm/src/account_basic.rs @@ -85,7 +85,7 @@ impl>::Balance::unique_saturated_from( diff_remaining_balance.low_u128(), ); - crate::Module::::dec_remaining_balance(&account_id, value); + crate::Module::::dec_remain_balance(&account_id, value); } } else if current.balance < new.balance { let diff = new.balance - current.balance; @@ -111,7 +111,7 @@ impl>::Balance::unique_saturated_from( diff_remaining_balance.low_u128(), ); - crate::Module::::inc_remaining_balance(&account_id, value); + crate::Module::::inc_remain_balance(&account_id, value); } } } diff --git a/frame/dvm/src/lib.rs b/frame/dvm/src/lib.rs index 764cbb5..85a4777 100644 --- a/frame/dvm/src/lib.rs +++ b/frame/dvm/src/lib.rs @@ -22,20 +22,16 @@ // Ensure we're `no_std` when compiling for Wasm. #![cfg_attr(not(feature = "std"), no_std)] -// --- hyperspace --- -use hyperspace_evm::{AccountBasicMapping, FeeCalculator, GasWeightMapping, Runner}; -use dp_consensus::{PostLog, PreLog, FRONTIER_ENGINE_ID}; -use dp_evm::CallOrCreateInfo; -use dp_storage::PALLET_ETHEREUM_SCHEMA; -pub use dvm_rpc_runtime_api::TransactionStatus; -// --- substrate --- -use frame_support::traits::Currency; +use codec::{Decode, Encode}; +use dvm_consensus_primitives::{ConsensusLog, FRONTIER_ENGINE_ID}; +use ethereum_types::{Bloom, BloomInput, H160, H256, H64, U256}; +use evm::ExitReason; use frame_support::{ decl_error, decl_event, decl_module, decl_storage, dispatch::DispatchResultWithPostInfo, traits::FindAuthor, traits::Get, weights::Weight, }; -use frame_support::{ensure, traits::UnfilteredDispatchable}; -use frame_system::{ensure_none, RawOrigin}; +use frame_system::ensure_none; +use sha3::{Digest, Keccak256}; use sp_runtime::{ generic::DigestItem, traits::{Saturating, UniqueSaturatedInto}, @@ -45,12 +41,12 @@ use sp_runtime::{ DispatchError, }; use sp_std::prelude::*; -// --- std --- -use codec::{Decode, Encode}; + +use hyperspace_evm::{AccountBasicMapping, AddressMapping, GasWeightMapping, Runner}; +use hyperspace_evm_primitives::CallOrCreateInfo; +pub use dvm_rpc_runtime_api::TransactionStatus; pub use ethereum::{Block, Log, Receipt, Transaction, TransactionAction, TransactionMessage}; -use ethereum_types::{Bloom, BloomInput, H160, H256, H64, U256}; -use evm::ExitReason; -use sha3::{Digest, Keccak256}; +use frame_support::traits::Currency; #[cfg(all(feature = "std", test))] mod tests; @@ -65,20 +61,8 @@ pub enum ReturnValue { Hash(H160), } -/// The schema version for Pallet Ethereum's storage -#[derive(Clone, Debug, Encode, Decode, PartialEq, Eq, PartialOrd, Ord)] -pub enum EthereumStorageSchema { - Undefined, - V1, -} - -impl Default for EthereumStorageSchema { - fn default() -> Self { - Self::Undefined - } -} - /// A type alias for the balance type from this pallet's point of view. +pub type BalanceOf = ::Balance; type EtpInstance = hyperspace_balances::Instance0; pub struct IntermediateStateRoot; @@ -105,6 +89,8 @@ pub trait Config: type StateRoot: Get; /// The block gas limit. Can be a simple constant, or an adjustment algorithm in another pallet. type BlockGasLimit: Get; + // How evm address convert to hyperspace address + type AddressMapping: AddressMapping; // Balance module type EtpCurrency: Currency; } @@ -125,10 +111,7 @@ decl_storage! { } add_extra_genesis { build(|_config: &GenesisConfig| { - >::store_block(false); - - // Initialize the storage schema at the well known key. - frame_support::storage::unhashed::put::(&PALLET_ETHEREUM_SCHEMA, &EthereumStorageSchema::V1); + >::store_block(); }); } } @@ -146,8 +129,6 @@ decl_error! { pub enum Error for Module { /// Signature is invalid. InvalidSignature, - /// Pre-log is present, therefore transact is not allowed. - PreLogExists, } } @@ -162,11 +143,6 @@ decl_module! { fn transact(origin, transaction: ethereum::Transaction) -> DispatchResultWithPostInfo { ensure_none(origin)?; - ensure!( - dp_consensus::find_pre_log(&frame_system::Module::::digest()).is_err(), - Error::::PreLogExists, - ); - let source = Self::recover_signer(&transaction) .ok_or_else(|| Error::::InvalidSignature)?; @@ -244,20 +220,11 @@ decl_module! { } fn on_finalize(_block_number: T::BlockNumber) { - >::store_block( - dp_consensus::find_pre_log(&frame_system::Module::::digest()).is_err(), - ); + >::store_block(); } fn on_initialize(_block_number: T::BlockNumber) -> Weight { Pending::kill(); - if let Ok(log) = dp_consensus::find_pre_log(&frame_system::Module::::digest()) { - let PreLog::Block(block) = log; - - for transaction in block.transactions { - let _ = Call::::transact(transaction).dispatch_bypass_filter(RawOrigin::None.into()); - } - } 0 } } @@ -297,12 +264,7 @@ impl frame_support::unsigned::ValidateUnsigned for Module { } let fee = transaction.gas_price.saturating_mul(transaction.gas_limit); - let total_payment = transaction.value.saturating_add(fee); - if account_data.balance < total_payment { - return InvalidTransaction::Payment.into(); - } - - if transaction.gas_price < T::FeeCalculator::min_gas_price() { + if account_data.balance < fee { return InvalidTransaction::Payment.into(); } @@ -337,7 +299,7 @@ impl Module { ))) } - fn store_block(post_log: bool) { + fn store_block() { let mut transactions = Vec::new(); let mut statuses = Vec::new(); let mut receipts = Vec::new(); @@ -378,17 +340,26 @@ impl Module { let mut block = ethereum::Block::new(partial_header, transactions.clone(), ommers); block.header.state_root = T::StateRoot::get(); + let mut transaction_hashes = Vec::new(); + + for t in &transactions { + let transaction_hash = H256::from_slice(Keccak256::digest(&rlp::encode(t)).as_slice()); + transaction_hashes.push(transaction_hash); + } + CurrentBlock::put(block.clone()); CurrentReceipts::put(receipts.clone()); CurrentTransactionStatuses::put(statuses.clone()); - if post_log { - let digest = DigestItem::::Consensus( - FRONTIER_ENGINE_ID, - PostLog::Hashes(dp_consensus::Hashes::from_block(block)).encode(), - ); - frame_system::Module::::deposit_log(digest.into()); - } + let digest = DigestItem::::Consensus( + FRONTIER_ENGINE_ID, + ConsensusLog::EndBlock { + block_hash: block.header.hash(), + transaction_hashes, + } + .encode(), + ); + frame_system::Module::::deposit_log(digest.into()); } /// Get the remaining balance for evm address @@ -402,14 +373,14 @@ impl Module { } /// Inc remaining balance - pub fn inc_remaining_balance(account_id: &T::AccountId, value: T::Balance) { + pub fn inc_remain_balance(account_id: &T::AccountId, value: T::Balance) { let remain_balance = Self::remaining_balance(account_id); let updated_balance = remain_balance.saturating_add(value); >::insert(account_id, updated_balance); } /// Dec remaining balance - pub fn dec_remaining_balance(account_id: &T::AccountId, value: T::Balance) { + pub fn dec_remain_balance(account_id: &T::AccountId, value: T::Balance) { let remain_balance = Self::remaining_balance(account_id); let updated_balance = remain_balance.saturating_sub(value); >::insert(account_id, updated_balance); diff --git a/frame/dvm/src/mock.rs b/frame/dvm/src/mock.rs index 59b9e86..7e8c766 100644 --- a/frame/dvm/src/mock.rs +++ b/frame/dvm/src/mock.rs @@ -138,7 +138,7 @@ impl FindAuthor for EthereumFindAuthor { parameter_types! { pub const TransactionByteFee: u64 = 1; - pub const ChainId: u64 = 42; + pub const ChainId: u64 = 22; pub const EVMModuleId: ModuleId = ModuleId(*b"py/evmpa"); } @@ -176,6 +176,7 @@ impl Config for Test { type FindAuthor = EthereumFindAuthor; type StateRoot = IntermediateStateRoot; type BlockGasLimit = BlockGasLimit; + type AddressMapping = HashedAddressMapping; type EtpCurrency = Etp; } diff --git a/frame/elections-phragmen/Cargo.toml b/frame/elections-phragmen/Cargo.toml index 9d084f8..236873a 100644 --- a/frame/elections-phragmen/Cargo.toml +++ b/frame/elections-phragmen/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0" name = "hyperspace-elections-phragmen" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" +version = "1.4.0" [dependencies] # crates @@ -16,11 +16,11 @@ serde = { version = "1.0.124", optional = true } # hyperspace hyperspace-support = { default-features = false, path = "../support" } # substrate -frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-npos-elections = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-npos-elections = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } [dev-dependencies] # crates @@ -29,9 +29,9 @@ hex-literal = { version = "0.3.1" } hyperspace-balances = { path = "../balances" } hyperspace-support = { path = "../support", features = ["easy-testing"] } # substrate -sp-core = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-io = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -substrate-test-utils = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-core = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-io = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +substrate-test-utils = { git = "https://github.com/new-mvs/substrate", branch = "latest" } [features] default = ["std"] diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index fe2ce46..9f152cf 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -106,7 +106,7 @@ use hyperspace_support::balance::lock::*; pub mod weights; pub use weights::WeightInfo; -pub mod migrations_2_0_0; +pub mod migrations_3_0_0; /// The maximum votes allowed per voter. pub const MAXIMUM_VOTE: usize = 16; diff --git a/frame/elections-phragmen/src/migrations_2_0_0.rs b/frame/elections-phragmen/src/migrations_2_0_0.rs deleted file mode 100644 index 1101b82..0000000 --- a/frame/elections-phragmen/src/migrations_2_0_0.rs +++ /dev/null @@ -1,191 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) 2019-2020 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -//! Migrations to version [`3.0.0`], as denoted by the changelog. - -use codec::{Decode, Encode, FullCodec}; -use frame_support::{ - storage::types::{StorageMap, StorageValue}, - traits::{GetPalletVersion, PalletVersion}, - weights::Weight, - RuntimeDebug, Twox64Concat, -}; -use sp_std::prelude::*; - -#[derive(Encode, Decode, Clone, Default, RuntimeDebug, PartialEq)] -struct SeatHolder { - who: AccountId, - stake: Balance, - deposit: Balance, -} - -#[derive(Encode, Decode, Clone, Default, RuntimeDebug, PartialEq)] -struct Voter { - votes: Vec, - stake: Balance, - deposit: Balance, -} - -/// Trait to implement to give information about types used for migration -pub trait ToV2 { - /// elections-phragmen module, used to check storage version. - type Module: GetPalletVersion; - - /// System config account id - type AccountId: 'static + FullCodec; - - /// Elections-phragmen currency balance. - type Balance: 'static + FullCodec + Copy; -} - -struct __Candidates; -impl frame_support::traits::StorageInstance for __Candidates { - fn pallet_prefix() -> &'static str { - "HyperspacePhragmenElection" - } - const STORAGE_PREFIX: &'static str = "Candidates"; -} - -#[allow(type_alias_bounds)] -type Candidates = StorageValue<__Candidates, Vec<(T::AccountId, T::Balance)>>; - -struct __Members; -impl frame_support::traits::StorageInstance for __Members { - fn pallet_prefix() -> &'static str { - "HyperspacePhragmenElection" - } - const STORAGE_PREFIX: &'static str = "Members"; -} -#[allow(type_alias_bounds)] -type Members = StorageValue<__Members, Vec>>; - -struct __RunnersUp; -impl frame_support::traits::StorageInstance for __RunnersUp { - fn pallet_prefix() -> &'static str { - "HyperspacePhragmenElection" - } - const STORAGE_PREFIX: &'static str = "RunnersUp"; -} -#[allow(type_alias_bounds)] -type RunnersUp = StorageValue<__RunnersUp, Vec>>; - -struct __Voting; -impl frame_support::traits::StorageInstance for __Voting { - fn pallet_prefix() -> &'static str { - "HyperspacePhragmenElection" - } - const STORAGE_PREFIX: &'static str = "Voting"; -} -#[allow(type_alias_bounds)] -type Voting = - StorageMap<__Voting, Twox64Concat, T::AccountId, Voter>; - -/// Apply all of the migrations 2_0_0. -/// -/// ### Warning -/// -/// This code will **ONLY** check that the storage version is less than 2_0_0 or `None`. -/// Further check might be needed at the user runtime. -/// -/// Be aware that this migration is intended to be used only for the mentioned versions. Use -/// with care and run at your own risk. -pub fn apply(old_voter_bond: T::Balance, old_candidacy_bond: T::Balance) -> Weight { - let maybe_storage_version = ::storage_version(); - - frame_support::debug::info!( - "Running migration for elections-phragmen with storage version {:?}", - maybe_storage_version - ); - - if let Some(storage_version) = maybe_storage_version { - if storage_version >= PalletVersion::new(2, 0, 0) { - frame_support::debug::info!("Skipped"); - - return 0; - } - } - - migrate_voters_to_recorded_deposit::(old_voter_bond); - migrate_candidates_to_recorded_deposit::(old_candidacy_bond); - migrate_runners_up_to_recorded_deposit::(old_candidacy_bond); - migrate_members_to_recorded_deposit::(old_candidacy_bond); - Weight::max_value() -} - -/// Migrate from the old legacy voting bond (fixed) to the new one (per-vote dynamic). -pub fn migrate_voters_to_recorded_deposit(old_deposit: T::Balance) { - >::translate::<(T::Balance, Vec), _>(|_who, (stake, votes)| { - Some(Voter { - votes, - stake, - deposit: old_deposit, - }) - }); - - frame_support::debug::info!("migrated {} voter accounts.", >::iter().count(),); -} - -/// Migrate all candidates to recorded deposit. -pub fn migrate_candidates_to_recorded_deposit(old_deposit: T::Balance) { - let _ = >::translate::, _>(|maybe_old_candidates| { - maybe_old_candidates.map(|old_candidates| { - frame_support::debug::info!("migrated {} candidate accounts.", old_candidates.len()); - old_candidates - .into_iter() - .map(|c| (c, old_deposit)) - .collect::>() - }) - }); -} - -/// Migrate all members to recorded deposit. -pub fn migrate_members_to_recorded_deposit(old_deposit: T::Balance) { - let _ = >::translate::, _>(|maybe_old_members| { - maybe_old_members.map(|old_members| { - frame_support::debug::info!("migrated {} member accounts.", old_members.len()); - old_members - .into_iter() - .map(|(who, stake)| SeatHolder { - who, - stake, - deposit: old_deposit, - }) - .collect::>() - }) - }); -} - -/// Migrate all runners-up to recorded deposit. -pub fn migrate_runners_up_to_recorded_deposit(old_deposit: T::Balance) { - let _ = - >::translate::, _>(|maybe_old_runners_up| { - maybe_old_runners_up.map(|old_runners_up| { - frame_support::debug::info!( - "migrated {} runner-up accounts.", - old_runners_up.len() - ); - old_runners_up - .into_iter() - .map(|(who, stake)| SeatHolder { - who, - stake, - deposit: old_deposit, - }) - .collect::>() - }) - }); -} diff --git a/frame/evm/Cargo.toml b/frame/evm/Cargo.toml index f3337c9..af0ab48 100644 --- a/frame/evm/Cargo.toml +++ b/frame/evm/Cargo.toml @@ -7,29 +7,29 @@ license = "GPL-3.0" name = "hyperspace-evm" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" +version = "1.4.0" [dependencies] # crates codec = { package = "parity-scale-codec", version = "1.3.7", default-features = false } -evm = { version = "0.23.0", default-features = false, features = ["with-codec"] } -evm-gasometer = { version = "0.23.0", default-features = false } -evm-runtime = { version = "0.23.0", default-features = false } +evm = { version = "0.22.0", default-features = false, features = ["with-codec"] } +evm-gasometer = { version = "0.22.0", default-features = false } +evm-runtime = { version = "0.22.0", default-features = false } primitive-types = { version = "0.8.0", default-features = false, features = ["rlp", "byteorder"] } rlp = { version = "0.5.0", default-features = false } serde = { version = "1.0.124", optional = true, default-features = false, features = ["derive"] } sha3 = { version = "0.8", default-features = false } # hyperspace -hyperspace-balances = { default-features = false, path = "../balances" } -dp-evm = { default-features = false, path = "../../primitives/evm" } +hyperspace-balances = { default-features = false, path = "../balances" } +hyperspace-evm-primitives = { default-features = false, path = "../../primitives/evm" } # substrate -frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -pallet-timestamp = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +pallet-timestamp = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } [dev-dependencies] hyperspace-support = { features = ["easy-testing"], path = "../support" } @@ -49,7 +49,7 @@ crates-std = [ ] hyperspace-std = [ "hyperspace-balances/std", - "dp-evm/std", + "hyperspace-evm-primitives/std", ] substrate-std = [ "evm/std", diff --git a/frame/evm/precompile/Cargo.toml b/frame/evm/precompile/Cargo.toml index 290d6f4..c194685 100644 --- a/frame/evm/precompile/Cargo.toml +++ b/frame/evm/precompile/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0" name = "hyperspace-evm-precompile" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" +version = "1.4.0" [dependencies] # hyperspace diff --git a/frame/evm/precompile/contracts/blake2/Cargo.toml b/frame/evm/precompile/contracts/blake2/Cargo.toml index 1cbebbf..d9b80ed 100644 --- a/frame/evm/precompile/contracts/blake2/Cargo.toml +++ b/frame/evm/precompile/contracts/blake2/Cargo.toml @@ -7,16 +7,16 @@ license = "GPL-3.0" name = "hyperspace-evm-precompile-blake2" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" +version = "1.4.0" [dependencies] # crates -evm = { default-features = false, version = "0.23.0", features = ["with-codec"] } -dp-evm = { default-features = false, path = "../../../../../primitives/evm" } +hyperspace-evm-primitives = { default-features = false, path = "../../../../../primitives/evm" } +evm = { version = "0.22.0", default-features = false, features = ["with-codec"] } # substrate -sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } [features] default = ["std"] @@ -28,7 +28,7 @@ std = [ crates-std = [ "evm/std", - "dp-evm/std", + "hyperspace-evm-primitives/std", ] substrate-std = [ diff --git a/frame/evm/precompile/contracts/blake2/src/lib.rs b/frame/evm/precompile/contracts/blake2/src/lib.rs index d828d7d..6f88d32 100644 --- a/frame/evm/precompile/contracts/blake2/src/lib.rs +++ b/frame/evm/precompile/contracts/blake2/src/lib.rs @@ -23,7 +23,7 @@ mod eip_152; use alloc::vec::Vec; use core::mem::size_of; -use dp_evm::LinearCostPrecompile; +use hyperspace_evm_primitives::LinearCostPrecompile; use evm::{ExitError, ExitSucceed}; pub struct Blake2F; diff --git a/frame/evm/precompile/contracts/bn128/Cargo.toml b/frame/evm/precompile/contracts/bn128/Cargo.toml index d1eb3a7..15e3b48 100644 --- a/frame/evm/precompile/contracts/bn128/Cargo.toml +++ b/frame/evm/precompile/contracts/bn128/Cargo.toml @@ -7,17 +7,17 @@ license = "GPL-3.0" name = "hyperspace-evm-precompile-bn128" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" +version = "1.4.0" [dependencies] # crates -bn = { default-features = false, package = "substrate-bn", version = "0.5" } -dp-evm = { default-features = false, path = "../../../../../primitives/evm" } -evm = { default-features = false, version = "0.23.0", features = ["with-codec"] } +bn = { package = "substrate-bn", version = "0.5", default-features = false } +hyperspace-evm-primitives = { default-features = false, path = "../../../../../primitives/evm" } +evm = { version = "0.22.0", default-features = false, features = ["with-codec"] } # substrate -sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } [features] default = ["std"] @@ -28,7 +28,7 @@ std = [ ] crates-std = [ - "dp-evm/std", + "hyperspace-evm-primitives/std", "evm/std", ] diff --git a/frame/evm/precompile/contracts/bn128/src/lib.rs b/frame/evm/precompile/contracts/bn128/src/lib.rs index d63e32a..267a4a3 100644 --- a/frame/evm/precompile/contracts/bn128/src/lib.rs +++ b/frame/evm/precompile/contracts/bn128/src/lib.rs @@ -20,7 +20,7 @@ extern crate alloc; use alloc::vec::Vec; -use dp_evm::LinearCostPrecompile; +use hyperspace_evm_primitives::LinearCostPrecompile; use evm::{ExitError, ExitSucceed}; use sp_core::U256; diff --git a/frame/evm/precompile/contracts/dispatch/Cargo.toml b/frame/evm/precompile/contracts/dispatch/Cargo.toml index dd54171..e807bc4 100644 --- a/frame/evm/precompile/contracts/dispatch/Cargo.toml +++ b/frame/evm/precompile/contracts/dispatch/Cargo.toml @@ -7,19 +7,19 @@ license = "GPL-3.0" name = "hyperspace-evm-precompile-dispatch" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" +version = "1.4.0" [dependencies] # crates -codec = { default-features = false, package = "parity-scale-codec", version = "1.3.7" } -hyperspace-evm = { default-features = false, path = "../../../../evm" } -dp-evm = { default-features = false, path = "../../../../../primitives/evm" } -evm = { default-features = false, version = "0.23.0", features = ["with-codec"] } +codec = { package = "parity-scale-codec", version = "1.3.7", default-features = false } +hyperspace-evm = { default-features = false, path = "../../../../evm" } +hyperspace-evm-primitives = { default-features = false, path = "../../../../../primitives/evm" } +evm = { version = "0.22.0", features = ["with-codec"], default-features = false } # substrate -frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } [features] default = ["std"] @@ -32,7 +32,7 @@ std = [ crates-std = [ "codec/std", "hyperspace-evm/std", - "dp-evm/std", + "hyperspace-evm-primitives/std", "evm/std", ] diff --git a/frame/evm/precompile/contracts/dispatch/src/lib.rs b/frame/evm/precompile/contracts/dispatch/src/lib.rs index 7d686ed..654353f 100644 --- a/frame/evm/precompile/contracts/dispatch/src/lib.rs +++ b/frame/evm/precompile/contracts/dispatch/src/lib.rs @@ -23,7 +23,7 @@ use alloc::vec::Vec; use codec::Decode; use core::marker::PhantomData; use hyperspace_evm::{AddressMapping, GasWeightMapping}; -use dp_evm::Precompile; +use hyperspace_evm_primitives::Precompile; use evm::{Context, ExitError, ExitSucceed}; use frame_support::{ dispatch::{Dispatchable, GetDispatchInfo, PostDispatchInfo}, diff --git a/frame/evm/precompile/contracts/dna/Cargo.toml b/frame/evm/precompile/contracts/dna/Cargo.toml index e05eb62..4bbf7c6 100644 --- a/frame/evm/precompile/contracts/dna/Cargo.toml +++ b/frame/evm/precompile/contracts/dna/Cargo.toml @@ -7,29 +7,28 @@ license = "GPL-3.0" name = "hyperspace-evm-precompile-dna" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" +version = "1.4.0" [dependencies] # crates -array-bytes = { version = "1.1.0" } -codec = { default-features = false, package = "parity-scale-codec", version = "1.3.7" } +codec = { package = "parity-scale-codec", version = "1.3.7", default-features = false } +hyperspace-evm-primitives = { default-features = false, path = "../../../../../primitives/evm" } ethabi = { default-features = false, git = "https://github.com/new-mvs/ethabi.git", branch = "with_no_std" } ethereum-types = { default-features = false, git = "https://github.com/new-mvs/parity-common.git" } -evm = { version = "0.23.0", default-features = false, features = ["with-codec"] } -hex = { version = "0.4", default-features = false } +evm = { version = "0.22.0", default-features = false, features = ["with-codec"] } ripemd160 = { version = "0.9", default-features = false } sha3 = { version = "0.8", default-features = false } +array-bytes = { version = "1.1.0" } # hyperspace hyperspace-evm = { default-features = false, path = "../../../" } -dp-evm = { default-features = false, path = "../../../../../primitives/evm" } # substrate -frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -pallet-timestamp = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +pallet-timestamp = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } [features] default = ["std"] @@ -42,7 +41,7 @@ std = [ crates-std = [ "codec/std", - "dp-evm/std", + "hyperspace-evm-primitives/std", "ethabi/std", "ethereum-types/std", "evm/std", diff --git a/frame/evm/precompile/contracts/dna/src/lib.rs b/frame/evm/precompile/contracts/dna/src/lib.rs index 861e8df..2f71e32 100644 --- a/frame/evm/precompile/contracts/dna/src/lib.rs +++ b/frame/evm/precompile/contracts/dna/src/lib.rs @@ -37,7 +37,7 @@ use sp_std::prelude::*; use sp_std::vec::Vec; use hyperspace_evm::{AddressMapping, Config, Runner}; -use dp_evm::Precompile; +use hyperspace_evm_primitives::Precompile; type AccountId = ::AccountId; diff --git a/frame/evm/precompile/contracts/ed25519/Cargo.toml b/frame/evm/precompile/contracts/ed25519/Cargo.toml index 0992f44..bd134db 100644 --- a/frame/evm/precompile/contracts/ed25519/Cargo.toml +++ b/frame/evm/precompile/contracts/ed25519/Cargo.toml @@ -7,16 +7,16 @@ license = "GPL-3.0" name = "hyperspace-evm-precompile-ed25519" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" +version = "1.4.0" [dependencies] # crates -dp-evm = { default-features = false, path = "../../../../../primitives/evm" } -ed25519-dalek = { default-features = false, version = "1.0.0", features = ["alloc", "u64_backend"] } -evm = { default-features = false, version = "0.23.0", features = ["with-codec"] } +hyperspace-evm-primitives = { default-features = false, path = "../../../../../primitives/evm" } +ed25519-dalek = { version = "1.0.0", default-features = false, features = ["alloc", "u64_backend"] } +evm = { version = "0.22.0", default-features = false, features = ["with-codec"] } # substrate -sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } [features] default = ["std"] @@ -27,7 +27,7 @@ std = [ ] crates-std = [ - "dp-evm/std", + "hyperspace-evm-primitives/std", "ed25519-dalek/std", "evm/std", ] diff --git a/frame/evm/precompile/contracts/ed25519/src/lib.rs b/frame/evm/precompile/contracts/ed25519/src/lib.rs index aae19e7..6d17df1 100644 --- a/frame/evm/precompile/contracts/ed25519/src/lib.rs +++ b/frame/evm/precompile/contracts/ed25519/src/lib.rs @@ -21,7 +21,7 @@ extern crate alloc; use alloc::vec::Vec; use core::convert::TryFrom; -use dp_evm::LinearCostPrecompile; +use hyperspace_evm_primitives::LinearCostPrecompile; use ed25519_dalek::{PublicKey, Signature, Verifier}; use evm::{ExitError, ExitSucceed}; diff --git a/frame/evm/precompile/contracts/empty/Cargo.toml b/frame/evm/precompile/contracts/empty/Cargo.toml index ddb2696..809adaa 100644 --- a/frame/evm/precompile/contracts/empty/Cargo.toml +++ b/frame/evm/precompile/contracts/empty/Cargo.toml @@ -7,12 +7,12 @@ license = "GPL-3.0" name = "hyperspace-evm-precompile-empty" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" +version = "1.4.0" [dependencies] # crates -dp-evm = { default-features = false, path = "../../../../../primitives/evm" } -evm = { default-features = false, version = "0.23.0", features = ["with-codec"] } +hyperspace-evm-primitives = { default-features = false, path = "../../../../../primitives/evm" } +evm = { version = "0.22.0", default-features = false, features = ["with-codec"] } [features] default = ["std"] @@ -22,6 +22,6 @@ std = [ ] crates-std = [ - "dp-evm/std", + "hyperspace-evm-primitives/std", "evm/std", ] diff --git a/frame/evm/precompile/contracts/empty/src/lib.rs b/frame/evm/precompile/contracts/empty/src/lib.rs index c594fde..6f45126 100644 --- a/frame/evm/precompile/contracts/empty/src/lib.rs +++ b/frame/evm/precompile/contracts/empty/src/lib.rs @@ -20,7 +20,7 @@ extern crate alloc; use alloc::vec::Vec; -use dp_evm::LinearCostPrecompile; +use hyperspace_evm_primitives::LinearCostPrecompile; use evm::{ExitError, ExitSucceed}; /// The empty precompile. diff --git a/frame/evm/precompile/contracts/modexp/Cargo.toml b/frame/evm/precompile/contracts/modexp/Cargo.toml index d7be154..9561b1e 100644 --- a/frame/evm/precompile/contracts/modexp/Cargo.toml +++ b/frame/evm/precompile/contracts/modexp/Cargo.toml @@ -7,17 +7,17 @@ license = "GPL-3.0" name = "hyperspace-evm-precompile-modexp" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" +version = "1.4.0" [dependencies] # crates -dp-evm = { default-features = false, path = "../../../../../primitives/evm" } -evm = { default-features = false, version = "0.23.0", features = ["with-codec"] } -num = { default-features = false, version = "0.3", features = ["alloc"] } +hyperspace-evm-primitives = { default-features = false, path = "../../../../../primitives/evm" } +evm = { version = "0.22.0", default-features = false, features = ["with-codec"] } +num = { version = "0.3", default-features = false, features = ["alloc"] } # substrate -sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } [dev-dependencies] hex = "0.4.0" @@ -31,7 +31,7 @@ std = [ ] crates-std = [ - "dp-evm/std", + "hyperspace-evm-primitives/std", "evm/std", "num/std", ] diff --git a/frame/evm/precompile/contracts/modexp/src/lib.rs b/frame/evm/precompile/contracts/modexp/src/lib.rs index 2f68ae4..d3e9da1 100644 --- a/frame/evm/precompile/contracts/modexp/src/lib.rs +++ b/frame/evm/precompile/contracts/modexp/src/lib.rs @@ -20,7 +20,7 @@ extern crate alloc; use alloc::vec::Vec; -use dp_evm::LinearCostPrecompile; +use hyperspace_evm_primitives::LinearCostPrecompile; use evm::{ExitError, ExitSucceed}; use num::{BigUint, FromPrimitive, One, ToPrimitive, Zero}; diff --git a/frame/evm/precompile/contracts/simple/Cargo.toml b/frame/evm/precompile/contracts/simple/Cargo.toml index 752e07e..c59aa89 100644 --- a/frame/evm/precompile/contracts/simple/Cargo.toml +++ b/frame/evm/precompile/contracts/simple/Cargo.toml @@ -7,16 +7,16 @@ license = "GPL-3.0" name = "hyperspace-evm-precompile-simple" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" +version = "1.4.0" [dependencies] # crates -dp-evm = { default-features = false, path = "../../../../../primitives/evm" } -evm = { default-features = false, version = "0.23.0", features = ["with-codec"] } -ripemd160 = { default-features = false, version = "0.9" } +hyperspace-evm-primitives = { default-features = false, path = "../../../../../primitives/evm" } +evm = { version = "0.22.0", default-features = false, features = ["with-codec"] } +ripemd160 = { version = "0.9", default-features = false } # substrate -sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } [features] default = ["std"] @@ -27,7 +27,7 @@ std = [ ] crates-std = [ - "dp-evm/std", + "hyperspace-evm-primitives/std", "evm/std", "ripemd160/std", ] diff --git a/frame/evm/precompile/contracts/simple/src/lib.rs b/frame/evm/precompile/contracts/simple/src/lib.rs index 02b94df..9b5dc99 100644 --- a/frame/evm/precompile/contracts/simple/src/lib.rs +++ b/frame/evm/precompile/contracts/simple/src/lib.rs @@ -21,7 +21,7 @@ extern crate alloc; use alloc::vec::Vec; use core::cmp::min; -use dp_evm::LinearCostPrecompile; +use hyperspace_evm_primitives::LinearCostPrecompile; use evm::{ExitError, ExitSucceed}; /// The identity precompile. diff --git a/frame/evm/precompile/contracts/withdraw/Cargo.toml b/frame/evm/precompile/contracts/withdraw/Cargo.toml index 1622e46..8f9f61a 100644 --- a/frame/evm/precompile/contracts/withdraw/Cargo.toml +++ b/frame/evm/precompile/contracts/withdraw/Cargo.toml @@ -7,24 +7,24 @@ license = "GPL-3.0" name = "hyperspace-evm-precompile-withdraw" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" +version = "1.4.0" [dependencies] # crates -codec = { default-features = false, package = "parity-scale-codec", version = "1.3.7" } -evm = { default-features = false, version = "0.23.0", features = ["with-codec"] } -ripemd160 = { default-features = false, version = "0.9" } +codec = { package = "parity-scale-codec", version = "1.3.7", default-features = false } +hyperspace-evm-primitives = { default-features = false, path = "../../../../../primitives/evm" } +evm = { version = "0.22.0", default-features = false, features = ["with-codec"] } +ripemd160 = { version = "0.9", default-features = false } # hyperspace hyperspace-evm = { default-features = false, path = "../../../" } -dp-evm = { default-features = false, path = "../../../../../primitives/evm" } # substrate -frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -pallet-timestamp = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +pallet-timestamp = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } [features] default = ["std"] @@ -37,13 +37,13 @@ std = [ crates-std = [ "codec/std", + "hyperspace-evm-primitives/std", "evm/std", "ripemd160/std", ] hyperspace-std = [ "hyperspace-evm/std", - "dp-evm/std", ] substrate-std = [ diff --git a/frame/evm/precompile/contracts/withdraw/src/lib.rs b/frame/evm/precompile/contracts/withdraw/src/lib.rs index e96ff5a..93f3ca0 100644 --- a/frame/evm/precompile/contracts/withdraw/src/lib.rs +++ b/frame/evm/precompile/contracts/withdraw/src/lib.rs @@ -27,7 +27,7 @@ use sp_std::vec::Vec; use codec::Decode; use hyperspace_evm::{AddressMapping, Config}; -use dp_evm::Precompile; +use hyperspace_evm_primitives::Precompile; use evm::{Context, ExitError, ExitSucceed}; type AccountId = ::AccountId; diff --git a/frame/evm/src/lib.rs b/frame/evm/src/lib.rs index fb81de0..a83999e 100644 --- a/frame/evm/src/lib.rs +++ b/frame/evm/src/lib.rs @@ -24,32 +24,28 @@ pub mod runner; mod tests; pub use crate::runner::Runner; -// --- hyperspace --- -pub use dp_evm::{ +pub use hyperspace_evm_primitives::{ Account, CallInfo, CreateInfo, ExecutionInfo, LinearCostPrecompile, Log, Precompile, PrecompileSet, Vicinity, }; -// --- substrate --- -use frame_support::{ - decl_error, decl_event, decl_module, decl_storage, - dispatch::DispatchResultWithPostInfo, - traits::{Currency, Get}, - weights::{Pays, PostDispatchInfo, Weight}, -}; +pub use evm::{ExitError, ExitFatal, ExitReason, ExitRevert, ExitSucceed}; + +#[cfg(feature = "std")] +use codec::{Decode, Encode}; +use evm::Config as EvmConfig; +use frame_support::dispatch::DispatchResultWithPostInfo; +use frame_support::traits::{Currency, Get}; +use frame_support::weights::{Pays, PostDispatchInfo, Weight}; +use frame_support::{decl_error, decl_event, decl_module, decl_storage}; use frame_system::RawOrigin; +#[cfg(feature = "std")] +use serde::{Deserialize, Serialize}; use sp_core::{Hasher, H160, H256, U256}; use sp_runtime::{ traits::{BadOrigin, UniqueSaturatedInto}, AccountId32, }; use sp_std::vec::Vec; -// --- std --- -#[cfg(feature = "std")] -use codec::{Decode, Encode}; -use evm::Config as EvmConfig; -pub use evm::{ExitError, ExitFatal, ExitReason, ExitRevert, ExitSucceed}; -#[cfg(feature = "std")] -use serde::{Deserialize, Serialize}; /// Type alias for currency balance. pub type BalanceOf = @@ -307,9 +303,9 @@ pub struct GenesisAccount { } decl_storage! { - trait Store for Module as EVM { - pub AccountCodes get(fn account_codes): map hasher(blake2_128_concat) H160 => Vec; - pub AccountStorages get(fn account_storages): + trait Store for Module as HyperspaceEVM { + AccountCodes get(fn account_codes): map hasher(blake2_128_concat) H160 => Vec; + AccountStorages get(fn account_storages): double_map hasher(blake2_128_concat) H160, hasher(blake2_128_concat) H256 => H256; } @@ -513,29 +509,10 @@ decl_module! { impl Module { fn remove_account(address: &H160) { - if AccountCodes::contains_key(address) { - let account_id = T::AddressMapping::into_account_id(*address); - let _ = frame_system::Module::::dec_consumers(&account_id); - } - AccountCodes::remove(address); AccountStorages::remove_prefix(address); } - /// Create an account. - pub fn create_account(address: H160, code: Vec) { - if code.is_empty() { - return; - } - - if !AccountCodes::contains_key(&address) { - let account_id = T::AddressMapping::into_account_id(address); - let _ = frame_system::Module::::inc_consumers(&account_id); - } - - AccountCodes::insert(address, code); - } - /// Check whether an account is empty. pub fn is_account_empty(address: &H160) -> bool { let account = T::AccountBasicMapping::account_basic(address); diff --git a/frame/evm/src/runner/mod.rs b/frame/evm/src/runner/mod.rs index b475b66..8956cfb 100644 --- a/frame/evm/src/runner/mod.rs +++ b/frame/evm/src/runner/mod.rs @@ -18,7 +18,7 @@ pub mod stack; use crate::Config; -use dp_evm::{CallInfo, CreateInfo}; +use hyperspace_evm_primitives::{CallInfo, CreateInfo}; use sp_core::{H160, H256, U256}; use sp_std::vec::Vec; diff --git a/frame/evm/src/runner/stack.rs b/frame/evm/src/runner/stack.rs index 1924cdc..07142dc 100644 --- a/frame/evm/src/runner/stack.rs +++ b/frame/evm/src/runner/stack.rs @@ -22,23 +22,19 @@ use crate::{ AccountBasicMapping, AccountCodes, AccountStorages, AddressMapping, Config, Error, Event, FeeCalculator, Module, PrecompileSet, }; - -// --- hyperspace --- -use dp_evm::{Account, CallInfo, CreateInfo, ExecutionInfo, Log, Vicinity}; -// --- substrate --- +use hyperspace_evm_primitives::{Account, CallInfo, CreateInfo, ExecutionInfo, Log, Vicinity}; +use evm::backend::Backend as BackendT; +use evm::executor::{StackExecutor, StackState as StackStateT, StackSubstateMetadata}; +use evm::{ExitError, ExitReason, Transfer}; use frame_support::{ debug, ensure, storage::{StorageDoubleMap, StorageMap}, traits::Get, }; +use sha3::{Digest, Keccak256}; use sp_core::{H160, H256, U256}; use sp_runtime::traits::UniqueSaturatedInto; use sp_std::{boxed::Box, collections::btree_set::BTreeSet, marker::PhantomData, mem, vec::Vec}; -// --- std --- -use evm::backend::Backend as BackendT; -use evm::executor::{StackExecutor, StackState as StackStateT, StackSubstateMetadata}; -use evm::{ExitError, ExitReason, Transfer}; -use sha3::{Digest, Keccak256}; #[derive(Default)] pub struct Runner { @@ -95,11 +91,12 @@ impl Runner { Error::::BalanceLow ); + Module::::withdraw_fee(&source, total_fee); + if let Some(nonce) = nonce { ensure!(source_account.nonce == nonce, Error::::InvalidNonce); } - Module::::withdraw_fee(&source, total_fee); let (reason, retv) = f(&mut executor); let used_gas = U256::from(executor.used_gas()); @@ -494,16 +491,22 @@ impl<'vicinity, 'config, T: Config> StackStateT<'config> code.len(), address ); - Module::::create_account(address, code); + AccountCodes::insert(address, code); } fn transfer(&mut self, transfer: Transfer) -> Result<(), ExitError> { + //EVM double transfer issue let source_account = T::AccountBasicMapping::account_basic(&transfer.source); + + //let target_account = T::AccountBasicMapping::account_basic(&transfer.target); + ensure!( source_account.balance >= transfer.value, ExitError::Other("Insufficient balance".into()) ); let new_source_balance = source_account.balance.saturating_sub(transfer.value); + //let new_target_balance = target_account.balance.saturating_add(transfer.value); + T::AccountBasicMapping::mutate_account_basic( &transfer.source, Account { @@ -511,9 +514,10 @@ impl<'vicinity, 'config, T: Config> StackStateT<'config> balance: new_source_balance, }, ); - + let target_account = T::AccountBasicMapping::account_basic(&transfer.target); let new_target_balance = target_account.balance.saturating_add(transfer.value); + T::AccountBasicMapping::mutate_account_basic( &transfer.target, Account { diff --git a/frame/header-mmr/Cargo.toml b/frame/header-mmr/Cargo.toml index 890c4de..4afd870 100644 --- a/frame/header-mmr/Cargo.toml +++ b/frame/header-mmr/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0" name = "hyperspace-header-mmr" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" +version = "1.4.0" [dependencies] # crates @@ -20,18 +20,20 @@ hyperspace-support = { default-features = false, path = "../s # github merkle-mountain-range = { package = "ckb-merkle-mountain-range", default-features = false, git = "https://github.com/new-mvs/merkle-mountain-range.git" } # substrate -frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } [dev-dependencies] # crates array-bytes = { version = "1.1.0" } -serde_json = { version = "1.0.62" } +serde_json = { version = "1.0.62" } + + # substrate -sp-core = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-io = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-core = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-io = { git = "https://github.com/new-mvs/substrate", branch = "latest" } [features] default = ["std"] diff --git a/frame/header-mmr/rpc/Cargo.toml b/frame/header-mmr/rpc/Cargo.toml index cdb98c0..43fed95 100644 --- a/frame/header-mmr/rpc/Cargo.toml +++ b/frame/header-mmr/rpc/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0" name = "hyperspace-header-mmr-rpc" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" +version = "1.4.0" [dependencies] # crates @@ -18,6 +18,6 @@ jsonrpc-derive = { version = "15.1.0" } # hyperspace hyperspace-header-mmr-rpc-runtime-api = { path = "./runtime-api" } # substrate -sp-api = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-blockchain = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-runtime = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-api = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-blockchain = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-runtime = { git = "https://github.com/new-mvs/substrate", branch = "latest" } diff --git a/frame/header-mmr/rpc/runtime-api/Cargo.toml b/frame/header-mmr/rpc/runtime-api/Cargo.toml index 72505d8..0664cd9 100644 --- a/frame/header-mmr/rpc/runtime-api/Cargo.toml +++ b/frame/header-mmr/rpc/runtime-api/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0" name = "hyperspace-header-mmr-rpc-runtime-api" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" +version = "1.4.0" [dependencies] # crates @@ -16,9 +16,9 @@ serde = { version = "1.0.124", optional = true, features = ["derive"] } # hyperspace hyperspace-support = { default-features = false, path = "../../../support" } # substrate -sp-api = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-api = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } [features] default = ["std"] diff --git a/frame/header-mmr/src/lib.rs b/frame/header-mmr/src/lib.rs index 57263c8..0f1e72f 100644 --- a/frame/header-mmr/src/lib.rs +++ b/frame/header-mmr/src/lib.rs @@ -37,16 +37,16 @@ //! //! ### Digest Item //! The is a ```MerkleMountainRangeRoot(Hash)``` digest item pre-subscribed in Digest. -//! This is implemented in Hyperspace's fork of substrate: https://github.com/hyperspace-network/substrate -//! The Pull request link is https://github.com/hyperspace-network/substrate/pull/1 +//! This is implemented in Hyperspace's fork of substrate: https://github.com/new-mvs/substrate +//! The Pull request link is https://github.com/new-mvs/substrate/pull/1 //! //! ## Implementation //! We are using the MMR library from https://github.com/nervosnetwork/merkle-mountain-range -//! Pull request: https://github.com/hyperspace-network/hyperspace/pull/358 +//! Pull request: https://github.com/new-mvs/hyperspace/pull/358 //! //! ## References //! Hyperspace Relay's Technical Paper: -//! https://github.com/hyperspace-network/rfcs/blob/master/paper/Hyperspace_Relay_Sublinear_Optimistic_Relay_for_Interoperable_Blockchains_v0.7.pdf +//! https://github.com/new-mvs/rfcs/blob/master/paper/Hyperspace_Relay_Sublinear_Optimistic_Relay_for_Interoperable_Blockchains_v0.7.pdf //! //! https://github.com/mimblewimble/grin/blob/master/doc/mmr.md#structure //! https://github.com/mimblewimble/grin/blob/0ff6763ee64e5a14e70ddd4642b99789a1648a32/core/src/core/pmmr.rs#L606 diff --git a/frame/header-mmr/src/tests.rs b/frame/header-mmr/src/tests.rs index 43725fc..afe5a50 100644 --- a/frame/header-mmr/src/tests.rs +++ b/frame/header-mmr/src/tests.rs @@ -25,6 +25,7 @@ use frame_support::traits::OnFinalize; use sp_runtime::testing::{Digest, H256}; // --- hyperspace --- use crate::{mock::*, *}; + use merkle_mountain_range::{leaf_index_to_pos, Merge}; #[test] diff --git a/frame/staking/Cargo.toml b/frame/staking/Cargo.toml index faad038..cde7c03 100644 --- a/frame/staking/Cargo.toml +++ b/frame/staking/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0" name = "hyperspace-staking" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" +version = "1.4.0" [dependencies] # crates @@ -21,17 +21,17 @@ hyperspace-support = { default-features = false, path = "../supp # github substrate-fixed = { default-features = false, git = "https://github.com/encointer/substrate-fixed", branch = "master" } # substrate -frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -pallet-authorship = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -pallet-session = { default-features = false, features = ["historical"], git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-arithmetic = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-npos-elections = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-staking = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +pallet-authorship = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +pallet-session = { default-features = false, features = ["historical"], git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-arithmetic = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-npos-elections = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-staking = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } [dev-dependencies] # crates @@ -40,10 +40,10 @@ rand_chacha = { version = "0.2" } hyperspace-balances = { path = "../../frame/balances" } hyperspace-support = { features = ["easy-testing"], path = "../support" } # substrate -pallet-timestamp = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-storage = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-tracing = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -substrate-test-utils = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +pallet-timestamp = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-storage = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-tracing = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +substrate-test-utils = { git = "https://github.com/new-mvs/substrate", branch = "latest" } [features] default = ["std"] diff --git a/frame/staking/rpc/Cargo.toml b/frame/staking/rpc/Cargo.toml index 489e080..efe1268 100644 --- a/frame/staking/rpc/Cargo.toml +++ b/frame/staking/rpc/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0" name = "hyperspace-staking-rpc" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" +version = "1.4.0" [dependencies] # crates @@ -18,6 +18,6 @@ jsonrpc-derive = { version = "15.1.0" } # hyperspace hyperspace-staking-rpc-runtime-api = { path = "./runtime-api" } # substrate -sp-api = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-blockchain = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-runtime = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-api = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-blockchain = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-runtime = { git = "https://github.com/new-mvs/substrate", branch = "latest" } diff --git a/frame/staking/rpc/runtime-api/Cargo.toml b/frame/staking/rpc/runtime-api/Cargo.toml index c963e60..5137a62 100644 --- a/frame/staking/rpc/runtime-api/Cargo.toml +++ b/frame/staking/rpc/runtime-api/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0" name = "hyperspace-staking-rpc-runtime-api" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" +version = "1.4.0" [dependencies] # crates @@ -16,8 +16,8 @@ serde = { version = "1.0.124", optional = true, features = ["derive"] } # hyperspace hyperspace-support = { default-features = false, path = "../../../support" } # substrate -sp-api = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-api = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } [features] default = ["std"] diff --git a/frame/staking/src/lib.rs b/frame/staking/src/lib.rs index e9bc2b5..531e983 100644 --- a/frame/staking/src/lib.rs +++ b/frame/staking/src/lib.rs @@ -269,7 +269,7 @@ #![feature(drain_filter)] #![recursion_limit = "128"] -// TODO: offchain phragmen test https://github.com/mvs-org/Hyperspaceissues/97 +// TODO: offchain phragmen test https://github.com/new-mvs/darwinia-common/issues/97 // #[cfg(features = "testing-utils")] // pub mod testing_utils; #[cfg(test)] @@ -1040,7 +1040,7 @@ decl_module! { fn on_runtime_upgrade() -> frame_support::weights::Weight { if StorageVersion::get() == Releases::V4_0_0 || !StorageVersion::exists() { log!(info, "Migrating Staking..."); - + StorageVersion::put(Releases::V5_0_0); migrations::migrate_to_blockable::() } else { @@ -1527,8 +1527,8 @@ decl_module! { Self::update_ledger(&controller, &mut ledger); - // TODO: https://github.com/mvs-org/Hyperspaceissues/96 - // FIXME: https://github.com/mvs-org/Hyperspaceissues/121 + // TODO: https://github.com/new-mvs/darwinia-common/issues/96 + // FIXME: https://github.com/new-mvs/darwinia-common/issues/121 // let StakingLedger { // active_etp, // active_dna, @@ -3084,14 +3084,14 @@ impl Module { } /// Compute payout for era. - #[allow(dead_code)] + #[allow(unused_variables, unused_mut)] fn end_era(active_era: ActiveEraInfo, _session_index: SessionIndex) { + // Temporary Disable era reward payout // Note: active_era_start can be None if end era is called during genesis config. - // Temporary Disable era reward - if let Some(active_era_start) = active_era.start { - let now = T::UnixTime::now().as_millis().saturated_into::(); - let living_time = Self::living_time(); - let era_duration = now - active_era_start; + //if let Some(active_era_start) = active_era.start { + //let now = T::UnixTime::now().as_millis().saturated_into::(); + //let living_time = Self::living_time(); + //let era_duration = now - active_era_start; //let (validator_payout, max_payout) = inflation::compute_total_payout::( // era_duration, @@ -3107,12 +3107,13 @@ impl Module { // rest, //)); - LivingTime::put(living_time + era_duration); + //LivingTime::put(living_time + era_duration); // Set ending era reward. + //>::insert(&active_era.index, validator_payout); //T::EtpCurrency::deposit_creating(&Self::account_id(), validator_payout); //T::EtpRewardRemainder::on_unbalanced(T::EtpCurrency::issue(rest)); - } + //} } /// Plan a new era. Return the potential new staking set. diff --git a/frame/staking/src/substrate_tests.rs b/frame/staking/src/substrate_tests.rs index 258f10f..ff91bb2 100644 --- a/frame/staking/src/substrate_tests.rs +++ b/frame/staking/src/substrate_tests.rs @@ -2125,7 +2125,7 @@ fn bond_with_no_staked_value() { Origin::signed(2), StakingBalance::EtpBalance(1) )); - // FIXME: https://github.com/mvs-org/Hyperspaceissues/121 + // FIXME: https://github.com/new-mvs/darwinia-common/issues/121 // assert!(Staking::ledger(2).is_none()); }); } diff --git a/frame/support/Cargo.toml b/frame/support/Cargo.toml index e5896d9..c9825e8 100644 --- a/frame/support/Cargo.toml +++ b/frame/support/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0" name = "hyperspace-support" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" +version = "1.4.0" [dependencies] # crates @@ -17,9 +17,9 @@ num-traits = { version = "0.2.14", default-features = false } # hyperspace ethereum-primitives = { default-features = false, path = "../../primitives/ethereum-primitives" } # substrate -frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } [features] diff --git a/frame/treasury/Cargo.toml b/frame/treasury/Cargo.toml index 456c21d..a398080 100644 --- a/frame/treasury/Cargo.toml +++ b/frame/treasury/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0" name = "hyperspace-treasury" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" +version = "1.4.0" [dependencies] # crates @@ -16,18 +16,18 @@ serde = { version = "1.0.124", optional = true, features = ["derive"] } # hyperspace hyperspace-support = { default-features = false, path = "../support" } # substrate -frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } [dev-dependencies] # hyperspace hyperspace-balances = { path = "../balances" } # substrate -sp-core = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-io = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-storage = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-core = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-io = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-storage = { git = "https://github.com/new-mvs/substrate", branch = "latest" } [features] default = ["std"] diff --git a/frame/vesting/Cargo.toml b/frame/vesting/Cargo.toml index f18969a..1b58dbb 100644 --- a/frame/vesting/Cargo.toml +++ b/frame/vesting/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0" name = "hyperspace-vesting" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" +version = "1.4.0" [dependencies] # crates @@ -15,10 +15,10 @@ codec = { package = "parity-scale-codec", version = "1.3.7", default-featur enumflags2 = { version = "0.6.2" } serde = { version = "1.0.124", optional = true } # substrate -frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +frame-system = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } # hyperspace hyperspace-support = { default-features = false, path = "../support" } @@ -26,9 +26,9 @@ hyperspace-support = { default-features = false, path = "../support" } # crates hex-literal = "0.3.1" # substrate -sp-core = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-io = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-storage = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-core = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-io = { git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-storage = { git = "https://github.com/new-mvs/substrate", branch = "latest" } # hyperspace hyperspace-balances = { path = "../balances" } diff --git a/primitives/consensus/Cargo.toml b/primitives/consensus/Cargo.toml index 93d2431..082ac38 100644 --- a/primitives/consensus/Cargo.toml +++ b/primitives/consensus/Cargo.toml @@ -4,35 +4,28 @@ description = "Primitives for DVM consensus" edition = "2018" homepage = "https://substrate.dev" license = "Apache-2.0" -name = "dp_consensus" +name = "dvm-consensus-primitives" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" +version = "1.4.0" [dependencies] # crates -codec = { default-features = false, package = "parity-scale-codec", version = "1.3.7", features = ["derive"] } -ethereum = { default-features = false, version = "0.6.0", features = ["with-codec"] } -rlp = { default-features = false, version = "0.5" } -sha3 = { default-features = false, version = "0.8" } +codec = { package = "parity-scale-codec", version = "1.3.7", default-features = false, features = ["derive"] } # substrate -sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } [features] default = ["std"] std = [ "crates-std", - "ethereum/std", - "rlp/std", - "sha3/std", "substrate-std", ] crates-std = ["codec/std"] - substrate-std = [ "sp-std/std", "sp-runtime/std", diff --git a/primitives/consensus/src/lib.rs b/primitives/consensus/src/lib.rs index bba6e19..6166185 100644 --- a/primitives/consensus/src/lib.rs +++ b/primitives/consensus/src/lib.rs @@ -18,152 +18,19 @@ #![cfg_attr(not(feature = "std"), no_std)] use codec::{Decode, Encode}; -use sha3::{Digest as Sha3Digest, Keccak256}; use sp_core::H256; -use sp_runtime::{ - generic::{Digest, OpaqueDigestItemId}, - ConsensusEngineId, -}; +use sp_runtime::ConsensusEngineId; use sp_std::vec::Vec; pub const FRONTIER_ENGINE_ID: ConsensusEngineId = [b'f', b'r', b'o', b'n']; -#[derive(Clone, PartialEq, Eq)] -pub enum Log { - Pre(PreLog), - Post(PostLog), -} - -impl Log { - pub fn into_hashes(self) -> Hashes { - match self { - Log::Post(PostLog::Hashes(post_hashes)) => post_hashes, - Log::Post(PostLog::Block(block)) => Hashes::from_block(block), - Log::Pre(PreLog::Block(block)) => Hashes::from_block(block), - } - } -} - #[derive(Decode, Encode, Clone, PartialEq, Eq)] -pub enum PreLog { - #[codec(index = "3")] - Block(ethereum::Block), -} - -#[derive(Decode, Encode, Clone, PartialEq, Eq)] -pub enum PostLog { +pub enum ConsensusLog { #[codec(index = "1")] - Hashes(Hashes), - #[codec(index = "2")] - Block(ethereum::Block), -} - -#[derive(Decode, Encode, Clone, PartialEq, Eq)] -pub struct Hashes { - /// Ethereum block hash. - pub block_hash: H256, - /// Transaction hashes of the Ethereum block. - pub transaction_hashes: Vec, -} - -impl Hashes { - pub fn from_block(block: ethereum::Block) -> Self { - let mut transaction_hashes = Vec::new(); - - for t in &block.transactions { - let transaction_hash = H256::from_slice(Keccak256::digest(&rlp::encode(t)).as_slice()); - transaction_hashes.push(transaction_hash); - } - - let block_hash = block.header.hash(); - - Hashes { - transaction_hashes, - block_hash, - } - } -} - -#[derive(Clone, Debug)] -pub enum FindLogError { - NotFound, - MultipleLogs, -} - -pub fn find_pre_log(digest: &Digest) -> Result { - let mut found = None; - - for log in digest.logs() { - let log = log.try_to::(OpaqueDigestItemId::PreRuntime(&FRONTIER_ENGINE_ID)); - match (log, found.is_some()) { - (Some(_), true) => return Err(FindLogError::MultipleLogs), - (Some(log), false) => found = Some(log), - (None, _) => (), - } - } - - found.ok_or(FindLogError::NotFound) -} - -pub fn find_post_log(digest: &Digest) -> Result { - let mut found = None; - - for log in digest.logs() { - let log = log.try_to::(OpaqueDigestItemId::Consensus(&FRONTIER_ENGINE_ID)); - match (log, found.is_some()) { - (Some(_), true) => return Err(FindLogError::MultipleLogs), - (Some(log), false) => found = Some(log), - (None, _) => (), - } - } - - found.ok_or(FindLogError::NotFound) -} - -pub fn find_log(digest: &Digest) -> Result { - let mut found = None; - - for log in digest.logs() { - let pre_log = log.try_to::(OpaqueDigestItemId::PreRuntime(&FRONTIER_ENGINE_ID)); - match (pre_log, found.is_some()) { - (Some(_), true) => return Err(FindLogError::MultipleLogs), - (Some(pre_log), false) => found = Some(Log::Pre(pre_log)), - (None, _) => (), - } - - let post_log = log.try_to::(OpaqueDigestItemId::Consensus(&FRONTIER_ENGINE_ID)); - match (post_log, found.is_some()) { - (Some(_), true) => return Err(FindLogError::MultipleLogs), - (Some(post_log), false) => found = Some(Log::Post(post_log)), - (None, _) => (), - } - } - - found.ok_or(FindLogError::NotFound) -} - -pub fn ensure_log(digest: &Digest) -> Result<(), FindLogError> { - let mut found = false; - - for log in digest.logs() { - let pre_log = log.try_to::(OpaqueDigestItemId::PreRuntime(&FRONTIER_ENGINE_ID)); - match (pre_log, found) { - (Some(_), true) => return Err(FindLogError::MultipleLogs), - (Some(_), false) => found = true, - (None, _) => (), - } - - let post_log = log.try_to::(OpaqueDigestItemId::Consensus(&FRONTIER_ENGINE_ID)); - match (post_log, found) { - (Some(_), true) => return Err(FindLogError::MultipleLogs), - (Some(_), false) => found = true, - (None, _) => (), - } - } - - if found { - Ok(()) - } else { - Err(FindLogError::NotFound) - } + EndBlock { + /// Ethereum block hash. + block_hash: H256, + /// Transaction hashes of the Ethereum block. + transaction_hashes: Vec, + }, } diff --git a/primitives/ethereum-primitives/Cargo.toml b/primitives/ethereum-primitives/Cargo.toml index 7af225d..55fb2c3 100644 --- a/primitives/ethereum-primitives/Cargo.toml +++ b/primitives/ethereum-primitives/Cargo.toml @@ -7,14 +7,14 @@ license = "GPL-3.0" name = "ethereum-primitives" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" +version = "1.4.0" [dependencies] # crates array-bytes = { version = "1.1.0" } -codec = { package = "parity-scale-codec", version = "1.3.7", default-features = false, features = ["derive"] } -ethash = { default-features = false, git = "https://github.com/new-mvs/ethash", branch = "v1" } -serde = { version = "1.0.124", optional = true, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "1.3.7", default-features = false, features = ["derive"] } +ethash = { default-features = false, git = "https://github.com/new-mvs/rust-ethash" } +serde = { version = "1.0.124", optional = true, features = ["derive"] } # hyperspace merkle-patricia-trie = { default-features = false, path = "../merkle-patricia-trie" } # github @@ -28,9 +28,9 @@ primitive-types = { default-features = false, features = ["codec", "rlp"], git = rlp = { default-features = false, git = "https://github.com/new-mvs/parity-common.git" } rlp-derive = { git = "https://github.com/new-mvs/parity-common.git" } # substrate -sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-io = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } [dev-dependencies] # crates @@ -39,7 +39,7 @@ serde_json = { version = "1.0.62" } # github triehash = { git = "https://github.com/new-mvs/parity-common.git" } # substrate -frame-support = { git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +frame-support = { git = "https://github.com/new-mvs/substrate", branch = "latest" } [features] default = ["std"] diff --git a/primitives/ethereum-primitives/src/ethashproof.rs b/primitives/ethereum-primitives/src/ethashproof.rs index e1e9ccf..718ae1f 100644 --- a/primitives/ethereum-primitives/src/ethashproof.rs +++ b/primitives/ethereum-primitives/src/ethashproof.rs @@ -16,6 +16,7 @@ // You should have received a copy of the GNU General Public License // along with Hyperspace. If not, see . + use codec::{Decode, Encode}; pub use ethereum_types::{H128, H512}; use sp_io::hashing::sha2_256; diff --git a/primitives/ethereum-primitives/src/header.rs b/primitives/ethereum-primitives/src/header.rs index 6e41780..5b874b7 100644 --- a/primitives/ethereum-primitives/src/header.rs +++ b/primitives/ethereum-primitives/src/header.rs @@ -30,6 +30,9 @@ use sp_std::prelude::*; // --- hyperspace --- use crate::*; + + + #[derive(Clone, Copy, PartialEq, Eq, Encode, Decode, RuntimeDebug)] enum Seal { /// The seal/signature is included. @@ -93,6 +96,8 @@ impl EthereumHeader { pub fn from_str_unchecked(s: &str) -> Self { // --- std --- use std::str::FromStr; + + fn parse_value_unchecked(s: &str) -> &str { s.splitn(2, ':') @@ -147,8 +152,7 @@ impl EthereumHeader { let s = if s.starts_with("0x") { &s[2..] } else { s }; eth_header.log_bloom = Bloom::from_str(s).unwrap_or_default(); } else if s.starts_with("\"miner") { - eth_header.author = - array_bytes::hex2array_unchecked!(parse_value_unchecked(s), 20).into(); + eth_header.author = array_bytes::hex2array_unchecked!(parse_value_unchecked(s), 20).into(); } else if s.starts_with("\"mixHash") { mix_hash = array_bytes::hex2array_unchecked!(parse_value_unchecked(s), 32).into(); } else if s.starts_with("\"nonce") { @@ -551,6 +555,7 @@ mod tests { use std::str::FromStr; // --- hyperspace --- use super::*; + use error::EthereumError; use pow::EthashPartial; diff --git a/primitives/ethereum-primitives/src/receipt.rs b/primitives/ethereum-primitives/src/receipt.rs index 72b20bf..6ef5059 100644 --- a/primitives/ethereum-primitives/src/receipt.rs +++ b/primitives/ethereum-primitives/src/receipt.rs @@ -176,6 +176,7 @@ mod tests { use keccak_hasher::KeccakHasher; // --- hyperspace --- use super::*; + #[inline] fn construct_receipts( diff --git a/primitives/evm/Cargo.toml b/primitives/evm/Cargo.toml index c8131ba..93537fd 100644 --- a/primitives/evm/Cargo.toml +++ b/primitives/evm/Cargo.toml @@ -4,20 +4,20 @@ description = "Primitives for Hyperspace EVM" edition = "2018" homepage = "https://substrate.dev" license = "Apache-2.0" -name = "dp-evm" +name = "hyperspace-evm-primitives" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" +version = "1.4.0" [dependencies] # crates codec = { package = "parity-scale-codec", version = "1.3.7", default-features = false } -evm = { version = "0.23.0", default-features = false, features = ["with-codec"] } +evm = { version = "0.22.0", default-features = false, features = ["with-codec"] } impl-trait-for-tuples = { version = "0.2.0" } serde = { version = "1.0.124", optional = true, features = ["derive"] } # substrate -sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-core = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } [features] default = ["std"] diff --git a/primitives/merkle-patricia-trie/Cargo.toml b/primitives/merkle-patricia-trie/Cargo.toml index aaddd66..892ab17 100644 --- a/primitives/merkle-patricia-trie/Cargo.toml +++ b/primitives/merkle-patricia-trie/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0" name = "merkle-patricia-trie" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" +version = "1.4.0" [[bench]] harness = false @@ -15,13 +15,13 @@ name = "trie" [dependencies] # crates -array-bytes = { version = "1.1.0" } -hashbrown = { version = "0.9.1" } +hashbrown = { version = "0.9.1" } +array-bytes = { version = "1.1.0" } # github hash = { package = "keccak-hash", default-features = false, git = "https://github.com/new-mvs/parity-common.git" } rlp = { default-features = false, git = "https://github.com/new-mvs/parity-common.git" } # substrate -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } [dev-dependencies] # crates diff --git a/primitives/merkle-patricia-trie/src/tests.rs b/primitives/merkle-patricia-trie/src/tests.rs index e53bd6e..2bfd662 100644 --- a/primitives/merkle-patricia-trie/src/tests.rs +++ b/primitives/merkle-patricia-trie/src/tests.rs @@ -685,10 +685,9 @@ mod trie_tests { fn test_ethereum_receipts_proof() { let rlp_proof: Vec = array_bytes::hex2bytes("f9016ef9016bb853f851a009b67a67265063da0dd6a7abad695edb2c439f6b458f2a2ee48a21442fef8a2680808080808080a0a7d4f8b974d21b7244014729b07e9c9f19fdc445da2ceddc089d90cead74be618080808080808080b90113f9011031b9010cf9010901835cdb6eb9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0").unwrap(); let expected: Vec = array_bytes::hex2bytes("f9010901835cdb6eb9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0").unwrap(); - let root = array_bytes::hex2bytes( - "7fa081e3e33e53c4d09ae691af3853bb73a7e02c856104fe843172abab85df7b", - ) - .unwrap(); + let root = + array_bytes::hex2bytes("7fa081e3e33e53c4d09ae691af3853bb73a7e02c856104fe843172abab85df7b") + .unwrap(); let proof: Proof = rlp::decode(&rlp_proof).unwrap(); let key = rlp::encode(&1usize); diff --git a/primitives/relay/Cargo.toml b/primitives/relay/Cargo.toml index 8c161aa..9224fad 100644 --- a/primitives/relay/Cargo.toml +++ b/primitives/relay/Cargo.toml @@ -7,15 +7,15 @@ license = "GPL-3.0" name = "hyperspace-relay-primitives" readme = "README.md" repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" +version = "1.4.0" [dependencies] # crates codec = { package = "parity-scale-codec", version = "1.3.7", default-features = false } # substrate -frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } -sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate.git", branch = "latest" } +frame-support = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-runtime = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } +sp-std = { default-features = false, git = "https://github.com/new-mvs/substrate", branch = "latest" } [features] default = ["std"] diff --git a/primitives/rpc/Cargo.toml b/primitives/rpc/Cargo.toml deleted file mode 100644 index 8bdfbcd..0000000 --- a/primitives/rpc/Cargo.toml +++ /dev/null @@ -1,21 +0,0 @@ -[package] -authors = ["Hyperspace Network "] -description = "RPC traits of Ethereum." -edition = "2018" -homepage = "https://mvs.org/" -license = "GPL-3.0" -name = "dp-rpc" -readme = "README.md" -repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" - -[dependencies] -# crates -ethereum-types = { version = "0.10.0" } -jsonrpc-core = { version = "15.1.0" } -jsonrpc-core-client = { version = "15.1.0" } -jsonrpc-derive = { version = "15.1.0" } -jsonrpc-pubsub = { version = "15.1.0" } -rustc-hex = { version = "2.1.0" } -serde = { version = "1.0", features = ["derive"] } -serde_json = { version = "1.0" } diff --git a/primitives/rpc/src/account_info.rs b/primitives/rpc/src/account_info.rs deleted file mode 100644 index 52dbb08..0000000 --- a/primitives/rpc/src/account_info.rs +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2015-2020 Parity Technologies (UK) Ltd. -// This file is part of Frontier. - -// Open Ethereum 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. - -// Open Ethereum 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 Open Ethereum. If not, see . - -//! Return types for RPC calls - -use crate::Bytes; -use ethereum_types::{Address, Public, H160, H256, U256}; -use serde::Serialize; - -/// Account information. -#[derive(Debug, Default, Clone, PartialEq, Serialize)] -pub struct AccountInfo { - /// Account name - pub name: String, -} - -/// Data structure with proof for one single storage-entry -#[derive(Debug, Default, Clone, PartialEq, Serialize)] -#[serde(rename_all = "camelCase")] -pub struct StorageProof { - pub key: U256, - pub value: U256, - pub proof: Vec, -} - -/// Account information. -#[derive(Debug, Default, Clone, PartialEq, Serialize)] -#[serde(rename_all = "camelCase")] -pub struct EthAccount { - pub address: H160, - pub balance: U256, - pub nonce: U256, - pub code_hash: H256, - pub storage_hash: H256, - pub account_proof: Vec, - pub storage_proof: Vec, -} - -/// Extended account information (used by `parity_allAccountInfo`). -#[derive(Debug, Default, Clone, PartialEq, Serialize)] -pub struct ExtAccountInfo { - /// Account name - pub name: String, - /// Account meta JSON - pub meta: String, - /// Account UUID (`None` for address book entries) - #[serde(skip_serializing_if = "Option::is_none")] - pub uuid: Option, -} - -/// account derived from a signature -/// as well as information that tells if it is valid for -/// the current chain -#[derive(Debug, Clone, Serialize)] -#[serde(rename_all = "camelCase")] -pub struct RecoveredAccount { - /// address of the recovered account - pub address: Address, - /// public key of the recovered account - pub public_key: Public, - /// If the signature contains chain replay protection, - /// And the chain_id encoded within the signature - /// matches the current chain this would be true, otherwise false. - pub is_valid_for_current_chain: bool, -} diff --git a/primitives/rpc/src/block.rs b/primitives/rpc/src/block.rs deleted file mode 100644 index f8445c2..0000000 --- a/primitives/rpc/src/block.rs +++ /dev/null @@ -1,177 +0,0 @@ -// Copyright 2015-2020 Parity Technologies (UK) Ltd. -// This file is part of Frontier. - -// Open Ethereum 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. - -// Open Ethereum 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 Open Ethereum. If not, see . - -use std::collections::BTreeMap; -use std::ops::Deref; - -use crate::{Bytes, Transaction}; -use ethereum_types::{Bloom as H2048, H160, H256, U256}; -use serde::ser::Error; -use serde::{Serialize, Serializer}; - -/// Block Transactions -#[derive(Debug)] -pub enum BlockTransactions { - /// Only hashes - Hashes(Vec), - /// Full transactions - Full(Vec), -} - -impl Serialize for BlockTransactions { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - match *self { - BlockTransactions::Hashes(ref hashes) => hashes.serialize(serializer), - BlockTransactions::Full(ref ts) => ts.serialize(serializer), - } - } -} - -/// Block representation -#[derive(Debug, Serialize)] -#[serde(rename_all = "camelCase")] -pub struct Block { - /// Hash of the block - pub hash: Option, - /// Hash of the parent - pub parent_hash: H256, - /// Hash of the uncles - #[serde(rename = "sha3Uncles")] - pub uncles_hash: H256, - /// Authors address - pub author: H160, - /// Alias of `author` - pub miner: H160, - /// State root hash - pub state_root: H256, - /// Transactions root hash - pub transactions_root: H256, - /// Transactions receipts root hash - pub receipts_root: H256, - /// Block number - pub number: Option, - /// Gas Used - pub gas_used: U256, - /// Gas Limit - pub gas_limit: U256, - /// Extra data - pub extra_data: Bytes, - /// Logs bloom - pub logs_bloom: Option, - /// Timestamp - pub timestamp: U256, - /// Difficulty - pub difficulty: U256, - /// Total difficulty - pub total_difficulty: U256, - /// Seal fields - pub seal_fields: Vec, - /// Uncles' hashes - pub uncles: Vec, - /// Transactions - pub transactions: BlockTransactions, - /// Size in bytes - pub size: Option, -} - -/// Block header representation. -#[derive(Debug, Clone, Serialize, PartialEq, Eq)] -#[serde(rename_all = "camelCase")] -pub struct Header { - /// Hash of the block - pub hash: Option, - /// Hash of the parent - pub parent_hash: H256, - /// Hash of the uncles - #[serde(rename = "sha3Uncles")] - pub uncles_hash: H256, - /// Authors address - pub author: H160, - /// Alias of `author` - pub miner: H160, - /// State root hash - pub state_root: H256, - /// Transactions root hash - pub transactions_root: H256, - /// Transactions receipts root hash - pub receipts_root: H256, - /// Block number - pub number: Option, - /// Gas Used - pub gas_used: U256, - /// Gas Limit - pub gas_limit: U256, - /// Extra data - pub extra_data: Bytes, - /// Logs bloom - pub logs_bloom: H2048, - /// Timestamp - pub timestamp: U256, - /// Difficulty - pub difficulty: U256, - /// Seal fields - pub seal_fields: Vec, - /// Size in bytes - pub size: Option, -} - -/// Block representation with additional info. -pub type RichBlock = Rich; - -/// Header representation with additional info. -pub type RichHeader = Rich

; - -/// Value representation with additional info -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct Rich { - /// Standard value. - pub inner: T, - /// Engine-specific fields with additional description. - /// Should be included directly to serialized block object. - // TODO [ToDr] #[serde(skip_serializing)] - pub extra_info: BTreeMap, -} - -impl Deref for Rich { - type Target = T; - fn deref(&self) -> &Self::Target { - &self.inner - } -} - -impl Serialize for Rich { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - use serde_json::{to_value, Value}; - - let serialized = (to_value(&self.inner), to_value(&self.extra_info)); - if let (Ok(Value::Object(mut value)), Ok(Value::Object(extras))) = serialized { - // join two objects - value.extend(extras); - // and serialize - value.serialize(serializer) - } else { - Err(S::Error::custom( - "Unserializable structures: expected objects", - )) - } - } -} diff --git a/primitives/rpc/src/block_number.rs b/primitives/rpc/src/block_number.rs deleted file mode 100644 index e0379b9..0000000 --- a/primitives/rpc/src/block_number.rs +++ /dev/null @@ -1,210 +0,0 @@ -// Copyright 2015-2020 Parity Technologies (UK) Ltd. -// This file is part of Frontier. - -// Open Ethereum 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. - -// Open Ethereum 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 Open Ethereum. If not, see . - -use ethereum_types::H256; -use serde::de::{Error, MapAccess, Visitor}; -use serde::{Deserialize, Deserializer, Serialize, Serializer}; -use std::fmt; - -/// Represents rpc api block number param. -#[derive(Debug, PartialEq, Clone, Hash, Eq)] -pub enum BlockNumber { - /// Hash - Hash { - /// block hash - hash: H256, - /// only return blocks part of the canon chain - require_canonical: bool, - }, - /// Number - Num(u64), - /// Latest block - Latest, - /// Earliest block (genesis) - Earliest, - /// Pending block (being mined) - Pending, -} - -impl Default for BlockNumber { - fn default() -> Self { - BlockNumber::Latest - } -} - -impl<'a> Deserialize<'a> for BlockNumber { - fn deserialize(deserializer: D) -> Result - where - D: Deserializer<'a>, - { - deserializer.deserialize_any(BlockNumberVisitor) - } -} - -impl BlockNumber { - /// Convert block number to min block target. - pub fn to_min_block_num(&self) -> Option { - match *self { - BlockNumber::Num(ref x) => Some(*x), - _ => None, - } - } -} - -impl Serialize for BlockNumber { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - match *self { - BlockNumber::Hash { - hash, - require_canonical, - } => serializer.serialize_str(&format!( - "{{ 'hash': '{}', 'requireCanonical': '{}' }}", - hash, require_canonical - )), - BlockNumber::Num(ref x) => serializer.serialize_str(&format!("0x{:x}", x)), - BlockNumber::Latest => serializer.serialize_str("latest"), - BlockNumber::Earliest => serializer.serialize_str("earliest"), - BlockNumber::Pending => serializer.serialize_str("pending"), - } - } -} - -struct BlockNumberVisitor; - -impl<'a> Visitor<'a> for BlockNumberVisitor { - type Value = BlockNumber; - - fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - write!( - formatter, - "a block number or 'latest', 'earliest' or 'pending'" - ) - } - - fn visit_map(self, mut visitor: V) -> Result - where - V: MapAccess<'a>, - { - let (mut require_canonical, mut block_number, mut block_hash) = - (false, None::, None::); - - loop { - let key_str: Option = visitor.next_key()?; - - match key_str { - Some(key) => match key.as_str() { - "blockNumber" => { - let value: String = visitor.next_value()?; - if value.starts_with("0x") { - let number = u64::from_str_radix(&value[2..], 16).map_err(|e| { - Error::custom(format!("Invalid block number: {}", e)) - })?; - - block_number = Some(number); - break; - } else { - return Err(Error::custom( - "Invalid block number: missing 0x prefix".to_string(), - )); - } - } - "blockHash" => { - block_hash = Some(visitor.next_value()?); - } - "requireCanonical" => { - require_canonical = visitor.next_value()?; - } - key => return Err(Error::custom(format!("Unknown key: {}", key))), - }, - None => break, - }; - } - - if let Some(number) = block_number { - return Ok(BlockNumber::Num(number)); - } - - if let Some(hash) = block_hash { - return Ok(BlockNumber::Hash { - hash, - require_canonical, - }); - } - - return Err(Error::custom("Invalid input")); - } - - fn visit_str(self, value: &str) -> Result - where - E: Error, - { - match value { - "latest" => Ok(BlockNumber::Latest), - "earliest" => Ok(BlockNumber::Earliest), - "pending" => Ok(BlockNumber::Pending), - _ if value.starts_with("0x") => u64::from_str_radix(&value[2..], 16) - .map(BlockNumber::Num) - .map_err(|e| Error::custom(format!("Invalid block number: {}", e))), - _ => u64::from_str_radix(&value, 10) - .map(BlockNumber::Num) - .map_err(|_| { - Error::custom( - "Invalid block number: non-decimal or missing 0x prefix".to_string(), - ) - }), - } - } - - fn visit_string(self, value: String) -> Result - where - E: Error, - { - self.visit_str(value.as_ref()) - } - - fn visit_u64(self, value: u64) -> Result - where - E: Error, - { - Ok(BlockNumber::Num(value)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - - fn match_block_number(block_number: BlockNumber) -> Option { - match block_number { - BlockNumber::Num(number) => Some(number), - _ => None, - } - } - - #[test] - fn block_number_deserialize() { - let bn_dec: BlockNumber = serde_json::from_str(r#""42""#).unwrap(); - let bn_hex: BlockNumber = serde_json::from_str(r#""0x45""#).unwrap(); - let bn_u64: BlockNumber = serde_json::from_str(r#"420"#).unwrap(); - - assert_eq!(match_block_number(bn_dec).unwrap(), 42 as u64); - assert_eq!(match_block_number(bn_hex).unwrap(), 69 as u64); - assert_eq!(match_block_number(bn_u64).unwrap(), 420 as u64); - } -} diff --git a/primitives/rpc/src/bytes.rs b/primitives/rpc/src/bytes.rs deleted file mode 100644 index 0a1cd34..0000000 --- a/primitives/rpc/src/bytes.rs +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright 2015-2020 Parity Technologies (UK) Ltd. -// This file is part of Frontier. - -// Open Ethereum 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. - -// Open Ethereum 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 Open Ethereum. If not, see . - -//! Serializable wrapper around vector of bytes - -use rustc_hex::{FromHex, ToHex}; -use serde::de::{Error, Visitor}; -use serde::{Deserialize, Deserializer, Serialize, Serializer}; -use std::fmt; - -/// Wrapper structure around vector of bytes. -#[derive(Debug, PartialEq, Eq, Default, Hash, Clone)] -pub struct Bytes(pub Vec); - -impl Bytes { - /// Simple constructor. - pub fn new(bytes: Vec) -> Bytes { - Bytes(bytes) - } - /// Convert back to vector - pub fn into_vec(self) -> Vec { - self.0 - } -} - -impl From> for Bytes { - fn from(bytes: Vec) -> Bytes { - Bytes(bytes) - } -} - -impl Into> for Bytes { - fn into(self) -> Vec { - self.0 - } -} - -impl Serialize for Bytes { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut serialized = "0x".to_owned(); - serialized.push_str(self.0.to_hex::().as_ref()); - serializer.serialize_str(serialized.as_ref()) - } -} - -impl<'a> Deserialize<'a> for Bytes { - fn deserialize(deserializer: D) -> Result - where - D: Deserializer<'a>, - { - deserializer.deserialize_any(BytesVisitor) - } -} - -struct BytesVisitor; - -impl<'a> Visitor<'a> for BytesVisitor { - type Value = Bytes; - - fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - write!(formatter, "a 0x-prefixed, hex-encoded vector of bytes") - } - - fn visit_str(self, value: &str) -> Result - where - E: Error, - { - if value.len() >= 2 && value.starts_with("0x") && value.len() & 1 == 0 { - Ok(Bytes::new(FromHex::from_hex(&value[2..]).map_err(|e| { - Error::custom(format!("Invalid hex: {}", e)) - })?)) - } else { - Err(Error::custom( - "Invalid bytes format. Expected a 0x-prefixed hex string with even length", - )) - } - } - - fn visit_string(self, value: String) -> Result - where - E: Error, - { - self.visit_str(value.as_ref()) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use rustc_hex::FromHex; - - #[test] - fn test_bytes_serialize() { - let bytes = Bytes("0123456789abcdef".from_hex().unwrap()); - let serialized = serde_json::to_string(&bytes).unwrap(); - assert_eq!(serialized, r#""0x0123456789abcdef""#); - } - - #[test] - fn test_bytes_deserialize() { - let bytes0: Result = serde_json::from_str(r#""∀∂""#); - let bytes1: Result = serde_json::from_str(r#""""#); - let bytes2: Result = serde_json::from_str(r#""0x123""#); - let bytes3: Result = serde_json::from_str(r#""0xgg""#); - - let bytes4: Bytes = serde_json::from_str(r#""0x""#).unwrap(); - let bytes5: Bytes = serde_json::from_str(r#""0x12""#).unwrap(); - let bytes6: Bytes = serde_json::from_str(r#""0x0123""#).unwrap(); - - assert!(bytes0.is_err()); - assert!(bytes1.is_err()); - assert!(bytes2.is_err()); - assert!(bytes3.is_err()); - assert_eq!(bytes4, Bytes(vec![])); - assert_eq!(bytes5, Bytes(vec![0x12])); - assert_eq!(bytes6, Bytes(vec![0x1, 0x23])); - } -} diff --git a/primitives/rpc/src/call_request.rs b/primitives/rpc/src/call_request.rs deleted file mode 100644 index 3dcd26f..0000000 --- a/primitives/rpc/src/call_request.rs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2015-2020 Parity Technologies (UK) Ltd. -// This file is part of Frontier. - -// Open Ethereum 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. - -// Open Ethereum 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 Open Ethereum. If not, see . - -use crate::Bytes; -use ethereum_types::{H160, U256}; -use serde::Deserialize; - -/// Call request -#[derive(Debug, Default, PartialEq, Deserialize, Clone)] -#[serde(deny_unknown_fields)] -#[serde(rename_all = "camelCase")] -pub struct CallRequest { - /// From - pub from: Option, - /// To - pub to: Option, - /// Gas Price - pub gas_price: Option, - /// Gas - pub gas: Option, - /// Value - pub value: Option, - /// Data - pub data: Option, - /// Nonce - pub nonce: Option, -} diff --git a/primitives/rpc/src/filter.rs b/primitives/rpc/src/filter.rs deleted file mode 100644 index 3814cdc..0000000 --- a/primitives/rpc/src/filter.rs +++ /dev/null @@ -1,348 +0,0 @@ -// Copyright 2015-2020 Parity Technologies (UK) Ltd. -// This file is part of Frontier. - -// Open Ethereum 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. - -// Open Ethereum 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 Open Ethereum. If not, see . - -use ethereum_types::{H160, H256, U256}; -use serde::de::{DeserializeOwned, Error}; -use serde::{Deserialize, Deserializer, Serialize, Serializer}; -use serde_json::{from_value, Value}; -use std::{ - collections::BTreeMap, - sync::{Arc, Mutex}, -}; - -use crate::{BlockNumber, Log}; - -/// Variadic value -#[derive(Debug, PartialEq, Eq, Clone, Hash)] -pub enum VariadicValue -where - T: DeserializeOwned, -{ - /// Single - Single(T), - /// List - Multiple(Vec), - /// None - Null, -} - -impl<'a, T> Deserialize<'a> for VariadicValue -where - T: DeserializeOwned, -{ - fn deserialize(deserializer: D) -> Result, D::Error> - where - D: Deserializer<'a>, - { - let v: Value = Deserialize::deserialize(deserializer)?; - - if v.is_null() { - return Ok(VariadicValue::Null); - } - - from_value(v.clone()) - .map(VariadicValue::Single) - .or_else(|_| from_value(v).map(VariadicValue::Multiple)) - .map_err(|err| D::Error::custom(format!("Invalid variadic value type: {}", err))) - } -} - -/// Filter Address -pub type FilterAddress = VariadicValue; -/// Topic, supports `A` | `null` | `[A,B,C]` | `[A,[B,C]]` | [null,[B,C]] | [null,[null,C]] -pub type Topic = VariadicValue>>>; -/// FlatTopic, simplifies the matching logic. -pub type FlatTopic = VariadicValue>; - -/// Filter -#[derive(Debug, PartialEq, Clone, Deserialize, Eq, Hash)] -#[serde(deny_unknown_fields)] -#[serde(rename_all = "camelCase")] -pub struct Filter { - /// From Block - pub from_block: Option, - /// To Block - pub to_block: Option, - /// Block hash - pub block_hash: Option, - /// Address - pub address: Option, - /// Topics - pub topics: Option, -} - -/// Helper for Filter matching. -/// Supports conditional indexed parameters and wildcards. -#[derive(Debug)] -pub struct FilteredParams { - pub filter: Option, - flat_topics: Vec, -} - -impl Default for FilteredParams { - fn default() -> Self { - FilteredParams { - filter: None, - flat_topics: Vec::new(), - } - } -} - -impl FilteredParams { - pub fn new(f: Option) -> Self { - if let Some(f) = f { - return FilteredParams { - filter: Some(f.clone()), - flat_topics: { - if let Some(t) = f.clone().topics { - Self::flatten(&t) - } else { - Vec::new() - } - }, - }; - } - Self::default() - } - /// Cartesian product for VariadicValue conditional indexed parameters. - /// Executed once on struct instance. - /// i.e. `[A,[B,C]]` to `[[A,B],[A,C]]`. - fn flatten(topic: &Topic) -> Vec { - fn cartesian(lists: &Vec>>) -> Vec>> { - let mut res = vec![]; - let mut list_iter = lists.iter(); - if let Some(first_list) = list_iter.next() { - for &i in first_list { - res.push(vec![i]); - } - } - for l in list_iter { - let mut tmp = vec![]; - for r in res { - for &el in l { - let mut tmp_el = r.clone(); - tmp_el.push(el); - tmp.push(tmp_el); - } - } - res = tmp; - } - res - } - let mut out: Vec = Vec::new(); - match topic { - VariadicValue::Multiple(multi) => { - let mut foo: Vec>> = Vec::new(); - for v in multi { - foo.push({ - if let Some(v) = v { - match v { - VariadicValue::Single(s) => vec![s.clone()], - VariadicValue::Multiple(s) => s.clone(), - VariadicValue::Null => vec![None], - } - } else { - vec![None] - } - }); - } - for permut in cartesian(&foo) { - out.push(FlatTopic::Multiple(permut)); - } - } - VariadicValue::Single(single) => { - if let Some(single) = single { - out.push(single.clone()); - } - } - VariadicValue::Null => { - out.push(FlatTopic::Null); - } - } - out - } - - /// Replace None values - aka wildcards - for the log input value in that position. - pub fn replace(&self, log: &Log, topic: FlatTopic) -> Option> { - let mut out: Vec = Vec::new(); - match topic { - VariadicValue::Single(value) => { - if let Some(value) = value { - out.push(value); - } - } - VariadicValue::Multiple(value) => { - for (k, v) in value.into_iter().enumerate() { - if let Some(v) = v { - out.push(v); - } else { - out.push(log.topics[k].clone()); - } - } - } - _ => {} - }; - if out.len() == 0 { - return None; - } - Some(out) - } - - pub fn filter_block_range(&self, block_number: u64) -> bool { - let mut out = true; - let filter = self.filter.clone().unwrap(); - if let Some(from) = filter.from_block { - match from { - BlockNumber::Num(_) => { - if from.to_min_block_num().unwrap_or(0 as u64) > block_number { - out = false; - } - } - _ => {} - } - } - if let Some(to) = filter.to_block { - match to { - BlockNumber::Num(_) => { - if to.to_min_block_num().unwrap_or(0 as u64) < block_number { - out = false; - } - } - BlockNumber::Earliest => { - out = false; - } - _ => {} - } - } - out - } - - pub fn filter_block_hash(&self, block_hash: H256) -> bool { - if let Some(h) = self.filter.clone().unwrap().block_hash { - if h != block_hash { - return false; - } - } - true - } - - pub fn filter_address(&self, log: &Log) -> bool { - if let Some(input_address) = &self.filter.clone().unwrap().address { - match input_address { - VariadicValue::Single(x) => { - if log.address != *x { - return false; - } - } - VariadicValue::Multiple(x) => { - if !x.contains(&log.address) { - return false; - } - } - _ => { - return true; - } - } - } - true - } - - pub fn filter_topics(&self, log: &Log) -> bool { - let mut out: bool = true; - for topic in self.flat_topics.clone() { - match topic { - VariadicValue::Single(single) => { - if let Some(single) = single { - if !log.topics.starts_with(&vec![single]) { - out = false; - } - } - } - VariadicValue::Multiple(multi) => { - // Shrink the topics until the last item is Some. - let mut new_multi = multi; - while new_multi - .iter() - .last() - .unwrap_or(&Some(H256::default())) - .is_none() - { - new_multi.pop(); - } - // We can discard right away any logs with lesser topics than the filter. - if new_multi.len() > log.topics.len() { - out = false; - break; - } - let replaced: Option> = - self.replace(log, VariadicValue::Multiple(new_multi)); - if let Some(replaced) = replaced { - out = false; - if log.topics.starts_with(&replaced[..]) { - out = true; - break; - } - } - } - _ => { - out = true; - } - } - } - out - } -} - -/// Results of the filter_changes RPC. -#[derive(Debug, PartialEq)] -pub enum FilterChanges { - /// New logs. - Logs(Vec), - /// New hashes (block or transactions) - Hashes(Vec), - /// Empty result, - Empty, -} - -impl Serialize for FilterChanges { - fn serialize(&self, s: S) -> Result - where - S: Serializer, - { - match *self { - FilterChanges::Logs(ref logs) => logs.serialize(s), - FilterChanges::Hashes(ref hashes) => hashes.serialize(s), - FilterChanges::Empty => (&[] as &[Value]).serialize(s), - } - } -} - -#[derive(Debug, Clone)] -pub enum FilterType { - Block, - PendingTransaction, - Log(Filter), -} - -#[derive(Debug, Clone)] -pub struct FilterPoolItem { - pub last_poll: BlockNumber, - pub filter_type: FilterType, - pub at_block: u64, -} - -/// On-memory stored filters created through the `eth_newFilter` RPC. -pub type FilterPool = Arc>>; diff --git a/primitives/rpc/src/index.rs b/primitives/rpc/src/index.rs deleted file mode 100644 index 65dd67d..0000000 --- a/primitives/rpc/src/index.rs +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright 2015-2020 Parity Technologies (UK) Ltd. -// This file is part of Frontier. - -// Open Ethereum 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. - -// Open Ethereum 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 Open Ethereum. If not, see . - -use serde::de::{Error, Visitor}; -use serde::{Deserialize, Deserializer}; -use std::fmt; - -/// Represents usize. -#[derive(Debug, PartialEq)] -pub struct Index(usize); - -impl Index { - /// Convert to usize - pub fn value(&self) -> usize { - self.0 - } -} - -impl<'a> Deserialize<'a> for Index { - fn deserialize(deserializer: D) -> Result - where - D: Deserializer<'a>, - { - deserializer.deserialize_any(IndexVisitor) - } -} - -struct IndexVisitor; - -impl<'a> Visitor<'a> for IndexVisitor { - type Value = Index; - - fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - write!(formatter, "a hex-encoded or decimal index") - } - - fn visit_str(self, value: &str) -> Result - where - E: Error, - { - match value { - _ if value.starts_with("0x") => usize::from_str_radix(&value[2..], 16) - .map(Index) - .map_err(|e| Error::custom(format!("Invalid index: {}", e))), - _ => value - .parse::() - .map(Index) - .map_err(|e| Error::custom(format!("Invalid index: {}", e))), - } - } - - fn visit_string(self, value: String) -> Result - where - E: Error, - { - self.visit_str(value.as_ref()) - } - - fn visit_u64(self, value: u64) -> Result - where - E: Error, - { - Ok(Index(value as usize)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use serde_json; - - #[test] - fn index_deserialization() { - let s = r#"["0xa", "10", 42]"#; - let deserialized: Vec = serde_json::from_str(s).unwrap(); - assert_eq!(deserialized, vec![Index(10), Index(10), Index(42)]); - } -} diff --git a/primitives/rpc/src/lib.rs b/primitives/rpc/src/lib.rs deleted file mode 100644 index ac7cca5..0000000 --- a/primitives/rpc/src/lib.rs +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2015-2020 Parity Technologies (UK) Ltd. -// This file is part of Frontier. - -// Open Ethereum 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. - -// Open Ethereum 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 Open Ethereum. If not, see . - -//! RPC types - -mod account_info; -mod block; -mod block_number; -mod bytes; -mod call_request; -mod filter; -mod index; -mod log; -mod receipt; -mod sync; -mod transaction; -mod transaction_request; -mod work; - -pub mod pubsub; - -pub use self::account_info::{ - AccountInfo, EthAccount, ExtAccountInfo, RecoveredAccount, StorageProof, -}; -pub use self::block::{Block, BlockTransactions, Header, Rich, RichBlock, RichHeader}; -pub use self::block_number::BlockNumber; -pub use self::bytes::Bytes; -pub use self::call_request::CallRequest; -pub use self::filter::{ - Filter, FilterAddress, FilterChanges, FilterPool, FilterPoolItem, FilterType, FilteredParams, - Topic, VariadicValue, -}; -pub use self::index::Index; -pub use self::log::Log; -pub use self::receipt::Receipt; -pub use self::sync::{ - ChainStatus, EthProtocolInfo, PeerInfo, PeerNetworkInfo, PeerProtocolsInfo, Peers, - PipProtocolInfo, SyncInfo, SyncStatus, TransactionStats, -}; -pub use self::transaction::{ - LocalTransactionStatus, PendingTransaction, PendingTransactions, RichRawTransaction, - Transaction, -}; -pub use self::transaction_request::TransactionRequest; -pub use self::work::Work; diff --git a/primitives/rpc/src/log.rs b/primitives/rpc/src/log.rs deleted file mode 100644 index 76017fd..0000000 --- a/primitives/rpc/src/log.rs +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2015-2020 Parity Technologies (UK) Ltd. -// This file is part of Frontier. - -// Open Ethereum 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. - -// Open Ethereum 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 Open Ethereum. If not, see . - -use crate::Bytes; -use ethereum_types::{H160, H256, U256}; -use serde::Serialize; - -/// Log -#[derive(Debug, Serialize, PartialEq, Eq, Hash, Clone)] -#[serde(rename_all = "camelCase")] -pub struct Log { - /// H160 - pub address: H160, - /// Topics - pub topics: Vec, - /// Data - pub data: Bytes, - /// Block Hash - pub block_hash: Option, - /// Block Number - pub block_number: Option, - /// Transaction Hash - pub transaction_hash: Option, - /// Transaction Index - pub transaction_index: Option, - /// Log Index in Block - pub log_index: Option, - /// Log Index in Transaction - pub transaction_log_index: Option, - /// Whether Log Type is Removed (Geth Compatibility Field) - #[serde(default)] - pub removed: bool, -} diff --git a/primitives/rpc/src/pubsub.rs b/primitives/rpc/src/pubsub.rs deleted file mode 100644 index edf2083..0000000 --- a/primitives/rpc/src/pubsub.rs +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright 2015-2020 Parity Technologies (UK) Ltd. -// This file is part of Frontier. - -// Open Ethereum 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. - -// Open Ethereum 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 Open Ethereum. If not, see . - -//! Pub-Sub types. - -use crate::{Filter, Log, RichHeader}; -use ethereum_types::H256; -use serde::de::Error; -use serde::{Deserialize, Deserializer, Serialize, Serializer}; -use serde_json::{from_value, Value}; - -/// Subscription result. -#[derive(Debug, Clone, PartialEq, Eq)] -pub enum Result { - /// New block header. - Header(Box), - /// Log - Log(Box), - /// Transaction hash - TransactionHash(H256), - /// SyncStatus - SyncState(PubSubSyncStatus), -} - -/// PubSbub sync status -#[derive(Debug, Serialize, Eq, PartialEq, Clone)] -#[serde(rename_all = "camelCase")] -pub struct PubSubSyncStatus { - /// is_major_syncing? - pub syncing: bool, -} - -impl Serialize for Result { - fn serialize(&self, serializer: S) -> ::std::result::Result - where - S: Serializer, - { - match *self { - Result::Header(ref header) => header.serialize(serializer), - Result::Log(ref log) => log.serialize(serializer), - Result::TransactionHash(ref hash) => hash.serialize(serializer), - Result::SyncState(ref sync) => sync.serialize(serializer), - } - } -} - -/// Subscription kind. -#[derive(Debug, Deserialize, PartialEq, Eq, Hash, Clone)] -#[serde(deny_unknown_fields)] -#[serde(rename_all = "camelCase")] -pub enum Kind { - /// New block headers subscription. - NewHeads, - /// Logs subscription. - Logs, - /// New Pending Transactions subscription. - NewPendingTransactions, - /// Node syncing status subscription. - Syncing, -} - -/// Subscription kind. -#[derive(Debug, PartialEq, Eq, Hash, Clone)] -pub enum Params { - /// No parameters passed. - None, - /// Log parameters. - Logs(Filter), -} - -impl Default for Params { - fn default() -> Self { - Params::None - } -} - -impl<'a> Deserialize<'a> for Params { - fn deserialize(deserializer: D) -> ::std::result::Result - where - D: Deserializer<'a>, - { - let v: Value = Deserialize::deserialize(deserializer)?; - - if v.is_null() { - return Ok(Params::None); - } - - from_value(v.clone()) - .map(Params::Logs) - .map_err(|e| D::Error::custom(format!("Invalid Pub-Sub parameters: {}", e))) - } -} diff --git a/primitives/rpc/src/receipt.rs b/primitives/rpc/src/receipt.rs deleted file mode 100644 index f65f131..0000000 --- a/primitives/rpc/src/receipt.rs +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2015-2020 Parity Technologies (UK) Ltd. -// This file is part of Frontier. - -// Open Ethereum 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. - -// Open Ethereum 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 Open Ethereum. If not, see . - -use crate::Log; -use ethereum_types::{Bloom as H2048, H160, H256, U256, U64}; -use serde::Serialize; - -/// Receipt -#[derive(Debug, Serialize)] -#[serde(rename_all = "camelCase")] -pub struct Receipt { - /// Transaction Hash - pub transaction_hash: Option, - /// Transaction index - pub transaction_index: Option, - /// Block hash - pub block_hash: Option, - /// Sender - pub from: Option, - /// Recipient - pub to: Option, - /// Block number - pub block_number: Option, - /// Cumulative gas used - pub cumulative_gas_used: U256, - /// Gas used - pub gas_used: Option, - /// Contract address - pub contract_address: Option, - /// Logs - pub logs: Vec, - /// State Root - // NOTE(niklasad1): EIP98 makes this optional field, if it's missing then skip serializing it - #[serde(skip_serializing_if = "Option::is_none", rename = "root")] - pub state_root: Option, - /// Logs bloom - pub logs_bloom: H2048, - /// Status code - // NOTE(niklasad1): Unknown after EIP98 rules, if it's missing then skip serializing it - #[serde(skip_serializing_if = "Option::is_none", rename = "status")] - pub status_code: Option, -} diff --git a/primitives/rpc/src/sync.rs b/primitives/rpc/src/sync.rs deleted file mode 100644 index a613ea4..0000000 --- a/primitives/rpc/src/sync.rs +++ /dev/null @@ -1,144 +0,0 @@ -// Copyright 2015-2020 Parity Technologies (UK) Ltd. -// This file is part of Frontier. - -// Open Ethereum 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. - -// Open Ethereum 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 Open Ethereum. If not, see . - -use std::collections::BTreeMap; - -use ethereum_types::{H512, U256}; -use serde::{Serialize, Serializer}; - -/// Sync info -#[derive(Default, Debug, Serialize, PartialEq)] -#[serde(rename_all = "camelCase")] -pub struct SyncInfo { - /// Starting block - pub starting_block: U256, - /// Current block - pub current_block: U256, - /// Highest block seen so far - pub highest_block: U256, - /// Warp sync snapshot chunks total. - pub warp_chunks_amount: Option, - /// Warp sync snpashot chunks processed. - pub warp_chunks_processed: Option, -} - -/// Peers info -#[derive(Default, Debug, Serialize)] -pub struct Peers { - /// Number of active peers - pub active: usize, - /// Number of connected peers - pub connected: usize, - /// Max number of peers - pub max: u32, - /// Detailed information on peers - pub peers: Vec, -} - -/// Peer connection information -#[derive(Default, Debug, Serialize)] -pub struct PeerInfo { - /// Public node id - pub id: Option, - /// Node client ID - pub name: String, - /// Capabilities - pub caps: Vec, - /// Network information - pub network: PeerNetworkInfo, - /// Protocols information - pub protocols: PeerProtocolsInfo, -} - -/// Peer network information -#[derive(Default, Debug, Serialize)] -#[serde(rename_all = "camelCase")] -pub struct PeerNetworkInfo { - /// Remote endpoint address - pub remote_address: String, - /// Local endpoint address - pub local_address: String, -} - -/// Peer protocols information -#[derive(Default, Debug, Serialize)] -pub struct PeerProtocolsInfo { - /// Ethereum protocol information - pub eth: Option, - /// PIP protocol information. - pub pip: Option, -} - -/// Peer Ethereum protocol information -#[derive(Default, Debug, Serialize)] -pub struct EthProtocolInfo { - /// Negotiated ethereum protocol version - pub version: u32, - /// Peer total difficulty if known - pub difficulty: Option, - /// SHA3 of peer best block hash - pub head: String, -} - -/// Peer PIP protocol information -#[derive(Default, Debug, Serialize)] -pub struct PipProtocolInfo { - /// Negotiated PIP protocol version - pub version: u32, - /// Peer total difficulty - pub difficulty: U256, - /// SHA3 of peer best block hash - pub head: String, -} - -/// Sync status -#[derive(Debug, PartialEq)] -pub enum SyncStatus { - /// Info when syncing - Info(SyncInfo), - /// Not syncing - None, -} - -impl Serialize for SyncStatus { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - match *self { - SyncStatus::Info(ref info) => info.serialize(serializer), - SyncStatus::None => false.serialize(serializer), - } - } -} - -/// Propagation statistics for pending transaction. -#[derive(Default, Debug, Serialize)] -#[serde(rename_all = "camelCase")] -pub struct TransactionStats { - /// Block no this transaction was first seen. - pub first_seen: u64, - /// Peers this transaction was propagated to with count. - pub propagated_to: BTreeMap, -} - -/// Chain status. -#[derive(Default, Debug, Serialize)] -#[serde(rename_all = "camelCase")] -pub struct ChainStatus { - /// Describes the gap in the blockchain, if there is one: (first, last) - pub block_gap: Option<(U256, U256)>, -} diff --git a/primitives/rpc/src/transaction.rs b/primitives/rpc/src/transaction.rs deleted file mode 100644 index d5bdfeb..0000000 --- a/primitives/rpc/src/transaction.rs +++ /dev/null @@ -1,175 +0,0 @@ -// Copyright 2015-2020 Parity Technologies (UK) Ltd. -// This file is part of Frontier. - -// Open Ethereum 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. - -// Open Ethereum 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 Open Ethereum. If not, see . - -use crate::Bytes; -use ethereum_types::{H160, H256, H512, U256, U64}; -use serde::ser::SerializeStruct; -use serde::{Serialize, Serializer}; -use std::{ - collections::HashMap, - sync::{Arc, Mutex}, -}; - -/// Transaction -#[derive(Debug, Default, Clone, PartialEq, Serialize)] -#[serde(rename_all = "camelCase")] -pub struct Transaction { - /// Hash - pub hash: H256, - /// Nonce - pub nonce: U256, - /// Block hash - pub block_hash: Option, - /// Block number - pub block_number: Option, - /// Transaction Index - pub transaction_index: Option, - /// Sender - pub from: H160, - /// Recipient - pub to: Option, - /// Transfered value - pub value: U256, - /// Gas Price - pub gas_price: U256, - /// Gas - pub gas: U256, - /// Data - pub input: Bytes, - /// Creates contract - pub creates: Option, - /// Raw transaction data - pub raw: Bytes, - /// Public key of the signer. - pub public_key: Option, - /// The network id of the transaction, if any. - pub chain_id: Option, - /// The standardised V field of the signature (0 or 1). - pub standard_v: U256, - /// The standardised V field of the signature. - pub v: U256, - /// The R field of the signature. - pub r: U256, - /// The S field of the signature. - pub s: U256, -} - -/// Local Transaction Status -#[derive(Debug)] -pub enum LocalTransactionStatus { - /// Transaction is pending - Pending, - /// Transaction is in future part of the queue - Future, - /// Transaction was mined. - Mined(Transaction), - /// Transaction was removed from the queue, but not mined. - Culled(Transaction), - /// Transaction was dropped because of limit. - Dropped(Transaction), - /// Transaction was replaced by transaction with higher gas price. - Replaced(Transaction, U256, H256), - /// Transaction never got into the queue. - Rejected(Transaction, String), - /// Transaction is invalid. - Invalid(Transaction), - /// Transaction was canceled. - Canceled(Transaction), -} - -impl Serialize for LocalTransactionStatus { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - use self::LocalTransactionStatus::*; - - let elems = match *self { - Pending | Future => 1, - Mined(..) | Culled(..) | Dropped(..) | Invalid(..) | Canceled(..) => 2, - Rejected(..) => 3, - Replaced(..) => 4, - }; - - let status = "status"; - let transaction = "transaction"; - - let mut struc = serializer.serialize_struct("LocalTransactionStatus", elems)?; - match *self { - Pending => struc.serialize_field(status, "pending")?, - Future => struc.serialize_field(status, "future")?, - Mined(ref tx) => { - struc.serialize_field(status, "mined")?; - struc.serialize_field(transaction, tx)?; - } - Culled(ref tx) => { - struc.serialize_field(status, "culled")?; - struc.serialize_field(transaction, tx)?; - } - Dropped(ref tx) => { - struc.serialize_field(status, "dropped")?; - struc.serialize_field(transaction, tx)?; - } - Canceled(ref tx) => { - struc.serialize_field(status, "canceled")?; - struc.serialize_field(transaction, tx)?; - } - Invalid(ref tx) => { - struc.serialize_field(status, "invalid")?; - struc.serialize_field(transaction, tx)?; - } - Rejected(ref tx, ref reason) => { - struc.serialize_field(status, "rejected")?; - struc.serialize_field(transaction, tx)?; - struc.serialize_field("error", reason)?; - } - Replaced(ref tx, ref gas_price, ref hash) => { - struc.serialize_field(status, "replaced")?; - struc.serialize_field(transaction, tx)?; - struc.serialize_field("hash", hash)?; - struc.serialize_field("gasPrice", gas_price)?; - } - } - - struc.end() - } -} - -/// Geth-compatible output for eth_signTransaction method -#[derive(Debug, Default, Clone, PartialEq, Serialize)] -pub struct RichRawTransaction { - /// Raw transaction RLP - pub raw: Bytes, - /// Transaction details - #[serde(rename = "tx")] - pub transaction: Transaction, -} - -pub struct PendingTransaction { - pub transaction: Transaction, - pub at_block: u64, -} - -impl PendingTransaction { - pub fn new(transaction: Transaction, at_block: u64) -> Self { - Self { - transaction, - at_block, - } - } -} - -pub type PendingTransactions = Option>>>; diff --git a/primitives/rpc/src/transaction_request.rs b/primitives/rpc/src/transaction_request.rs deleted file mode 100644 index dbb3767..0000000 --- a/primitives/rpc/src/transaction_request.rs +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2015-2020 Parity Technologies (UK) Ltd. -// This file is part of Frontier. - -// Open Ethereum 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. - -// Open Ethereum 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 Open Ethereum. If not, see . - -//! `TransactionRequest` type - -use crate::Bytes; -use ethereum_types::{H160, U256}; -use serde::{Deserialize, Serialize}; - -/// Transaction request coming from RPC -#[derive(Debug, Clone, Default, Eq, PartialEq, Hash, Serialize, Deserialize)] -#[serde(deny_unknown_fields)] -#[serde(rename_all = "camelCase")] -pub struct TransactionRequest { - /// Sender - pub from: Option, - /// Recipient - pub to: Option, - /// Gas Price - pub gas_price: Option, - /// Gas - pub gas: Option, - /// Value of transaction in wei - pub value: Option, - /// Additional data sent with transaction - pub data: Option, - /// Transaction's nonce - pub nonce: Option, -} diff --git a/primitives/rpc/src/work.rs b/primitives/rpc/src/work.rs deleted file mode 100644 index af98e16..0000000 --- a/primitives/rpc/src/work.rs +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2015-2020 Parity Technologies (UK) Ltd. -// This file is part of Frontier. - -// Open Ethereum 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. - -// Open Ethereum 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 Open Ethereum. If not, see . - -use ethereum_types::{H256, U256}; - -use serde::{Serialize, Serializer}; - -/// The result of an `eth_getWork` call: it differs based on an option -/// whether to send the block number. -#[derive(Debug, PartialEq, Eq)] -pub struct Work { - /// The proof-of-work hash. - pub pow_hash: H256, - /// The seed hash. - pub seed_hash: H256, - /// The target. - pub target: H256, - /// The block number: this isn't always stored. - pub number: Option, -} - -impl Serialize for Work { - fn serialize(&self, s: S) -> Result - where - S: Serializer, - { - match self.number.as_ref() { - Some(num) => ( - &self.pow_hash, - &self.seed_hash, - &self.target, - U256::from(*num), - ) - .serialize(s), - None => (&self.pow_hash, &self.seed_hash, &self.target).serialize(s), - } - } -} diff --git a/primitives/storage/Cargo.toml b/primitives/storage/Cargo.toml deleted file mode 100644 index d93f5d9..0000000 --- a/primitives/storage/Cargo.toml +++ /dev/null @@ -1,16 +0,0 @@ -[package] -authors = ["Hyperspace Network "] -description = "Storage key for ethereum schema" -edition = "2018" -homepage = "https://mvs.org/" -license = "GPL-3.0" -name = "dp-storage" -readme = "README.md" -repository = "https://github.com/mvs-org/Hyperspace" -version = "2.0.0" - -[dependencies] - -[features] -default = ["std"] -std = [] diff --git a/primitives/storage/src/lib.rs b/primitives/storage/src/lib.rs deleted file mode 100644 index d2382d0..0000000 --- a/primitives/storage/src/lib.rs +++ /dev/null @@ -1,21 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// This file is part of Frontier. -// -// Copyright (c) 2020 Parity Technologies (UK) Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#![cfg_attr(not(feature = "std"), no_std)] - -/// Current version of pallet Ethereum's storage schema is stored under this key. -pub const PALLET_ETHEREUM_SCHEMA: &'static [u8] = b":ethereum_schema"; From 6a0725261fa6c0b8ad7f61fae325f99dae231200 Mon Sep 17 00:00:00 2001 From: inodelisia Date: Sat, 19 Jun 2021 03:20:15 +0300 Subject: [PATCH 3/4] chainspec update --- bin/res/hyperspace/hyperspace.json | 4 ++-- hyperspace.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/res/hyperspace/hyperspace.json b/bin/res/hyperspace/hyperspace.json index 662aed7..b011807 100644 --- a/bin/res/hyperspace/hyperspace.json +++ b/bin/res/hyperspace/hyperspace.json @@ -3,10 +3,10 @@ "id": "hyperspace", "chainType": "Live", "bootNodes": [ - "/ip4/167.86.95.203/tcp/41984/p2p/12D3KooWCV6QDXZLRboH5NP6Qy63HzorWzSDekzajX2wEyKU1497" + "/dns4/hyperspace-seed-eu-01.mvs.org/tcp/30333/p2p/12D3KooWCV6QDXZLRboH5NP6Qy63HzorWzSDekzajX2wEyKU1497" ], "telemetryEndpoints": null, - "protocolId": "main", + "protocolId": "mainr", "properties": { "ss58Format": 150, "tokenDecimals": [ diff --git a/hyperspace.json b/hyperspace.json index 662aed7..b011807 100644 --- a/hyperspace.json +++ b/hyperspace.json @@ -3,10 +3,10 @@ "id": "hyperspace", "chainType": "Live", "bootNodes": [ - "/ip4/167.86.95.203/tcp/41984/p2p/12D3KooWCV6QDXZLRboH5NP6Qy63HzorWzSDekzajX2wEyKU1497" + "/dns4/hyperspace-seed-eu-01.mvs.org/tcp/30333/p2p/12D3KooWCV6QDXZLRboH5NP6Qy63HzorWzSDekzajX2wEyKU1497" ], "telemetryEndpoints": null, - "protocolId": "main", + "protocolId": "mainr", "properties": { "ss58Format": 150, "tokenDecimals": [ From f6e6fb471b5c15ea44fc03a6ad2f0f60ba9b35f0 Mon Sep 17 00:00:00 2001 From: inodelisia Date: Sat, 19 Jun 2021 23:09:58 +0300 Subject: [PATCH 4/4] chainspec update --- bin/res/hyperspace/hyperspace.json | 2 +- hyperspace.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/res/hyperspace/hyperspace.json b/bin/res/hyperspace/hyperspace.json index b011807..d75994c 100644 --- a/bin/res/hyperspace/hyperspace.json +++ b/bin/res/hyperspace/hyperspace.json @@ -6,7 +6,7 @@ "/dns4/hyperspace-seed-eu-01.mvs.org/tcp/30333/p2p/12D3KooWCV6QDXZLRboH5NP6Qy63HzorWzSDekzajX2wEyKU1497" ], "telemetryEndpoints": null, - "protocolId": "mainr", + "protocolId": "mainx", "properties": { "ss58Format": 150, "tokenDecimals": [ diff --git a/hyperspace.json b/hyperspace.json index b011807..d75994c 100644 --- a/hyperspace.json +++ b/hyperspace.json @@ -6,7 +6,7 @@ "/dns4/hyperspace-seed-eu-01.mvs.org/tcp/30333/p2p/12D3KooWCV6QDXZLRboH5NP6Qy63HzorWzSDekzajX2wEyKU1497" ], "telemetryEndpoints": null, - "protocolId": "mainr", + "protocolId": "mainx", "properties": { "ss58Format": 150, "tokenDecimals": [