Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Remove native execution, grow heap as needed #8893

Closed
wants to merge 9 commits into from
Closed
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
5 changes: 2 additions & 3 deletions bin/node-template/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ pub fn new_partial(config: &Configuration) -> Result<sc_service::PartialComponen
Ok((timestamp, slot))
},
spawner: &task_manager.spawn_essential_handle(),
can_author_with: sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()),
can_author_with: Default::default(), // TODO: can_author_with
registry: config.prometheus_registry(),
check_for_equivocation: Default::default(),
telemetry: telemetry.as_ref().map(|x| x.handle()),
Expand Down Expand Up @@ -215,8 +215,7 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
telemetry.as_ref().map(|x| x.handle()),
);

let can_author_with =
sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone());
let can_author_with = true;// TODO: can_author_with

let slot_duration = sc_consensus_aura::slot_duration(&*client)?;
let raw_slot_duration = slot_duration.slot_duration();
Expand Down
11 changes: 0 additions & 11 deletions bin/node-template/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ use sp_consensus_aura::sr25519::AuthorityId as AuraId;
use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList};
use pallet_grandpa::fg_primitives;
use sp_version::RuntimeVersion;
#[cfg(feature = "std")]
use sp_version::NativeVersion;

// A few exports that help ease life for downstream crates.
#[cfg(any(feature = "std", test))]
Expand Down Expand Up @@ -127,15 +125,6 @@ pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);
pub const HOURS: BlockNumber = MINUTES * 60;
pub const DAYS: BlockNumber = HOURS * 24;

/// The version information used to identify this runtime when compiled natively.
#[cfg(feature = "std")]
pub fn native_version() -> NativeVersion {
NativeVersion {
runtime_version: VERSION,
can_author_with: Default::default(),
}
}

const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);

parameter_types! {
Expand Down
5 changes: 2 additions & 3 deletions bin/node/cli/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ pub fn new_partial(
},
&task_manager.spawn_essential_handle(),
config.prometheus_registry(),
sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()),
Default::default(), // TODO: can_author_with
telemetry.as_ref().map(|x| x.handle()),
)?;

Expand Down Expand Up @@ -298,8 +298,7 @@ pub fn new_full_base(
telemetry.as_ref().map(|x| x.handle()),
);

let can_author_with =
sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone());
let can_author_with = true; // TODO: can_author_with

let client_clone = client.clone();
let slot_duration = babe_link.config().slot_duration();
Expand Down
20 changes: 5 additions & 15 deletions bin/node/executor/benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@

use codec::{Decode, Encode};
use criterion::{BatchSize, Criterion, criterion_group, criterion_main};
use node_executor::Executor;
use node_primitives::{BlockNumber, Hash};
use node_runtime::{
Block, BuildStorage, Call, CheckedExtrinsic, GenesisConfig, Header, UncheckedExtrinsic,
};
use node_runtime::constants::currency::*;
use node_testing::keyring::*;
use sp_core::{NativeOrEncoded, NeverNativeValue};
use sp_core::storage::well_known_keys;
use sp_core::traits::{CodeExecutor, RuntimeCode};
use frame_support::Hashable;
Expand All @@ -51,12 +49,6 @@ const HEAP_PAGES: u64 = 20;

type TestExternalities<H> = CoreTestExternalities<H, u64>;

#[derive(Debug)]
enum ExecutionMethod {
Native,
Wasm(WasmExecutionMethod),
}

fn sign(xt: CheckedExtrinsic) -> UncheckedExtrinsic {
node_testing::keyring::sign(xt, SPEC_VERSION, TRANSACTION_VERSION, GENESIS_HASH)
}
Expand Down Expand Up @@ -103,7 +95,7 @@ fn construct_block<E: Externalities>(
};

// execute the block to get the real header.
executor.call::<NeverNativeValue, fn() -> _>(
executor.call(
ext,
&runtime_code,
"Core_initialize_block",
Expand All @@ -113,7 +105,7 @@ fn construct_block<E: Externalities>(
).0.unwrap();

for i in extrinsics.iter() {
executor.call::<NeverNativeValue, fn() -> _>(
executor.call(
ext,
&runtime_code,
"BlockBuilder_apply_extrinsic",
Expand All @@ -123,17 +115,15 @@ fn construct_block<E: Externalities>(
).0.unwrap();
}

let header = match executor.call::<NeverNativeValue, fn() -> _>(
let encoded_header = executor.call(
ext,
&runtime_code,
"BlockBuilder_finalize_block",
&[0u8;0],
true,
None,
).0.unwrap() {
NativeOrEncoded::Native(_) => unreachable!(),
NativeOrEncoded::Encoded(h) => Header::decode(&mut &h[..]).unwrap(),
};
).0.unwrap();
let header = Header::decode(&mut &encoded_header[..]).unwrap();

let hash = header.blake2_256();
(Block { header, extrinsics }.encode(), hash.into())
Expand Down
Loading