Skip to content

Commit

Permalink
more debugging, simulation gas limit
Browse files Browse the repository at this point in the history
  • Loading branch information
lumtis committed Nov 18, 2024
1 parent 74d3082 commit 7899157
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 8 deletions.
4 changes: 3 additions & 1 deletion v2/contracts/zevm/GatewayZEVM.sol
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ contract GatewayZEVM is
/// https://github.com/zeta-chain/node/pull/3106
uint256 public constant MAX_GAS_LIMIT = 2_000_000;

uint256 public constant SIMULATION_GAS_LIMIT = 24_000_000;

/// @dev Only protocol address allowed modifier.
modifier onlyProtocol() {
if (msg.sender != PROTOCOL_ADDRESS) {
Expand Down Expand Up @@ -384,7 +386,7 @@ contract GatewayZEVM is

// TODO: remove after the protocol upgrad with this change: https://github.com/zeta-chain/node/pull/3106
uint256 leftGas = uint256(gasleft());
if (leftGas > MAX_GAS_LIMIT) {
if (leftGas > MAX_GAS_LIMIT && leftGas < SIMULATION_GAS_LIMIT) {
revert GasLimitExceeded();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ uint256 public constant MAX_GAS_LIMIT = 2_000_000;
```


### SIMULATION_GAS_LIMIT

```solidity
uint256 public constant SIMULATION_GAS_LIMIT = 24_000_000;
```


## Functions
### onlyProtocol

Expand Down
2 changes: 1 addition & 1 deletion v2/pkg/gatewayevmzevm.t.sol/gatewayevmzevmtest.go

Large diffs are not rendered by default.

35 changes: 33 additions & 2 deletions v2/pkg/gatewayzevm.sol/gatewayzevm.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion v2/pkg/gatewayzevm.t.sol/gatewayzevminboundtest.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion v2/pkg/gatewayzevm.t.sol/gatewayzevmoutboundtest.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion v2/pkg/zrc20.t.sol/zrc20test.go

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions v2/types/GatewayZEVM.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export interface GatewayZEVMInterface extends Interface {
| "MAX_MESSAGE_SIZE"
| "PAUSER_ROLE"
| "PROTOCOL_ADDRESS"
| "SIMULATION_GAS_LIMIT"
| "UPGRADE_INTERFACE_VERSION"
| "call"
| "deposit"
Expand Down Expand Up @@ -150,6 +151,10 @@ export interface GatewayZEVMInterface extends Interface {
functionFragment: "PROTOCOL_ADDRESS",
values?: undefined
): string;
encodeFunctionData(
functionFragment: "SIMULATION_GAS_LIMIT",
values?: undefined
): string;
encodeFunctionData(
functionFragment: "UPGRADE_INTERFACE_VERSION",
values?: undefined
Expand Down Expand Up @@ -291,6 +296,10 @@ export interface GatewayZEVMInterface extends Interface {
functionFragment: "PROTOCOL_ADDRESS",
data: BytesLike
): Result;
decodeFunctionResult(
functionFragment: "SIMULATION_GAS_LIMIT",
data: BytesLike
): Result;
decodeFunctionResult(
functionFragment: "UPGRADE_INTERFACE_VERSION",
data: BytesLike
Expand Down Expand Up @@ -636,6 +645,8 @@ export interface GatewayZEVM extends BaseContract {

PROTOCOL_ADDRESS: TypedContractMethod<[], [string], "view">;

SIMULATION_GAS_LIMIT: TypedContractMethod<[], [bigint], "view">;

UPGRADE_INTERFACE_VERSION: TypedContractMethod<[], [string], "view">;

call: TypedContractMethod<
Expand Down Expand Up @@ -829,6 +840,9 @@ export interface GatewayZEVM extends BaseContract {
getFunction(
nameOrSignature: "PROTOCOL_ADDRESS"
): TypedContractMethod<[], [string], "view">;
getFunction(
nameOrSignature: "SIMULATION_GAS_LIMIT"
): TypedContractMethod<[], [bigint], "view">;
getFunction(
nameOrSignature: "UPGRADE_INTERFACE_VERSION"
): TypedContractMethod<[], [string], "view">;
Expand Down
15 changes: 14 additions & 1 deletion v2/types/factories/GatewayZEVM__factory.ts

Large diffs are not rendered by default.

0 comments on commit 7899157

Please sign in to comment.