* ethcore: cleanup after #11531 * fix verification benches * ethcore: remove enact_verified * ethcore: replace PreverifiedBlock with a tuple * ethcore: more descriptive Vec<u8> type alias
This commit is contained in:
parent
3ccfe735aa
commit
5c3c979798
@ -296,7 +296,7 @@ impl Importer {
|
||||
trace_time!("import_verified_blocks");
|
||||
let start = Instant::now();
|
||||
|
||||
for mut block in blocks {
|
||||
for (block, block_bytes) in blocks {
|
||||
let hash = block.header.hash();
|
||||
|
||||
let is_invalid = invalid_blocks.contains(block.header.parent_hash());
|
||||
@ -305,12 +305,6 @@ impl Importer {
|
||||
continue;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------
|
||||
// NOTE: this will remove the RLP bytes from the
|
||||
// `PreverifiedBlock` so be careful not to use the bytes
|
||||
// anywhere after this, it will be an empty `Vec`.
|
||||
// --------------------------------------------------------
|
||||
let block_bytes = std::mem::take(&mut block.bytes);
|
||||
match self.check_and_lock_block(block, client) {
|
||||
Ok((locked_block, pending)) => {
|
||||
imported_blocks.push(hash);
|
||||
|
@ -76,10 +76,11 @@ pub struct PreverifiedBlock {
|
||||
pub transactions: Vec<SignedTransaction>,
|
||||
/// Populated block uncles
|
||||
pub uncles: Vec<Header>,
|
||||
/// Block bytes
|
||||
pub bytes: Bytes,
|
||||
}
|
||||
|
||||
/// The RLP representation of a block.
|
||||
pub type BlockRlpRepresentation = Vec<u8>;
|
||||
|
||||
/// Brief info about inserted block.
|
||||
#[derive(Clone)]
|
||||
pub struct BlockInfo {
|
||||
|
@ -119,7 +119,7 @@ fn block_verification(c: &mut Criterion) {
|
||||
|
||||
// Phase 3 verification
|
||||
let block = Unverified::from_rlp(rlp_8481476.clone()).expect(PROOF);
|
||||
let preverified = verification::verify_block_unordered(block, ðash, true).expect(PROOF);
|
||||
let preverified = verification::verify_block_unordered(block, ðash, true).expect(PROOF).0;
|
||||
let parent = Unverified::from_rlp(rlp_8481475.clone()).expect(PROOF);
|
||||
|
||||
let mut block_provider = TestBlockChain::new();
|
||||
|
@ -81,7 +81,7 @@ pub mod blocks {
|
||||
|
||||
use engine::Engine;
|
||||
use common_types::{
|
||||
block::PreverifiedBlock,
|
||||
block::{BlockRlpRepresentation, PreverifiedBlock},
|
||||
errors::{EthcoreError as Error, BlockError},
|
||||
verification::Unverified,
|
||||
};
|
||||
@ -96,7 +96,7 @@ pub mod blocks {
|
||||
impl Kind for Blocks {
|
||||
type Input = Unverified;
|
||||
type Unverified = Unverified;
|
||||
type Verified = PreverifiedBlock;
|
||||
type Verified = (PreverifiedBlock, BlockRlpRepresentation);
|
||||
|
||||
fn create(
|
||||
input: Self::Input,
|
||||
@ -146,21 +146,21 @@ pub mod blocks {
|
||||
}
|
||||
}
|
||||
|
||||
impl BlockLike for PreverifiedBlock {
|
||||
impl BlockLike for (PreverifiedBlock, BlockRlpRepresentation) {
|
||||
fn hash(&self) -> H256 {
|
||||
self.header.hash()
|
||||
self.0.header.hash()
|
||||
}
|
||||
|
||||
fn raw_hash(&self) -> H256 {
|
||||
keccak_hash::keccak(&self.bytes)
|
||||
keccak_hash::keccak(&self.1)
|
||||
}
|
||||
|
||||
fn parent_hash(&self) -> H256 {
|
||||
*self.header.parent_hash()
|
||||
*self.0.header.parent_hash()
|
||||
}
|
||||
|
||||
fn difficulty(&self) -> U256 {
|
||||
*self.header.difficulty()
|
||||
*self.0.header.difficulty()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ use common_types::{
|
||||
header::Header,
|
||||
errors::{EthcoreError as Error, BlockError},
|
||||
engines::MAX_UNCLE_AGE,
|
||||
block::PreverifiedBlock,
|
||||
block::{BlockRlpRepresentation, PreverifiedBlock},
|
||||
verification::Unverified,
|
||||
};
|
||||
|
||||
@ -78,8 +78,12 @@ pub fn verify_block_basic(block: &Unverified, engine: &dyn Engine, check_seal: b
|
||||
|
||||
/// Phase 2 verification. Perform costly checks such as transaction signatures and block nonce for ethash.
|
||||
/// Still operates on a individual block
|
||||
/// Returns a `PreverifiedBlock` structure populated with transactions
|
||||
pub fn verify_block_unordered(block: Unverified, engine: &dyn Engine, check_seal: bool) -> Result<PreverifiedBlock, Error> {
|
||||
/// Returns a `PreverifiedBlock` structure populated with transactions along with the RLP representation of the block.
|
||||
pub fn verify_block_unordered(
|
||||
block: Unverified,
|
||||
engine: &dyn Engine,
|
||||
check_seal: bool,
|
||||
) -> Result<(PreverifiedBlock, BlockRlpRepresentation), Error> {
|
||||
let header = block.header;
|
||||
if check_seal {
|
||||
engine.verify_block_unordered(&header)?;
|
||||
@ -107,12 +111,13 @@ pub fn verify_block_unordered(block: Unverified, engine: &dyn Engine, check_seal
|
||||
})
|
||||
.collect::<Result<Vec<_>, Error>>()?;
|
||||
|
||||
Ok(PreverifiedBlock {
|
||||
Ok((PreverifiedBlock {
|
||||
header,
|
||||
transactions,
|
||||
uncles: block.uncles,
|
||||
bytes: block.bytes,
|
||||
})
|
||||
},
|
||||
block.bytes,
|
||||
))
|
||||
}
|
||||
|
||||
/// Parameters for full verification of block family
|
||||
@ -502,7 +507,6 @@ mod tests {
|
||||
header,
|
||||
transactions,
|
||||
uncles: block.uncles,
|
||||
bytes: bytes.to_vec(),
|
||||
};
|
||||
|
||||
let full_params = FullFamilyParams {
|
||||
|
Loading…
Reference in New Issue
Block a user