Skip to content

Commit

Permalink
All features compile
Browse files Browse the repository at this point in the history
  • Loading branch information
Dinonard committed Aug 5, 2024
1 parent 3bbb593 commit 803c3f7
Show file tree
Hide file tree
Showing 9 changed files with 343 additions and 29 deletions.
2 changes: 1 addition & 1 deletion bin/collator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ cumulus-test-relay-sproof-builder = { workspace = true }

# polkadot dependencies
polkadot-cli = { workspace = true, optional = true }
polkadot-core-primitives = { workspace = true }
polkadot-parachain = { workspace = true, features = ["std"] }
polkadot-primitives = { workspace = true, features = ["std"] }
polkadot-service = { workspace = true }
polkadot-core-primitives = { workspace = true }

# benchmark dependencies
frame-benchmarking = { workspace = true, features = ["std"] }
Expand Down
17 changes: 9 additions & 8 deletions bin/collator/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,7 @@ pub fn run() -> Result<()> {
Some(Subcommand::Sign(cmd)) => cmd.run(),
Some(Subcommand::Verify(cmd)) => cmd.run(),
Some(Subcommand::Vanity(cmd)) => cmd.run(),
// TODO: Remove this and replace it with benchmarks CLI
#[cfg(feature = "runtime-benchmarks")]
Some(Subcommand::Benchmark(cmd)) => {
use crate::benchmarking::*;
Expand All @@ -492,26 +493,26 @@ pub fn run() -> Result<()> {
BenchmarkCmd::Pallet(cmd) => {
if chain_spec.is_astar() {
runner.sync_run(|config| {
cmd.run::<HashingFor<astar_runtime::Block>, parachain::HostFunctions>(
config,
cmd.run_with_spec::<HashingFor<astar_runtime::Block>, parachain::HostFunctions>(
Some(config.chain_spec),
)
})
} else if chain_spec.is_shiden() {
runner.sync_run(|config| {
cmd.run::<HashingFor<shiden_runtime::Block>, parachain::HostFunctions>(
config,
cmd.run_with_spec::<HashingFor<shiden_runtime::Block>, parachain::HostFunctions>(
Some(config.chain_spec),
)
})
} else if chain_spec.is_shibuya() {
runner.sync_run(|config| {
cmd.run::<HashingFor<shibuya_runtime::Block>, parachain::HostFunctions>(
config,
cmd.run_with_spec::<HashingFor<shibuya_runtime::Block>, parachain::HostFunctions>(
Some(config.chain_spec),
)
})
} else {
runner.sync_run(|config| {
cmd.run::<HashingFor<local_runtime::Block>, local::HostFunctions>(
config,
cmd.run_with_spec::<HashingFor<local_runtime::Block>, local::HostFunctions>(
Some(config.chain_spec),
)
})
}
Expand Down
8 changes: 5 additions & 3 deletions bin/collator/src/parachain/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ pub struct AdditionalConfig {
/// This is the actual implementation that is abstract over the executor and the runtime api.
#[cfg(feature = "evm-tracing")]
#[sc_tracing::logging::prefix_logs_with("Parachain")]
async fn start_node_impl<RuntimeApi, Executor, BIQ, SC>(
async fn start_node_impl<RuntimeApi, Executor, BIQ, SC, N>(
parachain_config: Configuration,
polkadot_config: Configuration,
collator_options: CollatorOptions,
Expand Down Expand Up @@ -684,13 +684,15 @@ where
CollatorPair,
AdditionalConfig,
) -> Result<(), sc_service::Error>,
N: NetworkBackend<Block, <Block as BlockT>::Hash>,
{
let parachain_config = prepare_node_config(parachain_config);

let params = new_partial::<RuntimeApi, Executor, BIQ>(&parachain_config, build_import_queue)?;
let (parachain_block_import, mut telemetry, telemetry_worker_handle, frontier_backend) =
params.other;
let net_config = sc_network::config::FullNetworkConfiguration::new(&parachain_config.network);
let net_config =
sc_network::config::FullNetworkConfiguration::<_, _, N>::new(&parachain_config.network);

let client = params.client.clone();
let backend = params.backend.clone();
Expand Down Expand Up @@ -726,7 +728,7 @@ where

let filter_pool: FilterPool = Arc::new(std::sync::Mutex::new(BTreeMap::new()));
let fee_history_cache: FeeHistoryCache = Arc::new(std::sync::Mutex::new(BTreeMap::new()));
let overrides = fc_storage::overrides_handle(client.clone());
let storage_override = Arc::new(StorageOverrideHandler::new(client.clone()));

// Sinks for pubsub notifications.
// Everytime a new subscription is created, a new mpsc channel is added to the sink pool.
Expand Down
78 changes: 78 additions & 0 deletions runtime/astar/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2197,6 +2197,84 @@ impl_runtime_apis! {

Ok(())
}

fn trace_call(
header: &<Block as BlockT>::Header,
from: H160,
to: H160,
data: Vec<u8>,
value: U256,
gas_limit: U256,
max_fee_per_gas: Option<U256>,
max_priority_fee_per_gas: Option<U256>,
nonce: Option<U256>,
access_list: Option<Vec<(H160, Vec<H256>)>>,
) -> Result<(), sp_runtime::DispatchError> {
use moonbeam_evm_tracer::tracer::EvmTracer;

// Initialize block: calls the "on_initialize" hook on every pallet
// in AllPalletsWithSystem.
Executive::initialize_block(header);

EvmTracer::new().trace(|| {
let is_transactional = false;
let validate = true;
let without_base_extrinsic_weight = true;


// Estimated encoded transaction size must be based on the heaviest transaction
// type (EIP1559Transaction) to be compatible with all transaction types.
let mut estimated_transaction_len = data.len() +
// pallet ethereum index: 1
// transact call index: 1
// Transaction enum variant: 1
// chain_id 8 bytes
// nonce: 32
// max_priority_fee_per_gas: 32
// max_fee_per_gas: 32
// gas_limit: 32
// action: 21 (enum varianrt + call address)
// value: 32
// access_list: 1 (empty vec size)
// 65 bytes signature
258;

if access_list.is_some() {
estimated_transaction_len += access_list.encoded_size();
}

let gas_limit = gas_limit.min(u64::MAX.into()).low_u64();

let (weight_limit, proof_size_base_cost) =
match <Runtime as pallet_evm::Config>::GasWeightMapping::gas_to_weight(
gas_limit,
without_base_extrinsic_weight
) {
weight_limit if weight_limit.proof_size() > 0 => {
(Some(weight_limit), Some(estimated_transaction_len as u64))
}
_ => (None, None),
};

let _ = <Runtime as pallet_evm::Config>::Runner::call(
from,
to,
data,
value,
gas_limit,
max_fee_per_gas,
max_priority_fee_per_gas,
nonce,
access_list.unwrap_or_default(),
is_transactional,
validate,
weight_limit,
proof_size_base_cost,
<Runtime as pallet_evm::Config>::config(),
);
});
Ok(())
}
}

#[cfg(feature = "evm-tracing")]
Expand Down
78 changes: 78 additions & 0 deletions runtime/local/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1932,6 +1932,84 @@ impl_runtime_apis! {

Ok(())
}

fn trace_call(
header: &<Block as BlockT>::Header,
from: H160,
to: H160,
data: Vec<u8>,
value: U256,
gas_limit: U256,
max_fee_per_gas: Option<U256>,
max_priority_fee_per_gas: Option<U256>,
nonce: Option<U256>,
access_list: Option<Vec<(H160, Vec<H256>)>>,
) -> Result<(), sp_runtime::DispatchError> {
use moonbeam_evm_tracer::tracer::EvmTracer;

// Initialize block: calls the "on_initialize" hook on every pallet
// in AllPalletsWithSystem.
Executive::initialize_block(header);

EvmTracer::new().trace(|| {
let is_transactional = false;
let validate = true;
let without_base_extrinsic_weight = true;


// Estimated encoded transaction size must be based on the heaviest transaction
// type (EIP1559Transaction) to be compatible with all transaction types.
let mut estimated_transaction_len = data.len() +
// pallet ethereum index: 1
// transact call index: 1
// Transaction enum variant: 1
// chain_id 8 bytes
// nonce: 32
// max_priority_fee_per_gas: 32
// max_fee_per_gas: 32
// gas_limit: 32
// action: 21 (enum varianrt + call address)
// value: 32
// access_list: 1 (empty vec size)
// 65 bytes signature
258;

if access_list.is_some() {
estimated_transaction_len += access_list.encoded_size();
}

let gas_limit = gas_limit.min(u64::MAX.into()).low_u64();

let (weight_limit, proof_size_base_cost) =
match <Runtime as pallet_evm::Config>::GasWeightMapping::gas_to_weight(
gas_limit,
without_base_extrinsic_weight
) {
weight_limit if weight_limit.proof_size() > 0 => {
(Some(weight_limit), Some(estimated_transaction_len as u64))
}
_ => (None, None),
};

let _ = <Runtime as pallet_evm::Config>::Runner::call(
from,
to,
data,
value,
gas_limit,
max_fee_per_gas,
max_priority_fee_per_gas,
nonce,
access_list.unwrap_or_default(),
is_transactional,
validate,
weight_limit,
proof_size_base_cost,
<Runtime as pallet_evm::Config>::config(),
);
});
Ok(())
}
}

#[cfg(feature = "evm-tracing")]
Expand Down
78 changes: 78 additions & 0 deletions runtime/shibuya/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2536,6 +2536,84 @@ impl_runtime_apis! {

Ok(())
}

fn trace_call(
header: &<Block as BlockT>::Header,
from: H160,
to: H160,
data: Vec<u8>,
value: U256,
gas_limit: U256,
max_fee_per_gas: Option<U256>,
max_priority_fee_per_gas: Option<U256>,
nonce: Option<U256>,
access_list: Option<Vec<(H160, Vec<H256>)>>,
) -> Result<(), sp_runtime::DispatchError> {
use moonbeam_evm_tracer::tracer::EvmTracer;

// Initialize block: calls the "on_initialize" hook on every pallet
// in AllPalletsWithSystem.
Executive::initialize_block(header);

EvmTracer::new().trace(|| {
let is_transactional = false;
let validate = true;
let without_base_extrinsic_weight = true;


// Estimated encoded transaction size must be based on the heaviest transaction
// type (EIP1559Transaction) to be compatible with all transaction types.
let mut estimated_transaction_len = data.len() +
// pallet ethereum index: 1
// transact call index: 1
// Transaction enum variant: 1
// chain_id 8 bytes
// nonce: 32
// max_priority_fee_per_gas: 32
// max_fee_per_gas: 32
// gas_limit: 32
// action: 21 (enum varianrt + call address)
// value: 32
// access_list: 1 (empty vec size)
// 65 bytes signature
258;

if access_list.is_some() {
estimated_transaction_len += access_list.encoded_size();
}

let gas_limit = gas_limit.min(u64::MAX.into()).low_u64();

let (weight_limit, proof_size_base_cost) =
match <Runtime as pallet_evm::Config>::GasWeightMapping::gas_to_weight(
gas_limit,
without_base_extrinsic_weight
) {
weight_limit if weight_limit.proof_size() > 0 => {
(Some(weight_limit), Some(estimated_transaction_len as u64))
}
_ => (None, None),
};

let _ = <Runtime as pallet_evm::Config>::Runner::call(
from,
to,
data,
value,
gas_limit,
max_fee_per_gas,
max_priority_fee_per_gas,
nonce,
access_list.unwrap_or_default(),
is_transactional,
validate,
weight_limit,
proof_size_base_cost,
<Runtime as pallet_evm::Config>::config(),
);
});
Ok(())
}
}

#[cfg(feature = "evm-tracing")]
Expand Down
Loading

0 comments on commit 803c3f7

Please sign in to comment.