Merge pull request #7075 from miyao-gmo/feature/estimate_gas_limit
escape inifinite loop in estimte_gas
This commit is contained in:
commit
e85c98e09a
@ -1231,12 +1231,12 @@ impl BlockChainClient for Client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn estimate_gas(&self, t: &SignedTransaction, block: BlockId) -> Result<U256, CallError> {
|
fn estimate_gas(&self, t: &SignedTransaction, block: BlockId) -> Result<U256, CallError> {
|
||||||
const UPPER_CEILING: u64 = 1_000_000_000_000u64;
|
let (mut upper, max_upper, env_info) = {
|
||||||
let (mut upper, env_info) = {
|
|
||||||
let mut env_info = self.env_info(block).ok_or(CallError::StatePruned)?;
|
let mut env_info = self.env_info(block).ok_or(CallError::StatePruned)?;
|
||||||
let initial_upper = env_info.gas_limit;
|
let init = env_info.gas_limit;
|
||||||
env_info.gas_limit = UPPER_CEILING.into();
|
let max = init * U256::from(10);
|
||||||
(initial_upper, env_info)
|
env_info.gas_limit = max;
|
||||||
|
(init, max, env_info)
|
||||||
};
|
};
|
||||||
|
|
||||||
// that's just a copy of the state.
|
// that's just a copy of the state.
|
||||||
@ -1257,9 +1257,7 @@ impl BlockChainClient for Client {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if !cond(upper)? {
|
if !cond(upper)? {
|
||||||
// impossible at block gas limit - try `UPPER_CEILING` instead.
|
upper = max_upper;
|
||||||
// TODO: consider raising limit by powers of two.
|
|
||||||
upper = UPPER_CEILING.into();
|
|
||||||
if !cond(upper)? {
|
if !cond(upper)? {
|
||||||
trace!(target: "estimate_gas", "estimate_gas failed with {}", upper);
|
trace!(target: "estimate_gas", "estimate_gas failed with {}", upper);
|
||||||
let err = ExecutionError::Internal(format!("Requires higher than upper limit of {}", upper));
|
let err = ExecutionError::Internal(format!("Requires higher than upper limit of {}", upper));
|
||||||
|
Loading…
Reference in New Issue
Block a user