Skip to content

Commit

Permalink
chore: prepare v4.0.3 (#317)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnletey authored Mar 11, 2024
1 parent 2da9930 commit 11f64b6
Show file tree
Hide file tree
Showing 207 changed files with 218 additions and 24,651 deletions.
2 changes: 1 addition & 1 deletion .changelog/config.toml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
project_url = "https://github.com/strangelove-ventures/noble"
project_url = "https://github.com/noble-assets/noble"
4 changes: 2 additions & 2 deletions .changelog/epilogue.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---

## Previous Changes
## Other Releases

This changelog has yet to be fully initialized. For previous versions please refer to the release notes for a summary of changes.
This changelog is specific to the v4 Argon release line. For other versions please refer to their release notes for a summary of changes.
1 change: 0 additions & 1 deletion .changelog/v3.1.0/features/235-ibc-authority.md

This file was deleted.

1 change: 0 additions & 1 deletion .changelog/v3.1.0/improvements/234-module-path.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changelog/v3.1.0/summary.md

This file was deleted.

2 changes: 1 addition & 1 deletion .changelog/v4.0.0/bug-fixes/252-simulation-tests.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
- Fix simulation tests. ([#252](https://github.com/strangelove-ventures/noble/pull/252))
- Fix simulation tests. ([#252](https://github.com/noble-assets/noble/pull/252))
2 changes: 1 addition & 1 deletion .changelog/v4.0.0/bug-fixes/253-ledger-macos-sonoma.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
- Fix Ledger support for macOS Sonoma. ([#253](https://github.com/strangelove-ventures/noble/pull/253))
- Fix Ledger support for macOS Sonoma. ([#253](https://github.com/noble-assets/noble/pull/253))
2 changes: 1 addition & 1 deletion .changelog/v4.0.0/dependencies/250-bump-ibc.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
- Bump IBC to [`v4.5.1`](https://github.com/cosmos/ibc-go/releases/tag/v4.5.1) ([#250](https://github.com/strangelove-ventures/noble/pull/250))
- Bump IBC to [`v4.5.1`](https://github.com/cosmos/ibc-go/releases/tag/v4.5.1) ([#250](https://github.com/noble-assets/noble/pull/250))
2 changes: 1 addition & 1 deletion .changelog/v4.0.0/dependencies/250-bump-pfm.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
- Bump Packet Forward Middleware to [`v4.1.1`](https://github.com/cosmos/ibc-apps/releases/tag/middleware%2Fpacket-forward-middleware%2Fv4.1.1) ([#250](https://github.com/strangelove-ventures/noble/pull/250), [#258](https://github.com/strangelove-ventures/noble/pull/258))
- Bump Packet Forward Middleware to [`v4.1.1`](https://github.com/cosmos/ibc-apps/releases/tag/middleware%2Fpacket-forward-middleware%2Fv4.1.1) ([#250](https://github.com/noble-assets/noble/pull/250), [#258](https://github.com/noble-assets/noble/pull/258))
2 changes: 1 addition & 1 deletion .changelog/v4.0.0/features/215-rosetta-support.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
- Include support for Coinbase's [Rosetta API](https://docs.cloud.coinbase.com/rosetta/docs/welcome). ([#215](https://github.com/strangelove-ventures/noble/pull/215))
- Include support for Coinbase's [Rosetta API](https://docs.cloud.coinbase.com/rosetta/docs/welcome). ([#215](https://github.com/noble-assets/noble/pull/215))
Original file line number Diff line number Diff line change
@@ -1 +1 @@
- Add `x/fiattokenfactory` interface changes required for CCTP. ([#241](https://github.com/strangelove-ventures/noble/pull/241))
- Add `x/fiattokenfactory` interface changes required for CCTP. ([#241](https://github.com/noble-assets/noble/pull/241))
2 changes: 1 addition & 1 deletion .changelog/v4.0.1/bug-fixes/274-distribution-hooks.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
- Unregister `x/distribution` hooks to address consensus failure. ([#274](https://github.com/strangelove-ventures/noble/pull/274))
- Unregister `x/distribution` hooks to address consensus failure. ([#274](https://github.com/noble-assets/noble/pull/274))
2 changes: 1 addition & 1 deletion .changelog/v4.0.2/improvements/277-tariff-query.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
- Implement a parameter query for the `x/tariff` module. ([#277](https://github.com/strangelove-ventures/noble/pull/277))
- Implement a parameter query for the `x/tariff` module. ([#277](https://github.com/noble-assets/noble/pull/277))
1 change: 1 addition & 0 deletions .changelog/v4.0.3/dependencies/000-ftf.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Bump FiatTokenFactory to [`14edf83`](https://github.com/circlefin/noble-fiattokenfactory/commit/14edf83ee1c96055e2c17ea56ca9dd303d3c14f6) to enable `x/authz` support.
1 change: 1 addition & 0 deletions .changelog/v4.0.3/dependencies/001-pfm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Bump PFM to [`455757b`](https://github.com/cosmos/ibc-apps/commit/455757bb5771c29cf2f83b59e37f6513e07c92be) to resolve Mandrake disclosure.
1 change: 1 addition & 0 deletions .changelog/v4.0.3/improvements/000-migrate-ftf.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Switch to [migrated](https://github.com/circlefin/noble-fiattokenfactory) version of `x/fiattokenfactory` module.
3 changes: 3 additions & 0 deletions .changelog/v4.0.3/summary.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*Mar 11, 2023*

This is the third patch release to the v4 Argon line.
51 changes: 25 additions & 26 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# CHANGELOG

## v4.0.3

*Mar 11, 2023*

This is the third patch release to the v4 Argon line.

### DEPENDENCIES

- Bump FiatTokenFactory to [`14edf83`](https://github.com/circlefin/noble-fiattokenfactory/commit/14edf83ee1c96055e2c17ea56ca9dd303d3c14f6) to enable `x/authz` support.
- Bump PFM to [`455757b`](https://github.com/cosmos/ibc-apps/commit/455757bb5771c29cf2f83b59e37f6513e07c92be) to resolve Mandrake disclosure.

### IMPROVEMENTS

- Switch to [migrated](https://github.com/circlefin/noble-fiattokenfactory) version of `x/fiattokenfactory` module.

## v4.0.2

*Nov 21, 2023*
Expand All @@ -8,7 +23,7 @@ This is the second patch release to the v4 Argon line.

### IMPROVEMENTS

- Implement a parameter query for the `x/tariff` module. ([#277](https://github.com/strangelove-ventures/noble/pull/277))
- Implement a parameter query for the `x/tariff` module. ([#277](https://github.com/noble-assets/noble/pull/277))

## v4.0.1

Expand All @@ -18,7 +33,7 @@ This is the first patch release to the v4 Argon line.

### BUG FIXES

- Unregister `x/distribution` hooks to address consensus failure. ([#274](https://github.com/strangelove-ventures/noble/pull/274))
- Unregister `x/distribution` hooks to address consensus failure. ([#274](https://github.com/noble-assets/noble/pull/274))

## v4.0.0

Expand All @@ -30,41 +45,25 @@ Along with the integration of the CCTP module, the following changes were made.

### BUG FIXES

- Fix simulation tests. ([#252](https://github.com/strangelove-ventures/noble/pull/252))
- Fix Ledger support for macOS Sonoma. ([#253](https://github.com/strangelove-ventures/noble/pull/253))
- Fix simulation tests. ([#252](https://github.com/noble-assets/noble/pull/252))
- Fix Ledger support for macOS Sonoma. ([#253](https://github.com/noble-assets/noble/pull/253))

### DEPENDENCIES

- Bump IBC to [`v4.5.1`](https://github.com/cosmos/ibc-go/releases/tag/v4.5.1) ([#250](https://github.com/strangelove-ventures/noble/pull/250))
- Bump Packet Forward Middleware to [`v4.1.1`](https://github.com/cosmos/ibc-apps/releases/tag/middleware%2Fpacket-forward-middleware%2Fv4.1.1) ([#250](https://github.com/strangelove-ventures/noble/pull/250), [#258](https://github.com/strangelove-ventures/noble/pull/258))

### FEATURES

- Include support for Coinbase's [Rosetta API](https://docs.cloud.coinbase.com/rosetta/docs/welcome). ([#215](https://github.com/strangelove-ventures/noble/pull/215))

### IMPROVEMENTS

- Add `x/fiattokenfactory` interface changes required for CCTP. ([#241](https://github.com/strangelove-ventures/noble/pull/241))

## v3.1.0

*Sep 15, 2023*

This is a minor release to the v3 Radon line.

In response to multiple IBC channels expiring on Noble's mainnet network, it was decided to expand the functionality of Noble's Maintenance Multisig to include IBC upgrade functionality (allowing expired clients to be changed).
- Bump IBC to [`v4.5.1`](https://github.com/cosmos/ibc-go/releases/tag/v4.5.1) ([#250](https://github.com/noble-assets/noble/pull/250))
- Bump Packet Forward Middleware to [`v4.1.1`](https://github.com/cosmos/ibc-apps/releases/tag/middleware%2Fpacket-forward-middleware%2Fv4.1.1) ([#250](https://github.com/noble-assets/noble/pull/250), [#258](https://github.com/noble-assets/noble/pull/258))

### FEATURES

- Include support for IBC inside the ParamAuthority. ([#235](https://github.com/strangelove-ventures/noble/pull/235))
- Include support for Coinbase's [Rosetta API](https://docs.cloud.coinbase.com/rosetta/docs/welcome). ([#215](https://github.com/noble-assets/noble/pull/215))

### IMPROVEMENTS

- Align module path with Go's [naming convention](https://go.dev/doc/modules/version-numbers#major-version). ([#234](https://github.com/strangelove-ventures/noble/pull/234))
- Add `x/fiattokenfactory` interface changes required for CCTP. ([#241](https://github.com/noble-assets/noble/pull/241))

---

## Previous Changes
## Other Releases

This changelog has yet to be fully initialized. For previous versions please refer to the release notes for a summary of changes.
This changelog is specific to the v4 Argon release line. For other versions please refer to their release notes for a summary of changes.

188 changes: 5 additions & 183 deletions app/ante.go
Original file line number Diff line number Diff line change
@@ -1,203 +1,25 @@
package app

import (
"github.com/cosmos/cosmos-sdk/types/bech32"
fiattokenfactory "github.com/strangelove-ventures/noble/x/fiattokenfactory/keeper"
fiattokenfactorytypes "github.com/strangelove-ventures/noble/x/fiattokenfactory/types"
tokenfactory "github.com/strangelove-ventures/noble/x/tokenfactory/keeper"
tokenfactorytypes "github.com/strangelove-ventures/noble/x/tokenfactory/types"

"github.com/circlefin/noble-fiattokenfactory/x/fiattokenfactory"
fiattokenfactorykeeper "github.com/circlefin/noble-fiattokenfactory/x/fiattokenfactory/keeper"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
transfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types"
ibcante "github.com/cosmos/ibc-go/v4/modules/core/ante"
ibckeeper "github.com/cosmos/ibc-go/v4/modules/core/keeper"

feeante "github.com/strangelove-ventures/noble/x/globalfee/ante"
)

type HandlerOptions struct {
ante.HandlerOptions
tokenFactoryKeeper *tokenfactory.Keeper
fiatTokenFactoryKeeper *fiattokenfactory.Keeper
fiatTokenFactoryKeeper *fiattokenfactorykeeper.Keeper
IBCKeeper *ibckeeper.Keeper
GlobalFeeSubspace paramtypes.Subspace
StakingSubspace paramtypes.Subspace
}

type IsPausedDecorator struct {
tokenFactory *tokenfactory.Keeper
fiatTokenFactory *fiattokenfactory.Keeper
}

func NewIsPausedDecorator(tf *tokenfactory.Keeper, ctf *fiattokenfactory.Keeper) IsPausedDecorator {
return IsPausedDecorator{
tokenFactory: tf,
fiatTokenFactory: ctf,
}
}

func (ad IsPausedDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) {
msgs := tx.GetMsgs()
for _, m := range msgs {
switch m := m.(type) {
case *banktypes.MsgSend, *banktypes.MsgMultiSend, *transfertypes.MsgTransfer:
switch m := m.(type) {
case *banktypes.MsgSend:
for _, c := range m.Amount {
paused, err := checkPausedStatebyTokenFactory(ctx, c, ad.tokenFactory, ad.fiatTokenFactory)
if paused {
return ctx, sdkerrors.Wrapf(err, "can not perform token transfers")
}
}
case *banktypes.MsgMultiSend:
for _, i := range m.Inputs {
for _, c := range i.Coins {
paused, err := checkPausedStatebyTokenFactory(ctx, c, ad.tokenFactory, ad.fiatTokenFactory)
if paused {
return ctx, sdkerrors.Wrapf(err, "can not perform token transfers")
}
}
}
case *transfertypes.MsgTransfer:
paused, err := checkPausedStatebyTokenFactory(ctx, m.Token, ad.tokenFactory, ad.fiatTokenFactory)
if paused {
return ctx, sdkerrors.Wrapf(err, "can not perform token transfers")
}
default:
continue
}
default:
continue
}
}
return next(ctx, tx, simulate)
}

func checkPausedStatebyTokenFactory(ctx sdk.Context, c sdk.Coin, tf *tokenfactory.Keeper, ctf *fiattokenfactory.Keeper) (bool, *sdkerrors.Error) {
tfMintingDenom := tf.GetMintingDenom(ctx)
if c.Denom == tfMintingDenom.Denom {
paused := tf.GetPaused(ctx)
if paused.Paused {
return true, tokenfactorytypes.ErrPaused
}
}
ctfMintingDenom := ctf.GetMintingDenom(ctx)
if c.Denom == ctfMintingDenom.Denom {
paused := ctf.GetPaused(ctx)
if paused.Paused {
return true, fiattokenfactorytypes.ErrPaused
}
}
return false, nil
}

type IsBlacklistedDecorator struct {
tokenfactory *tokenfactory.Keeper
fiattokenfactory *fiattokenfactory.Keeper
}

func NewIsBlacklistedDecorator(tf *tokenfactory.Keeper, ctf *fiattokenfactory.Keeper) IsBlacklistedDecorator {
return IsBlacklistedDecorator{
tokenfactory: tf,
fiattokenfactory: ctf,
}
}

func (ad IsBlacklistedDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) {
msgs := tx.GetMsgs()
for _, m := range msgs {
switch m := m.(type) {
case *banktypes.MsgSend, *banktypes.MsgMultiSend, *transfertypes.MsgTransfer:
switch m := m.(type) {
case *banktypes.MsgSend:
for _, c := range m.Amount {
addresses := []string{m.ToAddress, m.FromAddress}
blacklisted, address, err := checkForBlacklistedAddressByTokenFactory(ctx, addresses, c, ad.tokenfactory, ad.fiattokenfactory)
if blacklisted {
return ctx, sdkerrors.Wrapf(err, "an address (%s) is blacklisted and can not send or receive tokens", address)
}
if err != nil {
return ctx, sdkerrors.Wrapf(err, "error decoding address (%s)", address)
}
}
case *banktypes.MsgMultiSend:
for _, i := range m.Inputs {
for _, c := range i.Coins {
addresses := []string{i.Address}
blacklisted, address, err := checkForBlacklistedAddressByTokenFactory(ctx, addresses, c, ad.tokenfactory, ad.fiattokenfactory)
if blacklisted {
return ctx, sdkerrors.Wrapf(err, "an address (%s) is blacklisted and can not send or receive tokens", address)
}
if err != nil {
return ctx, sdkerrors.Wrapf(err, "error decoding address (%s)", address)
}
}
}
for _, o := range m.Outputs {
for _, c := range o.Coins {
addresses := []string{o.Address}
blacklisted, address, err := checkForBlacklistedAddressByTokenFactory(ctx, addresses, c, ad.tokenfactory, ad.fiattokenfactory)
if blacklisted {
return ctx, sdkerrors.Wrapf(err, "an address (%s) is blacklisted and can not send or receive tokens", address)
}
if err != nil {
return ctx, sdkerrors.Wrapf(err, "error decoding address (%s)", address)
}
}
}
case *transfertypes.MsgTransfer:
addresses := []string{m.Sender, m.Receiver}
blacklisted, address, err := checkForBlacklistedAddressByTokenFactory(ctx, addresses, m.Token, ad.tokenfactory, ad.fiattokenfactory)
if blacklisted {
return ctx, sdkerrors.Wrapf(err, "an address (%s) is blacklisted and can not send or receive tokens", address)
}
if err != nil {
return ctx, sdkerrors.Wrapf(err, "error decoding address (%s)", address)
}
}
default:
continue
}
}
return next(ctx, tx, simulate)
}

// checkForBlacklistedAddressByTokenFactory first checks if the denom being transacted is a mintable asset from a TokenFactory,
// if it is, it checks if the addresses involved in the tx are blacklisted by that specific TokenFactory.
func checkForBlacklistedAddressByTokenFactory(ctx sdk.Context, addresses []string, c sdk.Coin, tf *tokenfactory.Keeper, ctf *fiattokenfactory.Keeper) (blacklisted bool, blacklistedAddress string, err error) {
tfMintingDenom := tf.GetMintingDenom(ctx)
if c.Denom == tfMintingDenom.Denom {
for _, address := range addresses {
_, addressBz, err := bech32.DecodeAndConvert(address)
if err != nil {
return false, address, err
}
_, found := tf.GetBlacklisted(ctx, addressBz)
if found {
return true, address, tokenfactorytypes.ErrUnauthorized
}
}
}
ctfMintingDenom := ctf.GetMintingDenom(ctx)
if c.Denom == ctfMintingDenom.Denom {
for _, address := range addresses {
_, addressBz, err := bech32.DecodeAndConvert(address)
if err != nil {
return false, address, err
}
_, found := ctf.GetBlacklisted(ctx, addressBz)
if found {
return true, address, fiattokenfactorytypes.ErrUnauthorized
}
}
}
return false, "", nil
}

// maxTotalBypassMinFeeMsgGasUsage is the allowed maximum gas usage
// for all the bypass msgs in a transactions.
// A transaction that contains only bypass message types and the gas usage does not
Expand Down Expand Up @@ -226,8 +48,8 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
anteDecorators := []sdk.AnteDecorator{
ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first
ante.NewRejectExtensionOptionsDecorator(),
NewIsBlacklistedDecorator(options.tokenFactoryKeeper, options.fiatTokenFactoryKeeper),
NewIsPausedDecorator(options.tokenFactoryKeeper, options.fiatTokenFactoryKeeper),
fiattokenfactory.NewIsBlacklistedDecorator(options.fiatTokenFactoryKeeper),
fiattokenfactory.NewIsPausedDecorator(options.fiatTokenFactoryKeeper),
ante.NewMempoolFeeDecorator(),
ante.NewValidateBasicDecorator(),
ante.NewTxTimeoutHeightDecorator(),
Expand Down
Loading

0 comments on commit 11f64b6

Please sign in to comment.