From 870f86bb444ca0fab7cb3277414b4a23c9bf3b4b Mon Sep 17 00:00:00 2001 From: Aayush Date: Mon, 23 Feb 2026 11:50:38 -0500 Subject: [PATCH] fix(giga): bail on wrong nonce as v2 does --- app/app.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/app/app.go b/app/app.go index c2cb9258bc..85e844d6a6 100644 --- a/app/app.go +++ b/app/app.go @@ -1746,6 +1746,24 @@ func (app *App) executeEVMTxWithGigaExecutor(ctx sdk.Context, msg *evmtypes.MsgE _, isAssociated := app.GigaEvmKeeper.GetEVMAddress(ctx, seiAddr) + // ============================================================================ + // Nonce validation (mirrors V2's ante handler check in x/evm/ante/sig.go) + // V2 rejects with ErrWrongSequence if txNonce != expectedNonce, with NO state changes. + // ============================================================================ + expectedNonce := app.GigaEvmKeeper.GetNonce(ctx, sender) + txNonce := ethTx.Nonce() + if txNonce != expectedNonce { + nonceDirection := "too high" + if txNonce < expectedNonce { + nonceDirection = "too low" + } + return &abci.ExecTxResult{ + Code: sdkerrors.ErrWrongSequence.ABCICode(), + GasWanted: int64(ethTx.Gas()), //nolint:gosec + Log: fmt.Sprintf("nonce %s: address %s, tx: %d state: %d: %s", nonceDirection, sender.Hex(), txNonce, expectedNonce, sdkerrors.ErrWrongSequence.Error()), + }, nil + } + // ============================================================================ // Fee validation (mirrors V2's ante handler checks in evm_checktx.go) // NOTE: In V2, failed transactions still increment nonce and charge gas.