Skip to content

Commit

Permalink
allow custom view gas limit
Browse files Browse the repository at this point in the history
  • Loading branch information
oXtxNt9U committed Dec 11, 2024
1 parent e3360b1 commit 6099e67
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/evm-consensus/source/services/votes-iterator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export class AsyncVotesIterator implements AsyncIterable<Contracts.Evm.Vote> {
data: Buffer.from(data, "hex"),
recipient: consensusContractAddress,
specId: evmSpec,
gasLimit: 100_000_000n,
});

if (!result.success) {
Expand Down
11 changes: 10 additions & 1 deletion packages/evm/bindings/src/ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub struct JsTransactionViewContext {
pub recipient: JsString,
pub data: JsBuffer,
pub spec_id: JsString,
pub gas_limit: Option<JsBigInt>,
}

#[napi(object)]
Expand Down Expand Up @@ -102,6 +103,7 @@ pub struct TxViewContext {
pub recipient: Address,
pub data: Bytes,
pub spec_id: SpecId,
pub gas_limit: Option<u64>,
}

#[derive(Debug)]
Expand Down Expand Up @@ -158,7 +160,7 @@ impl From<TxViewContext> for ExecutionContext {
Self {
caller: value.caller,
recipient: Some(value.recipient),
gas_limit: None,
gas_limit: value.gas_limit,
gas_price: None,
value: U256::ZERO,
nonce: None,
Expand Down Expand Up @@ -264,11 +266,18 @@ impl TryFrom<JsTransactionViewContext> for TxViewContext {
fn try_from(value: JsTransactionViewContext) -> std::result::Result<Self, Self::Error> {
let buf = value.data.into_value()?;

let gas_limit = if let Some(gas_limit) = value.gas_limit {
Some(gas_limit.get_u64()?.0)
} else {
None
};

let tx_ctx = TxViewContext {
caller: utils::create_address_from_js_string(value.caller)?,
recipient: utils::create_address_from_js_string(value.recipient)?,
data: Bytes::from(buf.as_ref().to_owned()),
spec_id: parse_spec_id(value.spec_id)?,
gas_limit,
};

Ok(tx_ctx)
Expand Down

0 comments on commit 6099e67

Please sign in to comment.