From b5f49f70cca468236165be2f4a4070437cd42020 Mon Sep 17 00:00:00 2001 From: tgmichel Date: Thu, 1 Sep 2022 11:25:19 +0200 Subject: [PATCH 01/21] Public visibility for `validate_common` (#833) --- primitives/evm/src/validation.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/primitives/evm/src/validation.rs b/primitives/evm/src/validation.rs index 85670090d7..4913d5dfdc 100644 --- a/primitives/evm/src/validation.rs +++ b/primitives/evm/src/validation.rs @@ -178,7 +178,7 @@ impl<'config, E: From> CheckEvmTransaction<'config, } } - fn validate_common(&self) -> Result<&Self, E> { + pub fn validate_common(&self) -> Result<&Self, E> { if self.config.is_transactional { // We must ensure a transaction can pay the cost of its data bytes. // If it can't it should not be included in a block. From 233173e079327a7d6fa88f741f154127cd002e92 Mon Sep 17 00:00:00 2001 From: tgmichel Date: Sun, 4 Sep 2022 07:47:12 +0200 Subject: [PATCH 02/21] Support `ExitError::InvalidCode` in gas estimation (#840) * Pin evm * Support `InvalidCode` in gas estimation * Add ts test * EOF new line --- Cargo.lock | 8 +++--- client/rpc/Cargo.toml | 2 +- client/rpc/src/eth/execute.rs | 4 ++- frame/ethereum/Cargo.toml | 2 +- frame/evm/Cargo.toml | 2 +- frame/evm/test-vector-support/Cargo.toml | 2 +- primitives/evm/Cargo.toml | 2 +- ts-tests/contracts/InvalidOpcode.sol | 15 +++++++++++ ts-tests/tests/test-gas.ts | 33 ++++++++++++++++++++++++ 9 files changed, 60 insertions(+), 10 deletions(-) create mode 100644 ts-tests/contracts/InvalidOpcode.sol diff --git a/Cargo.lock b/Cargo.lock index 2feb2e240e..43451c0b70 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1516,7 +1516,7 @@ checksum = "f7531096570974c3a9dcf9e4b8e1cede1ec26cf5046219fb3b9d897503b9be59" [[package]] name = "evm" version = "0.35.0" -source = "git+https://github.com/rust-blockchain/evm?rev=01bcbd2205a212c34451d3b4fabc962793b057d3#01bcbd2205a212c34451d3b4fabc962793b057d3" +source = "git+https://github.com/rust-blockchain/evm?rev=51b8c2ce3104265e1fd5bb0fe5cdfd2e0938239c#51b8c2ce3104265e1fd5bb0fe5cdfd2e0938239c" dependencies = [ "auto_impl", "environmental", @@ -1536,7 +1536,7 @@ dependencies = [ [[package]] name = "evm-core" version = "0.35.0" -source = "git+https://github.com/rust-blockchain/evm?rev=01bcbd2205a212c34451d3b4fabc962793b057d3#01bcbd2205a212c34451d3b4fabc962793b057d3" +source = "git+https://github.com/rust-blockchain/evm?rev=51b8c2ce3104265e1fd5bb0fe5cdfd2e0938239c#51b8c2ce3104265e1fd5bb0fe5cdfd2e0938239c" dependencies = [ "parity-scale-codec", "primitive-types", @@ -1547,7 +1547,7 @@ dependencies = [ [[package]] name = "evm-gasometer" version = "0.35.0" -source = "git+https://github.com/rust-blockchain/evm?rev=01bcbd2205a212c34451d3b4fabc962793b057d3#01bcbd2205a212c34451d3b4fabc962793b057d3" +source = "git+https://github.com/rust-blockchain/evm?rev=51b8c2ce3104265e1fd5bb0fe5cdfd2e0938239c#51b8c2ce3104265e1fd5bb0fe5cdfd2e0938239c" dependencies = [ "environmental", "evm-core", @@ -1558,7 +1558,7 @@ dependencies = [ [[package]] name = "evm-runtime" version = "0.35.0" -source = "git+https://github.com/rust-blockchain/evm?rev=01bcbd2205a212c34451d3b4fabc962793b057d3#01bcbd2205a212c34451d3b4fabc962793b057d3" +source = "git+https://github.com/rust-blockchain/evm?rev=51b8c2ce3104265e1fd5bb0fe5cdfd2e0938239c#51b8c2ce3104265e1fd5bb0fe5cdfd2e0938239c" dependencies = [ "auto_impl", "environmental", diff --git a/client/rpc/Cargo.toml b/client/rpc/Cargo.toml index 330f1b10c8..2edb5da072 100644 --- a/client/rpc/Cargo.toml +++ b/client/rpc/Cargo.toml @@ -12,7 +12,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] ethereum = { version = "0.12.0", features = ["with-codec"] } -evm = { git = "https://github.com/rust-blockchain/evm", rev = "01bcbd2205a212c34451d3b4fabc962793b057d3" } +evm = { git = "https://github.com/rust-blockchain/evm", rev = "51b8c2ce3104265e1fd5bb0fe5cdfd2e0938239c" } futures = "0.3.21" hex = "0.4.3" log = "0.4.17" diff --git a/client/rpc/src/eth/execute.rs b/client/rpc/src/eth/execute.rs index f9888c23e7..355c041bdd 100644 --- a/client/rpc/src/eth/execute.rs +++ b/client/rpc/src/eth/execute.rs @@ -684,7 +684,9 @@ where } previous_highest = highest; } - ExitReason::Revert(_) | ExitReason::Error(ExitError::OutOfGas) => { + ExitReason::Revert(_) + | ExitReason::Error(ExitError::OutOfGas) + | ExitReason::Error(ExitError::InvalidCode(_)) => { lowest = mid; } other => error_on_execution_failure(&other, &data)?, diff --git a/frame/ethereum/Cargo.toml b/frame/ethereum/Cargo.toml index fa92c6e8e7..33bc9bb96a 100644 --- a/frame/ethereum/Cargo.toml +++ b/frame/ethereum/Cargo.toml @@ -12,7 +12,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] ethereum = { version = "0.12.0", default-features = false, features = ["with-codec"] } -evm = { git = "https://github.com/rust-blockchain/evm", rev = "01bcbd2205a212c34451d3b4fabc962793b057d3", features = ["with-codec"], default-features = false } +evm = { git = "https://github.com/rust-blockchain/evm", rev = "51b8c2ce3104265e1fd5bb0fe5cdfd2e0938239c", features = ["with-codec"], default-features = false } serde = { version = "1.0.144", optional = true } # Parity diff --git a/frame/evm/Cargo.toml b/frame/evm/Cargo.toml index d749ec9a8a..eefb26cf5b 100644 --- a/frame/evm/Cargo.toml +++ b/frame/evm/Cargo.toml @@ -12,7 +12,7 @@ repository = "https://github.com/paritytech/frontier/" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -evm = { git = "https://github.com/rust-blockchain/evm", rev = "01bcbd2205a212c34451d3b4fabc962793b057d3", default-features = false, features = ["with-codec"] } +evm = { git = "https://github.com/rust-blockchain/evm", rev = "51b8c2ce3104265e1fd5bb0fe5cdfd2e0938239c", default-features = false, features = ["with-codec"] } hex = { version = "0.4.3", default-features = false, features = ["alloc"] } log = { version = "0.4.17", default-features = false } serde = { version = "1.0.144", optional = true, features = ["derive"] } diff --git a/frame/evm/test-vector-support/Cargo.toml b/frame/evm/test-vector-support/Cargo.toml index 22507153d3..8c17b94f25 100644 --- a/frame/evm/test-vector-support/Cargo.toml +++ b/frame/evm/test-vector-support/Cargo.toml @@ -8,7 +8,7 @@ description = "Test vector support for EVM pallet." repository = "https://github.com/paritytech/frontier/" [dependencies] -evm = { git = "https://github.com/rust-blockchain/evm", rev = "01bcbd2205a212c34451d3b4fabc962793b057d3", features = ["with-codec"] } +evm = { git = "https://github.com/rust-blockchain/evm", rev = "51b8c2ce3104265e1fd5bb0fe5cdfd2e0938239c", features = ["with-codec"] } hex = "0.4.3" serde = { version = "1.0.101", features = ["derive"] } serde_json = "1.0" diff --git a/primitives/evm/Cargo.toml b/primitives/evm/Cargo.toml index 66fb825a02..aa4a52cc5a 100644 --- a/primitives/evm/Cargo.toml +++ b/primitives/evm/Cargo.toml @@ -11,7 +11,7 @@ repository = "https://github.com/paritytech/frontier/" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -evm = { git = "https://github.com/rust-blockchain/evm", rev = "01bcbd2205a212c34451d3b4fabc962793b057d3", default-features = false, features = ["with-codec"] } +evm = { git = "https://github.com/rust-blockchain/evm", rev = "51b8c2ce3104265e1fd5bb0fe5cdfd2e0938239c", default-features = false, features = ["with-codec"] } serde = { version = "1.0.144", features = ["derive"], optional = true } # Parity diff --git a/ts-tests/contracts/InvalidOpcode.sol b/ts-tests/contracts/InvalidOpcode.sol new file mode 100644 index 0000000000..c16dd6638b --- /dev/null +++ b/ts-tests/contracts/InvalidOpcode.sol @@ -0,0 +1,15 @@ +pragma solidity >=0.8.0; + +contract InvalidOpcode { + uint public number; + + function call() public { + number = 1; + if (gasleft() < 40000 ){ + assembly { + // Calls the INVALID opcode (0xFE) + invalid() + } + } + } +} diff --git a/ts-tests/tests/test-gas.ts b/ts-tests/tests/test-gas.ts index 4a89b1f1e4..0f4e1191e1 100644 --- a/ts-tests/tests/test-gas.ts +++ b/ts-tests/tests/test-gas.ts @@ -1,6 +1,7 @@ import { expect } from "chai"; import { AbiItem } from "web3-utils"; +import InvalidOpcode from "../build/contracts/InvalidOpcode.json"; import Test from "../build/contracts/Test.json"; import { GENESIS_ACCOUNT, GENESIS_ACCOUNT_PRIVATE_KEY, FIRST_CONTRACT_ADDRESS } from "./config"; import { describeWithFrontier, createAndFinalizeBlock, customRequest } from "./util"; @@ -187,3 +188,35 @@ describeWithFrontier("Frontier RPC (Gas)", (context) => { expect((createReceipt as any).error.message).to.equal("gas limit reached"); }); }); + +describeWithFrontier("Frontier RPC (Invalid opcode estimate gas)", (context) => { + const INVALID_OPCODE_BYTECODE = InvalidOpcode.bytecode; + + let contractAddess; + before(async () => { + const tx = await context.web3.eth.accounts.signTransaction( + { + from: GENESIS_ACCOUNT, + data: INVALID_OPCODE_BYTECODE, + value: "0x00", + gasPrice: "0x3B9ACA00", + gas: "0x100000", + }, + GENESIS_ACCOUNT_PRIVATE_KEY + ); + const txHash = (await customRequest(context.web3, "eth_sendRawTransaction", [tx.rawTransaction])).result; + await createAndFinalizeBlock(context.web3); + contractAddess = (await context.web3.eth.getTransactionReceipt(txHash)).contractAddress; + }); + + it("should estimate gas with invalid opcode", async function () { + let estimate = await context.web3.eth.estimateGas({ + from: GENESIS_ACCOUNT, + to: contractAddess, + data: "0x28b5e32b", // selector for the contract's `call` method + }); + // The actual estimated value is irrelevant for this test purposes, we just want to verify that + // the binary search is not interrupted when an InvalidCode is returned by the evm. + expect(estimate).to.equal(85703); + }); +}); From 7c96d95d906b5b1d617933fcc081a3015cdd9c4b Mon Sep 17 00:00:00 2001 From: tgmichel Date: Tue, 6 Sep 2022 06:04:27 +0200 Subject: [PATCH 03/21] Remove unwraps in RPC `pending_runtime_api` (#842) * Remove unwraps in RPC `pending_runtime_api` * clippy --- client/rpc/src/eth/mod.rs | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/client/rpc/src/eth/mod.rs b/client/rpc/src/eth/mod.rs index d5a8e3f2fd..110785f675 100644 --- a/client/rpc/src/eth/mod.rs +++ b/client/rpc/src/eth/mod.rs @@ -482,13 +482,19 @@ where .map(|in_pool_tx| in_pool_tx.data().clone()) .collect::::Extrinsic>>(); // Manually initialize the overlay. - let header = client.header(best).unwrap().unwrap(); - let parent_hash = BlockId::Hash(*header.parent_hash()); - api.initialize_block(&parent_hash, &header) - .map_err(|e| internal_err(format!("Runtime api access error: {:?}", e)))?; - // Apply the ready queue to the best block's state. - for xt in xts { - let _ = api.apply_extrinsic(&best, xt); - } - Ok(api) + if let Ok(Some(header)) = client.header(best) { + let parent_hash = BlockId::Hash(*header.parent_hash()); + api.initialize_block(&parent_hash, &header) + .map_err(|e| internal_err(format!("Runtime api access error: {:?}", e)))?; + // Apply the ready queue to the best block's state. + for xt in xts { + let _ = api.apply_extrinsic(&best, xt); + } + Ok(api) + } else { + Err(internal_err(format!( + "Cannot get header for block {:?}", + best + ))) + } } From 06eb4f258fb4e5df59409d479e7b89aff6417244 Mon Sep 17 00:00:00 2001 From: tgmichel Date: Thu, 8 Sep 2022 10:54:16 +0200 Subject: [PATCH 04/21] Handle `earliest` tag for `BlockNumber` (#836) * Handle `earliest` tag for `BlockNumber` * Add ts-test * editorconfig * prettier --- client/rpc-core/src/types/block_number.rs | 10 ++++ ts-tests/tests/test-log-tags.ts | 57 +++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 ts-tests/tests/test-log-tags.ts diff --git a/client/rpc-core/src/types/block_number.rs b/client/rpc-core/src/types/block_number.rs index 986bbafe2d..1ece65e96f 100644 --- a/client/rpc-core/src/types/block_number.rs +++ b/client/rpc-core/src/types/block_number.rs @@ -63,6 +63,7 @@ impl BlockNumber { pub fn to_min_block_num(&self) -> Option { match *self { BlockNumber::Num(ref x) => Some(*x), + BlockNumber::Earliest => Some(0), _ => None, } } @@ -193,6 +194,9 @@ mod tests { fn match_block_number(block_number: BlockNumber) -> Option { match block_number { BlockNumber::Num(number) => Some(number), + BlockNumber::Earliest => Some(0), + BlockNumber::Latest => Some(1000), + BlockNumber::Pending => Some(1001), _ => None, } } @@ -202,9 +206,15 @@ mod tests { let bn_dec: BlockNumber = serde_json::from_str(r#""42""#).unwrap(); let bn_hex: BlockNumber = serde_json::from_str(r#""0x45""#).unwrap(); let bn_u64: BlockNumber = serde_json::from_str(r#"420"#).unwrap(); + let bn_tag_earliest: BlockNumber = serde_json::from_str(r#""earliest""#).unwrap(); + let bn_tag_latest: BlockNumber = serde_json::from_str(r#""latest""#).unwrap(); + let bn_tag_pending: BlockNumber = serde_json::from_str(r#""pending""#).unwrap(); assert_eq!(match_block_number(bn_dec).unwrap(), 42); assert_eq!(match_block_number(bn_hex).unwrap(), 69); assert_eq!(match_block_number(bn_u64).unwrap(), 420); + assert_eq!(match_block_number(bn_tag_earliest).unwrap(), 0); + assert_eq!(match_block_number(bn_tag_latest).unwrap(), 1000); + assert_eq!(match_block_number(bn_tag_pending).unwrap(), 1001); } } diff --git a/ts-tests/tests/test-log-tags.ts b/ts-tests/tests/test-log-tags.ts new file mode 100644 index 0000000000..94f7f3203e --- /dev/null +++ b/ts-tests/tests/test-log-tags.ts @@ -0,0 +1,57 @@ +import { expect } from "chai"; +import { step } from "mocha-steps"; +import { TransactionReceipt } from "web3-core"; + +import { GENESIS_ACCOUNT, GENESIS_ACCOUNT_PRIVATE_KEY } from "./config"; +import { createAndFinalizeBlock, describeWithFrontier, customRequest } from "./util"; + +describeWithFrontier("Frontier RPC (Log BlockNumber tags)", (context) => { + const TEST_CONTRACT_BYTECODE = + "0x608060405234801561001057600080fd5b50610041337fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61004660201b60201c565b610291565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156100e9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f45524332303a206d696e7420746f20746865207a65726f20616464726573730081525060200191505060405180910390fd5b6101028160025461020960201b610c7c1790919060201c565b60028190555061015d816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461020960201b610c7c1790919060201c565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b600080828401905083811015610287576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b610e3a806102a06000396000f3fe608060405234801561001057600080fd5b50600436106100885760003560e01c806370a082311161005b57806370a08231146101fd578063a457c2d714610255578063a9059cbb146102bb578063dd62ed3e1461032157610088565b8063095ea7b31461008d57806318160ddd146100f357806323b872dd146101115780633950935114610197575b600080fd5b6100d9600480360360408110156100a357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610399565b604051808215151515815260200191505060405180910390f35b6100fb6103b7565b6040518082815260200191505060405180910390f35b61017d6004803603606081101561012757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506103c1565b604051808215151515815260200191505060405180910390f35b6101e3600480360360408110156101ad57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061049a565b604051808215151515815260200191505060405180910390f35b61023f6004803603602081101561021357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061054d565b6040518082815260200191505060405180910390f35b6102a16004803603604081101561026b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610595565b604051808215151515815260200191505060405180910390f35b610307600480360360408110156102d157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610662565b604051808215151515815260200191505060405180910390f35b6103836004803603604081101561033757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610680565b6040518082815260200191505060405180910390f35b60006103ad6103a6610707565b848461070f565b6001905092915050565b6000600254905090565b60006103ce848484610906565b61048f846103da610707565b61048a85604051806060016040528060288152602001610d7060289139600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610440610707565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610bbc9092919063ffffffff16565b61070f565b600190509392505050565b60006105436104a7610707565b8461053e85600160006104b8610707565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610c7c90919063ffffffff16565b61070f565b6001905092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60006106586105a2610707565b8461065385604051806060016040528060258152602001610de160259139600160006105cc610707565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610bbc9092919063ffffffff16565b61070f565b6001905092915050565b600061067661066f610707565b8484610906565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610795576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180610dbd6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561081b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180610d286022913960400191505060405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561098c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180610d986025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610a12576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180610d056023913960400191505060405180910390fd5b610a7d81604051806060016040528060268152602001610d4a602691396000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610bbc9092919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610b10816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610c7c90919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290610c69576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610c2e578082015181840152602081019050610c13565b50505050905090810190601f168015610c5b5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b600080828401905083811015610cfa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b809150509291505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa265627a7a72315820c7a5ffabf642bda14700b2de42f8c57b36621af020441df825de45fd2b3e1c5c64736f6c63430005100032"; + + const EXPECTED_LOGS = 3; + + async function sendTransaction(context) { + const tx = await context.web3.eth.accounts.signTransaction( + { + from: GENESIS_ACCOUNT, + data: TEST_CONTRACT_BYTECODE, + value: "0x00", + gasPrice: "0x3B9ACA00", + gas: "0x100000", + }, + GENESIS_ACCOUNT_PRIVATE_KEY + ); + + await customRequest(context.web3, "eth_sendRawTransaction", [tx.rawTransaction]); + return tx; + } + + before("Send some transactions across blocks", async function () { + for (var i = 0; i < EXPECTED_LOGS; i++) { + await sendTransaction(context); + await createAndFinalizeBlock(context.web3); + } + }); + + step("EthFilterApi::getFilterLogs - should handle earliest and latest tags", async function () { + let createFilter = await customRequest(context.web3, "eth_newFilter", [ + { + fromBlock: "earliest", + toBlock: "latest", + }, + ]); + let poll = await customRequest(context.web3, "eth_getFilterLogs", [createFilter.result]); + expect(poll.result.length).to.be.eq(EXPECTED_LOGS); + }); + + step("EthApi::getLogs - should handle earliest and latest tags", async function () { + let request = await customRequest(context.web3, "eth_getLogs", [ + { + fromBlock: "earliest", + toBlock: "latest", + }, + ]); + expect(request.result.length).to.be.eq(EXPECTED_LOGS); + }); +}); From 02ae871d6eb77c51147419c3210feaf3d7bfc945 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 9 Sep 2022 09:13:30 +0200 Subject: [PATCH 05/21] Bump thiserror from 1.0.32 to 1.0.34 (#845) Bumps [thiserror](https://github.com/dtolnay/thiserror) from 1.0.32 to 1.0.34. - [Release notes](https://github.com/dtolnay/thiserror/releases) - [Commits](https://github.com/dtolnay/thiserror/compare/1.0.32...1.0.34) --- updated-dependencies: - dependency-name: thiserror dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 43451c0b70..d7d1164408 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8127,18 +8127,18 @@ checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb" [[package]] name = "thiserror" -version = "1.0.32" +version = "1.0.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5f6586b7f764adc0231f4c79be7b920e766bb2f3e51b3661cdb263828f19994" +checksum = "8c1b05ca9d106ba7d2e31a9dab4a64e7be2cce415321966ea3132c49a656e252" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.32" +version = "1.0.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12bafc5b54507e0149cdf1b145a5d80ab80a90bcd9275df43d4fff68460f6c21" +checksum = "e8f2591983642de85c921015f3f070c665a197ed69e417af436115e3a1407487" dependencies = [ "proc-macro2", "quote", @@ -8499,7 +8499,7 @@ checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ "cfg-if", "digest 0.10.3", - "rand 0.7.3", + "rand 0.8.5", "static_assertions", ] From 8cc07553937a9fcb9f42d78d9ea05df5f10c1af9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 9 Sep 2022 09:13:39 +0200 Subject: [PATCH 06/21] Bump clap from 3.2.17 to 3.2.20 (#844) Bumps [clap](https://github.com/clap-rs/clap) from 3.2.17 to 3.2.20. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/v3.2.20/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v3.2.17...v3.2.20) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d7d1164408..7bad0293b6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -784,9 +784,9 @@ dependencies = [ [[package]] name = "clap" -version = "3.2.17" +version = "3.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29e724a68d9319343bb3328c9cc2dfde263f4b3142ee1059a9980580171c954b" +checksum = "23b71c3ce99b7611011217b366d923f1d0a7e07a92bb2dbf1e84508c673ca3bd" dependencies = [ "atty", "bitflags", @@ -801,9 +801,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "3.2.17" +version = "3.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13547f7012c01ab4a0e8f8967730ada8f9fdf419e8b6c792788f39cf4e46eefa" +checksum = "ea0c8bce528c4be4da13ea6fead8965e95b6073585a2f05204bd8f4119f82a65" dependencies = [ "heck", "proc-macro-error", From 96ba32ac450d046bf65837047bebc17cd28fd808 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 9 Sep 2022 09:13:49 +0200 Subject: [PATCH 07/21] Bump futures from 0.3.21 to 0.3.24 (#831) Bumps [futures](https://github.com/rust-lang/futures-rs) from 0.3.21 to 0.3.24. - [Release notes](https://github.com/rust-lang/futures-rs/releases) - [Changelog](https://github.com/rust-lang/futures-rs/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-lang/futures-rs/compare/0.3.21...0.3.24) --- updated-dependencies: - dependency-name: futures dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 36 +++++++++++++++++----------------- client/mapping-sync/Cargo.toml | 2 +- client/rpc/Cargo.toml | 2 +- template/node/Cargo.toml | 2 +- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7bad0293b6..fb19b9461d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2272,9 +2272,9 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "futures" -version = "0.3.21" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f73fe65f54d1e12b726f517d3e2135ca3125a437b6d998caf1962961f7172d9e" +checksum = "7f21eda599937fba36daeb58a22e8f5cee2d14c4a17b5b7739c7c8e5e3b8230c" dependencies = [ "futures-channel", "futures-core", @@ -2287,9 +2287,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.21" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3083ce4b914124575708913bca19bfe887522d6e2e6d0952943f5eac4a74010" +checksum = "30bdd20c28fadd505d0fd6712cdfcb0d4b5648baf45faef7f852afb2399bb050" dependencies = [ "futures-core", "futures-sink", @@ -2297,15 +2297,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.21" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c09fd04b7e4073ac7156a9539b57a484a8ea920f79c7c675d05d289ab6110d3" +checksum = "4e5aa3de05362c3fb88de6531e6296e85cde7739cccad4b9dfeeb7f6ebce56bf" [[package]] name = "futures-executor" -version = "0.3.21" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9420b90cfa29e327d0429f19be13e7ddb68fa1cccb09d65e5706b8c7a749b8a6" +checksum = "9ff63c23854bee61b6e9cd331d523909f238fc7636290b96826e9cfa5faa00ab" dependencies = [ "futures-core", "futures-task", @@ -2315,9 +2315,9 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.21" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc4045962a5a5e935ee2fdedaa4e08284547402885ab326734432bed5d12966b" +checksum = "bbf4d2a7a308fd4578637c0b17c7e1c7ba127b8f6ba00b29f717e9655d85eb68" [[package]] name = "futures-lite" @@ -2336,9 +2336,9 @@ dependencies = [ [[package]] name = "futures-macro" -version = "0.3.21" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33c1e13800337f4d4d7a316bf45a567dbcb6ffe087f16424852d97e97a91f512" +checksum = "42cd15d1c7456c04dbdf7e88bcd69760d74f3a798d6444e16974b505b0e62f17" dependencies = [ "proc-macro2", "quote", @@ -2358,15 +2358,15 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.21" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21163e139fa306126e6eedaf49ecdb4588f939600f0b1e770f4205ee4b7fa868" +checksum = "21b20ba5a92e727ba30e72834706623d94ac93a725410b6a6b6fbc1b07f7ba56" [[package]] name = "futures-task" -version = "0.3.21" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57c66a976bf5909d801bbef33416c41372779507e7a6b3a5e25e4749c58f776a" +checksum = "a6508c467c73851293f390476d4491cf4d227dbabcd4170f3bb6044959b294f1" [[package]] name = "futures-timer" @@ -2376,9 +2376,9 @@ checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" [[package]] name = "futures-util" -version = "0.3.21" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8b7abd5d659d9b90c8cba917f6ec750a74e2dc23902ef9cd4cc8c8b22e6036a" +checksum = "44fb6cb1be61cc1d2e43b262516aafcf63b241cffdb1d3fa115f91d9c7b09c90" dependencies = [ "futures-channel", "futures-core", diff --git a/client/mapping-sync/Cargo.toml b/client/mapping-sync/Cargo.toml index 56561cb9f0..8369a5a853 100644 --- a/client/mapping-sync/Cargo.toml +++ b/client/mapping-sync/Cargo.toml @@ -11,7 +11,7 @@ repository = "https://github.com/paritytech/frontier/" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -futures = "0.3.21" +futures = "0.3.24" futures-timer = "3.0.1" log = "0.4.17" diff --git a/client/rpc/Cargo.toml b/client/rpc/Cargo.toml index 2edb5da072..64abef5420 100644 --- a/client/rpc/Cargo.toml +++ b/client/rpc/Cargo.toml @@ -13,7 +13,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] ethereum = { version = "0.12.0", features = ["with-codec"] } evm = { git = "https://github.com/rust-blockchain/evm", rev = "51b8c2ce3104265e1fd5bb0fe5cdfd2e0938239c" } -futures = "0.3.21" +futures = "0.3.24" hex = "0.4.3" log = "0.4.17" lru = "0.7.8" diff --git a/template/node/Cargo.toml b/template/node/Cargo.toml index 1ba83b6602..05472247b0 100644 --- a/template/node/Cargo.toml +++ b/template/node/Cargo.toml @@ -14,7 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] async-trait = "0.1" clap = { version = "3.2", features = ["derive"] } -futures = "0.3.21" +futures = "0.3.24" log = "0.4.17" # Parity From d3beddc6911a559a3ecc9b3f08e153dbe37a8658 Mon Sep 17 00:00:00 2001 From: Stephen Shelton Date: Mon, 19 Sep 2022 21:39:37 -0600 Subject: [PATCH 08/21] Fix post dispatch weight (#851) * Call post_dispatch for CheckedSignature::SelfContained * add tests * rename tests Co-authored-by: Nisheeth Barthwal --- frame/ethereum/src/tests/eip1559.rs | 44 +++++++++++++++++++ frame/ethereum/src/tests/eip2930.rs | 44 +++++++++++++++++++ frame/ethereum/src/tests/legacy.rs | 44 +++++++++++++++++++ .../self-contained/src/checked_extrinsic.rs | 16 ++++++- 4 files changed, 146 insertions(+), 2 deletions(-) diff --git a/frame/ethereum/src/tests/eip1559.rs b/frame/ethereum/src/tests/eip1559.rs index 7957de633d..a059cf3672 100644 --- a/frame/ethereum/src/tests/eip1559.rs +++ b/frame/ethereum/src/tests/eip1559.rs @@ -407,3 +407,47 @@ fn call_should_handle_errors() { Ethereum::execute(alice.address, &t3, None).ok().unwrap(); }); } + +#[test] +fn self_contained_transaction_with_extra_gas_should_adjust_weight_with_post_dispatch() { + let (pairs, mut ext) = new_test_ext(1); + let alice = &pairs[0]; + let base_extrinsic_weight = frame_system::limits::BlockWeights::with_sensible_defaults( + 2000000000000, + sp_runtime::Perbill::from_percent(75), + ) + .per_class + .get(frame_support::weights::DispatchClass::Normal) + .base_extrinsic; + + ext.execute_with(|| { + let mut transaction = eip1559_erc20_creation_unsigned_transaction(); + transaction.gas_limit = 9_000_000.into(); + let signed = transaction.sign(&alice.private_key, None); + let call = crate::Call::::transact { + transaction: signed, + }; + let source = call.check_self_contained().unwrap().unwrap(); + let extrinsic = CheckedExtrinsic::<_, _, frame_system::CheckWeight, _> { + signed: fp_self_contained::CheckedSignature::SelfContained(source), + function: Call::Ethereum(call), + }; + let dispatch_info = extrinsic.get_dispatch_info(); + let post_dispatch_weight = extrinsic + .apply::(&dispatch_info, 0) + .unwrap() + .unwrap() + .actual_weight + .unwrap(); + + let expected_weight = base_extrinsic_weight.saturating_add(post_dispatch_weight); + let actual_weight = *frame_system::Pallet::::block_weight() + .get(frame_support::weights::DispatchClass::Normal); + assert_eq!( + expected_weight, + actual_weight, + "the block weight was unexpected, excess '{}'", + actual_weight as i128 - expected_weight as i128 + ); + }); +} diff --git a/frame/ethereum/src/tests/eip2930.rs b/frame/ethereum/src/tests/eip2930.rs index e64fcd950f..49b9c66c18 100644 --- a/frame/ethereum/src/tests/eip2930.rs +++ b/frame/ethereum/src/tests/eip2930.rs @@ -330,3 +330,47 @@ fn call_should_handle_errors() { Ethereum::execute(alice.address, &t3, None).ok().unwrap(); }); } + +#[test] +fn self_contained_transaction_with_extra_gas_should_adjust_weight_with_post_dispatch() { + let (pairs, mut ext) = new_test_ext(1); + let alice = &pairs[0]; + let base_extrinsic_weight = frame_system::limits::BlockWeights::with_sensible_defaults( + 2000000000000, + sp_runtime::Perbill::from_percent(75), + ) + .per_class + .get(frame_support::weights::DispatchClass::Normal) + .base_extrinsic; + + ext.execute_with(|| { + let mut transaction = eip2930_erc20_creation_unsigned_transaction(); + transaction.gas_limit = 9_000_000.into(); + let signed = transaction.sign(&alice.private_key, None); + let call = crate::Call::::transact { + transaction: signed, + }; + let source = call.check_self_contained().unwrap().unwrap(); + let extrinsic = CheckedExtrinsic::<_, _, frame_system::CheckWeight, _> { + signed: fp_self_contained::CheckedSignature::SelfContained(source), + function: Call::Ethereum(call), + }; + let dispatch_info = extrinsic.get_dispatch_info(); + let post_dispatch_weight = extrinsic + .apply::(&dispatch_info, 0) + .unwrap() + .unwrap() + .actual_weight + .unwrap(); + + let expected_weight = base_extrinsic_weight.saturating_add(post_dispatch_weight); + let actual_weight = *frame_system::Pallet::::block_weight() + .get(frame_support::weights::DispatchClass::Normal); + assert_eq!( + expected_weight, + actual_weight, + "the block weight was unexpected, excess '{}'", + actual_weight as i128 - expected_weight as i128 + ); + }); +} diff --git a/frame/ethereum/src/tests/legacy.rs b/frame/ethereum/src/tests/legacy.rs index 5af2e2fe02..0996b1d8da 100644 --- a/frame/ethereum/src/tests/legacy.rs +++ b/frame/ethereum/src/tests/legacy.rs @@ -330,3 +330,47 @@ fn call_should_handle_errors() { Ethereum::execute(alice.address, &t3, None).ok().unwrap(); }); } + +#[test] +fn self_contained_transaction_with_extra_gas_should_adjust_weight_with_post_dispatch() { + let (pairs, mut ext) = new_test_ext(1); + let alice = &pairs[0]; + let base_extrinsic_weight = frame_system::limits::BlockWeights::with_sensible_defaults( + 2000000000000, + sp_runtime::Perbill::from_percent(75), + ) + .per_class + .get(frame_support::weights::DispatchClass::Normal) + .base_extrinsic; + + ext.execute_with(|| { + let mut transaction = legacy_erc20_creation_unsigned_transaction(); + transaction.gas_limit = 9_000_000.into(); + let signed = transaction.sign(&alice.private_key); + let call = crate::Call::::transact { + transaction: signed, + }; + let source = call.check_self_contained().unwrap().unwrap(); + let extrinsic = CheckedExtrinsic::<_, _, frame_system::CheckWeight, _> { + signed: fp_self_contained::CheckedSignature::SelfContained(source), + function: Call::Ethereum(call), + }; + let dispatch_info = extrinsic.get_dispatch_info(); + let post_dispatch_weight = extrinsic + .apply::(&dispatch_info, 0) + .unwrap() + .unwrap() + .actual_weight + .unwrap(); + + let expected_weight = base_extrinsic_weight.saturating_add(post_dispatch_weight); + let actual_weight = *frame_system::Pallet::::block_weight() + .get(frame_support::weights::DispatchClass::Normal); + assert_eq!( + expected_weight, + actual_weight, + "the block weight was unexpected, excess '{}'", + actual_weight as i128 - expected_weight as i128 + ); + }); +} diff --git a/primitives/self-contained/src/checked_extrinsic.rs b/primitives/self-contained/src/checked_extrinsic.rs index ed61c2844e..ed1045189e 100644 --- a/primitives/self-contained/src/checked_extrinsic.rs +++ b/primitives/self-contained/src/checked_extrinsic.rs @@ -144,9 +144,21 @@ where .ok_or(TransactionValidityError::Invalid( InvalidTransaction::BadProof, ))??; - Ok(self.function.apply_self_contained(signed_info).ok_or( + let res = self.function.apply_self_contained(signed_info).ok_or( TransactionValidityError::Invalid(InvalidTransaction::BadProof), - )?) + )?; + let post_info = match res { + Ok(info) => info, + Err(err) => err.post_info, + }; + Extra::post_dispatch( + None, + info, + &post_info, + len, + &res.map(|_| ()).map_err(|e| e.error), + )?; + Ok(res) } } } From fe12fddded2eb77e7d6b50b0b02368948e32668f Mon Sep 17 00:00:00 2001 From: tgmichel Date: Tue, 20 Sep 2022 05:42:22 +0200 Subject: [PATCH 09/21] Add `safe` and `finalized` block tags support (#853) * Add `safe` and `finalized` block tags support * prettier --- client/rpc-core/src/types/block_number.rs | 18 +++++++++++++- client/rpc/src/lib.rs | 2 ++ ts-tests/package.json | 2 +- ts-tests/tests/test-block-tags.ts | 30 +++++++++++++++++++++++ ts-tests/tests/util.ts | 4 +-- 5 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 ts-tests/tests/test-block-tags.ts diff --git a/client/rpc-core/src/types/block_number.rs b/client/rpc-core/src/types/block_number.rs index 1ece65e96f..06ab5e946a 100644 --- a/client/rpc-core/src/types/block_number.rs +++ b/client/rpc-core/src/types/block_number.rs @@ -41,6 +41,12 @@ pub enum BlockNumber { Earliest, /// Pending block (being mined) Pending, + /// The most recent crypto-economically secure block. + /// There is no difference between Ethereum's `safe` and `finalized` + /// in Substrate finality gadget. + Safe, + /// The most recent crypto-economically secure block. + Finalized, } impl Default for BlockNumber { @@ -86,6 +92,8 @@ impl Serialize for BlockNumber { BlockNumber::Latest => serializer.serialize_str("latest"), BlockNumber::Earliest => serializer.serialize_str("earliest"), BlockNumber::Pending => serializer.serialize_str("pending"), + BlockNumber::Safe => serializer.serialize_str("safe"), + BlockNumber::Finalized => serializer.serialize_str("finalized"), } } } @@ -98,7 +106,7 @@ impl<'a> Visitor<'a> for BlockNumberVisitor { fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { write!( formatter, - "a block number or 'latest', 'earliest' or 'pending'" + "a block number or 'latest', 'safe', 'finalized', 'earliest' or 'pending'" ) } @@ -163,6 +171,8 @@ impl<'a> Visitor<'a> for BlockNumberVisitor { "latest" => Ok(BlockNumber::Latest), "earliest" => Ok(BlockNumber::Earliest), "pending" => Ok(BlockNumber::Pending), + "safe" => Ok(BlockNumber::Safe), + "finalized" => Ok(BlockNumber::Finalized), _ if value.starts_with("0x") => u64::from_str_radix(&value[2..], 16) .map(BlockNumber::Num) .map_err(|e| Error::custom(format!("Invalid block number: {}", e))), @@ -196,6 +206,8 @@ mod tests { BlockNumber::Num(number) => Some(number), BlockNumber::Earliest => Some(0), BlockNumber::Latest => Some(1000), + BlockNumber::Safe => Some(999), + BlockNumber::Finalized => Some(999), BlockNumber::Pending => Some(1001), _ => None, } @@ -208,6 +220,8 @@ mod tests { let bn_u64: BlockNumber = serde_json::from_str(r#"420"#).unwrap(); let bn_tag_earliest: BlockNumber = serde_json::from_str(r#""earliest""#).unwrap(); let bn_tag_latest: BlockNumber = serde_json::from_str(r#""latest""#).unwrap(); + let bn_tag_safe: BlockNumber = serde_json::from_str(r#""safe""#).unwrap(); + let bn_tag_finalized: BlockNumber = serde_json::from_str(r#""finalized""#).unwrap(); let bn_tag_pending: BlockNumber = serde_json::from_str(r#""pending""#).unwrap(); assert_eq!(match_block_number(bn_dec).unwrap(), 42); @@ -215,6 +229,8 @@ mod tests { assert_eq!(match_block_number(bn_u64).unwrap(), 420); assert_eq!(match_block_number(bn_tag_earliest).unwrap(), 0); assert_eq!(match_block_number(bn_tag_latest).unwrap(), 1000); + assert_eq!(match_block_number(bn_tag_safe).unwrap(), 999); + assert_eq!(match_block_number(bn_tag_finalized).unwrap(), 999); assert_eq!(match_block_number(bn_tag_pending).unwrap(), 1001); } } diff --git a/client/rpc/src/lib.rs b/client/rpc/src/lib.rs index 5f9db08e6c..647f8f7985 100644 --- a/client/rpc/src/lib.rs +++ b/client/rpc/src/lib.rs @@ -81,6 +81,8 @@ pub mod frontier_backend_client { BlockNumber::Latest => Some(BlockId::Hash(client.info().best_hash)), BlockNumber::Earliest => Some(BlockId::Number(Zero::zero())), BlockNumber::Pending => None, + BlockNumber::Safe => Some(BlockId::Hash(client.info().finalized_hash)), + BlockNumber::Finalized => Some(BlockId::Hash(client.info().finalized_hash)), }) } diff --git a/ts-tests/package.json b/ts-tests/package.json index 8f2a097c7f..100c98a509 100644 --- a/ts-tests/package.json +++ b/ts-tests/package.json @@ -23,7 +23,7 @@ "truffle": "^5.1.62", "ts-node": "^8.10.2", "typescript": "^3.9.6", - "web3": "^1.3.4" + "web3": "^1.8.0-rc.0" }, "devDependencies": { "@types/chai-as-promised": "^7.1.5", diff --git a/ts-tests/tests/test-block-tags.ts b/ts-tests/tests/test-block-tags.ts new file mode 100644 index 0000000000..125d114946 --- /dev/null +++ b/ts-tests/tests/test-block-tags.ts @@ -0,0 +1,30 @@ +import { expect } from "chai"; +import { step } from "mocha-steps"; + +import { GENESIS_ACCOUNT, GENESIS_ACCOUNT_PRIVATE_KEY, GENESIS_ACCOUNT_BALANCE, EXISTENTIAL_DEPOSIT } from "./config"; +import { createAndFinalizeBlock, describeWithFrontier, customRequest } from "./util"; + +describeWithFrontier("Frontier RPC (BlockNumber tags)", (context) => { + before("Send some transactions across blocks", async function () { + // block #1 finalized + await createAndFinalizeBlock(context.web3); + // block #2 not finalized + await createAndFinalizeBlock(context.web3, false); + }); + + step("`earliest` returns genesis", async function () { + expect((await context.web3.eth.getBlock("earliest")).number).to.equal(0); + }); + + step("`latest` returns `BlockchainInfo::best_hash` number", async function () { + expect((await context.web3.eth.getBlock("latest")).number).to.equal(2); + }); + + step("`finalized` uses `BlockchainInfo::finalized_hash` number", async function () { + expect((await context.web3.eth.getBlock("finalized")).number).to.equal(1); + }); + + step("`safe` is an alias for `finalized` in Polkadot", async function () { + expect((await context.web3.eth.getBlock("safe")).number).to.equal(1); + }); +}); diff --git a/ts-tests/tests/util.ts b/ts-tests/tests/util.ts index 9099dca964..4b944e61f0 100644 --- a/ts-tests/tests/util.ts +++ b/ts-tests/tests/util.ts @@ -41,8 +41,8 @@ export async function customRequest(web3: Web3, method: string, params: any[]) { // Create a block and finalize it. // It will include all previously executed transactions since the last finalized block. -export async function createAndFinalizeBlock(web3: Web3) { - const response = await customRequest(web3, "engine_createBlock", [true, true, null]); +export async function createAndFinalizeBlock(web3: Web3, finalize: boolean = true) { + const response = await customRequest(web3, "engine_createBlock", [true, finalize, null]); if (!response.result) { throw new Error(`Unexpected result: ${JSON.stringify(response)}`); } From 817bdfb06fc3ffd5c23315df91e32504aead0539 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 20 Sep 2022 05:42:36 +0200 Subject: [PATCH 10/21] Bump clap from 3.2.20 to 3.2.22 (#858) Bumps [clap](https://github.com/clap-rs/clap) from 3.2.20 to 3.2.22. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/v3.2.22/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v3.2.20...v3.2.22) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fb19b9461d..022f2c5947 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -784,9 +784,9 @@ dependencies = [ [[package]] name = "clap" -version = "3.2.20" +version = "3.2.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23b71c3ce99b7611011217b366d923f1d0a7e07a92bb2dbf1e84508c673ca3bd" +checksum = "86447ad904c7fb335a790c9d7fe3d0d971dc523b8ccd1561a520de9a85302750" dependencies = [ "atty", "bitflags", @@ -8121,9 +8121,9 @@ dependencies = [ [[package]] name = "textwrap" -version = "0.15.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb" +checksum = "949517c0cf1bf4ee812e2e07e08ab448e3ae0d23472aee8a06c985f0c8815b16" [[package]] name = "thiserror" From e8dbed108867e0bbdcc69c62ad488ec58f7aa1e7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 20 Sep 2022 05:42:49 +0200 Subject: [PATCH 11/21] Bump lru from 0.7.8 to 0.8.0 (#850) Bumps [lru](https://github.com/jeromefroe/lru-rs) from 0.7.8 to 0.8.0. - [Release notes](https://github.com/jeromefroe/lru-rs/releases) - [Changelog](https://github.com/jeromefroe/lru-rs/blob/master/CHANGELOG.md) - [Commits](https://github.com/jeromefroe/lru-rs/compare/0.7.8...0.8.0) --- updated-dependencies: - dependency-name: lru dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 25 +++++++++++++++++-------- client/rpc/Cargo.toml | 2 +- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 022f2c5947..40665f7125 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1692,7 +1692,7 @@ dependencies = [ "jsonrpsee", "libsecp256k1", "log", - "lru", + "lru 0.8.0", "parity-scale-codec", "prometheus", "rand 0.8.5", @@ -3311,7 +3311,7 @@ dependencies = [ "libp2p-core", "libp2p-swarm", "log", - "lru", + "lru 0.7.8", "prost", "prost-build", "prost-codec", @@ -3783,6 +3783,15 @@ dependencies = [ "hashbrown 0.12.0", ] +[[package]] +name = "lru" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "936d98d2ddd79c18641c6709e7bb09981449694e402d1a0f0f657ea8d61f4a51" +dependencies = [ + "hashbrown 0.12.0", +] + [[package]] name = "lru-cache" version = "0.1.2" @@ -4833,7 +4842,7 @@ dependencies = [ "ethereum-types", "hashbrown 0.12.0", "impl-trait-for-tuples", - "lru", + "lru 0.7.8", "parity-util-mem-derive", "parking_lot 0.12.1", "primitive-types", @@ -6106,7 +6115,7 @@ version = "0.10.0-dev" source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" dependencies = [ "lazy_static", - "lru", + "lru 0.7.8", "parity-scale-codec", "parking_lot 0.12.1", "sc-executor-common", @@ -6273,7 +6282,7 @@ dependencies = [ "linked-hash-map", "linked_hash_set", "log", - "lru", + "lru 0.7.8", "parity-scale-codec", "parking_lot 0.12.1", "pin-project", @@ -6329,7 +6338,7 @@ dependencies = [ "futures-timer", "libp2p", "log", - "lru", + "lru 0.7.8", "sc-network", "sp-runtime", "substrate-prometheus-endpoint", @@ -6365,7 +6374,7 @@ dependencies = [ "futures", "libp2p", "log", - "lru", + "lru 0.7.8", "parity-scale-codec", "prost", "prost-build", @@ -7201,7 +7210,7 @@ source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3 dependencies = [ "futures", "log", - "lru", + "lru 0.7.8", "parity-scale-codec", "parking_lot 0.12.1", "sp-api", diff --git a/client/rpc/Cargo.toml b/client/rpc/Cargo.toml index 64abef5420..ffe412ac53 100644 --- a/client/rpc/Cargo.toml +++ b/client/rpc/Cargo.toml @@ -16,7 +16,7 @@ evm = { git = "https://github.com/rust-blockchain/evm", rev = "51b8c2ce3104265e1 futures = "0.3.24" hex = "0.4.3" log = "0.4.17" -lru = "0.7.8" +lru = "0.8.0" prometheus = { version = "0.13.1", default-features = false } rand = "0.8" tokio = { version = "1.19", features = ["sync"] } From a8d4dd55643d324dbbf49be7f4e4e10494f56d39 Mon Sep 17 00:00:00 2001 From: Qinxuan Chen Date: Fri, 23 Sep 2022 23:43:23 +0800 Subject: [PATCH 12/21] Update substrate to polkadot-v0.9.28 (#830) * Update substrate to polkadot-v0.9.28 Signed-off-by: koushiro * Fix PruningParams fields Signed-off-by: koushiro * Some trivials Signed-off-by: koushiro * Ignore tests calling EthereumRuntimeRPCApi_current_transaction_statuses Signed-off-by: koushiro * ignore tests Signed-off-by: koushiro * Fix fmt Signed-off-by: koushiro Signed-off-by: koushiro --- Cargo.lock | 334 +++++++++--------- client/cli/src/frontier_db_cmd/mapping_db.rs | 10 +- client/cli/src/frontier_db_cmd/meta_db.rs | 9 +- client/cli/src/frontier_db_cmd/mod.rs | 14 +- client/cli/src/frontier_db_cmd/tests.rs | 43 ++- client/cli/src/frontier_db_cmd/utils.rs | 17 +- client/consensus/src/lib.rs | 3 +- client/db/src/lib.rs | 4 +- client/db/src/parity_db_adapter.rs | 3 +- client/mapping-sync/src/lib.rs | 6 +- client/mapping-sync/src/worker.rs | 7 +- client/rpc-core/Cargo.toml | 2 +- client/rpc/Cargo.toml | 4 +- client/rpc/src/eth/block.rs | 4 +- client/rpc/src/eth/cache/mod.rs | 6 +- client/rpc/src/eth/client.rs | 5 +- client/rpc/src/eth/execute.rs | 4 +- client/rpc/src/eth/fee.rs | 4 +- client/rpc/src/eth/filter.rs | 4 +- client/rpc/src/eth/format.rs | 4 +- client/rpc/src/eth/mining.rs | 4 +- client/rpc/src/eth/mod.rs | 4 +- client/rpc/src/eth/state.rs | 6 +- client/rpc/src/eth/submit.rs | 4 +- client/rpc/src/eth/transaction.rs | 4 +- client/rpc/src/eth_pubsub.rs | 40 +-- client/rpc/src/lib.rs | 4 +- client/rpc/src/net.rs | 6 +- client/rpc/src/overrides/mod.rs | 9 +- .../rpc/src/overrides/schema_v1_override.rs | 8 +- .../rpc/src/overrides/schema_v2_override.rs | 4 +- .../rpc/src/overrides/schema_v3_override.rs | 4 +- client/rpc/src/signer.rs | 5 +- client/rpc/src/web3.rs | 3 +- template/node/Cargo.toml | 2 +- 35 files changed, 314 insertions(+), 280 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 40665f7125..d5e83d2660 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -262,7 +262,7 @@ dependencies = [ "memchr", "num_cpus", "once_cell", - "pin-project-lite 0.2.7", + "pin-project-lite 0.2.9", "pin-utils", "slab", "wasm-bindgen-futures", @@ -310,7 +310,7 @@ dependencies = [ "futures-sink", "futures-util", "memchr", - "pin-project-lite 0.2.7", + "pin-project-lite 0.2.9", ] [[package]] @@ -399,7 +399,7 @@ dependencies = [ [[package]] name = "beefy-merkle-tree" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "beefy-primitives", "sp-api", @@ -408,7 +408,7 @@ dependencies = [ [[package]] name = "beefy-primitives" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "parity-scale-codec", "scale-info", @@ -1701,6 +1701,7 @@ dependencies = [ "sc-client-api", "sc-client-db", "sc-network", + "sc-network-common", "sc-rpc", "sc-service", "sc-transaction-pool", @@ -1829,7 +1830,7 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "fork-tree" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "parity-scale-codec", ] @@ -1929,7 +1930,7 @@ dependencies = [ [[package]] name = "frame-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "frame-support", "frame-system", @@ -1951,7 +1952,7 @@ dependencies = [ [[package]] name = "frame-benchmarking-cli" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "Inflector", "chrono", @@ -2002,7 +2003,7 @@ dependencies = [ [[package]] name = "frame-executive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "frame-support", "frame-system", @@ -2030,7 +2031,7 @@ dependencies = [ [[package]] name = "frame-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "bitflags", "frame-metadata", @@ -2044,6 +2045,7 @@ dependencies = [ "scale-info", "serde", "smallvec", + "sp-api", "sp-arithmetic", "sp-core", "sp-core-hashing-proc-macro", @@ -2060,7 +2062,7 @@ dependencies = [ [[package]] name = "frame-support-procedural" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "Inflector", "frame-support-procedural-tools", @@ -2072,7 +2074,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate", @@ -2084,7 +2086,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "proc-macro2", "quote", @@ -2094,7 +2096,7 @@ dependencies = [ [[package]] name = "frame-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "frame-support", "log", @@ -2111,7 +2113,7 @@ dependencies = [ [[package]] name = "frame-system-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "frame-benchmarking", "frame-support", @@ -2126,7 +2128,7 @@ dependencies = [ [[package]] name = "frame-system-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "parity-scale-codec", "sp-api", @@ -2330,7 +2332,7 @@ dependencies = [ "futures-io", "memchr", "parking", - "pin-project-lite 0.2.7", + "pin-project-lite 0.2.9", "waker-fn", ] @@ -2387,7 +2389,7 @@ dependencies = [ "futures-sink", "futures-task", "memchr", - "pin-project-lite 0.2.7", + "pin-project-lite 0.2.9", "pin-utils", "slab", ] @@ -2655,13 +2657,13 @@ dependencies = [ [[package]] name = "http" -version = "0.2.4" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "527e8c9ac747e28542699a951517aa9a6945af506cd1f2e1b53a576c17b6cc11" +checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" dependencies = [ "bytes", "fnv", - "itoa 0.4.7", + "itoa 1.0.1", ] [[package]] @@ -2672,7 +2674,7 @@ checksum = "399c583b2979440c60be0821a6199eca73bc3c8dcd9d070d75ac726e2c6186e5" dependencies = [ "bytes", "http", - "pin-project-lite 0.2.7", + "pin-project-lite 0.2.9", ] [[package]] @@ -2709,7 +2711,7 @@ dependencies = [ "httparse", "httpdate", "itoa 1.0.1", - "pin-project-lite 0.2.7", + "pin-project-lite 0.2.9", "socket2", "tokio", "tower-service", @@ -2915,9 +2917,9 @@ dependencies = [ [[package]] name = "jsonrpsee" -version = "0.14.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11e017217fcd18da0a25296d3693153dd19c8a6aadab330b3595285d075385d1" +checksum = "8bd0d559d5e679b1ab2f869b486a11182923863b1b3ee8b421763cdd707b783a" dependencies = [ "jsonrpsee-core", "jsonrpsee-http-server", @@ -2929,9 +2931,9 @@ dependencies = [ [[package]] name = "jsonrpsee-core" -version = "0.14.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16efcd4477de857d4a2195a45769b2fe9ebb54f3ef5a4221d3b014a4fe33ec0b" +checksum = "f3dc3e9cf2ba50b7b1d7d76a667619f82846caa39e8e8daa8a4962d74acaddca" dependencies = [ "anyhow", "arrayvec 0.7.2", @@ -2940,6 +2942,7 @@ dependencies = [ "futures-channel", "futures-util", "globset", + "http", "hyper", "jsonrpsee-types", "lazy_static", @@ -2957,9 +2960,9 @@ dependencies = [ [[package]] name = "jsonrpsee-http-server" -version = "0.14.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdd69efeb3ce2cba767f126872f4eeb4624038a29098e75d77608b2b4345ad03" +checksum = "03802f0373a38c2420c70b5144742d800b509e2937edc4afb116434f07120117" dependencies = [ "futures-channel", "futures-util", @@ -2970,13 +2973,14 @@ dependencies = [ "serde_json", "tokio", "tracing", + "tracing-futures", ] [[package]] name = "jsonrpsee-proc-macros" -version = "0.14.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "874cf3f6a027cebf36cae767feca9aa2e8a8f799880e49eb5540819fcbd8eada" +checksum = "bd67957d4280217247588ac86614ead007b301ca2fa9f19c19f880a536f029e3" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -2986,9 +2990,9 @@ dependencies = [ [[package]] name = "jsonrpsee-types" -version = "0.14.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bcf76cd316f5d3ad48138085af1f45e2c58c98e02f0779783dbb034d43f7c86" +checksum = "e290bba767401b646812f608c099b922d8142603c9e73a50fb192d3ac86f4a0d" dependencies = [ "anyhow", "beef", @@ -3000,12 +3004,13 @@ dependencies = [ [[package]] name = "jsonrpsee-ws-server" -version = "0.14.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bd2e4d266774a671f8def3794255b28eddd09b18d76e0b913fa439f34588c0a" +checksum = "d488ba74fb369e5ab68926feb75a483458b88e768d44319f37e4ecad283c7325" dependencies = [ "futures-channel", "futures-util", + "http", "jsonrpsee-core", "jsonrpsee-types", "serde_json", @@ -3014,6 +3019,7 @@ dependencies = [ "tokio-stream", "tokio-util", "tracing", + "tracing-futures", ] [[package]] @@ -4372,7 +4378,7 @@ dependencies = [ [[package]] name = "pallet-aura" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "frame-support", "frame-system", @@ -4388,7 +4394,7 @@ dependencies = [ [[package]] name = "pallet-authorship" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "frame-support", "frame-system", @@ -4403,7 +4409,7 @@ dependencies = [ [[package]] name = "pallet-babe" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "frame-benchmarking", "frame-support", @@ -4427,7 +4433,7 @@ dependencies = [ [[package]] name = "pallet-balances" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "frame-benchmarking", "frame-support", @@ -4635,7 +4641,7 @@ dependencies = [ [[package]] name = "pallet-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "frame-benchmarking", "frame-support", @@ -4674,7 +4680,7 @@ dependencies = [ [[package]] name = "pallet-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "frame-support", "frame-system", @@ -4695,7 +4701,7 @@ dependencies = [ [[package]] name = "pallet-sudo" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "frame-support", "frame-system", @@ -4709,7 +4715,7 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "frame-benchmarking", "frame-support", @@ -4727,7 +4733,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "frame-support", "frame-system", @@ -4743,7 +4749,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "jsonrpsee", "pallet-transaction-payment-rpc-runtime-api", @@ -4758,7 +4764,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "pallet-transaction-payment", "parity-scale-codec", @@ -4769,7 +4775,7 @@ dependencies = [ [[package]] name = "pallet-utility" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "frame-support", "frame-system", @@ -4802,13 +4808,14 @@ dependencies = [ [[package]] name = "parity-scale-codec" -version = "3.1.2" +version = "3.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8b44461635bbb1a0300f100a841e571e7d919c81c73075ef5d152ffdb521066" +checksum = "9182e4a71cae089267ab03e67c99368db7cd877baf50f931e5d6d4b71e195ac0" dependencies = [ "arrayvec 0.7.2", "bitvec", "byte-slice-cast", + "bytes", "impl-trait-for-tuples", "parity-scale-codec-derive", "serde", @@ -4816,9 +4823,9 @@ dependencies = [ [[package]] name = "parity-scale-codec-derive" -version = "3.1.2" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c45ed1f39709f5a89338fab50e59816b2e8815f5bb58276e7ddf9afd495f73f8" +checksum = "9299338969a3d2f491d65f140b00ddec470858402f888af98e8642fb5e8965cd" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -5047,9 +5054,9 @@ checksum = "257b64915a082f7811703966789728173279bdebb956b143dbcd23f6f970a777" [[package]] name = "pin-project-lite" -version = "0.2.7" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" [[package]] name = "pin-utils" @@ -5775,7 +5782,7 @@ dependencies = [ [[package]] name = "sc-allocator" version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "log", "sp-core", @@ -5786,7 +5793,7 @@ dependencies = [ [[package]] name = "sc-basic-authorship" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "futures", "futures-timer", @@ -5809,7 +5816,7 @@ dependencies = [ [[package]] name = "sc-block-builder" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "parity-scale-codec", "sc-client-api", @@ -5825,7 +5832,7 @@ dependencies = [ [[package]] name = "sc-chain-spec" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "impl-trait-for-tuples", "memmap2 0.5.3", @@ -5842,7 +5849,7 @@ dependencies = [ [[package]] name = "sc-chain-spec-derive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -5853,7 +5860,7 @@ dependencies = [ [[package]] name = "sc-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "chrono", "clap", @@ -5892,7 +5899,7 @@ dependencies = [ [[package]] name = "sc-client-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "fnv", "futures", @@ -5920,7 +5927,7 @@ dependencies = [ [[package]] name = "sc-client-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "hash-db", "kvdb", @@ -5945,7 +5952,7 @@ dependencies = [ [[package]] name = "sc-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "async-trait", "futures", @@ -5969,7 +5976,7 @@ dependencies = [ [[package]] name = "sc-consensus-aura" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "async-trait", "futures", @@ -5998,7 +6005,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "async-trait", "fork-tree", @@ -6040,7 +6047,7 @@ dependencies = [ [[package]] name = "sc-consensus-epochs" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "fork-tree", "parity-scale-codec", @@ -6053,7 +6060,7 @@ dependencies = [ [[package]] name = "sc-consensus-manual-seal" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "assert_matches", "async-trait", @@ -6087,7 +6094,7 @@ dependencies = [ [[package]] name = "sc-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "async-trait", "futures", @@ -6112,7 +6119,7 @@ dependencies = [ [[package]] name = "sc-executor" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "lazy_static", "lru 0.7.8", @@ -6139,14 +6146,13 @@ dependencies = [ [[package]] name = "sc-executor-common" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "environmental", "parity-scale-codec", "sc-allocator", "sp-maybe-compressed-blob", "sp-sandbox", - "sp-serializer", "sp-wasm-interface", "thiserror", "wasm-instrument", @@ -6156,7 +6162,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmi" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "log", "parity-scale-codec", @@ -6171,7 +6177,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "cfg-if", "libc", @@ -6191,7 +6197,7 @@ dependencies = [ [[package]] name = "sc-finality-grandpa" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "ahash", "async-trait", @@ -6232,7 +6238,7 @@ dependencies = [ [[package]] name = "sc-informant" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "ansi_term", "futures", @@ -6240,7 +6246,7 @@ dependencies = [ "log", "parity-util-mem", "sc-client-api", - "sc-network", + "sc-network-common", "sc-transaction-pool-api", "sp-blockchain", "sp-runtime", @@ -6249,7 +6255,7 @@ dependencies = [ [[package]] name = "sc-keystore" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "async-trait", "hex", @@ -6264,7 +6270,7 @@ dependencies = [ [[package]] name = "sc-network" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "async-trait", "asynchronous-codec", @@ -6313,9 +6319,11 @@ dependencies = [ [[package]] name = "sc-network-common" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ + "async-trait", "bitflags", + "bytes", "futures", "libp2p", "parity-scale-codec", @@ -6326,12 +6334,13 @@ dependencies = [ "sp-consensus", "sp-finality-grandpa", "sp-runtime", + "thiserror", ] [[package]] name = "sc-network-gossip" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "ahash", "futures", @@ -6340,6 +6349,7 @@ dependencies = [ "log", "lru 0.7.8", "sc-network", + "sc-network-common", "sp-runtime", "substrate-prometheus-endpoint", "tracing", @@ -6348,9 +6358,10 @@ dependencies = [ [[package]] name = "sc-network-light" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "futures", + "hex", "libp2p", "log", "parity-scale-codec", @@ -6368,10 +6379,11 @@ dependencies = [ [[package]] name = "sc-network-sync" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "fork-tree", "futures", + "hex", "libp2p", "log", "lru 0.7.8", @@ -6395,7 +6407,7 @@ dependencies = [ [[package]] name = "sc-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "bytes", "fnv", @@ -6411,6 +6423,7 @@ dependencies = [ "rand 0.7.3", "sc-client-api", "sc-network", + "sc-network-common", "sc-utils", "sp-api", "sp-core", @@ -6423,7 +6436,7 @@ dependencies = [ [[package]] name = "sc-peerset" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "futures", "libp2p", @@ -6436,7 +6449,7 @@ dependencies = [ [[package]] name = "sc-proposer-metrics" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "log", "substrate-prometheus-endpoint", @@ -6445,7 +6458,7 @@ dependencies = [ [[package]] name = "sc-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "futures", "hash-db", @@ -6475,7 +6488,7 @@ dependencies = [ [[package]] name = "sc-rpc-api" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "futures", "jsonrpsee", @@ -6498,7 +6511,7 @@ dependencies = [ [[package]] name = "sc-rpc-server" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "futures", "jsonrpsee", @@ -6511,7 +6524,7 @@ dependencies = [ [[package]] name = "sc-service" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "async-trait", "directories", @@ -6578,7 +6591,7 @@ dependencies = [ [[package]] name = "sc-state-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "log", "parity-scale-codec", @@ -6592,7 +6605,7 @@ dependencies = [ [[package]] name = "sc-sysinfo" version = "6.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "futures", "libc", @@ -6611,7 +6624,7 @@ dependencies = [ [[package]] name = "sc-telemetry" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "chrono", "futures", @@ -6629,7 +6642,7 @@ dependencies = [ [[package]] name = "sc-tracing" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "ansi_term", "atty", @@ -6660,7 +6673,7 @@ dependencies = [ [[package]] name = "sc-tracing-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -6671,7 +6684,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "futures", "futures-timer", @@ -6697,7 +6710,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "futures", "log", @@ -6710,7 +6723,7 @@ dependencies = [ [[package]] name = "sc-utils" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "futures", "futures-timer", @@ -7125,7 +7138,7 @@ dependencies = [ [[package]] name = "sp-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "hash-db", "log", @@ -7142,7 +7155,7 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "blake2", "proc-macro-crate", @@ -7154,7 +7167,7 @@ dependencies = [ [[package]] name = "sp-application-crypto" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "parity-scale-codec", "scale-info", @@ -7167,7 +7180,7 @@ dependencies = [ [[package]] name = "sp-arithmetic" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "integer-sqrt", "num-traits", @@ -7182,7 +7195,7 @@ dependencies = [ [[package]] name = "sp-authorship" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "async-trait", "parity-scale-codec", @@ -7194,7 +7207,7 @@ dependencies = [ [[package]] name = "sp-block-builder" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "parity-scale-codec", "sp-api", @@ -7206,7 +7219,7 @@ dependencies = [ [[package]] name = "sp-blockchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "futures", "log", @@ -7224,7 +7237,7 @@ dependencies = [ [[package]] name = "sp-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "async-trait", "futures", @@ -7243,7 +7256,7 @@ dependencies = [ [[package]] name = "sp-consensus-aura" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "async-trait", "parity-scale-codec", @@ -7261,7 +7274,7 @@ dependencies = [ [[package]] name = "sp-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "async-trait", "merlin", @@ -7284,7 +7297,7 @@ dependencies = [ [[package]] name = "sp-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "parity-scale-codec", "scale-info", @@ -7298,7 +7311,7 @@ dependencies = [ [[package]] name = "sp-consensus-vrf" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "parity-scale-codec", "scale-info", @@ -7311,7 +7324,7 @@ dependencies = [ [[package]] name = "sp-core" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "base58", "bitflags", @@ -7357,7 +7370,7 @@ dependencies = [ [[package]] name = "sp-core-hashing" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "blake2", "byteorder", @@ -7371,7 +7384,7 @@ dependencies = [ [[package]] name = "sp-core-hashing-proc-macro" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "proc-macro2", "quote", @@ -7382,7 +7395,7 @@ dependencies = [ [[package]] name = "sp-database" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "kvdb", "parking_lot 0.12.1", @@ -7391,7 +7404,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "proc-macro2", "quote", @@ -7401,7 +7414,7 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.12.0" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "environmental", "parity-scale-codec", @@ -7412,7 +7425,7 @@ dependencies = [ [[package]] name = "sp-finality-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "finality-grandpa", "log", @@ -7430,7 +7443,7 @@ dependencies = [ [[package]] name = "sp-inherents" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "async-trait", "impl-trait-for-tuples", @@ -7444,8 +7457,9 @@ dependencies = [ [[package]] name = "sp-io" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ + "bytes", "futures", "hash-db", "libsecp256k1", @@ -7469,7 +7483,7 @@ dependencies = [ [[package]] name = "sp-keyring" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "lazy_static", "sp-core", @@ -7480,7 +7494,7 @@ dependencies = [ [[package]] name = "sp-keystore" version = "0.12.0" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "async-trait", "futures", @@ -7497,7 +7511,7 @@ dependencies = [ [[package]] name = "sp-maybe-compressed-blob" version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "thiserror", "zstd", @@ -7506,7 +7520,7 @@ dependencies = [ [[package]] name = "sp-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "sp-api", "sp-core", @@ -7516,7 +7530,7 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "backtrace", "lazy_static", @@ -7526,7 +7540,7 @@ dependencies = [ [[package]] name = "sp-rpc" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "rustc-hash", "serde", @@ -7536,7 +7550,7 @@ dependencies = [ [[package]] name = "sp-runtime" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "either", "hash256-std-hasher", @@ -7558,8 +7572,9 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ + "bytes", "impl-trait-for-tuples", "parity-scale-codec", "primitive-types", @@ -7575,7 +7590,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "Inflector", "proc-macro-crate", @@ -7587,7 +7602,7 @@ dependencies = [ [[package]] name = "sp-sandbox" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "log", "parity-scale-codec", @@ -7598,19 +7613,10 @@ dependencies = [ "wasmi", ] -[[package]] -name = "sp-serializer" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" -dependencies = [ - "serde", - "serde_json", -] - [[package]] name = "sp-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "parity-scale-codec", "scale-info", @@ -7624,7 +7630,7 @@ dependencies = [ [[package]] name = "sp-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "parity-scale-codec", "scale-info", @@ -7635,7 +7641,7 @@ dependencies = [ [[package]] name = "sp-state-machine" version = "0.12.0" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "hash-db", "log", @@ -7657,12 +7663,12 @@ dependencies = [ [[package]] name = "sp-std" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" [[package]] name = "sp-storage" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "impl-serde", "parity-scale-codec", @@ -7675,7 +7681,7 @@ dependencies = [ [[package]] name = "sp-tasks" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "log", "sp-core", @@ -7688,7 +7694,7 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "async-trait", "futures-timer", @@ -7704,7 +7710,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "parity-scale-codec", "sp-std", @@ -7716,7 +7722,7 @@ dependencies = [ [[package]] name = "sp-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "sp-api", "sp-runtime", @@ -7725,7 +7731,7 @@ dependencies = [ [[package]] name = "sp-transaction-storage-proof" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "async-trait", "log", @@ -7741,7 +7747,7 @@ dependencies = [ [[package]] name = "sp-trie" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "hash-db", "memory-db", @@ -7757,7 +7763,7 @@ dependencies = [ [[package]] name = "sp-version" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "impl-serde", "parity-scale-codec", @@ -7774,7 +7780,7 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "parity-scale-codec", "proc-macro2", @@ -7785,7 +7791,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "impl-trait-for-tuples", "log", @@ -7898,7 +7904,7 @@ dependencies = [ [[package]] name = "substrate-build-script-utils" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "platforms", ] @@ -7906,7 +7912,7 @@ dependencies = [ [[package]] name = "substrate-frame-rpc-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "frame-system-rpc-runtime-api", "futures", @@ -7927,7 +7933,7 @@ dependencies = [ [[package]] name = "substrate-prometheus-endpoint" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "futures-util", "hyper", @@ -7940,7 +7946,7 @@ dependencies = [ [[package]] name = "substrate-test-client" version = "2.0.1" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "async-trait", "futures", @@ -7966,7 +7972,7 @@ dependencies = [ [[package]] name = "substrate-test-runtime" version = "2.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "beefy-merkle-tree", "beefy-primitives", @@ -8010,7 +8016,7 @@ dependencies = [ [[package]] name = "substrate-test-runtime-client" version = "2.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "futures", "parity-scale-codec", @@ -8029,7 +8035,7 @@ dependencies = [ [[package]] name = "substrate-wasm-builder" version = "5.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#782e08ed36e3c3e5ffa3a48484267b02ec8b7b6d" +source = "git+https://github.com/paritytech/substrate?branch=master#34a0621761c4a333cb2074ff720f7acbfb92dbb8" dependencies = [ "ansi_term", "build-helper", @@ -8256,7 +8262,7 @@ dependencies = [ "num_cpus", "once_cell", "parking_lot 0.12.1", - "pin-project-lite 0.2.7", + "pin-project-lite 0.2.9", "signal-hook-registry", "socket2", "tokio-macros", @@ -8292,7 +8298,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df54d54117d6fdc4e4fea40fe1e4e566b3505700e148a6827e59b34b0d2600d9" dependencies = [ "futures-core", - "pin-project-lite 0.2.7", + "pin-project-lite 0.2.9", "tokio", ] @@ -8306,7 +8312,7 @@ dependencies = [ "futures-core", "futures-io", "futures-sink", - "pin-project-lite 0.2.7", + "pin-project-lite 0.2.9", "tokio", "tracing", ] @@ -8328,21 +8334,21 @@ checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" [[package]] name = "tracing" -version = "0.1.30" +version = "0.1.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d8d93354fe2a8e50d5953f5ae2e47a3fc2ef03292e7ea46e3cc38f549525fb9" +checksum = "2fce9567bd60a67d08a16488756721ba392f24f29006402881e43b19aac64307" dependencies = [ "cfg-if", - "pin-project-lite 0.2.7", + "pin-project-lite 0.2.9", "tracing-attributes", "tracing-core", ] [[package]] name = "tracing-attributes" -version = "0.1.19" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8276d9a4a3a558d7b7ad5303ad50b53d58264641b82914b7ada36bd762e7a716" +checksum = "11c75893af559bc8e10716548bdef5cb2b983f8e637db9d0e15126b61b484ee2" dependencies = [ "proc-macro2", "quote", diff --git a/client/cli/src/frontier_db_cmd/mapping_db.rs b/client/cli/src/frontier_db_cmd/mapping_db.rs index 0a048c98d3..a3a332405f 100644 --- a/client/cli/src/frontier_db_cmd/mapping_db.rs +++ b/client/cli/src/frontier_db_cmd/mapping_db.rs @@ -16,15 +16,17 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +use std::sync::Arc; + use ethereum_types::H256; use serde::Deserialize; -use std::sync::Arc; +// Substrate +use sp_runtime::{generic::BlockId, traits::Block as BlockT}; +// Frontier +use fp_rpc::EthereumRuntimeRPCApi; use super::{utils::FrontierDbMessage, Column, FrontierDbCmd, Operation}; -use fp_rpc::EthereumRuntimeRPCApi; -use sp_runtime::{generic::BlockId, traits::Block as BlockT}; - #[derive(Debug, Deserialize)] #[serde(untagged)] pub enum MappingValue { diff --git a/client/cli/src/frontier_db_cmd/meta_db.rs b/client/cli/src/frontier_db_cmd/meta_db.rs index 2f6c42d5ab..e6d2a634eb 100644 --- a/client/cli/src/frontier_db_cmd/meta_db.rs +++ b/client/cli/src/frontier_db_cmd/meta_db.rs @@ -16,18 +16,19 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use ethereum_types::H256; -use serde::Deserialize; use std::{ collections::HashMap, str::{self, FromStr}, sync::Arc, }; -use super::{utils::FrontierDbMessage, FrontierDbCmd, Operation}; - +use ethereum_types::H256; +use serde::Deserialize; +// Substrate use sp_runtime::traits::Block as BlockT; +use super::{utils::FrontierDbMessage, FrontierDbCmd, Operation}; + #[derive(Debug, Deserialize)] #[serde(untagged)] pub enum MetaValue { diff --git a/client/cli/src/frontier_db_cmd/mod.rs b/client/cli/src/frontier_db_cmd/mod.rs index 4f491d9ce0..fff7601b7d 100644 --- a/client/cli/src/frontier_db_cmd/mod.rs +++ b/client/cli/src/frontier_db_cmd/mod.rs @@ -21,17 +21,19 @@ mod meta_db; mod tests; pub(crate) mod utils; -use mapping_db::{MappingDb, MappingKey, MappingValue}; -use meta_db::{MetaDb, MetaKey, MetaValue}; +use std::{path::PathBuf, str::FromStr, sync::Arc}; use clap::ArgEnum; -use sc_cli::{PruningParams, SharedParams}; +use ethereum_types::H256; use serde::Deserialize; -use std::{path::PathBuf, str::FromStr, sync::Arc}; - +// Substrate +use sc_cli::{PruningParams, SharedParams}; use sp_runtime::traits::Block as BlockT; -use ethereum_types::H256; +use self::{ + mapping_db::{MappingDb, MappingKey, MappingValue}, + meta_db::{MetaDb, MetaKey, MetaValue}, +}; /// Cli tool to interact with the Frontier backend db #[derive(Debug, Clone, clap::Parser)] diff --git a/client/cli/src/frontier_db_cmd/tests.rs b/client/cli/src/frontier_db_cmd/tests.rs index a64b4ed8cb..5b05a90199 100644 --- a/client/cli/src/frontier_db_cmd/tests.rs +++ b/client/cli/src/frontier_db_cmd/tests.rs @@ -18,29 +18,30 @@ #[cfg(test)] mod tests { - use frontier_template_runtime::RuntimeApi; - use substrate_test_runtime_client::{ - BlockBuilderExt, ClientBlockImportExt, ClientExt, DefaultTestClientBuilderExt, - TestClientBuilder, - }; - - use std::{collections::HashMap, path::PathBuf, sync::Arc}; + use std::{collections::HashMap, path::PathBuf, str::FromStr, sync::Arc}; - use crate::frontier_db_cmd::{Column, FrontierDbCmd, Operation}; use codec::Encode; use ethereum_types::H256; - use fp_storage::EthereumStorageSchema; use futures::executor; - use sc_block_builder::BlockBuilderProvider; use serde::Serialize; + use tempfile::tempdir; + // Substrate + use sc_block_builder::BlockBuilderProvider; use sp_consensus::BlockOrigin; use sp_io::hashing::twox_128; use sp_runtime::{ generic::{Block, BlockId, Header}, traits::{BlakeTwo256, Block as BlockT}, }; - use std::str::FromStr; - use tempfile::tempdir; + use substrate_test_runtime_client::{ + BlockBuilderExt, ClientBlockImportExt, ClientExt, DefaultTestClientBuilderExt, + TestClientBuilder, + }; + // Frontier + use fp_storage::{EthereumStorageSchema, ETHEREUM_CURRENT_TRANSACTION_STATUS, PALLET_ETHEREUM}; + use frontier_template_runtime::RuntimeApi; + + use crate::frontier_db_cmd::{Column, FrontierDbCmd, Operation}; type OpaqueBlock = Block, substrate_test_runtime_client::runtime::Extrinsic>; @@ -93,8 +94,8 @@ mod tests { detailed_log_output: false, }, pruning_params: sc_cli::PruningParams { - pruning: None, - keep_blocks: None, + state_pruning: None, + blocks_pruning: None, }, } } @@ -530,6 +531,7 @@ mod tests { assert_eq!(backend.meta().ethereum_schema(), Ok(None)); } + #[ignore] #[test] fn commitment_create() { let tmp = tempdir().expect("create a temporary directory"); @@ -544,7 +546,7 @@ mod tests { let statuses = vec![t1]; // Build a block and fill the pallet-ethereum status. - let key = storage_prefix_build(b"Ethereum", b"CurrentTransactionStatuses"); + let key = storage_prefix_build(PALLET_ETHEREUM, ETHEREUM_CURRENT_TRANSACTION_STATUS); let mut builder = client.new_block(Default::default()).unwrap(); builder .push_storage_change(key, Some(statuses.encode())) @@ -598,6 +600,7 @@ mod tests { .is_err()); } + #[ignore] #[test] fn commitment_update() { let tmp = tempdir().expect("create a temporary directory"); @@ -617,7 +620,7 @@ mod tests { let statuses_a1 = vec![t1.clone()]; let statuses_a2 = vec![t1, t2]; - let key = storage_prefix_build(b"Ethereum", b"CurrentTransactionStatuses"); + let key = storage_prefix_build(PALLET_ETHEREUM, ETHEREUM_CURRENT_TRANSACTION_STATUS); // First we create block and insert data in the offchain db. @@ -733,6 +736,7 @@ mod tests { ); } + #[ignore] #[test] fn mapping_read_works() { let tmp = tempdir().expect("create a temporary directory"); @@ -747,7 +751,7 @@ mod tests { let statuses = vec![t1]; // Build a block and fill the pallet-ethereum status. - let key = storage_prefix_build(b"Ethereum", b"CurrentTransactionStatuses"); + let key = storage_prefix_build(PALLET_ETHEREUM, ETHEREUM_CURRENT_TRANSACTION_STATUS); let mut builder = client.new_block(Default::default()).unwrap(); builder .push_storage_change(key, Some(statuses.encode())) @@ -764,13 +768,14 @@ mod tests { // Create command using some ethereum block hash as key. let ethereum_block_hash = H256::default(); - let _ = cmd( + assert!(cmd( format!("{:?}", ethereum_block_hash), Some(test_value_path.clone()), Operation::Create, Column::Block, ) - .run(Arc::clone(&client), backend.clone()); + .run(Arc::clone(&client), backend.clone()) + .is_ok()); // Read block command. assert!(cmd( diff --git a/client/cli/src/frontier_db_cmd/utils.rs b/client/cli/src/frontier_db_cmd/utils.rs index 4c203b69a6..a1095534c8 100644 --- a/client/cli/src/frontier_db_cmd/utils.rs +++ b/client/cli/src/frontier_db_cmd/utils.rs @@ -15,21 +15,22 @@ // // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#![allow(clippy::useless_format)] -#![allow(clippy::format_in_format_args)] -use super::{DbValue, Operation}; +#![allow(clippy::format_in_format_args)] -use serde::de::DeserializeOwned; -use serde_json::Deserializer; use std::{ fs, io::{self, Read}, path::PathBuf, }; +use serde::de::DeserializeOwned; +use serde_json::Deserializer; +// Substrate use sp_runtime::traits::Block as BlockT; +use super::{DbValue, Operation}; + pub fn maybe_deserialize_value( operation: &Operation, value: Option<&PathBuf>, @@ -41,7 +42,7 @@ pub fn maybe_deserialize_value( if let Some(Ok(value)) = stream_deser.next() { Ok(Some(value)) } else { - Err("Failed to deserialize value data".to_string().into()) + Err("Failed to deserialize value data".into()) } } @@ -91,7 +92,7 @@ pub trait FrontierDbMessage { } fn one_to_many_error(&self) -> sc_cli::Error { - "One-to-many operation not allowed".to_string().into() + "One-to-many operation not allowed".into() } #[cfg(not(test))] @@ -121,7 +122,7 @@ pub trait FrontierDbMessage { let mut buffer = String::new(); io::stdin().read_line(&mut buffer)?; if buffer.trim() != "confirm" { - return Err(format!("-- Cancel exit --").into()); + return Err("-- Cancel exit --".into()); } Ok(()) } diff --git a/client/consensus/src/lib.rs b/client/consensus/src/lib.rs index 47ee25b062..88b3a4361d 100644 --- a/client/consensus/src/lib.rs +++ b/client/consensus/src/lib.rs @@ -18,6 +18,7 @@ use std::{collections::HashMap, marker::PhantomData, sync::Arc}; +// Substrate use sc_client_api::{backend::AuxStore, BlockOf}; use sc_consensus::{BlockCheckParams, BlockImport, BlockImportParams, ImportResult}; use sp_api::ProvideRuntimeApi; @@ -25,7 +26,7 @@ use sp_block_builder::BlockBuilder as BlockBuilderApi; use sp_blockchain::{well_known_cache_keys::Id as CacheKeyId, HeaderBackend}; use sp_consensus::Error as ConsensusError; use sp_runtime::traits::{Block as BlockT, Header as HeaderT}; - +// Frontier use fp_consensus::{ensure_log, FindLogError}; use fp_rpc::EthereumRuntimeRPCApi; diff --git a/client/db/src/lib.rs b/client/db/src/lib.rs index 3caa87d382..c5b83da3a8 100644 --- a/client/db/src/lib.rs +++ b/client/db/src/lib.rs @@ -27,12 +27,14 @@ use std::{ }; use codec::{Decode, Encode}; -use fp_storage::{EthereumStorageSchema, PALLET_ETHEREUM_SCHEMA_CACHE}; use parking_lot::Mutex; +// Substrate pub use sc_client_db::DatabaseSource; use sp_core::H256; pub use sp_database::Database; use sp_runtime::traits::Block as BlockT; +// Frontier +use fp_storage::{EthereumStorageSchema, PALLET_ETHEREUM_SCHEMA_CACHE}; const DB_HASH_LEN: usize = 32; /// Hash type that this backend uses for the database. diff --git a/client/db/src/parity_db_adapter.rs b/client/db/src/parity_db_adapter.rs index 9d79f1ea03..26168ec34f 100644 --- a/client/db/src/parity_db_adapter.rs +++ b/client/db/src/parity_db_adapter.rs @@ -16,9 +16,10 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use crate::Database; use sp_database::{error::DatabaseError, Change, ColumnId, Transaction}; +use crate::Database; + fn handle_err(result: parity_db::Result) -> T { match result { Ok(r) => r, diff --git a/client/mapping-sync/src/lib.rs b/client/mapping-sync/src/lib.rs index b4c96e3e38..dcbd6ab823 100644 --- a/client/mapping-sync/src/lib.rs +++ b/client/mapping-sync/src/lib.rs @@ -22,8 +22,7 @@ mod worker; pub use worker::{MappingSyncWorker, SyncStrategy}; -use fp_consensus::FindLogError; -use fp_rpc::EthereumRuntimeRPCApi; +// Substrate use sc_client_api::BlockOf; use sp_api::{ApiExt, ProvideRuntimeApi}; use sp_blockchain::HeaderBackend; @@ -31,6 +30,9 @@ use sp_runtime::{ generic::BlockId, traits::{Block as BlockT, Header as HeaderT, Zero}, }; +// Frontier +use fp_consensus::FindLogError; +use fp_rpc::EthereumRuntimeRPCApi; pub fn sync_block( backend: &fc_db::Backend, diff --git a/client/mapping-sync/src/worker.rs b/client/mapping-sync/src/worker.rs index dd940dafc9..5c6c371634 100644 --- a/client/mapping-sync/src/worker.rs +++ b/client/mapping-sync/src/worker.rs @@ -16,18 +16,21 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use fp_rpc::EthereumRuntimeRPCApi; +use std::{pin::Pin, sync::Arc, time::Duration}; + use futures::{ prelude::*, task::{Context, Poll}, }; use futures_timer::Delay; use log::debug; +// Substrate use sc_client_api::{BlockOf, ImportNotifications}; use sp_api::ProvideRuntimeApi; use sp_blockchain::HeaderBackend; use sp_runtime::traits::{Block as BlockT, Header as HeaderT}; -use std::{pin::Pin, sync::Arc, time::Duration}; +// Frontier +use fp_rpc::EthereumRuntimeRPCApi; #[derive(PartialEq, Copy, Clone)] pub enum SyncStrategy { diff --git a/client/rpc-core/Cargo.toml b/client/rpc-core/Cargo.toml index aaf794510c..eafdf96802 100644 --- a/client/rpc-core/Cargo.toml +++ b/client/rpc-core/Cargo.toml @@ -18,5 +18,5 @@ serde_json = "1.0" # Parity ethereum-types = "0.13.1" -jsonrpsee = { version = "0.14.0", features = ["server", "macros"] } +jsonrpsee = { version = "0.15.1", features = ["server", "macros"] } rlp = "0.5" diff --git a/client/rpc/Cargo.toml b/client/rpc/Cargo.toml index ffe412ac53..d2297b2345 100644 --- a/client/rpc/Cargo.toml +++ b/client/rpc/Cargo.toml @@ -24,7 +24,7 @@ tokio = { version = "1.19", features = ["sync"] } # Parity codec = { package = "parity-scale-codec", version = "3.0.0" } ethereum-types = "0.13.1" -jsonrpsee = { version = "0.14.0", features = ["server", "macros"] } +jsonrpsee = { version = "0.15.1", features = ["server", "macros"] } libsecp256k1 = "0.7" rlp = "0.5" @@ -32,6 +32,7 @@ rlp = "0.5" prometheus-endpoint = { package = "substrate-prometheus-endpoint", git = "https://github.com/paritytech/substrate", branch = "master" } sc-client-api = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "master" } sc-network = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate", branch = "master" } +sc-network-common = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate", branch = "master" } sc-rpc = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "master" } sc-service = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate", branch = "master" } sc-transaction-pool = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "master" } @@ -39,6 +40,7 @@ sc-transaction-pool-api = { version = "4.0.0-dev", git = "https://github.com/par sp-api = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "master" } sp-block-builder = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "master" } sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "master" } +sp-consensus = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate", branch = "master" } sp-core = { version = "6.0.0", git = "https://github.com/paritytech/substrate", branch = "master" } sp-io = { version = "6.0.0", git = "https://github.com/paritytech/substrate", branch = "master" } sp-runtime = { version = "6.0.0", git = "https://github.com/paritytech/substrate", branch = "master" } diff --git a/client/rpc/src/eth/block.rs b/client/rpc/src/eth/block.rs index 821ec9f4ad..972063f201 100644 --- a/client/rpc/src/eth/block.rs +++ b/client/rpc/src/eth/block.rs @@ -20,14 +20,14 @@ use std::sync::Arc; use ethereum_types::{H256, U256}; use jsonrpsee::core::RpcResult as Result; - +// Substrate use sc_client_api::backend::{Backend, StateBackend, StorageProvider}; use sc_network::ExHashT; use sc_transaction_pool::ChainApi; use sp_blockchain::HeaderBackend; use sp_core::hashing::keccak_256; use sp_runtime::traits::{BlakeTwo256, Block as BlockT}; - +// Frontier use fc_rpc_core::types::*; use crate::{ diff --git a/client/rpc/src/eth/cache/mod.rs b/client/rpc/src/eth/cache/mod.rs index 6aa019e036..70addaf7f8 100644 --- a/client/rpc/src/eth/cache/mod.rs +++ b/client/rpc/src/eth/cache/mod.rs @@ -24,12 +24,11 @@ use std::{ sync::{Arc, Mutex}, }; -use self::lru_cache::LRUCacheByteLimited; use ethereum::BlockV2 as EthereumBlock; use ethereum_types::{H256, U256}; use futures::StreamExt; use tokio::sync::{mpsc, oneshot}; - +// Substrate use sc_client_api::{ backend::{Backend, StateBackend, StorageProvider}, client::BlockchainEvents, @@ -41,11 +40,12 @@ use sp_runtime::{ generic::BlockId, traits::{BlakeTwo256, Block as BlockT, Header as HeaderT, UniqueSaturatedInto}, }; - +// Frontier use fc_rpc_core::types::*; use fp_rpc::{EthereumRuntimeRPCApi, TransactionStatus}; use fp_storage::EthereumStorageSchema; +use self::lru_cache::LRUCacheByteLimited; use crate::{ frontier_backend_client, overrides::{OverrideHandle, StorageOverride}, diff --git a/client/rpc/src/eth/client.rs b/client/rpc/src/eth/client.rs index 7d871a7add..320eb1e8fc 100644 --- a/client/rpc/src/eth/client.rs +++ b/client/rpc/src/eth/client.rs @@ -18,17 +18,18 @@ use ethereum_types::{H160, H256, U256, U64}; use jsonrpsee::core::RpcResult as Result; - +// Substrate use sc_client_api::backend::{Backend, StateBackend, StorageProvider}; use sc_network::ExHashT; use sc_transaction_pool::ChainApi; use sp_api::ProvideRuntimeApi; use sp_blockchain::HeaderBackend; +use sp_consensus::SyncOracle; use sp_runtime::{ generic::BlockId, traits::{BlakeTwo256, Block as BlockT, UniqueSaturatedInto}, }; - +// Frontier use fc_rpc_core::types::*; use fp_rpc::EthereumRuntimeRPCApi; diff --git a/client/rpc/src/eth/execute.rs b/client/rpc/src/eth/execute.rs index 355c041bdd..e079d6c797 100644 --- a/client/rpc/src/eth/execute.rs +++ b/client/rpc/src/eth/execute.rs @@ -21,7 +21,7 @@ use std::sync::Arc; use ethereum_types::{H256, U256}; use evm::{ExitError, ExitReason}; use jsonrpsee::core::RpcResult as Result; - +// Substrate use sc_client_api::backend::{Backend, StateBackend, StorageProvider}; use sc_network::ExHashT; use sc_transaction_pool::ChainApi; @@ -33,7 +33,7 @@ use sp_runtime::{ traits::{BlakeTwo256, Block as BlockT}, SaturatedConversion, }; - +// Frontier use fc_rpc_core::types::*; use fp_rpc::EthereumRuntimeRPCApi; diff --git a/client/rpc/src/eth/fee.rs b/client/rpc/src/eth/fee.rs index 3968d7b0d0..29ebff4a65 100644 --- a/client/rpc/src/eth/fee.rs +++ b/client/rpc/src/eth/fee.rs @@ -18,7 +18,7 @@ use ethereum_types::{H256, U256}; use jsonrpsee::core::RpcResult as Result; - +// Substrate use sc_client_api::backend::{Backend, StateBackend, StorageProvider}; use sc_network::ExHashT; use sc_transaction_pool::ChainApi; @@ -28,7 +28,7 @@ use sp_runtime::{ generic::BlockId, traits::{BlakeTwo256, Block as BlockT, Header as HeaderT, UniqueSaturatedInto}, }; - +// Frontier use fc_rpc_core::types::*; use fp_rpc::EthereumRuntimeRPCApi; diff --git a/client/rpc/src/eth/filter.rs b/client/rpc/src/eth/filter.rs index 6e0dd142f7..f275c2ead4 100644 --- a/client/rpc/src/eth/filter.rs +++ b/client/rpc/src/eth/filter.rs @@ -21,7 +21,7 @@ use std::{marker::PhantomData, sync::Arc, time}; use ethereum::BlockV2 as EthereumBlock; use ethereum_types::{H256, U256}; use jsonrpsee::core::{async_trait, RpcResult as Result}; - +// Substrate use sc_client_api::backend::{Backend, StateBackend, StorageProvider}; use sp_api::ProvideRuntimeApi; use sp_blockchain::HeaderBackend; @@ -30,7 +30,7 @@ use sp_runtime::{ generic::BlockId, traits::{BlakeTwo256, Block as BlockT, NumberFor, One, Saturating, UniqueSaturatedInto}, }; - +// Frontier use fc_rpc_core::{types::*, EthFilterApiServer}; use fp_rpc::{EthereumRuntimeRPCApi, TransactionStatus}; diff --git a/client/rpc/src/eth/format.rs b/client/rpc/src/eth/format.rs index 421da8f1ca..19df69e2a2 100644 --- a/client/rpc/src/eth/format.rs +++ b/client/rpc/src/eth/format.rs @@ -16,9 +16,11 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use fp_evm::InvalidEvmTransactionError as VError; +// Substrate use sc_transaction_pool_api::error::{Error as PError, IntoPoolError}; use sp_runtime::transaction_validity::InvalidTransaction; +// Frontier +use fp_evm::InvalidEvmTransactionError as VError; // Formats the same way Geth node formats responses. pub struct Geth; diff --git a/client/rpc/src/eth/mining.rs b/client/rpc/src/eth/mining.rs index c662c206c8..90897d24ad 100644 --- a/client/rpc/src/eth/mining.rs +++ b/client/rpc/src/eth/mining.rs @@ -18,11 +18,11 @@ use ethereum_types::{H256, H64, U256}; use jsonrpsee::core::RpcResult as Result; - +// Substrate use sc_network::ExHashT; use sc_transaction_pool::ChainApi; use sp_runtime::traits::Block as BlockT; - +// Frontier use fc_rpc_core::types::*; use crate::eth::Eth; diff --git a/client/rpc/src/eth/mod.rs b/client/rpc/src/eth/mod.rs index 110785f675..7e1ce0220c 100644 --- a/client/rpc/src/eth/mod.rs +++ b/client/rpc/src/eth/mod.rs @@ -33,7 +33,7 @@ use std::{collections::BTreeMap, marker::PhantomData, sync::Arc}; use ethereum::{BlockV2 as EthereumBlock, TransactionV2 as EthereumTransaction}; use ethereum_types::{H160, H256, H512, H64, U256, U64}; use jsonrpsee::core::{async_trait, RpcResult as Result}; - +// Substrate use sc_client_api::backend::{Backend, StateBackend, StorageProvider}; use sc_network::{ExHashT, NetworkService}; use sc_transaction_pool::{ChainApi, Pool}; @@ -46,7 +46,7 @@ use sp_runtime::{ generic::BlockId, traits::{BlakeTwo256, Block as BlockT, UniqueSaturatedInto}, }; - +// Frontier use fc_rpc_core::{types::*, EthApiServer}; use fp_rpc::{ConvertTransactionRuntimeApi, EthereumRuntimeRPCApi, TransactionStatus}; diff --git a/client/rpc/src/eth/state.rs b/client/rpc/src/eth/state.rs index c637c84660..b37b6dffdc 100644 --- a/client/rpc/src/eth/state.rs +++ b/client/rpc/src/eth/state.rs @@ -16,10 +16,10 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +use codec::Encode; use ethereum_types::{H160, H256, U256}; use jsonrpsee::core::RpcResult as Result; - -use codec::Encode; +// Substrate use sc_client_api::backend::{Backend, StateBackend, StorageProvider}; use sc_network::ExHashT; use sc_transaction_pool::ChainApi; @@ -31,7 +31,7 @@ use sp_runtime::{ generic::BlockId, traits::{BlakeTwo256, Block as BlockT}, }; - +// Frontier use fc_rpc_core::types::*; use fp_rpc::EthereumRuntimeRPCApi; diff --git a/client/rpc/src/eth/submit.rs b/client/rpc/src/eth/submit.rs index 1ae62284a5..9bee93bb45 100644 --- a/client/rpc/src/eth/submit.rs +++ b/client/rpc/src/eth/submit.rs @@ -19,7 +19,7 @@ use ethereum_types::H256; use futures::future::TryFutureExt; use jsonrpsee::core::RpcResult as Result; - +// Substrate use sc_client_api::backend::{Backend, StateBackend, StorageProvider}; use sc_network::ExHashT; use sc_transaction_pool::ChainApi; @@ -32,7 +32,7 @@ use sp_runtime::{ traits::{BlakeTwo256, Block as BlockT}, transaction_validity::TransactionSource, }; - +// Frontier use fc_rpc_core::types::*; use fp_rpc::{ConvertTransaction, ConvertTransactionRuntimeApi, EthereumRuntimeRPCApi}; diff --git a/client/rpc/src/eth/transaction.rs b/client/rpc/src/eth/transaction.rs index 980416ff4d..6b1489662d 100644 --- a/client/rpc/src/eth/transaction.rs +++ b/client/rpc/src/eth/transaction.rs @@ -21,7 +21,7 @@ use std::sync::Arc; use ethereum::TransactionV2 as EthereumTransaction; use ethereum_types::{H256, U256, U64}; use jsonrpsee::core::RpcResult as Result; - +// Substrate use sc_client_api::backend::{Backend, StateBackend, StorageProvider}; use sc_network::ExHashT; use sc_transaction_pool::ChainApi; @@ -33,7 +33,7 @@ use sp_runtime::{ generic::BlockId, traits::{BlakeTwo256, Block as BlockT}, }; - +// Frontier use fc_rpc_core::types::*; use fp_rpc::EthereumRuntimeRPCApi; diff --git a/client/rpc/src/eth_pubsub.rs b/client/rpc/src/eth_pubsub.rs index bc65e6cebb..51275b66ad 100644 --- a/client/rpc/src/eth_pubsub.rs +++ b/client/rpc/src/eth_pubsub.rs @@ -21,20 +21,21 @@ use std::{collections::BTreeMap, marker::PhantomData, sync::Arc}; use ethereum::{BlockV2 as EthereumBlock, TransactionV2 as EthereumTransaction}; use ethereum_types::{H256, U256}; use futures::{FutureExt as _, StreamExt as _}; -use jsonrpsee::PendingSubscription; - +use jsonrpsee::{types::SubscriptionResult, SubscriptionSink}; +// Substrate use sc_client_api::{ backend::{Backend, StateBackend, StorageProvider}, client::BlockchainEvents, }; -use sc_network::{ExHashT, NetworkService}; +use sc_network::{ExHashT, NetworkService, NetworkStatusProvider}; use sc_rpc::SubscriptionTaskExecutor; use sc_transaction_pool_api::TransactionPool; use sp_api::{ApiExt, BlockId, ProvideRuntimeApi}; use sp_blockchain::HeaderBackend; +use sp_consensus::SyncOracle; use sp_core::hashing::keccak_256; use sp_runtime::traits::{BlakeTwo256, Block as BlockT, UniqueSaturatedInto}; - +// Frontier use fc_rpc_core::{ types::{ pubsub::{Kind, Params, PubSubSyncStatus, Result as PubSubResult, SyncStatusMetadata}, @@ -92,12 +93,9 @@ where } } -struct SubscriptionResult {} -impl SubscriptionResult { - pub fn new() -> Self { - SubscriptionResult {} - } - pub fn new_heads(&self, block: EthereumBlock) -> PubSubResult { +struct EthSubscriptionResult; +impl EthSubscriptionResult { + pub fn new_heads(block: EthereumBlock) -> PubSubResult { PubSubResult::Header(Box::new(Rich { inner: Header { hash: Some(H256::from(keccak_256(&rlp::encode(&block.header)))), @@ -122,7 +120,6 @@ impl SubscriptionResult { })) } pub fn logs( - &self, block: EthereumBlock, receipts: Vec, params: &FilteredParams, @@ -143,7 +140,7 @@ impl SubscriptionResult { None }; for log in receipt_logs { - if self.add_log(block_hash.unwrap(), &log, &block, params) { + if Self::add_log(block_hash.unwrap(), &log, &block, params) { logs.push(Log { address: log.address, topics: log.topics, @@ -164,7 +161,6 @@ impl SubscriptionResult { logs } fn add_log( - &self, block_hash: H256, ethereum_log: ðereum::Log, block: &EthereumBlock, @@ -207,12 +203,13 @@ where BE: Backend + 'static, BE::State: StateBackend, { - fn subscribe(&self, sink: PendingSubscription, kind: Kind, params: Option) { - let mut sink = if let Some(sink) = sink.accept() { - sink - } else { - return; - }; + fn subscribe( + &self, + mut sink: SubscriptionSink, + kind: Kind, + params: Option, + ) -> SubscriptionResult { + sink.accept()?; let filtered_params = match params { Some(Params::Logs(filter)) => FilteredParams::new(Some(filter)), @@ -257,7 +254,7 @@ where } }) .flat_map(move |(block, receipts)| { - futures::stream::iter(SubscriptionResult::new().logs( + futures::stream::iter(EthSubscriptionResult::logs( block, receipts, &filtered_params, @@ -289,7 +286,7 @@ where futures::future::ready(None) } }) - .map(|block| SubscriptionResult::new().new_heads(block)); + .map(EthSubscriptionResult::new_heads); sink.pipe_from_stream(stream).await; } Kind::NewPendingTransactions => { @@ -412,5 +409,6 @@ where Some("rpc"), fut.map(drop).boxed(), ); + Ok(()) } } diff --git a/client/rpc/src/lib.rs b/client/rpc/src/lib.rs index 647f8f7985..2b2f2242e6 100644 --- a/client/rpc/src/lib.rs +++ b/client/rpc/src/lib.rs @@ -54,7 +54,7 @@ pub mod frontier_backend_client { use codec::Decode; use ethereum_types::H256; use jsonrpsee::core::RpcResult; - + // Substrate use sc_client_api::backend::{Backend, StateBackend, StorageProvider}; use sp_blockchain::HeaderBackend; use sp_runtime::{ @@ -62,7 +62,7 @@ pub mod frontier_backend_client { traits::{BlakeTwo256, Block as BlockT, Header as HeaderT, UniqueSaturatedInto, Zero}, }; use sp_storage::StorageKey; - + // Frontier use fc_rpc_core::types::BlockNumber; use fp_storage::{EthereumStorageSchema, PALLET_ETHEREUM_SCHEMA}; diff --git a/client/rpc/src/net.rs b/client/rpc/src/net.rs index 2ee504935e..2000b62fb6 100644 --- a/client/rpc/src/net.rs +++ b/client/rpc/src/net.rs @@ -20,11 +20,13 @@ use std::sync::Arc; use ethereum_types::H256; use jsonrpsee::core::RpcResult as Result; +// Substrate use sc_network::{ExHashT, NetworkService}; +use sc_network_common::service::NetworkPeers; use sp_api::ProvideRuntimeApi; use sp_blockchain::HeaderBackend; use sp_runtime::{generic::BlockId, traits::Block as BlockT}; - +// Frontier use fc_rpc_core::{types::PeerCount, NetApiServer}; use fp_rpc::EthereumRuntimeRPCApi; @@ -68,7 +70,7 @@ where } fn peer_count(&self) -> Result { - let peer_count = self.network.num_connected(); + let peer_count = self.network.sync_num_connected(); Ok(match self.peer_count_as_hex { true => PeerCount::String(format!("0x{:x}", peer_count)), false => PeerCount::U32(peer_count as u32), diff --git a/client/rpc/src/overrides/mod.rs b/client/rpc/src/overrides/mod.rs index 914346f580..43836d4be1 100644 --- a/client/rpc/src/overrides/mod.rs +++ b/client/rpc/src/overrides/mod.rs @@ -16,16 +16,17 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use std::collections::BTreeMap; +use std::{collections::BTreeMap, marker::PhantomData, sync::Arc}; use ethereum::BlockV2 as EthereumBlock; use ethereum_types::{H160, H256, U256}; -use fp_rpc::{EthereumRuntimeRPCApi, TransactionStatus}; -use fp_storage::EthereumStorageSchema; +// Substrate use sp_api::{ApiExt, BlockId, ProvideRuntimeApi}; use sp_io::hashing::{blake2_128, twox_128}; use sp_runtime::{traits::Block as BlockT, Permill}; -use std::{marker::PhantomData, sync::Arc}; +// Frontier +use fp_rpc::{EthereumRuntimeRPCApi, TransactionStatus}; +use fp_storage::EthereumStorageSchema; mod schema_v1_override; mod schema_v2_override; diff --git a/client/rpc/src/overrides/schema_v1_override.rs b/client/rpc/src/overrides/schema_v1_override.rs index dd0fee16a7..7258bc733e 100644 --- a/client/rpc/src/overrides/schema_v1_override.rs +++ b/client/rpc/src/overrides/schema_v1_override.rs @@ -20,7 +20,7 @@ use std::{marker::PhantomData, sync::Arc}; use codec::Decode; use ethereum_types::{H160, H256, U256}; - +// Substrate use sc_client_api::backend::{Backend, StateBackend, StorageProvider}; use sp_api::BlockId; use sp_runtime::{ @@ -28,7 +28,7 @@ use sp_runtime::{ Permill, }; use sp_storage::StorageKey; - +// Frontier use fp_rpc::TransactionStatus; use fp_storage::*; @@ -133,8 +133,8 @@ where self.query_storage::>( block, &StorageKey(storage_prefix_build( - b"Ethereum", - b"CurrentTransactionStatuses", + PALLET_ETHEREUM, + ETHEREUM_CURRENT_TRANSACTION_STATUS, )), ) } diff --git a/client/rpc/src/overrides/schema_v2_override.rs b/client/rpc/src/overrides/schema_v2_override.rs index 80faff842a..713c79eede 100644 --- a/client/rpc/src/overrides/schema_v2_override.rs +++ b/client/rpc/src/overrides/schema_v2_override.rs @@ -20,7 +20,7 @@ use std::{marker::PhantomData, sync::Arc}; use codec::Decode; use ethereum_types::{H160, H256, U256}; - +// Substrate use sc_client_api::backend::{Backend, StateBackend, StorageProvider}; use sp_api::BlockId; use sp_runtime::{ @@ -28,7 +28,7 @@ use sp_runtime::{ Permill, }; use sp_storage::StorageKey; - +// Frontier use fp_rpc::TransactionStatus; use fp_storage::*; diff --git a/client/rpc/src/overrides/schema_v3_override.rs b/client/rpc/src/overrides/schema_v3_override.rs index b157b4f5ba..f2209554ca 100644 --- a/client/rpc/src/overrides/schema_v3_override.rs +++ b/client/rpc/src/overrides/schema_v3_override.rs @@ -20,7 +20,7 @@ use std::{marker::PhantomData, sync::Arc}; use codec::Decode; use ethereum_types::{H160, H256, U256}; - +// Substrate use sc_client_api::backend::{Backend, StateBackend, StorageProvider}; use sp_api::BlockId; use sp_runtime::{ @@ -28,7 +28,7 @@ use sp_runtime::{ Permill, }; use sp_storage::StorageKey; - +// Frontier use fp_rpc::TransactionStatus; use fp_storage::*; diff --git a/client/rpc/src/signer.rs b/client/rpc/src/signer.rs index 7ae8042bac..c1c90fb4a0 100644 --- a/client/rpc/src/signer.rs +++ b/client/rpc/src/signer.rs @@ -19,9 +19,10 @@ use ethereum::TransactionV2 as EthereumTransaction; use ethereum_types::{H160, H256}; use jsonrpsee::core::Error; - -use fc_rpc_core::types::TransactionMessage; +// Substrate use sp_core::hashing::keccak_256; +// Frontier +use fc_rpc_core::types::TransactionMessage; use crate::internal_err; diff --git a/client/rpc/src/web3.rs b/client/rpc/src/web3.rs index 7f664ee0f0..417db683b2 100644 --- a/client/rpc/src/web3.rs +++ b/client/rpc/src/web3.rs @@ -20,11 +20,12 @@ use std::{marker::PhantomData, sync::Arc}; use ethereum_types::H256; use jsonrpsee::core::RpcResult as Result; +// Substrate use sp_api::{Core, ProvideRuntimeApi}; use sp_blockchain::HeaderBackend; use sp_core::keccak_256; use sp_runtime::{generic::BlockId, traits::Block as BlockT}; - +// Frontier use fc_rpc_core::{types::Bytes, Web3ApiServer}; use fp_rpc::EthereumRuntimeRPCApi; diff --git a/template/node/Cargo.toml b/template/node/Cargo.toml index 05472247b0..1ad36412ce 100644 --- a/template/node/Cargo.toml +++ b/template/node/Cargo.toml @@ -19,7 +19,7 @@ log = "0.4.17" # Parity codec = { package = "parity-scale-codec", version = "3.1", features = ["derive"] } -jsonrpsee = { version = "0.14.0", features = ["server", "macros"] } +jsonrpsee = { version = "0.15.1", features = ["server", "macros"] } # Substrate sc-basic-authorship = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate", branch = "master" } From 6576c564509a8f91c94f477a7d5901f5a8e1ffa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lo=C3=AFs?= Date: Mon, 3 Oct 2022 13:36:11 +0200 Subject: [PATCH 13/21] add feature forbid-evm-reentrancy (#863) * add feature forbid-evm-reentrancy * apply suggestions * link feature forbid-evm-reentrancy * clippy --- Cargo.lock | 1 + frame/ethereum/Cargo.toml | 1 + frame/evm/Cargo.toml | 3 + frame/evm/src/lib.rs | 3 + frame/evm/src/runner/stack.rs | 127 ++++++++++++++++++++++++++++++++++ 5 files changed, 135 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index d5e83d2660..40b5214338 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4514,6 +4514,7 @@ dependencies = [ name = "pallet-evm" version = "6.0.0-dev" dependencies = [ + "environmental", "evm", "fp-evm", "frame-benchmarking", diff --git a/frame/ethereum/Cargo.toml b/frame/ethereum/Cargo.toml index 33bc9bb96a..3afdc2592f 100644 --- a/frame/ethereum/Cargo.toml +++ b/frame/ethereum/Cargo.toml @@ -83,3 +83,4 @@ runtime-benchmarks = [ "pallet-evm/runtime-benchmarks", ] try-runtime = ["frame-support/try-runtime"] +forbid-evm-reentrancy = ["pallet-evm/forbid-evm-reentrancy"] diff --git a/frame/evm/Cargo.toml b/frame/evm/Cargo.toml index eefb26cf5b..52ffb54fac 100644 --- a/frame/evm/Cargo.toml +++ b/frame/evm/Cargo.toml @@ -12,6 +12,7 @@ repository = "https://github.com/paritytech/frontier/" targets = ["x86_64-unknown-linux-gnu"] [dependencies] +environmental = { version = "1.1.3", default-features = false, optional = true } evm = { git = "https://github.com/rust-blockchain/evm", rev = "51b8c2ce3104265e1fd5bb0fe5cdfd2e0938239c", default-features = false, features = ["with-codec"] } hex = { version = "0.4.3", default-features = false, features = ["alloc"] } log = { version = "0.4.17", default-features = false } @@ -43,6 +44,7 @@ pallet-balances = { version = "4.0.0-dev", git = "https://github.com/paritytech/ [features] default = ["std"] std = [ + "environmental?/std", "evm/std", "evm/with-serde", "hex/std", @@ -72,3 +74,4 @@ runtime-benchmarks = [ "frame-system/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", ] +forbid-evm-reentrancy = ["dep:environmental"] diff --git a/frame/evm/src/lib.rs b/frame/evm/src/lib.rs index f2c2a4255d..32daa66950 100644 --- a/frame/evm/src/lib.rs +++ b/frame/evm/src/lib.rs @@ -53,6 +53,7 @@ // Ensure we're `no_std` when compiling for Wasm. #![cfg_attr(not(feature = "std"), no_std)] #![allow(clippy::too_many_arguments)] +#![cfg_attr(test, feature(assert_matches))] #[cfg(feature = "runtime-benchmarks")] pub mod benchmarking; @@ -417,6 +418,8 @@ pub mod pallet { GasLimitTooHigh, /// Undefined error. Undefined, + /// EVM reentrancy + Reentrancy, } impl From for Error { diff --git a/frame/evm/src/runner/stack.rs b/frame/evm/src/runner/stack.rs index 886ccfb2f4..225c3d5065 100644 --- a/frame/evm/src/runner/stack.rs +++ b/frame/evm/src/runner/stack.rs @@ -33,6 +33,9 @@ use sp_core::{H160, H256, U256}; use sp_runtime::traits::UniqueSaturatedInto; use sp_std::{boxed::Box, collections::btree_set::BTreeSet, marker::PhantomData, mem, vec::Vec}; +#[cfg(feature = "forbid-evm-reentrancy")] +environmental::thread_local_impl!(static IN_EVM: environmental::RefCell = environmental::RefCell::new(false)); + #[derive(Default)] pub struct Runner { _marker: PhantomData, @@ -42,6 +45,7 @@ impl Runner where BalanceOf: TryFrom + Into, { + #[allow(clippy::let_and_return)] /// Execute an already validated EVM operation. fn execute<'config, 'precompiles, F, R>( source: H160, @@ -65,6 +69,61 @@ where ) -> (ExitReason, R), { let (base_fee, weight) = T::FeeCalculator::min_gas_price(); + + #[cfg(feature = "forbid-evm-reentrancy")] + if IN_EVM.with(|in_evm| in_evm.replace(true)) { + return Err(RunnerError { + error: Error::::Reentrancy, + weight, + }); + } + + let res = Self::execute_inner( + source, + value, + gas_limit, + max_fee_per_gas, + max_priority_fee_per_gas, + config, + precompiles, + is_transactional, + f, + base_fee, + weight, + ); + + // Set IN_EVM to false + // We should make sure that this line is executed whatever the execution path. + #[cfg(feature = "forbid-evm-reentrancy")] + let _ = IN_EVM.with(|in_evm| in_evm.take()); + + res + } + + // Execute an already validated EVM operation. + fn execute_inner<'config, 'precompiles, F, R>( + source: H160, + value: U256, + gas_limit: u64, + max_fee_per_gas: Option, + max_priority_fee_per_gas: Option, + config: &'config evm::Config, + precompiles: &'precompiles T::PrecompilesType, + is_transactional: bool, + f: F, + base_fee: U256, + weight: crate::Weight, + ) -> Result, RunnerError>> + where + F: FnOnce( + &mut StackExecutor< + 'config, + 'precompiles, + SubstrateStackState<'_, 'config, T>, + T::PrecompilesType, + >, + ) -> (ExitReason, R), + { let max_fee_per_gas = match (max_fee_per_gas, is_transactional) { (Some(max_fee_per_gas), _) => max_fee_per_gas, // Gas price check is skipped for non-transactional calls that don't @@ -714,3 +773,71 @@ where .recursive_is_cold(&|a: &Accessed| a.accessed_storage.contains(&(address, key))) } } + +#[cfg(feature = "forbid-evm-reentrancy")] +#[cfg(test)] +mod tests { + use super::*; + use crate::mock::Test; + use evm::ExitSucceed; + use std::assert_matches::assert_matches; + + #[test] + fn test_evm_reentrancy() { + let config = evm::Config::istanbul(); + + // Should fail with the appropriate error if there is reentrancy + let res = Runner::::execute( + H160::default(), + U256::default(), + 100_000, + None, + None, + &config, + &(), + false, + |_| { + let res = Runner::::execute( + H160::default(), + U256::default(), + 100_000, + None, + None, + &config, + &(), + false, + |_| (ExitReason::Succeed(ExitSucceed::Stopped), ()), + ); + assert_matches!( + res, + Err(RunnerError { + error: Error::::Reentrancy, + .. + }) + ); + (ExitReason::Error(ExitError::CallTooDeep), ()) + }, + ); + assert_matches!( + res, + Ok(ExecutionInfo { + exit_reason: ExitReason::Error(ExitError::CallTooDeep), + .. + }) + ); + + // Should succeed if there is no reentrancy + let res = Runner::::execute( + H160::default(), + U256::default(), + 100_000, + None, + None, + &config, + &(), + false, + |_| (ExitReason::Succeed(ExitSucceed::Stopped), ()), + ); + assert!(res.is_ok()); + } +} From 2d802a10c9e17bc2585415781fd374ecfea9f8be Mon Sep 17 00:00:00 2001 From: tgmichel Date: Tue, 4 Oct 2022 16:30:20 +0200 Subject: [PATCH 14/21] Align `GasWeightMapping` with Substrate `do_pre_dispatch` logic (#865) * Align `GasWeightMapping` with Substrate `do_pre_dispatch` logic * Add `without_base_extrinsic` param * fmt --- frame/ethereum/src/lib.rs | 12 ++++--- frame/ethereum/src/mock.rs | 4 ++- frame/ethereum/src/tests/eip1559.rs | 6 ++-- frame/evm/precompile/dispatch/src/lib.rs | 2 +- frame/evm/precompile/dispatch/src/mock.rs | 4 ++- frame/evm/src/lib.rs | 40 ++++++++++++++++++----- frame/evm/src/mock.rs | 4 ++- template/runtime/src/lib.rs | 30 +++++++++-------- ts-tests/tests/test-gas.ts | 4 +-- 9 files changed, 73 insertions(+), 33 deletions(-) diff --git a/frame/ethereum/src/lib.rs b/frame/ethereum/src/lib.rs index 4ab4cebf39..d2ce85d21a 100644 --- a/frame/ethereum/src/lib.rs +++ b/frame/ethereum/src/lib.rs @@ -256,10 +256,13 @@ pub mod pallet { OriginFor: Into>>, { /// Transact an Ethereum transaction. - #[pallet::weight(::GasWeightMapping::gas_to_weight({ - let transaction_data: TransactionData = transaction.into(); - transaction_data.gas_limit.unique_saturated_into() - }))] + #[pallet::weight({ + let without_base_extrinsic_weight = true; + ::GasWeightMapping::gas_to_weight({ + let transaction_data: TransactionData = transaction.into(); + transaction_data.gas_limit.unique_saturated_into() + }, without_base_extrinsic_weight) + })] pub fn transact( origin: OriginFor, transaction: Transaction, @@ -604,6 +607,7 @@ impl Pallet { Ok(PostDispatchInfo { actual_weight: Some(T::GasWeightMapping::gas_to_weight( used_gas.unique_saturated_into(), + true, )), pays_fee: Pays::No, }) diff --git a/frame/ethereum/src/mock.rs b/frame/ethereum/src/mock.rs index 666f2ba5de..4930549e7b 100644 --- a/frame/ethereum/src/mock.rs +++ b/frame/ethereum/src/mock.rs @@ -138,6 +138,7 @@ parameter_types! { pub const ChainId: u64 = 42; pub const EVMModuleId: PalletId = PalletId(*b"py/evmpa"); pub const BlockGasLimit: U256 = U256::MAX; + pub const WeightPerGas: u64 = 20_000; } pub struct HashedAddressMapping; @@ -152,7 +153,8 @@ impl AddressMapping for HashedAddressMapping { impl pallet_evm::Config for Test { type FeeCalculator = FixedGasPrice; - type GasWeightMapping = (); + type GasWeightMapping = pallet_evm::FixedGasWeightMapping; + type WeightPerGas = WeightPerGas; type CallOrigin = EnsureAddressTruncated; type WithdrawOrigin = EnsureAddressTruncated; type AddressMapping = HashedAddressMapping; diff --git a/frame/ethereum/src/tests/eip1559.rs b/frame/ethereum/src/tests/eip1559.rs index a059cf3672..bde7272238 100644 --- a/frame/ethereum/src/tests/eip1559.rs +++ b/frame/ethereum/src/tests/eip1559.rs @@ -83,8 +83,10 @@ fn transaction_with_gas_limit_greater_than_max_extrinsic_should_fail_pre_dispatc let limits: frame_system::limits::BlockWeights = ::BlockWeights::get(); let max_extrinsic = limits.get(DispatchClass::Normal).max_extrinsic.unwrap(); - let max_extrinsic_gas = - ::GasWeightMapping::weight_to_gas(max_extrinsic); + let base_extrinsic = limits.get(DispatchClass::Normal).base_extrinsic; + let max_extrinsic_gas = ::GasWeightMapping::weight_to_gas( + max_extrinsic + base_extrinsic, + ); ext.execute_with(|| { let transaction = EIP1559UnsignedTransaction { diff --git a/frame/evm/precompile/dispatch/src/lib.rs b/frame/evm/precompile/dispatch/src/lib.rs index 513d3b4f1c..6c00c805af 100644 --- a/frame/evm/precompile/dispatch/src/lib.rs +++ b/frame/evm/precompile/dispatch/src/lib.rs @@ -73,7 +73,7 @@ where } if let Some(gas) = target_gas { - let valid_weight = info.weight <= T::GasWeightMapping::gas_to_weight(gas); + let valid_weight = info.weight <= T::GasWeightMapping::gas_to_weight(gas, false); if !valid_weight { return Err(PrecompileFailure::Error { exit_status: ExitError::OutOfGas, diff --git a/frame/evm/precompile/dispatch/src/mock.rs b/frame/evm/precompile/dispatch/src/mock.rs index 6f42b16d6f..e5d12b7280 100644 --- a/frame/evm/precompile/dispatch/src/mock.rs +++ b/frame/evm/precompile/dispatch/src/mock.rs @@ -136,10 +136,12 @@ impl FindAuthor for FindAuthorTruncated { } parameter_types! { pub BlockGasLimit: U256 = U256::max_value(); + pub WeightPerGas: u64 = 20_000; } impl pallet_evm::Config for Test { type FeeCalculator = FixedGasPrice; - type GasWeightMapping = (); + type GasWeightMapping = pallet_evm::FixedGasWeightMapping; + type WeightPerGas = WeightPerGas; type CallOrigin = EnsureAddressRoot; type WithdrawOrigin = EnsureAddressNever; diff --git a/frame/evm/src/lib.rs b/frame/evm/src/lib.rs index 32daa66950..bd258339b3 100644 --- a/frame/evm/src/lib.rs +++ b/frame/evm/src/lib.rs @@ -115,6 +115,9 @@ pub mod pallet { /// Maps Ethereum gas to Substrate weight. type GasWeightMapping: GasWeightMapping; + /// Weight corresponding to a gas unit. + type WeightPerGas: Get; + /// Block number to block hash. type BlockHashMapping: BlockHashMapping; @@ -177,7 +180,10 @@ pub mod pallet { } /// Issue an EVM call operation. This is similar to a message call transaction in Ethereum. - #[pallet::weight(T::GasWeightMapping::gas_to_weight(*gas_limit))] + #[pallet::weight({ + let without_base_extrinsic_weight = true; + T::GasWeightMapping::gas_to_weight(*gas_limit, without_base_extrinsic_weight) + })] pub fn call( origin: OriginFor, source: H160, @@ -232,6 +238,7 @@ pub mod pallet { Ok(PostDispatchInfo { actual_weight: Some(T::GasWeightMapping::gas_to_weight( info.used_gas.unique_saturated_into(), + true, )), pays_fee: Pays::No, }) @@ -239,7 +246,10 @@ pub mod pallet { /// Issue an EVM create operation. This is similar to a contract creation transaction in /// Ethereum. - #[pallet::weight(T::GasWeightMapping::gas_to_weight(*gas_limit))] + #[pallet::weight({ + let without_base_extrinsic_weight = true; + T::GasWeightMapping::gas_to_weight(*gas_limit, without_base_extrinsic_weight) + })] pub fn create( origin: OriginFor, source: H160, @@ -304,13 +314,17 @@ pub mod pallet { Ok(PostDispatchInfo { actual_weight: Some(T::GasWeightMapping::gas_to_weight( info.used_gas.unique_saturated_into(), + true, )), pays_fee: Pays::No, }) } /// Issue an EVM create2 operation. - #[pallet::weight(T::GasWeightMapping::gas_to_weight(*gas_limit))] + #[pallet::weight({ + let without_base_extrinsic_weight = true; + T::GasWeightMapping::gas_to_weight(*gas_limit, without_base_extrinsic_weight) + })] pub fn create2( origin: OriginFor, source: H160, @@ -377,6 +391,7 @@ pub mod pallet { Ok(PostDispatchInfo { actual_weight: Some(T::GasWeightMapping::gas_to_weight( info.used_gas.unique_saturated_into(), + true, )), pays_fee: Pays::No, }) @@ -621,16 +636,25 @@ impl BlockHashMapping for SubstrateBlockHashMapping { /// A mapping function that converts Ethereum gas to Substrate weight pub trait GasWeightMapping { - fn gas_to_weight(gas: u64) -> Weight; + fn gas_to_weight(gas: u64, without_base_weight: bool) -> Weight; fn weight_to_gas(weight: Weight) -> u64; } -impl GasWeightMapping for () { - fn gas_to_weight(gas: u64) -> Weight { - gas as Weight +pub struct FixedGasWeightMapping(sp_std::marker::PhantomData); +impl GasWeightMapping for FixedGasWeightMapping { + fn gas_to_weight(gas: u64, without_base_weight: bool) -> Weight { + let mut weight = gas.saturating_mul(T::WeightPerGas::get()); + if without_base_weight { + weight = weight.saturating_sub( + T::BlockWeights::get() + .get(frame_support::weights::DispatchClass::Normal) + .base_extrinsic, + ); + } + weight } fn weight_to_gas(weight: Weight) -> u64 { - weight as u64 + weight.wrapping_div(T::WeightPerGas::get()) } } diff --git a/frame/evm/src/mock.rs b/frame/evm/src/mock.rs index f271168dfd..ecd34f4e08 100644 --- a/frame/evm/src/mock.rs +++ b/frame/evm/src/mock.rs @@ -124,10 +124,12 @@ impl FindAuthor for FindAuthorTruncated { } parameter_types! { pub BlockGasLimit: U256 = U256::max_value(); + pub WeightPerGas: u64 = 20_000; } impl crate::Config for Test { type FeeCalculator = FixedGasPrice; - type GasWeightMapping = (); + type GasWeightMapping = crate::FixedGasWeightMapping; + type WeightPerGas = WeightPerGas; type CallOrigin = EnsureAddressRoot; type WithdrawOrigin = EnsureAddressNever; diff --git a/template/runtime/src/lib.rs b/template/runtime/src/lib.rs index 6e5b978709..4e39d02574 100644 --- a/template/runtime/src/lib.rs +++ b/template/runtime/src/lib.rs @@ -40,8 +40,7 @@ use pallet_transaction_payment::CurrencyAdapter; use fp_rpc::TransactionStatus; use pallet_ethereum::{Call::transact, Transaction as EthereumTransaction}; use pallet_evm::{ - Account as EVMAccount, EnsureAddressTruncated, FeeCalculator, GasWeightMapping, - HashedAddressMapping, Runner, + Account as EVMAccount, EnsureAddressTruncated, FeeCalculator, HashedAddressMapping, Runner, }; // A few exports that help ease life for downstream crates. @@ -309,24 +308,16 @@ impl> FindAuthor for FindAuthorTruncated { } } -pub struct FixedGasWeightMapping; -impl GasWeightMapping for FixedGasWeightMapping { - fn gas_to_weight(gas: u64) -> Weight { - gas.saturating_mul(WEIGHT_PER_GAS) - } - fn weight_to_gas(weight: Weight) -> u64 { - weight.wrapping_div(WEIGHT_PER_GAS) - } -} - parameter_types! { pub BlockGasLimit: U256 = U256::from(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT / WEIGHT_PER_GAS); pub PrecompilesValue: FrontierPrecompiles = FrontierPrecompiles::<_>::new(); + pub WeightPerGas: u64 = 20_000; } impl pallet_evm::Config for Runtime { type FeeCalculator = BaseFee; - type GasWeightMapping = FixedGasWeightMapping; + type GasWeightMapping = pallet_evm::FixedGasWeightMapping; + type WeightPerGas = WeightPerGas; type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping; type CallOrigin = EnsureAddressTruncated; type WithdrawOrigin = EnsureAddressTruncated; @@ -857,3 +848,16 @@ impl_runtime_apis! { } } } + +#[cfg(test)] +mod tests { + use super::{Runtime, WeightPerGas}; + #[test] + fn configured_base_extrinsic_weight_is_evm_compatible() { + let min_ethereum_transaction_weight = WeightPerGas::get() * 21_000; + let base_extrinsic = ::BlockWeights::get() + .get(frame_support::weights::DispatchClass::Normal) + .base_extrinsic; + assert!(base_extrinsic <= min_ethereum_transaction_weight); + } +} diff --git a/ts-tests/tests/test-gas.ts b/ts-tests/tests/test-gas.ts index 0f4e1191e1..28e55b174f 100644 --- a/ts-tests/tests/test-gas.ts +++ b/ts-tests/tests/test-gas.ts @@ -40,8 +40,8 @@ describeWithFrontier("Frontier RPC (Gas)", (context) => { // Those test are ordered. In general this should be avoided, but due to the time it takes // to spin up a frontier node, it saves a lot of time. - // EXTRINSIC_GAS_LIMIT = [BLOCK_GAS_LIMIT - BLOCK_GAS_LIMIT * (NORMAL_DISPATCH_RATIO - AVERAGE_ON_INITIALIZE_RATIO) - EXTRINSIC_BASE_Weight] / WEIGHT_PER_GAS = (1_000_000_000_000 * 2 * (0.75-0.1) - 125_000_000) / 20000 - const EXTRINSIC_GAS_LIMIT = 64995685; + // EXTRINSIC_GAS_LIMIT = [BLOCK_GAS_LIMIT - BLOCK_GAS_LIMIT * (NORMAL_DISPATCH_RATIO - AVERAGE_ON_INITIALIZE_RATIO)] / WEIGHT_PER_GAS = (1_000_000_000_000 * 2 * (0.75-0.1) - 125_000_000) / 20000 + const EXTRINSIC_GAS_LIMIT = 65000000; it("eth_estimateGas for contract creation", async function () { // The value returned as an estimation by the evm with estimate mode ON. From d2516b354934157b61b4c42e5b65e572b12741e4 Mon Sep 17 00:00:00 2001 From: tgmichel Date: Tue, 4 Oct 2022 16:31:03 +0200 Subject: [PATCH 15/21] Fix geth error messages (#870) * Fix geth error messages * taplo --- Cargo.lock | 23 ++++++++++++++++++++ client/rpc/Cargo.toml | 1 + client/rpc/src/eth/format.rs | 28 ++++++++++++------------- frame/ethereum/src/lib.rs | 18 +++++----------- frame/ethereum/src/tests/eip1559.rs | 2 +- frame/ethereum/src/tests/eip2930.rs | 2 +- frame/ethereum/src/tests/legacy.rs | 2 +- primitives/ethereum/Cargo.toml | 2 ++ primitives/ethereum/src/lib.rs | 13 ++++++++++++ ts-tests/tests/test-gas.ts | 2 +- ts-tests/tests/test-transaction-cost.ts | 2 +- 11 files changed, 63 insertions(+), 32 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 40b5214338..8675a98e0e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1683,6 +1683,7 @@ dependencies = [ "evm", "fc-db", "fc-rpc-core", + "fp-ethereum", "fp-evm", "fp-rpc", "fp-storage", @@ -1873,6 +1874,7 @@ dependencies = [ "ethereum-types", "fp-evm", "frame-support", + "num_enum", "parity-scale-codec", "sp-core", "sp-std", @@ -4315,6 +4317,27 @@ dependencies = [ "libc", ] +[[package]] +name = "num_enum" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf5395665662ef45796a4ff5486c5d41d29e0c09640af4c5f17fd94ee2c119c9" +dependencies = [ + "num_enum_derive", +] + +[[package]] +name = "num_enum_derive" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0498641e53dd6ac1a4f22547548caa6864cc4933784319cd1775271c5a46ce" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "object" version = "0.27.1" diff --git a/client/rpc/Cargo.toml b/client/rpc/Cargo.toml index d2297b2345..69aa9993d0 100644 --- a/client/rpc/Cargo.toml +++ b/client/rpc/Cargo.toml @@ -49,6 +49,7 @@ sp-storage = { version = "6.0.0", git = "https://github.com/paritytech/substrate # Frontier fc-db = { version = "2.0.0-dev", path = "../db" } fc-rpc-core = { version = "1.1.0-dev", path = "../rpc-core" } +fp-ethereum = { version = "1.0.0-dev", path = "../../primitives/ethereum" } fp-evm = { version = "3.0.0-dev", path = "../../primitives/evm" } fp-rpc = { version = "3.0.0-dev", path = "../../primitives/rpc" } fp-storage = { version = "2.0.0-dev", path = "../../primitives/storage" } diff --git a/client/rpc/src/eth/format.rs b/client/rpc/src/eth/format.rs index 19df69e2a2..4d110196dd 100644 --- a/client/rpc/src/eth/format.rs +++ b/client/rpc/src/eth/format.rs @@ -20,7 +20,7 @@ use sc_transaction_pool_api::error::{Error as PError, IntoPoolError}; use sp_runtime::transaction_validity::InvalidTransaction; // Frontier -use fp_evm::InvalidEvmTransactionError as VError; +use fp_ethereum::TransactionValidationError as VError; // Formats the same way Geth node formats responses. pub struct Geth; @@ -31,23 +31,23 @@ impl Geth { // https://github.com/ethereum/go-ethereum/blob/794c6133efa2c7e8376d9d141c900ea541790bce/core/error.go match err.into_pool_error() { Ok(PError::AlreadyImported(_)) => "already known".to_string(), - // In Frontier the only case there is a `TemporarilyBanned` is because - // the same transaction was received before and returned - // `InvalidTransaction::Stale`. Thus we return the same error. - Ok(PError::TemporarilyBanned) => "nonce too low".into(), + Ok(PError::TemporarilyBanned) => "already known".into(), Ok(PError::TooLowPriority { .. }) => "replacement transaction underpriced".into(), - Ok(ref outer @ PError::InvalidTransaction(inner)) => match inner { + Ok(PError::InvalidTransaction(inner)) => match inner { InvalidTransaction::Stale => "nonce too low".into(), InvalidTransaction::Payment => "insufficient funds for gas * price + value".into(), - InvalidTransaction::ExhaustsResources => "gas limit reached".into(), - InvalidTransaction::Custom(inner) => match inner { - a if a == VError::InvalidChainId as u8 => "invalid chain id".into(), - // VError::InvalidSignature => "invalid sender".into(), - a if a == VError::GasLimitTooLow as u8 => "intrinsic gas too low".into(), - a if a == VError::GasLimitTooHigh as u8 => "exceeds block gas limit".into(), - _ => format!("submit transaction to pool failed: {:?}", outer), + InvalidTransaction::ExhaustsResources => "exceeds block gas limit".into(), + InvalidTransaction::Custom(inner) => match inner.into() { + VError::UnknownError => "unknown error".into(), + VError::InvalidChainId => "invalid chain id".into(), + VError::InvalidSignature => "invalid sender".into(), + VError::GasLimitTooLow => "intrinsic gas too low".into(), + VError::GasLimitTooHigh => "exceeds block gas limit".into(), + VError::MaxFeePerGasTooLow => { + "max priority fee per gas higher than max fee per gas".into() + } }, - _ => format!("submit transaction to pool failed: {:?}", outer), + _ => "unknown error".into(), }, err => format!("submit transaction to pool failed: {:?}", err), } diff --git a/frame/ethereum/src/lib.rs b/frame/ethereum/src/lib.rs index d2ce85d21a..d1f5af2f92 100644 --- a/frame/ethereum/src/lib.rs +++ b/frame/ethereum/src/lib.rs @@ -32,7 +32,9 @@ mod tests; use ethereum_types::{Bloom, BloomInput, H160, H256, H64, U256}; use evm::ExitReason; use fp_consensus::{PostLog, PreLog, FRONTIER_ENGINE_ID}; -use fp_ethereum::{TransactionData, ValidatedTransaction as ValidatedTransactionT}; +use fp_ethereum::{ + TransactionData, TransactionValidationError, ValidatedTransaction as ValidatedTransactionT, +}; use fp_evm::{ CallOrCreateInfo, CheckEvmTransaction, CheckEvmTransactionConfig, InvalidEvmTransactionError, }; @@ -876,26 +878,16 @@ impl BlockHashMapping for EthereumBlockHashMapping { } } -#[repr(u8)] -enum TransactionValidationError { - #[allow(dead_code)] - UnknownError, - InvalidChainId, - InvalidSignature, - InvalidGasLimit, - MaxFeePerGasTooLow, -} - pub struct InvalidTransactionWrapper(InvalidTransaction); impl From for InvalidTransactionWrapper { fn from(validation_error: InvalidEvmTransactionError) -> Self { match validation_error { InvalidEvmTransactionError::GasLimitTooLow => InvalidTransactionWrapper( - InvalidTransaction::Custom(TransactionValidationError::InvalidGasLimit as u8), + InvalidTransaction::Custom(TransactionValidationError::GasLimitTooLow as u8), ), InvalidEvmTransactionError::GasLimitTooHigh => InvalidTransactionWrapper( - InvalidTransaction::Custom(TransactionValidationError::InvalidGasLimit as u8), + InvalidTransaction::Custom(TransactionValidationError::GasLimitTooHigh as u8), ), InvalidEvmTransactionError::GasPriceTooLow => { InvalidTransactionWrapper(InvalidTransaction::Payment) diff --git a/frame/ethereum/src/tests/eip1559.rs b/frame/ethereum/src/tests/eip1559.rs index bde7272238..94fad5d8d0 100644 --- a/frame/ethereum/src/tests/eip1559.rs +++ b/frame/ethereum/src/tests/eip1559.rs @@ -254,7 +254,7 @@ fn transaction_with_invalid_chain_id_should_fail_in_block() { assert_err!( extrinsic.apply::(&dispatch_info, 0), TransactionValidityError::Invalid(InvalidTransaction::Custom( - crate::TransactionValidationError::InvalidChainId as u8, + fp_ethereum::TransactionValidationError::InvalidChainId as u8, )) ); }); diff --git a/frame/ethereum/src/tests/eip2930.rs b/frame/ethereum/src/tests/eip2930.rs index 49b9c66c18..fbdac95590 100644 --- a/frame/ethereum/src/tests/eip2930.rs +++ b/frame/ethereum/src/tests/eip2930.rs @@ -178,7 +178,7 @@ fn transaction_with_invalid_chain_id_should_fail_in_block() { assert_err!( extrinsic.apply::(&dispatch_info, 0), TransactionValidityError::Invalid(InvalidTransaction::Custom( - crate::TransactionValidationError::InvalidChainId as u8, + fp_ethereum::TransactionValidationError::InvalidChainId as u8, )) ); }); diff --git a/frame/ethereum/src/tests/legacy.rs b/frame/ethereum/src/tests/legacy.rs index 0996b1d8da..84acb27d94 100644 --- a/frame/ethereum/src/tests/legacy.rs +++ b/frame/ethereum/src/tests/legacy.rs @@ -178,7 +178,7 @@ fn transaction_with_invalid_chain_id_should_fail_in_block() { assert_err!( extrinsic.apply::(&dispatch_info, 0), TransactionValidityError::Invalid(InvalidTransaction::Custom( - crate::TransactionValidationError::InvalidChainId as u8, + fp_ethereum::TransactionValidationError::InvalidChainId as u8, )) ); }); diff --git a/primitives/ethereum/Cargo.toml b/primitives/ethereum/Cargo.toml index 61c9fd9eb4..27fb62187c 100644 --- a/primitives/ethereum/Cargo.toml +++ b/primitives/ethereum/Cargo.toml @@ -14,6 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"] ethereum = { version = "0.12.0", default-features = false, features = ["with-codec"] } ethereum-types = { version = "0.13.1", default-features = false } fp-evm = { version = "3.0.0-dev", path = "../evm", default-features = false } +num_enum = { version = "0.5.4", default-features = false } # Parity codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } @@ -29,6 +30,7 @@ default = ["std"] std = [ "ethereum/std", "ethereum-types/std", + "num_enum/std", # Parity "codec/std", # Substrate diff --git a/primitives/ethereum/src/lib.rs b/primitives/ethereum/src/lib.rs index 931a6dbb3e..abf4b36260 100644 --- a/primitives/ethereum/src/lib.rs +++ b/primitives/ethereum/src/lib.rs @@ -26,6 +26,19 @@ use ethereum_types::{H160, H256, U256}; use fp_evm::CheckEvmTransactionInput; use sp_std::vec::Vec; +#[repr(u8)] +#[derive(num_enum::FromPrimitive, num_enum::IntoPrimitive)] +pub enum TransactionValidationError { + #[allow(dead_code)] + #[num_enum(default)] + UnknownError, + InvalidChainId, + InvalidSignature, + GasLimitTooLow, + GasLimitTooHigh, + MaxFeePerGasTooLow, +} + pub trait ValidatedTransaction { fn apply( source: H160, diff --git a/ts-tests/tests/test-gas.ts b/ts-tests/tests/test-gas.ts index 28e55b174f..7e3faa97a0 100644 --- a/ts-tests/tests/test-gas.ts +++ b/ts-tests/tests/test-gas.ts @@ -185,7 +185,7 @@ describeWithFrontier("Frontier RPC (Gas)", (context) => { ); const createReceipt = await customRequest(context.web3, "eth_sendRawTransaction", [tx.rawTransaction]); await createAndFinalizeBlock(context.web3); - expect((createReceipt as any).error.message).to.equal("gas limit reached"); + expect((createReceipt as any).error.message).to.equal("exceeds block gas limit"); }); }); diff --git a/ts-tests/tests/test-transaction-cost.ts b/ts-tests/tests/test-transaction-cost.ts index cbdafaeaa2..bcde9388ef 100644 --- a/ts-tests/tests/test-transaction-cost.ts +++ b/ts-tests/tests/test-transaction-cost.ts @@ -11,7 +11,7 @@ describeWithFrontier("Frontier RPC (Transaction cost)", (context) => { d4afd7aefb4a34b373314fff470bb9db743a84d674a0aa06e5994f2d07eafe1c37b4ce5471caecec29011f6f5b\ f0b1a552c55ea348df35f", ]); - let msg = "submit transaction to pool failed: InvalidTransaction(InvalidTransaction::Custom(3))"; + let msg = "intrinsic gas too low"; expect(tx.error).to.include({ message: msg, }); From 5bd0dc7aef2054cb881037a40866df3ce47b3b9e Mon Sep 17 00:00:00 2001 From: tgmichel Date: Wed, 5 Oct 2022 21:52:25 +0200 Subject: [PATCH 16/21] Frontier DB block mapping one-to-many (#862) * WIP Frontier DB block mapping one-to-many * Fix * fmt * Cleanup * Cleanup * Cleanup * fmt skip * parity db migration * Cleanup + tests * WIP retroactively fix non-canon mapped blocks * Update tests * Fix more tests * clippy * taplo * Test transaction metadata * Use test runtime api * Remove unnecessary generic --- Cargo.lock | 7 + client/cli/src/frontier_db_cmd/tests.rs | 126 +++--- client/db/Cargo.toml | 10 + client/db/src/lib.rs | 70 ++-- client/db/src/upgrade.rs | 486 ++++++++++++++++++++++++ client/db/src/utils.rs | 94 ++++- client/rpc/src/eth/block.rs | 16 +- client/rpc/src/eth/filter.rs | 8 +- client/rpc/src/eth/transaction.rs | 24 +- client/rpc/src/lib.rs | 164 +++++++- template/node/src/service.rs | 1 + 11 files changed, 896 insertions(+), 110 deletions(-) create mode 100644 client/db/src/upgrade.rs diff --git a/Cargo.lock b/Cargo.lock index 8675a98e0e..c249e9a25e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1647,14 +1647,21 @@ name = "fc-db" version = "2.0.0-dev" dependencies = [ "fp-storage", + "futures", "kvdb-rocksdb", + "log", "parity-db", "parity-scale-codec", "parking_lot 0.12.1", + "sc-block-builder", "sc-client-db", + "sp-blockchain", + "sp-consensus", "sp-core", "sp-database", "sp-runtime", + "substrate-test-runtime-client", + "tempfile", ] [[package]] diff --git a/client/cli/src/frontier_db_cmd/tests.rs b/client/cli/src/frontier_db_cmd/tests.rs index 5b05a90199..003e3176d2 100644 --- a/client/cli/src/frontier_db_cmd/tests.rs +++ b/client/cli/src/frontier_db_cmd/tests.rs @@ -46,10 +46,15 @@ mod tests { type OpaqueBlock = Block, substrate_test_runtime_client::runtime::Extrinsic>; - pub fn open_frontier_backend( + pub fn open_frontier_backend( + client: Arc, path: PathBuf, - ) -> Result>, String> { + ) -> Result>, String> + where + C: sp_blockchain::HeaderBackend, + { Ok(Arc::new(fc_db::Backend::::new( + client, &fc_db::DatabaseSettings { source: sc_client_db::DatabaseSource::RocksDb { path, @@ -126,11 +131,13 @@ mod tests { // Write some data in a temp file. let test_value_path = test_json_file(&tmp, &schema_test_value()); - // Create a temporary frontier secondary DB. - let backend = open_frontier_backend(tmp.into_path()).expect("a temporary db was created"); // Test client. let (client, _) = TestClientBuilder::new().build_with_native_executor::(None); + let client = Arc::new(client); + // Create a temporary frontier secondary DB. + let backend = open_frontier_backend(client.clone(), tmp.into_path()) + .expect("a temporary db was created"); assert_eq!(backend.meta().ethereum_schema(), Ok(None)); @@ -141,7 +148,7 @@ mod tests { Operation::Create, Column::Meta ) - .run(Arc::new(client), backend.clone()) + .run(client, backend.clone()) .is_ok()); assert_eq!( @@ -156,11 +163,13 @@ mod tests { // Write some data in a temp file. let test_value_path = test_json_file(&tmp, &schema_test_value()); - // Create a temporary frontier secondary DB. - let backend = open_frontier_backend(tmp.into_path()).expect("a temporary db was created"); // Test client. let (client, _) = TestClientBuilder::new().build_with_native_executor::(None); + let client = Arc::new(client); + // Create a temporary frontier secondary DB. + let backend = open_frontier_backend(client.clone(), tmp.into_path()) + .expect("a temporary db was created"); let data_before = vec![(EthereumStorageSchema::V2, H256::default())]; @@ -176,7 +185,7 @@ mod tests { Operation::Create, Column::Meta ) - .run(Arc::new(client), backend.clone()) + .run(client, backend.clone()) .is_err()); let data_after = backend.meta().ethereum_schema().unwrap().unwrap(); @@ -186,12 +195,13 @@ mod tests { #[test] fn schema_read_works() { let tmp = tempdir().expect("create a temporary directory"); - - // Create a temporary frontier secondary DB. - let backend = open_frontier_backend(tmp.into_path()).expect("a temporary db was created"); // Test client. let (client, _) = TestClientBuilder::new().build_with_native_executor::(None); + let client = Arc::new(client); + // Create a temporary frontier secondary DB. + let backend = open_frontier_backend(client.clone(), tmp.into_path()) + .expect("a temporary db was created"); assert_eq!(backend.meta().ethereum_schema(), Ok(None)); @@ -209,7 +219,7 @@ mod tests { Operation::Read, Column::Meta ) - .run(Arc::new(client), backend.clone()) + .run(client, backend.clone()) .is_ok()); } @@ -218,12 +228,13 @@ mod tests { let tmp = tempdir().expect("create a temporary directory"); // Write some data in a temp file. let test_value_path = test_json_file(&tmp, &schema_test_value()); - - // Create a temporary frontier secondary DB. - let backend = open_frontier_backend(tmp.into_path()).expect("a temporary db was created"); // Test client. let (client, _) = TestClientBuilder::new().build_with_native_executor::(None); + let client = Arc::new(client); + // Create a temporary frontier secondary DB. + let backend = open_frontier_backend(client.clone(), tmp.into_path()) + .expect("a temporary db was created"); assert_eq!(backend.meta().ethereum_schema(), Ok(None)); // Run the command @@ -233,7 +244,7 @@ mod tests { Operation::Update, Column::Meta ) - .run(Arc::new(client), backend.clone()) + .run(client, backend.clone()) .is_ok()); assert_eq!( @@ -245,12 +256,13 @@ mod tests { #[test] fn schema_delete_works() { let tmp = tempdir().expect("create a temporary directory"); - - // Create a temporary frontier secondary DB. - let backend = open_frontier_backend(tmp.into_path()).expect("a temporary db was created"); // Test client. let (client, _) = TestClientBuilder::new().build_with_native_executor::(None); + let client = Arc::new(client); + // Create a temporary frontier secondary DB. + let backend = open_frontier_backend(client.clone(), tmp.into_path()) + .expect("a temporary db was created"); let data = vec![(EthereumStorageSchema::V2, H256::default())]; @@ -265,7 +277,7 @@ mod tests { Operation::Delete, Column::Meta ) - .run(Arc::new(client), backend.clone()) + .run(client, backend.clone()) .is_ok()); assert_eq!(backend.meta().ethereum_schema(), Ok(Some(vec![]))); @@ -276,12 +288,13 @@ mod tests { let tmp = tempdir().expect("create a temporary directory"); // Write some data in a temp file. let test_value_path = test_json_file(&tmp, &tips_test_value()); - - // Create a temporary frontier secondary DB. - let backend = open_frontier_backend(tmp.into_path()).expect("a temporary db was created"); // Test client. let (client, _) = TestClientBuilder::new().build_with_native_executor::(None); + let client = Arc::new(client); + // Create a temporary frontier secondary DB. + let backend = open_frontier_backend(client.clone(), tmp.into_path()) + .expect("a temporary db was created"); assert_eq!(backend.meta().current_syncing_tips(), Ok(vec![])); // Run the command @@ -291,7 +304,7 @@ mod tests { Operation::Create, Column::Meta ) - .run(Arc::new(client), backend.clone()) + .run(client, backend.clone()) .is_ok()); assert_eq!( @@ -305,12 +318,13 @@ mod tests { let tmp = tempdir().expect("create a temporary directory"); // Write some data in a temp file. let test_value_path = test_json_file(&tmp, &tips_test_value()); - - // Create a temporary frontier secondary DB. - let backend = open_frontier_backend(tmp.into_path()).expect("a temporary db was created"); // Test client. let (client, _) = TestClientBuilder::new().build_with_native_executor::(None); + let client = Arc::new(client); + // Create a temporary frontier secondary DB. + let backend = open_frontier_backend(client.clone(), tmp.into_path()) + .expect("a temporary db was created"); let data_before = vec![H256::default()]; @@ -325,7 +339,7 @@ mod tests { Operation::Create, Column::Meta ) - .run(Arc::new(client), backend.clone()) + .run(client, backend.clone()) .is_err()); let data_after = backend.meta().current_syncing_tips().unwrap(); @@ -335,12 +349,13 @@ mod tests { #[test] fn tips_read_works() { let tmp = tempdir().expect("create a temporary directory"); - - // Create a temporary frontier secondary DB. - let backend = open_frontier_backend(tmp.into_path()).expect("a temporary db was created"); // Test client. let (client, _) = TestClientBuilder::new().build_with_native_executor::(None); + let client = Arc::new(client); + // Create a temporary frontier secondary DB. + let backend = open_frontier_backend(client.clone(), tmp.into_path()) + .expect("a temporary db was created"); assert_eq!(backend.meta().current_syncing_tips(), Ok(vec![])); @@ -357,7 +372,7 @@ mod tests { Operation::Read, Column::Meta ) - .run(Arc::new(client), backend.clone()) + .run(client, backend.clone()) .is_ok()); } @@ -366,12 +381,13 @@ mod tests { let tmp = tempdir().expect("create a temporary directory"); // Write some data in a temp file. let test_value_path = test_json_file(&tmp, &tips_test_value()); - - // Create a temporary frontier secondary DB. - let backend = open_frontier_backend(tmp.into_path()).expect("a temporary db was created"); // Test client. let (client, _) = TestClientBuilder::new().build_with_native_executor::(None); + let client = Arc::new(client); + // Create a temporary frontier secondary DB. + let backend = open_frontier_backend(client.clone(), tmp.into_path()) + .expect("a temporary db was created"); assert_eq!(backend.meta().current_syncing_tips(), Ok(vec![])); // Run the command @@ -381,7 +397,7 @@ mod tests { Operation::Update, Column::Meta ) - .run(Arc::new(client), backend.clone()) + .run(client, backend.clone()) .is_ok()); assert_eq!( @@ -393,12 +409,13 @@ mod tests { #[test] fn tips_delete_works() { let tmp = tempdir().expect("create a temporary directory"); - - // Create a temporary frontier secondary DB. - let backend = open_frontier_backend(tmp.into_path()).expect("a temporary db was created"); // Test client. let (client, _) = TestClientBuilder::new().build_with_native_executor::(None); + let client = Arc::new(client); + // Create a temporary frontier secondary DB. + let backend = open_frontier_backend(client.clone(), tmp.into_path()) + .expect("a temporary db was created"); let data = vec![H256::default()]; @@ -413,7 +430,7 @@ mod tests { Operation::Delete, Column::Meta ) - .run(Arc::new(client), backend.clone()) + .run(client, backend.clone()) .is_ok()); assert_eq!(backend.meta().current_syncing_tips(), Ok(vec![])); @@ -424,13 +441,14 @@ mod tests { let tmp = tempdir().expect("create a temporary directory"); // Write some data in a temp file. let test_value_path = test_json_file(&tmp, &schema_test_value()); - - // Create a temporary frontier secondary DB. - let backend = open_frontier_backend(tmp.into_path()).expect("a temporary db was created"); // Test client. let (client, _) = TestClientBuilder::new().build_with_native_executor::(None); let client = Arc::new(client); + // Create a temporary frontier secondary DB. + let backend = open_frontier_backend(client.clone(), tmp.into_path()) + .expect("a temporary db was created"); + let client = client; let data = vec![(EthereumStorageSchema::V1, H256::default())]; @@ -498,13 +516,14 @@ mod tests { serde_json::to_string("im_not_allowed_here").unwrap(), ) .expect("write test value json file"); - - // Create a temporary frontier secondary DB. - let backend = open_frontier_backend(tmp.into_path()).expect("a temporary db was created"); // Test client. let (client, _) = TestClientBuilder::new().build_with_native_executor::(None); let client = Arc::new(client); + // Create a temporary frontier secondary DB. + let backend = open_frontier_backend(client.clone(), tmp.into_path()) + .expect("a temporary db was created"); + let client = client; // Run the Create command assert!(cmd( @@ -559,7 +578,8 @@ mod tests { let test_value_path = test_json_file(&tmp, &TestValue::Commitment(block_hash)); // Create a temporary frontier secondary DB. - let backend = open_frontier_backend(tmp.into_path()).expect("a temporary db was created"); + let backend = open_frontier_backend(client.clone(), tmp.into_path()) + .expect("a temporary db was created"); // Run the command using some ethereum block hash as key. let ethereum_block_hash = H256::default(); @@ -575,7 +595,7 @@ mod tests { // Expect the ethereum and substrate block hashes to be mapped. assert_eq!( backend.mapping().block_hash(ðereum_block_hash), - Ok(Some(block_hash)) + Ok(Some(vec![block_hash])) ); // Expect the offchain-stored transaction metadata to match the one we stored in the runtime. @@ -643,7 +663,8 @@ mod tests { let test_value_path = test_json_file(&tmp, &TestValue::Commitment(block_a1_hash)); // Create a temporary frontier secondary DB. - let backend = open_frontier_backend(tmp.into_path()).expect("a temporary db was created"); + let backend = open_frontier_backend(client.clone(), tmp.into_path()) + .expect("a temporary db was created"); // Run the command using some ethereum block hash as key. let ethereum_block_hash = H256::default(); @@ -659,7 +680,7 @@ mod tests { // Expect the ethereum and substrate block hashes to be mapped. assert_eq!( backend.mapping().block_hash(ðereum_block_hash), - Ok(Some(block_a1_hash)) + Ok(Some(vec![block_a1_hash])) ); // Expect the offchain-stored transaction metadata to match the one we stored in the runtime. @@ -709,7 +730,7 @@ mod tests { // Expect the ethereum and substrate block hashes to be mapped. assert_eq!( backend.mapping().block_hash(ðereum_block_hash), - Ok(Some(block_a2_hash)) + Ok(Some(vec![block_a1_hash, block_a2_hash])) ); // Expect the offchain-stored transaction metadata to have data for both blocks. @@ -764,7 +785,8 @@ mod tests { let test_value_path = test_json_file(&tmp, &TestValue::Commitment(block_hash)); // Create a temporary frontier secondary DB. - let backend = open_frontier_backend(tmp.into_path()).expect("a temporary db was created"); + let backend = open_frontier_backend(client.clone(), tmp.into_path()) + .expect("a temporary db was created"); // Create command using some ethereum block hash as key. let ethereum_block_hash = H256::default(); diff --git a/client/db/Cargo.toml b/client/db/Cargo.toml index 79993e30fa..6cfd4baacc 100644 --- a/client/db/Cargo.toml +++ b/client/db/Cargo.toml @@ -11,6 +11,7 @@ repository = "https://github.com/paritytech/frontier/" targets = ["x86_64-unknown-linux-gnu"] [dependencies] +log = "0.4.17" parking_lot = "0.12.1" # Parity @@ -20,6 +21,7 @@ parity-db = { version = "0.3.16", optional = true } # Substrate sc-client-db = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate", branch = "master" } +sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "master" } sp-core = { version = "6.0.0", git = "https://github.com/paritytech/substrate", branch = "master" } sp-database = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "master" } sp-runtime = { version = "6.0.0", git = "https://github.com/paritytech/substrate", branch = "master" } @@ -29,3 +31,11 @@ fp-storage = { version = "2.0.0-dev", path = "../../primitives/storage" } [features] default = ["kvdb-rocksdb", "parity-db"] + +[dev-dependencies] +futures = "0.3.24" +sc-block-builder = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate", branch = "master" } +sc-client-db = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate", branch = "master", features = ["rocksdb"] } +sp-consensus = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate", branch = "master" } +substrate-test-runtime-client = { version = "2.0.0", git = "https://github.com/paritytech/substrate", branch = "master" } +tempfile = "3.3.0" diff --git a/client/db/src/lib.rs b/client/db/src/lib.rs index c5b83da3a8..f8889384d4 100644 --- a/client/db/src/lib.rs +++ b/client/db/src/lib.rs @@ -18,6 +18,7 @@ #[cfg(feature = "parity-db")] mod parity_db_adapter; +mod upgrade; mod utils; use std::{ @@ -70,30 +71,42 @@ pub fn frontier_database_dir(db_config_dir: &Path, db_path: &str) -> PathBuf { } impl Backend { - pub fn open(database: &DatabaseSource, db_config_dir: &Path) -> Result { - Self::new(&DatabaseSettings { - source: match database { - DatabaseSource::RocksDb { .. } => DatabaseSource::RocksDb { - path: frontier_database_dir(db_config_dir, "db"), - cache_size: 0, + pub fn open>( + client: Arc, + database: &DatabaseSource, + db_config_dir: &Path, + ) -> Result { + Self::new( + client, + &DatabaseSettings { + source: match database { + DatabaseSource::RocksDb { .. } => DatabaseSource::RocksDb { + path: frontier_database_dir(db_config_dir, "db"), + cache_size: 0, + }, + DatabaseSource::ParityDb { .. } => DatabaseSource::ParityDb { + path: frontier_database_dir(db_config_dir, "paritydb"), + }, + DatabaseSource::Auto { .. } => DatabaseSource::Auto { + rocksdb_path: frontier_database_dir(db_config_dir, "db"), + paritydb_path: frontier_database_dir(db_config_dir, "paritydb"), + cache_size: 0, + }, + _ => { + return Err( + "Supported db sources: `rocksdb` | `paritydb` | `auto`".to_string() + ) + } }, - DatabaseSource::ParityDb { .. } => DatabaseSource::ParityDb { - path: frontier_database_dir(db_config_dir, "paritydb"), - }, - DatabaseSource::Auto { .. } => DatabaseSource::Auto { - rocksdb_path: frontier_database_dir(db_config_dir, "db"), - paritydb_path: frontier_database_dir(db_config_dir, "paritydb"), - cache_size: 0, - }, - _ => { - return Err("Supported db sources: `rocksdb` | `paritydb` | `auto`".to_string()) - } }, - }) + ) } - pub fn new(config: &DatabaseSettings) -> Result { - let db = utils::open_database(config)?; + pub fn new>( + client: Arc, + config: &DatabaseSettings, + ) -> Result { + let db = utils::open_database::(client, config)?; Ok(Self { mapping: Arc::new(MappingDb { @@ -214,13 +227,16 @@ impl MappingDb { } } - pub fn block_hash(&self, ethereum_block_hash: &H256) -> Result, String> { + pub fn block_hash( + &self, + ethereum_block_hash: &H256, + ) -> Result>, String> { match self .db .get(crate::columns::BLOCK_MAPPING, ðereum_block_hash.encode()) { Some(raw) => Ok(Some( - Block::Hash::decode(&mut &raw[..]).map_err(|e| format!("{:?}", e))?, + Vec::::decode(&mut &raw[..]).map_err(|e| format!("{:?}", e))?, )), None => Ok(None), } @@ -263,10 +279,18 @@ impl MappingDb { let mut transaction = sp_database::Transaction::new(); + let substrate_hashes = match self.block_hash(&commitment.ethereum_block_hash) { + Ok(Some(mut data)) => { + data.push(commitment.block_hash); + data + } + _ => vec![commitment.block_hash], + }; + transaction.set( crate::columns::BLOCK_MAPPING, &commitment.ethereum_block_hash.encode(), - &commitment.block_hash.encode(), + &substrate_hashes.encode(), ); for (i, ethereum_transaction_hash) in commitment diff --git a/client/db/src/upgrade.rs b/client/db/src/upgrade.rs new file mode 100644 index 0000000000..5660ebe198 --- /dev/null +++ b/client/db/src/upgrade.rs @@ -0,0 +1,486 @@ +// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 +// This file is part of Frontier. +// +// Copyright (c) 2020-2022 Parity Technologies (UK) Ltd. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +use codec::{Decode, Encode}; +use sp_runtime::traits::{Block as BlockT, Header}; + +use sp_core::H256; + +use crate::DatabaseSource; + +use std::{ + fmt, fs, + io::{self, ErrorKind, Read, Write}, + path::{Path, PathBuf}, + sync::Arc, +}; + +/// Version file name. +const VERSION_FILE_NAME: &str = "db_version"; + +/// Current db version. +const CURRENT_VERSION: u32 = 2; + +/// Number of columns in each version. +const _V1_NUM_COLUMNS: u32 = 4; +const V2_NUM_COLUMNS: u32 = 4; + +/// Database upgrade errors. +#[derive(Debug)] +pub(crate) enum UpgradeError { + /// Database version cannot be read from existing db_version file. + UnknownDatabaseVersion, + /// Database version no longer supported. + UnsupportedVersion(u32), + /// Database version comes from future version of the client. + FutureDatabaseVersion(u32), + /// Common io error. + Io(io::Error), +} + +pub(crate) type UpgradeResult = Result; + +pub(crate) struct UpgradeVersion1To2Summary { + pub success: u32, + pub error: Vec, +} + +impl From for UpgradeError { + fn from(err: io::Error) -> Self { + UpgradeError::Io(err) + } +} + +impl fmt::Display for UpgradeError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + UpgradeError::UnknownDatabaseVersion => { + write!( + f, + "Database version cannot be read from existing db_version file" + ) + } + UpgradeError::UnsupportedVersion(version) => { + write!(f, "Database version no longer supported: {}", version) + } + UpgradeError::FutureDatabaseVersion(version) => { + write!( + f, + "Database version comes from future version of the client: {}", + version + ) + } + UpgradeError::Io(err) => write!(f, "Io error: {}", err), + } + } +} + +/// Upgrade database to current version. +pub(crate) fn upgrade_db( + client: Arc, + db_path: &Path, + source: &DatabaseSource, +) -> UpgradeResult<()> +where + C: sp_blockchain::HeaderBackend + Send + Sync, +{ + let db_version = current_version(db_path)?; + match db_version { + 0 => return Err(UpgradeError::UnsupportedVersion(db_version)), + 1 => { + let summary = match source { + DatabaseSource::ParityDb { .. } => { + migrate_1_to_2_parity_db::(client, db_path)? + } + DatabaseSource::RocksDb { .. } => { + migrate_1_to_2_rocks_db::(client, db_path)? + } + _ => panic!("DatabaseSource required for upgrade ParityDb | RocksDb"), + }; + if !summary.error.is_empty() { + panic!( + "Inconsistent migration from version 1 to 2. Failed on {:?}", + summary.error + ); + } else { + log::info!("✔️ Successful Frontier DB migration from version 1 to version 2 ({:?} entries).", summary.success); + } + } + CURRENT_VERSION => (), + _ => return Err(UpgradeError::FutureDatabaseVersion(db_version)), + } + update_version(db_path)?; + Ok(()) +} + +/// Reads current database version from the file at given path. +/// If the file does not exist it gets created with version 1. +pub(crate) fn current_version(path: &Path) -> UpgradeResult { + match fs::File::open(version_file_path(path)) { + Err(ref err) if err.kind() == ErrorKind::NotFound => { + fs::create_dir_all(path)?; + let mut file = fs::File::create(version_file_path(path))?; + file.write_all(format!("{}", 1).as_bytes())?; + Ok(1u32) + } + Err(_) => Err(UpgradeError::UnknownDatabaseVersion), + Ok(mut file) => { + let mut s = String::new(); + file.read_to_string(&mut s) + .map_err(|_| UpgradeError::UnknownDatabaseVersion)?; + s.parse::() + .map_err(|_| UpgradeError::UnknownDatabaseVersion) + } + } +} + +/// Writes current database version to the file. +/// Creates a new file if the version file does not exist yet. +pub(crate) fn update_version(path: &Path) -> io::Result<()> { + fs::create_dir_all(path)?; + let mut file = fs::File::create(version_file_path(path))?; + file.write_all(format!("{}", CURRENT_VERSION).as_bytes())?; + Ok(()) +} + +/// Returns the version file path. +fn version_file_path(path: &Path) -> PathBuf { + let mut file_path = path.to_owned(); + file_path.push(VERSION_FILE_NAME); + file_path +} + +/// Migration from version1 to version2: +/// - The format of the Ethereum<>Substrate block mapping changed to support equivocation. +/// - Migrating schema from One-to-one to One-to-many (EthHash: Vec) relationship. +pub(crate) fn migrate_1_to_2_rocks_db( + client: Arc, + db_path: &Path, +) -> UpgradeResult +where + C: sp_blockchain::HeaderBackend + Send + Sync, +{ + log::info!("🔨 Running Frontier DB migration from version 1 to version 2. Please wait."); + let mut res = UpgradeVersion1To2Summary { + success: 0, + error: vec![], + }; + // Process a batch of hashes in a single db transaction + #[rustfmt::skip] + let mut process_chunk = | + db: &kvdb_rocksdb::Database, + ethereum_hashes: &[std::boxed::Box<[u8]>] + | -> UpgradeResult<()> { + let mut transaction = db.transaction(); + for ethereum_hash in ethereum_hashes { + let mut maybe_error = true; + if let Some(substrate_hash) = db.get(crate::columns::BLOCK_MAPPING, ethereum_hash)? { + // Only update version1 data + let decoded = Vec::::decode(&mut &substrate_hash[..]); + if decoded.is_err() || decoded.unwrap().is_empty() { + // Verify the substrate hash is part of the canonical chain. + if let Ok(Some(number)) = client.number(Block::Hash::decode(&mut &substrate_hash[..]).unwrap()) { + if let Ok(Some(header)) = client.header(sp_runtime::generic::BlockId::Number(number)) { + transaction.put_vec( + crate::columns::BLOCK_MAPPING, + ethereum_hash, + vec![header.hash()].encode(), + ); + res.success += 1; + maybe_error = false; + } + } + } + } + if maybe_error { + res.error.push(H256::from_slice(ethereum_hash)); + } + } + db.write(transaction) + .map_err(|_| io::Error::new(ErrorKind::Other, "Failed to commit on migrate_1_to_2"))?; + Ok(()) + }; + + let db_cfg = kvdb_rocksdb::DatabaseConfig::with_columns(V2_NUM_COLUMNS); + let db = kvdb_rocksdb::Database::open(&db_cfg, db_path)?; + + // Get all the block hashes we need to update + let ethereum_hashes: Vec<_> = db + .iter(crate::columns::BLOCK_MAPPING) + .map(|entry| entry.0) + .collect(); + + // Read and update each entry in db transaction batches + const CHUNK_SIZE: usize = 10_000; + let chunks = ethereum_hashes.chunks(CHUNK_SIZE); + for chunk in chunks { + process_chunk(&db, chunk)?; + } + Ok(res) +} + +pub(crate) fn migrate_1_to_2_parity_db( + client: Arc, + db_path: &Path, +) -> UpgradeResult +where + C: sp_blockchain::HeaderBackend + Send + Sync, +{ + log::info!("🔨 Running Frontier DB migration from version 1 to version 2. Please wait."); + let mut res = UpgradeVersion1To2Summary { + success: 0, + error: vec![], + }; + // Process a batch of hashes in a single db transaction + #[rustfmt::skip] + let mut process_chunk = | + db: &parity_db::Db, + ethereum_hashes: &[Vec] + | -> UpgradeResult<()> { + let mut transaction = vec![]; + for ethereum_hash in ethereum_hashes { + let mut maybe_error = true; + if let Some(substrate_hash) = db.get(crate::columns::BLOCK_MAPPING as u8, ethereum_hash).map_err(|_| + io::Error::new(ErrorKind::Other, "Key does not exist") + )? { + // Only update version1 data + let decoded = Vec::::decode(&mut &substrate_hash[..]); + if decoded.is_err() || decoded.unwrap().is_empty() { + // Verify the substrate hash is part of the canonical chain. + if let Ok(Some(number)) = client.number(Block::Hash::decode(&mut &substrate_hash[..]).unwrap()) { + if let Ok(Some(header)) = client.header(sp_runtime::generic::BlockId::Number(number)) { + transaction.push(( + crate::columns::BLOCK_MAPPING as u8, + ethereum_hash, + Some(vec![header.hash()].encode()), + )); + res.success += 1; + maybe_error = false; + } + } + } + } + if maybe_error { + res.error.push(H256::from_slice(ethereum_hash)); + } + } + db.commit(transaction) + .map_err(|_| io::Error::new(ErrorKind::Other, "Failed to commit on migrate_1_to_2"))?; + Ok(()) + }; + + let mut db_cfg = parity_db::Options::with_columns(db_path, V2_NUM_COLUMNS as u8); + db_cfg.columns[crate::columns::BLOCK_MAPPING as usize].btree_index = true; + + let db = parity_db::Db::open_or_create(&db_cfg) + .map_err(|_| io::Error::new(ErrorKind::Other, "Failed to open db"))?; + + // Get all the block hashes we need to update + let ethereum_hashes: Vec<_> = match db.iter(crate::columns::BLOCK_MAPPING as u8) { + Ok(mut iter) => { + let mut hashes = vec![]; + while let Ok(Some((k, _))) = iter.next() { + hashes.push(k); + } + hashes + } + Err(_) => vec![], + }; + // Read and update each entry in db transaction batches + const CHUNK_SIZE: usize = 10_000; + let chunks = ethereum_hashes.chunks(CHUNK_SIZE); + for chunk in chunks { + process_chunk(&db, chunk)?; + } + Ok(res) +} + +#[cfg(test)] +mod tests { + use futures::executor; + use sc_block_builder::BlockBuilderProvider; + use sp_consensus::BlockOrigin; + use substrate_test_runtime_client::{ + prelude::*, DefaultTestClientBuilderExt, TestClientBuilder, + }; + + use std::sync::Arc; + + use codec::Encode; + use sp_core::H256; + use sp_runtime::{ + generic::{Block, BlockId, Header}, + traits::BlakeTwo256, + }; + use tempfile::tempdir; + + type OpaqueBlock = + Block, substrate_test_runtime_client::runtime::Extrinsic>; + + pub fn open_frontier_backend( + client: Arc, + setting: &crate::DatabaseSettings, + ) -> Result>, String> + where + C: sp_blockchain::HeaderBackend, + { + Ok(Arc::new(crate::Backend::::new( + client, setting, + )?)) + } + + #[test] + fn upgrade_1_to_2_works() { + let tmp_1 = tempdir().expect("create a temporary directory"); + let tmp_2 = tempdir().expect("create a temporary directory"); + + let settings = vec![ + // Rocks db + crate::DatabaseSettings { + source: sc_client_db::DatabaseSource::RocksDb { + path: tmp_1.path().to_owned(), + cache_size: 0, + }, + }, + // Parity db + crate::DatabaseSettings { + source: sc_client_db::DatabaseSource::ParityDb { + path: tmp_2.path().to_owned(), + }, + }, + ]; + + for setting in settings { + let (client, _) = TestClientBuilder::new() + .build_with_native_executor::( + None, + ); + let mut client = Arc::new(client); + + // Genesis block + let mut builder = client.new_block(Default::default()).unwrap(); + builder.push_storage_change(vec![1], None).unwrap(); + let block = builder.build().unwrap().block; + let mut previous_canon_block_hash = block.header.hash(); + executor::block_on(client.import(BlockOrigin::Own, block)).unwrap(); + + let path = setting.source.path().unwrap(); + + let mut ethereum_hashes = vec![]; + let mut substrate_hashes = vec![]; + let mut transaction_hashes = vec![]; + { + // Create a temporary frontier secondary DB. + let backend = open_frontier_backend(client.clone(), &setting) + .expect("a temporary db was created"); + + // Fill the tmp db with some data + let mut transaction = sp_database::Transaction::new(); + for _ in 0..1000 { + // Ethereum hash + let ethhash = H256::random(); + // Create two branches, and map the orphan one. + // Keep track of the canon hash to later verify the migration replaced it. + // A1 + let mut builder = client + .new_block_at( + &BlockId::Hash(previous_canon_block_hash), + Default::default(), + false, + ) + .unwrap(); + builder.push_storage_change(vec![1], None).unwrap(); + let block = builder.build().unwrap().block; + let next_canon_block_hash = block.header.hash(); + executor::block_on(client.import(BlockOrigin::Own, block)).unwrap(); + // A2 + let mut builder = client + .new_block_at( + &BlockId::Hash(previous_canon_block_hash), + Default::default(), + false, + ) + .unwrap(); + builder.push_storage_change(vec![2], None).unwrap(); + let block = builder.build().unwrap().block; + let orphan_block_hash = block.header.hash(); + executor::block_on(client.import(BlockOrigin::Own, block)).unwrap(); + + // Track canon hash + ethereum_hashes.push(ethhash); + substrate_hashes.push(next_canon_block_hash); + // Set orphan hash block mapping + transaction.set( + crate::columns::BLOCK_MAPPING, + ðhash.encode(), + &orphan_block_hash.encode(), + ); + // Test also that one-to-many transaction data is not affected by the migration logic. + // Map a transaction to both canon and orphan block hashes. This is what would have + // happened in case of fork or equivocation. + let eth_tx_hash = H256::random(); + let mut metadata = vec![]; + for hash in vec![next_canon_block_hash, orphan_block_hash].iter() { + metadata.push(crate::TransactionMetadata:: { + block_hash: *hash, + ethereum_block_hash: ethhash, + ethereum_index: 0u32, + }); + } + transaction.set( + crate::columns::TRANSACTION_MAPPING, + ð_tx_hash.encode(), + &metadata.encode(), + ); + transaction_hashes.push(eth_tx_hash); + previous_canon_block_hash = next_canon_block_hash; + } + let _ = backend.mapping().db.commit(transaction); + } + // Upgrade database from version 1 to 2 + let _ = super::upgrade_db::(client.clone(), &path, &setting.source); + + // Check data after migration + let backend = + open_frontier_backend(client, &setting).expect("a temporary db was created"); + for (i, original_ethereum_hash) in ethereum_hashes.iter().enumerate() { + let canon_substrate_block_hash = substrate_hashes.get(i).expect("Block hash"); + let mapped_block = backend + .mapping() + .block_hash(original_ethereum_hash) + .unwrap() + .unwrap(); + // All entries now hold a single element Vec + assert_eq!(mapped_block.len(), 1); + // The Vec holds the canon block hash + assert_eq!(mapped_block.first(), Some(canon_substrate_block_hash)); + // Transaction hash still holds canon block data + let mapped_transaction = backend + .mapping() + .transaction_metadata(transaction_hashes.get(i).expect("Transaction hash")) + .unwrap(); + assert!(mapped_transaction + .into_iter() + .any(|tx| tx.block_hash == *canon_substrate_block_hash)); + } + + // Upgrade db version file + assert_eq!(super::current_version(&path).expect("version"), 2u32); + } + } +} diff --git a/client/db/src/utils.rs b/client/db/src/utils.rs index 37542e9ca4..9fd7dca14e 100644 --- a/client/db/src/utils.rs +++ b/client/db/src/utils.rs @@ -18,51 +18,113 @@ use std::{path::Path, sync::Arc}; +use sp_runtime::traits::Block as BlockT; + use crate::{Database, DatabaseSettings, DatabaseSource, DbHash}; -pub fn open_database(config: &DatabaseSettings) -> Result>, String> { +pub fn open_database( + client: Arc, + config: &DatabaseSettings, +) -> Result>, String> +where + C: sp_blockchain::HeaderBackend + Send + Sync, +{ let db: Arc> = match &config.source { - DatabaseSource::ParityDb { path } => open_parity_db(path)?, - DatabaseSource::RocksDb { path, .. } => open_kvdb_rocksdb(path, true)?, + DatabaseSource::ParityDb { path } => { + open_parity_db::(client, path, &config.source)? + } + DatabaseSource::RocksDb { path, .. } => { + open_kvdb_rocksdb::(client, path, true, &config.source)? + } DatabaseSource::Auto { paritydb_path, rocksdb_path, .. - } => match open_kvdb_rocksdb(rocksdb_path, false) { - Ok(db) => db, - Err(_) => open_parity_db(paritydb_path)?, - }, + } => { + match open_kvdb_rocksdb::(client.clone(), rocksdb_path, false, &config.source) + { + Ok(db) => db, + Err(_) => open_parity_db::(client, paritydb_path, &config.source)?, + } + } _ => return Err("Missing feature flags `parity-db`".to_string()), }; Ok(db) } #[cfg(feature = "kvdb-rocksdb")] -fn open_kvdb_rocksdb(path: &Path, create: bool) -> Result>, String> { +fn open_kvdb_rocksdb( + client: Arc, + path: &Path, + create: bool, + _source: &DatabaseSource, +) -> Result>, String> +where + C: sp_blockchain::HeaderBackend + Send + Sync, +{ + // first upgrade database to required version + #[cfg(not(test))] + match crate::upgrade::upgrade_db::(client, path, _source) { + Ok(_) => (), + Err(_) => return Err("Frontier DB upgrade error".to_string()), + } + let mut db_config = kvdb_rocksdb::DatabaseConfig::with_columns(crate::columns::NUM_COLUMNS); db_config.create_if_missing = create; - let path = path - .to_str() - .ok_or_else(|| "Invalid database path".to_string())?; - let db = kvdb_rocksdb::Database::open(&db_config, &path).map_err(|err| format!("{}", err))?; + // write database version only after the database is succesfully opened + #[cfg(not(test))] + let _ = crate::upgrade::update_version(path).map_err(|_| "Cannot update db version".to_string())?; return Ok(sp_database::as_database(db)); } #[cfg(not(feature = "kvdb-rocksdb"))] -fn open_kvdb_rocksdb(_path: &Path, _create: bool) -> Result>, String> { +fn open_kvdb_rocksdb( + _client: Arc, + _path: &Path, + _create: bool, + _source: &DatabaseSource, +) -> Result>, String> +where + C: sp_blockchain::HeaderBackend + Send + Sync, +{ Err("Missing feature flags `kvdb-rocksdb`".to_string()) } #[cfg(feature = "parity-db")] -fn open_parity_db(path: &Path) -> Result>, String> { - let config = parity_db::Options::with_columns(path, crate::columns::NUM_COLUMNS as u8); +fn open_parity_db( + client: Arc, + path: &Path, + _source: &DatabaseSource, +) -> Result>, String> +where + C: sp_blockchain::HeaderBackend + Send + Sync, +{ + // first upgrade database to required version + #[cfg(not(test))] + match crate::upgrade::upgrade_db::(client, path, _source) { + Ok(_) => (), + Err(_) => return Err("Frontier DB upgrade error".to_string()), + } + let mut config = parity_db::Options::with_columns(path, crate::columns::NUM_COLUMNS as u8); + config.columns[crate::columns::BLOCK_MAPPING as usize].btree_index = true; + let db = parity_db::Db::open_or_create(&config).map_err(|err| format!("{}", err))?; + // write database version only after the database is succesfully opened + #[cfg(not(test))] + let _ = crate::upgrade::update_version(path).map_err(|_| "Cannot update db version".to_string())?; Ok(Arc::new(crate::parity_db_adapter::DbAdapter(db))) } #[cfg(not(feature = "parity-db"))] -fn open_parity_db(_path: &Path) -> Result>, String> { +fn open_parity_db( + _client: Arc, + _path: &Path, + _source: &DatabaseSource, +) -> Result>, String> +where + C: sp_blockchain::HeaderBackend + Send + Sync, +{ Err("Missing feature flags `parity-db`".to_string()) } diff --git a/client/rpc/src/eth/block.rs b/client/rpc/src/eth/block.rs index 972063f201..1997b450c0 100644 --- a/client/rpc/src/eth/block.rs +++ b/client/rpc/src/eth/block.rs @@ -48,8 +48,12 @@ where let block_data_cache = Arc::clone(&self.block_data_cache); let backend = Arc::clone(&self.backend); - let id = match frontier_backend_client::load_hash::(backend.as_ref(), hash) - .map_err(|err| internal_err(format!("{:?}", err)))? + let id = match frontier_backend_client::load_hash::( + client.as_ref(), + backend.as_ref(), + hash, + ) + .map_err(|err| internal_err(format!("{:?}", err)))? { Some(hash) => hash, _ => return Ok(None), @@ -137,8 +141,12 @@ where } pub fn block_transaction_count_by_hash(&self, hash: H256) -> Result> { - let id = match frontier_backend_client::load_hash::(self.backend.as_ref(), hash) - .map_err(|err| internal_err(format!("{:?}", err)))? + let id = match frontier_backend_client::load_hash::( + self.client.as_ref(), + self.backend.as_ref(), + hash, + ) + .map_err(|err| internal_err(format!("{:?}", err)))? { Some(hash) => hash, _ => return Ok(None), diff --git a/client/rpc/src/eth/filter.rs b/client/rpc/src/eth/filter.rs index f275c2ead4..00f09f5b24 100644 --- a/client/rpc/src/eth/filter.rs +++ b/client/rpc/src/eth/filter.rs @@ -363,8 +363,12 @@ where let mut ret: Vec = Vec::new(); if let Some(hash) = filter.block_hash { - let id = match frontier_backend_client::load_hash::(backend.as_ref(), hash) - .map_err(|err| internal_err(format!("{:?}", err)))? + let id = match frontier_backend_client::load_hash::( + client.as_ref(), + backend.as_ref(), + hash, + ) + .map_err(|err| internal_err(format!("{:?}", err)))? { Some(hash) => hash, _ => return Ok(Vec::new()), diff --git a/client/rpc/src/eth/transaction.rs b/client/rpc/src/eth/transaction.rs index 6b1489662d..e0600429a4 100644 --- a/client/rpc/src/eth/transaction.rs +++ b/client/rpc/src/eth/transaction.rs @@ -127,8 +127,12 @@ where } }; - let id = match frontier_backend_client::load_hash::(backend.as_ref(), hash) - .map_err(|err| internal_err(format!("{:?}", err)))? + let id = match frontier_backend_client::load_hash::( + client.as_ref(), + backend.as_ref(), + hash, + ) + .map_err(|err| internal_err(format!("{:?}", err)))? { Some(hash) => hash, _ => return Ok(None), @@ -172,8 +176,12 @@ where let block_data_cache = Arc::clone(&self.block_data_cache); let backend = Arc::clone(&self.backend); - let id = match frontier_backend_client::load_hash::(backend.as_ref(), hash) - .map_err(|err| internal_err(format!("{:?}", err)))? + let id = match frontier_backend_client::load_hash::( + client.as_ref(), + backend.as_ref(), + hash, + ) + .map_err(|err| internal_err(format!("{:?}", err)))? { Some(hash) => hash, _ => return Ok(None), @@ -291,8 +299,12 @@ where None => return Ok(None), }; - let id = match frontier_backend_client::load_hash::(backend.as_ref(), hash) - .map_err(|err| internal_err(format!("{:?}", err)))? + let id = match frontier_backend_client::load_hash::( + client.as_ref(), + backend.as_ref(), + hash, + ) + .map_err(|err| internal_err(format!("{:?}", err)))? { Some(hash) => hash, _ => return Ok(None), diff --git a/client/rpc/src/lib.rs b/client/rpc/src/lib.rs index 2b2f2242e6..553174fb85 100644 --- a/client/rpc/src/lib.rs +++ b/client/rpc/src/lib.rs @@ -76,7 +76,9 @@ pub mod frontier_backend_client { C: HeaderBackend + Send + Sync + 'static, { Ok(match number.unwrap_or(BlockNumber::Latest) { - BlockNumber::Hash { hash, .. } => load_hash::(backend, hash).unwrap_or(None), + BlockNumber::Hash { hash, .. } => { + load_hash::(client, backend, hash).unwrap_or(None) + } BlockNumber::Num(number) => Some(BlockId::Number(number.unique_saturated_into())), BlockNumber::Latest => Some(BlockId::Hash(client.info().best_hash)), BlockNumber::Earliest => Some(BlockId::Number(Zero::zero())), @@ -86,29 +88,36 @@ pub mod frontier_backend_client { }) } - pub fn load_hash( + pub fn load_hash( + client: &C, backend: &fc_db::Backend, hash: H256, ) -> RpcResult>> where B: BlockT + Send + Sync + 'static, + C: HeaderBackend + Send + Sync + 'static, { - let substrate_hash = backend + let substrate_hashes = backend .mapping() .block_hash(&hash) .map_err(|err| internal_err(format!("fetch aux store failed: {:?}", err)))?; - if let Some(substrate_hash) = substrate_hash { - return Ok(Some(BlockId::Hash(substrate_hash))); + if let Some(substrate_hashes) = substrate_hashes { + for substrate_hash in substrate_hashes { + if is_canon::(client, substrate_hash) { + return Ok(Some(BlockId::Hash(substrate_hash))); + } + } } Ok(None) } - pub fn load_cached_schema( + pub fn load_cached_schema( backend: &fc_db::Backend, ) -> RpcResult>> where B: BlockT + Send + Sync + 'static, + C: HeaderBackend + Send + Sync + 'static, { let cache = backend .meta() @@ -117,12 +126,13 @@ pub mod frontier_backend_client { Ok(cache) } - pub fn write_cached_schema( + pub fn write_cached_schema( backend: &fc_db::Backend, new_cache: Vec<(EthereumStorageSchema, H256)>, ) -> RpcResult<()> where B: BlockT + Send + Sync + 'static, + C: HeaderBackend + Send + Sync + 'static, { backend .meta() @@ -246,3 +256,143 @@ pub fn public_key(transaction: &EthereumTransaction) -> Result<[u8; 64], sp_io:: } sp_io::crypto::secp256k1_ecdsa_recover(&sig, &msg) } + +#[cfg(test)] +mod tests { + use std::{path::PathBuf, sync::Arc}; + + use futures::executor; + use sc_block_builder::BlockBuilderProvider; + use sp_consensus::BlockOrigin; + use sp_runtime::{ + generic::{Block, BlockId, Header}, + traits::BlakeTwo256, + }; + use substrate_test_runtime_client::{ + prelude::*, DefaultTestClientBuilderExt, TestClientBuilder, + }; + use tempfile::tempdir; + + type OpaqueBlock = + Block, substrate_test_runtime_client::runtime::Extrinsic>; + + fn open_frontier_backend( + client: Arc, + path: PathBuf, + ) -> Result>, String> + where + C: sp_blockchain::HeaderBackend, + { + Ok(Arc::new(fc_db::Backend::::new( + client, + &fc_db::DatabaseSettings { + source: sc_client_db::DatabaseSource::RocksDb { + path, + cache_size: 0, + }, + }, + )?)) + } + + #[test] + fn substrate_block_hash_one_to_many_works() { + let tmp = tempdir().expect("create a temporary directory"); + let (client, _) = TestClientBuilder::new() + .build_with_native_executor::( + None, + ); + + let mut client = Arc::new(client); + + // Create a temporary frontier secondary DB. + let frontier_backend = open_frontier_backend(client.clone(), tmp.into_path()).unwrap(); + + // A random ethereum block hash to use + let ethereum_block_hash = sp_core::H256::random(); + + // G -> A1. + let mut builder = client.new_block(Default::default()).unwrap(); + builder.push_storage_change(vec![1], None).unwrap(); + let a1 = builder.build().unwrap().block; + let a1_hash = a1.header.hash(); + executor::block_on(client.import(BlockOrigin::Own, a1)).unwrap(); + + // A1 -> B1 + let mut builder = client + .new_block_at(&BlockId::Hash(a1_hash), Default::default(), false) + .unwrap(); + builder.push_storage_change(vec![1], None).unwrap(); + let b1 = builder.build().unwrap().block; + let b1_hash = b1.header.hash(); + executor::block_on(client.import(BlockOrigin::Own, b1)).unwrap(); + + // Map B1 + let commitment = fc_db::MappingCommitment:: { + block_hash: b1_hash, + ethereum_block_hash, + ethereum_transaction_hashes: vec![], + }; + let _ = frontier_backend.mapping().write_hashes(commitment); + + // Expect B1 to be canon + assert_eq!( + super::frontier_backend_client::load_hash( + client.as_ref(), + frontier_backend.as_ref(), + ethereum_block_hash + ) + .unwrap() + .unwrap(), + BlockId::Hash(b1_hash), + ); + + // A1 -> B2 + let mut builder = client + .new_block_at(&BlockId::Hash(a1_hash), Default::default(), false) + .unwrap(); + builder.push_storage_change(vec![2], None).unwrap(); + let b2 = builder.build().unwrap().block; + let b2_hash = b2.header.hash(); + executor::block_on(client.import(BlockOrigin::Own, b2)).unwrap(); + + // Map B2 to same ethereum hash + let commitment = fc_db::MappingCommitment:: { + block_hash: b2_hash, + ethereum_block_hash, + ethereum_transaction_hashes: vec![], + }; + let _ = frontier_backend.mapping().write_hashes(commitment); + + // Still expect B1 to be canon + assert_eq!( + super::frontier_backend_client::load_hash( + client.as_ref(), + frontier_backend.as_ref(), + ethereum_block_hash + ) + .unwrap() + .unwrap(), + BlockId::Hash(b1_hash), + ); + + // B2 -> C1. B2 branch is now canon. + let mut builder = client + .new_block_at(&BlockId::Hash(b2_hash), Default::default(), false) + .unwrap(); + builder.push_storage_change(vec![1], None).unwrap(); + let c1 = builder.build().unwrap().block; + executor::block_on(client.import(BlockOrigin::Own, c1)).unwrap(); + + // Expect B2 to be new canon + assert_eq!( + super::frontier_backend_client::load_hash( + client.as_ref(), + frontier_backend.as_ref(), + ethereum_block_hash + ) + .unwrap() + .unwrap(), + BlockId::Hash(b2_hash), + ); + } +} diff --git a/template/node/src/service.rs b/template/node/src/service.rs index 0ac8cf1651..8df42ce63e 100644 --- a/template/node/src/service.rs +++ b/template/node/src/service.rs @@ -151,6 +151,7 @@ pub fn new_partial( ); let frontier_backend = Arc::new(FrontierBackend::open( + Arc::clone(&client), &config.database, &db_config_dir(config), )?); From 72aeaf67fc7483c17373d0ecce55b98e08096785 Mon Sep 17 00:00:00 2001 From: nanocryk <6422796+nanocryk@users.noreply.github.com> Date: Thu, 6 Oct 2022 11:02:40 +0200 Subject: [PATCH 17/21] impl original_storage in SubstrateStackState (#871) * handle original_storage * only cache original_storage in set_storage * test * clippy * remove RefCell * don't write to cache if = to original --- frame/evm/src/runner/stack.rs | 35 ++++++++++++++++--- ts-tests/tests/test-contract-storage.ts | 46 ++++++++++++++++++++++++- 2 files changed, 76 insertions(+), 5 deletions(-) diff --git a/frame/evm/src/runner/stack.rs b/frame/evm/src/runner/stack.rs index 225c3d5065..2e30a1c420 100644 --- a/frame/evm/src/runner/stack.rs +++ b/frame/evm/src/runner/stack.rs @@ -31,7 +31,13 @@ use fp_evm::{CallInfo, CreateInfo, ExecutionInfo, Log, Vicinity}; use frame_support::traits::{Currency, ExistenceRequirement, Get}; use sp_core::{H160, H256, U256}; use sp_runtime::traits::UniqueSaturatedInto; -use sp_std::{boxed::Box, collections::btree_set::BTreeSet, marker::PhantomData, mem, vec::Vec}; +use sp_std::{ + boxed::Box, + collections::{btree_map::BTreeMap, btree_set::BTreeSet}, + marker::PhantomData, + mem, + vec::Vec, +}; #[cfg(feature = "forbid-evm-reentrancy")] environmental::thread_local_impl!(static IN_EVM: environmental::RefCell = environmental::RefCell::new(false)); @@ -553,6 +559,7 @@ impl<'config> SubstrateStackSubstate<'config> { pub struct SubstrateStackState<'vicinity, 'config, T> { vicinity: &'vicinity Vicinity, substate: SubstrateStackSubstate<'config>, + original_storage: BTreeMap<(H160, H256), H256>, _marker: PhantomData, } @@ -568,6 +575,7 @@ impl<'vicinity, 'config, T: Config> SubstrateStackState<'vicinity, 'config, T> { parent: None, }, _marker: PhantomData, + original_storage: BTreeMap::new(), } } } @@ -635,8 +643,15 @@ impl<'vicinity, 'config, T: Config> BackendT for SubstrateStackState<'vicinity, >::get(address, index) } - fn original_storage(&self, _address: H160, _index: H256) -> Option { - None + fn original_storage(&self, address: H160, index: H256) -> Option { + // Not being cached means that it was never changed, which means we + // can fetch it from storage. + Some( + self.original_storage + .get(&(address, index)) + .cloned() + .unwrap_or_else(|| self.storage(address, index)), + ) } fn block_base_fee_per_gas(&self) -> sp_core::U256 { @@ -688,6 +703,18 @@ where } fn set_storage(&mut self, address: H160, index: H256, value: H256) { + // We cache the current value if this is the first time we modify it + // in the transaction. + use sp_std::collections::btree_map::Entry::Vacant; + if let Vacant(e) = self.original_storage.entry((address, index)) { + let original = >::get(address, index); + // No need to cache if same value. + if original != value { + e.insert(original); + } + } + + // Then we insert or remove the entry based on the value. if value == H256::default() { log::debug!( target: "evm", @@ -752,7 +779,7 @@ where // // This function exists in EVM because a design issue // (arguably a bug) in SELFDESTRUCT that can cause total - // issurance to be reduced. We do not need to replicate this. + // issuance to be reduced. We do not need to replicate this. } fn touch(&mut self, _address: H160) { diff --git a/ts-tests/tests/test-contract-storage.ts b/ts-tests/tests/test-contract-storage.ts index a08bdedc78..d39fa7fe4c 100644 --- a/ts-tests/tests/test-contract-storage.ts +++ b/ts-tests/tests/test-contract-storage.ts @@ -2,7 +2,7 @@ import { expect } from "chai"; import { AbiItem } from "web3-utils"; import Test from "../build/contracts/Storage.json"; -import { GENESIS_ACCOUNT, GENESIS_ACCOUNT_PRIVATE_KEY } from "./config"; +import { GENESIS_ACCOUNT, GENESIS_ACCOUNT_PRIVATE_KEY, FIRST_CONTRACT_ADDRESS } from "./config"; import { createAndFinalizeBlock, customRequest, describeWithFrontier } from "./util"; describeWithFrontier("Frontier RPC (Contract)", (context) => { @@ -80,4 +80,48 @@ describeWithFrontier("Frontier RPC (Contract)", (context) => { expect(getStorage1.result).to.be.eq(expectedStorage); }); + + it("SSTORE cost should properly take into account transaction initial value", async function () { + this.timeout(5000); + + let nonce = await context.web3.eth.getTransactionCount(GENESIS_ACCOUNT); + + await context.web3.eth.accounts.wallet.add(GENESIS_ACCOUNT_PRIVATE_KEY); + const contract = new context.web3.eth.Contract(TEST_CONTRACT_ABI, FIRST_CONTRACT_ADDRESS, { + from: GENESIS_ACCOUNT, + gasPrice: "0x3B9ACA00", + }); + + const promisify = (inner) => new Promise((resolve, reject) => inner(resolve, reject)); + + let tx1 = contract.methods + .setStorage("0x2A", "0x1") + .send({ from: GENESIS_ACCOUNT, gas: "0x100000", nonce: nonce++ }); + + let tx2 = contract.methods + .setStorage("0x2A", "0x1") + .send({ from: GENESIS_ACCOUNT, gas: "0x100000", nonce: nonce++ }); + + let tx3 = contract.methods + .setStorage("0x2A", "0x2") + .send( + { from: GENESIS_ACCOUNT, gas: "0x100000", nonce: nonce++ }, + async (hash) => await createAndFinalizeBlock(context.web3) + ); + + tx1 = await tx1; + tx2 = await tx2; + tx3 = await tx3; + + // cost minus SSTORE + const baseCost = 24029; + + // going from unset storage to some value (original = 0) + expect(tx1.gasUsed - baseCost).to.be.eq(20000); + // in London config, setting back the same value have cost of warm read + expect(tx2.gasUsed - baseCost).to.be.eq(100); + // - the original storage didn't change in the current transaction + // - the original storage is not zero (otherwise tx1) + expect(tx3.gasUsed - baseCost).to.be.eq(2900); + }); }); From e3ee95ab59d4ce04ec23110abe56ea69af8e79e1 Mon Sep 17 00:00:00 2001 From: Stephen Shelton Date: Thu, 6 Oct 2022 04:49:40 -0600 Subject: [PATCH 18/21] EIP1559 strict balance validation (#857) * Change test assumptions * Validate account balance against max_fee_per_gas * Deduct base_fee + tip rather than max_fee_per_gas * fmt * Leave actual_priority_fee_per_gas unused * Remove TODO comment --- frame/evm/src/runner/stack.rs | 65 +++++++++++++++++--------------- primitives/evm/src/validation.rs | 30 +++++++-------- 2 files changed, 49 insertions(+), 46 deletions(-) diff --git a/frame/evm/src/runner/stack.rs b/frame/evm/src/runner/stack.rs index 2e30a1c420..2d1c737ba0 100644 --- a/frame/evm/src/runner/stack.rs +++ b/frame/evm/src/runner/stack.rs @@ -130,27 +130,41 @@ where >, ) -> (ExitReason, R), { - let max_fee_per_gas = match (max_fee_per_gas, is_transactional) { - (Some(max_fee_per_gas), _) => max_fee_per_gas, - // Gas price check is skipped for non-transactional calls that don't - // define a `max_fee_per_gas` input. - (None, false) => Default::default(), - // Unreachable, previously validated. Handle gracefully. - _ => { - return Err(RunnerError { - error: Error::::GasPriceTooLow, - weight, - }) - } - }; + let (total_fee_per_gas, _actual_priority_fee_per_gas) = + match (max_fee_per_gas, max_priority_fee_per_gas, is_transactional) { + // With no tip, we pay exactly the base_fee + (Some(_), None, _) => (base_fee, U256::zero()), + // With tip, we include as much of the tip on top of base_fee that we can, never + // exceeding max_fee_per_gas + (Some(max_fee_per_gas), Some(max_priority_fee_per_gas), _) => { + let actual_priority_fee_per_gas = max_fee_per_gas + .saturating_sub(base_fee) + .min(max_priority_fee_per_gas); + ( + base_fee.saturating_add(actual_priority_fee_per_gas), + actual_priority_fee_per_gas, + ) + } + // Gas price check is skipped for non-transactional calls that don't + // define a `max_fee_per_gas` input. + (None, _, false) => (Default::default(), U256::zero()), + // Unreachable, previously validated. Handle gracefully. + _ => { + return Err(RunnerError { + error: Error::::GasPriceTooLow, + weight, + }) + } + }; // After eip-1559 we make sure the account can pay both the evm execution and priority fees. - let total_fee = max_fee_per_gas - .checked_mul(U256::from(gas_limit)) - .ok_or(RunnerError { - error: Error::::FeeOverflow, - weight, - })?; + let total_fee = + total_fee_per_gas + .checked_mul(U256::from(gas_limit)) + .ok_or(RunnerError { + error: Error::::FeeOverflow, + weight, + })?; // Deduct fee from the `source` account. Returns `None` if `total_fee` is Zero. let fee = T::OnChargeTransaction::withdraw_fee(&source, total_fee) @@ -170,18 +184,7 @@ where // Post execution. let used_gas = U256::from(executor.used_gas()); - let actual_fee = if let Some(max_priority_fee) = max_priority_fee_per_gas { - let actual_priority_fee = max_fee_per_gas - .saturating_sub(base_fee) - .min(max_priority_fee) - .saturating_mul(used_gas); - executor - .fee(base_fee) - .checked_add(actual_priority_fee) - .unwrap_or_else(U256::max_value) - } else { - executor.fee(base_fee) - }; + let actual_fee = executor.fee(total_fee_per_gas); log::debug!( target: "evm", "Execution {:?} [source: {:?}, value: {}, gas_limit: {}, actual_fee: {}, is_transactional: {}]", diff --git a/primitives/evm/src/validation.rs b/primitives/evm/src/validation.rs index 4913d5dfdc..046d60be5b 100644 --- a/primitives/evm/src/validation.rs +++ b/primitives/evm/src/validation.rs @@ -116,23 +116,18 @@ impl<'config, E: From> CheckEvmTransaction<'config, pub fn with_balance_for(&self, who: &Account) -> Result<&Self, E> { // Get fee data from either a legacy or typed transaction input. - let (_, effective_gas_price) = self.transaction_fee_input()?; + let (max_fee_per_gas, _) = self.transaction_fee_input()?; // Account has enough funds to pay for the transaction. // Check is skipped on non-transactional calls that don't provide // a gas price input. // - // Fee for EIP-1559 transaction **with** tip is calculated using - // the effective gas price. - // - // Fee for EIP-1559 transaction **without** tip is calculated using - // the base fee. + // Validation for EIP-1559 is done using the max_fee_per_gas, which is + // the most a txn could possibly pay. // // Fee for Legacy or EIP-2930 transaction is calculated using // the provided `gas_price`. - let fee = effective_gas_price - .unwrap_or_default() - .saturating_mul(self.transaction.gas_limit); + let fee = max_fee_per_gas.saturating_mul(self.transaction.gas_limit); if self.config.is_transactional || fee > U256::zero() { let total_payment = self.transaction.value.saturating_add(fee); if who.balance < total_payment { @@ -142,6 +137,9 @@ impl<'config, E: From> CheckEvmTransaction<'config, Ok(self) } + // Returns the max_fee_per_gas (or gas_price for legacy txns) as well as an optional + // effective_gas_price for EIP-1559 transactions. effective_gas_price represents + // the total (fee + tip) that would be paid given the current base_fee. fn transaction_fee_input(&self) -> Result<(U256, Option), E> { match ( self.transaction.gas_price, @@ -659,29 +657,31 @@ mod tests { } #[test] - // Account balance is matched against the base fee without tip. - fn validate_balance_using_base_fee() { + // Account balance is matched against max_fee_per_gas (without txn tip) + fn validate_balance_regardless_of_base_fee() { let who = Account { + // sufficient for base_fee, but not for max_fee_per_gas balance: U256::from(21_000_000_000_001u128), nonce: U256::zero(), }; let with_tip = false; let test = transaction_max_fee_high(with_tip); let res = test.with_balance_for(&who); - assert!(res.is_ok()); + assert!(res.is_err()); } #[test] - // Account balance is matched against the effective gas price with tip. - fn validate_balance_using_effective_gas_price() { + // Account balance is matched against max_fee_per_gas (with txn tip) + fn validate_balance_regardless_of_effective_gas_price() { let who = Account { + // sufficient for (base_fee + tip), but not for max_fee_per_gas balance: U256::from(42_000_000_000_001u128), nonce: U256::zero(), }; let with_tip = true; let test = transaction_max_fee_high(with_tip); let res = test.with_balance_for(&who); - assert!(res.is_ok()); + assert!(res.is_err()); } #[test] From d492fd4bc60727c23f63a0adc6da4fc6a11c706d Mon Sep 17 00:00:00 2001 From: tgmichel Date: Mon, 10 Oct 2022 00:49:46 +0200 Subject: [PATCH 19/21] Version 2 db migration improvements (#874) --- client/db/src/upgrade.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/client/db/src/upgrade.rs b/client/db/src/upgrade.rs index 5660ebe198..34a4739631 100644 --- a/client/db/src/upgrade.rs +++ b/client/db/src/upgrade.rs @@ -205,6 +205,11 @@ where maybe_error = false; } } + } else { + // If version 2 data, we just consider this hash a success. + // This can happen if the process was closed in the middle of the migration. + res.success += 1; + maybe_error = false; } } if maybe_error { @@ -213,6 +218,12 @@ where } db.write(transaction) .map_err(|_| io::Error::new(ErrorKind::Other, "Failed to commit on migrate_1_to_2"))?; + log::debug!( + target: "fc-db-upgrade", + "🔨 Success {}, error {}.", + res.success, + res.error.len() + ); Ok(()) }; @@ -228,8 +239,15 @@ where // Read and update each entry in db transaction batches const CHUNK_SIZE: usize = 10_000; let chunks = ethereum_hashes.chunks(CHUNK_SIZE); - for chunk in chunks { + let all_len = ethereum_hashes.len(); + for (i, chunk) in chunks.enumerate() { process_chunk(&db, chunk)?; + log::debug!( + target: "fc-db-upgrade", + "🔨 Processed {} of {} entries.", + (CHUNK_SIZE * (i + 1)), + all_len + ); } Ok(res) } From 692df1f7ed49712a35dc988dac7e83dbabbec784 Mon Sep 17 00:00:00 2001 From: tgmichel Date: Mon, 10 Oct 2022 17:01:50 +0200 Subject: [PATCH 20/21] Add back support for zero gas price validated transactions (#875) --- frame/ethereum/src/tests/eip1559.rs | 35 ++++++++++++++++++++++++++++- frame/ethereum/src/tests/eip2930.rs | 33 +++++++++++++++++++++++++++ frame/ethereum/src/tests/legacy.rs | 33 +++++++++++++++++++++++++++ frame/evm/src/runner/stack.rs | 3 +++ 4 files changed, 103 insertions(+), 1 deletion(-) diff --git a/frame/ethereum/src/tests/eip1559.rs b/frame/ethereum/src/tests/eip1559.rs index 94fad5d8d0..687cb89252 100644 --- a/frame/ethereum/src/tests/eip1559.rs +++ b/frame/ethereum/src/tests/eip1559.rs @@ -18,8 +18,9 @@ //! Consensus extension module tests for BABE consensus. use super::*; +use fp_ethereum::ValidatedTransaction; use frame_support::{traits::Get, weights::DispatchClass}; -use pallet_evm::GasWeightMapping; +use pallet_evm::{AddressMapping, GasWeightMapping}; fn eip1559_erc20_creation_unsigned_transaction() -> EIP1559UnsignedTransaction { EIP1559UnsignedTransaction { @@ -453,3 +454,35 @@ fn self_contained_transaction_with_extra_gas_should_adjust_weight_with_post_disp ); }); } + +#[test] +fn validated_transaction_apply_zero_gas_price_works() { + let (pairs, mut ext) = new_test_ext_with_initial_balance(2, 1_000); + let alice = &pairs[0]; + let bob = &pairs[1]; + let substrate_alice = + ::AddressMapping::into_account_id(alice.address); + let substrate_bob = ::AddressMapping::into_account_id(bob.address); + + ext.execute_with(|| { + let transaction = EIP1559UnsignedTransaction { + nonce: U256::zero(), + max_priority_fee_per_gas: U256::zero(), + max_fee_per_gas: U256::zero(), + gas_limit: U256::from(21_000), + action: ethereum::TransactionAction::Call(bob.address), + value: U256::from(100), + input: Default::default(), + } + .sign(&alice.private_key, None); + + assert_ok!(crate::ValidatedTransaction::::apply( + alice.address, + transaction + )); + // Alice didn't pay fees, transfer 100 to Bob. + assert_eq!(Balances::free_balance(&substrate_alice), 900); + // Bob received 100 from Alice. + assert_eq!(Balances::free_balance(&substrate_bob), 1_100); + }); +} diff --git a/frame/ethereum/src/tests/eip2930.rs b/frame/ethereum/src/tests/eip2930.rs index fbdac95590..7f5cd050ad 100644 --- a/frame/ethereum/src/tests/eip2930.rs +++ b/frame/ethereum/src/tests/eip2930.rs @@ -18,6 +18,8 @@ //! Consensus extension module tests for BABE consensus. use super::*; +use fp_ethereum::ValidatedTransaction; +use pallet_evm::AddressMapping; fn eip2930_erc20_creation_unsigned_transaction() -> EIP2930UnsignedTransaction { EIP2930UnsignedTransaction { @@ -374,3 +376,34 @@ fn self_contained_transaction_with_extra_gas_should_adjust_weight_with_post_disp ); }); } + +#[test] +fn validated_transaction_apply_zero_gas_price_works() { + let (pairs, mut ext) = new_test_ext_with_initial_balance(2, 1_000); + let alice = &pairs[0]; + let bob = &pairs[1]; + let substrate_alice = + ::AddressMapping::into_account_id(alice.address); + let substrate_bob = ::AddressMapping::into_account_id(bob.address); + + ext.execute_with(|| { + let transaction = EIP2930UnsignedTransaction { + nonce: U256::zero(), + gas_price: U256::zero(), + gas_limit: U256::from(21_000), + action: ethereum::TransactionAction::Call(bob.address), + value: U256::from(100), + input: Default::default(), + } + .sign(&alice.private_key, None); + + assert_ok!(crate::ValidatedTransaction::::apply( + alice.address, + transaction + )); + // Alice didn't pay fees, transfer 100 to Bob. + assert_eq!(Balances::free_balance(&substrate_alice), 900); + // Bob received 100 from Alice. + assert_eq!(Balances::free_balance(&substrate_bob), 1_100); + }); +} diff --git a/frame/ethereum/src/tests/legacy.rs b/frame/ethereum/src/tests/legacy.rs index 84acb27d94..c749125a5d 100644 --- a/frame/ethereum/src/tests/legacy.rs +++ b/frame/ethereum/src/tests/legacy.rs @@ -18,6 +18,8 @@ //! Consensus extension module tests for BABE consensus. use super::*; +use fp_ethereum::ValidatedTransaction; +use pallet_evm::AddressMapping; fn legacy_erc20_creation_unsigned_transaction() -> LegacyUnsignedTransaction { LegacyUnsignedTransaction { @@ -374,3 +376,34 @@ fn self_contained_transaction_with_extra_gas_should_adjust_weight_with_post_disp ); }); } + +#[test] +fn validated_transaction_apply_zero_gas_price_works() { + let (pairs, mut ext) = new_test_ext_with_initial_balance(2, 1_000); + let alice = &pairs[0]; + let bob = &pairs[1]; + let substrate_alice = + ::AddressMapping::into_account_id(alice.address); + let substrate_bob = ::AddressMapping::into_account_id(bob.address); + + ext.execute_with(|| { + let transaction = LegacyUnsignedTransaction { + nonce: U256::zero(), + gas_price: U256::zero(), + gas_limit: U256::from(21_000), + action: ethereum::TransactionAction::Call(bob.address), + value: U256::from(100), + input: Default::default(), + } + .sign(&alice.private_key); + + assert_ok!(crate::ValidatedTransaction::::apply( + alice.address, + transaction + )); + // Alice didn't pay fees, transfer 100 to Bob. + assert_eq!(Balances::free_balance(&substrate_alice), 900); + // Bob received 100 from Alice. + assert_eq!(Balances::free_balance(&substrate_bob), 1_100); + }); +} diff --git a/frame/evm/src/runner/stack.rs b/frame/evm/src/runner/stack.rs index 2d1c737ba0..49b475d057 100644 --- a/frame/evm/src/runner/stack.rs +++ b/frame/evm/src/runner/stack.rs @@ -132,6 +132,9 @@ where { let (total_fee_per_gas, _actual_priority_fee_per_gas) = match (max_fee_per_gas, max_priority_fee_per_gas, is_transactional) { + // Zero max_fee_per_gas for validated transactional calls exist in XCM -> EVM + // because fees are already withdrawn in the xcm-executor. + (Some(max_fee), _, true) if max_fee.is_zero() => (U256::zero(), U256::zero()), // With no tip, we pay exactly the base_fee (Some(_), None, _) => (base_fee, U256::zero()), // With tip, we include as much of the tip on top of base_fee that we can, never From b0b78f037961836787dd2e03b77d8dcf881f8f1a Mon Sep 17 00:00:00 2001 From: Wei Tang Date: Tue, 25 Oct 2022 14:11:58 +0200 Subject: [PATCH 21/21] Update evm revision (#879) --- Cargo.lock | 8 ++++---- client/rpc/Cargo.toml | 2 +- frame/ethereum/Cargo.toml | 2 +- frame/evm/Cargo.toml | 2 +- frame/evm/test-vector-support/Cargo.toml | 2 +- primitives/evm/Cargo.toml | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c249e9a25e..7a5cc1e469 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1516,7 +1516,7 @@ checksum = "f7531096570974c3a9dcf9e4b8e1cede1ec26cf5046219fb3b9d897503b9be59" [[package]] name = "evm" version = "0.35.0" -source = "git+https://github.com/rust-blockchain/evm?rev=51b8c2ce3104265e1fd5bb0fe5cdfd2e0938239c#51b8c2ce3104265e1fd5bb0fe5cdfd2e0938239c" +source = "git+https://github.com/rust-blockchain/evm?rev=6534c1dd8ad77b53d05032f80e8a5f2de4d37fd2#6534c1dd8ad77b53d05032f80e8a5f2de4d37fd2" dependencies = [ "auto_impl", "environmental", @@ -1536,7 +1536,7 @@ dependencies = [ [[package]] name = "evm-core" version = "0.35.0" -source = "git+https://github.com/rust-blockchain/evm?rev=51b8c2ce3104265e1fd5bb0fe5cdfd2e0938239c#51b8c2ce3104265e1fd5bb0fe5cdfd2e0938239c" +source = "git+https://github.com/rust-blockchain/evm?rev=6534c1dd8ad77b53d05032f80e8a5f2de4d37fd2#6534c1dd8ad77b53d05032f80e8a5f2de4d37fd2" dependencies = [ "parity-scale-codec", "primitive-types", @@ -1547,7 +1547,7 @@ dependencies = [ [[package]] name = "evm-gasometer" version = "0.35.0" -source = "git+https://github.com/rust-blockchain/evm?rev=51b8c2ce3104265e1fd5bb0fe5cdfd2e0938239c#51b8c2ce3104265e1fd5bb0fe5cdfd2e0938239c" +source = "git+https://github.com/rust-blockchain/evm?rev=6534c1dd8ad77b53d05032f80e8a5f2de4d37fd2#6534c1dd8ad77b53d05032f80e8a5f2de4d37fd2" dependencies = [ "environmental", "evm-core", @@ -1558,7 +1558,7 @@ dependencies = [ [[package]] name = "evm-runtime" version = "0.35.0" -source = "git+https://github.com/rust-blockchain/evm?rev=51b8c2ce3104265e1fd5bb0fe5cdfd2e0938239c#51b8c2ce3104265e1fd5bb0fe5cdfd2e0938239c" +source = "git+https://github.com/rust-blockchain/evm?rev=6534c1dd8ad77b53d05032f80e8a5f2de4d37fd2#6534c1dd8ad77b53d05032f80e8a5f2de4d37fd2" dependencies = [ "auto_impl", "environmental", diff --git a/client/rpc/Cargo.toml b/client/rpc/Cargo.toml index 69aa9993d0..052d6e872d 100644 --- a/client/rpc/Cargo.toml +++ b/client/rpc/Cargo.toml @@ -12,7 +12,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] ethereum = { version = "0.12.0", features = ["with-codec"] } -evm = { git = "https://github.com/rust-blockchain/evm", rev = "51b8c2ce3104265e1fd5bb0fe5cdfd2e0938239c" } +evm = { git = "https://github.com/rust-blockchain/evm", rev = "6534c1dd8ad77b53d05032f80e8a5f2de4d37fd2" } futures = "0.3.24" hex = "0.4.3" log = "0.4.17" diff --git a/frame/ethereum/Cargo.toml b/frame/ethereum/Cargo.toml index 3afdc2592f..715db0bc3d 100644 --- a/frame/ethereum/Cargo.toml +++ b/frame/ethereum/Cargo.toml @@ -12,7 +12,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] ethereum = { version = "0.12.0", default-features = false, features = ["with-codec"] } -evm = { git = "https://github.com/rust-blockchain/evm", rev = "51b8c2ce3104265e1fd5bb0fe5cdfd2e0938239c", features = ["with-codec"], default-features = false } +evm = { git = "https://github.com/rust-blockchain/evm", rev = "6534c1dd8ad77b53d05032f80e8a5f2de4d37fd2", features = ["with-codec"], default-features = false } serde = { version = "1.0.144", optional = true } # Parity diff --git a/frame/evm/Cargo.toml b/frame/evm/Cargo.toml index 52ffb54fac..2380a7f46f 100644 --- a/frame/evm/Cargo.toml +++ b/frame/evm/Cargo.toml @@ -13,7 +13,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] environmental = { version = "1.1.3", default-features = false, optional = true } -evm = { git = "https://github.com/rust-blockchain/evm", rev = "51b8c2ce3104265e1fd5bb0fe5cdfd2e0938239c", default-features = false, features = ["with-codec"] } +evm = { git = "https://github.com/rust-blockchain/evm", rev = "6534c1dd8ad77b53d05032f80e8a5f2de4d37fd2", default-features = false, features = ["with-codec"] } hex = { version = "0.4.3", default-features = false, features = ["alloc"] } log = { version = "0.4.17", default-features = false } serde = { version = "1.0.144", optional = true, features = ["derive"] } diff --git a/frame/evm/test-vector-support/Cargo.toml b/frame/evm/test-vector-support/Cargo.toml index 8c17b94f25..c9439a4488 100644 --- a/frame/evm/test-vector-support/Cargo.toml +++ b/frame/evm/test-vector-support/Cargo.toml @@ -8,7 +8,7 @@ description = "Test vector support for EVM pallet." repository = "https://github.com/paritytech/frontier/" [dependencies] -evm = { git = "https://github.com/rust-blockchain/evm", rev = "51b8c2ce3104265e1fd5bb0fe5cdfd2e0938239c", features = ["with-codec"] } +evm = { git = "https://github.com/rust-blockchain/evm", rev = "6534c1dd8ad77b53d05032f80e8a5f2de4d37fd2", features = ["with-codec"] } hex = "0.4.3" serde = { version = "1.0.101", features = ["derive"] } serde_json = "1.0" diff --git a/primitives/evm/Cargo.toml b/primitives/evm/Cargo.toml index aa4a52cc5a..935fe6f08b 100644 --- a/primitives/evm/Cargo.toml +++ b/primitives/evm/Cargo.toml @@ -11,7 +11,7 @@ repository = "https://github.com/paritytech/frontier/" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -evm = { git = "https://github.com/rust-blockchain/evm", rev = "51b8c2ce3104265e1fd5bb0fe5cdfd2e0938239c", default-features = false, features = ["with-codec"] } +evm = { git = "https://github.com/rust-blockchain/evm", rev = "6534c1dd8ad77b53d05032f80e8a5f2de4d37fd2", default-features = false, features = ["with-codec"] } serde = { version = "1.0.144", features = ["derive"], optional = true } # Parity