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:
committed by
Andronik Ordian
parent
87e1080581
commit
73354d8d93
@@ -97,23 +97,29 @@ pub struct AuthorityRoundParams {
|
||||
pub two_thirds_majority_transition: Option<Uint>,
|
||||
/// The random number contract's address, or a map of contract transitions.
|
||||
pub randomness_contract_address: Option<BTreeMap<Uint, Address>>,
|
||||
/// The addresses of contracts that determine the block gas limit starting from the block number
|
||||
/// associated with each of those contracts.
|
||||
pub block_gas_limit_contract_transitions: Option<BTreeMap<Uint, Address>>,
|
||||
}
|
||||
|
||||
/// Authority engine deserialization.
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct AuthorityRound {
|
||||
/// Ethash params.
|
||||
/// Authority Round parameters.
|
||||
pub params: AuthorityRoundParams,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{Address, Uint, StepDuration};
|
||||
use ethereum_types::{U256, H160};
|
||||
use crate::spec::{validator_set::ValidatorSet, authority_round::AuthorityRound};
|
||||
use std::str::FromStr;
|
||||
|
||||
use ethereum_types::{U256, H160};
|
||||
use serde_json;
|
||||
|
||||
use super::{Address, Uint, StepDuration};
|
||||
use crate::{spec::{validator_set::ValidatorSet, authority_round::AuthorityRound}};
|
||||
|
||||
#[test]
|
||||
fn authority_round_deserialization() {
|
||||
let s = r#"{
|
||||
@@ -130,6 +136,10 @@ mod tests {
|
||||
"randomnessContractAddress": {
|
||||
"10": "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
"20": "0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
|
||||
},
|
||||
"blockGasLimitContractTransitions": {
|
||||
"10": "0x1000000000000000000000000000000000000001",
|
||||
"20": "0x2000000000000000000000000000000000000002"
|
||||
}
|
||||
}
|
||||
}"#;
|
||||
@@ -149,5 +159,10 @@ mod tests {
|
||||
(Uint(10.into()), Address(H160::from_str("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").unwrap())),
|
||||
(Uint(20.into()), Address(H160::from_str("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb").unwrap())),
|
||||
].into_iter().collect());
|
||||
let expected_bglc =
|
||||
[(Uint(10.into()), Address(H160::from_str("1000000000000000000000000000000000000001").unwrap())),
|
||||
(Uint(20.into()), Address(H160::from_str("2000000000000000000000000000000000000002").unwrap()))];
|
||||
assert_eq!(deserialized.params.block_gas_limit_contract_transitions,
|
||||
Some(expected_bglc.to_vec().into_iter().collect()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user