Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into make-test-stable
Browse files Browse the repository at this point in the history
  • Loading branch information
koushiro committed May 9, 2022
2 parents a31226a + 142058c commit d432223
Show file tree
Hide file tree
Showing 10 changed files with 495 additions and 391 deletions.
2 changes: 2 additions & 0 deletions client/rpc-core/src/types/fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ pub struct FeeHistory {
}

pub type FeeHistoryCache = Arc<Mutex<BTreeMap<u64, FeeHistoryCacheItem>>>;
/// Maximum fee history cache size.
pub type FeeHistoryCacheLimit = u64;

pub struct FeeHistoryCacheItem {
pub base_fee: u64,
Expand Down
2 changes: 1 addition & 1 deletion client/rpc-core/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub use self::{
block_number::BlockNumber,
bytes::Bytes,
call_request::CallRequest,
fee::{FeeHistory, FeeHistoryCache, FeeHistoryCacheItem},
fee::{FeeHistory, FeeHistoryCache, FeeHistoryCacheItem, FeeHistoryCacheLimit},
filter::{
Filter, FilterAddress, FilterChanges, FilterPool, FilterPoolItem, FilterType,
FilteredParams, Topic, VariadicValue,
Expand Down
2 changes: 1 addition & 1 deletion client/rpc/src/eth/fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ where
let best_number =
UniqueSaturatedInto::<u64>::unique_saturated_into(self.client.info().best_number);
// Only support in-cache queries.
if lowest < best_number.saturating_sub(self.fee_history_limit) {
if lowest < best_number.saturating_sub(self.fee_history_cache_limit) {
return Err(internal_err(format!("Block range out of bounds.")));
}
if let Ok(fee_history_cache) = &self.fee_history_cache.lock() {
Expand Down
6 changes: 3 additions & 3 deletions client/rpc/src/eth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ pub struct EthApi<B: BlockT, C, P, CT, BE, H: ExHashT, A: ChainApi> {
overrides: Arc<OverrideHandle<B>>,
backend: Arc<fc_db::Backend<B>>,
block_data_cache: Arc<EthBlockDataCache<B>>,
fee_history_limit: u64,
fee_history_cache: FeeHistoryCache,
fee_history_cache_limit: FeeHistoryCacheLimit,
_marker: PhantomData<(B, BE)>,
}

Expand All @@ -85,8 +85,8 @@ impl<B: BlockT, C, P, CT, BE, H: ExHashT, A: ChainApi> EthApi<B, C, P, CT, BE, H
backend: Arc<fc_db::Backend<B>>,
is_authority: bool,
block_data_cache: Arc<EthBlockDataCache<B>>,
fee_history_limit: u64,
fee_history_cache: FeeHistoryCache,
fee_history_cache_limit: FeeHistoryCacheLimit,
) -> Self {
Self {
client,
Expand All @@ -99,8 +99,8 @@ impl<B: BlockT, C, P, CT, BE, H: ExHashT, A: ChainApi> EthApi<B, C, P, CT, BE, H
overrides,
backend,
block_data_cache,
fee_history_limit,
fee_history_cache,
fee_history_cache_limit,
_marker: PhantomData,
}
}
Expand Down
21 changes: 5 additions & 16 deletions frame/evm/test-vector-support/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,9 @@ repository = "https://github.com/paritytech/frontier/"
description = "Test vector support for EVM pallet."

[dependencies]
evm = { version = "0.35.0", default-features = false, features = ["with-codec"] }
hex = { version = "0.4.0", optional = true }
serde = { version = "1.0.101", features = ["derive"], optional = true }
serde_json = { version = "1.0", optional = true }
evm = { version = "0.35.0", features = ["with-codec"] }
hex = "0.4.0"
serde = { version = "1.0.101", features = ["derive"] }
serde_json = "1.0"

fp-evm = { version = "3.0.0-dev", path = "../../../primitives/evm", default-features = false }

[features]
default = ["std"]
std = [
"evm/std",
"hex",
"serde",
"serde_json",

"fp-evm/std",
]
fp-evm = { version = "3.0.0-dev", path = "../../../primitives/evm" }
11 changes: 2 additions & 9 deletions frame/evm/test-vector-support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,8 @@
use evm::{Context, ExitSucceed};
use fp_evm::Precompile;

#[cfg(feature = "std")]
use serde::Deserialize;

#[allow(non_snake_case)]
#[derive(Deserialize, Debug)]
#[cfg(feature = "std")]
#[derive(Debug, serde::Deserialize)]
struct EthConsensusTest {
Input: String,
Expected: String,
Expand All @@ -34,11 +30,8 @@ struct EthConsensusTest {
/// Tests a precompile against the ethereum consensus tests defined in the given file at filepath.
/// The file is expected to be in JSON format and contain an array of test vectors, where each
/// vector can be deserialized into an "EthConsensusTest".
#[cfg(feature = "std")]
pub fn test_precompile_test_vectors<P: Precompile>(filepath: &str) -> Result<(), String> {
use std::fs;

let data = fs::read_to_string(&filepath).expect("Failed to read blake2F.json");
let data = std::fs::read_to_string(&filepath).expect("Failed to read blake2F.json");

let tests: Vec<EthConsensusTest> = serde_json::from_str(&data).expect("expected json array");

Expand Down
2 changes: 1 addition & 1 deletion shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ let
rev = "4a07484cf0e49047f82d83fd119acffbad3b235f";
});
nixpkgs = import <nixpkgs> { overlays = [ mozillaOverlay ]; };
rust-nightly = with nixpkgs; ((rustChannelOf { date = "2021-07-06"; channel = "nightly"; }).rust.override {
rust-nightly = with nixpkgs; ((rustChannelOf { date = "2022-05-02"; channel = "nightly"; }).rust.override {
extensions = [ "rust-src" ];
targets = [ "wasm32-unknown-unknown" ];
});
Expand Down
14 changes: 10 additions & 4 deletions template/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ sc-basic-authorship = { version = "0.10.0-dev", git = "https://github.com/parity
sc-cli = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate", branch = "master", features = ["wasmtime"] }
sc-client-api = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "master" }
sc-consensus = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate", branch = "master" }
sc-consensus-aura = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate", branch = "master" }
sc-consensus-manual-seal = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate", branch = "master" }
sc-consensus-aura = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate", branch = "master", optional = true }
sc-consensus-manual-seal = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate", branch = "master", optional = true }
sc-executor = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate", branch = "master", features = ["wasmtime"] }
sc-finality-grandpa = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate", branch = "master" }
sc-keystore = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "master" }
Expand Down Expand Up @@ -76,8 +76,14 @@ substrate-build-script-utils = { version = "3.0.0", git = "https://github.com/pa

[features]
default = ["aura"]
aura = ["frontier-template-runtime/aura"]
manual-seal = ["frontier-template-runtime/manual-seal"]
aura = [
"sc-consensus-aura",
"frontier-template-runtime/aura",
]
manual-seal = [
"sc-consensus-manual-seal",
"frontier-template-runtime/manual-seal",
]
rpc_binary_search_estimate = ["fc-rpc/rpc_binary_search_estimate"]
runtime-benchmarks = [
"frontier-template-runtime/runtime-benchmarks",
Expand Down
54 changes: 29 additions & 25 deletions template/node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,13 @@
use std::{collections::BTreeMap, sync::Arc};

use fc_rpc::{
EthBlockDataCache, OverrideHandle, RuntimeApiStorageOverride, SchemaV1Override,
SchemaV2Override, SchemaV3Override, StorageOverride,
};
use fc_rpc_core::types::{FeeHistoryCache, FilterPool};
use fp_storage::EthereumStorageSchema;
use frontier_template_runtime::{opaque::Block, AccountId, Balance, Hash, Index};
use jsonrpc_pubsub::manager::SubscriptionManager;
// Substrate
use sc_client_api::{
backend::{AuxStore, Backend, StateBackend, StorageProvider},
client::BlockchainEvents,
};
#[cfg(feature = "manual-seal")]
use sc_consensus_manual_seal::rpc::{ManualSeal, ManualSealApi};
use sc_network::NetworkService;
use sc_rpc::SubscriptionTaskExecutor;
Expand All @@ -24,6 +19,15 @@ use sp_api::ProvideRuntimeApi;
use sp_block_builder::BlockBuilder;
use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};
use sp_runtime::traits::BlakeTwo256;
// Frontier
use fc_rpc::{
EthBlockDataCache, OverrideHandle, RuntimeApiStorageOverride, SchemaV1Override,
SchemaV2Override, SchemaV3Override, StorageOverride,
};
use fc_rpc_core::types::{FeeHistoryCache, FeeHistoryCacheLimit, FilterPool};
use fp_storage::EthereumStorageSchema;
// Runtime
use frontier_template_runtime::{opaque::Block, AccountId, Balance, Hash, Index};

/// Full client dependencies.
pub struct FullDeps<C, P, A: ChainApi> {
Expand All @@ -47,17 +51,18 @@ pub struct FullDeps<C, P, A: ChainApi> {
pub backend: Arc<fc_db::Backend<Block>>,
/// Maximum number of logs in a query.
pub max_past_logs: u32,
/// Maximum fee history cache size.
pub fee_history_limit: u64,
/// Fee history cache.
pub fee_history_cache: FeeHistoryCache,
/// Manual seal command sink
pub command_sink:
Option<futures::channel::mpsc::Sender<sc_consensus_manual_seal::rpc::EngineCommand<Hash>>>,
/// Maximum fee history cache size.
pub fee_history_cache_limit: FeeHistoryCacheLimit,
/// Ethereum data access overrides.
pub overrides: Arc<OverrideHandle<Block>>,
/// Cache for Ethereum block data.
pub block_data_cache: Arc<EthBlockDataCache<Block>>,
/// Manual seal command sink
#[cfg(feature = "manual-seal")]
pub command_sink:
Option<futures::channel::mpsc::Sender<sc_consensus_manual_seal::rpc::EngineCommand<Hash>>>,
}

pub fn overrides_handle<C, BE>(client: Arc<C>) -> Arc<OverrideHandle<Block>>
Expand Down Expand Up @@ -129,16 +134,17 @@ where
graph,
deny_unsafe,
is_authority,
enable_dev_signer,
network,
filter_pool,
command_sink,
backend,
max_past_logs,
fee_history_limit,
fee_history_cache,
enable_dev_signer,
fee_history_cache_limit,
overrides,
block_data_cache,
#[cfg(feature = "manual-seal")]
command_sink,
} = deps;

io.extend_with(SystemApi::to_delegate(FullSystem::new(
Expand Down Expand Up @@ -166,8 +172,8 @@ where
backend.clone(),
is_authority,
block_data_cache.clone(),
fee_history_limit,
fee_history_cache,
fee_history_cache_limit,
)));

if let Some(filter_pool) = filter_pool {
Expand Down Expand Up @@ -201,15 +207,13 @@ where
overrides,
)));

match command_sink {
Some(command_sink) => {
io.extend_with(
// We provide the rpc handler with the sending end of the channel to allow the rpc
// send EngineCommands to the background block authorship task.
ManualSealApi::to_delegate(ManualSeal::new(command_sink)),
);
}
_ => {}
#[cfg(feature = "manual-seal")]
if let Some(command_sink) = command_sink {
io.extend_with(
// We provide the rpc handler with the sending end of the channel to allow the rpc
// send EngineCommands to the background block authorship task.
ManualSealApi::to_delegate(ManualSeal::new(command_sink)),
);
}

io
Expand Down
Loading

0 comments on commit d432223

Please sign in to comment.