Struct ethcore::machine::EthereumMachine
source · [−]pub struct EthereumMachine { /* private fields */ }
Expand description
An ethereum-like state machine.
Implementations
sourceimpl EthereumMachine
impl EthereumMachine
sourcepub fn regular(
params: CommonParams,
builtins: BTreeMap<Address, Builtin>
) -> EthereumMachine
pub fn regular(
params: CommonParams,
builtins: BTreeMap<Address, Builtin>
) -> EthereumMachine
Regular ethereum machine.
sourcepub fn with_ethash_extensions(
params: CommonParams,
builtins: BTreeMap<Address, Builtin>,
extensions: EthashExtensions
) -> EthereumMachine
pub fn with_ethash_extensions(
params: CommonParams,
builtins: BTreeMap<Address, Builtin>,
extensions: EthashExtensions
) -> EthereumMachine
Ethereum machine with ethash extensions.
sourcepub fn set_schedule_creation_rules(&mut self, rules: Box<ScheduleCreationRules>)
pub fn set_schedule_creation_rules(&mut self, rules: Box<ScheduleCreationRules>)
Attach special rules to the creation of schedule.
sourcepub fn ethash_extensions(&self) -> Option<&EthashExtensions>
pub fn ethash_extensions(&self) -> Option<&EthashExtensions>
Get a reference to the ethash-specific extensions.
sourceimpl EthereumMachine
impl EthereumMachine
sourcepub fn execute_as_system(
&self,
block: &mut ExecutedBlock,
contract_address: Address,
gas: U256,
data: Option<Vec<u8>>
) -> Result<Vec<u8>, Error>
pub fn execute_as_system(
&self,
block: &mut ExecutedBlock,
contract_address: Address,
gas: U256,
data: Option<Vec<u8>>
) -> Result<Vec<u8>, Error>
Execute a call as the system address. Block environment information passed to the VM is modified to have its gas limit bounded at the upper limit of possible used gases including this system call, capped at the maximum value able to be represented by U256. This system call modifies the block state, but discards other information. If suicides, logs or refunds happen within the system call, they will not be executed or recorded. Gas used by this system call will not be counted on the block.
sourcepub fn execute_code_as_system(
&self,
block: &mut ExecutedBlock,
contract_address: Option<Address>,
code: Option<Arc<Vec<u8>>>,
code_hash: Option<H256>,
value: Option<ActionValue>,
gas: U256,
data: Option<Vec<u8>>,
call_type: Option<CallType>
) -> Result<Vec<u8>, Error>
pub fn execute_code_as_system(
&self,
block: &mut ExecutedBlock,
contract_address: Option<Address>,
code: Option<Arc<Vec<u8>>>,
code_hash: Option<H256>,
value: Option<ActionValue>,
gas: U256,
data: Option<Vec<u8>>,
call_type: Option<CallType>
) -> Result<Vec<u8>, Error>
Same as execute_as_system, but execute code directly. If contract address is None, use the null sender address. If code is None, then this function has no effect. The call is executed without finalization, and does not form a transaction.
sourcepub fn on_new_block(&self, block: &mut ExecutedBlock) -> Result<(), Error>
pub fn on_new_block(&self, block: &mut ExecutedBlock) -> Result<(), Error>
fork, for ethash.
sourcepub fn populate_from_parent(
&self,
header: &mut Header,
parent: &Header,
gas_floor_target: U256,
gas_ceil_target: U256
)
pub fn populate_from_parent(
&self,
header: &mut Header,
parent: &Header,
gas_floor_target: U256,
gas_ceil_target: U256
)
Populate a header’s fields based on its parent’s header. Usually implements the chain scoring rule based on weight. The gas floor target must not be lower than the engine’s minimum gas limit.
sourcepub fn params(&self) -> &CommonParams
pub fn params(&self) -> &CommonParams
Get the general parameters of the chain.
sourcepub fn schedule(&self, block_number: BlockNumber) -> Schedule
pub fn schedule(&self, block_number: BlockNumber) -> Schedule
Get the EVM schedule for the given block number.
sourcepub fn builtin(
&self,
a: &Address,
block_number: BlockNumber
) -> Option<&Builtin>
pub fn builtin(
&self,
a: &Address,
block_number: BlockNumber
) -> Option<&Builtin>
Attempt to get a handle to a built-in contract. Only returns references to activated built-ins.
sourcepub fn maximum_extra_data_size(&self) -> usize
pub fn maximum_extra_data_size(&self) -> usize
Some intrinsic operation parameters; by default they take their value from the spec()
’s engine_params
.
sourcepub fn account_start_nonce(&self, block: u64) -> U256
pub fn account_start_nonce(&self, block: u64) -> U256
The nonce with which accounts begin at given block.
sourcepub fn signing_chain_id(&self, env_info: &EnvInfo) -> Option<u64>
pub fn signing_chain_id(&self, env_info: &EnvInfo) -> Option<u64>
The network ID that transactions should be signed with.
sourcepub fn create_address_scheme(
&self,
_number: BlockNumber
) -> CreateContractAddress
pub fn create_address_scheme(
&self,
_number: BlockNumber
) -> CreateContractAddress
Returns new contract address generation scheme at given block number.
sourcepub fn verify_transaction_unordered(
&self,
t: UnverifiedTransaction,
header: &Header
) -> Result<SignedTransaction, Error>
pub fn verify_transaction_unordered(
&self,
t: UnverifiedTransaction,
header: &Header
) -> Result<SignedTransaction, Error>
Verify a particular transaction is valid, regardless of order.
sourcepub fn verify_transaction_basic(
&self,
t: &UnverifiedTransaction,
header: &Header
) -> Result<(), Error>
pub fn verify_transaction_basic(
&self,
t: &UnverifiedTransaction,
header: &Header
) -> Result<(), Error>
Does basic verification of the transaction.
sourcepub fn verify_transaction<C: BlockInfo + CallContract>(
&self,
t: &SignedTransaction,
parent: &Header,
client: &C
) -> Result<(), Error>
pub fn verify_transaction<C: BlockInfo + CallContract>(
&self,
t: &SignedTransaction,
parent: &Header,
client: &C
) -> Result<(), Error>
Does verification of the transaction against the parent state.
sourcepub fn additional_params(&self) -> HashMap<String, String>
pub fn additional_params(&self) -> HashMap<String, String>
Additional params.
sourcepub fn decode_transaction(
&self,
transaction: &[u8],
schedule: &Schedule
) -> Result<UnverifiedTransaction, Error>
pub fn decode_transaction(
&self,
transaction: &[u8],
schedule: &Schedule
) -> Result<UnverifiedTransaction, Error>
Performs pre-validation of RLP decoded transaction before other processing
sourcepub fn calc_base_fee(&self, parent: &Header) -> Option<U256>
pub fn calc_base_fee(&self, parent: &Header) -> Option<U256>
Calculates base fee for the block that should be mined next. Base fee is calculated based on the parent header (last block in blockchain / best block).
Introduced by EIP1559 to support new market fee mechanism.
Modified for xDai chain to have an ability to set min base fee through eip1559BaseFeeMinValue spec option. The modification made in v3.3.0-rc.14
Trait Implementations
sourceimpl Engine<EthereumMachine> for AuthorityRound
impl Engine<EthereumMachine> for AuthorityRound
sourcefn seal_fields(&self, header: &Header) -> usize
fn seal_fields(&self, header: &Header) -> usize
Three fields - consensus step and the corresponding proposer signature, and a list of empty step messages (which should be empty if no steps are skipped)
sourcefn extra_info(&self, header: &Header) -> BTreeMap<String, String>
fn extra_info(&self, header: &Header) -> BTreeMap<String, String>
Additional engine-specific information for the user/developer concerning header
.
sourcefn generate_seal(&self, block: &ExecutedBlock, parent: &Header) -> Seal
fn generate_seal(&self, block: &ExecutedBlock, parent: &Header) -> Seal
Attempt to seal the block internally.
This operation is synchronous and may (quite reasonably) not be available, in which case
Seal::None
will be returned.
sourcefn on_new_block(
&self,
block: &mut ExecutedBlock,
epoch_begin: bool,
_ancestry: &mut dyn Iterator<Item = ExtendedHeader>
) -> Result<(), Error>
fn on_new_block(
&self,
block: &mut ExecutedBlock,
epoch_begin: bool,
_ancestry: &mut dyn Iterator<Item = ExtendedHeader>
) -> Result<(), Error>
Apply operations on new epoch. Apply rewrite bytecode transitions if available.
sourcefn on_close_block(&self, block: &mut ExecutedBlock) -> Result<(), Error>
fn on_close_block(&self, block: &mut ExecutedBlock) -> Result<(), Error>
Apply the block reward on finalisation of the block.
sourcefn verify_block_basic(&self, header: &Header) -> Result<(), Error>
fn verify_block_basic(&self, header: &Header) -> Result<(), Error>
Check the number of seal fields.
sourcefn verify_block_family(
&self,
header: &Header,
parent: &Header
) -> Result<(), Error>
fn verify_block_family(
&self,
header: &Header,
parent: &Header
) -> Result<(), Error>
Do the step and gas limit validation.
sourcefn machine(&self) -> &EthereumMachine
fn machine(&self) -> &EthereumMachine
Get access to the underlying state machine.
sourcefn maximum_uncle_count(&self, block: BlockNumber) -> usize
fn maximum_uncle_count(&self, block: BlockNumber) -> usize
Maximum number of uncles a block is allowed to declare.
sourcefn populate_from_parent(&self, header: &mut Header, parent: &Header)
fn populate_from_parent(&self, header: &mut Header, parent: &Header)
Populate a header’s fields based on its parent’s header. Usually implements the chain scoring rule based on weight. Read more
sourcefn is_allowed_to_seal(&self) -> bool
fn is_allowed_to_seal(&self) -> bool
Returns whether the current node is a validator and actually may seal a block if AuRa engine is used. Read more
sourcefn sealing_state(&self) -> SealingState
fn sealing_state(&self) -> SealingState
Returns the engine’s current sealing state.
sourcefn handle_message(&self, rlp: &[u8]) -> Result<(), EngineError>
fn handle_message(&self, rlp: &[u8]) -> Result<(), EngineError>
Handle any potential consensus messages; updating consensus state and potentially issuing a new one. Read more
sourcefn verify_local_seal(&self, _header: &Header) -> Result<(), Error>
fn verify_local_seal(&self, _header: &Header) -> Result<(), Error>
Verify a locally-generated seal of a header. Read more
sourcefn generate_engine_transactions(
&self,
block: &ExecutedBlock
) -> Result<Vec<SignedTransaction>, Error>
fn generate_engine_transactions(
&self,
block: &ExecutedBlock
) -> Result<Vec<SignedTransaction>, Error>
Returns a list of transactions for a new block if we are the author. Read more
sourcefn verify_block_external(&self, header: &Header) -> Result<(), Error>
fn verify_block_external(&self, header: &Header) -> Result<(), Error>
Phase 4 verification. Verify block header against potentially external data.
Should only be called when register_client
has been called previously. Read more
sourcefn genesis_epoch_data(
&self,
header: &Header,
call: &Call<'_>
) -> Result<Vec<u8>, String>
fn genesis_epoch_data(
&self,
header: &Header,
call: &Call<'_>
) -> Result<Vec<u8>, String>
Genesis epoch data.
sourcefn signals_epoch_end(
&self,
header: &Header,
aux: AuxiliaryData<'_>
) -> EpochChange<EthereumMachine>
fn signals_epoch_end(
&self,
header: &Header,
aux: AuxiliaryData<'_>
) -> EpochChange<EthereumMachine>
Whether an epoch change is signalled at the given header but will require finality.
If a change can be enacted immediately then return No
from this function but
Yes
from is_epoch_end
. Read more
sourcefn is_epoch_end(
&self,
chain_head: &Header,
finalized: &[H256],
chain: &Headers<'_, Header>,
transition_store: &PendingTransitionStore<'_>
) -> Option<Vec<u8>>
fn is_epoch_end(
&self,
chain_head: &Header,
finalized: &[H256],
chain: &Headers<'_, Header>,
transition_store: &PendingTransitionStore<'_>
) -> Option<Vec<u8>>
Whether a block is the end of an epoch. Read more
sourcefn epoch_verifier<'a>(
&self,
_header: &Header,
proof: &'a [u8]
) -> ConstructedVerifier<'a, EthereumMachine>
fn epoch_verifier<'a>(
&self,
_header: &Header,
proof: &'a [u8]
) -> ConstructedVerifier<'a, EthereumMachine>
Create an epoch verifier from validation proof and a flag indicating whether finality is required. Read more
sourcefn register_client(&self, client: Weak<dyn EngineClient>)
fn register_client(&self, client: Weak<dyn EngineClient>)
Add Client which can be used for sealing, potentially querying the state and sending messages.
sourcefn set_signer(&self, signer: Option<Box<dyn EngineSigner>>)
fn set_signer(&self, signer: Option<Box<dyn EngineSigner>>)
Register a component which signs consensus messages.
sourcefn sign(&self, hash: H256) -> Result<Signature, Error>
fn sign(&self, hash: H256) -> Result<Signature, Error>
Sign using the EngineSigner, to be used for consensus tx signing.
sourcefn snapshot_components(&self) -> Option<Box<dyn SnapshotComponents>>
fn snapshot_components(&self) -> Option<Box<dyn SnapshotComponents>>
Create a factory for building snapshot chunks and restoring from them.
Returning None
indicates that this engine doesn’t support snapshot creation. Read more
sourcefn fork_choice(
&self,
new: &ExtendedHeader,
current: &ExtendedHeader
) -> ForkChoice
fn fork_choice(
&self,
new: &ExtendedHeader,
current: &ExtendedHeader
) -> ForkChoice
Check whether the given new block is the best block, after finalization check.
sourcefn ancestry_actions(
&self,
header: &Header,
ancestry: &mut dyn Iterator<Item = ExtendedHeader>
) -> Vec<AncestryAction>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
fn ancestry_actions(
&self,
header: &Header,
ancestry: &mut dyn Iterator<Item = ExtendedHeader>
) -> Vec<AncestryAction>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
the ancestry exists.
sourcefn gas_limit_override(&self, header: &Header) -> Option<U256>
fn gas_limit_override(&self, header: &Header) -> Option<U256>
Overrides the block gas limit. Whenever this returns Some
for a header, the next block’s gas limit must be
exactly that value. used by AuRa engine. Read more
sourcefn maximum_gas_limit(&self) -> Option<U256>
fn maximum_gas_limit(&self) -> Option<U256>
Optional maximum gas limit.
sourcefn on_seal_block(&self, _block: &mut ExecutedBlock) -> Result<(), Error>
fn on_seal_block(&self, _block: &mut ExecutedBlock) -> Result<(), Error>
Allow mutating the header during seal generation. Currently only used by Clique.
sourcefn should_reseal_on_update(&self) -> bool
fn should_reseal_on_update(&self) -> bool
Called in miner.chain_new_blocks
if the engine wishes to update_sealing
after a block was recently sealed. Read more
sourcefn verify_block_unordered(&self, _header: &Header) -> Result<(), M::Error>
fn verify_block_unordered(&self, _header: &Header) -> Result<(), M::Error>
Phase 2 verification. Perform costly checks such as transaction signatures. Returns either a null Ok
or a general error detailing the problem with import.
The verification module can optionally avoid checking the seal (check_seal
), if seal verification is disabled this method won’t be called. Read more
sourcefn supports_warp(&self) -> bool
fn supports_warp(&self) -> bool
Whether this engine supports warp sync.
sourcefn open_block_header_timestamp(&self, parent_timestamp: u64) -> u64
fn open_block_header_timestamp(&self, parent_timestamp: u64) -> u64
Return a new open block header timestamp based on the parent timestamp.
sourcefn is_timestamp_valid(
&self,
header_timestamp: u64,
parent_timestamp: u64
) -> bool
fn is_timestamp_valid(
&self,
header_timestamp: u64,
parent_timestamp: u64
) -> bool
Check whether the parent timestamp is valid.
Returns author should used when executing tx’s for this block.
sourceimpl Engine<EthereumMachine> for BasicAuthority
impl Engine<EthereumMachine> for BasicAuthority
sourcefn generate_seal(&self, block: &ExecutedBlock, _parent: &Header) -> Seal
fn generate_seal(&self, block: &ExecutedBlock, _parent: &Header) -> Seal
Attempt to seal the block internally.
sourcefn machine(&self) -> &EthereumMachine
fn machine(&self) -> &EthereumMachine
Get access to the underlying state machine.
sourcefn seal_fields(&self, _header: &Header) -> usize
fn seal_fields(&self, _header: &Header) -> usize
The number of additional header fields required for this engine.
sourcefn sealing_state(&self) -> SealingState
fn sealing_state(&self) -> SealingState
Returns the engine’s current sealing state.
sourcefn verify_local_seal(&self, _header: &Header) -> Result<(), Error>
fn verify_local_seal(&self, _header: &Header) -> Result<(), Error>
Verify a locally-generated seal of a header. Read more
sourcefn verify_block_external(&self, header: &Header) -> Result<(), Error>
fn verify_block_external(&self, header: &Header) -> Result<(), Error>
Phase 4 verification. Verify block header against potentially external data.
Should only be called when register_client
has been called previously. Read more
sourcefn genesis_epoch_data(
&self,
header: &Header,
call: &Call<'_>
) -> Result<Vec<u8>, String>
fn genesis_epoch_data(
&self,
header: &Header,
call: &Call<'_>
) -> Result<Vec<u8>, String>
Genesis epoch data.
sourcefn signals_epoch_end(
&self,
_header: &Header,
_auxiliary: AuxiliaryData<'_>
) -> EpochChange<EthereumMachine>
fn signals_epoch_end(
&self,
_header: &Header,
_auxiliary: AuxiliaryData<'_>
) -> EpochChange<EthereumMachine>
Whether an epoch change is signalled at the given header but will require finality.
If a change can be enacted immediately then return No
from this function but
Yes
from is_epoch_end
. Read more
sourcefn is_epoch_end(
&self,
chain_head: &Header,
_finalized: &[H256],
_chain: &Headers<'_, Header>,
_transition_store: &PendingTransitionStore<'_>
) -> Option<Vec<u8>>
fn is_epoch_end(
&self,
chain_head: &Header,
_finalized: &[H256],
_chain: &Headers<'_, Header>,
_transition_store: &PendingTransitionStore<'_>
) -> Option<Vec<u8>>
Whether a block is the end of an epoch. Read more
sourcefn epoch_verifier<'a>(
&self,
header: &Header,
proof: &'a [u8]
) -> ConstructedVerifier<'a, EthereumMachine>
fn epoch_verifier<'a>(
&self,
header: &Header,
proof: &'a [u8]
) -> ConstructedVerifier<'a, EthereumMachine>
Create an epoch verifier from validation proof and a flag indicating whether finality is required. Read more
sourcefn register_client(&self, client: Weak<dyn EngineClient>)
fn register_client(&self, client: Weak<dyn EngineClient>)
Add Client which can be used for sealing, potentially querying the state and sending messages.
sourcefn set_signer(&self, signer: Option<Box<dyn EngineSigner>>)
fn set_signer(&self, signer: Option<Box<dyn EngineSigner>>)
Register a component which signs consensus messages.
sourcefn sign(&self, hash: H256) -> Result<Signature, Error>
fn sign(&self, hash: H256) -> Result<Signature, Error>
Sign using the EngineSigner, to be used for consensus tx signing.
sourcefn snapshot_components(&self) -> Option<Box<dyn SnapshotComponents>>
fn snapshot_components(&self) -> Option<Box<dyn SnapshotComponents>>
Create a factory for building snapshot chunks and restoring from them.
Returning None
indicates that this engine doesn’t support snapshot creation. Read more
sourcefn fork_choice(
&self,
new: &ExtendedHeader,
current: &ExtendedHeader
) -> ForkChoice
fn fork_choice(
&self,
new: &ExtendedHeader,
current: &ExtendedHeader
) -> ForkChoice
Check whether the given new block is the best block, after finalization check.
sourcefn extra_info(&self, _header: &Header) -> BTreeMap<String, String>
fn extra_info(&self, _header: &Header) -> BTreeMap<String, String>
Additional engine-specific information for the user/developer concerning header
.
sourcefn maximum_uncle_count(&self, _block: BlockNumber) -> usize
fn maximum_uncle_count(&self, _block: BlockNumber) -> usize
Maximum number of uncles a block is allowed to declare.
sourcefn maximum_gas_limit(&self) -> Option<U256>
fn maximum_gas_limit(&self) -> Option<U256>
Optional maximum gas limit.
sourcefn on_new_block(
&self,
_block: &mut ExecutedBlock,
_epoch_begin: bool,
_ancestry: &mut dyn Iterator<Item = ExtendedHeader>
) -> Result<(), M::Error>
fn on_new_block(
&self,
_block: &mut ExecutedBlock,
_epoch_begin: bool,
_ancestry: &mut dyn Iterator<Item = ExtendedHeader>
) -> Result<(), M::Error>
Block transformation functions, before the transactions.
epoch_begin
set to true if this block kicks off an epoch. Read more
sourcefn on_close_block(&self, _block: &mut ExecutedBlock) -> Result<(), M::Error>
fn on_close_block(&self, _block: &mut ExecutedBlock) -> Result<(), M::Error>
Block transformation functions, after the transactions.
sourcefn on_seal_block(&self, _block: &mut ExecutedBlock) -> Result<(), Error>
fn on_seal_block(&self, _block: &mut ExecutedBlock) -> Result<(), Error>
Allow mutating the header during seal generation. Currently only used by Clique.
sourcefn should_reseal_on_update(&self) -> bool
fn should_reseal_on_update(&self) -> bool
Called in miner.chain_new_blocks
if the engine wishes to update_sealing
after a block was recently sealed. Read more
sourcefn verify_block_basic(&self, _header: &Header) -> Result<(), M::Error>
fn verify_block_basic(&self, _header: &Header) -> Result<(), M::Error>
Phase 1 quick block verification. Only does checks that are cheap. Returns either a null Ok
or a general error detailing the problem with import.
The verification module can optionally avoid checking the seal (check_seal
), if seal verification is disabled this method won’t be called. Read more
sourcefn verify_block_unordered(&self, _header: &Header) -> Result<(), M::Error>
fn verify_block_unordered(&self, _header: &Header) -> Result<(), M::Error>
Phase 2 verification. Perform costly checks such as transaction signatures. Returns either a null Ok
or a general error detailing the problem with import.
The verification module can optionally avoid checking the seal (check_seal
), if seal verification is disabled this method won’t be called. Read more
sourcefn verify_block_family(
&self,
_header: &Header,
_parent: &Header
) -> Result<(), M::Error>
fn verify_block_family(
&self,
_header: &Header,
_parent: &Header
) -> Result<(), M::Error>
Phase 3 verification. Check block information against parent. Returns either a null Ok
or a general error detailing the problem with import.
sourcefn populate_from_parent(&self, _header: &mut Header, _parent: &Header)
fn populate_from_parent(&self, _header: &mut Header, _parent: &Header)
Populate a header’s fields based on its parent’s header. Usually implements the chain scoring rule based on weight. Read more
sourcefn handle_message(&self, _message: &[u8]) -> Result<(), EngineError>
fn handle_message(&self, _message: &[u8]) -> Result<(), EngineError>
Handle any potential consensus messages; updating consensus state and potentially issuing a new one. Read more
sourcefn is_allowed_to_seal(&self) -> bool
fn is_allowed_to_seal(&self) -> bool
Returns whether the current node is a validator and actually may seal a block if AuRa engine is used. Read more
sourcefn supports_warp(&self) -> bool
fn supports_warp(&self) -> bool
Whether this engine supports warp sync.
sourcefn open_block_header_timestamp(&self, parent_timestamp: u64) -> u64
fn open_block_header_timestamp(&self, parent_timestamp: u64) -> u64
Return a new open block header timestamp based on the parent timestamp.
sourcefn is_timestamp_valid(
&self,
header_timestamp: u64,
parent_timestamp: u64
) -> bool
fn is_timestamp_valid(
&self,
header_timestamp: u64,
parent_timestamp: u64
) -> bool
Check whether the parent timestamp is valid.
sourcefn ancestry_actions(
&self,
_header: &Header,
_ancestry: &mut dyn Iterator<Item = ExtendedHeader>
) -> Vec<AncestryAction>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
fn ancestry_actions(
&self,
_header: &Header,
_ancestry: &mut dyn Iterator<Item = ExtendedHeader>
) -> Vec<AncestryAction>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
the ancestry exists.
Returns author should used when executing tx’s for this block.
sourcefn generate_engine_transactions(
&self,
_block: &ExecutedBlock
) -> Result<Vec<SignedTransaction>, Error>
fn generate_engine_transactions(
&self,
_block: &ExecutedBlock
) -> Result<Vec<SignedTransaction>, Error>
Returns a list of transactions for a new block if we are the author. Read more
sourceimpl Engine<EthereumMachine> for Clique
impl Engine<EthereumMachine> for Clique
sourcefn sealing_state(&self) -> SealingState
fn sealing_state(&self) -> SealingState
Clique doesn’t require external work to seal, so we always return true here.
sourcefn generate_seal(&self, block: &ExecutedBlock, parent: &Header) -> Seal
fn generate_seal(&self, block: &ExecutedBlock, parent: &Header) -> Seal
Returns if we are ready to seal, the real sealing (signing extra_data) is actually done in on_seal_block()
.
sourcefn verify_block_family(
&self,
header: &Header,
parent: &Header
) -> Result<(), Error>
fn verify_block_family(
&self,
header: &Header,
parent: &Header
) -> Result<(), Error>
Verify block family by looking up parent state (backfill if needed), then try to apply current header. see https://github.com/ethereum/go-ethereum/blob/master/consensus/clique/clique.go#L338
sourcefn open_block_header_timestamp(&self, parent_timestamp: u64) -> u64
fn open_block_header_timestamp(&self, parent_timestamp: u64) -> u64
Clique timestamp is set to parent + period , or current time which ever is higher.
sourcefn machine(&self) -> &EthereumMachine
fn machine(&self) -> &EthereumMachine
Get access to the underlying state machine.
sourcefn seal_fields(&self, _header: &Header) -> usize
fn seal_fields(&self, _header: &Header) -> usize
The number of additional header fields required for this engine.
sourcefn maximum_uncle_count(&self, _block: BlockNumber) -> usize
fn maximum_uncle_count(&self, _block: BlockNumber) -> usize
Maximum number of uncles a block is allowed to declare.
sourcefn on_new_block(
&self,
_block: &mut ExecutedBlock,
_epoch_begin: bool,
_ancestry: &mut dyn Iterator<Item = ExtendedHeader>
) -> Result<(), Error>
fn on_new_block(
&self,
_block: &mut ExecutedBlock,
_epoch_begin: bool,
_ancestry: &mut dyn Iterator<Item = ExtendedHeader>
) -> Result<(), Error>
Block transformation functions, before the transactions.
epoch_begin
set to true if this block kicks off an epoch. Read more
sourcefn on_close_block(&self, _block: &mut ExecutedBlock) -> Result<(), Error>
fn on_close_block(&self, _block: &mut ExecutedBlock) -> Result<(), Error>
Block transformation functions, after the transactions.
sourcefn on_seal_block(&self, block: &mut ExecutedBlock) -> Result<(), Error>
fn on_seal_block(&self, block: &mut ExecutedBlock) -> Result<(), Error>
Allow mutating the header during seal generation. Currently only used by Clique.
sourcefn verify_local_seal(&self, _header: &Header) -> Result<(), Error>
fn verify_local_seal(&self, _header: &Header) -> Result<(), Error>
Verify a locally-generated seal of a header. Read more
sourcefn verify_block_basic(&self, header: &Header) -> Result<(), Error>
fn verify_block_basic(&self, header: &Header) -> Result<(), Error>
Phase 1 quick block verification. Only does checks that are cheap. Returns either a null Ok
or a general error detailing the problem with import.
The verification module can optionally avoid checking the seal (check_seal
), if seal verification is disabled this method won’t be called. Read more
sourcefn verify_block_unordered(&self, _header: &Header) -> Result<(), Error>
fn verify_block_unordered(&self, _header: &Header) -> Result<(), Error>
Phase 2 verification. Perform costly checks such as transaction signatures. Returns either a null Ok
or a general error detailing the problem with import.
The verification module can optionally avoid checking the seal (check_seal
), if seal verification is disabled this method won’t be called. Read more
sourcefn genesis_epoch_data(
&self,
header: &Header,
_call: &Call<'_>
) -> Result<Vec<u8>, String>
fn genesis_epoch_data(
&self,
header: &Header,
_call: &Call<'_>
) -> Result<Vec<u8>, String>
Genesis epoch data.
sourcefn populate_from_parent(&self, header: &mut Header, parent: &Header)
fn populate_from_parent(&self, header: &mut Header, parent: &Header)
Populate a header’s fields based on its parent’s header. Usually implements the chain scoring rule based on weight. Read more
sourcefn set_signer(&self, signer: Option<Box<dyn EngineSigner>>)
fn set_signer(&self, signer: Option<Box<dyn EngineSigner>>)
Register a component which signs consensus messages.
sourcefn register_client(&self, client: Weak<dyn EngineClient>)
fn register_client(&self, client: Weak<dyn EngineClient>)
Add Client which can be used for sealing, potentially querying the state and sending messages.
sourcefn is_timestamp_valid(
&self,
header_timestamp: u64,
parent_timestamp: u64
) -> bool
fn is_timestamp_valid(
&self,
header_timestamp: u64,
parent_timestamp: u64
) -> bool
Check whether the parent timestamp is valid.
sourcefn fork_choice(
&self,
new: &ExtendedHeader,
current: &ExtendedHeader
) -> ForkChoice
fn fork_choice(
&self,
new: &ExtendedHeader,
current: &ExtendedHeader
) -> ForkChoice
Check whether the given new block is the best block, after finalization check.
Returns author should used when executing tx’s for this block.
sourcefn extra_info(&self, _header: &Header) -> BTreeMap<String, String>
fn extra_info(&self, _header: &Header) -> BTreeMap<String, String>
Additional engine-specific information for the user/developer concerning header
.
sourcefn maximum_gas_limit(&self) -> Option<U256>
fn maximum_gas_limit(&self) -> Option<U256>
Optional maximum gas limit.
sourcefn should_reseal_on_update(&self) -> bool
fn should_reseal_on_update(&self) -> bool
Called in miner.chain_new_blocks
if the engine wishes to update_sealing
after a block was recently sealed. Read more
sourcefn verify_block_external(&self, _header: &Header) -> Result<(), M::Error>
fn verify_block_external(&self, _header: &Header) -> Result<(), M::Error>
Phase 4 verification. Verify block header against potentially external data.
Should only be called when register_client
has been called previously. Read more
sourcefn signals_epoch_end<'a>(
&self,
_header: &Header,
_aux: AuxiliaryData<'a>
) -> EpochChange<M>
fn signals_epoch_end<'a>(
&self,
_header: &Header,
_aux: AuxiliaryData<'a>
) -> EpochChange<M>
Whether an epoch change is signalled at the given header but will require finality.
If a change can be enacted immediately then return No
from this function but
Yes
from is_epoch_end
. Read more
sourcefn is_epoch_end(
&self,
_chain_head: &Header,
_finalized: &[H256],
_chain: &Headers<'_, Header>,
_transition_store: &PendingTransitionStore<'_>
) -> Option<Vec<u8>>
fn is_epoch_end(
&self,
_chain_head: &Header,
_finalized: &[H256],
_chain: &Headers<'_, Header>,
_transition_store: &PendingTransitionStore<'_>
) -> Option<Vec<u8>>
Whether a block is the end of an epoch. Read more
sourcefn epoch_verifier<'a>(
&self,
_header: &Header,
_proof: &'a [u8]
) -> ConstructedVerifier<'a, M>
fn epoch_verifier<'a>(
&self,
_header: &Header,
_proof: &'a [u8]
) -> ConstructedVerifier<'a, M>
Create an epoch verifier from validation proof and a flag indicating whether finality is required. Read more
sourcefn handle_message(&self, _message: &[u8]) -> Result<(), EngineError>
fn handle_message(&self, _message: &[u8]) -> Result<(), EngineError>
Handle any potential consensus messages; updating consensus state and potentially issuing a new one. Read more
sourcefn is_allowed_to_seal(&self) -> bool
fn is_allowed_to_seal(&self) -> bool
Returns whether the current node is a validator and actually may seal a block if AuRa engine is used. Read more
sourcefn sign(&self, _hash: H256) -> Result<Signature, M::Error>
fn sign(&self, _hash: H256) -> Result<Signature, M::Error>
Sign using the EngineSigner, to be used for consensus tx signing.
sourcefn snapshot_components(&self) -> Option<Box<dyn SnapshotComponents>>
fn snapshot_components(&self) -> Option<Box<dyn SnapshotComponents>>
Create a factory for building snapshot chunks and restoring from them.
Returning None
indicates that this engine doesn’t support snapshot creation. Read more
sourcefn supports_warp(&self) -> bool
fn supports_warp(&self) -> bool
Whether this engine supports warp sync.
sourcefn ancestry_actions(
&self,
_header: &Header,
_ancestry: &mut dyn Iterator<Item = ExtendedHeader>
) -> Vec<AncestryAction>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
fn ancestry_actions(
&self,
_header: &Header,
_ancestry: &mut dyn Iterator<Item = ExtendedHeader>
) -> Vec<AncestryAction>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
the ancestry exists.
sourcefn generate_engine_transactions(
&self,
_block: &ExecutedBlock
) -> Result<Vec<SignedTransaction>, Error>
fn generate_engine_transactions(
&self,
_block: &ExecutedBlock
) -> Result<Vec<SignedTransaction>, Error>
Returns a list of transactions for a new block if we are the author. Read more
sourceimpl Engine<EthereumMachine> for Arc<Ethash>
impl Engine<EthereumMachine> for Arc<Ethash>
sourcefn extra_info(&self, header: &Header) -> BTreeMap<String, String>
fn extra_info(&self, header: &Header) -> BTreeMap<String, String>
Additional engine-specific information for the user/developer concerning header
.
sourcefn on_close_block(&self, block: &mut ExecutedBlock) -> Result<(), Error>
fn on_close_block(&self, block: &mut ExecutedBlock) -> Result<(), Error>
Apply the block reward on finalisation of the block. This assumes that all uncles are valid uncles (i.e. of at least one generation before the current).
sourcefn machine(&self) -> &EthereumMachine
fn machine(&self) -> &EthereumMachine
Get access to the underlying state machine.
sourcefn seal_fields(&self, _header: &Header) -> usize
fn seal_fields(&self, _header: &Header) -> usize
The number of additional header fields required for this engine.
sourcefn maximum_uncle_count(&self, _block: BlockNumber) -> usize
fn maximum_uncle_count(&self, _block: BlockNumber) -> usize
Maximum number of uncles a block is allowed to declare.
sourcefn maximum_gas_limit(&self) -> Option<U256>
fn maximum_gas_limit(&self) -> Option<U256>
Optional maximum gas limit.
sourcefn populate_from_parent(&self, header: &mut Header, parent: &Header)
fn populate_from_parent(&self, header: &mut Header, parent: &Header)
Populate a header’s fields based on its parent’s header. Usually implements the chain scoring rule based on weight. Read more
sourcefn verify_local_seal(&self, header: &Header) -> Result<(), Error>
fn verify_local_seal(&self, header: &Header) -> Result<(), Error>
Verify a locally-generated seal of a header. Read more
sourcefn verify_block_basic(&self, header: &Header) -> Result<(), Error>
fn verify_block_basic(&self, header: &Header) -> Result<(), Error>
Phase 1 quick block verification. Only does checks that are cheap. Returns either a null Ok
or a general error detailing the problem with import.
The verification module can optionally avoid checking the seal (check_seal
), if seal verification is disabled this method won’t be called. Read more
sourcefn verify_block_unordered(&self, header: &Header) -> Result<(), Error>
fn verify_block_unordered(&self, header: &Header) -> Result<(), Error>
Phase 2 verification. Perform costly checks such as transaction signatures. Returns either a null Ok
or a general error detailing the problem with import.
The verification module can optionally avoid checking the seal (check_seal
), if seal verification is disabled this method won’t be called. Read more
sourcefn verify_block_family(
&self,
header: &Header,
parent: &Header
) -> Result<(), Error>
fn verify_block_family(
&self,
header: &Header,
parent: &Header
) -> Result<(), Error>
Phase 3 verification. Check block information against parent. Returns either a null Ok
or a general error detailing the problem with import.
sourcefn epoch_verifier<'a>(
&self,
_header: &Header,
_proof: &'a [u8]
) -> ConstructedVerifier<'a, EthereumMachine>
fn epoch_verifier<'a>(
&self,
_header: &Header,
_proof: &'a [u8]
) -> ConstructedVerifier<'a, EthereumMachine>
Create an epoch verifier from validation proof and a flag indicating whether finality is required. Read more
sourcefn snapshot_components(&self) -> Option<Box<dyn SnapshotComponents>>
fn snapshot_components(&self) -> Option<Box<dyn SnapshotComponents>>
Create a factory for building snapshot chunks and restoring from them.
Returning None
indicates that this engine doesn’t support snapshot creation. Read more
sourcefn fork_choice(
&self,
new: &ExtendedHeader,
current: &ExtendedHeader
) -> ForkChoice
fn fork_choice(
&self,
new: &ExtendedHeader,
current: &ExtendedHeader
) -> ForkChoice
Check whether the given new block is the best block, after finalization check.
sourcefn on_new_block(
&self,
_block: &mut ExecutedBlock,
_epoch_begin: bool,
_ancestry: &mut dyn Iterator<Item = ExtendedHeader>
) -> Result<(), M::Error>
fn on_new_block(
&self,
_block: &mut ExecutedBlock,
_epoch_begin: bool,
_ancestry: &mut dyn Iterator<Item = ExtendedHeader>
) -> Result<(), M::Error>
Block transformation functions, before the transactions.
epoch_begin
set to true if this block kicks off an epoch. Read more
sourcefn on_seal_block(&self, _block: &mut ExecutedBlock) -> Result<(), Error>
fn on_seal_block(&self, _block: &mut ExecutedBlock) -> Result<(), Error>
Allow mutating the header during seal generation. Currently only used by Clique.
sourcefn sealing_state(&self) -> SealingState
fn sealing_state(&self) -> SealingState
Returns the engine’s current sealing state.
sourcefn should_reseal_on_update(&self) -> bool
fn should_reseal_on_update(&self) -> bool
Called in miner.chain_new_blocks
if the engine wishes to update_sealing
after a block was recently sealed. Read more
sourcefn generate_seal(&self, _block: &ExecutedBlock, _parent: &Header) -> Seal
fn generate_seal(&self, _block: &ExecutedBlock, _parent: &Header) -> Seal
Attempt to seal the block internally. Read more
sourcefn verify_block_external(&self, _header: &Header) -> Result<(), M::Error>
fn verify_block_external(&self, _header: &Header) -> Result<(), M::Error>
Phase 4 verification. Verify block header against potentially external data.
Should only be called when register_client
has been called previously. Read more
sourcefn genesis_epoch_data<'a>(
&self,
_header: &Header,
_state: &Call<'_>
) -> Result<Vec<u8>, String>
fn genesis_epoch_data<'a>(
&self,
_header: &Header,
_state: &Call<'_>
) -> Result<Vec<u8>, String>
Genesis epoch data.
sourcefn signals_epoch_end<'a>(
&self,
_header: &Header,
_aux: AuxiliaryData<'a>
) -> EpochChange<M>
fn signals_epoch_end<'a>(
&self,
_header: &Header,
_aux: AuxiliaryData<'a>
) -> EpochChange<M>
Whether an epoch change is signalled at the given header but will require finality.
If a change can be enacted immediately then return No
from this function but
Yes
from is_epoch_end
. Read more
sourcefn is_epoch_end(
&self,
_chain_head: &Header,
_finalized: &[H256],
_chain: &Headers<'_, Header>,
_transition_store: &PendingTransitionStore<'_>
) -> Option<Vec<u8>>
fn is_epoch_end(
&self,
_chain_head: &Header,
_finalized: &[H256],
_chain: &Headers<'_, Header>,
_transition_store: &PendingTransitionStore<'_>
) -> Option<Vec<u8>>
Whether a block is the end of an epoch. Read more
sourcefn handle_message(&self, _message: &[u8]) -> Result<(), EngineError>
fn handle_message(&self, _message: &[u8]) -> Result<(), EngineError>
Handle any potential consensus messages; updating consensus state and potentially issuing a new one. Read more
sourcefn set_signer(&self, _signer: Option<Box<dyn EngineSigner>>)
fn set_signer(&self, _signer: Option<Box<dyn EngineSigner>>)
Register a component which signs consensus messages.
sourcefn is_allowed_to_seal(&self) -> bool
fn is_allowed_to_seal(&self) -> bool
Returns whether the current node is a validator and actually may seal a block if AuRa engine is used. Read more
sourcefn sign(&self, _hash: H256) -> Result<Signature, M::Error>
fn sign(&self, _hash: H256) -> Result<Signature, M::Error>
Sign using the EngineSigner, to be used for consensus tx signing.
sourcefn register_client(&self, _client: Weak<M::EngineClient>)
fn register_client(&self, _client: Weak<M::EngineClient>)
Add Client which can be used for sealing, potentially querying the state and sending messages.
sourcefn supports_warp(&self) -> bool
fn supports_warp(&self) -> bool
Whether this engine supports warp sync.
sourcefn open_block_header_timestamp(&self, parent_timestamp: u64) -> u64
fn open_block_header_timestamp(&self, parent_timestamp: u64) -> u64
Return a new open block header timestamp based on the parent timestamp.
sourcefn is_timestamp_valid(
&self,
header_timestamp: u64,
parent_timestamp: u64
) -> bool
fn is_timestamp_valid(
&self,
header_timestamp: u64,
parent_timestamp: u64
) -> bool
Check whether the parent timestamp is valid.
sourcefn ancestry_actions(
&self,
_header: &Header,
_ancestry: &mut dyn Iterator<Item = ExtendedHeader>
) -> Vec<AncestryAction>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
fn ancestry_actions(
&self,
_header: &Header,
_ancestry: &mut dyn Iterator<Item = ExtendedHeader>
) -> Vec<AncestryAction>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
the ancestry exists.
Returns author should used when executing tx’s for this block.
sourcefn generate_engine_transactions(
&self,
_block: &ExecutedBlock
) -> Result<Vec<SignedTransaction>, Error>
fn generate_engine_transactions(
&self,
_block: &ExecutedBlock
) -> Result<Vec<SignedTransaction>, Error>
Returns a list of transactions for a new block if we are the author. Read more
sourceimpl EpochVerifier<EthereumMachine> for Arc<Ethash>
impl EpochVerifier<EthereumMachine> for Arc<Ethash>
sourceimpl Machine for EthereumMachine
impl Machine for EthereumMachine
type EngineClient = dyn EngineClient
type EngineClient = dyn EngineClient
A handle to a blockchain client for this machine.
sourcefn balance(
&self,
live: &ExecutedBlock,
address: &Address
) -> Result<U256, Error>
fn balance(
&self,
live: &ExecutedBlock,
address: &Address
) -> Result<U256, Error>
Get the balance, in base units, associated with an account. Extracts data from the live block. Read more
sourcefn add_balance(
&self,
live: &mut ExecutedBlock,
address: &Address,
amount: &U256
) -> Result<(), Error>
fn add_balance(
&self,
live: &mut ExecutedBlock,
address: &Address,
amount: &U256
) -> Result<(), Error>
Increment the balance of an account in the state of the live block.
Auto Trait Implementations
impl !RefUnwindSafe for EthereumMachine
impl Send for EthereumMachine
impl Sync for EthereumMachine
impl Unpin for EthereumMachine
impl !UnwindSafe for EthereumMachine
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more