Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Remove AuxiliaryData/AuxiliaryRequest #11533

Merged
merged 3 commits into from
Mar 3, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove AuxiliaryData
dvdplm committed Mar 2, 2020
commit 5b0a2d52ee80b99fe022e013e5b400a6002268d5
4 changes: 2 additions & 2 deletions ethcore/engine/src/engine.rs
Original file line number Diff line number Diff line change
@@ -28,9 +28,9 @@ use common_types::{
Seal, SealingState, Headers, PendingTransitionStore,
params::CommonParams,
machine as machine_types,
machine::AuxiliaryData,
},
errors::{EthcoreError as Error, EngineError},
receipt::Receipt,
snapshot::Snapshotting,
transaction::{self, SignedTransaction, UnverifiedTransaction},
};
@@ -254,7 +254,7 @@ pub trait Engine: Sync + Send {
/// Return `Yes` or `No` when the answer is definitively known.
///
/// Should not interact with state.
fn signals_epoch_end<'a>(&self, _header: &Header, _aux: AuxiliaryData<'a>) -> EpochChange {
fn signals_epoch_end<'a>(&self, _header: &Header, _receipts: Option<&'a [Receipt]>) -> EpochChange {
EpochChange::No
}

7 changes: 4 additions & 3 deletions ethcore/engines/authority-round/src/lib.rs
Original file line number Diff line number Diff line change
@@ -71,10 +71,11 @@ use common_types::{
PendingTransitionStore,
Seal,
SealingState,
machine::{Call, AuxiliaryData},
machine::Call,
},
errors::{BlockError, EthcoreError as Error, EngineError},
ids::BlockId,
receipt::Receipt,
snapshot::Snapshotting,
transaction::SignedTransaction,
};
@@ -1766,11 +1767,11 @@ impl Engine for AuthorityRound {
.map(|set_proof| combine_proofs(0, &set_proof, &[]))
}

fn signals_epoch_end(&self, header: &Header, aux: AuxiliaryData) -> engine::EpochChange {
fn signals_epoch_end(&self, header: &Header, receipts: Option<&[Receipt]>) -> engine::EpochChange {
if self.immediate_transitions { return engine::EpochChange::No }

let first = header.number() == 0;
self.validators.signals_epoch_end(first, header, aux)
self.validators.signals_epoch_end(first, header, receipts)
}

fn is_epoch_end_light(
9 changes: 5 additions & 4 deletions ethcore/engines/basic-authority/src/lib.rs
Original file line number Diff line number Diff line change
@@ -26,9 +26,10 @@ use common_types::{
SealingState,
Seal,
params::CommonParams,
machine::{AuxiliaryData, Call},
machine::Call,
},
errors::{EngineError, BlockError, EthcoreError as Error},
receipt::Receipt,
};
use client_traits::EngineClient;
use ethereum_types::{H256, H520};
@@ -142,16 +143,16 @@ impl Engine for BasicAuthority {
}

#[cfg(not(any(test, feature = "test-helpers")))]
fn signals_epoch_end(&self, _header: &Header, _auxiliary: AuxiliaryData) -> engine::EpochChange {
fn signals_epoch_end(&self, _header: &Header, _receipts: Option<&[Receipt]>) -> engine::EpochChange {
// don't bother signalling even though a contract might try.
engine::EpochChange::No
}

#[cfg(any(test, feature = "test-helpers"))]
fn signals_epoch_end(&self, header: &Header, auxiliary: AuxiliaryData) -> engine::EpochChange {
fn signals_epoch_end(&self, header: &Header, receipts: Option<&[Receipt]>) -> engine::EpochChange {
// in test mode, always signal even though they don't be finalized.
let first = header.number() == 0;
self.validators.signals_epoch_end(first, header, auxiliary)
self.validators.signals_epoch_end(first, header, receipts)
}

fn is_epoch_end(
7 changes: 4 additions & 3 deletions ethcore/engines/validator-set/src/contract.rs
Original file line number Diff line number Diff line change
@@ -30,7 +30,8 @@ use common_types::{
ids::BlockId,
header::Header,
errors::EthcoreError,
engines::machine::{Call, AuxiliaryData},
engines::machine::Call,
receipt::Receipt,
transaction,
};

@@ -141,9 +142,9 @@ impl ValidatorSet for ValidatorContract {
&self,
first: bool,
header: &Header,
aux: AuxiliaryData,
receipts: Option<&[Receipt]>,
) -> engine::EpochChange {
self.validators.signals_epoch_end(first, header, aux)
self.validators.signals_epoch_end(first, header, receipts)
}

fn epoch_set(&self, first: bool, machine: &Machine, number: BlockNumber, proof: &[u8]) -> Result<(SimpleList, Option<H256>), EthcoreError> {
5 changes: 3 additions & 2 deletions ethcore/engines/validator-set/src/lib.rs
Original file line number Diff line number Diff line change
@@ -31,7 +31,8 @@ use common_types::{
header::Header,
ids::BlockId,
errors::EthcoreError,
engines::machine::{Call, AuxiliaryData},
engines::machine::Call,
receipt::Receipt,
};
use engine::SystemCall;
use ethereum_types::{H256, Address};
@@ -144,7 +145,7 @@ pub trait ValidatorSet: Send + Sync + 'static {
&self,
first: bool,
header: &Header,
aux: AuxiliaryData,
receipts: Option<&[Receipt]>,
) -> engine::EpochChange;

/// Recover the validator set from the given proof, the block number, and
7 changes: 4 additions & 3 deletions ethcore/engines/validator-set/src/multi.rs
Original file line number Diff line number Diff line change
@@ -24,7 +24,8 @@ use common_types::{
header::Header,
ids::BlockId,
errors::EthcoreError,
engines::machine::{Call, AuxiliaryData},
engines::machine::Call,
receipt::Receipt,
};
use client_traits::EngineClient;
use ethereum_types::{H256, Address};
@@ -117,13 +118,13 @@ impl ValidatorSet for Multi {
set.is_epoch_end(first, chain_head)
}

fn signals_epoch_end(&self, _first: bool, header: &Header, aux: AuxiliaryData)
fn signals_epoch_end(&self, _first: bool, header: &Header, receipts: Option<&[Receipt]>)
-> engine::EpochChange
{
let (set_block, set) = self.correct_set_by_number(header.number());
let first = set_block == header.number();

set.signals_epoch_end(first, header, aux)
set.signals_epoch_end(first, header, receipts)
}

fn epoch_set(&self, _first: bool, machine: &Machine, number: BlockNumber, proof: &[u8]) -> Result<(super::SimpleList, Option<H256>), EthcoreError> {
7 changes: 2 additions & 5 deletions ethcore/engines/validator-set/src/safe_contract.rs
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ use common_types::{
errors::{EngineError, EthcoreError, BlockError},
ids::BlockId,
log_entry::LogEntry,
engines::machine::{Call, AuxiliaryData},
engines::machine::Call,
receipt::Receipt,
transaction::{self, Action, Transaction},
};
@@ -438,11 +438,9 @@ impl ValidatorSet for ValidatorSafeContract {
None // no immediate transitions to contract.
}

fn signals_epoch_end(&self, first: bool, header: &Header, aux: AuxiliaryData)
fn signals_epoch_end(&self, first: bool, header: &Header, receipts: Option<&[Receipt]>)
-> engine::EpochChange
{
let receipts = aux.receipts;

// transition to the first block of a contract requires finality but has no log event.
if first {
debug!(target: "engine", "signalling transition to fresh contract.");
@@ -642,7 +640,6 @@ mod tests {
use accounts::AccountProvider;
use common_types::{
ids::BlockId,
engines::machine::AuxiliaryRequest,
header::Header,
log_entry::LogEntry,
transaction::{Transaction, Action},
7 changes: 3 additions & 4 deletions ethcore/engines/validator-set/src/simple_list.rs
Original file line number Diff line number Diff line change
@@ -21,7 +21,8 @@ use common_types::{
ids::BlockId,
header::Header,
errors::EthcoreError,
engines::machine::{Call, AuxiliaryData},
engines::machine::Call,
receipt::Receipt,
};
use ethereum_types::{H256, Address};
use log::warn;
@@ -89,9 +90,7 @@ impl ValidatorSet for SimpleList {
}
}

fn signals_epoch_end(&self, _: bool, _: &Header, _: AuxiliaryData)
-> engine::EpochChange
{
fn signals_epoch_end(&self, _: bool, _: &Header, _: Option<&[Receipt]>) -> engine::EpochChange {
engine::EpochChange::No
}

7 changes: 3 additions & 4 deletions ethcore/engines/validator-set/src/test.rs
Original file line number Diff line number Diff line change
@@ -27,7 +27,8 @@ use common_types::{
ids::BlockId,
header::Header,
errors::EthcoreError,
engines::machine::{Call, AuxiliaryData},
engines::machine::Call,
receipt::Receipt,
};
use ethereum_types::{H256, Address};
use machine::Machine;
@@ -94,9 +95,7 @@ impl ValidatorSet for TestSet {

fn is_epoch_end(&self, _first: bool, _chain_head: &Header) -> Option<Vec<u8>> { None }

fn signals_epoch_end(&self, _: bool, _: &Header, _: AuxiliaryData)
-> engine::EpochChange
{
fn signals_epoch_end(&self, _: bool, _: &Header, _: Option<&[Receipt]>) -> engine::EpochChange {
engine::EpochChange::No
}

8 changes: 1 addition & 7 deletions ethcore/light/src/client/mod.rs
Original file line number Diff line number Diff line change
@@ -474,18 +474,12 @@ impl<T: ChainDataFetcher> Client<T> {
}

fn check_epoch_signal(&self, verified_header: &Header) -> Result<Option<Proof>, T::Error> {
use common_types::engines::machine::AuxiliaryData;

let mut receipts: Option<Vec<_>> = None;

loop {

let is_signal = {
dvdplm marked this conversation as resolved.
Show resolved Hide resolved
let auxiliary = AuxiliaryData {
receipts: receipts.as_ref().map(|x| &x[..]),
};

self.engine.signals_epoch_end(verified_header, auxiliary)
self.engine.signals_epoch_end(verified_header, receipts.as_ref().map(|x| &x[..]))
};

// check with any auxiliary data fetched so far
6 changes: 2 additions & 4 deletions ethcore/src/client/client.rs
Original file line number Diff line number Diff line change
@@ -114,7 +114,7 @@ use types::{
engines::{
epoch::{PendingTransition, Transition as EpochTransition},
ForkChoice,
machine::{AuxiliaryData, Call as MachineCall},
machine::Call as MachineCall,
MAX_UNCLE_AGE,
SealingState,
},
@@ -602,9 +602,7 @@ impl Importer {
use engine::EpochChange;

let hash = header.hash();
let auxiliary = AuxiliaryData { receipts: Some(&receipts) };

match self.engine.signals_epoch_end(header, auxiliary) {
match self.engine.signals_epoch_end(header, Some(&receipts)) {
EpochChange::Yes(proof) => {
use engine::Proof;

10 changes: 0 additions & 10 deletions ethcore/types/src/engines/machine.rs
Original file line number Diff line number Diff line change
@@ -21,23 +21,13 @@ use bytes::Bytes;

use crate::{
log_entry::LogEntry,
receipt,
state_diff::StateDiff,
};

/// Type alias for a function we can make calls through synchronously.
/// Returns the call result and state proof for each call.
pub type Call<'a> = dyn Fn(Address, Vec<u8>) -> Result<(Vec<u8>, Vec<Vec<u8>>), String> + 'a;

/// Auxiliary data fetcher for an Ethereum machine. In Ethereum-like machines
/// there are two kinds of auxiliary data: bodies and receipts.
#[derive(Default, Clone)]
pub struct AuxiliaryData<'a> {
/// The block receipts.
pub receipts: Option<&'a [receipt::Receipt]>,
}


/// Transaction execution receipt.
#[derive(Debug, PartialEq, Clone)]
pub struct Executed<T, V> {