Improve CodeExecutor (#2358)

Since `sp-state-machine` and `GenesisConfigBuilderRuntimeCaller` always
set `use_native` to be false.
We should remove this param and make `NativeElseWasmExecutor` behave
like its name.
It could make the above components use the correct execution strategy.

Maybe polkadot do not need about `NativeElseWasmExecutor` anymore. But
it is still needed by other chains and it's useful for debugging.

---------

Co-authored-by: Bastian Köcher <git@kchr.de>
Co-authored-by: command-bot <>
Co-authored-by: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com>
This commit is contained in:
yjh
2023-11-29 21:48:32 +08:00
committed by GitHub
parent 63ac2471aa
commit f2fe6a4c56
9 changed files with 56 additions and 81 deletions
+6 -8
View File
@@ -95,7 +95,7 @@ fn fee_multiplier_increases_and_decreases_on_big_weight() {
);
// execute a big block.
executor_call(&mut t, "Core_execute_block", &block1.0, true).0.unwrap();
executor_call(&mut t, "Core_execute_block", &block1.0).0.unwrap();
// weight multiplier is increased for next block.
t.execute_with(|| {
@@ -106,7 +106,7 @@ fn fee_multiplier_increases_and_decreases_on_big_weight() {
});
// execute a big block.
executor_call(&mut t, "Core_execute_block", &block2.0, true).0.unwrap();
executor_call(&mut t, "Core_execute_block", &block2.0).0.unwrap();
// weight multiplier is increased for next block.
t.execute_with(|| {
@@ -151,12 +151,10 @@ fn transaction_fee_is_correct() {
function: RuntimeCall::Balances(default_transfer_call()),
});
let r =
executor_call(&mut t, "Core_initialize_block", &vec![].and(&from_block_number(1u32)), true)
.0;
let r = executor_call(&mut t, "Core_initialize_block", &vec![].and(&from_block_number(1u32))).0;
assert!(r.is_ok());
let r = executor_call(&mut t, "BlockBuilder_apply_extrinsic", &vec![].and(&xt.clone()), true).0;
let r = executor_call(&mut t, "BlockBuilder_apply_extrinsic", &vec![].and(&xt.clone())).0;
assert!(r.is_ok());
t.execute_with(|| {
@@ -247,7 +245,7 @@ fn block_weight_capacity_report() {
len / 1024 / 1024,
);
let r = executor_call(&mut t, "Core_execute_block", &block.0, true).0;
let r = executor_call(&mut t, "Core_execute_block", &block.0).0;
println!(" || Result = {:?}", r);
assert!(r.is_ok());
@@ -310,7 +308,7 @@ fn block_length_capacity_report() {
len / 1024 / 1024,
);
let r = executor_call(&mut t, "Core_execute_block", &block.0, true).0;
let r = executor_call(&mut t, "Core_execute_block", &block.0).0;
println!(" || Result = {:?}", r);
assert!(r.is_ok());