Skip to content

Commit

Permalink
Various blocklist and pause check enhancements (#24)
Browse files Browse the repository at this point in the history
This PR accomplishes the following:

- Apply blocklist check to sender & recipient of every transfer event in
abci
- Extend pause check to `MsgGrant` and `MsgConfigureMinter`
- Migrate blockibc module from
[noble](https://github.com/noble-assets/noble) to fiattokenfactory
module.
  • Loading branch information
yvonnezhangc authored Apr 12, 2024
2 parents 14edf83 + 9c86d05 commit 0a7385d
Show file tree
Hide file tree
Showing 17 changed files with 646 additions and 1,518 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ test: test-e2e test-unit

test-e2e:
@echo "🤖 Running e2e tests..."
@cd e2e && GOWORK=off go test -race -v ./...
@cd e2e && GOWORK=off go test -timeout 0 -race -v ./...
@echo "✅ Completed e2e tests!"

test-unit:
Expand Down
2 changes: 1 addition & 1 deletion e2e/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ func nobleChainSpec(
ChainID: chainID,
Bin: "simd", // "nobled",
Denom: "token",
Bech32Prefix: "cosmos", // "noble",
Bech32Prefix: "noble",
CoinType: "118",
GasPrices: "0.0token",
GasAdjustment: 1.1,
Expand Down
8 changes: 4 additions & 4 deletions e2e/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.21
require (
github.com/circlefin/noble-fiattokenfactory v1.0.0
github.com/cosmos/cosmos-sdk v0.45.16
github.com/cosmos/ibc-go/v4 v4.5.1
github.com/icza/dyno v0.0.0-20220812133438-f0b6f8a18845
github.com/strangelove-ventures/interchaintest/v4 v4.0.0-20231026153934-334934f17a68
github.com/stretchr/testify v1.8.4
Expand Down Expand Up @@ -42,7 +43,6 @@ require (
github.com/cosmos/go-bip39 v1.0.0 // indirect
github.com/cosmos/gorocksdb v1.2.0 // indirect
github.com/cosmos/iavl v0.19.5 // indirect
github.com/cosmos/ibc-go/v4 v4.5.1 // indirect
github.com/cosmos/ledger-cosmos-go v0.12.2 // indirect
github.com/danieljoos/wincred v1.1.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
Expand Down Expand Up @@ -90,7 +90,6 @@ require (
github.com/klauspost/compress v1.16.3 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/lib/pq v1.10.9 // indirect
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
github.com/linxGnu/grocksdb v1.7.10 // indirect
github.com/magiconair/properties v1.8.7 // indirect
Expand All @@ -99,10 +98,8 @@ require (
github.com/mimoo/StrobeGo v0.0.0-20220103164710-9a04d6ca976b // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mtibben/percent v0.2.1 // indirect
github.com/onsi/gomega v1.28.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0-rc2 // indirect
github.com/otiai10/copy v1.11.0 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
github.com/petermattis/goid v0.0.0-20230317030725-371a4b8eda08 // indirect
Expand Down Expand Up @@ -175,6 +172,9 @@ replace (
// https://github.com/cosmos/cosmos-sdk/issues/8469
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1

// use noble compatible strangelove-ventures/interchaintest
github.com/strangelove-ventures/interchaintest/v4 => github.com/noble-assets/interchaintest/v4 v4.0.0-20240310120800-113c680bdc4c

// use cosmos compatible syndtr/goleveldb
github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7

Expand Down
4 changes: 2 additions & 2 deletions e2e/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,8 @@ github.com/nats-io/nkeys v0.0.2/go.mod h1:dab7URMsZm6Z/jp9Z5UGa87Uutgc2mVpXLC4B7
github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w=
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/noble-assets/interchaintest/v4 v4.0.0-20240310120800-113c680bdc4c h1:f1e4yRB1Ph06TDZxOJUCzB0ZTN24gS+52xOpwysVvII=
github.com/noble-assets/interchaintest/v4 v4.0.0-20240310120800-113c680bdc4c/go.mod h1:oEYorKX6XBoQOrkVv9uhq4X0azZbEf5Jq6h3GN8jJ2w=
github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
Expand Down Expand Up @@ -656,8 +658,6 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
github.com/spf13/viper v1.15.0 h1:js3yy885G8xwJa6iOISGFwd+qlUo5AvyXb7CiihdtiU=
github.com/spf13/viper v1.15.0/go.mod h1:fFcTBJxvhhzSJiZy8n+PeW6t8l+KeT/uTARa0jHOQLA=
github.com/strangelove-ventures/interchaintest/v4 v4.0.0-20231026153934-334934f17a68 h1:f16Xo7gvZ/g3YyXsmUQBwvUcq0orQeBrIcdsyVrMrjU=
github.com/strangelove-ventures/interchaintest/v4 v4.0.0-20231026153934-334934f17a68/go.mod h1:oEYorKX6XBoQOrkVv9uhq4X0azZbEf5Jq6h3GN8jJ2w=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
Expand Down
250 changes: 223 additions & 27 deletions e2e/noble_test.go

Large diffs are not rendered by default.

1,603 changes: 129 additions & 1,474 deletions go.work.sum

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions simapp/abci.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package simapp

import (
"github.com/cosmos/cosmos-sdk/types/errors"
abci "github.com/tendermint/tendermint/abci/types"
)

func (app *SimApp) DeliverTx(req abci.RequestDeliverTx) abci.ResponseDeliverTx {
res := app.BaseApp.DeliverTx(req)
ctx := app.BaseApp.DeliverState.Context()

for _, event := range res.Events {
err := app.FiatTokenFactoryKeeper.HandleDeliverTxEvent(ctx, event)
if err != nil {
app.SetDeliverState(ctx.BlockHeader())
return errors.ResponseDeliverTxWithEvents(err, uint64(res.GasWanted), uint64(res.GasUsed), res.Events, app.Trace())
}
}

return res
}
4 changes: 3 additions & 1 deletion simapp/ante_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package simapp
import (
"github.com/circlefin/noble-fiattokenfactory/x/fiattokenfactory"
fiattokenfactorykeeper "github.com/circlefin/noble-fiattokenfactory/x/fiattokenfactory/keeper"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
Expand All @@ -17,6 +18,7 @@ type HandlerOptions struct {
IBCKeeper *keeper.Keeper

// FiatTokenFactory
cdc codec.Codec
FiatTokenFactoryKeeper *fiattokenfactorykeeper.Keeper
}

Expand Down Expand Up @@ -44,7 +46,7 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
ante.NewSetUpContextDecorator(),
ante.NewRejectExtensionOptionsDecorator(),
fiattokenfactory.NewIsBlacklistedDecorator(options.FiatTokenFactoryKeeper),
fiattokenfactory.NewIsPausedDecorator(options.FiatTokenFactoryKeeper),
fiattokenfactory.NewIsPausedDecorator(options.cdc, options.FiatTokenFactoryKeeper),
ante.NewMempoolFeeDecorator(),
ante.NewValidateBasicDecorator(),
ante.NewTxTimeoutHeightDecorator(),
Expand Down
4 changes: 4 additions & 0 deletions simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ import (
authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper"
authzmodule "github.com/cosmos/cosmos-sdk/x/authz/module"

// BlockIBC
"github.com/circlefin/noble-fiattokenfactory/x/blockibc"
// FiatTokenFactory
"github.com/circlefin/noble-fiattokenfactory/x/fiattokenfactory"
fiattokenfactorykeeper "github.com/circlefin/noble-fiattokenfactory/x/fiattokenfactory/keeper"
Expand Down Expand Up @@ -433,6 +435,7 @@ func NewSimApp(
var transferStack porttypes.IBCModule
transferStack = transfer.NewIBCModule(app.TransferKeeper)
transferStack = ibcfee.NewIBCMiddleware(transferStack, app.IBCFeeKeeper)
transferStack = blockibc.NewIBCMiddleware(transferStack, app.FiatTokenFactoryKeeper)

// Add transfer stack to IBC Router
ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferStack)
Expand Down Expand Up @@ -628,6 +631,7 @@ func NewSimApp(
SigGasConsumer: ante.DefaultSigVerificationGasConsumer,
},
IBCKeeper: app.IBCKeeper,
cdc: appCodec,
FiatTokenFactoryKeeper: app.FiatTokenFactoryKeeper,
},
)
Expand Down
5 changes: 3 additions & 2 deletions simapp/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ require (
github.com/minio/highwayhash v1.0.2 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mtibben/percent v0.2.1 // indirect
github.com/onsi/gomega v1.28.0 // indirect
github.com/otiai10/copy v1.11.0 // indirect
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
github.com/petermattis/goid v0.0.0-20230317030725-371a4b8eda08 // indirect
github.com/pkg/errors v0.9.1 // indirect
Expand Down Expand Up @@ -153,6 +151,9 @@ replace (
// use local version of circlefin/noble-fiattokenfactory
github.com/circlefin/noble-fiattokenfactory => ./..

// use noble compatible cosmos/cosmos-sdk
github.com/cosmos/cosmos-sdk => github.com/noble-assets/cosmos-sdk v0.45.16-noble

// use cosmos flavored gogo/protobuf
// https://github.com/cosmos/cosmos-sdk/issues/8469
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
Expand Down
8 changes: 4 additions & 4 deletions simapp/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,6 @@ github.com/cosmos/cosmos-db v0.0.0-20221226095112-f3c38ecb5e32 h1:zlCp9n3uwQieEL
github.com/cosmos/cosmos-db v0.0.0-20221226095112-f3c38ecb5e32/go.mod h1:kwMlEC4wWvB48zAShGKVqboJL6w4zCLesaNQ3YLU2BQ=
github.com/cosmos/cosmos-proto v1.0.0-beta.2 h1:X3OKvWgK9Gsejo0F1qs5l8Qn6xJV/AzgIWR2wZ8Nua8=
github.com/cosmos/cosmos-proto v1.0.0-beta.2/go.mod h1:+XRCLJ14pr5HFEHIUcn51IKXD1Fy3rkEQqt4WqmN4V0=
github.com/cosmos/cosmos-sdk v0.45.16 h1:5ba/Bh5/LE55IwHQuCU4fiG4eXeDKtSWzehXRpaKDcw=
github.com/cosmos/cosmos-sdk v0.45.16/go.mod h1:bScuNwWAP0TZJpUf+SHXRU3xGoUPp+X9nAzfeIXts40=
github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y=
github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY=
github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw=
Expand Down Expand Up @@ -788,6 +786,8 @@ github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxzi
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
github.com/neilotoole/errgroup v0.1.6/go.mod h1:Q2nLGf+594h0CLBs/Mbg6qOr7GtqDK7C2S41udRnToE=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/noble-assets/cosmos-sdk v0.45.16-noble h1:c0SUrD02hNPvE3y9SHEhkOWOmTtdll1PYxZDf8K6YLw=
github.com/noble-assets/cosmos-sdk v0.45.16-noble/go.mod h1:bScuNwWAP0TZJpUf+SHXRU3xGoUPp+X9nAzfeIXts40=
github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs=
Expand Down Expand Up @@ -944,8 +944,8 @@ github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPx
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
Expand Down
17 changes: 17 additions & 0 deletions simapp/simd/cmd/prefixes.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package cmd

import sdk "github.com/cosmos/cosmos-sdk/types"

func SetPrefixes(prefix string) {
accountPubKeyPrefix := prefix + "pub"
validatorAddressPrefix := prefix + "valoper"
validatorPubKeyPrefix := prefix + "valoperpub"
consNodeAddressPrefix := prefix + "valcons"
consNodePubKeyPrefix := prefix + "valconspub"

config := sdk.GetConfig()
config.SetBech32PrefixForAccount(prefix, accountPubKeyPrefix)
config.SetBech32PrefixForValidator(validatorAddressPrefix, validatorPubKeyPrefix)
config.SetBech32PrefixForConsensusNode(consNodeAddressPrefix, consNodePubKeyPrefix)
config.Seal()
}
3 changes: 3 additions & 0 deletions simapp/simd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) {
WithHomeDir(simapp.DefaultNodeHome).
WithViper("") // In simapp, we don't use any prefix for env variables.

// FiatTokenFactory
SetPrefixes("noble")

rootCmd := &cobra.Command{
Use: "simd",
Short: "simulation app",
Expand Down
148 changes: 148 additions & 0 deletions x/blockibc/blockibc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
package blockibc

import (
"github.com/circlefin/noble-fiattokenfactory/x/fiattokenfactory/keeper"
"github.com/circlefin/noble-fiattokenfactory/x/fiattokenfactory/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/bech32"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
transfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types"
channeltypes "github.com/cosmos/ibc-go/v4/modules/core/04-channel/types"
porttypes "github.com/cosmos/ibc-go/v4/modules/core/05-port/types"
ibcexported "github.com/cosmos/ibc-go/v4/modules/core/exported"
)

var _ porttypes.IBCModule = &IBCMiddleware{}

// IBCMiddleware implements the tokenfactory keeper in order to check against blacklisted addresses.
type IBCMiddleware struct {
app porttypes.IBCModule
keeper *keeper.Keeper
}

// NewIBCMiddleware creates a new IBCMiddleware given the keeper and underlying application.
func NewIBCMiddleware(app porttypes.IBCModule, k *keeper.Keeper) IBCMiddleware {
return IBCMiddleware{
app: app,
keeper: k,
}
}

// OnChanOpenInit implements the IBCModule interface.
func (im IBCMiddleware) OnChanOpenInit(
ctx sdk.Context,
order channeltypes.Order,
connectionHops []string,
portID string,
channelID string,
channelCap *capabilitytypes.Capability,
counterparty channeltypes.Counterparty,
version string,
) (string, error) {
return im.app.OnChanOpenInit(ctx, order, connectionHops, portID, channelID, channelCap, counterparty, version)
}

// OnChanOpenTry implements the IBCModule interface.
func (im IBCMiddleware) OnChanOpenTry(
ctx sdk.Context,
order channeltypes.Order,
connectionHops []string,
portID, channelID string,
chanCap *capabilitytypes.Capability,
counterparty channeltypes.Counterparty,
counterpartyVersion string,
) (version string, err error) {
return im.app.OnChanOpenTry(ctx, order, connectionHops, portID, channelID, chanCap, counterparty, counterpartyVersion)
}

// OnChanOpenAck implements the IBCModule interface.
func (im IBCMiddleware) OnChanOpenAck(
ctx sdk.Context,
portID, channelID string,
counterpartyChannelID string,
counterpartyVersion string,
) error {
return im.app.OnChanOpenAck(ctx, portID, channelID, counterpartyChannelID, counterpartyVersion)
}

// OnChanOpenConfirm implements the IBCModule interface.
func (im IBCMiddleware) OnChanOpenConfirm(ctx sdk.Context, portID, channelID string) error {
return im.app.OnChanOpenConfirm(ctx, portID, channelID)
}

// OnChanCloseInit implements the IBCModule interface.
func (im IBCMiddleware) OnChanCloseInit(ctx sdk.Context, portID, channelID string) error {
return im.app.OnChanCloseInit(ctx, portID, channelID)
}

// OnChanCloseConfirm implements the IBCModule interface.
func (im IBCMiddleware) OnChanCloseConfirm(ctx sdk.Context, portID, channelID string) error {
return im.app.OnChanCloseConfirm(ctx, portID, channelID)
}

// OnRecvPacket intercepts the packet data and checks the sender and receiver address against
// the blacklisted addresses held in the tokenfactory keeper. If the address is found in the blacklist, an
// acknowledgment error is returned.
func (im IBCMiddleware) OnRecvPacket(
ctx sdk.Context,
packet channeltypes.Packet,
relayer sdk.AccAddress,
) ibcexported.Acknowledgement {
var data transfertypes.FungibleTokenPacketData
var ackErr error
if err := types.ModuleCdc.UnmarshalJSON(packet.GetData(), &data); err != nil {
ackErr = sdkerrors.Wrapf(sdkerrors.ErrInvalidType, "cannot unmarshal ICS-20 transfer packet data")
return channeltypes.NewErrorAcknowledgement(ackErr)
}

denomTrace := transfertypes.ParseDenomTrace(data.Denom)

mintingDenom := im.keeper.GetMintingDenom(ctx)
if denomTrace.BaseDenom != mintingDenom.Denom {
return im.app.OnRecvPacket(ctx, packet, relayer)
}

if im.keeper.GetPaused(ctx).Paused {
return channeltypes.NewErrorAcknowledgement(types.ErrPaused)
}

_, addressBz, err := bech32.DecodeAndConvert(data.Receiver)
if err != nil {
return channeltypes.NewErrorAcknowledgement(err)
}

_, found := im.keeper.GetBlacklisted(ctx, addressBz)
if found {
ackErr = sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "receiver address is blacklisted")
return channeltypes.NewErrorAcknowledgement(ackErr)
}

_, addressBz, err = bech32.DecodeAndConvert(data.Sender)
if err != nil {
return channeltypes.NewErrorAcknowledgement(err)
}

_, found = im.keeper.GetBlacklisted(ctx, addressBz)
if found {
ackErr = sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "sender address is blacklisted")
return channeltypes.NewErrorAcknowledgement(ackErr)
}

return im.app.OnRecvPacket(ctx, packet, relayer)
}

// OnAcknowledgementPacket implements the IBCModule interface.
func (im IBCMiddleware) OnAcknowledgementPacket(
ctx sdk.Context,
packet channeltypes.Packet,
acknowledgement []byte,
relayer sdk.AccAddress,
) error {
return im.app.OnAcknowledgementPacket(ctx, packet, acknowledgement, relayer)
}

// OnTimeoutPacket implements the IBCModule interface.
func (im IBCMiddleware) OnTimeoutPacket(ctx sdk.Context, packet channeltypes.Packet, relayer sdk.AccAddress) error {
return im.app.OnTimeoutPacket(ctx, packet, relayer)
}
Loading

0 comments on commit 0a7385d

Please sign in to comment.