mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 08:11:04 +00:00
* Revert "Build block without checking signatures (#4916)"
This reverts commit e50f610907.
* Some further clean ups
This commit is contained in:
@@ -203,7 +203,7 @@ impl<A, B, Block, C> ProposerInner<B, Block, C, A>
|
||||
inherent_data
|
||||
)?
|
||||
{
|
||||
block_builder.push_trusted(extrinsic)?;
|
||||
block_builder.push(extrinsic)?;
|
||||
}
|
||||
|
||||
// proceed with transactions
|
||||
@@ -226,7 +226,7 @@ impl<A, B, Block, C> ProposerInner<B, Block, C, A>
|
||||
let pending_tx_data = pending_tx.data().clone();
|
||||
let pending_tx_hash = pending_tx.hash().clone();
|
||||
trace!("[{:?}] Pushing to the block.", pending_tx_hash);
|
||||
match sc_block_builder::BlockBuilder::push_trusted(&mut block_builder, pending_tx_data) {
|
||||
match sc_block_builder::BlockBuilder::push(&mut block_builder, pending_tx_data) {
|
||||
Ok(()) => {
|
||||
debug!("[{:?}] Pushed to the block.", pending_tx_hash);
|
||||
}
|
||||
|
||||
@@ -145,43 +145,15 @@ where
|
||||
///
|
||||
/// This will ensure the extrinsic can be validly executed (by executing it).
|
||||
pub fn push(&mut self, xt: <Block as BlockT>::Extrinsic) -> Result<(), ApiErrorFor<A, Block>> {
|
||||
self.push_internal(xt, false)
|
||||
}
|
||||
|
||||
/// Push onto the block's list of extrinsics.
|
||||
///
|
||||
/// This will treat incoming extrinsic `xt` as trusted and skip signature check (for signed transactions).
|
||||
pub fn push_trusted(&mut self, xt: <Block as BlockT>::Extrinsic) -> Result<(), ApiErrorFor<A, Block>> {
|
||||
self.push_internal(xt, true)
|
||||
}
|
||||
|
||||
fn push_internal(&mut self, xt: <Block as BlockT>::Extrinsic, skip_signature: bool) -> Result<(), ApiErrorFor<A, Block>> {
|
||||
let block_id = &self.block_id;
|
||||
let extrinsics = &mut self.extrinsics;
|
||||
|
||||
let use_trusted = skip_signature && self
|
||||
.api
|
||||
.has_api_with::<dyn BlockBuilderApi<Block, Error = ApiErrorFor<A, Block>>, _>(
|
||||
block_id,
|
||||
|version| version >= 5,
|
||||
)?;
|
||||
|
||||
self.api.map_api_result(|api| {
|
||||
let apply_result = if use_trusted {
|
||||
api.apply_trusted_extrinsic_with_context(
|
||||
block_id,
|
||||
ExecutionContext::BlockConstruction,
|
||||
xt.clone(),
|
||||
)?
|
||||
} else {
|
||||
api.apply_extrinsic_with_context(
|
||||
block_id,
|
||||
ExecutionContext::BlockConstruction,
|
||||
xt.clone(),
|
||||
)?
|
||||
};
|
||||
|
||||
match apply_result {
|
||||
match api.apply_extrinsic_with_context(
|
||||
block_id,
|
||||
ExecutionContext::BlockConstruction,
|
||||
xt.clone(),
|
||||
)? {
|
||||
Ok(_) => {
|
||||
extrinsics.push(xt);
|
||||
Ok(())
|
||||
|
||||
@@ -402,7 +402,7 @@ fn should_return_runtime_version() {
|
||||
|
||||
let result = "{\"specName\":\"test\",\"implName\":\"parity-test\",\"authoringVersion\":1,\
|
||||
\"specVersion\":1,\"implVersion\":2,\"apis\":[[\"0xdf6acb689907609b\",2],\
|
||||
[\"0x37e397fc7c91f5e4\",1],[\"0xd2bc9897eed08f15\",1],[\"0x40fe3ad401f8959a\",5],\
|
||||
[\"0x37e397fc7c91f5e4\",1],[\"0xd2bc9897eed08f15\",1],[\"0x40fe3ad401f8959a\",4],\
|
||||
[\"0xc6e9a76309f39b09\",1],[\"0xdd718d5cc53262d4\",1],[\"0xcbca25e39f142387\",1],\
|
||||
[\"0xf78b278be53f454c\",2],[\"0xab3c0572291feb8b\",1],[\"0xbc9d89904f5b923f\",1]]}";
|
||||
|
||||
|
||||
@@ -656,7 +656,6 @@ mod tests {
|
||||
use futures::executor::block_on;
|
||||
use sp_consensus::SelectChain;
|
||||
use sp_runtime::traits::BlindCheckable;
|
||||
use sp_runtime::generic::CheckSignature;
|
||||
use substrate_test_runtime_client::{prelude::*, runtime::{Extrinsic, Transfer}};
|
||||
use sc_transaction_pool::{BasicPool, FullChainApi};
|
||||
|
||||
@@ -685,7 +684,7 @@ mod tests {
|
||||
|
||||
// then
|
||||
assert_eq!(transactions.len(), 1);
|
||||
assert!(transactions[0].1.clone().check(CheckSignature::Yes).is_ok());
|
||||
assert!(transactions[0].1.clone().check().is_ok());
|
||||
// this should not panic
|
||||
let _ = transactions[0].1.transfer();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user