diff --git a/client/rpc/src/eth/block.rs b/client/rpc/src/eth/block.rs index c9a1f88017..5956829abb 100644 --- a/client/rpc/src/eth/block.rs +++ b/client/rpc/src/eth/block.rs @@ -33,7 +33,7 @@ use fc_rpc_core::types::*; use fp_rpc::EthereumRuntimeRPCApi; use crate::{ - eth::{rich_block_build, Eth, EthConfig}, + eth::{empty_block_from, rich_block_build, Eth, EthConfig}, frontier_backend_client, internal_err, }; @@ -198,7 +198,23 @@ where _ => Ok(None), } } - None => Ok(None), + None => { + if let BlockNumber::Num(block_number) = number { + let eth_block = empty_block_from(block_number.into()); + let eth_hash = + H256::from_slice(keccak_256(&rlp::encode(ð_block.header)).as_slice()); + Ok(Some(rich_block_build( + eth_block, + Default::default(), + Some(eth_hash), + full, + None, + false, + ))) + } else { + Ok(None) + } + } } } diff --git a/client/rpc/src/eth/mod.rs b/client/rpc/src/eth/mod.rs index ed7a1491a1..43097d3c00 100644 --- a/client/rpc/src/eth/mod.rs +++ b/client/rpc/src/eth/mod.rs @@ -473,6 +473,31 @@ fn rich_block_build( } } +fn empty_block_from(number: U256) -> ethereum::BlockV2 { + let ommers = Vec::::new(); + let receipts = Vec::::new(); + let receipts_root = ethereum::util::ordered_trie_root( + receipts.iter().map(ethereum::EnvelopedEncodable::encode), + ); + let logs_bloom = ethereum_types::Bloom::default(); + let partial_header = ethereum::PartialHeader { + parent_hash: H256::default(), + beneficiary: Default::default(), + state_root: Default::default(), + receipts_root, + logs_bloom, + difficulty: U256::zero(), + number, + gas_limit: U256::from(4_000_000), + gas_used: U256::zero(), + timestamp: Default::default(), + extra_data: Vec::new(), + mix_hash: H256::default(), + nonce: H64::default(), + }; + ethereum::Block::new(partial_header, Default::default(), ommers) +} + fn transaction_build( ethereum_transaction: EthereumTransaction, block: Option, diff --git a/docs/package.json b/docs/package.json index 50920a321c..22d1c143d4 100644 --- a/docs/package.json +++ b/docs/package.json @@ -13,6 +13,6 @@ }, "license": "Apache-2.0", "dependencies": { - "vuepress": "^1.9.9" + "vuepress": "^1.9.10" } } diff --git a/docs/yarn.lock b/docs/yarn.lock index e551b16dbd..d2ac02b669 100644 --- a/docs/yarn.lock +++ b/docs/yarn.lock @@ -1184,19 +1184,19 @@ optionalDependencies: prettier "^1.18.2" -"@vuepress/core@1.9.9": - version "1.9.9" - resolved "https://registry.yarnpkg.com/@vuepress/core/-/core-1.9.9.tgz#aa8bc4497fcbb6aab9c1e290944d422edeb20495" - integrity sha512-Ekgu409ZSgvAV9n14F3DaEWtgkwrEicg1nWs0gbxGgUCdREeX/7rwxSfKwWwBjCwfCUKR2L3+6pXGjzxex0t+g== +"@vuepress/core@1.9.10": + version "1.9.10" + resolved "https://registry.yarnpkg.com/@vuepress/core/-/core-1.9.10.tgz#ce17d603a0195ab2b8152f5a33bea274869184a3" + integrity sha512-H9ddo5fSinPb8QYl8OJFbZikMpOW84bm/U3Drzz8CnCXNtpda7CU2wX/XzOhe98G8jp45xhtZRkxOrqzBBAShA== dependencies: "@babel/core" "^7.8.4" "@vue/babel-preset-app" "^4.1.2" - "@vuepress/markdown" "1.9.9" - "@vuepress/markdown-loader" "1.9.9" - "@vuepress/plugin-last-updated" "1.9.9" - "@vuepress/plugin-register-components" "1.9.9" - "@vuepress/shared-utils" "1.9.9" - "@vuepress/types" "1.9.9" + "@vuepress/markdown" "1.9.10" + "@vuepress/markdown-loader" "1.9.10" + "@vuepress/plugin-last-updated" "1.9.10" + "@vuepress/plugin-register-components" "1.9.10" + "@vuepress/shared-utils" "1.9.10" + "@vuepress/types" "1.9.10" autoprefixer "^9.5.1" babel-loader "^8.0.4" bundle-require "2.1.8" @@ -1231,21 +1231,21 @@ webpack-merge "^4.1.2" webpackbar "3.2.0" -"@vuepress/markdown-loader@1.9.9": - version "1.9.9" - resolved "https://registry.yarnpkg.com/@vuepress/markdown-loader/-/markdown-loader-1.9.9.tgz#b44e446a04808b9aef503d32fdcbc1e7fb7afef4" - integrity sha512-nyY+sytuQaDLEIk6Yj9JFUfSQpe9/sz30xQFkGCYqi0lQTRGQM6IcRDgfcTS7b25A0qRlwpDGBfKQiGGMZKSfg== +"@vuepress/markdown-loader@1.9.10": + version "1.9.10" + resolved "https://registry.yarnpkg.com/@vuepress/markdown-loader/-/markdown-loader-1.9.10.tgz#076619a9079d4955bb73b59dc9e474c488d49bb7" + integrity sha512-94BlwKc+lOaN/A5DkyA9KWHvMlMC1sWunAXE3Tv0WYzgYLDs9QqCsx7L5kLkpcOOVVm/8kBJumnXvVBwhqJddw== dependencies: - "@vuepress/markdown" "1.9.9" + "@vuepress/markdown" "1.9.10" loader-utils "^1.1.0" lru-cache "^5.1.1" -"@vuepress/markdown@1.9.9": - version "1.9.9" - resolved "https://registry.yarnpkg.com/@vuepress/markdown/-/markdown-1.9.9.tgz#1f582e6302e91a09491ca7bd0c8bcf9683140e03" - integrity sha512-JzFdBdGe5aoiKSaEgF+h3JLDXNVfWPI5DJWXrIt7rhhkMJesF6HowIznPLdXqukzHfXHcPvo9oQ4o6eT0YmVGA== +"@vuepress/markdown@1.9.10": + version "1.9.10" + resolved "https://registry.yarnpkg.com/@vuepress/markdown/-/markdown-1.9.10.tgz#63df6c6137e2d6bac2d03b5911e4326484761ba7" + integrity sha512-sXTLjeZzH8SQuAL5AEH0hhsMljjNJbzWbBvzaj5yQCCdf+3sp/dJ0kwnBSnQjFPPnzPg5t3tLKGUYHyW0KiKzA== dependencies: - "@vuepress/shared-utils" "1.9.9" + "@vuepress/shared-utils" "1.9.10" markdown-it "^8.4.1" markdown-it-anchor "^5.0.2" markdown-it-chain "^1.3.0" @@ -1253,49 +1253,49 @@ markdown-it-table-of-contents "^0.4.0" prismjs "^1.13.0" -"@vuepress/plugin-active-header-links@1.9.9": - version "1.9.9" - resolved "https://registry.yarnpkg.com/@vuepress/plugin-active-header-links/-/plugin-active-header-links-1.9.9.tgz#fad96c550bea0b204fe16266cff1405e8636c1e1" - integrity sha512-lTnIhbuALjOjFts33jJD8r4ScNBxnZ6MtmePKEwvYlC3J9uvngs1Htpb1JzLEX9QCydt+bhLmZ92bTXn/PdTpg== +"@vuepress/plugin-active-header-links@1.9.10": + version "1.9.10" + resolved "https://registry.yarnpkg.com/@vuepress/plugin-active-header-links/-/plugin-active-header-links-1.9.10.tgz#bcd96ee7c156310de30a9565ab9ca18e72f18a5a" + integrity sha512-2dRr3DE2UBFXhyMtLR3sGTdRyDM8YStuY6AOoQmoSgwy1IHt7PO7ypOuf1akF+1Nv8Q2aISU06q6TExZouu3Mw== dependencies: - "@vuepress/types" "1.9.9" + "@vuepress/types" "1.9.10" lodash.debounce "^4.0.8" -"@vuepress/plugin-last-updated@1.9.9": - version "1.9.9" - resolved "https://registry.yarnpkg.com/@vuepress/plugin-last-updated/-/plugin-last-updated-1.9.9.tgz#a7cb5f39b2793c8d113de08a514c316c26cc38c1" - integrity sha512-MV4csmM0/lye83VtkOc+b8fs0roi7mvE7BmCCOE39Z6t8nv/ZmEPOwKeHD0+hXPT+ZfoATYvDcsYU7uxbdw0Pw== +"@vuepress/plugin-last-updated@1.9.10": + version "1.9.10" + resolved "https://registry.yarnpkg.com/@vuepress/plugin-last-updated/-/plugin-last-updated-1.9.10.tgz#e2564512fe5652be892351cd95c5e611fd11a3be" + integrity sha512-YxzWGF/OfU6WsHSynZFn74NGGp7dY27Bjy9JyyFo8wF5+2V1gpyDjveHKHGKugS/pMXlxfjzhv9E2Wmy9R7Iog== dependencies: - "@vuepress/types" "1.9.9" + "@vuepress/types" "1.9.10" cross-spawn "^6.0.5" -"@vuepress/plugin-nprogress@1.9.9": - version "1.9.9" - resolved "https://registry.yarnpkg.com/@vuepress/plugin-nprogress/-/plugin-nprogress-1.9.9.tgz#4fee4818ddc8ddc6a1778b7f2b74ab784c90915d" - integrity sha512-+3fLxjwTLH8MeU54E7i1ovRu9KzBom2lvSeUsu9B8PuLyrETAqW7Pe1H66awEEALEe0ZnnEU4d7SeVe9ljsLAQ== +"@vuepress/plugin-nprogress@1.9.10": + version "1.9.10" + resolved "https://registry.yarnpkg.com/@vuepress/plugin-nprogress/-/plugin-nprogress-1.9.10.tgz#945142c2db4a2a11942c063d5d0f01bc5d295f49" + integrity sha512-I1kkm6yWUQd7vwiV3lEDVpVP0Lr04K0zlczU502lDUa1RufSZ7vt+mlF5fOM28GqT+pKTEToWmm+VNT/R3qvMQ== dependencies: - "@vuepress/types" "1.9.9" + "@vuepress/types" "1.9.10" nprogress "^0.2.0" -"@vuepress/plugin-register-components@1.9.9": - version "1.9.9" - resolved "https://registry.yarnpkg.com/@vuepress/plugin-register-components/-/plugin-register-components-1.9.9.tgz#95be133d6ef33c03f410caae8eb1fabdf27a7999" - integrity sha512-tddnAiSmJsIWWPzE7TcbGU8xzndXf4a8i4BfIev2QzSUnIOQFZDGXUAsCkw4/f9N9UFxQSObjFPzTeUUxb7EvA== +"@vuepress/plugin-register-components@1.9.10": + version "1.9.10" + resolved "https://registry.yarnpkg.com/@vuepress/plugin-register-components/-/plugin-register-components-1.9.10.tgz#3f8fd91acefec32b115d4dce89b14863cbe29212" + integrity sha512-sgdJ5OydTPZAoTkselpvVP3Xsd6bfZ0FpaxOTinal0gJ99h49lvLu9bvzMx13rdGRFO/kRXn0qQQpwKTAfTPqA== dependencies: - "@vuepress/shared-utils" "1.9.9" - "@vuepress/types" "1.9.9" + "@vuepress/shared-utils" "1.9.10" + "@vuepress/types" "1.9.10" -"@vuepress/plugin-search@1.9.9": - version "1.9.9" - resolved "https://registry.yarnpkg.com/@vuepress/plugin-search/-/plugin-search-1.9.9.tgz#d30804b86f9b7f54b3db0b987a288433be3cfd7b" - integrity sha512-W/FE+YHoXDD4qk2wu5yRMkti271TA4y+7UBMrmCavvVAGrLIRnaZfswRUgIiDlEthBc+Pn8/As/Dy1jFTLBa9A== +"@vuepress/plugin-search@1.9.10": + version "1.9.10" + resolved "https://registry.yarnpkg.com/@vuepress/plugin-search/-/plugin-search-1.9.10.tgz#313a504020d60a2f694b27a8b6457ee99b4c71e7" + integrity sha512-bn2XJikaRgQZXvu8upCjOWrxbLHIRTqnJ3w7G0mo6jCYWGVsHNo6XhVpqylpLR2PWnHT/ImO2bGo38/5Bag/tQ== dependencies: - "@vuepress/types" "1.9.9" + "@vuepress/types" "1.9.10" -"@vuepress/shared-utils@1.9.9": - version "1.9.9" - resolved "https://registry.yarnpkg.com/@vuepress/shared-utils/-/shared-utils-1.9.9.tgz#f6561ec2264d54e4e459d17678766ffe09f4bfc6" - integrity sha512-qhk/7QF5LgMEXhEB1hlqreGFgkz4p2pmaBBNFxnAnYmSwmyO+u/oFOpZLI16QRx9Wg6ekR2ENmByQLxV7y4lJg== +"@vuepress/shared-utils@1.9.10": + version "1.9.10" + resolved "https://registry.yarnpkg.com/@vuepress/shared-utils/-/shared-utils-1.9.10.tgz#45aae7fcf07a2067fb340c71e5bd96837b48dfee" + integrity sha512-M9A3DocPih+V8dKK2Zg9FJQ/f3JZrYsdaM/vQ9F48l8bPlzxw5NvqXIYMK4kKcGEyerQNTWCudoCpLL5uiU0hg== dependencies: chalk "^2.3.2" escape-html "^1.0.3" @@ -1322,15 +1322,15 @@ toml "^3.0.0" upath "^1.1.0" -"@vuepress/theme-default@1.9.9": - version "1.9.9" - resolved "https://registry.yarnpkg.com/@vuepress/theme-default/-/theme-default-1.9.9.tgz#26f1965e1204445fa617308d3b06f134baab4936" - integrity sha512-de0FiOwM/h3rFTBSZK0NNBB117lA/e3IHusU7Xm2XeZRiZ/EE3yvbWclZnbbRNt3YjDMmrWXEW/kBTBxfiMuWQ== +"@vuepress/theme-default@1.9.10": + version "1.9.10" + resolved "https://registry.yarnpkg.com/@vuepress/theme-default/-/theme-default-1.9.10.tgz#6e916e2164ab3d9cc9567610e4ada9c3a568f206" + integrity sha512-XnXn9t+pYCIhWi3cZXJlighuy93FFm5yXdISAAlFlcNkshuGtqamkjacHV8q/QZMfOhSIs6wX7Hj88u2IsT5mw== dependencies: - "@vuepress/plugin-active-header-links" "1.9.9" - "@vuepress/plugin-nprogress" "1.9.9" - "@vuepress/plugin-search" "1.9.9" - "@vuepress/types" "1.9.9" + "@vuepress/plugin-active-header-links" "1.9.10" + "@vuepress/plugin-nprogress" "1.9.10" + "@vuepress/plugin-search" "1.9.10" + "@vuepress/types" "1.9.10" docsearch.js "^2.5.2" lodash "^4.17.15" stylus "^0.54.8" @@ -1338,10 +1338,10 @@ vuepress-plugin-container "^2.0.2" vuepress-plugin-smooth-scroll "^0.0.3" -"@vuepress/types@1.9.9": - version "1.9.9" - resolved "https://registry.yarnpkg.com/@vuepress/types/-/types-1.9.9.tgz#7c21e4c91c13e58e2ff303ded9ad7425805cb07d" - integrity sha512-ukGW49ILzLhIc7CltHMr+BeIjWKloJNN1mrvbDz3beycp9b9kgH+DXNdRIK9QCKr4fJsy7x08vNMwZr9Nq/PTQ== +"@vuepress/types@1.9.10": + version "1.9.10" + resolved "https://registry.yarnpkg.com/@vuepress/types/-/types-1.9.10.tgz#5b8d112a0d7dbaffce1e5d39b66754412c83ecc6" + integrity sha512-TDNQn4og85onmBpLTTXXmncW3rUnYGr2MkuI8OIFJZetDNM49t1WbjNVlrT+kx7C6qXi6okDQgrHGYXajHZWfg== dependencies: "@types/markdown-it" "^10.0.0" "@types/webpack-dev-server" "^3" @@ -7936,14 +7936,14 @@ vuepress-plugin-smooth-scroll@^0.0.3: dependencies: smoothscroll-polyfill "^0.4.3" -vuepress@^1.9.9: - version "1.9.9" - resolved "https://registry.yarnpkg.com/vuepress/-/vuepress-1.9.9.tgz#75b313f48a21b2eeb435cad52333f26b3b8a7404" - integrity sha512-CU94W3EdWaCavGx2VSvQJMI/hyv+m/YMdrvJJw67EVfmmJJDb1iTGrilDgLd0qsyrXzBy0Ru9Qi6rkf4IwcOTg== +vuepress@^1.9.10: + version "1.9.10" + resolved "https://registry.yarnpkg.com/vuepress/-/vuepress-1.9.10.tgz#14700fccd85bc56c810cf367ecc797fcbecc7c0f" + integrity sha512-UnGm9vjQvG918SZVNvgiUlNimLqawdYPq0aPRXDpEB1VksvqegVFy/GKdA8ShXJaEpOMPSt7YD4uK21jaMs3kA== dependencies: - "@vuepress/core" "1.9.9" - "@vuepress/theme-default" "1.9.9" - "@vuepress/types" "1.9.9" + "@vuepress/core" "1.9.10" + "@vuepress/theme-default" "1.9.10" + "@vuepress/types" "1.9.10" cac "^6.5.6" envinfo "^7.2.0" opencollective-postinstall "^2.0.2" diff --git a/frame/ethereum/src/lib.rs b/frame/ethereum/src/lib.rs index e667341c92..859be26891 100644 --- a/frame/ethereum/src/lib.rs +++ b/frame/ethereum/src/lib.rs @@ -42,7 +42,9 @@ use fp_evm::{ use fp_storage::{EthereumStorageSchema, PALLET_ETHEREUM_SCHEMA}; use frame_support::{ codec::{Decode, Encode, MaxEncodedLen}, - dispatch::{DispatchInfo, DispatchResultWithPostInfo, Pays, PostDispatchInfo}, + dispatch::{ + DispatchErrorWithPostInfo, DispatchInfo, DispatchResultWithPostInfo, Pays, PostDispatchInfo, + }, scale_info::TypeInfo, traits::{EnsureOrigin, Get, PalletInfoAccess, Time}, weights::Weight, @@ -55,7 +57,7 @@ use sp_runtime::{ transaction_validity::{ InvalidTransaction, TransactionValidity, TransactionValidityError, ValidTransactionBuilder, }, - DispatchErrorWithPostInfo, RuntimeDebug, SaturatedConversion, + RuntimeDebug, SaturatedConversion, }; use sp_std::{marker::PhantomData, prelude::*}; @@ -241,7 +243,7 @@ pub mod pallet { Self::validate_transaction_in_block(source, &transaction).expect( "pre-block transaction verification failed; the block cannot be built", ); - let r = Self::apply_validated_transaction(source, transaction) + let (r, _) = Self::apply_validated_transaction(source, transaction) .expect("pre-block apply transaction failed; the block cannot be built"); weight = weight.saturating_add(r.actual_weight.unwrap_or_default()); @@ -290,7 +292,7 @@ pub mod pallet { "pre log already exists; block is invalid", ); - Self::apply_validated_transaction(source, transaction) + Self::apply_validated_transaction(source, transaction).map(|(post_info, _)| post_info) } } @@ -317,7 +319,7 @@ pub mod pallet { /// Current building block's transactions and receipts. #[pallet::storage] - pub(super) type Pending = + pub type Pending = StorageValue<_, Vec<(Transaction, TransactionStatus, Receipt)>, ValueQuery>; /// The current Ethereum block. @@ -558,14 +560,14 @@ impl Pallet { fn apply_validated_transaction( source: H160, transaction: Transaction, - ) -> DispatchResultWithPostInfo { + ) -> Result<(PostDispatchInfo, CallOrCreateInfo), DispatchErrorWithPostInfo> { let (to, _, info) = Self::execute(source, &transaction, None)?; let pending = Pending::::get(); let transaction_hash = transaction.hash(); let transaction_index = pending.len() as u32; - let (reason, status, weight_info, used_gas, dest, extra_data) = match info { + let (reason, status, weight_info, used_gas, dest, extra_data) = match info.clone() { CallOrCreateInfo::Call(info) => ( info.exit_reason.clone(), TransactionStatus { @@ -680,21 +682,24 @@ impl Pallet { extra_data, }); - Ok(PostDispatchInfo { - actual_weight: { - let mut gas_to_weight = T::GasWeightMapping::gas_to_weight( - used_gas.standard.unique_saturated_into(), - true, - ); - if let Some(weight_info) = weight_info { - if let Some(proof_size_usage) = weight_info.proof_size_usage { - *gas_to_weight.proof_size_mut() = proof_size_usage; + Ok(( + (PostDispatchInfo { + actual_weight: { + let mut gas_to_weight = T::GasWeightMapping::gas_to_weight( + used_gas.standard.unique_saturated_into(), + true, + ); + if let Some(weight_info) = weight_info { + if let Some(proof_size_usage) = weight_info.proof_size_usage { + *gas_to_weight.proof_size_mut() = proof_size_usage; + } } - } - Some(gas_to_weight) - }, - pays_fee: Pays::No, - }) + Some(gas_to_weight) + }, + pays_fee: Pays::No, + }), + info, + )) } /// Get current block hash @@ -707,10 +712,7 @@ impl Pallet { from: H160, transaction: &Transaction, config: Option, - ) -> Result< - (Option, Option, CallOrCreateInfo), - DispatchErrorWithPostInfo, - > { + ) -> Result<(Option, Option, CallOrCreateInfo), DispatchErrorWithPostInfo> { let ( input, value, @@ -963,7 +965,10 @@ impl Pallet { pub struct ValidatedTransaction(PhantomData); impl ValidatedTransactionT for ValidatedTransaction { - fn apply(source: H160, transaction: Transaction) -> DispatchResultWithPostInfo { + fn apply( + source: H160, + transaction: Transaction, + ) -> Result<(PostDispatchInfo, CallOrCreateInfo), DispatchErrorWithPostInfo> { Pallet::::apply_validated_transaction(source, transaction) } } diff --git a/primitives/consensus/src/lib.rs b/primitives/consensus/src/lib.rs index e9643d8eee..98c9a47217 100644 --- a/primitives/consensus/src/lib.rs +++ b/primitives/consensus/src/lib.rs @@ -130,5 +130,8 @@ pub fn find_log(digest: &Digest) -> Result { } pub fn ensure_log(digest: &Digest) -> Result<(), FindLogError> { - find_log(digest).map(|_log| ()) + match find_log(digest) { + Err(FindLogError::MultipleLogs) => Err(FindLogError::MultipleLogs), + _ => Ok(()), + } } diff --git a/primitives/ethereum/src/lib.rs b/primitives/ethereum/src/lib.rs index 03d7092ea3..69bcec62bc 100644 --- a/primitives/ethereum/src/lib.rs +++ b/primitives/ethereum/src/lib.rs @@ -23,9 +23,10 @@ pub use ethereum::{ TransactionAction, TransactionV2 as Transaction, }; use ethereum_types::{H160, H256, U256}; -use fp_evm::CheckEvmTransactionInput; +use fp_evm::{CallOrCreateInfo, CheckEvmTransactionInput}; +use frame_support::dispatch::{DispatchErrorWithPostInfo, PostDispatchInfo}; use scale_codec::{Decode, Encode}; -use sp_std::vec::Vec; +use sp_std::prelude::*; #[repr(u8)] #[derive(num_enum::FromPrimitive, num_enum::IntoPrimitive)] @@ -44,7 +45,7 @@ pub trait ValidatedTransaction { fn apply( source: H160, transaction: Transaction, - ) -> frame_support::dispatch::DispatchResultWithPostInfo; + ) -> Result<(PostDispatchInfo, CallOrCreateInfo), DispatchErrorWithPostInfo>; } #[derive(Clone, Debug, Eq, PartialEq, Encode, Decode)]