Skip to content

Commit 0a7385d

Browse files
authored
Various blocklist and pause check enhancements (#24)
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.
2 parents 14edf83 + 9c86d05 commit 0a7385d

17 files changed

Lines changed: 646 additions & 1518 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ test: test-e2e test-unit
6565

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

7171
test-unit:

e2e/genesis_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ func nobleChainSpec(
417417
ChainID: chainID,
418418
Bin: "simd", // "nobled",
419419
Denom: "token",
420-
Bech32Prefix: "cosmos", // "noble",
420+
Bech32Prefix: "noble",
421421
CoinType: "118",
422422
GasPrices: "0.0token",
423423
GasAdjustment: 1.1,

e2e/go.mod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ go 1.21
55
require (
66
github.com/circlefin/noble-fiattokenfactory v1.0.0
77
github.com/cosmos/cosmos-sdk v0.45.16
8+
github.com/cosmos/ibc-go/v4 v4.5.1
89
github.com/icza/dyno v0.0.0-20220812133438-f0b6f8a18845
910
github.com/strangelove-ventures/interchaintest/v4 v4.0.0-20231026153934-334934f17a68
1011
github.com/stretchr/testify v1.8.4
@@ -42,7 +43,6 @@ require (
4243
github.com/cosmos/go-bip39 v1.0.0 // indirect
4344
github.com/cosmos/gorocksdb v1.2.0 // indirect
4445
github.com/cosmos/iavl v0.19.5 // indirect
45-
github.com/cosmos/ibc-go/v4 v4.5.1 // indirect
4646
github.com/cosmos/ledger-cosmos-go v0.12.2 // indirect
4747
github.com/danieljoos/wincred v1.1.2 // indirect
4848
github.com/davecgh/go-spew v1.1.1 // indirect
@@ -90,7 +90,6 @@ require (
9090
github.com/klauspost/compress v1.16.3 // indirect
9191
github.com/kr/pretty v0.3.1 // indirect
9292
github.com/kr/text v0.2.0 // indirect
93-
github.com/lib/pq v1.10.9 // indirect
9493
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
9594
github.com/linxGnu/grocksdb v1.7.10 // indirect
9695
github.com/magiconair/properties v1.8.7 // indirect
@@ -99,10 +98,8 @@ require (
9998
github.com/mimoo/StrobeGo v0.0.0-20220103164710-9a04d6ca976b // indirect
10099
github.com/mitchellh/mapstructure v1.5.0 // indirect
101100
github.com/mtibben/percent v0.2.1 // indirect
102-
github.com/onsi/gomega v1.28.0 // indirect
103101
github.com/opencontainers/go-digest v1.0.0 // indirect
104102
github.com/opencontainers/image-spec v1.1.0-rc2 // indirect
105-
github.com/otiai10/copy v1.11.0 // indirect
106103
github.com/pelletier/go-toml v1.9.5 // indirect
107104
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
108105
github.com/petermattis/goid v0.0.0-20230317030725-371a4b8eda08 // indirect
@@ -175,6 +172,9 @@ replace (
175172
// https://github.com/cosmos/cosmos-sdk/issues/8469
176173
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
177174

175+
// use noble compatible strangelove-ventures/interchaintest
176+
github.com/strangelove-ventures/interchaintest/v4 => github.com/noble-assets/interchaintest/v4 v4.0.0-20240310120800-113c680bdc4c
177+
178178
// use cosmos compatible syndtr/goleveldb
179179
github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
180180

e2e/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,8 @@ github.com/nats-io/nkeys v0.0.2/go.mod h1:dab7URMsZm6Z/jp9Z5UGa87Uutgc2mVpXLC4B7
537537
github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w=
538538
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
539539
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
540+
github.com/noble-assets/interchaintest/v4 v4.0.0-20240310120800-113c680bdc4c h1:f1e4yRB1Ph06TDZxOJUCzB0ZTN24gS+52xOpwysVvII=
541+
github.com/noble-assets/interchaintest/v4 v4.0.0-20240310120800-113c680bdc4c/go.mod h1:oEYorKX6XBoQOrkVv9uhq4X0azZbEf5Jq6h3GN8jJ2w=
540542
github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78=
541543
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
542544
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
@@ -656,8 +658,6 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An
656658
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
657659
github.com/spf13/viper v1.15.0 h1:js3yy885G8xwJa6iOISGFwd+qlUo5AvyXb7CiihdtiU=
658660
github.com/spf13/viper v1.15.0/go.mod h1:fFcTBJxvhhzSJiZy8n+PeW6t8l+KeT/uTARa0jHOQLA=
659-
github.com/strangelove-ventures/interchaintest/v4 v4.0.0-20231026153934-334934f17a68 h1:f16Xo7gvZ/g3YyXsmUQBwvUcq0orQeBrIcdsyVrMrjU=
660-
github.com/strangelove-ventures/interchaintest/v4 v4.0.0-20231026153934-334934f17a68/go.mod h1:oEYorKX6XBoQOrkVv9uhq4X0azZbEf5Jq6h3GN8jJ2w=
661661
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
662662
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
663663
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=

e2e/noble_test.go

Lines changed: 223 additions & 27 deletions
Large diffs are not rendered by default.

go.work.sum

Lines changed: 129 additions & 1474 deletions
Large diffs are not rendered by default.

simapp/abci.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package simapp
2+
3+
import (
4+
"github.com/cosmos/cosmos-sdk/types/errors"
5+
abci "github.com/tendermint/tendermint/abci/types"
6+
)
7+
8+
func (app *SimApp) DeliverTx(req abci.RequestDeliverTx) abci.ResponseDeliverTx {
9+
res := app.BaseApp.DeliverTx(req)
10+
ctx := app.BaseApp.DeliverState.Context()
11+
12+
for _, event := range res.Events {
13+
err := app.FiatTokenFactoryKeeper.HandleDeliverTxEvent(ctx, event)
14+
if err != nil {
15+
app.SetDeliverState(ctx.BlockHeader())
16+
return errors.ResponseDeliverTxWithEvents(err, uint64(res.GasWanted), uint64(res.GasUsed), res.Events, app.Trace())
17+
}
18+
}
19+
20+
return res
21+
}

simapp/ante_handler.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package simapp
33
import (
44
"github.com/circlefin/noble-fiattokenfactory/x/fiattokenfactory"
55
fiattokenfactorykeeper "github.com/circlefin/noble-fiattokenfactory/x/fiattokenfactory/keeper"
6+
"github.com/cosmos/cosmos-sdk/codec"
67
sdk "github.com/cosmos/cosmos-sdk/types"
78
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
89
"github.com/cosmos/cosmos-sdk/x/auth/ante"
@@ -17,6 +18,7 @@ type HandlerOptions struct {
1718
IBCKeeper *keeper.Keeper
1819

1920
// FiatTokenFactory
21+
cdc codec.Codec
2022
FiatTokenFactoryKeeper *fiattokenfactorykeeper.Keeper
2123
}
2224

@@ -44,7 +46,7 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
4446
ante.NewSetUpContextDecorator(),
4547
ante.NewRejectExtensionOptionsDecorator(),
4648
fiattokenfactory.NewIsBlacklistedDecorator(options.FiatTokenFactoryKeeper),
47-
fiattokenfactory.NewIsPausedDecorator(options.FiatTokenFactoryKeeper),
49+
fiattokenfactory.NewIsPausedDecorator(options.cdc, options.FiatTokenFactoryKeeper),
4850
ante.NewMempoolFeeDecorator(),
4951
ante.NewValidateBasicDecorator(),
5052
ante.NewTxTimeoutHeightDecorator(),

simapp/app.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ import (
108108
authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper"
109109
authzmodule "github.com/cosmos/cosmos-sdk/x/authz/module"
110110

111+
// BlockIBC
112+
"github.com/circlefin/noble-fiattokenfactory/x/blockibc"
111113
// FiatTokenFactory
112114
"github.com/circlefin/noble-fiattokenfactory/x/fiattokenfactory"
113115
fiattokenfactorykeeper "github.com/circlefin/noble-fiattokenfactory/x/fiattokenfactory/keeper"
@@ -433,6 +435,7 @@ func NewSimApp(
433435
var transferStack porttypes.IBCModule
434436
transferStack = transfer.NewIBCModule(app.TransferKeeper)
435437
transferStack = ibcfee.NewIBCMiddleware(transferStack, app.IBCFeeKeeper)
438+
transferStack = blockibc.NewIBCMiddleware(transferStack, app.FiatTokenFactoryKeeper)
436439

437440
// Add transfer stack to IBC Router
438441
ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferStack)
@@ -628,6 +631,7 @@ func NewSimApp(
628631
SigGasConsumer: ante.DefaultSigVerificationGasConsumer,
629632
},
630633
IBCKeeper: app.IBCKeeper,
634+
cdc: appCodec,
631635
FiatTokenFactoryKeeper: app.FiatTokenFactoryKeeper,
632636
},
633637
)

simapp/go.mod

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,6 @@ require (
100100
github.com/minio/highwayhash v1.0.2 // indirect
101101
github.com/mitchellh/mapstructure v1.5.0 // indirect
102102
github.com/mtibben/percent v0.2.1 // indirect
103-
github.com/onsi/gomega v1.28.0 // indirect
104-
github.com/otiai10/copy v1.11.0 // indirect
105103
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
106104
github.com/petermattis/goid v0.0.0-20230317030725-371a4b8eda08 // indirect
107105
github.com/pkg/errors v0.9.1 // indirect
@@ -153,6 +151,9 @@ replace (
153151
// use local version of circlefin/noble-fiattokenfactory
154152
github.com/circlefin/noble-fiattokenfactory => ./..
155153

154+
// use noble compatible cosmos/cosmos-sdk
155+
github.com/cosmos/cosmos-sdk => github.com/noble-assets/cosmos-sdk v0.45.16-noble
156+
156157
// use cosmos flavored gogo/protobuf
157158
// https://github.com/cosmos/cosmos-sdk/issues/8469
158159
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1

0 commit comments

Comments
 (0)