Skip to content

Commit

Permalink
feat: blacklist ante
Browse files Browse the repository at this point in the history
  • Loading branch information
javiersuweijie committed Jul 31, 2024
1 parent ae1c715 commit 5c6aa71
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/ante/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ante
import (
ibcante "github.com/cosmos/ibc-go/v7/modules/core/ante"
ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"
"github.com/terra-money/core/v2/app/ante/blacklist"
feesharekeeper "github.com/terra-money/core/v2/x/feeshare/keeper"

"github.com/cosmos/cosmos-sdk/client"
Expand Down Expand Up @@ -54,6 +55,7 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first
wasmkeeper.NewLimitSimulationGasDecorator(options.WasmConfig.SimulationGasLimit),
wasmkeeper.NewCountTXDecorator(options.TxCounterStoreKey),
blacklist.NewBlacklistDecorator(),
ante.NewExtensionOptionsDecorator(options.ExtensionOptionChecker),
ante.NewValidateBasicDecorator(),
ante.NewTxTimeoutHeightDecorator(),
Expand Down
31 changes: 31 additions & 0 deletions app/ante/blacklist/blacklist.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package blacklist

import (
"fmt"
sdk "github.com/cosmos/cosmos-sdk/types"
authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
)

var Blacklist = map[string]bool{
// IBC exploiter
"terra1wrve5z5vsmrgy6ldcveq93aldr6wk3qmxavs4j": true,
}

type BlacklistAnteHandler struct {
}

func NewBlacklistDecorator() BlacklistAnteHandler {
return BlacklistAnteHandler{}
}

func (b BlacklistAnteHandler) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) {
sigTx, ok := tx.(authsigning.SigVerifiableTx)
if ok {
for _, sig := range sigTx.GetSigners() {
if Blacklist[sig.String()] {
return ctx, fmt.Errorf("signer %s is blacklisted", sig.String())
}
}
}
return next(ctx, tx, simulate)
}

0 comments on commit 5c6aa71

Please sign in to comment.