Remove RefCell from Header (#8227)
* Cache RLP and header hashes. * Refactor header - WiP * Avoid decoding laster header. * Pre-compute hashes for Sealed/Locked block. * Use accrue bloom. Closes ##8241
This commit is contained in:
committed by
Marek Kotewicz
parent
d477670cb9
commit
9f775a7673
@@ -201,7 +201,7 @@ mod tests {
|
||||
"0000000000000000000000007d577a597b2742b498cb5cf0c26cdcd726d39e6e"
|
||||
);
|
||||
// Simulate a misbehaving validator by handling a double proposal.
|
||||
let header = client.best_block_header().decode();
|
||||
let header = client.best_block_header();
|
||||
assert!(client.engine().verify_block_family(&header, &header).is_err());
|
||||
// Seal a block.
|
||||
client.engine().step();
|
||||
|
||||
@@ -20,7 +20,7 @@ use std::sync::{Weak, Arc};
|
||||
use hash::keccak;
|
||||
|
||||
use ethereum_types::{H256, U256, Address, Bloom};
|
||||
use parking_lot::{Mutex, RwLock};
|
||||
use parking_lot::RwLock;
|
||||
|
||||
use bytes::Bytes;
|
||||
use memory_cache::MemoryLruCache;
|
||||
@@ -53,19 +53,19 @@ lazy_static! {
|
||||
// only "first" proofs are such.
|
||||
struct StateProof {
|
||||
contract_address: Address,
|
||||
header: Mutex<Header>,
|
||||
header: Header,
|
||||
provider: validator_set::ValidatorSet,
|
||||
}
|
||||
|
||||
impl ::engines::StateDependentProof<EthereumMachine> for StateProof {
|
||||
fn generate_proof(&self, caller: &Call) -> Result<Vec<u8>, String> {
|
||||
prove_initial(&self.provider, self.contract_address, &*self.header.lock(), caller)
|
||||
prove_initial(&self.provider, self.contract_address, &self.header, caller)
|
||||
}
|
||||
|
||||
fn check_proof(&self, machine: &EthereumMachine, proof: &[u8]) -> Result<(), String> {
|
||||
let (header, state_items) = decode_first_proof(&UntrustedRlp::new(proof))
|
||||
.map_err(|e| format!("proof incorrectly encoded: {}", e))?;
|
||||
if &header != &*self.header.lock(){
|
||||
if &header != &self.header {
|
||||
return Err("wrong header in proof".into());
|
||||
}
|
||||
|
||||
@@ -325,7 +325,7 @@ impl ValidatorSet for ValidatorSafeContract {
|
||||
debug!(target: "engine", "signalling transition to fresh contract.");
|
||||
let state_proof = Arc::new(StateProof {
|
||||
contract_address: self.contract_address,
|
||||
header: Mutex::new(header.clone()),
|
||||
header: header.clone(),
|
||||
provider: validator_set::ValidatorSet::default(),
|
||||
});
|
||||
return ::engines::EpochChange::Yes(::engines::Proof::WithState(state_proof as Arc<_>));
|
||||
|
||||
Reference in New Issue
Block a user