Trait enjen::Engine[][src]

pub trait Engine: Sync + Send {
    fn name(&self) -> &str;
fn mashina(&self) -> &Machine;
fn verify_local_seal(&self, header: &Header) -> Result<(), Error>;
fn params(&self) -> &CommonParams; fn seal_fields(&self, _header: &Header) -> usize { ... }
fn extra_info(&self, _header: &Header) -> BTreeMap<String, String> { ... }
fn maximum_uncle_count(&self, _block: BlockNumber) -> usize { ... }
fn maximum_gas_limit(&self) -> Option<U256> { ... }
fn on_new_block(
        &self,
        _block: &mut ExecutedBlock,
        _epoch_begin: bool
    ) -> Result<(), Error> { ... }
fn on_close_block(
        &self,
        _block: &mut ExecutedBlock,
        _parent_header: &Header
    ) -> Result<(), Error> { ... }
fn on_seal_block(&self, _block: &mut ExecutedBlock) -> Result<(), Error> { ... }
fn generate_engine_transactions(
        &self,
        _block: &ExecutedBlock
    ) -> Result<Vec<SignedTransaction>, Error> { ... }
fn sealing_state(&self) -> SealingState { ... }
fn should_reseal_on_update(&self) -> bool { ... }
fn generate_seal(&self, _block: &ExecutedBlock, _parent: &Header) -> Seal { ... }
fn verify_block_basic(&self, _header: &Header) -> Result<(), Error> { ... }
fn verify_block_unordered(&self, _header: &Header) -> Result<(), Error> { ... }
fn verify_block_family(
        &self,
        _header: &Header,
        _parent: &Header
    ) -> Result<(), Error> { ... }
fn verify_block_external(&self, _header: &Header) -> Result<(), Error> { ... }
fn genesis_epoch_data<'a>(
        &self,
        _header: &Header,
        _state: &Call<'_>
    ) -> Result<Vec<u8>, String> { ... }
fn signals_epoch_end<'a>(
        &self,
        _header: &Header,
        _aux: AuxiliaryData<'a>
    ) -> EpochChange { ... }
fn is_epoch_end(
        &self,
        _chain_head: &Header,
        _finalized: &[H256],
        _chain: &Headers<'_, Header>,
        _transition_store: &PendingTransitionStore<'_>
    ) -> Option<Vec<u8>> { ... }
fn is_epoch_end_light(
        &self,
        _chain_head: &Header,
        _chain: &Headers<'_, Header>,
        _transition_store: &PendingTransitionStore<'_>
    ) -> Option<Vec<u8>> { ... }
fn epoch_verifier<'a>(
        &self,
        _header: &Header,
        _proof: &'a [u8]
    ) -> ConstructedVerifier<'a> { ... }
fn populate_from_parent(&self, _header: &mut Header, _parent: &Header) { ... }
fn handle_message(&self, _message: &[u8]) -> Result<(), EngineError> { ... }
fn set_signer(&self, _signer: Option<Box<dyn EngineSigner>>) { ... }
fn sign(&self, _hash: H256) -> Result<Signature, Error> { ... }
fn register_client(&self, _client: Weak<dyn EngineClient>) { ... }
fn step(&self) { ... }
fn snapshot_mode(&self) -> Snapshotting { ... }
fn open_block_header_timestamp(&self, parent_timestamp: u64) -> u64 { ... }
fn is_timestamp_valid(
        &self,
        header_timestamp: u64,
        parent_timestamp: u64
    ) -> bool { ... }
fn ancestry_actions(
        &self,
        _header: &Header,
        _ancestry: &mut dyn Iterator<Item = ExtendedHeader>
    ) -> Vec<AncestryAction> { ... }
fn executive_author(&self, header: &Header) -> Result<Address, Error> { ... }
fn gas_limit_override(&self, _header: &Header) -> Option<U256> { ... }
fn schedule(&self, block_number: BlockNumber) -> Schedule { ... }
fn builtins(&self) -> &BTreeMap<Address, Builtin> { ... }
fn builtin(
        &self,
        a: &Address,
        block_number: BlockNumber
    ) -> Option<&Builtin> { ... }
fn maximum_extra_data_size(&self) -> usize { ... }
fn account_start_nonce(&self, block: BlockNumber) -> U256 { ... }
fn signing_chain_id(&self, env_info: &EnvInfo) -> Option<u64> { ... }
fn verify_transaction_basic(
        &self,
        t: &UnverifiedTransaction,
        header: &Header
    ) -> Result<(), Error> { ... }
fn decode_transaction(
        &self,
        transaction: &[u8]
    ) -> Result<UnverifiedTransaction, Error> { ... }
fn min_gas_limit(&self) -> U256 { ... } }

A consensus mechanism for the chain. Generally either proof-of-work or proof-of-stake-based. Provides hooks into each of the major parts of block import.

Required methods

fn name(&self) -> &str[src]

The name of this engine.

fn mashina(&self) -> &Machine[src]

Get access to the underlying state mashina.

fn verify_local_seal(&self, header: &Header) -> Result<(), Error>[src]

Verify a locally-generated seal of a header.

If this engine seals internally, no checks have to be done here, since all internally generated seals should be valid.

Externally-generated seals (e.g. PoW) will need to be checked for validity.

It is fine to require access to state or a full client for this function, since light clients do not generate seals.

fn params(&self) -> &CommonParams[src]

Get the general parameters of the chain.

Loading content...

Provided methods

fn seal_fields(&self, _header: &Header) -> usize[src]

The number of additional header fields required for this engine.

fn extra_info(&self, _header: &Header) -> BTreeMap<String, String>[src]

Additional engine-specific information for the user/developer concerning header.

fn maximum_uncle_count(&self, _block: BlockNumber) -> usize[src]

Maximum number of uncles a block is allowed to declare.

fn maximum_gas_limit(&self) -> Option<U256>[src]

Optional maximum gas limit.

fn on_new_block(
    &self,
    _block: &mut ExecutedBlock,
    _epoch_begin: bool
) -> Result<(), Error>
[src]

Block transformation functions, before the transactions. epoch_begin set to true if this block kicks off an epoch.

fn on_close_block(
    &self,
    _block: &mut ExecutedBlock,
    _parent_header: &Header
) -> Result<(), Error>
[src]

Block transformation functions, after the transactions.

fn on_seal_block(&self, _block: &mut ExecutedBlock) -> Result<(), Error>[src]

Allow mutating the header during seal generation. Currently only used by Clique.

fn generate_engine_transactions(
    &self,
    _block: &ExecutedBlock
) -> Result<Vec<SignedTransaction>, Error>
[src]

Returns a list of transactions for a new block if we are the author.

This is called when the miner prepares a new block that this node will author and seal. It returns a list of transactions that will be added to the block before any other transactions from the queue.

fn sealing_state(&self) -> SealingState[src]

Returns the engine’s current sealing state.

fn should_reseal_on_update(&self) -> bool[src]

Called in miner.chain_new_blocks if the engine wishes to update_sealing after a block was recently sealed.

returns false by default

fn generate_seal(&self, _block: &ExecutedBlock, _parent: &Header) -> Seal[src]

Attempt to seal the block internally.

If Some is returned, then you get a valid seal.

This operation is synchronous and may (quite reasonably) not be available, in which None will be returned.

It is fine to require access to state or a full client for this function, since light clients do not generate seals.

fn verify_block_basic(&self, _header: &Header) -> Result<(), Error>[src]

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.

fn verify_block_unordered(&self, _header: &Header) -> Result<(), Error>[src]

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.

fn verify_block_family(
    &self,
    _header: &Header,
    _parent: &Header
) -> Result<(), Error>
[src]

Phase 3 verification. Check block information against parent. Returns either a null Ok or a general error detailing the problem with import.

fn verify_block_external(&self, _header: &Header) -> Result<(), Error>[src]

Phase 4 verification. Verify block header against potentially external data. Should only be called when register_client has been called previously.

fn genesis_epoch_data<'a>(
    &self,
    _header: &Header,
    _state: &Call<'_>
) -> Result<Vec<u8>, String>
[src]

Genesis epoch data.

fn signals_epoch_end<'a>(
    &self,
    _header: &Header,
    _aux: AuxiliaryData<'a>
) -> EpochChange
[src]

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.

If auxiliary data of the block is required, return an auxiliary request and the function will be called again with them. Return Yes or No when the answer is definitively known.

Should not interact with state.

fn is_epoch_end(
    &self,
    _chain_head: &Header,
    _finalized: &[H256],
    _chain: &Headers<'_, Header>,
    _transition_store: &PendingTransitionStore<'_>
) -> Option<Vec<u8>>
[src]

Whether a block is the end of an epoch.

This either means that an immediate transition occurs or a block signalling transition has reached finality. The Headers given are not guaranteed to return any blocks from any epoch other than the current. The client must keep track of finality and provide the latest finalized headers to check against the transition store.

Return optional transition proof.

fn is_epoch_end_light(
    &self,
    _chain_head: &Header,
    _chain: &Headers<'_, Header>,
    _transition_store: &PendingTransitionStore<'_>
) -> Option<Vec<u8>>
[src]

Whether a block is the end of an epoch.

This either means that an immediate transition occurs or a block signalling transition has reached finality. The Headers given are not guaranteed to return any blocks from any epoch other than the current. This is a specialized method to use for light clients since the light client doesn’t track finality of all blocks, and therefore finality for blocks in the current epoch is built inside this method by the engine.

Return optional transition proof.

fn epoch_verifier<'a>(
    &self,
    _header: &Header,
    _proof: &'a [u8]
) -> ConstructedVerifier<'a>
[src]

Create an epoch verifier from validation proof and a flag indicating whether finality is required.

fn populate_from_parent(&self, _header: &mut Header, _parent: &Header)[src]

Populate a header’s fields based on its parent’s header. Usually implements the chain scoring rule based on weight.

fn handle_message(&self, _message: &[u8]) -> Result<(), EngineError>[src]

Handle any potential consensus messages; updating consensus state and potentially issuing a new one.

fn set_signer(&self, _signer: Option<Box<dyn EngineSigner>>)[src]

Register a component which signs consensus messages.

fn sign(&self, _hash: H256) -> Result<Signature, Error>[src]

Sign using the EngineSigner, to be used for consensus tx signing.

fn register_client(&self, _client: Weak<dyn EngineClient>)[src]

Add Client which can be used for sealing, potentially querying the state and sending messages.

fn step(&self)[src]

Trigger next step of the consensus engine.

fn snapshot_mode(&self) -> Snapshotting[src]

Snapshot mode for the engine: Unsupported, PoW or PoA

fn open_block_header_timestamp(&self, parent_timestamp: u64) -> u64[src]

Return a new open block header timestamp based on the parent timestamp.

fn is_timestamp_valid(
    &self,
    header_timestamp: u64,
    parent_timestamp: u64
) -> bool
[src]

Check whether the parent timestamp is valid.

fn ancestry_actions(
    &self,
    _header: &Header,
    _ancestry: &mut dyn Iterator<Item = ExtendedHeader>
) -> Vec<AncestryAction>
[src]

Gather all ancestry actions. Called at the last stage when a block is committed. The Engine must guarantee that the ancestry exists.

fn executive_author(&self, header: &Header) -> Result<Address, Error>[src]

Returns author should used when executing tx’s for this block.

fn gas_limit_override(&self, _header: &Header) -> Option<U256>[src]

Overrides the block gas limit. Whenever this returns Some for a header, the next block’s gas limit must be exactly that value.

fn schedule(&self, block_number: BlockNumber) -> Schedule[src]

Get the VVM schedule for the given block number.

fn builtins(&self) -> &BTreeMap<Address, Builtin>[src]

Builtin-contracts for the chain..

fn builtin(&self, a: &Address, block_number: BlockNumber) -> Option<&Builtin>[src]

Attempt to get a handle to a built-in contract. Only returns references to activated built-ins.

fn maximum_extra_data_size(&self) -> usize[src]

Some intrinsic operation parameters; by default they take their value from the spec()’s engine_params.

fn account_start_nonce(&self, block: BlockNumber) -> U256[src]

The nonce with which accounts begin at given block.

fn signing_chain_id(&self, env_info: &EnvInfo) -> Option<u64>[src]

The network ID that transactions should be signed with.

fn verify_transaction_basic(
    &self,
    t: &UnverifiedTransaction,
    header: &Header
) -> Result<(), Error>
[src]

Perform basic/cheap transaction verification.

This should include all cheap checks that can be done before actually checking the signature, like chain-replay protection.

NOTE This is done before the signature is recovered so avoid doing any state-touching checks that might be expensive.

TODO: Add flags for which bits of the transaction to check. TODO: consider including State in the params.

fn decode_transaction(
    &self,
    transaction: &[u8]
) -> Result<UnverifiedTransaction, Error>
[src]

Performs pre-validation of RLP decoded transaction before other processing

fn min_gas_limit(&self) -> U256[src]

The configured minimum gas limit.

Loading content...

Implementors

Loading content...