Skip to content

Commit

Permalink
partial changes in cli, consensus-transition and precompiles
Browse files Browse the repository at this point in the history
  • Loading branch information
Raj-RR1 committed Aug 19, 2023
1 parent 88094e8 commit b2978f3
Show file tree
Hide file tree
Showing 7 changed files with 205 additions and 227 deletions.
173 changes: 76 additions & 97 deletions node/cli/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,103 +1,98 @@
// Copyright 2018-2020 Commonwealth Labs, Inc.
// Copyright 2018-2020 Commonwealth Labs, Inc.
// This file is part of Edgeware.

// Edgeware 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
// Edgeware 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.

// Edgeware 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
// Edgeware 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 Edgeware. If not, see <http://www.gnu.org/licenses/>.
// You should have received a copy of the GNU General Public License
// along with Edgeware. If not, see <http://www.gnu.org/licenses/>.


// 2022 rewrite by flipchan @ edgeware

use sc_cli::{KeySubcommand, SignCmd, VanityCmd, VerifyCmd};
//use structopt::StructOpt;
use edgeware_cli_opt::EthApi;
use clap::Parser;

//use ethereum_types::{H160, H256, U256};

#[allow(missing_docs)]
#[derive(Debug, Parser)]
pub struct RunCmd {
#[allow(missing_docs)]
#[clap(flatten)]
pub base: sc_cli::RunCmd,

#[clap(long = "enable-dev-signer")]
pub enable_dev_signer: bool,

/// The dynamic-fee pallet target gas price set by block author
#[clap(long, default_value = "1")]
pub target_gas_price: u64,

/// Enable EVM tracing module on a non-authority node.
#[clap(
long,
conflicts_with = "validator",
use_value_delimiter = true,
require_value_delimiter = true,
multiple_values = true
)]
pub ethapi: Vec<EthApi>,

/// Number of concurrent tracing tasks. Meant to be shared by both "debug"
/// and "trace" modules.
#[clap(long, default_value = "10")]
use sc_cli::{KeySubcommand, SignCmd, VanityCmd, VerifyCmd};
//use structopt::StructOpt;
use edgeware_cli_opt::EthApi;
use clap::Parser;

//use ethereum_types::{H160, H256, U256};

#[allow(missing_docs)]
#[derive(Debug, Parser)]
pub struct RunCmd {
#[allow(missing_docs)]
#[clap(flatten)]
pub base: sc_cli::RunCmd,

#[clap(long = "enable-dev-signer")]
pub enable_dev_signer: bool,

/// The dynamic-fee pallet target gas price set by block author
#[clap(long, default_value = "1")]
pub target_gas_price: u64,

/// Enable EVM tracing module on a non-authority node.
#[clap(
long,
conflicts_with = "validator",
use_value_delimiter = true,
require_value_delimiter = true,
multiple_values = true
)]
pub ethapi: Vec<EthApi>,

/// Number of concurrent tracing tasks. Meant to be shared by both "debug"
/// and "trace" modules.
#[clap(long, default_value = "10")]
pub ethapi_max_permits: u32,

/// Maximum number of trace entries a single request of `trace_filter` is
/// allowed to return. A request asking for more or an unbounded one going
/// over this limit will both return an error.
#[clap(long, default_value = "500")]
pub ethapi_trace_max_count: u32,
/// Maximum number of trace entries a single request of `trace_filter` is
/// allowed to return. A request asking for more or an unbounded one going
/// over this limit will both return an error.
#[clap(long, default_value = "500")]
pub ethapi_trace_max_count: u32,

/// Duration (in seconds) after which the cache of `trace_filter` for a
/// given block will be discarded.
#[clap(long, default_value = "300")]
/// Duration (in seconds) after which the cache of `trace_filter` for a
/// given block will be discarded.
#[clap(long, default_value = "300")]
pub ethapi_trace_cache_duration: u64,

/// Size in bytes of the LRU cache for block data.
#[clap(long, default_value = "300000000")]
pub eth_log_block_cache: usize,

/// Size in bytes of the LRU cache for transactions statuses data.
#[clap(long, default_value = "300000000")]
pub eth_statuses_cache: usize,
/// Size in bytes of the LRU cache for block data.
#[clap(long, default_value = "300000000")]
pub eth_log_block_cache: usize,

/// Size in bytes of data a raw tracing request is allowed to use.
/// Bound the size of memory, stack and storage data.
#[clap(long, default_value = "20000000")]
pub tracing_raw_max_memory_usage: usize,
/// Size in bytes of the LRU cache for transactions statuses data.
#[clap(long, default_value = "300000000")]
pub eth_statuses_cache: usize,

/// Maximum number of logs in a query.
#[clap(long, default_value = "10000")]
pub max_past_logs: u32,
/// Maximum number of logs in a query.
#[clap(long, default_value = "10000")]
pub max_past_logs: u32,

/// Maximum fee history cache size.
#[clap(long, default_value = "2048")]
pub fee_history_limit: u64,
/// Maximum fee history cache size.
#[clap(long, default_value = "2048")]
pub fee_history_limit: u64,
}

/// An overarching CLI command definition.
#[derive(Debug, Parser)]
#[clap(
propagate_version = true,
args_conflicts_with_subcommands = true,
subcommand_negates_reqs = true
#[derive(Debug, Parser)]
#[clap(
propagate_version = true,
args_conflicts_with_subcommands = true,
subcommand_negates_reqs = true
)]
pub struct Cli {
/// Possible subcommand with parameters.
#[clap(subcommand)]
#[command(subcommand)]
pub subcommand: Option<Subcommand>,
#[allow(missing_docs)]
#[allow(missing_docs)]
#[clap(flatten)]
pub run: RunCmd,

Expand All @@ -119,33 +114,17 @@ pub struct Cli {
/// Possible subcommands of the main binary.
#[derive(Debug, clap::Subcommand)]
pub enum Subcommand {

/// The custom inspect subcommmand for decoding blocks and extrinsics.
#[command(
name = "inspect",
about = "Decode given block or extrinsic using current native runtime."
)]
Inspect(node_inspect::cli::InspectCmd),
/// Key management cli utilities
#[clap(subcommand)]
/// Key management cli utilities
#[command(subcommand)]
Key(KeySubcommand),

/// The custom benchmark subcommmand benchmarking runtime pallets.
/// The custom benchmark subcommmand benchmarking runtime pallets.
// #[clap(name = "benchmark", about = "Benchmark runtime pallets.")]
#[clap(subcommand)]
#[command(subcommand)]
Benchmark(frame_benchmarking_cli::BenchmarkCmd),


/// Try some command against runtime state.
#[cfg(feature = "try-runtime")]
TryRuntime(try_runtime_cli::TryRuntimeCmd),

/// Try some command against runtime state. Note: `try-runtime` feature must be enabled.
#[cfg(not(feature = "try-runtime"))]
TryRuntime,

/// Verify a signature for a message, provided on STDIN, with a given
/// (public or secret) key.
/// Verify a signature for a message, provided on STDIN, with a given
/// (public or secret) key.
Verify(VerifyCmd),

/// Generate a seed that provides a vanity address.
Expand Down
43 changes: 15 additions & 28 deletions node/cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,64 +88,52 @@ pub fn run() -> Result<()> {
Some(Subcommand::BuildSpec(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.sync_run(|config| cmd.run(config.chain_spec, config.network))
}
},
Some(Subcommand::CheckBlock(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.async_run(|config| {
let PartialComponents {
client,
task_manager,
import_queue,
..
} = new_partial(&config, &cli)?;
let PartialComponents { client, task_manager, import_queue, .. } =
new_partial(&config, &cli)?;
Ok((cmd.run(client, import_queue), task_manager))
})
}
},
Some(Subcommand::ExportBlocks(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.async_run(|config| {
let PartialComponents {
client, task_manager, ..
} = new_partial(&config, &cli)?;
let PartialComponents { client, task_manager, .. } = new_partial(&config, &cli)?;
Ok((cmd.run(client, config.database), task_manager))
})
}
},
Some(Subcommand::ExportState(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.async_run(|config| {
let PartialComponents {
client, task_manager, ..
} = new_partial(&config, &cli)?;
let PartialComponents { client, task_manager, .. } = new_partial(&config, &cli)?;
Ok((cmd.run(client, config.chain_spec), task_manager))
})
}
},
Some(Subcommand::ImportBlocks(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.async_run(|config| {
let PartialComponents {
client,
task_manager,
import_queue,
..
} = new_partial(&config, &cli)?;
let PartialComponents { client, task_manager, import_queue, .. } =
new_partial(&config, &cli)?;
Ok((cmd.run(client, import_queue), task_manager))
})
}
},
Some(Subcommand::PurgeChain(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.sync_run(|config| cmd.run(config.database))
}
},
Some(Subcommand::Revert(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.async_run(|config| {
let PartialComponents { client, task_manager, backend, .. } = new_partial(&config,&cli)?;
let aux_revert = Box::new(move |client,_, blocks| {
let PartialComponents { client, task_manager, backend, .. } = new_partial(&config, &cli)?;
let aux_revert = Box::new(|client,_, blocks| {
sc_finality_grandpa::revert(client, blocks)?;
Ok(())
});
Ok((cmd.run(client, backend, Some(aux_revert)), task_manager))
})
}
},
None => {
let runner = cli.create_runner(&cli.run.base)?;

Expand All @@ -159,7 +147,6 @@ pub fn run() -> Result<()> {
fee_history_limit: cli.run.fee_history_limit,
max_past_logs: cli.run.max_past_logs,
relay_chain_rpc_url: None,
tracing_raw_max_memory_usage: cli.run.tracing_raw_max_memory_usage
};

runner.run_node_until_exit(|config| async move {
Expand Down
12 changes: 7 additions & 5 deletions node/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ pub mod chain_spec;
#[macro_use]
mod service;
#[cfg(feature = "cli")]
mod benchmarking;
#[cfg(feature = "cli")]
mod cli;
#[cfg(feature = "cli")]
mod command;
Expand All @@ -43,9 +45,9 @@ mod command;
pub use cli::*;
#[cfg(feature = "cli")]
pub use command::*;

pub use cli::*;
pub use command::*;

pub use cli::*;
pub use command::*;

pub mod mainnet_fixtures;
pub mod testnet_fixtures;
pub mod mainnet_fixtures;
pub mod testnet_fixtures;
15 changes: 9 additions & 6 deletions node/consensus-transition/manual-seal/src/consensus/aura.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is part of Substrate.

// Copyright (C) 2022 Parity Technologies (UK) Ltd.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0

// This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -35,14 +35,14 @@ use sp_timestamp::TimestampInherentData;
use std::{marker::PhantomData, sync::Arc};

/// Consensus data provider for Aura.
pub struct AuraConsensusDataProvider<B, C> {
pub struct AuraConsensusDataProvider<B, C, P> {
// slot duration
slot_duration: SlotDuration,
// phantom data for required generics
_phantom: PhantomData<(B, C)>,
_phantom: PhantomData<(B, C, P)>,
}

impl<B, C> AuraConsensusDataProvider<B, C>
impl<B, C, P> AuraConsensusDataProvider<B, C, P>
where
B: BlockT,
C: AuxStore + ProvideRuntimeApi<B> + UsageProvider<B>,
Expand All @@ -58,7 +58,7 @@ where
}
}

impl<B, C> ConsensusDataProvider<B> for AuraConsensusDataProvider<B, C>
impl<B, C, P> ConsensusDataProvider<B> for AuraConsensusDataProvider<B, C, P>
where
B: BlockT,
C: AuxStore
Expand All @@ -67,8 +67,10 @@ where
+ UsageProvider<B>
+ ProvideRuntimeApi<B>,
C::Api: AuraApi<B, AuthorityId>,
P: Send + Sync,
{
type Transaction = TransactionFor<C, B>;
type Proof = P;

fn create_digest(
&self,
Expand All @@ -92,7 +94,8 @@ where
_parent: &B::Header,
_params: &mut BlockImportParams<B, Self::Transaction>,
_inherents: &InherentData,
_proof: Self::Proof,
) -> Result<(), Error> {
Ok(())
}
}
}
Loading

0 comments on commit b2978f3

Please sign in to comment.