fix aura backcompat: revert to manual encoding/decoding of transition proofs (#6665)

This commit is contained in:
Robert Habermeier 2017-10-06 17:36:26 +02:00 committed by Arkadiy Paronyan
parent 1b45870af8
commit 59365b0133

View File

@ -18,8 +18,10 @@
use bigint::hash::H256; use bigint::hash::H256;
use rlp::{Encodable, Decodable, DecoderError, RlpStream, UntrustedRlp};
/// A full epoch transition. /// A full epoch transition.
#[derive(Debug, Clone, RlpEncodable, RlpDecodable)] #[derive(Debug, Clone)]
pub struct Transition { pub struct Transition {
/// Block hash at which the transition occurred. /// Block hash at which the transition occurred.
pub block_hash: H256, pub block_hash: H256,
@ -29,14 +31,46 @@ pub struct Transition {
pub proof: Vec<u8>, pub proof: Vec<u8>,
} }
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<Self, DecoderError> {
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. /// An epoch transition pending a finality proof.
/// Not all transitions need one. /// Not all transitions need one.
#[derive(RlpEncodableWrapper, RlpDecodableWrapper)]
pub struct PendingTransition { pub struct PendingTransition {
/// "transition/epoch" proof from the engine. /// "transition/epoch" proof from the engine.
pub proof: Vec<u8>, pub proof: Vec<u8>,
} }
impl Encodable for PendingTransition {
fn rlp_append(&self, s: &mut RlpStream) {
s.append(&self.proof);
}
}
impl Decodable for PendingTransition {
fn decode(rlp: &UntrustedRlp) -> Result<Self, DecoderError> {
Ok(PendingTransition {
proof: rlp.as_val()?,
})
}
}
/// Verifier for all blocks within an epoch with self-contained state. /// Verifier for all blocks within an epoch with self-contained state.
pub trait EpochVerifier<M: ::parity_machine::Machine>: Send + Sync { pub trait EpochVerifier<M: ::parity_machine::Machine>: Send + Sync {
/// Lightly verify the next block header. /// Lightly verify the next block header.