Skip to content

Commit

Permalink
Pre v0.6 dependency updates (#215)
Browse files Browse the repository at this point in the history
* Bump polkadot and substrate versions

* cumulus-parachain-upgrade renamed to cumulus-parachain-system

* Update frontier branch v0.5-hotfixes -> v0.6-moonbeam

* Resolve parity-util-mem dependency conflicts

* Revert "cumulus-parachain-upgrade renamed to cumulus-parachain-system"

This reverts commit 15c6218.

The change this was meant to addressed isn't introduced in Cumulus until
commit b5f6580.

* Don't specify frontier commit

* Cargo wants to play rough

* Bump cumulus and polkadot versions

* Reintroduce upgrade -> system renaming

* Bump parity-scale-codec and related intermediate dependencies

* Remove deadbeef precompile

* Make it compile

* Revert substrate 9659509 -> 93b231e

* Reflect upstream changes in Cumulus

* Don't specify git rev in toml file

* Properly specify BlockGasLimit

Co-authored-by: Joshy Orndorff <JoshOrndorff@users.noreply.github.com>

* Add EthFilterApi

* Add filter pool maintenance task

* Add filter pool test

* Specify MAXIMUM_BLOCK_WEIGHT

* Update Cargo.lock

* Refactor logger initialization

* Hard tabs > spaces

* Simplify gas_to_weight impl

* Spaces > hard tabs (for javascript)

* Update Cargo.lock

* Import the whole test file from frontier...

* Oops, actually add test

* rustfmt

* Chop contract data into smaller chunks

* 100 chars max line length

* Apply prettier

* Update Cargo.lock files to make standalone build

* Add filter_pool and remove telemetry_on_connect from standalone

* Undo earlier testing changes

* Chop lines at 100 chars

* Missed one

* Point to notlesh fork of ethereum

* Bump target gas to 12.5M per block

* Modify test to reflect updated gas limit

* s/frontier/moonbeam/

* s/context.web3/context.polkadotApi/

* Update Cargo.lock

* Upstream changes for newly merged code

* Add FilterPool to dev_service

* Revert map_err() change

* Fixes node command error returned

* Format command.rs

* Reduce max ethereum txn gas and bump GAS_PER_SECOND to target 12.5M / sec

* Update comment about gas limits

* s/Upgrade/System/

* Update gas constants in test-gas.ts

* Update gas values in test based on observed values

* Update gasLimit in tests; comment about gas calculation

* Add EthFilterApi maintenance task to dev-service

* Pass graph to EthApi

* rustfmt

* kill processes on exit and sigint

* retyped events and updated api

* Reflect changes to event ordering in test-balance.ts

* s/upgrade/system/ AGAIN

* Fix compiler warnings

* log--

* Bump GAS_PER_SECOND to 40M

* Chop long line

* Update gasLimit expectations in tests

Co-authored-by: Joshy Orndorff <JoshOrndorff@users.noreply.github.com>
Co-authored-by: Crystalin <alan.sapede@gmail.com>
Co-authored-by: tgmichel <telmo@purestake.com>
Co-authored-by: joelamouche <estienne.antoine@gmail.com>
  • Loading branch information
5 people authored Feb 9, 2021
1 parent c330ce5 commit 5308f49
Show file tree
Hide file tree
Showing 32 changed files with 5,534 additions and 768 deletions.
1,209 changes: 642 additions & 567 deletions Cargo.lock

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions client/rpc-core/txpool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ license = 'GPL-3.0-only'
repository = 'https://github.com/PureStake/moonbeam/'

[dependencies]
ethereum = { git = "https://github.com/rust-blockchain/ethereum", branch = "master", features = ["with-codec"] }
ethereum-types = "0.10.0"
# ethereum = { git = "https://github.com/rust-blockchain/ethereum", branch = "master", features = ["with-codec"] }
ethereum = { git = "https://github.com/notlesh/ethereum", branch = "notlesh-moonbeam-v0.6", features = ["with-codec"] }
ethereum-types = "0.11.0"
jsonrpc-core = "15.0.0"
jsonrpc-core-client = "14.0.3"
jsonrpc-derive = "14.0.3"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"

fc-rpc-core = { git = "https://github.com/purestake/frontier", branch = "v0.5-hotfixes" }
fc-rpc-core = { git = "https://github.com/purestake/frontier", branch = "v0.6-moonbeam" }
5 changes: 3 additions & 2 deletions client/rpc/txpool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ repository = 'https://github.com/PureStake/moonbeam/'
[dependencies]
sha3 = "0.8"
jsonrpc-core = "15.0.0"
ethereum-types = "0.10.0"
ethereum = { git = "https://github.com/rust-blockchain/ethereum", branch = "master", features = ["with-codec"] }
ethereum-types = "0.11.0"
# ethereum = { git = "https://github.com/rust-blockchain/ethereum", branch = "master", features = ["with-codec"] }
ethereum = { git = "https://github.com/notlesh/ethereum", branch = "notlesh-moonbeam-v0.6", features = ["with-codec"] }
moonbeam-rpc-core-txpool = { path = "../../rpc-core/txpool" }
sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-api = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
Expand Down
18 changes: 9 additions & 9 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ futures = { version = "0.3.1", features = ["compat"] }
log = '0.4.8'
parking_lot = '0.9.0'
trie-root = '0.15.2'
parity-scale-codec = '1.0.0'
parity-scale-codec = '2.0.0'
structopt = "0.3"
ansi_term = "0.12.1"
serde = { version = "1.0.101", features = ["derive"] }
Expand Down Expand Up @@ -48,6 +48,7 @@ sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "mas
sc-client-db = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-executor = { git = "https://github.com/paritytech/substrate", branch = "master", features = ["wasmtime"] }
sc-service = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-telemetry = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-network = { git = "https://github.com/paritytech/substrate", branch = "master" }
Expand All @@ -67,15 +68,14 @@ pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/substrat
sp-block-builder = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-consensus-manual-seal = { git = "https://github.com/paritytech/substrate", branch = "master" }

# Frontier Dependencies
evm = { package = "pallet-evm", git = "https://github.com/purestake/frontier", branch = "v0.5-hotfixes" }
ethereum = { package = "pallet-ethereum", git = "https://github.com/purestake/frontier", branch = "v0.5-hotfixes" }
evm = { package = "pallet-evm", git = "https://github.com/purestake/frontier", branch = "v0.6-moonbeam" }
ethereum = { package = "pallet-ethereum", git = "https://github.com/purestake/frontier", branch = "v0.6-moonbeam" }

fc-consensus = { git = "https://github.com/purestake/frontier", branch = "v0.5-hotfixes" }
fp-consensus = { git = "https://github.com/purestake/frontier", branch = "v0.5-hotfixes" }
fc-rpc-core = { git = "https://github.com/purestake/frontier", branch = "v0.5-hotfixes" }
fc-rpc = { git = "https://github.com/purestake/frontier", branch = "v0.5-hotfixes" }
fp-rpc = { git = "https://github.com/purestake/frontier", branch = "v0.5-hotfixes" }
fc-consensus = { git = "https://github.com/purestake/frontier", branch = "v0.6-moonbeam" }
fp-consensus = { git = "https://github.com/purestake/frontier", branch = "v0.6-moonbeam" }
fc-rpc-core = { git = "https://github.com/purestake/frontier", branch = "v0.6-moonbeam" }
fc-rpc = { git = "https://github.com/purestake/frontier", branch = "v0.6-moonbeam" }
fp-rpc = { git = "https://github.com/purestake/frontier", branch = "v0.6-moonbeam" }

# Cumulus dependencies
cumulus-consensus = { git = "https://github.com/paritytech/cumulus", branch = "master" }
Expand Down
137 changes: 76 additions & 61 deletions node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ use parity_scale_codec::Encode;
use polkadot_parachain::primitives::AccountIdConversion;
use polkadot_service::RococoChainSpec;
use sc_cli::{
ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, InitLoggerParams,
KeystoreParams, NetworkParams, Result, RuntimeVersion, SharedParams, SubstrateCli,
ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams,
NetworkParams, Result, RuntimeVersion, SharedParams, SubstrateCli,
};
use sc_service::{
config::{BasePath, PrometheusConfig},
Expand Down Expand Up @@ -231,10 +231,9 @@ pub fn run() -> Result<()> {
})
}
Some(Subcommand::ExportGenesisState(params)) => {
sc_cli::init_logger(InitLoggerParams {
tracing_receiver: sc_tracing::TracingReceiver::Log,
..Default::default()
})?;
let mut builder = sc_cli::LoggerBuilder::new("");
builder.with_profiling(sc_tracing::TracingReceiver::Log, "");
let _ = builder.init();

let block: Block = generate_genesis_block(&load_spec(
&params.chain.clone().unwrap_or_default(),
Expand All @@ -256,10 +255,9 @@ pub fn run() -> Result<()> {
Ok(())
}
Some(Subcommand::ExportGenesisWasm(params)) => {
sc_cli::init_logger(InitLoggerParams {
tracing_receiver: sc_tracing::TracingReceiver::Log,
..Default::default()
})?;
let mut builder = sc_cli::LoggerBuilder::new("");
builder.with_profiling(sc_tracing::TracingReceiver::Log, "");
let _ = builder.init();

let raw_wasm_blob =
extract_genesis_wasm(&cli.load_spec(&params.chain.clone().unwrap_or_default())?)?;
Expand All @@ -285,58 +283,75 @@ pub fn run() -> Result<()> {
return Err("Collator nodes must specify an author account id".into());
}

runner.run_node_until_exit(|config| async move {
// If this is a --dev node, start up manual or instant seal.
// Otherwise continue with the normal parachain node.
if cli.run.base.shared_params.dev {
// If no author id was supplied, use the one that is staked at genesis
let author_id = author_id.or_else(|| {
Some(
AccountId::from_str("6Be02d1d3665660d22FF9624b7BE0551ee1Ac91b")
.expect("Gerald is a valid account"),
)
});

return crate::dev_service::new_full(config, cli.run.sealing, author_id);
}

let key = sp_core::Pair::generate().0;

let extension = chain_spec::Extensions::try_get(&*config.chain_spec);
let relay_chain_id = extension.map(|e| e.relay_chain.clone());
let para_id = extension.map(|e| e.para_id);

let polkadot_cli = RelayChainCli::new(
config.base_path.as_ref().map(|x| x.path().join("polkadot")),
relay_chain_id,
[RelayChainCli::executable_name()]
.iter()
.chain(cli.relaychain_args.iter()),
);

let id = ParaId::from(cli.run.parachain_id.or(para_id).unwrap_or(1000));

let parachain_account =
AccountIdConversion::<polkadot_primitives::v0::AccountId>::into_account(&id);

let block: Block =
generate_genesis_block(&config.chain_spec).map_err(|e| format!("{:?}", e))?;
let genesis_state = format!("0x{:?}", HexDisplay::from(&block.header().encode()));

let task_executor = config.task_executor.clone();
let polkadot_config =
SubstrateCli::create_configuration(&polkadot_cli, &polkadot_cli, task_executor)
.map_err(|err| format!("Relay chain argument error: {}", err))?;

info!("Parachain id: {:?}", id);
info!("Parachain Account: {}", parachain_account);
info!("Parachain genesis state: {}", genesis_state);
info!("Is collating: {}", if collator { "yes" } else { "no" });

crate::service::start_node(config, key, author_id, polkadot_config, id, collator)
runner
.run_node_until_exit(|config| async move {
// If this is a --dev node, start up manual or instant seal.
// Otherwise continue with the normal parachain node.
if cli.run.base.shared_params.dev {
// If no author id was supplied, use the one that is staked at genesis
let author_id = author_id.or_else(|| {
Some(
AccountId::from_str("6Be02d1d3665660d22FF9624b7BE0551ee1Ac91b")
.expect("Gerald is a valid account"),
)
});

return crate::dev_service::new_full(config, cli.run.sealing, author_id);
}

let key = sp_core::Pair::generate().0;

let extension = chain_spec::Extensions::try_get(&*config.chain_spec);
let relay_chain_id = extension.map(|e| e.relay_chain.clone());
let para_id = extension.map(|e| e.para_id);

let polkadot_cli = RelayChainCli::new(
config.base_path.as_ref().map(|x| x.path().join("polkadot")),
relay_chain_id,
[RelayChainCli::executable_name()]
.iter()
.chain(cli.relaychain_args.iter()),
);

let id = ParaId::from(cli.run.parachain_id.or(para_id).unwrap_or(1000));

let parachain_account =
AccountIdConversion::<polkadot_primitives::v0::AccountId>::into_account(
&id,
);

let block: Block = generate_genesis_block(&config.chain_spec)
.map_err(|e| format!("{:?}", e))?;
let genesis_state =
format!("0x{:?}", HexDisplay::from(&block.header().encode()));

let task_executor = config.task_executor.clone();
let polkadot_config = SubstrateCli::create_configuration(
&polkadot_cli,
&polkadot_cli,
task_executor,
config.telemetry_handle.clone(),
)
.map_err(|err| format!("Relay chain argument error: {}", err))?;

info!("Parachain id: {:?}", id);
info!("Parachain Account: {}", parachain_account);
info!("Parachain genesis state: {}", genesis_state);
info!("Is collating: {}", if collator { "yes" } else { "no" });

crate::service::start_node(
config,
key,
author_id,
polkadot_config,
id,
collator,
)
.await
.map(|r| r.0)
})
.map_err(Into::into)
})
.map_err(Into::into)
}
}
}
Expand Down Expand Up @@ -399,7 +414,7 @@ impl CliConfiguration<Self> for RelayChainCli {
self.base.base.prometheus_config(default_listen_port)
}

fn init<C: SubstrateCli>(&self) -> Result<()> {
fn init<C: SubstrateCli>(&self) -> Result<sc_telemetry::TelemetryWorker> {
unreachable!("PolkadotCli is never initialized; qed");
}

Expand Down
38 changes: 32 additions & 6 deletions node/src/dev_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
use crate::cli::Sealing;
use async_io::Timer;
use fc_consensus::FrontierBlockImport;
use fc_rpc_core::types::PendingTransactions;
use fc_rpc_core::types::{FilterPool, PendingTransactions};
use futures::Stream;
use futures::StreamExt;
use moonbeam_runtime::{self, opaque::Block, RuntimeApi};
Expand All @@ -33,7 +33,7 @@ use sp_core::H160;
use sp_core::H256;
use std::time::Duration;
use std::{
collections::HashMap,
collections::{BTreeMap, HashMap},
sync::{Arc, Mutex},
};

Expand Down Expand Up @@ -62,6 +62,7 @@ pub fn new_partial(
(
FrontierBlockImport<Block, Arc<FullClient>, FullClient>,
PendingTransactions,
Option<FilterPool>,
),
>,
ServiceError,
Expand All @@ -83,6 +84,8 @@ pub fn new_partial(

let pending_transactions: PendingTransactions = Some(Arc::new(Mutex::new(HashMap::new())));

let filter_pool: Option<FilterPool> = Some(Arc::new(Mutex::new(BTreeMap::new())));

let frontier_block_import = FrontierBlockImport::new(client.clone(), client.clone(), true);

let import_queue = sc_consensus_manual_seal::import_queue(
Expand All @@ -100,7 +103,7 @@ pub fn new_partial(
select_chain,
transaction_pool,
inherent_data_providers,
other: (frontier_block_import, pending_transactions),
other: (frontier_block_import, pending_transactions, filter_pool),
})
}

Expand All @@ -119,7 +122,7 @@ pub fn new_full(
select_chain,
transaction_pool,
inherent_data_providers,
other: (block_import, pending_transactions),
other: (block_import, pending_transactions, filter_pool),
} = new_partial(&config, author_id)?;

let (network, network_status_sinks, system_rpc_tx, network_starter) =
Expand All @@ -145,7 +148,6 @@ pub fn new_full(

let role = config.role.clone();
let prometheus_registry = config.prometheus_registry().cloned();
let telemetry_connection_sinks = sc_service::TelemetryConnectionSinks::default();
let is_authority = role.is_authority();
let subscription_task_executor =
sc_rpc::SubscriptionTaskExecutor::new(task_manager.spawn_handle());
Expand Down Expand Up @@ -213,6 +215,7 @@ pub fn new_full(
let pool = transaction_pool.clone();
let network = network.clone();
let pending = pending_transactions.clone();
let filter_pool = filter_pool.clone();
Box::new(move |deny_unsafe, _| {
let deps = crate::rpc::FullDeps {
client: client.clone(),
Expand All @@ -222,6 +225,7 @@ pub fn new_full(
is_authority,
network: network.clone(),
pending_transactions: pending.clone(),
filter_pool: filter_pool.clone(),
command_sink: command_sink.clone(),
};
crate::rpc::create_full(deps, subscription_task_executor.clone())
Expand All @@ -234,7 +238,6 @@ pub fn new_full(
keystore: keystore_container.sync_keystore(),
task_manager: &mut task_manager,
transaction_pool: transaction_pool.clone(),
telemetry_connection_sinks,
rpc_extensions_builder,
on_demand: None,
remote_blockchain: None,
Expand All @@ -244,6 +247,29 @@ pub fn new_full(
config,
})?;

// Spawn Frontier EthFilterApi maintenance task.
if filter_pool.is_some() {
// Each filter is allowed to stay in the pool for 100 blocks.
const FILTER_RETAIN_THRESHOLD: u64 = 100;
task_manager.spawn_essential_handle().spawn(
"frontier-filter-pool",
client
.import_notification_stream()
.for_each(move |notification| {
if let Ok(locked) = &mut filter_pool.clone().unwrap().lock() {
let imported_number: u64 = notification.header.number as u64;
for (k, v) in locked.clone().iter() {
let lifespan_limit = v.at_block + FILTER_RETAIN_THRESHOLD;
if lifespan_limit <= imported_number {
locked.remove(&k);
}
}
}
futures::future::ready(())
}),
);
}

// Spawn Frontier pending transactions maintenance task (as essential, otherwise we leak).
if pending_transactions.is_some() {
use fp_consensus::{ConsensusLog, FRONTIER_ENGINE_ID};
Expand Down
Loading

0 comments on commit 5308f49

Please sign in to comment.