Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 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
55 changes: 0 additions & 55 deletions .github/workflows/e2e-wasm.yml
Copy link
Member Author

@Unique-Divine Unique-Divine Apr 17, 2025

Choose a reason for hiding this comment

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

Because it was outdated and not adding much value at all

This file was deleted.

5 changes: 4 additions & 1 deletion .golangci.yml
Copy link
Member Author

Choose a reason for hiding this comment

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

The "misspell" linter was in conflict with the use of British English in imports from go-ethereum. It kept renaming StateDB functions and breaking interface compatibility

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ issues:
linters:
enable:
- whitespace
- misspell
- goimports
linters-settings:
misspell:
Expand All @@ -20,5 +19,9 @@ linters-settings:
# Put imports beginning with prefix after 3rd-party packages.
# It's a comma-separated list of prefixes.
local-prefixes: github.com/NibiruChain/nibiru
revive:
rules:
- name: exported
disabled: true
severity:
default-severity: error
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- [#2271](https://github.com/NibiruChain/nibiru/pull/2271) - fix(ci): update tag-pattern for changelog step in releases
- [#2270](https://github.com/NibiruChain/nibiru/pull/2270) - refactor(app): remove private keeper struct and transient/mem keys from app
<<<<<<< HEAD
- [#2274](https://github.com/NibiruChain/nibiru/pull/2274) - feat(evm)!: update to geth v1.13 with EIP-1153, PRECOMPILE_ADDRS, and transient storage support
- [#2275](https://github.com/NibiruChain/nibiru/pull/2275) - feat(evm)!: update
to geth v1.14 with tracing updates and new StateDB methods.
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

Fix bullet formatting for PR #2275 entry.
The PR entry for [#2275] is split across two lines without proper continuation indentation. Combine it into a single bullet or indent the second line as a nested continuation, for example:

- [#2275](.../2275) - feat(evm)!: update to geth v1.14 with tracing updates and new StateDB methods.

- This upgrade keeps Nibiru's EVM on the Berlin upgrade to avoid
incompatibilities stemming from functionality specific to Ethereum's consesnus
setup. Namely, blobs (Cancun) and Verkle additions for zkEVM.
- The jump to v1.14 was necessary to use an up-to-date "cockroach/pebble" DB
dependency and leverage new generics features added in Go 1.23+.
- [#2288](https://github.com/NibiruChain/nibiru/pull/2288) - chore(ci): add workflow to check for missing upgrade handler
- [#2278](https://github.com/NibiruChain/nibiru/pull/2278) - chore: migrate to cosmossdk.io/mathLegacyDec and cosmossdk.io/math.Int

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
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 LEGACY-CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ NOTE: It's pragmatic to assume that any change prior to v1.0.0 was state machine
- [#1459](https://github.com/NibiruChain/nibiru/pull/1459) - fix(spot): wire `x/spot` msgService into app router
- [#1452](https://github.com/NibiruChain/nibiru/pull/1452) - fix(oracle): continue with abci hook during error
- [#1451](https://github.com/NibiruChain/nibiru/pull/1451) - fix(perp): decrease position with zero size
- [#1446](https://github.com/NibiruChain/nibiru/pull/1446) - fix(cmd): Add custom InitCmd to set set desired Tendermint consensus params for each node.
- [#1446](https://github.com/NibiruChain/nibiru/pull/1446) - fix(cmd): Add custom InitCmd to set desired Tendermint consensus params for each node.
- [#1441](https://github.com/NibiruChain/nibiru/pull/1441) - fix(oracle): ignore abstain votes in std dev calculation
- [#1425](https://github.com/NibiruChain/nibiru/pull/1425) - fix: remove positions from state when closed with reverse position
- [#1423](https://github.com/NibiruChain/nibiru/pull/1423) - fix: remove panics from abci hooks
Expand Down
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 @@ func (ctd CanTransferDecorator) AnteHandle(
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 @@ func (ctd CanTransferDecorator) AnteHandle(
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 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
2 changes: 1 addition & 1 deletion app/evmante/evmante_gas_consume.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func (anteDec AnteDecEthGasConsume) AnteHandle(
fees, err := keeper.VerifyFee(
txData,
baseFeeMicronibiPerGas,
ctx.IsCheckTx(),
ctx,
)
if err != nil {
return ctx, errors.Wrapf(err, "failed to verify the fees")
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.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (anteDec AnteDecVerifyEthAcc) AnteHandle(
}

if err := keeper.CheckSenderBalance(
evm.NativeToWei(acct.BalanceNative), txData,
evm.NativeToWei(acct.BalanceNative.ToBig()), txData,
); err != nil {
return ctx, errors.Wrap(err, "failed to check sender balance")
}
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 @@ -347,7 +347,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
109 changes: 109 additions & 0 deletions app/server/geth_log_handler.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
package server

import (
// 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
"context"
"log/slog"

cmtlog "github.com/cometbft/cometbft/libs/log"
gethlog "github.com/ethereum/go-ethereum/log"
)
Comment on lines +10 to +12
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

gethlog import becomes unused after level‑mapping fix

Once the switch statement stops referencing gethlog.Level* constants (see next comment) the gethlog import is redundant and should be dropped to keep go vet happy.

-import (
-
-    gethlog "github.com/ethereum/go-ethereum/log"
-)
+import (
+
+)
📝 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
cmtlog "github.com/cometbft/cometbft/libs/log"
gethlog "github.com/ethereum/go-ethereum/log"
)
import (
cmtlog "github.com/cometbft/cometbft/libs/log"
)


// 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
}
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
}
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
}
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
}
Loading
Loading