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

Commit

Permalink
Remove deprecated batch verification (#13799)
Browse files Browse the repository at this point in the history
This removes the deprecated batch verification. This was actually never really activated.
Nevertheless, we need to keep the host functions around to support old runtimes which may import
these host functions. However, we do not give access to these functions anymore. This means that any new
runtime can not call them anymore. The host function implementations we keep will not do batch verification and will
instead fall back to the always existing option of directly verifying the passed signature.
`finish_batch_verification` will return the combined result of all the batch verify calls.

This removes the `TaskExecutorExt` which only existed to support the batch verification. So, any
code that used this extension can just remove the registration of them. It also removes
`SignatureBatching` that was used by `frame-executive` to control the batch verification.
However, there wasn't any `Verify` implementation that called the batch verification functions.
  • Loading branch information
bkchr authored and gpestana committed Apr 20, 2023
1 parent 71eaef9 commit fae245d
Show file tree
Hide file tree
Showing 15 changed files with 76 additions and 530 deletions.
1 change: 0 additions & 1 deletion client/service/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ where
let executor = crate::client::LocalCallExecutor::new(
backend.clone(),
executor,
spawn_handle.clone(),
config.clone(),
execution_extensions,
)?;
Expand Down
11 changes: 1 addition & 10 deletions client/service/src/client/call_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use sc_client_api::{
use sc_executor::{RuntimeVersion, RuntimeVersionOf};
use sp_api::{ProofRecorder, StorageTransactionCache};
use sp_core::{
traits::{CallContext, CodeExecutor, RuntimeCode, SpawnNamed},
traits::{CallContext, CodeExecutor, RuntimeCode},
ExecutionContext,
};
use sp_runtime::{generic::BlockId, traits::Block as BlockT};
Expand All @@ -39,7 +39,6 @@ pub struct LocalCallExecutor<Block: BlockT, B, E> {
executor: E,
wasm_override: Arc<Option<WasmOverride>>,
wasm_substitutes: WasmSubstitutes<Block, E, B>,
spawn_handle: Box<dyn SpawnNamed>,
execution_extensions: Arc<ExecutionExtensions<Block>>,
}

Expand All @@ -52,7 +51,6 @@ where
pub fn new(
backend: Arc<B>,
executor: E,
spawn_handle: Box<dyn SpawnNamed>,
client_config: ClientConfig<Block>,
execution_extensions: ExecutionExtensions<Block>,
) -> sp_blockchain::Result<Self> {
Expand All @@ -72,7 +70,6 @@ where
backend,
executor,
wasm_override: Arc::new(wasm_override),
spawn_handle,
wasm_substitutes,
execution_extensions: Arc::new(execution_extensions),
})
Expand Down Expand Up @@ -142,7 +139,6 @@ where
backend: self.backend.clone(),
executor: self.executor.clone(),
wasm_override: self.wasm_override.clone(),
spawn_handle: self.spawn_handle.clone(),
wasm_substitutes: self.wasm_substitutes.clone(),
execution_extensions: self.execution_extensions.clone(),
}
Expand Down Expand Up @@ -196,7 +192,6 @@ where
call_data,
extensions,
&runtime_code,
self.spawn_handle.clone(),
context,
)
.set_parent_hash(at_hash);
Expand Down Expand Up @@ -256,7 +251,6 @@ where
call_data,
extensions,
&runtime_code,
self.spawn_handle.clone(),
call_context,
)
.with_storage_transaction_cache(storage_transaction_cache.as_deref_mut())
Expand All @@ -272,7 +266,6 @@ where
call_data,
extensions,
&runtime_code,
self.spawn_handle.clone(),
call_context,
)
.with_storage_transaction_cache(storage_transaction_cache.as_deref_mut())
Expand Down Expand Up @@ -313,7 +306,6 @@ where
trie_backend,
&mut Default::default(),
&self.executor,
self.spawn_handle.clone(),
method,
call_data,
&runtime_code,
Expand Down Expand Up @@ -425,7 +417,6 @@ mod tests {
backend: backend.clone(),
executor: executor.clone(),
wasm_override: Arc::new(Some(overrides)),
spawn_handle: Box::new(TaskExecutor::new()),
wasm_substitutes: WasmSubstitutes::new(
Default::default(),
executor.clone(),
Expand Down
9 changes: 2 additions & 7 deletions client/service/src/client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,13 +245,8 @@ where
sc_offchain::OffchainDb::factory_from_backend(&*backend),
);

let call_executor = LocalCallExecutor::new(
backend.clone(),
executor,
spawn_handle.clone(),
config.clone(),
extensions,
)?;
let call_executor =
LocalCallExecutor::new(backend.clone(), executor, config.clone(), extensions)?;

Client::new(
backend,
Expand Down
7 changes: 0 additions & 7 deletions client/service/test/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ fn construct_block(
let mut overlay = OverlayedChanges::default();
let backend_runtime_code = sp_state_machine::backend::BackendRuntimeCode::new(backend);
let runtime_code = backend_runtime_code.runtime_code().expect("Code is part of the backend");
let task_executor = Box::new(TaskExecutor::new());

StateMachine::new(
backend,
Expand All @@ -114,7 +113,6 @@ fn construct_block(
&header.encode(),
Default::default(),
&runtime_code,
task_executor.clone() as Box<_>,
CallContext::Onchain,
)
.execute(ExecutionStrategy::NativeElseWasm)
Expand All @@ -129,7 +127,6 @@ fn construct_block(
&tx.encode(),
Default::default(),
&runtime_code,
task_executor.clone() as Box<_>,
CallContext::Onchain,
)
.execute(ExecutionStrategy::NativeElseWasm)
Expand All @@ -144,7 +141,6 @@ fn construct_block(
&[],
Default::default(),
&runtime_code,
task_executor.clone() as Box<_>,
CallContext::Onchain,
)
.execute(ExecutionStrategy::NativeElseWasm)
Expand Down Expand Up @@ -217,7 +213,6 @@ fn construct_genesis_should_work_with_native() {
&b1data,
Default::default(),
&runtime_code,
TaskExecutor::new(),
CallContext::Onchain,
)
.execute(ExecutionStrategy::NativeElseWasm)
Expand Down Expand Up @@ -251,7 +246,6 @@ fn construct_genesis_should_work_with_wasm() {
&b1data,
Default::default(),
&runtime_code,
TaskExecutor::new(),
CallContext::Onchain,
)
.execute(ExecutionStrategy::AlwaysWasm)
Expand Down Expand Up @@ -285,7 +279,6 @@ fn construct_genesis_with_bad_transaction_should_panic() {
&b1data,
Default::default(),
&runtime_code,
TaskExecutor::new(),
CallContext::Onchain,
)
.execute(ExecutionStrategy::NativeElseWasm);
Expand Down
6 changes: 0 additions & 6 deletions frame/executive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,16 +480,10 @@ where
// any initial checks
Self::initial_checks(&block);

let signature_batching = sp_runtime::SignatureBatching::start();

// execute extrinsics
let (header, extrinsics) = block.deconstruct();
Self::execute_extrinsics_with_book_keeping(extrinsics, *header.number());

if !signature_batching.verify() {
panic!("Signature verification failed.");
}

// any final checks
Self::final_checks(&header);
}
Expand Down
1 change: 0 additions & 1 deletion primitives/api/test/tests/runtime_calls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ fn record_proof_works() {
&backend,
&mut overlay,
&executor,
sp_core::testing::TaskExecutor::new(),
"Core_execute_block",
&block.encode(),
&runtime_code,
Expand Down
12 changes: 0 additions & 12 deletions primitives/core/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,18 +169,6 @@ impl ReadRuntimeVersionExt {
}
}

sp_externalities::decl_extension! {
/// Task executor extension.
pub struct TaskExecutorExt(Box<dyn SpawnNamed>);
}

impl TaskExecutorExt {
/// New instance of task executor extension.
pub fn new(spawn_handle: impl SpawnNamed + Send + 'static) -> Self {
Self(Box::new(spawn_handle))
}
}

/// Something that can spawn tasks (blocking and non-blocking) with an assigned name
/// and optional group.
#[dyn_clonable::clonable]
Expand Down
Loading

0 comments on commit fae245d

Please sign in to comment.