Skip to content

Commit 58d5805

Browse files
authored
Merge pull request #27 from PureStake/crystalin-add-frontier-consensus
Updates frontier to new version with consensus
2 parents 059911c + 9899415 commit 58d5805

18 files changed

+1258
-794
lines changed

Cargo.lock

+871-448
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node/Cargo.toml

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ homepage = 'https://moonbeam.network'
77
license = 'Unlicense'
88
name = 'node-moonbeam'
99
repository = 'https://github.com/PureStake/moonbeam/'
10-
version = '0.1.0'
10+
version = '0.1.1'
1111

1212
[package.metadata.docs.rs]
1313
targets = ["x86_64-unknown-linux-gnu"]
@@ -16,7 +16,6 @@ targets = ["x86_64-unknown-linux-gnu"]
1616
futures = "0.3.4"
1717
log = "0.4.8"
1818
structopt = "0.3.8"
19-
parking_lot = "0.10.0"
2019
jsonrpc-core = "14.0.3"
2120

2221
sp-api = { version = "2.0.0-dev", path = "../vendor/frontier/vendor/substrate/primitives/api" }
@@ -49,6 +48,8 @@ sc-basic-authorship = { path = "../vendor/frontier/vendor/substrate/client/basic
4948
sp-block-builder = { path = "../vendor/frontier/vendor/substrate/primitives/block-builder" }
5049

5150
moonbeam-runtime = { path = "../runtime" }
51+
52+
frontier-consensus = { version = "0.1.0", path = "../vendor/frontier/consensus" }
5253
frontier-rpc = { version = "0.1.0", path = "../vendor/frontier/rpc" }
5354
frontier-rpc-primitives = { version = "0.1.0", path = "../vendor/frontier/rpc/primitives" }
5455

node/src/chain_spec.rs

+7-11
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@
1111
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212
// GNU General Public License for more details.
1313

14-
// You should have received a copy of the GNU General Public License
15-
// along with Moonbeam. If not, see <http://www.gnu.org/licenses/>.
16-
17-
1814
use sp_core::{Pair, Public, sr25519, H160, U256};
1915
use moonbeam_runtime::{
2016
AccountId, AuraConfig, BalancesConfig, EVMConfig, EthereumConfig, GenesisConfig, GrandpaConfig,
@@ -165,28 +161,28 @@ fn testnet_genesis(
165161
);
166162
log::info!("Adding balance for {}", gerald_evm_account_id);
167163
GenesisConfig {
168-
system: Some(SystemConfig {
164+
frame_system: Some(SystemConfig {
169165
// Add Wasm runtime to storage.
170166
code: wasm_binary.to_vec(),
171167
changes_trie_config: Default::default(),
172168
}),
173-
balances: Some(BalancesConfig {
169+
pallet_balances: Some(BalancesConfig {
174170
// Configure endowed accounts with initial balance of 1 << 60.
175171
balances: endowed_accounts.iter().cloned().map(|k|(k, 1 << 60)).collect(),
176172
}),
177-
aura: Some(AuraConfig {
173+
pallet_aura: Some(AuraConfig {
178174
authorities: initial_authorities.iter().map(|x| (x.0.clone())).collect(),
179175
}),
180-
grandpa: Some(GrandpaConfig {
176+
pallet_grandpa: Some(GrandpaConfig {
181177
authorities: initial_authorities.iter().map(|x| (x.1.clone(), 1)).collect(),
182178
}),
183-
sudo: Some(SudoConfig {
179+
pallet_sudo: Some(SudoConfig {
184180
// Assign network admin rights.
185181
key: root_key,
186182
}),
187-
evm: Some(EVMConfig {
183+
frame_evm: Some(EVMConfig {
188184
accounts: evm_accounts,
189185
}),
190-
ethereum: Some(EthereumConfig {}),
186+
frame_ethereum: Some(EthereumConfig {}),
191187
}
192188
}

node/src/cli.rs

+24-2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@
1414
// You should have received a copy of the GNU General Public License
1515
// along with Moonbeam. If not, see <http://www.gnu.org/licenses/>.
1616

17-
use sc_cli::{Subcommand};
1817
use structopt::StructOpt;
1918

20-
2119
#[allow(missing_docs)]
2220
#[derive(Debug, StructOpt)]
2321
pub struct RunCmd {
@@ -38,3 +36,27 @@ pub struct Cli {
3836
#[structopt(flatten)]
3937
pub run: RunCmd,
4038
}
39+
40+
#[derive(Debug, StructOpt)]
41+
pub enum Subcommand {
42+
/// Build a chain specification.
43+
BuildSpec(sc_cli::BuildSpecCmd),
44+
45+
/// Validate blocks.
46+
CheckBlock(sc_cli::CheckBlockCmd),
47+
48+
/// Export blocks.
49+
ExportBlocks(sc_cli::ExportBlocksCmd),
50+
51+
/// Export the state of a given block into a chain spec.
52+
ExportState(sc_cli::ExportStateCmd),
53+
54+
/// Import blocks.
55+
ImportBlocks(sc_cli::ImportBlocksCmd),
56+
57+
/// Remove the whole chain.
58+
PurgeChain(sc_cli::PurgeChainCmd),
59+
60+
/// Revert the chain to a previous state.
61+
Revert(sc_cli::RevertCmd),
62+
}

node/src/command.rs

+50-10
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
// along with Moonbeam. If not, see <http://www.gnu.org/licenses/>.
1616

1717
use crate::chain_spec;
18-
use crate::cli::Cli;
18+
use crate::cli::{Cli, Subcommand};
1919
use crate::service;
2020
use sc_cli::{SubstrateCli, RuntimeVersion, Role, ChainSpec};
21-
use sc_service::ServiceParams;
22-
use crate::service::new_full_params;
21+
use sc_service::PartialComponents;
22+
use crate::service::new_partial;
2323

2424
impl SubstrateCli for Cli {
2525
fn impl_name() -> String {
@@ -66,14 +66,54 @@ pub fn run() -> sc_cli::Result<()> {
6666
let cli = Cli::from_args();
6767

6868
match &cli.subcommand {
69-
Some(subcommand) => {
70-
let runner = cli.create_runner(subcommand)?;
71-
runner.run_subcommand(subcommand, |config| {
72-
let (ServiceParams { client, backend, task_manager, import_queue, .. }, ..)
73-
= new_full_params(config, cli.run.manual_seal)?;
74-
Ok((client, backend, import_queue, task_manager))
69+
Some(Subcommand::BuildSpec(cmd)) => {
70+
let runner = cli.create_runner(cmd)?;
71+
runner.sync_run(|config| cmd.run(config.chain_spec, config.network))
72+
},
73+
Some(Subcommand::CheckBlock(cmd)) => {
74+
let runner = cli.create_runner(cmd)?;
75+
runner.async_run(|config| {
76+
let PartialComponents { client, task_manager, import_queue, ..}
77+
= new_partial(&config, cli.run.manual_seal)?;
78+
Ok((cmd.run(client, import_queue), task_manager))
7579
})
76-
}
80+
},
81+
Some(Subcommand::ExportBlocks(cmd)) => {
82+
let runner = cli.create_runner(cmd)?;
83+
runner.async_run(|config| {
84+
let PartialComponents { client, task_manager, ..}
85+
= new_partial(&config, cli.run.manual_seal)?;
86+
Ok((cmd.run(client, config.database), task_manager))
87+
})
88+
},
89+
Some(Subcommand::ExportState(cmd)) => {
90+
let runner = cli.create_runner(cmd)?;
91+
runner.async_run(|config| {
92+
let PartialComponents { client, task_manager, ..}
93+
= new_partial(&config, cli.run.manual_seal)?;
94+
Ok((cmd.run(client, config.chain_spec), task_manager))
95+
})
96+
},
97+
Some(Subcommand::ImportBlocks(cmd)) => {
98+
let runner = cli.create_runner(cmd)?;
99+
runner.async_run(|config| {
100+
let PartialComponents { client, task_manager, import_queue, ..}
101+
= new_partial(&config, cli.run.manual_seal)?;
102+
Ok((cmd.run(client, import_queue), task_manager))
103+
})
104+
},
105+
Some(Subcommand::PurgeChain(cmd)) => {
106+
let runner = cli.create_runner(cmd)?;
107+
runner.sync_run(|config| cmd.run(config.database))
108+
},
109+
Some(Subcommand::Revert(cmd)) => {
110+
let runner = cli.create_runner(cmd)?;
111+
runner.async_run(|config| {
112+
let PartialComponents { client, task_manager, backend, ..}
113+
= new_partial(&config, cli.run.manual_seal)?;
114+
Ok((cmd.run(client, backend), task_manager))
115+
})
116+
},
77117
None => {
78118
let runner = cli.create_runner(&cli.run.base)?;
79119
runner.run_node_until_exit(|config| match config.role {

node/src/rpc.rs

+9-8
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,16 @@
1919
use std::{sync::Arc, fmt};
2020

2121
use sc_consensus_manual_seal::rpc::{ManualSeal, ManualSealApi};
22-
use moonbeam_runtime::{Hash, AccountId, Index, opaque::Block, Balance, UncheckedExtrinsic};
22+
use moonbeam_runtime::{Hash, AccountId, Index, opaque::Block, Balance};
2323
use sp_api::ProvideRuntimeApi;
2424
use sp_transaction_pool::TransactionPool;
2525
use sp_blockchain::{Error as BlockChainError, HeaderMetadata, HeaderBackend};
2626
use sp_consensus::SelectChain;
2727
use sc_rpc_api::DenyUnsafe;
28-
use sc_client_api::backend::{StorageProvider, Backend, StateBackend};
28+
use sc_client_api::backend::{StorageProvider, Backend, StateBackend, AuxStore};
2929
use sp_runtime::traits::BlakeTwo256;
3030
use sp_block_builder::BlockBuilder;
3131

32-
pub type IoHandler = jsonrpc_core::IoHandler<sc_rpc::Metadata>;
33-
3432
/// Light client extra dependencies.
3533
pub struct LightDeps<C, F, P> {
3634
/// The client instance to use.
@@ -65,21 +63,21 @@ pub fn create_full<C, P, M, SC, BE>(
6563
) -> jsonrpc_core::IoHandler<M> where
6664
BE: Backend<Block> + 'static,
6765
BE::State: StateBackend<BlakeTwo256>,
68-
C: ProvideRuntimeApi<Block> + StorageProvider<Block, BE>,
66+
C: ProvideRuntimeApi<Block> + StorageProvider<Block, BE> + AuxStore,
6967
C: HeaderBackend<Block> + HeaderMetadata<Block, Error=BlockChainError> + 'static,
7068
C: Send + Sync + 'static,
7169
C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>,
7270
C::Api: BlockBuilder<Block>,
73-
C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance, UncheckedExtrinsic>,
74-
C::Api: frontier_rpc_primitives::EthereumRuntimeApi<Block>,
71+
C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,
72+
C::Api: frontier_rpc_primitives::EthereumRuntimeRPCApi<Block>,
7573
<C::Api as sp_api::ApiErrorExt>::Error: fmt::Debug,
7674
P: TransactionPool<Block=Block> + 'static,
7775
M: jsonrpc_core::Metadata + Default,
7876
SC: SelectChain<Block> +'static,
7977
{
8078
use substrate_frame_rpc_system::{FullSystem, SystemApi};
8179
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi};
82-
use frontier_rpc::{EthApi, EthApiServer};
80+
use frontier_rpc::{EthApi, EthApiServer, NetApi, NetApiServer};
8381

8482
let mut io = jsonrpc_core::IoHandler::default();
8583
let FullDeps {
@@ -106,6 +104,9 @@ pub fn create_full<C, P, M, SC, BE>(
106104
is_authority,
107105
))
108106
);
107+
io.extend_with(
108+
NetApiServer::to_delegate(NetApi)
109+
);
109110

110111
match command_sink {
111112
Some(command_sink) => {

0 commit comments

Comments
 (0)