Skip to content

Commit

Permalink
Logging invalid data items after recheck
Browse files Browse the repository at this point in the history
  • Loading branch information
szynwelski committed Oct 18, 2023
1 parent c970a5a commit 6abc9e1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
36 changes: 29 additions & 7 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1"
"cosmossdk.io/errors"
dbm "github.com/cometbft/cometbft-db"
abci "github.com/cometbft/cometbft/abci/types"
"github.com/cometbft/cometbft/libs/log"
Expand All @@ -27,7 +28,6 @@ import (
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"cosmossdk.io/errors"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/auth"
Expand Down Expand Up @@ -640,11 +640,11 @@ func New(
// initialize BaseApp
anteHandler, err := sequencerante.NewAnteHandler(
sequencerante.HandlerOptions{
AccountKeeper: app.AccountKeeper,
BankKeeper: app.BankKeeper,
FeegrantKeeper: app.FeeGrantKeeper,
SignModeHandler: encodingConfig.TxConfig.SignModeHandler(),
SigGasConsumer: sequencerante.SigVerificationGasConsumer,
AccountKeeper: app.AccountKeeper,
BankKeeper: app.BankKeeper,
FeegrantKeeper: app.FeeGrantKeeper,
SignModeHandler: encodingConfig.TxConfig.SignModeHandler(),
SigGasConsumer: sequencerante.SigVerificationGasConsumer,
},
)
if err != nil {
Expand Down Expand Up @@ -865,7 +865,9 @@ func (app *App) CheckTx(req abci.RequestCheckTx) abci.ResponseCheckTx {
return res
}
}
return app.BaseApp.CheckTx(req)
res := app.BaseApp.CheckTx(req)
app.logInvalidDataItemAfterRecheck(req, res)
return res
}

func (app *App) checkDataItemAlreadyInBlock(txBytes []byte) (bool, abci.ResponseCheckTx) {
Expand All @@ -884,3 +886,23 @@ func (app *App) checkDataItemAlreadyInBlock(txBytes []byte) (bool, abci.Response
}
return true, abci.ResponseCheckTx{}
}

func (app *App) logInvalidDataItemAfterRecheck(req abci.RequestCheckTx, res abci.ResponseCheckTx) {
if req.Type != abci.CheckTxType_Recheck || res.Code == abci.CodeTypeOK {
return
}

tx, err := app.txConfig.TxDecoder()(req.Tx)
if err != nil {
return
}

dataItem, err := sequencerante.GetL2Interaction(tx)
if dataItem == nil || err != nil {
return
}

app.Logger().
With("info", dataItem.GetInfo()).
Info("Data item is no longer valid")
}
2 changes: 1 addition & 1 deletion x/sequencer/types/message_data_item.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,6 @@ func (msg *MsgDataItem) GetInfo() DataItemInfo {
return DataItemInfo{
DataItemId: msg.DataItem.Id.Base64(),
Nonce: nonce,
Sender: msg.GetSigners()[0].String(),
Sender: msg.GetCreator().String(),
}
}

0 comments on commit 6abc9e1

Please sign in to comment.