Set the block gas limit to the value returned by a contract call (#10928)

* Block gas limit contract

Lower gas limit if TxPermission.limitBlockGas.

Call blockGasLimit before every block.

Make the block gas limit contract a separate config option.

Add `info` level logging of block gas limit switching

block-gas-limit subcrate and responses to review comments

simplified call_contract_before

moved block_gas_limit_contract_transitions to AuRa params

removed call_contract_before

Update and fix test_verify_block.

Remove some unused imports and functions.

* Move gas limit override check to verify_block_basic.

Co-authored-by: Andreas Fackler <afck@users.noreply.github.com>
This commit is contained in:
Vladimir Komendantskiy
2020-01-13 10:27:03 +00:00
committed by Andronik Ordian
parent 87e1080581
commit 73354d8d93
9 changed files with 212 additions and 31 deletions

View File

@@ -347,6 +347,12 @@ pub trait Engine: Sync + Send {
Ok(*header.author())
}
/// Overrides the block gas limit. Whenever this returns `Some` for a header, the next block's gas limit must be
/// exactly that value.
fn gas_limit_override(&self, _header: &Header) -> Option<U256> {
None
}
/// Get the general parameters of the chain.
fn params(&self) -> &CommonParams;
@@ -397,6 +403,11 @@ pub trait Engine: Sync + Send {
fn decode_transaction(&self, transaction: &[u8]) -> Result<UnverifiedTransaction, transaction::Error> {
self.machine().decode_transaction(transaction)
}
/// The configured minimum gas limit.
fn min_gas_limit(&self) -> U256 {
self.params().min_gas_limit
}
}
/// Verifier for all blocks within an epoch with self-contained state.