From 59365b0133be777b1a1ec6cd4e1b64596eb04eb9 Mon Sep 17 00:00:00 2001 From: Robert Habermeier Date: Fri, 6 Oct 2017 17:36:26 +0200 Subject: [PATCH] fix aura backcompat: revert to manual encoding/decoding of transition proofs (#6665) --- ethcore/src/engines/epoch.rs | 38 ++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/ethcore/src/engines/epoch.rs b/ethcore/src/engines/epoch.rs index b5ffd8a2d..c765f727d 100644 --- a/ethcore/src/engines/epoch.rs +++ b/ethcore/src/engines/epoch.rs @@ -18,8 +18,10 @@ use bigint::hash::H256; +use rlp::{Encodable, Decodable, DecoderError, RlpStream, UntrustedRlp}; + /// A full epoch transition. -#[derive(Debug, Clone, RlpEncodable, RlpDecodable)] +#[derive(Debug, Clone)] pub struct Transition { /// Block hash at which the transition occurred. pub block_hash: H256, @@ -29,14 +31,46 @@ pub struct Transition { pub proof: Vec, } +impl Encodable for Transition { + fn rlp_append(&self, s: &mut RlpStream) { + s.begin_list(3) + .append(&self.block_hash) + .append(&self.block_number) + .append(&self.proof); + } +} + +impl Decodable for Transition { + fn decode(rlp: &UntrustedRlp) -> Result { + Ok(Transition { + block_hash: rlp.val_at(0)?, + block_number: rlp.val_at(1)?, + proof: rlp.val_at(2)?, + }) + } +} + /// An epoch transition pending a finality proof. /// Not all transitions need one. -#[derive(RlpEncodableWrapper, RlpDecodableWrapper)] pub struct PendingTransition { /// "transition/epoch" proof from the engine. pub proof: Vec, } +impl Encodable for PendingTransition { + fn rlp_append(&self, s: &mut RlpStream) { + s.append(&self.proof); + } +} + +impl Decodable for PendingTransition { + fn decode(rlp: &UntrustedRlp) -> Result { + Ok(PendingTransition { + proof: rlp.as_val()?, + }) + } +} + /// Verifier for all blocks within an epoch with self-contained state. pub trait EpochVerifier: Send + Sync { /// Lightly verify the next block header.