Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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/e2e-evm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.24
go-version: 1.22
cache: true

# Use GitHub actions output paramters to get go paths. For more info, see
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- uses: actions/setup-go@v5
if: steps.check_nibiru_go.outputs.nibiru-go == 'true'
with:
go-version: 1.24
go-version: 1.22
cache: false # the golangci-lint action already caches for us (https://github.com/golangci/golangci-lint-action#performance)

# Use GitHub actions output paramters to get go paths. For more info, see
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
if: steps.check_nibiru_go.outputs.nibiru-go == 'true'
uses: actions/setup-go@v5
with:
go-version: 1.24
go-version: 1.22
cache: true

# Use GitHub actions output paramters to get go paths. For more info, see
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/simulation-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.24
go-version: 1.22
cache: true
- name: TestAppStateDeterminism
run: |
Expand All @@ -28,7 +28,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.24
go-version: 1.22
cache: true
- name: TestFullAppSimulation
run: |
Expand All @@ -40,7 +40,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.24
go-version: 1.22
cache: true
- name: TestAppImportExport
run: |
Expand All @@ -52,7 +52,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.24
go-version: 1.22
cache: true
- name: TestAppSimulationAfterImport
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
if: steps.check_nibiru_go.outputs.nibiru-go == 'true'
uses: actions/setup-go@v5
with:
go-version: 1.24
go-version: 1.22
cache: true

# Use GitHub actions output paramters to get go paths. For more info, see
Expand Down Expand Up @@ -94,7 +94,7 @@ jobs:
if: steps.check_nibiru_go.outputs.nibiru-go == 'true'
uses: actions/setup-go@v5
with:
go-version: 1.24
go-version: 1.22

- name: "Install just"
if: steps.check_nibiru_go.outputs.nibiru-go == 'true'
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased

- [#2270](https://github.com/NibiruChain/nibiru/pull/2270) - refactor(app): remove private keeper struct and transient/mem keys from app
- [#2274](https://github.com/NibiruChain/nibiru/pull/2274) - feat(evm)!: update to geth v1.13 with EIP-1153, PRECOMPILE_ADDRS, and transient storage support

## v2.3.0

Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ARG src=base

# ---------- Build Stage ----------
FROM golang:1.24 AS build-base
FROM golang:1.22 AS build-base

WORKDIR /nibiru

Expand Down Expand Up @@ -74,4 +74,4 @@ RUN apk --no-cache add ca-certificates
COPY --from=build-source /root/nibid /usr/local/bin/nibid

ENTRYPOINT ["nibid"]
CMD ["start"]
CMD ["start"]
2 changes: 1 addition & 1 deletion api/nibiru/sudo/v1/event.pulsar.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 11 additions & 7 deletions app/evmante/evmante_can_transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@
ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler,
) (sdk.Context, error) {
ethCfg := evm.EthereumConfig(ctd.EVMKeeper.EthChainID(ctx))
signer := gethcore.MakeSigner(ethCfg, big.NewInt(ctx.BlockHeight()))
signer := gethcore.MakeSigner(
ethCfg,
big.NewInt(ctx.BlockHeight()),
evm.ParseBlockTimeUnixU64(ctx),
)

for _, msg := range tx.GetMsgs() {
msgEthTx, ok := msg.(*evm.MsgEthereumTx)
Expand Down Expand Up @@ -57,25 +61,25 @@
return ctx, errors.Wrapf(
sdkerrors.ErrInsufficientFee,
"gas fee cap (wei) less than block base fee (wei); (%s < %s)",
evmMsg.GasFeeCap(), baseFeeWeiPerGas,
evmMsg.GasFeeCap, baseFeeWeiPerGas,

Check warning on line 64 in app/evmante/evmante_can_transfer.go

View check run for this annotation

Codecov / codecov/patch

app/evmante/evmante_can_transfer.go#L64

Added line #L64 was not covered by tests
)
}

// check that caller has enough balance to cover asset transfer for **topmost** call
// NOTE: here the gas consumed is from the context with the infinite gas meter

if evmMsg.Value().Sign() > 0 {
nibiruAddr := eth.EthAddrToNibiruAddr(evmMsg.From())
if evmMsg.Value.Sign() > 0 {
nibiruAddr := eth.EthAddrToNibiruAddr(evmMsg.From)
balanceNative := ctd.Bank.GetBalance(ctx, nibiruAddr, evm.EVMBankDenom).Amount.BigInt()
balanceWei := evm.NativeToWei(balanceNative)

if balanceWei.Cmp(evmMsg.Value()) < 0 {
if balanceWei.Cmp(evmMsg.Value) < 0 {
return ctx, errors.Wrapf(
sdkerrors.ErrInsufficientFunds,
"failed to transfer %s wei ( balance=%s )from address %s using the EVM block context transfer function",
evmMsg.Value(),
evmMsg.Value,
balanceWei,
evmMsg.From(),
evmMsg.From,
)
}
}
Expand Down
4 changes: 2 additions & 2 deletions app/evmante/evmante_gas_consume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (s *TestSuite) TestAnteDecEthGasConsume() {
beforeTxSetup: func(deps *evmtest.TestDeps, sdb *statedb.StateDB) {
gasLimit := happyGasLimit()
balance := evm.NativeToWei(new(big.Int).Add(gasLimit, big.NewInt(100)))
sdb.AddBalance(deps.Sender.EthAddr, balance)
sdb.AddBalanceSigned(deps.Sender.EthAddr, balance)
},
txSetup: evmtest.HappyCreateContractTx,
wantErr: "",
Expand All @@ -47,7 +47,7 @@ func (s *TestSuite) TestAnteDecEthGasConsume() {
beforeTxSetup: func(deps *evmtest.TestDeps, sdb *statedb.StateDB) {
gasLimit := happyGasLimit()
balance := evm.NativeToWei(new(big.Int).Add(gasLimit, big.NewInt(100)))
sdb.AddBalance(deps.Sender.EthAddr, balance)
sdb.AddBalanceSigned(deps.Sender.EthAddr, balance)
},
txSetup: evmtest.HappyCreateContractTx,
wantErr: "exceeds block gas limit (0)",
Expand Down
2 changes: 1 addition & 1 deletion app/evmante/evmante_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (s *TestSuite) TestAnteHandlerEVM() {
name: "happy: signed tx, sufficient funds",
beforeTxSetup: func(deps *evmtest.TestDeps, sdb *statedb.StateDB) {
balanceMicronibi := new(big.Int).Add(evmtest.GasLimitCreateContract(), big.NewInt(100))
sdb.AddBalance(
sdb.AddBalanceSigned(
deps.Sender.EthAddr,
evm.NativeToWei(balanceMicronibi),
)
Expand Down
4 changes: 2 additions & 2 deletions app/evmante/evmante_increment_sender_seq_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func (s *TestSuite) TestAnteDecEthIncrementSenderSequence() {
name: "happy: single message",
beforeTxSetup: func(deps *evmtest.TestDeps, sdb *statedb.StateDB) {
balance := big.NewInt(100)
sdb.AddBalance(deps.Sender.EthAddr, balance)
sdb.AddBalanceSigned(deps.Sender.EthAddr, balance)
},
txSetup: func(deps *evmtest.TestDeps) sdk.Tx {
return evmtest.HappyTransferTx(deps, 0)
Expand All @@ -34,7 +34,7 @@ func (s *TestSuite) TestAnteDecEthIncrementSenderSequence() {
name: "happy: two messages",
beforeTxSetup: func(deps *evmtest.TestDeps, sdb *statedb.StateDB) {
balance := big.NewInt(100)
sdb.AddBalance(deps.Sender.EthAddr, balance)
sdb.AddBalanceSigned(deps.Sender.EthAddr, balance)
},
txSetup: func(deps *evmtest.TestDeps) sdk.Tx {
txMsgOne := evmtest.HappyTransferTx(deps, 0)
Expand Down
6 changes: 5 additions & 1 deletion app/evmante/evmante_sigverify.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ func (esvd EthSigVerificationDecorator) AnteHandle(
chainID := esvd.evmKeeper.EthChainID(ctx)
ethCfg := evm.EthereumConfig(chainID)
blockNum := big.NewInt(ctx.BlockHeight())
signer := gethcore.MakeSigner(ethCfg, blockNum)
signer := gethcore.MakeSigner(
ethCfg,
blockNum,
evm.ParseBlockTimeUnixU64(ctx),
)

for _, msg := range tx.GetMsgs() {
msgEthTx, ok := msg.(*evm.MsgEthereumTx)
Expand Down
2 changes: 1 addition & 1 deletion app/evmante/evmante_verify_eth_acc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func (s *TestSuite) TestAnteDecoratorVerifyEthAcc_CheckTx() {
{
name: "happy: sender with funds",
beforeTxSetup: func(deps *evmtest.TestDeps, sdb *statedb.StateDB) {
sdb.AddBalance(deps.Sender.EthAddr, evm.NativeToWei(happyGasLimit()))
sdb.AddBalanceSigned(deps.Sender.EthAddr, evm.NativeToWei(happyGasLimit()))
},
txSetup: evmtest.HappyCreateContractTx,
wantErr: "",
Expand Down
2 changes: 1 addition & 1 deletion app/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ func (app *NibiruApp) initNonDepinjectKeepers(

app.GovKeeper.SetLegacyRouter(govRouter)

app.EvmKeeper.AddPrecompiles(precompile.InitPrecompiles(app.AppKeepers.PublicKeepers))
precompile.InitPrecompiles(app.AppKeepers.PublicKeepers)

return wasmConfig
}
Expand Down
110 changes: 110 additions & 0 deletions app/server/geth_log_handler.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
package server

import (
"context"

cmtlog "github.com/cometbft/cometbft/libs/log"
gethlog "github.com/ethereum/go-ethereum/log"

// Use "log/slog" from the Go std lib because Geth migrated to support
// slog and deprecated the original go-ethereum/log implementation.
// For more info on the migration, see https://github.com/ethereum/go-ethereum/pull/28187
"golang.org/x/exp/slog"
)

// Ensure LogHandler implements slog.Handler
var _ slog.Handler = (*LogHandler)(nil)

// LogHandler implements slog.Handler, which is needed to construct the
// conventional go-ethereum.Logger, using a CometBFT logger
// ("github.com/cometbft/cometbft/libs/log".Logger).
type LogHandler struct {
CmtLogger cmtlog.Logger
attrs []slog.Attr // Attributes gathered via WithAttrs
group string // Group name gathered via WithGroup (simple implementation)
}

// Enabled decides whether a log record should be processed.
// We let the underlying CometBFT logger handle filtering.
func (h *LogHandler) Enabled(_ context.Context, level slog.Level) bool {
// You could potentially check the CmtLogger's level here if needed,
// but returning true is usually sufficient.
return true
}

// Handle processes the log record and sends it to the CometBFT logger.
func (h *LogHandler) Handle(_ context.Context, r slog.Record) error {
// 1. Determine the corresponding CometBFT log function
var logFunc func(msg string, keyvals ...interface{})
switch r.Level {
// Check against Geth's custom levels first if they exist
// This handler covers all defined slog and go-ethereum log levels.
case gethlog.LevelTrace, slog.LevelDebug: // Handles -8, -4
logFunc = h.CmtLogger.Debug
case slog.LevelInfo, slog.LevelWarn: // Handles 0, 4
logFunc = h.CmtLogger.Info
case gethlog.LevelCrit, slog.LevelError: // Handles 12, 8
// Map Geth Crit level along with standard Error
logFunc = h.CmtLogger.Error
default: // Handle any other levels (e.g., below Debug)
logFunc = h.CmtLogger.Debug // Default to Debug or Info as appropriate

Check warning on line 50 in app/server/geth_log_handler.go

View check run for this annotation

Codecov / codecov/patch

app/server/geth_log_handler.go#L46-L50

Added lines #L46 - L50 were not covered by tests
}
Comment on lines +38 to +50
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Compile‑time type mismatch between slog.Level and gethlog.Lvl

r.Level is of type slog.Level, whereas gethlog.LevelTrace / LevelCrit are of the distinct type gethlog.Lvl.
The comparison in the switch therefore fails to compile:

cannot use gethlog.LevelTrace (untyped int constant) as type slog.Level in case expression

A simple fix is to map purely on slog.Level:

-    switch r.Level {
-    case gethlog.LevelTrace, slog.LevelDebug: // Handles -8, -4
-        logFunc = h.CmtLogger.Debug
-    case slog.LevelInfo, slog.LevelWarn: // Handles 0, 4
-        logFunc = h.CmtLogger.Info
-    case gethlog.LevelCrit, slog.LevelError: // Handles 12, 8
-        logFunc = h.CmtLogger.Error
-    default:
-        logFunc = h.CmtLogger.Debug
-    }
+    switch {
+    case r.Level < slog.LevelInfo: // Debug & anything more verbose
+        logFunc = h.CmtLogger.Debug
+    case r.Level < slog.LevelError: // Info & Warn
+        logFunc = h.CmtLogger.Info
+    default: // Error and above
+        logFunc = h.CmtLogger.Error
+    }

This removes the cross‑package constant dependency, compiles cleanly, and still preserves the intended level mapping.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
switch r.Level {
// Check against Geth's custom levels first if they exist
// This handler covers all defined slog and go-ethereum log levels.
case gethlog.LevelTrace, slog.LevelDebug: // Handles -8, -4
logFunc = h.CmtLogger.Debug
case slog.LevelInfo, slog.LevelWarn: // Handles 0, 4
logFunc = h.CmtLogger.Info
case gethlog.LevelCrit, slog.LevelError: // Handles 12, 8
// Map Geth Crit level along with standard Error
logFunc = h.CmtLogger.Error
default: // Handle any other levels (e.g., below Debug)
logFunc = h.CmtLogger.Debug // Default to Debug or Info as appropriate
}
switch {
case r.Level < slog.LevelInfo: // Debug & anything more verbose
logFunc = h.CmtLogger.Debug
case r.Level < slog.LevelError: // Info & Warn
logFunc = h.CmtLogger.Info
default: // Error and above
logFunc = h.CmtLogger.Error
}


// 2. Collect attributes (key-value pairs)
// Preallocate assuming 2 slots per attribute plus handler attrs
keyvals := make([]interface{}, 0, (r.NumAttrs()+len(h.attrs))*2)

// Add attributes stored in the handler first (from WithAttrs)
currentGroup := h.group
for _, attr := range h.attrs {
key := attr.Key
if currentGroup != "" {
key = currentGroup + "." + key // Basic grouping
}

Check warning on line 63 in app/server/geth_log_handler.go

View check run for this annotation

Codecov / codecov/patch

app/server/geth_log_handler.go#L62-L63

Added lines #L62 - L63 were not covered by tests
keyvals = append(keyvals, key, attr.Value.Any())
}

// Add attributes from the specific log record
r.Attrs(func(attr slog.Attr) bool {
key := attr.Key
if currentGroup != "" {
key = currentGroup + "." + key // Basic grouping
}

Check warning on line 72 in app/server/geth_log_handler.go

View check run for this annotation

Codecov / codecov/patch

app/server/geth_log_handler.go#L71-L72

Added lines #L71 - L72 were not covered by tests
keyvals = append(keyvals, key, attr.Value.Any())
return true // Continue iterating
})

// 3. Call the CometBFT logger function
logFunc(r.Message, keyvals...)

return nil // No error to return in this basic implementation
}

// WithAttrs returns a new LogHandler with the provided attributes added.
func (h *LogHandler) WithAttrs(attrs []slog.Attr) slog.Handler {
// Create a new handler, cloning existing state and adding new attrs
newHandler := &LogHandler{
CmtLogger: h.CmtLogger, // Keep the same underlying logger
// Important: Clone slices to avoid modifying the original handler's state
attrs: append(append([]slog.Attr{}, h.attrs...), attrs...),
group: h.group,
}
return newHandler
}

// WithGroup returns a new LogHandler associated with the specified group.
func (h *LogHandler) WithGroup(name string) slog.Handler {
// Create a new handler, cloning attributes and setting/appending the group
newHandler := &LogHandler{
CmtLogger: h.CmtLogger,
attrs: append([]slog.Attr{}, h.attrs...), // Clone attributes
// Basic implementation: Overwrites group. Could concatenate if nesting needed.
group: name,
}
// If nested groups are needed:
// if h.group != "" {
// name = h.group + "." + name
// }
// newHandler.group = name
return newHandler

Check warning on line 109 in app/server/geth_log_handler.go

View check run for this annotation

Codecov / codecov/patch

app/server/geth_log_handler.go#L96-L109

Added lines #L96 - L109 were not covered by tests
}
25 changes: 9 additions & 16 deletions app/server/json_rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/server"
"github.com/cosmos/cosmos-sdk/server/types"
ethlog "github.com/ethereum/go-ethereum/log"
ethrpc "github.com/ethereum/go-ethereum/rpc"
gethlog "github.com/ethereum/go-ethereum/log"
gethrpc "github.com/ethereum/go-ethereum/rpc"

srvconfig "github.com/NibiruChain/nibiru/v2/app/server/config"
)
Expand All @@ -31,20 +31,13 @@
) (*http.Server, chan struct{}, error) {
tmWsClientForRPCApi := ConnectTmWS(tmRPCAddr, tmEndpoint, ctx.Logger)

logger := ctx.Logger.With("module", "geth")
ethlog.Root().SetHandler(ethlog.FuncHandler(func(r *ethlog.Record) error {
switch r.Lvl {
case ethlog.LvlTrace, ethlog.LvlDebug:
logger.Debug(r.Msg, r.Ctx...)
case ethlog.LvlInfo, ethlog.LvlWarn:
logger.Info(r.Msg, r.Ctx...)
case ethlog.LvlError, ethlog.LvlCrit:
logger.Error(r.Msg, r.Ctx...)
}
return nil
}))
// Configure the go-ethereum logger to sync with the ctx.Logger
gethLogger := gethlog.NewLogger(&LogHandler{
CmtLogger: ctx.Logger.With("module", "geth"),
})
gethlog.SetDefault(gethLogger)

rpcServer := ethrpc.NewServer()
rpcServer := gethrpc.NewServer()

allowUnprotectedTxs := config.JSONRPC.AllowUnprotectedTxs
rpcAPIArr := config.JSONRPC.API
Expand All @@ -53,7 +46,7 @@

for _, api := range apis {
if err := rpcServer.RegisterName(api.Namespace, api.Service); err != nil {
ctx.Logger.Error(
gethLogger.Error(

Check warning on line 49 in app/server/json_rpc.go

View check run for this annotation

Codecov / codecov/patch

app/server/json_rpc.go#L49

Added line #L49 was not covered by tests
"failed to register service in JSON RPC namespace",
"namespace", api.Namespace,
"service", api.Service,
Expand Down
Loading
Loading