Skip to content

Commit

Permalink
Merge pull request #1106 from Agoric/mfig/update-goz-1b
Browse files Browse the repository at this point in the history
Bump dependency on newer cosmos-sdk
  • Loading branch information
michaelfig authored May 17, 2020
2 parents 50caaa6 + d114c5e commit fdac401
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 35 deletions.
26 changes: 20 additions & 6 deletions packages/cosmic-swingset/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/codec"
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/simapp"
"github.com/cosmos/cosmos-sdk/std"
codecstd "github.com/cosmos/cosmos-sdk/std"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/version"
Expand Down Expand Up @@ -176,8 +176,7 @@ func NewAgoricApp(
) *AgoricApp {

// TODO: Remove cdc in favor of appCodec once all modules are migrated.
cdc := codecstd.MakeCodec(ModuleBasics)
appCodec := codecstd.NewAppCodec(cdc)
appCodec, cdc := MakeCodecs()

bApp := baseapp.NewBaseApp(appName, logger, db, auth.DefaultTxDecoder(cdc), baseAppOptions...)
bApp.SetCommitMultiStoreTracer(traceStore)
Expand Down Expand Up @@ -268,13 +267,15 @@ func NewAgoricApp(
)

// Create IBC keeper
// TODO: remove amino codec dependency once Tendermint version is upgraded with
// protobuf changes
app.ibcKeeper = ibc.NewKeeper(
app.cdc, keys[ibc.StoreKey], stakingKeeper, scopedIBCKeeper,
app.cdc, appCodec, keys[ibc.StoreKey], stakingKeeper, scopedIBCKeeper,
)

// create Transfer Keepers
app.transferKeeper = transfer.NewKeeper(
app.cdc, keys[transfer.StoreKey],
appCodec, keys[transfer.StoreKey],
app.ibcKeeper.ChannelKeeper, &app.ibcKeeper.PortKeeper,
app.accountKeeper, app.bankKeeper,
scopedTransferKeeper,
Expand Down Expand Up @@ -329,7 +330,7 @@ func NewAgoricApp(
distr.NewAppModule(appCodec, app.distrKeeper, app.accountKeeper, app.bankKeeper, app.stakingKeeper),
staking.NewAppModule(appCodec, app.stakingKeeper, app.accountKeeper, app.bankKeeper),
upgrade.NewAppModule(app.upgradeKeeper),
evidence.NewAppModule(appCodec, app.evidenceKeeper),
evidence.NewAppModule(app.evidenceKeeper),
ibc.NewAppModule(app.ibcKeeper),
params.NewAppModule(app.paramsKeeper),
swingsetModule,
Expand Down Expand Up @@ -497,6 +498,19 @@ func (app *AgoricApp) SimulationManager() *module.SimulationManager {
return app.sm
}

// MakeCodecs constructs the *std.Codec and *codec.Codec instances used by
// GaiaApp.
func MakeCodecs() (*std.Codec, *codec.Codec) {
cdc := std.MakeCodec(ModuleBasics)
interfaceRegistry := cdctypes.NewInterfaceRegistry()
appCodec := std.NewAppCodec(cdc, interfaceRegistry)

sdk.RegisterInterfaces(interfaceRegistry)
ModuleBasics.RegisterInterfaceModules(interfaceRegistry)

return appCodec, cdc
}

// GetMaccPerms returns a copy of the module account permissions
func GetMaccPerms() map[string][]string {
dupMaccPerms := make(map[string][]string)
Expand Down
7 changes: 2 additions & 5 deletions packages/cosmic-swingset/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.14
require (
github.com/Agoric/agoric-sdk v0.0.0-00010101000000-000000000000 // indirect
github.com/bartekn/go-bip39 v0.0.0-20171116152956-a05967ea095d // indirect
github.com/cosmos/cosmos-sdk v0.34.4-0.20200502230752-7557f0eda346
github.com/cosmos/cosmos-sdk v0.34.4-0.20200511222341-80be50319ca5
github.com/gibson042/canonicaljson-go v1.0.3 // indirect
github.com/golang/mock v1.4.3 // indirect
github.com/gorilla/handlers v1.4.2 // indirect
Expand All @@ -16,11 +16,10 @@ require (
github.com/pelletier/go-toml v1.7.0 // indirect
github.com/pkg/errors v0.9.1
github.com/rakyll/statik v0.1.7 // indirect
github.com/regen-network/cosmos-proto v0.2.2 // indirect
github.com/snikch/goodman v0.0.0-20171125024755-10e37e294daa
github.com/spf13/afero v1.2.2 // indirect
github.com/spf13/cobra v1.0.0
github.com/spf13/viper v1.6.3
github.com/spf13/viper v1.7.0
github.com/stretchr/testify v1.5.1
github.com/tendermint/go-amino v0.15.1
github.com/tendermint/iavl v0.13.3 // indirect
Expand All @@ -31,5 +30,3 @@ require (
replace github.com/keybase/go-keychain => github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4

replace github.com/Agoric/agoric-sdk => ../..

replace github.com/cosmos/cosmos-sdk => github.com/cosmos/cosmos-sdk v0.34.4-0.20200502230752-7557f0eda346
84 changes: 84 additions & 0 deletions packages/cosmic-swingset/go.sum

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions packages/cosmic-swingset/lib/daemon/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"github.com/cosmos/cosmos-sdk/client/debug"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/server"
codecstd "github.com/cosmos/cosmos-sdk/std"
"github.com/cosmos/cosmos-sdk/store"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/bank"
Expand Down Expand Up @@ -50,8 +49,7 @@ func Run() {
func RunWithController(sendToController Sender) {
cobra.EnableCommandSorting = false

cdc := codecstd.MakeCodec(app.ModuleBasics)
appCodec := codecstd.NewAppCodec(cdc)
appCodec, cdc := app.MakeCodecs()

config := sdk.GetConfig()
app.SetConfigDefaults(config)
Expand Down
4 changes: 1 addition & 3 deletions packages/cosmic-swingset/lib/helper/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"github.com/cosmos/cosmos-sdk/client/keys"
"github.com/cosmos/cosmos-sdk/client/lcd"
"github.com/cosmos/cosmos-sdk/client/rpc"
codecstd "github.com/cosmos/cosmos-sdk/std"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/auth"
Expand All @@ -29,8 +28,7 @@ import (
)

var (
cdc = codecstd.MakeCodec(app.ModuleBasics)
appCodec = codecstd.NewAppCodec(cdc)
appCodec, cdc = app.MakeCodecs()
)

func init() {
Expand Down
25 changes: 12 additions & 13 deletions packages/cosmic-swingset/x/swingset/ibc.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/capability"
channel "github.com/cosmos/cosmos-sdk/x/ibc/04-channel"
channelexported "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/exported"
channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types"
port "github.com/cosmos/cosmos-sdk/x/ibc/05-port"
porttypes "github.com/cosmos/cosmos-sdk/x/ibc/05-port/types"
Expand All @@ -21,14 +20,14 @@ type channelHandler struct {
}

type channelMessage struct { // comes from swingset's IBC handler
Type string `json:"type"` // IBC_METHOD
Method string `json:"method"`
Packet channeltypes.Packet `json:"packet"`
RelativeTimeout uint64 `json:"relativeTimeout"`
Order channelexported.Order `json:"order"`
Hops []string `json:"hops"`
Version string `json:"version"`
Ack []byte `json:"ack"`
Type string `json:"type"` // IBC_METHOD
Method string `json:"method"`
Packet channeltypes.Packet `json:"packet"`
RelativeTimeout uint64 `json:"relativeTimeout"`
Order ibctypes.Order `json:"order"`
Hops []string `json:"hops"`
Version string `json:"version"`
Ack []byte `json:"ack"`
}

// DefaultRouter is a temporary hack until cosmos-sdk implements its features FIXME.
Expand Down Expand Up @@ -143,7 +142,7 @@ func (am AppModule) CallToController(ctx sdk.Context, send string) (string, erro
type channelOpenInitEvent struct {
Type string `json:"type"` // IBC
Event string `json:"event"` // channelOpenInit
Order channelexported.Order `json:"order"`
Order ibctypes.Order `json:"order"`
ConnectionHops []string `json:"connectionHops"`
PortID string `json:"portID"`
ChannelID string `json:"channelID"`
Expand All @@ -154,7 +153,7 @@ type channelOpenInitEvent struct {
// Implement IBCModule callbacks
func (am AppModule) OnChanOpenInit(
ctx sdk.Context,
order channelexported.Order,
order ibctypes.Order,
connectionHops []string,
portID string,
channelID string,
Expand Down Expand Up @@ -194,7 +193,7 @@ func (am AppModule) OnChanOpenInit(
type channelOpenTryEvent struct {
Type string `json:"type"` // IBC
Event string `json:"event"` // channelOpenTry
Order channelexported.Order `json:"order"`
Order ibctypes.Order `json:"order"`
ConnectionHops []string `json:"connectionHops"`
PortID string `json:"portID"`
ChannelID string `json:"channelID"`
Expand All @@ -205,7 +204,7 @@ type channelOpenTryEvent struct {

func (am AppModule) OnChanOpenTry(
ctx sdk.Context,
order channelexported.Order,
order ibctypes.Order,
connectionHops []string,
portID,
channelID string,
Expand Down
6 changes: 3 additions & 3 deletions packages/cosmic-swingset/x/swingset/internal/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,10 @@ func (k Keeper) GetNextSequenceSend(ctx sdk.Context, portID, channelID string) (

// ChanOpenInit defines a wrapper function for the channel Keeper's function
// in order to expose it to the SwingSet IBC handler.
func (k Keeper) ChanOpenInit(ctx sdk.Context, order channelexported.Order, connectionHops []string,
func (k Keeper) ChanOpenInit(ctx sdk.Context, order ibctypes.Order, connectionHops []string,
portID, channelID, rPortID, rChannelID, version string,
) error {
capName := porttypes.PortPath(portID)
capName := ibctypes.PortPath(portID)
portCap, ok := k.GetCapability(ctx, capName)
if !ok {
return sdkerrors.Wrapf(porttypes.ErrInvalidPort, "could not retrieve port capability at: %s", capName)
Expand Down Expand Up @@ -228,7 +228,7 @@ func (k Keeper) ChanCloseInit(ctx sdk.Context, portID, channelID string) error {
// order to expose it to the SwingSet IBC handler.
func (k Keeper) BindPort(ctx sdk.Context, portID string) error {
cap := k.portKeeper.BindPort(ctx, portID)
return k.ClaimCapability(ctx, cap, porttypes.PortPath(portID))
return k.ClaimCapability(ctx, cap, ibctypes.PortPath(portID))
}

// TimeoutExecuted defines a wrapper function for the channel Keeper's function
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/capability"
clientexported "github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported"
connection "github.com/cosmos/cosmos-sdk/x/ibc/03-connection"
connection "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types"
channel "github.com/cosmos/cosmos-sdk/x/ibc/04-channel"
channelexported "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/exported"
"github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types"
ibctypes "github.com/cosmos/cosmos-sdk/x/ibc/types"
)

// ChannelKeeper defines the expected IBC channel keeper
Expand All @@ -16,7 +17,7 @@ type ChannelKeeper interface {
GetNextSequenceSend(ctx sdk.Context, portID, channelID string) (uint64, bool)
SendPacket(ctx sdk.Context, channelCap *capability.Capability, packet channelexported.PacketI) error
PacketExecuted(ctx sdk.Context, channelCap *capability.Capability, packet channelexported.PacketI, acknowledgement []byte) error
ChanOpenInit(ctx sdk.Context, order channelexported.Order, connectionHops []string, portID, channelID string,
ChanOpenInit(ctx sdk.Context, order ibctypes.Order, connectionHops []string, portID, channelID string,
portCap *capability.Capability, counterparty types.Counterparty, version string) (*capability.Capability, error)

ChanCloseInit(ctx sdk.Context, portID, channelID string, chanCap *capability.Capability) error
Expand Down

0 comments on commit fdac401

Please sign in to comment.