Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/changelog-check.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Check changelog update"
name: "Changelog"
on:
pull_request:
# The specific activity types are listed here to include "labeled" and "unlabeled"
Expand Down
2 changes: 1 addition & 1 deletion evm-e2e/test/eth_queries.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe("eth queries", () => {
}
const estimatedGas = await provider.estimateGas(tx)
expect(estimatedGas).toBeGreaterThan(BigInt(0))
expect(estimatedGas).toEqual(INTRINSIC_TX_GAS)
expect(estimatedGas - INTRINSIC_TX_GAS).toBeLessThan(INTRINSIC_TX_GAS / BigInt(20))
})

it("eth_feeHistory", async () => {
Expand Down
16 changes: 7 additions & 9 deletions x/evm/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ const (
Erc20GasLimitExecute uint64 = 200_000
)

type contextKey string

const (
CtxKeyEvmSimulation contextKey = "evm_simulation"
CtxKeyGasEstimateZeroTolerance contextKey = "gas_estimate_zero_tolerance"
)

// BASE_FEE_MICRONIBI is the global base fee value for the network. It has a
// constant value of 1 unibi (micronibi) == 10^12 wei.
var (
Expand Down Expand Up @@ -123,15 +130,6 @@ const (
updateParamsName = "evm/MsgUpdateParams"
)

type CallType int

const (
// CallTypeRPC call type is used on requests to eth_estimateGas rpc API endpoint
CallTypeRPC CallType = iota + 1
// CallTypeSmart call type is used in case of smart contract methods calls
CallTypeSmart
)

var (
EVM_MODULE_ADDRESS gethcommon.Address
EVM_MODULE_ADDRESS_NIBI sdk.AccAddress
Expand Down
34 changes: 0 additions & 34 deletions x/evm/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ package evm

import (
"fmt"
"strings"

"github.com/cometbft/cometbft/crypto/tmhash"
sdk "github.com/cosmos/cosmos-sdk/types"
bank "github.com/cosmos/cosmos-sdk/x/bank/types"
gethcommon "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/vm"

"github.com/NibiruChain/nibiru/v2/eth"
)
Expand Down Expand Up @@ -114,38 +112,6 @@ func ValidateFunTokenBankMetadata(
return out, nil
}

// HandleOutOfGasPanic captures an sdk.ErrorOutOfGas panic and folds it into
// *errp, an error pointer.
// - If *errp is nil: sets *errp = vm.ErrOutOfGas
// - If *errp is non-nil: preserves it (do not overwrite)
// - Always applies `format` wrapping if *errp is non-nil after recovery
// - Re-panics for any non-OutOfGas panic
func HandleOutOfGasPanic(errp *error, format string) func() {
return func() {
if perr := recover(); perr != nil {
_, isOutOfGasPanic := perr.(sdk.ErrorOutOfGas)
switch {
case isOutOfGasPanic:
if errp != nil && *errp == nil {
*errp = vm.ErrOutOfGas
}
// else: preserve existing detailed error
case strings.Contains(fmt.Sprint(perr), vm.ErrOutOfGas.Error()):
if errp == nil {
errp = new(error)
}
*errp = fmt.Errorf("%s: %w", perr, vm.ErrOutOfGas)
default:
// Non-OOG panics are not handled here
panic(perr)
}
}
if errp != nil && *errp != nil && format != "" {
*errp = fmt.Errorf("%s: %w", format, *errp)
}
}
}

// Gracefully handles "out of gas"
func SafeConsumeGas(ctx sdk.Context, amount uint64, descriptor string) (err error) {
defer func() {
Expand Down
Loading
Loading