Skip to content

Commit 9fbaadc

Browse files
committed
Allow higher provider gas limit than block gas limit
Operators can set a higher provider gas limit for eth_call and eth_estimateGas and meter usage themselves.
1 parent 11d93cd commit 9fbaadc

File tree

3 files changed

+4
-15
lines changed

3 files changed

+4
-15
lines changed

monad-ethcall/src/lib.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use std::{
2020
sync::Arc,
2121
};
2222

23-
use alloy_consensus::{Header, Transaction as _, TxEnvelope};
23+
use alloy_consensus::{Header, TxEnvelope};
2424
use alloy_eips::eip2718::Encodable2718;
2525
use alloy_primitives::{Address, Bytes, B256, U256, U64};
2626
use alloy_rlp::Encodable;
@@ -195,15 +195,6 @@ pub async fn eth_call(
195195
tracer: MonadTracer,
196196
gas_specified: bool,
197197
) -> CallResult {
198-
// upper bound gas limit of transaction to block gas limit to prevent abuse of eth_call
199-
if transaction.gas_limit() > block_header.gas_limit {
200-
return CallResult::Failure(FailureCallResult {
201-
error_code: EthCallResult::OtherError,
202-
message: "gas limit too high".into(),
203-
data: None,
204-
});
205-
}
206-
207198
let mut rlp_encoded_tx = vec![];
208199
transaction.encode_2718(&mut rlp_encoded_tx);
209200

monad-rpc/src/handlers/eth/call.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ pub async fn fill_gas_params<T: Triedb>(
484484
header.base_fee_per_gas = Some(0);
485485
tx.fill_gas_prices(U256::ZERO)?;
486486
if tx.gas.is_none() {
487-
tx.gas = Some(U256::from(header.gas_limit).min(eth_call_provider_gas_limit));
487+
tx.gas = Some(eth_call_provider_gas_limit);
488488
}
489489
}
490490
}
@@ -662,7 +662,6 @@ async fn prepare_eth_call<T: Triedb + TriedbPath>(
662662
.tx()
663663
.gas
664664
.unwrap_or(U256::from(header.header.gas_limit));
665-
let eth_call_provider_gas_limit = eth_call_provider_gas_limit.min(header.header.gas_limit);
666665
fill_gas_params(
667666
triedb_env,
668667
block_key,
@@ -962,7 +961,7 @@ mod tests {
962961
let mock_triedb = MockTriedb::default();
963962

964963
// when gas price is not populated, then
965-
// (1) header base fee is set to zero and (2) tx gas limit is set to block gas limit
964+
// (1) header base fee is set to zero and (2) tx gas limit is set to the provider gas limit
966965
let mut call_request = CallRequest::default();
967966
let mut header = Header {
968967
base_fee_per_gas: Some(10_000_000_000),
@@ -982,7 +981,7 @@ mod tests {
982981
)
983982
.await;
984983
assert!(result.is_ok());
985-
assert_eq!(call_request.gas, Some(U256::from(300_000_000)));
984+
assert_eq!(call_request.gas, Some(U256::MAX));
986985
assert_eq!(header.base_fee_per_gas, Some(0));
987986

988987
// when gas price is populated but sender address is not populated, then

monad-rpc/src/handlers/eth/gas.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@ pub async fn monad_eth_estimateGas<T: Triedb>(
269269
};
270270

271271
let gas_specified = params.tx.gas.is_some();
272-
let provider_gas_limit = provider_gas_limit.min(header.header.gas_limit);
273272
let original_tx_gas = params.tx.gas.unwrap_or(U256::from(header.header.gas_limit));
274273
fill_gas_params(
275274
triedb_env,

0 commit comments

Comments
 (0)