Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7,391 changes: 5,058 additions & 2,333 deletions Cargo.lock

Large diffs are not rendered by default.

214 changes: 110 additions & 104 deletions Cargo.toml

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions node/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ tokio = { workspace = true, features = ["macros", "sync"] }
# substrate client dependencies
sc-client-api = { workspace = true }
sc-rpc = { workspace = true }
sc-rpc-api = { workspace = true }
sc-transaction-pool = { workspace = true }
sc-chain-spec = { workspace = true }
sc-consensus-grandpa = { workspace = true }
sc-consensus-manual-seal = { workspace = true }
Expand All @@ -28,7 +26,7 @@ sc-service = { workspace = true }
substrate-prometheus-endpoint = { workspace = true }

# benchmarking dependencies
frame-benchmarking = { workspace = true, features = ["std"] }
frame-benchmarking = { workspace = true, optional = true, features = ["std"] }

# substrate primitives dependencies
sp-core = { workspace = true, features = ["std"] }
Expand All @@ -49,9 +47,12 @@ fc-rpc-debug = { workspace = true }
fc-rpc-trace = { workspace = true }
fp-ext = { workspace = true, features = ["std"] }

# Cumulus dependencies
cumulus-primitives-proof-size-hostfunction = { workspace = true }

# Local Dependencies
bp-core = { workspace = true }

[features]
default = []
runtime-benchmarks = []
runtime-benchmarks = ["frame-benchmarking/runtime-benchmarks"]
14 changes: 4 additions & 10 deletions node/common/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ use sc_consensus_manual_seal::EngineCommand;
use sc_network::service::traits::NetworkService;
use sc_network_sync::SyncingService;
use sc_rpc::SubscriptionTaskExecutor;
use sc_rpc_api::DenyUnsafe;
use sc_service::TaskManager;
use sc_transaction_pool::{ChainApi, Pool};

use bp_core::{BlockNumber, Hash, Header};
use sp_core::H256;
Expand Down Expand Up @@ -49,7 +47,7 @@ pub struct GrandpaDeps<B> {
}

/// Full client dependencies.
pub struct FullDevDeps<C, P, BE, SC, A: ChainApi, CIDP> {
pub struct FullDevDeps<C, P, BE, SC, CIDP> {
/// Client version.
pub client_version: String,
/// The client instance to use.
Expand All @@ -61,9 +59,7 @@ pub struct FullDevDeps<C, P, BE, SC, A: ChainApi, CIDP> {
/// A copy of the chain spec.
pub chain_spec: Box<dyn sc_chain_spec::ChainSpec>,
/// Graph pool instance.
pub graph: Arc<Pool<A>>,
/// Whether to deny unsafe calls
pub deny_unsafe: DenyUnsafe,
pub graph: Arc<P>,
/// GRANDPA specific dependencies.
pub grandpa: GrandpaDeps<BE>,
/// The Node authority flag
Expand Down Expand Up @@ -101,7 +97,7 @@ pub struct FullDevDeps<C, P, BE, SC, A: ChainApi, CIDP> {
}

/// Mainnet/Testnet client dependencies.
pub struct FullDeps<C, P, BE, SC, A: ChainApi, CIDP> {
pub struct FullDeps<C, P, BE, SC, CIDP> {
/// Client version.
pub client_version: String,
/// The client instance to use.
Expand All @@ -113,9 +109,7 @@ pub struct FullDeps<C, P, BE, SC, A: ChainApi, CIDP> {
/// A copy of the chain spec.
pub chain_spec: Box<dyn sc_chain_spec::ChainSpec>,
/// Graph pool instance.
pub graph: Arc<Pool<A>>,
/// Whether to deny unsafe calls
pub deny_unsafe: DenyUnsafe,
pub graph: Arc<P>,
/// GRANDPA specific dependencies.
pub grandpa: GrandpaDeps<BE>,
/// The Node authority flag
Expand Down
15 changes: 11 additions & 4 deletions node/common/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,18 @@ use sp_runtime::traits::BlakeTwo256;

/// Only enable the benchmarking host functions when we actually want to benchmark.
#[cfg(feature = "runtime-benchmarks")]
pub type HostFunctions =
(sp_io::SubstrateHostFunctions, frame_benchmarking::benchmarking::HostFunctions);
/// Otherwise we use empty host functions for ext host functions.
pub type HostFunctions = (
sp_io::SubstrateHostFunctions,
frame_benchmarking::benchmarking::HostFunctions,
cumulus_primitives_proof_size_hostfunction::storage_proof_size::HostFunctions,
);
/// Otherwise we use storage proof size host functions for compatibility.
#[cfg(not(feature = "runtime-benchmarks"))]
pub type HostFunctions = (sp_io::SubstrateHostFunctions, fp_ext::bifrost_ext::HostFunctions);
pub type HostFunctions = (
sp_io::SubstrateHostFunctions,
fp_ext::bifrost_ext::HostFunctions,
cumulus_primitives_proof_size_hostfunction::storage_proof_size::HostFunctions,
);

/// Configure frontier database.
pub fn frontier_database_dir(config: &Configuration, path: &str) -> std::path::PathBuf {
Expand Down
19 changes: 13 additions & 6 deletions node/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,17 @@ sc-service = { workspace = true }
sc-consensus-grandpa = { workspace = true }

# benchmarking dependencies
frame-benchmarking = { workspace = true, features = ["std"] }
frame-benchmarking-cli = { workspace = true }

# Bifrost runtimes
bifrost-dev-runtime = { workspace = true, features = ["std", "evm-tracing"] }
bifrost-testnet-runtime = { workspace = true, features = [
"std",
"evm-tracing",
"std",
"evm-tracing",
] }
bifrost-mainnet-runtime = { workspace = true, features = [
"std",
"evm-tracing",
"std",
"evm-tracing",
] }

# Bifrost node specs
Expand All @@ -53,4 +52,12 @@ substrate-build-script-utils = { workspace = true }

[features]
default = []
runtime-benchmarks = []
runtime-benchmarks = [
"bifrost-dev-runtime/runtime-benchmarks",
"bifrost-testnet-runtime/runtime-benchmarks",
"bifrost-mainnet-runtime/runtime-benchmarks",
"bifrost-dev-node/runtime-benchmarks",
"bifrost-testnet-node/runtime-benchmarks",
"bifrost-mainnet-node/runtime-benchmarks",
"sc-service/runtime-benchmarks",
]
41 changes: 32 additions & 9 deletions node/core/src/command.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use crate::cli::{Cli, Subcommand};

use bifrost_common_node::cli_opt::{BackendType, BackendTypeConfig, RpcConfig};
use bifrost_common_node::{
cli_opt::{BackendType, BackendTypeConfig, RpcConfig},
service::HostFunctions,
};

use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE};

Expand Down Expand Up @@ -294,9 +297,9 @@ pub fn run() -> sc_cli::Result<()> {
);
}

cmd.run_with_spec::<sp_runtime::traits::HashingFor<Block>, ()>(Some(
config.chain_spec,
))
cmd.run_with_spec::<sp_runtime::traits::HashingFor<Block>, HostFunctions>(
Some(config.chain_spec),
)
},
BenchmarkCmd::Block(cmd) => {
let PartialComponents { client, .. } =
Expand All @@ -310,12 +313,32 @@ pub fn run() -> sc_cli::Result<()> {
),
#[cfg(feature = "runtime-benchmarks")]
BenchmarkCmd::Storage(cmd) => {
let PartialComponents { client, backend, .. } =
service::new_partial(&config)?;
let db = backend.expose_db();
let storage = backend.expose_storage();
let chain_spec = &config.chain_spec;

cmd.run(config, client, db, storage)
match chain_spec {
_spec if chain_spec.is_dev() => {
use bifrost_dev_node::service;
let params = service::new_partial(&config, &rpc_config)?;
let db = params.backend.expose_db();
let storage = params.backend.expose_storage();
cmd.run(config, params.client, db, storage)
},
_spec if chain_spec.is_mainnet() => {
use bifrost_mainnet_node::service;
let params = service::new_partial(&config, &rpc_config)?;
let db = params.backend.expose_db();
let storage = params.backend.expose_storage();
cmd.run(config, params.client, db, storage)
},
_spec if chain_spec.is_testnet() => {
use bifrost_testnet_node::service;
let params = service::new_partial(&config, &rpc_config)?;
let db = params.backend.expose_db();
let storage = params.backend.expose_storage();
cmd.run(config, params.client, db, storage)
},
_ => panic!("Invalid chain spec"),
}
},
BenchmarkCmd::Machine(cmd) => {
cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone())
Expand Down
15 changes: 8 additions & 7 deletions node/dev/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ sc-consensus = { workspace = true }
sc-network = { workspace = true }
sc-network-sync = { workspace = true }
sc-rpc = { workspace = true }
sc-rpc-api = { workspace = true }
sc-chain-spec = { workspace = true }
sc-basic-authorship = { workspace = true }
sc-offchain = { workspace = true }
Expand All @@ -57,22 +56,21 @@ substrate-frame-rpc-system = { workspace = true }
fc-db = { workspace = true, features = ["rocksdb"] }
fc-rpc-core = { workspace = true }
fc-mapping-sync = { workspace = true, features = ["sql"] }
fc-rpc-txpool = { workspace = true }
fc-rpc-debug = { workspace = true }
fc-rpc-trace = { workspace = true }
fc-rpc = { workspace = true, features = ["rpc-binary-search-estimate"] }
fc-rpc = { workspace = true, features = ["rpc-binary-search-estimate", "aura"] }

fp-evm = { workspace = true }
fp-ext = { workspace = true, features = ["std"] }
fp-rpc = { workspace = true, features = ["std"] }
fp-rpc-txpool = { workspace = true, features = ["std"] }
pallet-ethereum = { workspace = true, features = [
"std",
"forbid-evm-reentrancy",
"std",
"forbid-evm-reentrancy",
] }

# benchmarking dependencies
frame-benchmarking = { workspace = true, features = ["std"] }
frame-benchmarking = { workspace = true, optional = true, features = ["std"] }

# Local Dependencies
bp-core = { workspace = true }
Expand All @@ -82,4 +80,7 @@ bifrost-common-node = { workspace = true }

[features]
default = []
runtime-benchmarks = ["bifrost-dev-runtime/runtime-benchmarks"]
runtime-benchmarks = [
"bifrost-dev-runtime/runtime-benchmarks",
"frame-benchmarking/runtime-benchmarks",
]
33 changes: 16 additions & 17 deletions node/dev/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,19 @@ use sp_blockchain::{
use sp_consensus::SelectChain;
use sp_consensus_aura::{sr25519::AuthorityId as AuraId, AuraApi};
use sp_inherents::CreateInherentDataProviders;
use sp_runtime::traits::BlakeTwo256;
use sp_runtime::traits::{BlakeTwo256, Block as BlockT};

use fc_rpc::pending::AuraConsensusDataProvider;
use sc_client_api::{
backend::{Backend, StateBackend, StorageProvider},
UsageProvider,
};
pub use sc_client_api::{AuxStore, BlockOf, BlockchainEvents};
use sc_consensus_manual_seal::rpc::{ManualSeal, ManualSealApiServer};
pub use sc_rpc_api::DenyUnsafe;
use sc_transaction_pool::ChainApi;
use sc_transaction_pool_api::TransactionPool;

/// Instantiate all full RPC extensions.
pub fn create_full<C, P, BE, SC, A, CIDP>(
deps: FullDevDeps<C, P, BE, SC, A, CIDP>,
pub fn create_full<C, P, BE, SC, CIDP>(
deps: FullDevDeps<C, P, BE, SC, CIDP>,
maybe_tracing_config: Option<TracingConfig>,
pubsub_notification_sinks: Arc<
fc_mapping_sync::EthereumBlockNotificationSinks<
Expand All @@ -63,18 +60,17 @@ where
C::Api: fp_rpc::ConvertTransactionRuntimeApi<Block>,
C::Api: fp_rpc_txpool::TxPoolRuntimeApi<Block>,
C::Api: AuraApi<Block, AuraId>,
P: TransactionPool<Block = Block> + 'static,
A: ChainApi<Block = Block> + 'static,
P: TransactionPool<Block = Block, Hash = <Block as BlockT>::Hash> + 'static,
SC: SelectChain<Block> + 'static,
CIDP: CreateInherentDataProviders<Block, ()> + Send + 'static,
{
use fc_rpc::{
Eth, EthApiServer, EthFilter, EthFilterApiServer, EthPubSub, EthPubSubApiServer, Net,
NetApiServer, Web3, Web3ApiServer,
pending::AuraConsensusDataProvider, Eth, EthApiServer, EthFilter, EthFilterApiServer,
EthPubSub, EthPubSubApiServer, Net, NetApiServer, TxPool, TxPoolApiServer, Web3,
Web3ApiServer,
};
use fc_rpc_debug::{Debug, DebugServer};
use fc_rpc_trace::{Trace, TraceServer};
use fc_rpc_txpool::{TxPool, TxPoolServer};
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer};
use sc_consensus_grandpa_rpc::{Grandpa, GrandpaApiServer};
use substrate_frame_rpc_system::{System, SystemApiServer};
Expand All @@ -86,7 +82,6 @@ where
pool,
select_chain: _,
chain_spec: _,
deny_unsafe,
graph,
network,
filter_pool,
Expand Down Expand Up @@ -115,8 +110,7 @@ where
finality_provider,
} = grandpa;

io.merge(System::new(Arc::clone(&client), Arc::clone(&pool), deny_unsafe).into_rpc())
.ok();
io.merge(System::new(Arc::clone(&client), Arc::clone(&pool)).into_rpc()).ok();
io.merge(TransactionPayment::new(Arc::clone(&client)).into_rpc()).ok();

io.merge(
Expand Down Expand Up @@ -191,7 +185,7 @@ where
let convert_transaction: Option<Never> = None;

io.merge(
Eth::<_, _, _, _, _, _, _, DefaultEthConfig<C, BE>>::new(
Eth::<_, _, _, _, _, _, DefaultEthConfig<C, BE>>::new(
Arc::clone(&client),
Arc::clone(&pool),
graph.clone(),
Expand All @@ -217,8 +211,13 @@ where
if let Some(tracing_config) = maybe_tracing_config {
if let Some(trace_filter_requester) = tracing_config.tracing_requesters.trace {
io.merge(
Trace::new(client, trace_filter_requester, tracing_config.trace_filter_max_count)
.into_rpc(),
Trace::new(
client,
trace_filter_requester,
tracing_config.trace_filter_max_count,
frontier_backend.clone(),
)
.into_rpc(),
)
.ok();
}
Expand Down
Loading