Skip to content

Commit

Permalink
Merge branch 'update-sdk47' into feat/enhance-contract-failure-with-e…
Browse files Browse the repository at this point in the history
…rror
  • Loading branch information
pr0n00gler committed Nov 13, 2023
2 parents bed0634 + bb17f3b commit ec21cfa
Show file tree
Hide file tree
Showing 23 changed files with 104 additions and 75 deletions.
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ var (
auctiontypes.ModuleName: nil,
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
icatypes.ModuleName: nil,
wasmtypes.ModuleName: {authtypes.Burner},
wasmtypes.ModuleName: {},
interchainqueriesmoduletypes.ModuleName: nil,
feetypes.ModuleName: nil,
feeburnertypes.ModuleName: nil,
Expand Down
4 changes: 3 additions & 1 deletion app/upgrades/nextupgrade/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import (

const (
// UpgradeName defines the on-chain upgrade name.
UpgradeName = "Next-Upgrade"
UpgradeName = "Next-Upgrade"
AtomDenom = "ibc/C4CFF46FD6DE35CA4CF4CE031E643C8FDC9BA4B99AE598E9B0ED98FE3A2319F9"
AxelarUsdcDenom = "ibc/F082B65C88E4B6D5EF1DB243CDA1D331D002759E938A0F5CD3FFDC5D53B3E349"
)

var Upgrade = upgrades.Upgrade{
Expand Down
9 changes: 5 additions & 4 deletions app/upgrades/nextupgrade/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/cosmos/cosmos-sdk/baseapp"
consensuskeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/neutron-org/neutron/app/params"

"cosmossdk.io/math"
"github.com/cosmos/cosmos-sdk/codec"
Expand Down Expand Up @@ -227,7 +228,7 @@ func migrateInterchainQueriesParams(ctx sdk.Context, paramsKeepers paramskeeper.
return nil
}

func setInterchainTxsParams(ctx sdk.Context, paramsKeepers paramskeeper.Keeper, storeKey storetypes.StoreKey, wasmStoreKey storetypes.StoreKey, codec codec.Codec) error {
func setInterchainTxsParams(ctx sdk.Context, paramsKeepers paramskeeper.Keeper, storeKey, wasmStoreKey storetypes.StoreKey, codec codec.Codec) error {
store := ctx.KVStore(storeKey)
var currParams interchaintxstypes.Params
subspace, _ := paramsKeepers.GetSubspace(interchaintxstypes.StoreKey)
Expand Down Expand Up @@ -257,9 +258,9 @@ func migrateGlobalFees(ctx sdk.Context, keepers *upgrades.UpgradeKeepers) error
// As of June 22nd, 2023 this is
// 0.9untrn,0.026ibc/C4CFF46FD6DE35CA4CF4CE031E643C8FDC9BA4B99AE598E9B0ED98FE3A2319F9,0.25ibc/F082B65C88E4B6D5EF1DB243CDA1D331D002759E938A0F5CD3FFDC5D53B3E349
requiredGlobalFees := sdk.DecCoins{
sdk.NewDecCoinFromDec("untrn", sdk.MustNewDecFromStr("0.9")),
sdk.NewDecCoinFromDec("ibc/C4CFF46FD6DE35CA4CF4CE031E643C8FDC9BA4B99AE598E9B0ED98FE3A2319F9", sdk.MustNewDecFromStr("0.026")),
sdk.NewDecCoinFromDec("ibc/F082B65C88E4B6D5EF1DB243CDA1D331D002759E938A0F5CD3FFDC5D53B3E349", sdk.MustNewDecFromStr("0.25")),
sdk.NewDecCoinFromDec(params.DefaultDenom, sdk.MustNewDecFromStr("0.9")),
sdk.NewDecCoinFromDec(AtomDenom, sdk.MustNewDecFromStr("0.026")),
sdk.NewDecCoinFromDec(AxelarUsdcDenom, sdk.MustNewDecFromStr("0.25")),
}
requiredGlobalFees = requiredGlobalFees.Sort()

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ replace (
github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0
github.com/ChainSafe/go-schnorrkel => github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d
github.com/CosmWasm/wasmd => github.com/neutron-org/wasmd v0.43.0
github.com/cosmos/admin-module => github.com/neutron-org/admin-module v0.0.0-20230906150724-9ccb75c61fc5
github.com/cosmos/admin-module => github.com/neutron-org/admin-module v0.0.0-20231102080303-b3efc44ef5d9
github.com/cosmos/cosmos-sdk => github.com/neutron-org/cosmos-sdk v0.47.5
github.com/cosmos/gaia/v11 => github.com/cosmos/gaia/v11 v11.0.0-20230724152830-861ba391c3b4
github.com/cosmos/ledger-cosmos-go => github.com/cosmos/ledger-cosmos-go v0.12.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -934,8 +934,8 @@ github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxzi
github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w=
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/neutron-org/admin-module v0.0.0-20230906150724-9ccb75c61fc5 h1:96ZjLWoN4nCIcFdxrz51Xu2Y8aqpcScy3eva3S5hM60=
github.com/neutron-org/admin-module v0.0.0-20230906150724-9ccb75c61fc5/go.mod h1:INknneN2W3Fr9Eld7SpfLRdjyHR1muzFbbqXln1ixic=
github.com/neutron-org/admin-module v0.0.0-20231102080303-b3efc44ef5d9 h1:46M72zk3g8Uff2i3Fl0Nl/vE/QVL2Fv+jfwqCYI2Ki0=
github.com/neutron-org/admin-module v0.0.0-20231102080303-b3efc44ef5d9/go.mod h1:INknneN2W3Fr9Eld7SpfLRdjyHR1muzFbbqXln1ixic=
github.com/neutron-org/cosmos-sdk v0.47.5 h1:BUBqUPI5I8rF9ql3RfSCo9XkpZBJPhTZSIWexyxutA4=
github.com/neutron-org/cosmos-sdk v0.47.5/go.mod h1:3uZbdGpMOT5usEich5wHANLxz0VbKE9lL1PUq+rzkS4=
github.com/neutron-org/wasmd v0.43.0 h1:aXzN9diVRAKTs2+EdK4zoTOmNCjjr8vpAhIq8VbBUJc=
Expand Down
115 changes: 60 additions & 55 deletions wasmbinding/message_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,64 +83,69 @@ type CustomMessenger struct {
var _ wasmkeeper.Messenger = (*CustomMessenger)(nil)

func (m *CustomMessenger) DispatchMsg(ctx sdk.Context, contractAddr sdk.AccAddress, contractIBCPortID string, msg wasmvmtypes.CosmosMsg) ([]sdk.Event, [][]byte, error) {
if msg.Custom != nil {
var contractMsg bindings.NeutronMsg
if err := json.Unmarshal(msg.Custom, &contractMsg); err != nil {
ctx.Logger().Debug("json.Unmarshal: failed to decode incoming custom cosmos message",
"from_address", contractAddr.String(),
"message", string(msg.Custom),
"error", err,
)
return nil, nil, errors.Wrap(err, "failed to decode incoming custom cosmos message")
}
// Return early if msg.Custom is nil
if msg.Custom == nil {
return m.Wrapped.DispatchMsg(ctx, contractAddr, contractIBCPortID, msg)
}

if contractMsg.SubmitTx != nil {
return m.submitTx(ctx, contractAddr, contractMsg.SubmitTx)
}
if contractMsg.RegisterInterchainAccount != nil {
return m.registerInterchainAccount(ctx, contractAddr, contractMsg.RegisterInterchainAccount)
}
if contractMsg.RegisterInterchainQuery != nil {
return m.registerInterchainQuery(ctx, contractAddr, contractMsg.RegisterInterchainQuery)
}
if contractMsg.UpdateInterchainQuery != nil {
return m.updateInterchainQuery(ctx, contractAddr, contractMsg.UpdateInterchainQuery)
}
if contractMsg.RemoveInterchainQuery != nil {
return m.removeInterchainQuery(ctx, contractAddr, contractMsg.RemoveInterchainQuery)
}
if contractMsg.IBCTransfer != nil {
return m.ibcTransfer(ctx, contractAddr, *contractMsg.IBCTransfer)
}
if contractMsg.SubmitAdminProposal != nil {
return m.submitAdminProposal(ctx, contractAddr, &contractMsg.SubmitAdminProposal.AdminProposal)
}
if contractMsg.CreateDenom != nil {
return m.createDenom(ctx, contractAddr, contractMsg.CreateDenom)
}
if contractMsg.MintTokens != nil {
return m.mintTokens(ctx, contractAddr, contractMsg.MintTokens)
}
if contractMsg.SetBeforeSendHook != nil {
return m.setBeforeSendHook(ctx, contractAddr, contractMsg.SetBeforeSendHook)
}
if contractMsg.ChangeAdmin != nil {
return m.changeAdmin(ctx, contractAddr, contractMsg.ChangeAdmin)
}
if contractMsg.BurnTokens != nil {
return m.burnTokens(ctx, contractAddr, contractMsg.BurnTokens)
}
if contractMsg.AddSchedule != nil {
return m.addSchedule(ctx, contractAddr, contractMsg.AddSchedule)
}
if contractMsg.RemoveSchedule != nil {
return m.removeSchedule(ctx, contractAddr, contractMsg.RemoveSchedule)
}
if contractMsg.ResubmitFailure != nil {
return m.resubmitFailure(ctx, contractAddr, contractMsg.ResubmitFailure)
}
var contractMsg bindings.NeutronMsg
if err := json.Unmarshal(msg.Custom, &contractMsg); err != nil {
ctx.Logger().Debug("json.Unmarshal: failed to decode incoming custom cosmos message",
"from_address", contractAddr.String(),
"message", string(msg.Custom),
"error", err,
)
return nil, nil, errors.Wrap(err, "failed to decode incoming custom cosmos message")
}

// Dispatch the message based on its type by checking each possible field
if contractMsg.SubmitTx != nil {
return m.submitTx(ctx, contractAddr, contractMsg.SubmitTx)
}
if contractMsg.RegisterInterchainAccount != nil {
return m.registerInterchainAccount(ctx, contractAddr, contractMsg.RegisterInterchainAccount)
}
if contractMsg.RegisterInterchainQuery != nil {
return m.registerInterchainQuery(ctx, contractAddr, contractMsg.RegisterInterchainQuery)
}
if contractMsg.UpdateInterchainQuery != nil {
return m.updateInterchainQuery(ctx, contractAddr, contractMsg.UpdateInterchainQuery)
}
if contractMsg.RemoveInterchainQuery != nil {
return m.removeInterchainQuery(ctx, contractAddr, contractMsg.RemoveInterchainQuery)
}
if contractMsg.IBCTransfer != nil {
return m.ibcTransfer(ctx, contractAddr, *contractMsg.IBCTransfer)
}
if contractMsg.SubmitAdminProposal != nil {
return m.submitAdminProposal(ctx, contractAddr, &contractMsg.SubmitAdminProposal.AdminProposal)
}
if contractMsg.CreateDenom != nil {
return m.createDenom(ctx, contractAddr, contractMsg.CreateDenom)
}
if contractMsg.MintTokens != nil {
return m.mintTokens(ctx, contractAddr, contractMsg.MintTokens)
}
if contractMsg.SetBeforeSendHook != nil {
return m.setBeforeSendHook(ctx, contractAddr, contractMsg.SetBeforeSendHook)
}
if contractMsg.ChangeAdmin != nil {
return m.changeAdmin(ctx, contractAddr, contractMsg.ChangeAdmin)
}
if contractMsg.BurnTokens != nil {
return m.burnTokens(ctx, contractAddr, contractMsg.BurnTokens)
}
if contractMsg.AddSchedule != nil {
return m.addSchedule(ctx, contractAddr, contractMsg.AddSchedule)
}
if contractMsg.RemoveSchedule != nil {
return m.removeSchedule(ctx, contractAddr, contractMsg.RemoveSchedule)
}
if contractMsg.ResubmitFailure != nil {
return m.resubmitFailure(ctx, contractAddr, contractMsg.ResubmitFailure)
}

// If none of the conditions are met, forward the message to the wrapped handler
return m.Wrapped.DispatchMsg(ctx, contractAddr, contractIBCPortID, msg)
}

Expand Down
2 changes: 1 addition & 1 deletion x/contractmanager/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw
}

// ConsensusVersion is a sequence number for state-breaking change of the module. It should be incremented on each consensus-breaking change introduced by the module. To avoid wrong/empty versions, the initial version should be set to 1
func (AppModule) ConsensusVersion() uint64 { return 2 }
func (AppModule) ConsensusVersion() uint64 { return types.ConsensusVersion }

// BeginBlock contains the logic that is automatically triggered at the beginning of each block
func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {}
Expand Down
3 changes: 3 additions & 0 deletions x/contractmanager/types/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package types

const ConsensusVersion = 2
2 changes: 1 addition & 1 deletion x/cron/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw
}

// ConsensusVersion is a sequence number for state-breaking change of the module. It should be incremented on each consensus-breaking change introduced by the module. To avoid wrong/empty versions, the initial version should be set to 1
func (AppModule) ConsensusVersion() uint64 { return 1 }
func (AppModule) ConsensusVersion() uint64 { return types.ConsensusVersion }

// BeginBlock contains the logic that is automatically triggered at the beginning of each block
func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {}
Expand Down
3 changes: 3 additions & 0 deletions x/cron/types/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package types

const ConsensusVersion = 1
2 changes: 1 addition & 1 deletion x/feeburner/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw
}

// ConsensusVersion is a sequence number for state-breaking change of the module. It should be incremented on each consensus-breaking change introduced by the module. To avoid wrong/empty versions, the initial version should be set to 1
func (AppModule) ConsensusVersion() uint64 { return 1 }
func (AppModule) ConsensusVersion() uint64 { return types.ConsensusVersion }

// BeginBlock contains the logic that is automatically triggered at the beginning of each block
func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {}
Expand Down
3 changes: 3 additions & 0 deletions x/feeburner/types/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package types

const ConsensusVersion = 1
2 changes: 1 addition & 1 deletion x/feerefunder/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw
}

// ConsensusVersion is a sequence number for state-breaking change of the module. It should be incremented on each consensus-breaking change introduced by the module. To avoid wrong/empty versions, the initial version should be set to 1
func (AppModule) ConsensusVersion() uint64 { return 1 }
func (AppModule) ConsensusVersion() uint64 { return types.ConsensusVersion }

// BeginBlock contains the logic that is automatically triggered at the beginning of each block
func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {}
Expand Down
3 changes: 3 additions & 0 deletions x/feerefunder/types/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package types

const ConsensusVersion = 1
2 changes: 1 addition & 1 deletion x/interchainqueries/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw
}

// ConsensusVersion implements ConsensusVersion.
func (AppModule) ConsensusVersion() uint64 { return 2 }
func (AppModule) ConsensusVersion() uint64 { return types.ConsensusVersion }

// BeginBlock executes all ABCI BeginBlock logic respective to the capability module.
func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {}
Expand Down
3 changes: 3 additions & 0 deletions x/interchainqueries/types/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package types

const ConsensusVersion = 2
2 changes: 1 addition & 1 deletion x/interchaintxs/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw
}

// ConsensusVersion implements ConsensusVersion.
func (AppModule) ConsensusVersion() uint64 { return 2 }
func (AppModule) ConsensusVersion() uint64 { return types.ConsensusVersion }

// BeginBlock executes all ABCI BeginBlock logic respective to the capability module.
func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {}
Expand Down
3 changes: 3 additions & 0 deletions x/interchaintxs/types/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package types

const ConsensusVersion = 2
6 changes: 4 additions & 2 deletions x/interchaintxs/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,7 @@ const (
prefixICARegistrationFeeFirstCodeID = iota + 2
)

var ParamsKey = []byte{prefixParamsKey}
var ICARegistrationFeeFirstCodeID = []byte{prefixICARegistrationFeeFirstCodeID}
var (
ParamsKey = []byte{prefixParamsKey}
ICARegistrationFeeFirstCodeID = []byte{prefixICARegistrationFeeFirstCodeID}
)
2 changes: 1 addition & 1 deletion x/tokenfactory/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw
}

// ConsensusVersion implements ConsensusVersion.
func (AppModule) ConsensusVersion() uint64 { return 1 }
func (AppModule) ConsensusVersion() uint64 { return types.ConsensusVersion }

// BeginBlock executes all ABCI BeginBlock logic respective to the tokenfactory module.
func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {}
Expand Down
2 changes: 2 additions & 0 deletions x/tokenfactory/types/constants.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package types

const ConsensusVersion = 1

var TrackBeforeSendGasLimit = uint64(100_000)
2 changes: 1 addition & 1 deletion x/transfer/ibc_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (im IBCModule) HandleTimeout(ctx sdk.Context, packet channeltypes.Packet, r

_, err = im.sudoKeeper.Sudo(ctx, senderAddress, msg)
if err != nil {
im.keeper.Logger(ctx).Debug("HandleAcknowledgement: failed to Sudo contract on packet acknowledgement", "error", err)
im.keeper.Logger(ctx).Debug("HandleAcknowledgement: failed to Sudo contract on packet timeout", "error", err)
}

return nil
Expand Down
1 change: 0 additions & 1 deletion x/transfer/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ func (k KeeperTransferWrapper) Transfer(goCtx context.Context, msg *wrappedtypes
}

transferMsg := types.NewMsgTransfer(msg.SourcePort, msg.SourceChannel, msg.Token, msg.Sender, msg.Receiver, msg.TimeoutHeight, msg.TimeoutTimestamp, msg.Memo)
transferMsg.Memo = msg.Memo
if _, err := k.Keeper.Transfer(goCtx, transferMsg); err != nil {
return nil, err
}
Expand Down

0 comments on commit ec21cfa

Please sign in to comment.