1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use client_traits::BlockChainClient;
use common_types::{header::Header, ids::BlockId};
use vapabi::FunctionOutputDecoder;
use vapabi_contract::use_contract;
use vapory_types::{Address, U256};
use log::{debug, error};
use_contract!(contract, "res/block_gas_limit.json");
pub fn block_gas_limit(full_client: &dyn BlockChainClient, header: &Header, address: Address) -> Option<U256> {
let (data, decoder) = contract::functions::block_gas_limit::call();
let value = full_client.call_contract(BlockId::Hash(*header.parent_hash()), address, data).map_err(|err| {
error!(target: "block_gas_limit", "Contract call failed. Not changing the block gas limit. {:?}", err);
}).ok()?;
if value.is_empty() {
debug!(target: "block_gas_limit", "Contract call returned nothing. Not changing the block gas limit.");
None
} else {
decoder.decode(&value).ok()
}
}