From ab60820fb3eb9cfee7e93dd5c737f46bcfca36f7 Mon Sep 17 00:00:00 2001 From: Xiliang Chen Date: Fri, 2 Oct 2020 23:05:59 +1300 Subject: [PATCH 1/8] use substrate 2.0 (#149) --- Cargo.lock | 422 ++++++++++++++++---------------- consensus/Cargo.toml | 18 +- consensus/primitives/Cargo.toml | 6 +- frame/ethereum/src/mock.rs | 2 +- template/runtime/src/lib.rs | 2 +- 5 files changed, 225 insertions(+), 225 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 40ad2af830..7668312e27 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1068,9 +1068,9 @@ dependencies = [ [[package]] name = "environmental" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "516aa8d7a71cb00a1c4146f0798549b93d083d4f189b3ced8f3de6b8f11ee6c4" +checksum = "6576a1755ddffd988788025e75bce9e74b018f7cc226198fe931d077911c6d7e" [[package]] name = "erased-serde" @@ -1281,16 +1281,16 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "fork-tree" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "parity-scale-codec", ] [[package]] name = "frame-benchmarking" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "frame-support", "frame-system", @@ -1307,8 +1307,8 @@ dependencies = [ [[package]] name = "frame-executive" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "frame-support", "frame-system", @@ -1323,8 +1323,8 @@ dependencies = [ [[package]] name = "frame-metadata" -version = "11.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "12.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "parity-scale-codec", "serde", @@ -1334,8 +1334,8 @@ dependencies = [ [[package]] name = "frame-support" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "bitmask", "frame-metadata", @@ -1359,8 +1359,8 @@ dependencies = [ [[package]] name = "frame-support-procedural" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "frame-support-procedural-tools", "proc-macro2", @@ -1370,8 +1370,8 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate", @@ -1382,8 +1382,8 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "proc-macro2", "quote", @@ -1392,8 +1392,8 @@ dependencies = [ [[package]] name = "frame-system" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "frame-support", "impl-trait-for-tuples", @@ -1408,8 +1408,8 @@ dependencies = [ [[package]] name = "frame-system-rpc-runtime-api" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "parity-scale-codec", "sp-api", @@ -3610,8 +3610,8 @@ dependencies = [ [[package]] name = "pallet-aura" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "frame-support", "frame-system", @@ -3629,8 +3629,8 @@ dependencies = [ [[package]] name = "pallet-authorship" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "frame-support", "frame-system", @@ -3644,8 +3644,8 @@ dependencies = [ [[package]] name = "pallet-balances" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "frame-benchmarking", "frame-support", @@ -3690,8 +3690,8 @@ checksum = "bd4556fb64842e71bb6e2f98b7541c0d310069eb607d432c6ac9bdaecbfd3118" [[package]] name = "pallet-evm" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "evm", "frame-support", @@ -3713,8 +3713,8 @@ dependencies = [ [[package]] name = "pallet-finality-tracker" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "frame-support", "frame-system", @@ -3729,8 +3729,8 @@ dependencies = [ [[package]] name = "pallet-grandpa" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "frame-benchmarking", "frame-support", @@ -3751,8 +3751,8 @@ dependencies = [ [[package]] name = "pallet-randomness-collective-flip" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "frame-support", "frame-system", @@ -3764,8 +3764,8 @@ dependencies = [ [[package]] name = "pallet-session" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "frame-support", "frame-system", @@ -3784,8 +3784,8 @@ dependencies = [ [[package]] name = "pallet-sudo" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "frame-support", "frame-system", @@ -3798,8 +3798,8 @@ dependencies = [ [[package]] name = "pallet-timestamp" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "frame-benchmarking", "frame-support", @@ -3815,8 +3815,8 @@ dependencies = [ [[package]] name = "pallet-transaction-payment" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "frame-support", "frame-system", @@ -3832,8 +3832,8 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "jsonrpc-core 15.0.0", "jsonrpc-core-client 15.0.0", @@ -3850,8 +3850,8 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc-runtime-api" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "frame-support", "parity-scale-codec", @@ -4900,8 +4900,8 @@ dependencies = [ [[package]] name = "sc-basic-authorship" -version = "0.8.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "0.8.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "futures 0.3.5", "futures-timer 3.0.2", @@ -4924,8 +4924,8 @@ dependencies = [ [[package]] name = "sc-block-builder" -version = "0.8.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "0.8.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "parity-scale-codec", "sc-client-api", @@ -4941,8 +4941,8 @@ dependencies = [ [[package]] name = "sc-chain-spec" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", @@ -4958,8 +4958,8 @@ dependencies = [ [[package]] name = "sc-chain-spec-derive" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -4969,8 +4969,8 @@ dependencies = [ [[package]] name = "sc-cli" -version = "0.8.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "0.8.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "ansi_term 0.12.1", "atty", @@ -5018,8 +5018,8 @@ dependencies = [ [[package]] name = "sc-client-api" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "derive_more", "fnv", @@ -5054,8 +5054,8 @@ dependencies = [ [[package]] name = "sc-client-db" -version = "0.8.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "0.8.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "blake2-rfc", "hash-db", @@ -5084,8 +5084,8 @@ dependencies = [ [[package]] name = "sc-consensus" -version = "0.8.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "0.8.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "sc-client-api", "sp-blockchain", @@ -5095,8 +5095,8 @@ dependencies = [ [[package]] name = "sc-consensus-aura" -version = "0.8.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "0.8.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "derive_more", "futures 0.3.5", @@ -5126,8 +5126,8 @@ dependencies = [ [[package]] name = "sc-consensus-babe" -version = "0.8.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "0.8.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "derive_more", "fork-tree", @@ -5170,8 +5170,8 @@ dependencies = [ [[package]] name = "sc-consensus-epochs" -version = "0.8.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "0.8.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "fork-tree", "parity-scale-codec", @@ -5183,8 +5183,8 @@ dependencies = [ [[package]] name = "sc-consensus-manual-seal" -version = "0.8.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "0.8.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "assert_matches", "derive_more", @@ -5214,8 +5214,8 @@ dependencies = [ [[package]] name = "sc-consensus-slots" -version = "0.8.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "0.8.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "futures 0.3.5", "futures-timer 3.0.2", @@ -5237,8 +5237,8 @@ dependencies = [ [[package]] name = "sc-consensus-uncles" -version = "0.8.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "0.8.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "log", "sc-client-api", @@ -5251,8 +5251,8 @@ dependencies = [ [[package]] name = "sc-executor" -version = "0.8.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "0.8.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "derive_more", "lazy_static", @@ -5278,8 +5278,8 @@ dependencies = [ [[package]] name = "sc-executor-common" -version = "0.8.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "0.8.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "derive_more", "log", @@ -5295,8 +5295,8 @@ dependencies = [ [[package]] name = "sc-executor-wasmi" -version = "0.8.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "0.8.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "log", "parity-scale-codec", @@ -5310,8 +5310,8 @@ dependencies = [ [[package]] name = "sc-finality-grandpa" -version = "0.8.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "0.8.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "derive_more", "finality-grandpa", @@ -5347,8 +5347,8 @@ dependencies = [ [[package]] name = "sc-informant" -version = "0.8.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "0.8.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "ansi_term 0.12.1", "futures 0.3.5", @@ -5365,8 +5365,8 @@ dependencies = [ [[package]] name = "sc-keystore" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "derive_more", "hex", @@ -5381,8 +5381,8 @@ dependencies = [ [[package]] name = "sc-light" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "hash-db", "lazy_static", @@ -5400,8 +5400,8 @@ dependencies = [ [[package]] name = "sc-network" -version = "0.8.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "0.8.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "async-std", "async-trait", @@ -5454,8 +5454,8 @@ dependencies = [ [[package]] name = "sc-network-gossip" -version = "0.8.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "0.8.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "futures 0.3.5", "futures-timer 3.0.2", @@ -5469,8 +5469,8 @@ dependencies = [ [[package]] name = "sc-offchain" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "bytes 0.5.6", "fnv", @@ -5496,8 +5496,8 @@ dependencies = [ [[package]] name = "sc-peerset" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "futures 0.3.5", "libp2p", @@ -5509,8 +5509,8 @@ dependencies = [ [[package]] name = "sc-proposer-metrics" -version = "0.8.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "0.8.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "log", "substrate-prometheus-endpoint", @@ -5518,8 +5518,8 @@ dependencies = [ [[package]] name = "sc-rpc" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "futures 0.3.5", "hash-db", @@ -5550,8 +5550,8 @@ dependencies = [ [[package]] name = "sc-rpc-api" -version = "0.8.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "0.8.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "derive_more", "futures 0.3.5", @@ -5574,8 +5574,8 @@ dependencies = [ [[package]] name = "sc-rpc-server" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "futures 0.1.29", "jsonrpc-core 15.0.0", @@ -5592,8 +5592,8 @@ dependencies = [ [[package]] name = "sc-service" -version = "0.8.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "0.8.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "derive_more", "directories", @@ -5654,8 +5654,8 @@ dependencies = [ [[package]] name = "sc-state-db" -version = "0.8.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "0.8.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "log", "parity-scale-codec", @@ -5668,8 +5668,8 @@ dependencies = [ [[package]] name = "sc-telemetry" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "futures 0.3.5", "futures-timer 3.0.2", @@ -5689,8 +5689,8 @@ dependencies = [ [[package]] name = "sc-tracing" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "erased-serde", "log", @@ -5708,8 +5708,8 @@ dependencies = [ [[package]] name = "sc-transaction-graph" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "derive_more", "futures 0.3.5", @@ -5729,8 +5729,8 @@ dependencies = [ [[package]] name = "sc-transaction-pool" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "derive_more", "futures 0.3.5", @@ -6100,8 +6100,8 @@ dependencies = [ [[package]] name = "sp-allocator" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "derive_more", "log", @@ -6112,8 +6112,8 @@ dependencies = [ [[package]] name = "sp-api" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "hash-db", "parity-scale-codec", @@ -6127,8 +6127,8 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "blake2-rfc", "proc-macro-crate", @@ -6139,8 +6139,8 @@ dependencies = [ [[package]] name = "sp-application-crypto" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "parity-scale-codec", "serde", @@ -6151,8 +6151,8 @@ dependencies = [ [[package]] name = "sp-arithmetic" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "integer-sqrt", "num-traits", @@ -6164,8 +6164,8 @@ dependencies = [ [[package]] name = "sp-authorship" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "parity-scale-codec", "sp-inherents", @@ -6175,8 +6175,8 @@ dependencies = [ [[package]] name = "sp-block-builder" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "parity-scale-codec", "sp-api", @@ -6187,8 +6187,8 @@ dependencies = [ [[package]] name = "sp-blockchain" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "derive_more", "log", @@ -6204,8 +6204,8 @@ dependencies = [ [[package]] name = "sp-chain-spec" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "serde", "serde_json", @@ -6213,8 +6213,8 @@ dependencies = [ [[package]] name = "sp-consensus" -version = "0.8.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "0.8.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "derive_more", "futures 0.3.5", @@ -6239,8 +6239,8 @@ dependencies = [ [[package]] name = "sp-consensus-aura" -version = "0.8.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "0.8.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "parity-scale-codec", "sp-api", @@ -6253,8 +6253,8 @@ dependencies = [ [[package]] name = "sp-consensus-babe" -version = "0.8.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "0.8.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "merlin", "parity-scale-codec", @@ -6272,8 +6272,8 @@ dependencies = [ [[package]] name = "sp-consensus-slots" -version = "0.8.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "0.8.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "parity-scale-codec", "sp-runtime", @@ -6281,8 +6281,8 @@ dependencies = [ [[package]] name = "sp-consensus-vrf" -version = "0.8.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "0.8.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "parity-scale-codec", "schnorrkel", @@ -6293,8 +6293,8 @@ dependencies = [ [[package]] name = "sp-core" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "base58", "blake2-rfc", @@ -6337,8 +6337,8 @@ dependencies = [ [[package]] name = "sp-database" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "kvdb", "parking_lot 0.10.2", @@ -6346,8 +6346,8 @@ dependencies = [ [[package]] name = "sp-debug-derive" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "proc-macro2", "quote", @@ -6356,8 +6356,8 @@ dependencies = [ [[package]] name = "sp-externalities" -version = "0.8.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "0.8.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "environmental", "parity-scale-codec", @@ -6367,8 +6367,8 @@ dependencies = [ [[package]] name = "sp-finality-grandpa" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "finality-grandpa", "log", @@ -6383,8 +6383,8 @@ dependencies = [ [[package]] name = "sp-finality-tracker" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "parity-scale-codec", "sp-inherents", @@ -6393,8 +6393,8 @@ dependencies = [ [[package]] name = "sp-inherents" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "derive_more", "parity-scale-codec", @@ -6405,8 +6405,8 @@ dependencies = [ [[package]] name = "sp-io" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "futures 0.3.5", "hash-db", @@ -6428,8 +6428,8 @@ dependencies = [ [[package]] name = "sp-keyring" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "lazy_static", "sp-core", @@ -6439,8 +6439,8 @@ dependencies = [ [[package]] name = "sp-offchain" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "sp-api", "sp-core", @@ -6449,8 +6449,8 @@ dependencies = [ [[package]] name = "sp-panic-handler" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "backtrace", "log", @@ -6458,8 +6458,8 @@ dependencies = [ [[package]] name = "sp-rpc" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "serde", "sp-core", @@ -6467,8 +6467,8 @@ dependencies = [ [[package]] name = "sp-runtime" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "either", "hash256-std-hasher", @@ -6489,8 +6489,8 @@ dependencies = [ [[package]] name = "sp-runtime-interface" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "parity-scale-codec", "primitive-types", @@ -6505,8 +6505,8 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "Inflector", "proc-macro-crate", @@ -6517,8 +6517,8 @@ dependencies = [ [[package]] name = "sp-serializer" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "serde", "serde_json", @@ -6526,8 +6526,8 @@ dependencies = [ [[package]] name = "sp-session" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "parity-scale-codec", "sp-api", @@ -6539,8 +6539,8 @@ dependencies = [ [[package]] name = "sp-staking" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "parity-scale-codec", "sp-runtime", @@ -6549,8 +6549,8 @@ dependencies = [ [[package]] name = "sp-state-machine" -version = "0.8.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "0.8.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "hash-db", "log", @@ -6570,13 +6570,13 @@ dependencies = [ [[package]] name = "sp-std" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" [[package]] name = "sp-storage" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "impl-serde", "parity-scale-codec", @@ -6588,8 +6588,8 @@ dependencies = [ [[package]] name = "sp-timestamp" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", @@ -6602,8 +6602,8 @@ dependencies = [ [[package]] name = "sp-tracing" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "log", "parity-scale-codec", @@ -6615,8 +6615,8 @@ dependencies = [ [[package]] name = "sp-transaction-pool" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "derive_more", "futures 0.3.5", @@ -6630,8 +6630,8 @@ dependencies = [ [[package]] name = "sp-trie" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "hash-db", "memory-db", @@ -6644,8 +6644,8 @@ dependencies = [ [[package]] name = "sp-utils" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "futures 0.3.5", "futures-core", @@ -6656,8 +6656,8 @@ dependencies = [ [[package]] name = "sp-version" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "impl-serde", "parity-scale-codec", @@ -6668,8 +6668,8 @@ dependencies = [ [[package]] name = "sp-wasm-interface" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", @@ -6797,16 +6797,16 @@ dependencies = [ [[package]] name = "substrate-build-script-utils" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "platforms", ] [[package]] name = "substrate-frame-rpc-system" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "frame-system-rpc-runtime-api", "futures 0.3.5", @@ -6828,8 +6828,8 @@ dependencies = [ [[package]] name = "substrate-prometheus-endpoint" -version = "0.8.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "0.8.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "async-std", "derive_more", @@ -6842,8 +6842,8 @@ dependencies = [ [[package]] name = "substrate-test-client" -version = "2.0.0-rc6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" dependencies = [ "futures 0.1.29", "futures 0.3.5", @@ -6869,7 +6869,7 @@ dependencies = [ [[package]] name = "substrate-wasm-builder-runner" version = "1.0.6" -source = "git+https://github.com/paritytech/substrate.git?branch=frontier#7314ddce65d6023ccb7ae18006a4ada792604bfd" +source = "git+https://github.com/paritytech/substrate.git?branch=frontier#d81e3abb6c62fad079a8a8127d595d2772ec7a98" [[package]] name = "subtle" diff --git a/consensus/Cargo.toml b/consensus/Cargo.toml index 3ce3a60a6c..9d30b89aa1 100644 --- a/consensus/Cargo.toml +++ b/consensus/Cargo.toml @@ -9,18 +9,18 @@ repository = "https://github.com/paritytech/frontier/" [dependencies] codec = { package = "parity-scale-codec", version = "1.3.4", features = ["derive"] } -sp-core = { version = "2.0.0-rc6", git = "https://github.com/paritytech/substrate.git", branch = "frontier" } -sp-blockchain = { version = "2.0.0-rc6", git = "https://github.com/paritytech/substrate.git", branch = "frontier" } -sp-runtime = { version = "2.0.0-rc6", git = "https://github.com/paritytech/substrate.git", branch = "frontier" } -sp-api = { version = "2.0.0-rc6", git = "https://github.com/paritytech/substrate.git", branch = "frontier" } -sc-client-api = { version = "2.0.0-rc6", git = "https://github.com/paritytech/substrate.git", branch = "frontier" } -sp-block-builder = { version = "2.0.0-rc6", git = "https://github.com/paritytech/substrate.git", branch = "frontier" } -sp-inherents = { version = "2.0.0-rc6", git = "https://github.com/paritytech/substrate.git", branch = "frontier" } +sp-core = { version = "2.0.0", git = "https://github.com/paritytech/substrate.git", branch = "frontier" } +sp-blockchain = { version = "2.0.0", git = "https://github.com/paritytech/substrate.git", branch = "frontier" } +sp-runtime = { version = "2.0.0", git = "https://github.com/paritytech/substrate.git", branch = "frontier" } +sp-api = { version = "2.0.0", git = "https://github.com/paritytech/substrate.git", branch = "frontier" } +sc-client-api = { version = "2.0.0", git = "https://github.com/paritytech/substrate.git", branch = "frontier" } +sp-block-builder = { version = "2.0.0", git = "https://github.com/paritytech/substrate.git", branch = "frontier" } +sp-inherents = { version = "2.0.0", git = "https://github.com/paritytech/substrate.git", branch = "frontier" } frontier-consensus-primitives = { version = "0.1.0", path = "primitives" } -sp-consensus = { version = "0.8.0-rc6", git = "https://github.com/paritytech/substrate.git", branch = "frontier" } +sp-consensus = { version = "0.8.0", git = "https://github.com/paritytech/substrate.git", branch = "frontier" } log = "0.4.8" futures = { version = "0.3.1", features = ["compat"] } -sp-timestamp = { version = "2.0.0-rc6", git = "https://github.com/paritytech/substrate.git", branch = "frontier" } +sp-timestamp = { version = "2.0.0", git = "https://github.com/paritytech/substrate.git", branch = "frontier" } derive_more = "0.99.2" prometheus-endpoint = { package = "substrate-prometheus-endpoint", git = "https://github.com/paritytech/substrate.git", branch = "frontier"} ethereum = { version = "0.3", features = ["codec"] } \ No newline at end of file diff --git a/consensus/primitives/Cargo.toml b/consensus/primitives/Cargo.toml index 83f658bdcc..84e8de8963 100644 --- a/consensus/primitives/Cargo.toml +++ b/consensus/primitives/Cargo.toml @@ -9,9 +9,9 @@ homepage = "https://substrate.dev" repository = "https://github.com/paritytech/substrate/" [dependencies] -sp-std = { version = "2.0.0-rc6", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "frontier" } -sp-runtime = { version = "2.0.0-rc6", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "frontier" } -sp-core = { version = "2.0.0-rc6", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "frontier" } +sp-std = { version = "2.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "frontier" } +sp-runtime = { version = "2.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "frontier" } +sp-core = { version = "2.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "frontier" } codec = { package = "parity-scale-codec", version = "1.3.1", default-features = false, features = ["derive"] } [features] diff --git a/frame/ethereum/src/mock.rs b/frame/ethereum/src/mock.rs index bbd63ad52f..d9445056fe 100644 --- a/frame/ethereum/src/mock.rs +++ b/frame/ethereum/src/mock.rs @@ -69,7 +69,7 @@ impl frame_system::Trait for Test { type MaximumBlockLength = MaximumBlockLength; type AvailableBlockRatio = AvailableBlockRatio; type Version = (); - type ModuleToIndex = (); + type PalletInfo = (); type AccountData = pallet_balances::AccountData; type OnNewAccount = (); type OnKilledAccount = (); diff --git a/template/runtime/src/lib.rs b/template/runtime/src/lib.rs index 4f96465e01..e558cfb5fa 100644 --- a/template/runtime/src/lib.rs +++ b/template/runtime/src/lib.rs @@ -200,7 +200,7 @@ impl frame_system::Trait for Runtime { /// Converts a module to the index of the module in `construct_runtime!`. /// /// This type is being generated by `construct_runtime!`. - type ModuleToIndex = ModuleToIndex; + type PalletInfo = PalletInfo; /// What to do if a new account is created. type OnNewAccount = (); /// What to do if an account is fully reaped from the system. From 0caeafd34ca5d119c0b7347e610ee2ef80507337 Mon Sep 17 00:00:00 2001 From: tgmichel Date: Fri, 2 Oct 2020 13:34:09 +0200 Subject: [PATCH 2/8] Fix filter `to_block` (#150) --- rpc/src/eth_pubsub.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/rpc/src/eth_pubsub.rs b/rpc/src/eth_pubsub.rs index a9701772e9..06a2d54d8c 100644 --- a/rpc/src/eth_pubsub.rs +++ b/rpc/src/eth_pubsub.rs @@ -116,9 +116,14 @@ impl EthPubSubApi where params: Option ) -> (Option, Option) { if let Some(Params::Logs(f)) = params { + let to_block: Option = if f.to_block.is_some() { + self.native_block_number(f.to_block).unwrap_or(None) + } else { + None + }; return ( self.native_block_number(f.from_block).unwrap_or(None), - self.native_block_number(f.to_block).unwrap_or(None) + to_block ); } (None, None) From e937d5c68ada42d74218c92f6bb22d5ca17984be Mon Sep 17 00:00:00 2001 From: tgmichel Date: Fri, 2 Oct 2020 15:34:39 +0200 Subject: [PATCH 3/8] Use HeaderBackend instead SelectChain (#143) --- Cargo.lock | 1 - rpc/Cargo.toml | 1 - rpc/src/eth.rs | 100 ++++++++++------------------------- rpc/src/eth_pubsub.rs | 34 +++++------- template/node/src/rpc.rs | 16 ++---- template/node/src/service.rs | 2 - 6 files changed, 46 insertions(+), 108 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7668312e27..015d151ece 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1472,7 +1472,6 @@ dependencies = [ "sha3 0.8.2", "sp-api", "sp-blockchain", - "sp-consensus", "sp-io", "sp-runtime", "sp-storage", diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index 12a46df934..56e4a74069 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -19,7 +19,6 @@ frontier-rpc-primitives = { path = "primitives" } sp-io = { git = "https://github.com/paritytech/substrate.git", branch = "frontier" } sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "frontier" } sp-api = { git = "https://github.com/paritytech/substrate.git", branch = "frontier" } -sp-consensus = { git = "https://github.com/paritytech/substrate.git", branch = "frontier" } sp-transaction-pool = { git = "https://github.com/paritytech/substrate.git", branch = "frontier" } sp-storage = { git = "https://github.com/paritytech/substrate.git", branch = "frontier" } sp-blockchain = { git = "https://github.com/paritytech/substrate.git", branch = "frontier" } diff --git a/rpc/src/eth.rs b/rpc/src/eth.rs index 3a53850fe8..d02e354308 100644 --- a/rpc/src/eth.rs +++ b/rpc/src/eth.rs @@ -20,10 +20,9 @@ use ethereum::{Block as EthereumBlock, Transaction as EthereumTransaction}; use ethereum_types::{H160, H256, H64, U256, U64, H512}; use jsonrpc_core::{BoxFuture, Result, futures::future::{self, Future}}; use futures::future::TryFutureExt; -use sp_runtime::traits::{Block as BlockT, Header as _, UniqueSaturatedInto, Zero, One, Saturating}; +use sp_runtime::traits::{Block as BlockT, UniqueSaturatedInto, Zero, One, Saturating}; use sp_runtime::transaction_validity::TransactionSource; use sp_api::{ProvideRuntimeApi, BlockId}; -use sp_consensus::SelectChain; use sp_transaction_pool::TransactionPool; use sc_client_api::backend::{StorageProvider, Backend, StateBackend, AuxStore}; use sha3::{Keccak256, Digest}; @@ -39,24 +38,22 @@ use crate::internal_err; pub use frontier_rpc_core::{EthApiServer, NetApiServer}; -pub struct EthApi { +pub struct EthApi { pool: Arc

, client: Arc, - select_chain: SC, convert_transaction: CT, is_authority: bool, _marker: PhantomData<(B, BE)>, } -impl EthApi { +impl EthApi { pub fn new( client: Arc, - select_chain: SC, pool: Arc

, convert_transaction: CT, is_authority: bool ) -> Self { - Self { client, select_chain, pool, convert_transaction, is_authority, _marker: PhantomData } + Self { client, pool, convert_transaction, is_authority, _marker: PhantomData } } } @@ -171,7 +168,7 @@ fn transaction_build( } } -impl EthApi where +impl EthApi where C: ProvideRuntimeApi + StorageProvider + AuxStore, C: HeaderBackend + HeaderMetadata + 'static, C::Api: EthereumRuntimeRPCApi, @@ -179,7 +176,6 @@ impl EthApi where BE::State: StateBackend, B: BlockT + Send + Sync + 'static, C: Send + Sync + 'static, - SC: SelectChain + Clone + 'static, P: TransactionPool + Send + Sync + 'static, CT: ConvertTransaction<::Extrinsic> + Send + Sync + 'static, { @@ -193,9 +189,7 @@ impl EthApi where }, BlockNumber::Latest => { Some(BlockId::Hash( - self.select_chain.best_chain() - .map_err(|err| internal_err(format!("fetch header failed: {:?}", err)))? - .hash() + self.client.info().best_hash )) }, BlockNumber::Earliest => { @@ -233,7 +227,7 @@ impl EthApi where } } -impl EthApiT for EthApi where +impl EthApiT for EthApi where C: ProvideRuntimeApi + StorageProvider + AuxStore, C: HeaderBackend + HeaderMetadata + 'static, C::Api: EthereumRuntimeRPCApi, @@ -241,7 +235,6 @@ impl EthApiT for EthApi where BE::State: StateBackend, B: BlockT + Send + Sync + 'static, C: Send + Sync + 'static, - SC: SelectChain + Clone + 'static, P: TransactionPool + Send + Sync + 'static, CT: ConvertTransaction<::Extrinsic> + Send + Sync + 'static, { @@ -250,12 +243,7 @@ impl EthApiT for EthApi where } fn syncing(&self) -> Result { - let header = self - .select_chain - .best_chain() - .map_err(|err| internal_err(format!("fetch header failed: {:?}", err)))?; - - let block_number = U256::from(header.number().clone().unique_saturated_into()); + let block_number = U256::from(self.client.info().best_number.clone().unique_saturated_into()); Ok(SyncStatus::Info(SyncInfo { starting_block: U256::zero(), @@ -271,14 +259,12 @@ impl EthApiT for EthApi where } fn author(&self) -> Result { - let header = self.select_chain - .best_chain() - .map_err(|err| internal_err(format!("fetch header failed: {:?}", err)))?; + let hash = self.client.info().best_hash; Ok( self.client .runtime_api() - .author(&BlockId::Hash(header.hash())) + .author(&BlockId::Hash(hash)) .map_err(|err| internal_err(format!("fetch runtime chain id failed: {:?}", err)))?.into() ) } @@ -288,21 +274,17 @@ impl EthApiT for EthApi where } fn chain_id(&self) -> Result> { - let header = self.select_chain.best_chain() - .map_err(|err| internal_err(format!("fetch header failed: {:?}", err)))?; - Ok(Some(self.client.runtime_api().chain_id(&BlockId::Hash(header.hash())) + let hash = self.client.info().best_hash; + Ok(Some(self.client.runtime_api().chain_id(&BlockId::Hash(hash)) .map_err(|err| internal_err(format!("fetch runtime chain id failed: {:?}", err)))?.into())) } fn gas_price(&self) -> Result { - let header = self - .select_chain - .best_chain() - .map_err(|err| internal_err(format!("fetch header failed: {:?}", err)))?; + let hash = self.client.info().best_hash; Ok( self.client .runtime_api() - .gas_price(&BlockId::Hash(header.hash())) + .gas_price(&BlockId::Hash(hash)) .map_err(|err| internal_err(format!("fetch runtime chain id failed: {:?}", err)))? .into(), ) @@ -313,11 +295,7 @@ impl EthApiT for EthApi where } fn block_number(&self) -> Result { - let header = self - .select_chain - .best_chain() - .map_err(|err| internal_err(format!("fetch header failed: {:?}", err)))?; - Ok(U256::from(header.number().clone().unique_saturated_into())) + Ok(U256::from(self.client.info().best_number.clone().unique_saturated_into())) } fn balance(&self, address: H160, number: Option) -> Result { @@ -483,17 +461,11 @@ impl EthApiT for EthApi where let transaction_hash = H256::from_slice( Keccak256::digest(&rlp::encode(&transaction)).as_slice() ); - let header = match self.select_chain.best_chain() { - Ok(header) => header, - Err(_) => return Box::new( - future::result(Err(internal_err("fetch header failed"))) - ), - }; - let best_block_hash = header.hash(); + let hash = self.client.info().best_hash; Box::new( self.pool .submit_one( - &BlockId::hash(best_block_hash), + &BlockId::hash(hash), TransactionSource::Local, self.convert_transaction.convert_transaction(transaction), ) @@ -504,10 +476,7 @@ impl EthApiT for EthApi where } fn call(&self, request: CallRequest, _: Option) -> Result { - let header = self - .select_chain - .best_chain() - .map_err(|err| internal_err(format!("fetch header failed: {:?}", err)))?; + let hash = self.client.info().best_hash; let from = request.from.unwrap_or_default(); let to = request.to.unwrap_or_default(); @@ -519,7 +488,7 @@ impl EthApiT for EthApi where let (ret, _) = self.client.runtime_api() .call( - &BlockId::Hash(header.hash()), + &BlockId::Hash(hash), from, data, value, @@ -535,10 +504,7 @@ impl EthApiT for EthApi where } fn estimate_gas(&self, request: CallRequest, _: Option) -> Result { - let header = self - .select_chain - .best_chain() - .map_err(|err| internal_err(format!("fetch header failed: {:?}", err)))?; + let hash = self.client.info().best_hash; let from = request.from.unwrap_or_default(); let gas_price = request.gas_price; @@ -549,7 +515,7 @@ impl EthApiT for EthApi where let (_, used_gas) = self.client.runtime_api() .call( - &BlockId::Hash(header.hash()), + &BlockId::Hash(hash), from, data, value, @@ -778,18 +744,14 @@ impl EthApiT for EthApi where .and_then(|v| v.to_min_block_num()) .map(|s| s.unique_saturated_into()) .unwrap_or( - *self.select_chain.best_chain() - .map_err(|err| internal_err(format!("fetch header failed: {:?}", err)))? - .number() + self.client.info().best_number ); let from_number = filter.from_block .and_then(|v| v.to_min_block_num()) .map(|s| s.unique_saturated_into()) .unwrap_or( - *self.select_chain.best_chain() - .map_err(|err| internal_err(format!("fetch header failed: {:?}", err)))? - .number() + self.client.info().best_number ); while current_number >= from_number { @@ -886,32 +848,29 @@ impl EthApiT for EthApi where } } -pub struct NetApi { - select_chain: SC, +pub struct NetApi { client: Arc, _marker: PhantomData<(B, BE)>, } -impl NetApi { +impl NetApi { pub fn new( client: Arc, - select_chain: SC, ) -> Self { Self { client: client, - select_chain: select_chain, _marker: PhantomData, } } } -impl NetApiT for NetApi where +impl NetApiT for NetApi where C: ProvideRuntimeApi + StorageProvider + AuxStore, + C: HeaderBackend + HeaderMetadata + 'static, C::Api: EthereumRuntimeRPCApi, BE: Backend + 'static, BE::State: StateBackend, C: Send + Sync + 'static, - SC: SelectChain + Clone + 'static, B: BlockT + Send + Sync + 'static, { fn is_listening(&self) -> Result { @@ -923,9 +882,8 @@ impl NetApiT for NetApi where } fn version(&self) -> Result { - let header = self.select_chain.best_chain() - .map_err(|_| internal_err("fetch header failed"))?; - Ok(self.client.runtime_api().chain_id(&BlockId::Hash(header.hash())) + let hash = self.client.info().best_hash; + Ok(self.client.runtime_api().chain_id(&BlockId::Hash(hash)) .map_err(|_| internal_err("fetch runtime chain id failed"))?.to_string()) } } diff --git a/rpc/src/eth_pubsub.rs b/rpc/src/eth_pubsub.rs index 06a2d54d8c..2eb69fa3c9 100644 --- a/rpc/src/eth_pubsub.rs +++ b/rpc/src/eth_pubsub.rs @@ -1,12 +1,12 @@ use std::{marker::PhantomData, sync::Arc}; use std::collections::BTreeMap; use sp_runtime::traits::{ - Block as BlockT, Header as _, BlakeTwo256, + Block as BlockT, BlakeTwo256, UniqueSaturatedInto }; use sp_transaction_pool::TransactionPool; use sp_api::{ProvideRuntimeApi, BlockId}; -use sp_blockchain::HeaderBackend; +use sp_blockchain::{Error as BlockChainError, HeaderMetadata, HeaderBackend}; use sp_storage::{StorageKey, StorageData}; use sp_io::hashing::twox_128; use sc_client_api::{ @@ -14,7 +14,6 @@ use sc_client_api::{ client::BlockchainEvents }; use sc_rpc::Metadata; -use sp_consensus::SelectChain; use log::warn; use jsonrpc_pubsub::{typed::Subscriber, SubscriptionId, manager::SubscriptionManager}; @@ -36,44 +35,37 @@ use frontier_rpc_primitives::{EthereumRuntimeRPCApi, TransactionStatus}; use sc_network::{NetworkService, ExHashT}; use crate::internal_err; -pub struct EthPubSubApi { +pub struct EthPubSubApi { _pool: Arc

, client: Arc, - select_chain: SC, network: Arc>, subscriptions: SubscriptionManager, _marker: PhantomData<(B, BE)>, } -impl EthPubSubApi { +impl EthPubSubApi { pub fn new( _pool: Arc

, client: Arc, - select_chain: SC, network: Arc>, subscriptions: SubscriptionManager, ) -> Self { - Self { _pool, client, select_chain, network, subscriptions, _marker: PhantomData } + Self { _pool, client, network, subscriptions, _marker: PhantomData } } } -impl EthPubSubApi where +impl EthPubSubApi where B: BlockT + Send + Sync + 'static, P: TransactionPool + Send + Sync + 'static, C: ProvideRuntimeApi + StorageProvider + - BlockchainEvents + HeaderBackend + AuxStore, + BlockchainEvents + AuxStore, + C: HeaderBackend + HeaderMetadata + 'static, C::Api: EthereumRuntimeRPCApi, C: Send + Sync + 'static, BE: Backend + 'static, BE::State: StateBackend, - SC: SelectChain + Clone + 'static, { fn native_block_number(&self, number: Option) -> JsonRpcResult> { - let header = self - .select_chain - .best_chain() - .map_err(|_| internal_err("fetch header failed"))?; - let mut native_number: Option = None; if let Some(number) = number { @@ -93,7 +85,7 @@ impl EthPubSubApi where }, BlockNumber::Latest => { native_number = Some( - header.number().clone().unique_saturated_into() as u32 + self.client.info().best_number.clone().unique_saturated_into() as u32 ); }, BlockNumber::Earliest => { @@ -105,7 +97,7 @@ impl EthPubSubApi where }; } else { native_number = Some( - header.number().clone().unique_saturated_into() as u32 + self.client.info().best_number.clone().unique_saturated_into() as u32 ); } Ok(native_number) @@ -382,17 +374,17 @@ macro_rules! stream_build { }}; } -impl EthPubSubApiT for EthPubSubApi +impl EthPubSubApiT for EthPubSubApi where B: BlockT + Send + Sync + 'static, P: TransactionPool + Send + Sync + 'static, C: ProvideRuntimeApi + StorageProvider + - BlockchainEvents + HeaderBackend + AuxStore, + BlockchainEvents + AuxStore, + C: HeaderBackend + HeaderMetadata + 'static, C: Send + Sync + 'static, C::Api: EthereumRuntimeRPCApi, BE: Backend + 'static, BE::State: StateBackend, - SC: SelectChain + Clone + 'static, { type Metadata = Metadata; fn subscribe( diff --git a/template/node/src/rpc.rs b/template/node/src/rpc.rs index 414d742afd..74ce5b5935 100644 --- a/template/node/src/rpc.rs +++ b/template/node/src/rpc.rs @@ -24,7 +24,6 @@ use frontier_template_runtime::{Hash, AccountId, Index, opaque::Block, Balance}; use sp_api::ProvideRuntimeApi; use sp_transaction_pool::TransactionPool; use sp_blockchain::{Error as BlockChainError, HeaderMetadata, HeaderBackend}; -use sp_consensus::SelectChain; use sc_rpc_api::DenyUnsafe; use sc_client_api::{ backend::{StorageProvider, Backend, StateBackend, AuxStore}, @@ -49,13 +48,11 @@ pub struct LightDeps { } /// Full client dependencies. -pub struct FullDeps { +pub struct FullDeps { /// The client instance to use. pub client: Arc, /// Transaction pool instance. pub pool: Arc

, - /// The SelectChain Strategy - pub select_chain: SC, /// Whether to deny unsafe calls pub deny_unsafe: DenyUnsafe, /// The Node authority flag @@ -67,15 +64,15 @@ pub struct FullDeps { } /// Instantiate all Full RPC extensions. -pub fn create_full( - deps: FullDeps, +pub fn create_full( + deps: FullDeps, subscription_task_executor: SubscriptionTaskExecutor ) -> jsonrpc_core::IoHandler where BE: Backend + 'static, BE::State: StateBackend, C: ProvideRuntimeApi + StorageProvider + AuxStore, C: BlockchainEvents, - C: HeaderBackend + HeaderMetadata + 'static, + C: HeaderBackend + HeaderMetadata, C: Send + Sync + 'static, C::Api: substrate_frame_rpc_system::AccountNonceApi, C::Api: BlockBuilder, @@ -83,7 +80,6 @@ pub fn create_full( C::Api: frontier_rpc_primitives::EthereumRuntimeRPCApi, ::Error: fmt::Debug, P: TransactionPool + 'static, - SC: SelectChain +'static, { use substrate_frame_rpc_system::{FullSystem, SystemApi}; use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi}; @@ -93,7 +89,6 @@ pub fn create_full( let FullDeps { client, pool, - select_chain, deny_unsafe, is_authority, network, @@ -109,7 +104,6 @@ pub fn create_full( io.extend_with( EthApiServer::to_delegate(EthApi::new( client.clone(), - select_chain.clone(), pool.clone(), frontier_template_runtime::TransactionConverter, is_authority, @@ -119,14 +113,12 @@ pub fn create_full( io.extend_with( NetApiServer::to_delegate(NetApi::new( client.clone(), - select_chain.clone(), )) ); io.extend_with( EthPubSubApiServer::to_delegate(EthPubSubApi::new( pool.clone(), client.clone(), - select_chain.clone(), network.clone(), SubscriptionManager::new(Arc::new(subscription_task_executor)), )) diff --git a/template/node/src/service.rs b/template/node/src/service.rs index 5acee24aa1..6997440b8e 100644 --- a/template/node/src/service.rs +++ b/template/node/src/service.rs @@ -181,14 +181,12 @@ pub fn new_full(config: Configuration, manual_seal: bool) -> Result Date: Fri, 2 Oct 2020 16:28:35 +0200 Subject: [PATCH 4/8] Use the new helper functions in ethereum crate (#151) * Update ethereum to 0.3.1 * fix: uncles_hash are ommers_hash * Update ethereum to 0.3.2 with export of PartialHeader * Use PartialHeader type * Remove sha3Uncles from test --- Cargo.lock | 6 +++--- Cargo.toml | 3 +-- frame/ethereum/src/lib.rs | 27 ++++++--------------------- rpc/src/eth.rs | 2 +- ts-tests/tests/test-block.ts | 2 -- 5 files changed, 11 insertions(+), 29 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 015d151ece..3fc40ef188 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1097,9 +1097,9 @@ dependencies = [ [[package]] name = "ethereum" -version = "0.3.0" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f873613a1191fe9d63794b5d0b636712446153ef0df192e9381bf1f951d3b94" +checksum = "da7fef4d2da1de3a4f4f85408379644276db9b46c4af7b0fe38a3debec5cb7cd" dependencies = [ "ethereum-types", "parity-scale-codec", @@ -7431,7 +7431,7 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3bfd5b7557925ce778ff9b9ef90e3ade34c524b5ff10e239c69a42d546d2af56" dependencies = [ - "rand 0.7.3", + "rand 0.3.23", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index f9b714d3d0..617395b329 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,5 +9,4 @@ members = [ "template/node", "template/runtime", "template/test-utils/client", -] -exclude = ["vendor"] \ No newline at end of file +] \ No newline at end of file diff --git a/frame/ethereum/src/lib.rs b/frame/ethereum/src/lib.rs index bf849ee612..e937b074d1 100644 --- a/frame/ethereum/src/lib.rs +++ b/frame/ethereum/src/lib.rs @@ -243,16 +243,11 @@ impl Module { } let ommers = Vec::::new(); - let header = ethereum::Header { + let partial_header = ethereum::PartialHeader { parent_hash: Self::current_block_hash().unwrap_or_default(), - ommers_hash: H256::from_slice( - Keccak256::digest(&rlp::encode_list(&ommers)[..]).as_slice(), - ), // TODO: check ommers hash. beneficiary: >::find_author(), - state_root: H256::default(), // TODO: figure out if there's better way to get a sort-of-valid state root. - transactions_root: H256::from_slice( - Keccak256::digest(&rlp::encode_list(&transactions)[..]).as_slice(), - ), // TODO: check transactions hash. + // TODO: figure out if there's better way to get a sort-of-valid state root. + state_root: H256::default(), receipts_root: H256::from_slice( Keccak256::digest(&rlp::encode_list(&receipts)[..]).as_slice(), ), // TODO: check receipts hash. @@ -272,13 +267,7 @@ impl Module { mix_hash: H256::default(), nonce: H64::default(), }; - let hash = Self::ethereum_block_hash(&header); - - let block = ethereum::Block { - header: header.clone(), - transactions: transactions.clone(), - ommers, - }; + let block = ethereum::Block::new(partial_header, transactions.clone(), ommers); let mut transaction_hashes = Vec::new(); @@ -296,7 +285,7 @@ impl Module { let digest = DigestItem::::Consensus( FRONTIER_ENGINE_ID, ConsensusLog::EndBlock { - block_hash: hash, + block_hash: block.header.hash(), transaction_hashes, }.encode(), ); @@ -323,7 +312,7 @@ impl Module { /// Get current block hash pub fn current_block_hash() -> Option { - Self::current_block().map(|block| Self::ethereum_block_hash(&block.header)) + Self::current_block().map(|block| block.header.hash()) } /// Get receipts by number. @@ -457,8 +446,4 @@ impl Module { ExitError::Other(_s) => return Error::::ExitErrorOther, } } - - fn ethereum_block_hash(header: ðereum::Header) -> H256 { - H256::from_slice(Keccak256::digest(&rlp::encode(header)).as_slice()) - } } diff --git a/rpc/src/eth.rs b/rpc/src/eth.rs index d02e354308..75831ee560 100644 --- a/rpc/src/eth.rs +++ b/rpc/src/eth.rs @@ -71,7 +71,7 @@ fn rich_block_build( ) })), parent_hash: block.header.parent_hash, - uncles_hash: H256::zero(), + uncles_hash: block.header.ommers_hash, author: block.header.beneficiary, miner: block.header.beneficiary, state_root: block.header.state_root, diff --git a/ts-tests/tests/test-block.ts b/ts-tests/tests/test-block.ts index e92b722f57..7efb9cb029 100644 --- a/ts-tests/tests/test-block.ts +++ b/ts-tests/tests/test-block.ts @@ -30,7 +30,6 @@ describeWithFrontier("Frontier RPC (Block)", `simple-specs.json`, (context) => { number: 0, //parentHash: "0x2cc74f91423ba20e9bb0b2c7d8924eacd14bc98aa1daad078f8844e529221cde", receiptsRoot: "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - sha3Uncles: "0x0000000000000000000000000000000000000000000000000000000000000000", size: 533, stateRoot: "0x0000000000000000000000000000000000000000000000000000000000000000", //timestamp: 1595012243836, @@ -84,7 +83,6 @@ describeWithFrontier("Frontier RPC (Block)", `simple-specs.json`, (context) => { number: 1, //parentHash: "0x04540257811b46d103d9896e7807040e7de5080e285841c5430d1a81588a0ce4", receiptsRoot: "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - sha3Uncles: "0x0000000000000000000000000000000000000000000000000000000000000000", size: 539, stateRoot: "0x0000000000000000000000000000000000000000000000000000000000000000", //timestamp: 1595012243836, From 0e9381c272feb1807779ab0ad7de90cd7799e023 Mon Sep 17 00:00:00 2001 From: Wei Tang Date: Fri, 2 Oct 2020 20:29:25 +0200 Subject: [PATCH 5/8] Small styling fixes for ts files (#152) * Small styling fixes for ts files * Combine contract-erc20 and contract-erc20-rpc --- .editorconfig | 5 + template/examples/contract-erc20/README.md | 33 +- .../contract-erc20/create-erc20-rpc.ts | 83 +++++ .../examples/contract-erc20/create-erc20.ts | 293 +++++++++--------- template/examples/contract-erc20/package.json | 2 +- .../tsconfig.json | 0 .../examples/contract-web3-rpc/.gitignore | 2 - template/examples/contract-web3-rpc/README.md | 11 - .../contract-web3-rpc/create-erc20.ts | 84 ----- .../examples/contract-web3-rpc/package.json | 9 - ts-tests/tests/test-block.ts | 4 +- 11 files changed, 264 insertions(+), 262 deletions(-) create mode 100755 template/examples/contract-erc20/create-erc20-rpc.ts rename template/examples/{contract-web3-rpc => contract-erc20}/tsconfig.json (100%) mode change 100755 => 100644 delete mode 100755 template/examples/contract-web3-rpc/.gitignore delete mode 100755 template/examples/contract-web3-rpc/README.md delete mode 100755 template/examples/contract-web3-rpc/create-erc20.ts delete mode 100644 template/examples/contract-web3-rpc/package.json diff --git a/.editorconfig b/.editorconfig index 0d412aa775..97bd27e878 100644 --- a/.editorconfig +++ b/.editorconfig @@ -12,4 +12,9 @@ insert_final_newline=true [*.toml] indent_style=tab indent_size=tab +tab_width=4 + +[*.ts] +indent_style=tab +indent_size=tab tab_width=4 \ No newline at end of file diff --git a/template/examples/contract-erc20/README.md b/template/examples/contract-erc20/README.md index 4a26485d50..d3a3ca5494 100644 --- a/template/examples/contract-erc20/README.md +++ b/template/examples/contract-erc20/README.md @@ -1,14 +1,20 @@ -# Frontier Template tutorial +# ERC20 contract creation -This directory contains typescript script describing the different topics presented by the frontier node template. +This directory contains typescript script describing the different +topics presented by the frontier node template. -## Installation and Usage +## Basic -Use `npm i` to install dependencies. To create an ERC20 contract, execute `node_modules/.bin/ts-node create-erc20.ts` while your template node is running in `--dev` mode. +### Installation and Usage -## Expected output +Use `npm i` to install dependencies. To create an ERC20 contract, +execute `node_modules/.bin/ts-node create-erc20.ts` while your +template node is running in `--dev` mode. + +### Expected output + +The ouput of the command should look similar to this: -The ouput of the command should look similar to this ``` └────╼ ts-node create-erc20.ts Initiating the API (ignore message "Unable to resolve type B..." and "Unknown types found...") @@ -53,3 +59,18 @@ Bob EVM Account (nonce: 0) balance: 0x000000000000000000000000000000000000000000 Bob Contract storage key: 0x0e4b5229940f8e2bf475520e854b789139893f70ee7b5ec9006de746028449fe Bob Contract account storage: 0x00000000000000000000000000000000000000000000000000000000000000dd ``` + +## RPC + +This section describes how to use the web3.js SDK to interact with +Frontier. + +## Installation and Usage + +Use `npm i` to install dependencies. To create an ERC20 contract, +execute `node_modules/.bin/ts-node create-erc20.ts` while your +template node is running in `--dev` mode. + +## Expected output + +WIP diff --git a/template/examples/contract-erc20/create-erc20-rpc.ts b/template/examples/contract-erc20/create-erc20-rpc.ts new file mode 100755 index 0000000000..92d18747f2 --- /dev/null +++ b/template/examples/contract-erc20/create-erc20-rpc.ts @@ -0,0 +1,83 @@ +import Web3 from "web3"; +import * as web3Utils from 'web3-utils'; + +const web3 = new Web3("http://localhost:9933"); +const ERC20_BYTECODE = require("./truffle/contracts/MyToken.json").bytecode; +const STORAGE_SLOT = "0"; + +const createAccount = () => { + const account = web3.eth.accounts.create(); + const mapStorageSlot = STORAGE_SLOT.padStart(64, '0'); + const mapKey = account.address.toString().substring(2).padStart(64, '0'); + const storageKey = web3Utils.sha3('0x'.concat(mapKey.concat(mapStorageSlot))); + return {...account, storageKey}; +} + +const main = async () => { + + console.log("Generating accounts..."); + const alice = createAccount(); + const bob = createAccount(); + + // Step 1: Creating the contract. + console.log(`Alice account: ${alice.address}\n storageKey [slot ${STORAGE_SLOT}]: ${alice.storageKey}`); + console.log(`Bob account: ${bob.address}\n storageKey [slot ${STORAGE_SLOT}]: ${bob.storageKey}`); + + console.log(`\nCreating contract using Eth RPC "sendTransaction" from alice`); + const createTransaction = await alice.signTransaction( + { + data: ERC20_BYTECODE, + value: "0x00", + gasPrice: "0x00", + gas: "0x100000", + }); + console.log("Transaction", { + ...createTransaction, + rawTransaction: `${createTransaction.rawTransaction.substring( + 0, + 32 + )}... (${createTransaction.rawTransaction.length} length)`, + }); + + const createReceipt = await web3.eth.sendSignedTransaction( + createTransaction.rawTransaction + ); + console.log( + `Contract deployed at address ${createReceipt.contractAddress}` + ); + + // Step 2: Sending contract tokens to bob + console.log(`\nSending 221 Contract tokens from alice to bob`); + const transferFnCode = `a9059cbb000000000000000000000000`; + const tokensToTransfer = `00000000000000000000000000000000000000000000000000000000000000dd`; + const inputCode = `0x${transferFnCode}${bob.address.substring( + 2 + )}${tokensToTransfer}`; + + const transferTransaction = await alice.signTransaction( + { + to: createReceipt.contractAddress, + data: inputCode, + value: "0x00", + gasPrice: "0x00", + gas: "0x100000", + }); + console.log("Transaction", { + ...transferTransaction, + rawTransaction: `${transferTransaction.rawTransaction.substring( + 0, + 32 + )}... (${transferTransaction.rawTransaction.length} length)`, + }); + + const transferReceipt = await web3.eth.sendSignedTransaction( + transferTransaction.rawTransaction + ); + console.log( + `Transfer executed to ${transferReceipt.to} (H: ${transferReceipt.transactionHash})` + ); +}; + +main().catch((err) => { + console.log("Error", err); +}); diff --git a/template/examples/contract-erc20/create-erc20.ts b/template/examples/contract-erc20/create-erc20.ts index e012a50e58..577a9b0cc4 100644 --- a/template/examples/contract-erc20/create-erc20.ts +++ b/template/examples/contract-erc20/create-erc20.ts @@ -4,201 +4,200 @@ import { U8aFixed } from '@polkadot/types/codec'; import * as web3Utils from 'web3-utils'; import * as crypto from '@polkadot/util-crypto'; - // Provider is set to localhost for development const wsProvider = new WsProvider("ws://localhost:9944"); // Keyring needed to sign using Alice account const keyring = new Keyring({ type: 'sr25519' }); -// ByteCode of our ERC20 exemple: copied from ../truffle/contracts/MyToken.json -const ERC20_BYTECODES = "0x608060405234801561001057600080fd5b50610041337fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61004660201b60201c565b610291565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156100e9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f45524332303a206d696e7420746f20746865207a65726f20616464726573730081525060200191505060405180910390fd5b6101028160025461020960201b610c7c1790919060201c565b60028190555061015d816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461020960201b610c7c1790919060201c565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b600080828401905083811015610287576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b610e3a806102a06000396000f3fe608060405234801561001057600080fd5b50600436106100885760003560e01c806370a082311161005b57806370a08231146101fd578063a457c2d714610255578063a9059cbb146102bb578063dd62ed3e1461032157610088565b8063095ea7b31461008d57806318160ddd146100f357806323b872dd146101115780633950935114610197575b600080fd5b6100d9600480360360408110156100a357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610399565b604051808215151515815260200191505060405180910390f35b6100fb6103b7565b6040518082815260200191505060405180910390f35b61017d6004803603606081101561012757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506103c1565b604051808215151515815260200191505060405180910390f35b6101e3600480360360408110156101ad57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061049a565b604051808215151515815260200191505060405180910390f35b61023f6004803603602081101561021357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061054d565b6040518082815260200191505060405180910390f35b6102a16004803603604081101561026b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610595565b604051808215151515815260200191505060405180910390f35b610307600480360360408110156102d157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610662565b604051808215151515815260200191505060405180910390f35b6103836004803603604081101561033757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610680565b6040518082815260200191505060405180910390f35b60006103ad6103a6610707565b848461070f565b6001905092915050565b6000600254905090565b60006103ce848484610906565b61048f846103da610707565b61048a85604051806060016040528060288152602001610d7060289139600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610440610707565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610bbc9092919063ffffffff16565b61070f565b600190509392505050565b60006105436104a7610707565b8461053e85600160006104b8610707565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610c7c90919063ffffffff16565b61070f565b6001905092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60006106586105a2610707565b8461065385604051806060016040528060258152602001610de160259139600160006105cc610707565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610bbc9092919063ffffffff16565b61070f565b6001905092915050565b600061067661066f610707565b8484610906565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610795576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180610dbd6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561081b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180610d286022913960400191505060405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561098c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180610d986025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610a12576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180610d056023913960400191505060405180910390fd5b610a7d81604051806060016040528060268152602001610d4a602691396000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610bbc9092919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610b10816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610c7c90919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290610c69576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610c2e578082015181840152602081019050610c13565b50505050905090810190601f168015610c5b5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b600080828401905083811015610cfa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b809150509291505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa265627a7a72315820c7a5ffabf642bda14700b2de42f8c57b36621af020441df825de45fd2b3e1c5c64736f6c63430005100032"; +// ByteCode of our ERC20 exemple: copied from ./truffle/contracts/MyToken.json +const ERC20_BYTECODES = require("./truffle/contracts/MyToken.json").bytecode; // Setup the API and Alice Account async function init() { - console.log(`Initiating the API (ignore message "Unable to resolve type B..." and "Unknown types found...")`); - - // Initiate the polkadot API. - const api = await ApiPromise.create({ - provider: wsProvider, - types: { - // mapping the actual specified address format - Address: "AccountId", - // mapping the lookup - LookupSource: "AccountId", - Account: { - nonce: "U256", - balance: "U256" - }, - Transaction: { - nonce: "U256", - action: "String", - gas_price: "u64", - gas_limit: "u64", - value: "U256", - input: "Vec", - signature: "Signature" - }, - Signature: { - v: "u64", - r: "H256", - s: "H256" - } - } - }); - console.log(`Initialiation done`); - console.log(`Genesis at block: ${api.genesisHash.toHex()}`); - - const alice = keyring.addFromUri('//Alice', { name: 'Alice default' }); - const bob = keyring.addFromUri('//Bob', { name: 'Bob default' }); - - const { nonce, data: balance } = await api.query.system.account(alice.address); - console.log(`Alice Substrate Account: ${alice.address}`); - console.log(`Alice Substrate Account (nonce: ${nonce}) balance, free: ${balance.free.toHex()}`); - - const aliceEvmAccount = `0x${crypto.blake2AsHex(crypto.decodeAddress(alice.address), 256).substring(26)}`; - - console.log(`Alice EVM Account: ${aliceEvmAccount}`); - const evmData = (await api.query.evm.accounts(aliceEvmAccount)) as any; - console.log(`Alice EVM Account (nonce: ${evmData.nonce}) balance: ${evmData.balance.toHex()}`); - - return { api, alice, bob }; + console.log(`Initiating the API (ignore message "Unable to resolve type B..." and "Unknown types found...")`); + + // Initiate the polkadot API. + const api = await ApiPromise.create({ + provider: wsProvider, + types: { + // mapping the actual specified address format + Address: "AccountId", + // mapping the lookup + LookupSource: "AccountId", + Account: { + nonce: "U256", + balance: "U256" + }, + Transaction: { + nonce: "U256", + action: "String", + gas_price: "u64", + gas_limit: "u64", + value: "U256", + input: "Vec", + signature: "Signature" + }, + Signature: { + v: "u64", + r: "H256", + s: "H256" + } + } + }); + console.log(`Initialiation done`); + console.log(`Genesis at block: ${api.genesisHash.toHex()}`); + + const alice = keyring.addFromUri('//Alice', { name: 'Alice default' }); + const bob = keyring.addFromUri('//Bob', { name: 'Bob default' }); + + const { nonce, data: balance } = await api.query.system.account(alice.address); + console.log(`Alice Substrate Account: ${alice.address}`); + console.log(`Alice Substrate Account (nonce: ${nonce}) balance, free: ${balance.free.toHex()}`); + + const aliceEvmAccount = `0x${crypto.blake2AsHex(crypto.decodeAddress(alice.address), 256).substring(26)}`; + + console.log(`Alice EVM Account: ${aliceEvmAccount}`); + const evmData = (await api.query.evm.accounts(aliceEvmAccount)) as any; + console.log(`Alice EVM Account (nonce: ${evmData.nonce}) balance: ${evmData.balance.toHex()}`); + + return { api, alice, bob }; } // Create the ERC20 contract from ALICE async function step1(api: ApiPromise, alice: KeyringPair) { - console.log(`\nStep 1: Creating Smart Contract`); - - // params: [bytecode, initialBalance, gasLimit, gasPrice], - // tx: api.tx.evm.create - - const transaction = await api.tx.evm.create(ERC20_BYTECODES, 0, 4294967295, 1, null); - - const contract = new Promise<{ block: string, address: string }>(async (resolve, reject) => { - const unsub = await transaction.signAndSend(alice, (result) => { - console.log(`Contract creation is ${result.status}`); - if (result.status.isInBlock) { - console.log(`Contract included at blockHash ${result.status.asInBlock}`); - console.log(`Waiting for finalization... (can take a minute)`); - } else if (result.status.isFinalized) { - const contractAddress = ( - result.events?.find( - event => event?.event?.index.toHex() == "0x0500" - )?.event.data[0] as any - ).address as string; - console.log(`Contract finalized at blockHash ${result.status.asFinalized}`); - console.log(`Contract address: ${contractAddress}`); - unsub(); - resolve({ - block: result.status.asFinalized.toString(), - address: contractAddress - }); - } - }); - }); - return contract; + console.log(`\nStep 1: Creating Smart Contract`); + + // params: [bytecode, initialBalance, gasLimit, gasPrice], + // tx: api.tx.evm.create + + const transaction = await api.tx.evm.create(ERC20_BYTECODES, 0, 4294967295, 1, null); + + const contract = new Promise<{ block: string, address: string }>(async (resolve, reject) => { + const unsub = await transaction.signAndSend(alice, (result) => { + console.log(`Contract creation is ${result.status}`); + if (result.status.isInBlock) { + console.log(`Contract included at blockHash ${result.status.asInBlock}`); + console.log(`Waiting for finalization... (can take a minute)`); + } else if (result.status.isFinalized) { + const contractAddress = ( + result.events?.find( + event => event?.event?.index.toHex() == "0x0500" + )?.event.data[0] as any + ).address as string; + console.log(`Contract finalized at blockHash ${result.status.asFinalized}`); + console.log(`Contract address: ${contractAddress}`); + unsub(); + resolve({ + block: result.status.asFinalized.toString(), + address: contractAddress + }); + } + }); + }); + return contract; } // Retrieve Alice & Contract Storage async function step2(api: ApiPromise, alice: KeyringPair, contractAddress: string) { - console.log(`\nStep 2: Retrieving Contract from evm address: ${contractAddress}`); + console.log(`\nStep 2: Retrieving Contract from evm address: ${contractAddress}`); - // Retrieve Alice account with new nonce value - const { nonce, data: balance } = await api.query.system.account(alice.address); - console.log(`Alice Substrate Account (nonce: ${nonce}) balance, free: ${balance.free}`); + // Retrieve Alice account with new nonce value + const { nonce, data: balance } = await api.query.system.account(alice.address); + console.log(`Alice Substrate Account (nonce: ${nonce}) balance, free: ${balance.free}`); - const accountCode = (await api.query.evm.accountCodes(contractAddress)).toString(); - console.log(`Contract account code: ${accountCode.substring(0, 16)}...${accountCode.substring(accountCode.length - 16)}`); + const accountCode = (await api.query.evm.accountCodes(contractAddress)).toString(); + console.log(`Contract account code: ${accountCode.substring(0, 16)}...${accountCode.substring(accountCode.length - 16)}`); - // Computing Contract Storage Slot, using slot 0 and alice EVM account - const aliceEvmAccount = `0x${crypto.blake2AsHex(crypto.decodeAddress(alice.address), 256).substring(26)}`; - const slot = "0"; - const mapStorageSlot = slot.padStart(64, '0'); - const mapKey = aliceEvmAccount.toString().substring(2).padStart(64, '0'); + // Computing Contract Storage Slot, using slot 0 and alice EVM account + const aliceEvmAccount = `0x${crypto.blake2AsHex(crypto.decodeAddress(alice.address), 256).substring(26)}`; + const slot = "0"; + const mapStorageSlot = slot.padStart(64, '0'); + const mapKey = aliceEvmAccount.toString().substring(2).padStart(64, '0'); - const storageKey = web3Utils.sha3('0x'.concat(mapKey.concat(mapStorageSlot))); - console.log(`Alice Contract storage key: ${storageKey}`); + const storageKey = web3Utils.sha3('0x'.concat(mapKey.concat(mapStorageSlot))); + console.log(`Alice Contract storage key: ${storageKey}`); - const accountStorage = (await api.query.evm.accountStorages(contractAddress, storageKey)).toString(); - console.log(`Alice Contract account storage: ${accountStorage}`); - return; + const accountStorage = (await api.query.evm.accountStorages(contractAddress, storageKey)).toString(); + console.log(`Alice Contract account storage: ${accountStorage}`); + return; } // Transfer tokens to Bob async function step3(api: ApiPromise, alice: KeyringPair, bob: KeyringPair, contractAddress: string) { - const bobEvmAccount = `0x${crypto.blake2AsHex(crypto.decodeAddress(bob.address), 256).substring(26)}`; - console.log(`\nStep 3: Transfering Tokens to Bob EVM Account: ${bobEvmAccount}`); - - console.log(`Preparing transfer of 0xdd`); - // params: [contractAddress, inputCode, value,m gasLimit, gasPrice], - // tx: api.tx.evm.create - const transferFnCode = `a9059cbb000000000000000000000000`; - const tokensToTransfer = `00000000000000000000000000000000000000000000000000000000000000dd`; - const inputCode = `0x${transferFnCode}${bobEvmAccount.substring(2)}${tokensToTransfer}`; - console.log(`Sending call input: ${inputCode}`); - const transaction = await api.tx.evm.call(contractAddress, inputCode, 0, 4294967295, 1, null); - - const data = new Promise<{ block: string, address: string }>(async (resolve, reject) => { - const unsub = await transaction.signAndSend(alice, (result) => { - console.log(`Transfer is ${result.status}`); - if (result.status.isInBlock) { - console.log(`Transfer included at blockHash ${result.status.asInBlock}`); - console.log(`Waiting for finalization... (can take a minute)`); - } else if (result.status.isFinalized) { - console.log(`Transfer finalized at blockHash ${result.status.asFinalized}`); - unsub(); - resolve(); - } - }); - }); - return data; + const bobEvmAccount = `0x${crypto.blake2AsHex(crypto.decodeAddress(bob.address), 256).substring(26)}`; + console.log(`\nStep 3: Transfering Tokens to Bob EVM Account: ${bobEvmAccount}`); + + console.log(`Preparing transfer of 0xdd`); + // params: [contractAddress, inputCode, value,m gasLimit, gasPrice], + // tx: api.tx.evm.create + const transferFnCode = `a9059cbb000000000000000000000000`; + const tokensToTransfer = `00000000000000000000000000000000000000000000000000000000000000dd`; + const inputCode = `0x${transferFnCode}${bobEvmAccount.substring(2)}${tokensToTransfer}`; + console.log(`Sending call input: ${inputCode}`); + const transaction = await api.tx.evm.call(contractAddress, inputCode, 0, 4294967295, 1, null); + + const data = new Promise<{ block: string, address: string }>(async (resolve, reject) => { + const unsub = await transaction.signAndSend(alice, (result) => { + console.log(`Transfer is ${result.status}`); + if (result.status.isInBlock) { + console.log(`Transfer included at blockHash ${result.status.asInBlock}`); + console.log(`Waiting for finalization... (can take a minute)`); + } else if (result.status.isFinalized) { + console.log(`Transfer finalized at blockHash ${result.status.asFinalized}`); + unsub(); + resolve(); + } + }); + }); + return data; } // Retrieve Bob async function step4(api: ApiPromise, bob: KeyringPair, contractAddress: string) { - console.log(`\nStep 4: Retrieving Bob tokens`); + console.log(`\nStep 4: Retrieving Bob tokens`); - // Retrieve Bob account with new nonce value - const { nonce, data: balance } = await api.query.system.account(bob.address); - console.log(`Bob Substrate Account (nonce: ${nonce}) balance, free: ${balance.free}`); - const bobEvmAccount = `0x${crypto.blake2AsHex(crypto.decodeAddress(bob.address), 256).substring(26)}`; + // Retrieve Bob account with new nonce value + const { nonce, data: balance } = await api.query.system.account(bob.address); + console.log(`Bob Substrate Account (nonce: ${nonce}) balance, free: ${balance.free}`); + const bobEvmAccount = `0x${crypto.blake2AsHex(crypto.decodeAddress(bob.address), 256).substring(26)}`; - console.log(`Bob EVM Account: ${bobEvmAccount}`); - const evmData = (await api.query.evm.accounts(bobEvmAccount)) as any; - console.log(`Bob EVM Account (nonce: ${evmData.nonce}) balance: ${evmData.balance.toHex()}`); + console.log(`Bob EVM Account: ${bobEvmAccount}`); + const evmData = (await api.query.evm.accounts(bobEvmAccount)) as any; + console.log(`Bob EVM Account (nonce: ${evmData.nonce}) balance: ${evmData.balance.toHex()}`); - const slot = "0"; - const mapStorageSlot = slot.padStart(64, '0'); - const mapKey = bobEvmAccount.toString().substring(2).padStart(64, '0'); + const slot = "0"; + const mapStorageSlot = slot.padStart(64, '0'); + const mapKey = bobEvmAccount.toString().substring(2).padStart(64, '0'); - const storageKey = web3Utils.sha3('0x'.concat(mapKey.concat(mapStorageSlot))); - console.log(`Bob Contract storage key: ${storageKey}`); + const storageKey = web3Utils.sha3('0x'.concat(mapKey.concat(mapStorageSlot))); + console.log(`Bob Contract storage key: ${storageKey}`); - const accountStorage = (await api.query.evm.accountStorages(contractAddress, storageKey)).toString(); - console.log(`Bob Contract account storage: ${accountStorage}`); + const accountStorage = (await api.query.evm.accountStorages(contractAddress, storageKey)).toString(); + console.log(`Bob Contract account storage: ${accountStorage}`); - return; + return; } async function main() { - const { api, alice, bob } = await init(); + const { api, alice, bob } = await init(); - // step 1: Creating the contract from ALICE - const contractAccount = await step1(api, alice) + // step 1: Creating the contract from ALICE + const contractAccount = await step1(api, alice) - // step 2: Retrieving Alice and Contract information - await step2(api, alice, contractAccount.address); + // step 2: Retrieving Alice and Contract information + await step2(api, alice, contractAccount.address); - // step 3: Transfering Smart Contract tokens from Alice to Bob - await step3(api, alice, bob, contractAccount.address); + // step 3: Transfering Smart Contract tokens from Alice to Bob + await step3(api, alice, bob, contractAccount.address); - // step 3: Retrieving Bob information - await step4(api, bob, contractAccount.address); + // step 3: Retrieving Bob information + await step4(api, bob, contractAccount.address); } main().catch(console.error).then(() => process.exit(0)); diff --git a/template/examples/contract-erc20/package.json b/template/examples/contract-erc20/package.json index e37d61a5d1..1a142aff95 100644 --- a/template/examples/contract-erc20/package.json +++ b/template/examples/contract-erc20/package.json @@ -1,5 +1,5 @@ { - "name": "frontier-tutorials", + "name": "frontier-template-contract-erc20", "version": "0.0.0", "dependencies": { "@polkadot/api": "^1.16.0-beta.2", diff --git a/template/examples/contract-web3-rpc/tsconfig.json b/template/examples/contract-erc20/tsconfig.json old mode 100755 new mode 100644 similarity index 100% rename from template/examples/contract-web3-rpc/tsconfig.json rename to template/examples/contract-erc20/tsconfig.json diff --git a/template/examples/contract-web3-rpc/.gitignore b/template/examples/contract-web3-rpc/.gitignore deleted file mode 100755 index 34b23da894..0000000000 --- a/template/examples/contract-web3-rpc/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/build/ -/node_modules/ diff --git a/template/examples/contract-web3-rpc/README.md b/template/examples/contract-web3-rpc/README.md deleted file mode 100755 index 5028e16e19..0000000000 --- a/template/examples/contract-web3-rpc/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# ERC20 contract creation (RPC) - -This directory contains typescript script describing how to use the web3.js SDK to interact with Frontier. - -## Installation and Usage - -Use `npm i` to install dependencies. To create an ERC20 contract, execute `node_modules/.bin/ts-node create-erc20.ts` while your template node is running in `--dev` mode. - -## Expected output - -WIP diff --git a/template/examples/contract-web3-rpc/create-erc20.ts b/template/examples/contract-web3-rpc/create-erc20.ts deleted file mode 100755 index 952d792679..0000000000 --- a/template/examples/contract-web3-rpc/create-erc20.ts +++ /dev/null @@ -1,84 +0,0 @@ -import Web3 from "web3"; -import * as web3Utils from 'web3-utils'; - -const web3 = new Web3("http://localhost:9933"); -const ERC20_BYTECODE = - "0x608060405234801561001057600080fd5b50610041337fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61004660201b60201c565b610291565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156100e9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f45524332303a206d696e7420746f20746865207a65726f20616464726573730081525060200191505060405180910390fd5b6101028160025461020960201b610c7c1790919060201c565b60028190555061015d816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461020960201b610c7c1790919060201c565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b600080828401905083811015610287576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b610e3a806102a06000396000f3fe608060405234801561001057600080fd5b50600436106100885760003560e01c806370a082311161005b57806370a08231146101fd578063a457c2d714610255578063a9059cbb146102bb578063dd62ed3e1461032157610088565b8063095ea7b31461008d57806318160ddd146100f357806323b872dd146101115780633950935114610197575b600080fd5b6100d9600480360360408110156100a357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610399565b604051808215151515815260200191505060405180910390f35b6100fb6103b7565b6040518082815260200191505060405180910390f35b61017d6004803603606081101561012757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506103c1565b604051808215151515815260200191505060405180910390f35b6101e3600480360360408110156101ad57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061049a565b604051808215151515815260200191505060405180910390f35b61023f6004803603602081101561021357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061054d565b6040518082815260200191505060405180910390f35b6102a16004803603604081101561026b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610595565b604051808215151515815260200191505060405180910390f35b610307600480360360408110156102d157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610662565b604051808215151515815260200191505060405180910390f35b6103836004803603604081101561033757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610680565b6040518082815260200191505060405180910390f35b60006103ad6103a6610707565b848461070f565b6001905092915050565b6000600254905090565b60006103ce848484610906565b61048f846103da610707565b61048a85604051806060016040528060288152602001610d7060289139600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610440610707565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610bbc9092919063ffffffff16565b61070f565b600190509392505050565b60006105436104a7610707565b8461053e85600160006104b8610707565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610c7c90919063ffffffff16565b61070f565b6001905092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60006106586105a2610707565b8461065385604051806060016040528060258152602001610de160259139600160006105cc610707565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610bbc9092919063ffffffff16565b61070f565b6001905092915050565b600061067661066f610707565b8484610906565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610795576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180610dbd6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561081b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180610d286022913960400191505060405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561098c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180610d986025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610a12576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180610d056023913960400191505060405180910390fd5b610a7d81604051806060016040528060268152602001610d4a602691396000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610bbc9092919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610b10816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610c7c90919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290610c69576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610c2e578082015181840152602081019050610c13565b50505050905090810190601f168015610c5b5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b600080828401905083811015610cfa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b809150509291505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa265627a7a72315820c7a5ffabf642bda14700b2de42f8c57b36621af020441df825de45fd2b3e1c5c64736f6c63430005100032"; -const STORAGE_SLOT = "0"; - -const createAccount = () => { - const account = web3.eth.accounts.create(); - const mapStorageSlot = STORAGE_SLOT.padStart(64, '0'); - const mapKey = account.address.toString().substring(2).padStart(64, '0'); - const storageKey = web3Utils.sha3('0x'.concat(mapKey.concat(mapStorageSlot))); - return {...account, storageKey}; -} - -const main = async () => { - - console.log("Generating accounts..."); - const alice = createAccount(); - const bob = createAccount(); - - // Step 1: Creating the contract. - console.log(`Alice account: ${alice.address}\n storageKey [slot ${STORAGE_SLOT}]: ${alice.storageKey}`); - console.log(`Bob account: ${bob.address}\n storageKey [slot ${STORAGE_SLOT}]: ${bob.storageKey}`); - - console.log(`\nCreating contract using Eth RPC "sendTransaction" from alice`); - const createTransaction = await alice.signTransaction( - { - data: ERC20_BYTECODE, - value: "0x00", - gasPrice: "0x00", - gas: "0x100000", - }); - console.log("Transaction", { - ...createTransaction, - rawTransaction: `${createTransaction.rawTransaction.substring( - 0, - 32 - )}... (${createTransaction.rawTransaction.length} length)`, - }); - - const createReceipt = await web3.eth.sendSignedTransaction( - createTransaction.rawTransaction - ); - console.log( - `Contract deployed at address ${createReceipt.contractAddress}` - ); - - // Step 2: Sending contract tokens to bob - console.log(`\nSending 221 Contract tokens from alice to bob`); - const transferFnCode = `a9059cbb000000000000000000000000`; - const tokensToTransfer = `00000000000000000000000000000000000000000000000000000000000000dd`; - const inputCode = `0x${transferFnCode}${bob.address.substring( - 2 - )}${tokensToTransfer}`; - - const transferTransaction = await alice.signTransaction( - { - to: createReceipt.contractAddress, - data: inputCode, - value: "0x00", - gasPrice: "0x00", - gas: "0x100000", - }); - console.log("Transaction", { - ...transferTransaction, - rawTransaction: `${transferTransaction.rawTransaction.substring( - 0, - 32 - )}... (${transferTransaction.rawTransaction.length} length)`, - }); - - const transferReceipt = await web3.eth.sendSignedTransaction( - transferTransaction.rawTransaction - ); - console.log( - `Transfer executed to ${transferReceipt.to} (H: ${transferReceipt.transactionHash})` - ); -}; - -main().catch((err) => { - console.log("Error", err); -}); diff --git a/template/examples/contract-web3-rpc/package.json b/template/examples/contract-web3-rpc/package.json deleted file mode 100644 index 15d5395ecd..0000000000 --- a/template/examples/contract-web3-rpc/package.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "frontier-contract-web3", - "version": "0.0.0", - "dependencies": { - "ts-node": "^8.10.1", - "typescript": "^3.9.3", - "web3": "^1.2.8" - } -} diff --git a/ts-tests/tests/test-block.ts b/ts-tests/tests/test-block.ts index 7efb9cb029..aba85a1d2f 100644 --- a/ts-tests/tests/test-block.ts +++ b/ts-tests/tests/test-block.ts @@ -60,8 +60,8 @@ describeWithFrontier("Frontier RPC (Block)", `simple-specs.json`, (context) => { step("should have valid timestamp after block production", async function () { const block = await context.web3.eth.getBlock("latest"); - const last5Minutes= (Date.now() / 1000) - 300; - const next5Minutes= (Date.now() / 1000) + 300; + const last5Minutes = (Date.now() / 1000) - 300; + const next5Minutes = (Date.now() / 1000) + 300; expect(block.timestamp).to.be.least(last5Minutes); expect(block.timestamp).to.be.below(next5Minutes); }); From cc1040c13f7e78aef94b8a5c4fcf0d1b05db0cd5 Mon Sep 17 00:00:00 2001 From: tgmichel Date: Mon, 5 Oct 2020 15:05:14 +0200 Subject: [PATCH 6/8] Improve `eth_getLogs` runtime access (#153) * Add `current_all` to EthereumRuntimeRPCApi * Use `TransactionStatus` only. * Fix checker --- rpc/primitives/src/lib.rs | 6 ++++++ rpc/src/eth.rs | 43 ++++++++++++++++--------------------- template/runtime/src/lib.rs | 12 +++++++++++ 3 files changed, 36 insertions(+), 25 deletions(-) diff --git a/rpc/primitives/src/lib.rs b/rpc/primitives/src/lib.rs index fadbcbceaa..59167598d3 100644 --- a/rpc/primitives/src/lib.rs +++ b/rpc/primitives/src/lib.rs @@ -80,6 +80,12 @@ sp_api::decl_runtime_apis! { fn current_receipts() -> Option>; /// Return the current transaction status. fn current_transaction_statuses() -> Option>; + /// Return all the current data for a block in a single runtime call. + fn current_all() -> ( + Option, + Option>, + Option> + ); } } diff --git a/rpc/src/eth.rs b/rpc/src/eth.rs index 75831ee560..64fa5306ef 100644 --- a/rpc/src/eth.rs +++ b/rpc/src/eth.rs @@ -719,7 +719,7 @@ impl EthApiT for EthApi where } fn logs(&self, filter: Filter) -> Result> { - let mut blocks_and_receipts = Vec::new(); + let mut blocks_and_statuses = Vec::new(); let mut ret = Vec::new(); if let Some(hash) = filter.block_hash { @@ -730,14 +730,12 @@ impl EthApiT for EthApi where _ => return Ok(Vec::new()), }; - let block = self.client.runtime_api() - .current_block(&id) + let (block, _, statuses) = self.client.runtime_api() + .current_all(&id) .map_err(|err| internal_err(format!("fetch runtime account basic failed: {:?}", err)))?; - let receipts = self.client.runtime_api().current_receipts(&id) - .map_err(|err| internal_err(format!("call runtime failed: {:?}", err)))?; - if let (Some(block), Some(receipts)) = (block, receipts) { - blocks_and_receipts.push((block, receipts)); + if let (Some(block), Some(statuses)) = (block, statuses) { + blocks_and_statuses.push((block, statuses)); } } else { let mut current_number = filter.to_block @@ -753,18 +751,15 @@ impl EthApiT for EthApi where .unwrap_or( self.client.info().best_number ); - while current_number >= from_number { let id = BlockId::Number(current_number); - let block = self.client.runtime_api() - .current_block(&id) + let (block, _, statuses) = self.client.runtime_api() + .current_all(&id) .map_err(|err| internal_err(format!("fetch runtime account basic failed: {:?}", err)))?; - let receipts = self.client.runtime_api().current_receipts(&id) - .map_err(|err| internal_err(format!("call runtime failed: {:?}", err)))?; - if let (Some(block), Some(receipts)) = (block, receipts) { - blocks_and_receipts.push((block, receipts)); + if let (Some(block), Some(statuses)) = (block, statuses) { + blocks_and_statuses.push((block, statuses)); } if current_number == Zero::zero() { @@ -775,15 +770,15 @@ impl EthApiT for EthApi where } } - for (block, receipts) in blocks_and_receipts { + for (block, statuses) in blocks_and_statuses { let mut block_log_index: u32 = 0; - for (index, receipt) in receipts.iter().enumerate() { - let logs = receipt.logs.clone(); + 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 = &block.transactions[index as usize]; - let transaction_hash = H256::from_slice( - Keccak256::digest(&rlp::encode(transaction)).as_slice() - ); + let transaction_hash = status.transaction_hash; for log in logs { let mut add: bool = false; if let ( @@ -810,12 +805,10 @@ impl EthApiT for EthApi where address: log.address.clone(), topics: log.topics.clone(), data: Bytes(log.data.clone()), - block_hash: Some(H256::from_slice( - Keccak256::digest(&rlp::encode(&block.header)).as_slice() - )), + block_hash: Some(block_hash), block_number: Some(block.header.number.clone()), transaction_hash: Some(transaction_hash), - transaction_index: Some(U256::from(index)), + transaction_index: Some(U256::from(status.transaction_index)), log_index: Some(U256::from(block_log_index)), transaction_log_index: Some(U256::from(transaction_log_index)), removed: false, diff --git a/template/runtime/src/lib.rs b/template/runtime/src/lib.rs index e558cfb5fa..d34afa9d31 100644 --- a/template/runtime/src/lib.rs +++ b/template/runtime/src/lib.rs @@ -553,6 +553,18 @@ impl_runtime_apis! { fn current_receipts() -> Option> { Ethereum::current_receipts() } + + fn current_all() -> ( + Option, + Option>, + Option> + ) { + ( + Ethereum::current_block(), + Ethereum::current_receipts(), + Ethereum::current_transaction_statuses() + ) + } } impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi< From 428e2cd980fc0e5417f334a137b224511442be56 Mon Sep 17 00:00:00 2001 From: Wei Tang Date: Mon, 5 Oct 2020 15:46:06 +0200 Subject: [PATCH 7/8] Add some badges to README (#154) --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e0c569963b..4411b7db55 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # Frontier +![GitHub Workflow Status](https://img.shields.io/github/workflow/status/paritytech/frontier/Rust) +![Matrix](https://img.shields.io/matrix/frontier:matrix.org) + Frontier is Substrate's Ethereum compatibility layer. It allows you to run unmodified Ethereum dapps. @@ -57,4 +60,4 @@ git submodule update 1. Override your local cargo config to point to your local substrate (pointing to your WIP branch): place `paths = ["path/to/substrate"]` in `~/.cargo/config`. 2. You are good to go. -Remember to comment out the override after it is done to avoid mysterious build issues on other repo. \ No newline at end of file +Remember to comment out the override after it is done to avoid mysterious build issues on other repo. From 085ed1611a926d8c351786b43af058b2f18abadf Mon Sep 17 00:00:00 2001 From: tgmichel Date: Tue, 6 Oct 2020 16:56:02 +0200 Subject: [PATCH 8/8] Fix bug transaction index --- rpc/src/eth_pubsub.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/rpc/src/eth_pubsub.rs b/rpc/src/eth_pubsub.rs index 2eb69fa3c9..337b008672 100644 --- a/rpc/src/eth_pubsub.rs +++ b/rpc/src/eth_pubsub.rs @@ -305,8 +305,15 @@ impl SubscriptionResult { )); let mut logs: Vec = vec![]; let mut log_index: u32 = 0; - for receipt in receipts { + for (receipt_index, receipt) in receipts.into_iter().enumerate() { let mut transaction_log_index: u32 = 0; + let transaction_hash: Option = if receipt.logs.len() > 0 { + Some(H256::from_slice( + Keccak256::digest(&rlp::encode( + &block.transactions[receipt_index as usize] + )).as_slice() + )) + } else { None }; for log in receipt.logs { if self.add_log( block_hash.unwrap(), @@ -320,11 +327,7 @@ impl SubscriptionResult { data: Bytes(log.data), block_hash: block_hash, block_number: Some(block.header.number), - transaction_hash: Some(H256::from_slice( - Keccak256::digest(&rlp::encode( - &block.transactions[log_index as usize] - )).as_slice() - )), + transaction_hash: transaction_hash, transaction_index: Some(U256::from(log_index)), log_index: Some(U256::from(log_index)), transaction_log_index: Some(U256::from(