Skip to content

Commit

Permalink
Update to ibc wasmvm (#7)
Browse files Browse the repository at this point in the history
* Update to ibc version of wasmvm

* Update test contracts

* Adjust code to updated wasmvm

* Update to tip of wasmvm PR 172

* Update test contracts and add stargate support to tests

* Upgrade to wasmvm 94043576bb71

Co-authored-by: Alex Peters <[email protected]>
  • Loading branch information
alpe authored Jan 19, 2021
2 parents d757176 + 607d1ee commit 572400e
Show file tree
Hide file tree
Showing 26 changed files with 472 additions and 473 deletions.
4 changes: 3 additions & 1 deletion app/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,8 @@ func CheckBalance(t *testing.T, app *WasmApp, addr sdk.AccAddress, balances sdk.
require.True(t, balances.IsEqual(app.bankKeeper.GetAllBalances(ctxCheck, addr)))
}

const DefaultGas = 1200000

// SignCheckDeliver checks a generated signed transaction and simulates a
// block commitment with the given transaction. A test assertion is made using
// the parameter 'expPass' against the result. A corresponding result is
Expand All @@ -333,7 +335,7 @@ func SignCheckDeliver(
txCfg,
msgs,
sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 0)},
helpers.DefaultGenTxGas,
DefaultGas,
chainID,
accNums,
accSeqs,
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/CosmWasm/wasmd
go 1.15

require (
github.com/CosmWasm/wasmvm v0.13.0
github.com/CosmWasm/wasmvm v0.13.1-0.20210118212136-94043576bb71
github.com/cosmos/cosmos-sdk v0.40.0
github.com/cosmos/iavl v0.15.3
github.com/dvsekhvalnov/jose2go v0.0.0-20200901110807-248326c1351b
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d h1:nalkkPQcITbvhmL4+C4cKA87NW0tfm3Kl9VXRoPywFg=
github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4=
github.com/CosmWasm/wasmvm v0.13.0 h1:AP8LVcCxI3KLtHY24qLhzVe+ChOXwcR8MNm8Jxkuhwk=
github.com/CosmWasm/wasmvm v0.13.0/go.mod h1:Id107qllDJyJjVQQsKMOy2YYF98sqPJ2t+jX1QES40A=
github.com/CosmWasm/wasmvm v0.13.1-0.20210118212136-94043576bb71 h1:MqEMNi3s1lONMT3iKPqJIsKDi0S4KoxmvvDfGpz4t5E=
github.com/CosmWasm/wasmvm v0.13.1-0.20210118212136-94043576bb71/go.mod h1:Id107qllDJyJjVQQsKMOy2YYF98sqPJ2t+jX1QES40A=
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
github.com/DataDog/zstd v1.4.1/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo=
github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ=
Expand Down
72 changes: 36 additions & 36 deletions x/wasm/ibc.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package wasm

import (
"github.com/CosmWasm/wasmd/x/wasm/internal/keeper/cosmwasm"
wasmTypes "github.com/CosmWasm/wasmd/x/wasm/internal/types"
wasmvmtypes "github.com/CosmWasm/wasmvm/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
"github.com/cosmos/cosmos-sdk/x/ibc/core/03-connection/types"
connectiontypes "github.com/cosmos/cosmos-sdk/x/ibc/core/03-connection/types"
channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/core/04-channel/types"
porttypes "github.com/cosmos/cosmos-sdk/x/ibc/core/05-port/types"
host "github.com/cosmos/cosmos-sdk/x/ibc/core/24-host"
Expand Down Expand Up @@ -44,12 +44,12 @@ func (i IBCHandler) OnChanOpenInit(
return sdkerrors.Wrapf(err, "contract port id")
}

err = i.keeper.OnOpenChannel(ctx, contractAddr, cosmwasm.IBCChannel{
Endpoint: cosmwasm.IBCEndpoint{Port: portID, Channel: channelID},
CounterpartyEndpoint: cosmwasm.IBCEndpoint{Port: counterParty.PortId, Channel: counterParty.ChannelId},
Order: order,
err = i.keeper.OnOpenChannel(ctx, contractAddr, wasmvmtypes.IBCChannel{
Endpoint: wasmvmtypes.IBCEndpoint{PortID: portID, ChannelID: channelID},
CounterpartyEndpoint: wasmvmtypes.IBCEndpoint{PortID: counterParty.PortId, ChannelID: counterParty.ChannelId},
Order: order.String(),
Version: version,
ConnectionHops: connectionHops,
ConnectionID: connectionHops[0], // At the moment this list must be of length 1. In the future multi-hop channels may be supported.
})
if err != nil {
return err
Expand Down Expand Up @@ -81,13 +81,13 @@ func (i IBCHandler) OnChanOpenTry(
return sdkerrors.Wrapf(err, "contract port id")
}

err = i.keeper.OnOpenChannel(ctx, contractAddr, cosmwasm.IBCChannel{
Endpoint: cosmwasm.IBCEndpoint{Port: portID, Channel: channelID},
CounterpartyEndpoint: cosmwasm.IBCEndpoint{Port: counterParty.PortId, Channel: counterParty.ChannelId},
Order: order,
err = i.keeper.OnOpenChannel(ctx, contractAddr, wasmvmtypes.IBCChannel{
Endpoint: wasmvmtypes.IBCEndpoint{PortID: portID, ChannelID: channelID},
CounterpartyEndpoint: wasmvmtypes.IBCEndpoint{PortID: counterParty.PortId, ChannelID: counterParty.ChannelId},
Order: order.String(),
Version: version,
CounterpartyVersion: &counterpartyVersion,
ConnectionHops: connectionHops,
CounterpartyVersion: counterpartyVersion,
ConnectionID: connectionHops[0], // At the moment this list must be of length 1. In the future multi-hop channels may be supported.
})
if err != nil {
return err
Expand Down Expand Up @@ -117,15 +117,15 @@ func (i IBCHandler) OnChanOpenAck(
}
channelInfo, ok := i.channelKeeper.GetChannel(ctx, portID, channelID)
if !ok {
return sdkerrors.Wrap(types.ErrInvalidCounterparty, "not found")
return sdkerrors.Wrap(connectiontypes.ErrInvalidCounterparty, "not found")
}
return i.keeper.OnConnectChannel(ctx, contractAddr, cosmwasm.IBCChannel{
Endpoint: cosmwasm.IBCEndpoint{Port: portID, Channel: channelID},
CounterpartyEndpoint: cosmwasm.IBCEndpoint{Port: channelInfo.Counterparty.PortId, Channel: channelInfo.Counterparty.ChannelId},
Order: channelInfo.Ordering,
return i.keeper.OnConnectChannel(ctx, contractAddr, wasmvmtypes.IBCChannel{
Endpoint: wasmvmtypes.IBCEndpoint{PortID: portID, ChannelID: channelID},
CounterpartyEndpoint: wasmvmtypes.IBCEndpoint{PortID: channelInfo.Counterparty.PortId, ChannelID: channelInfo.Counterparty.ChannelId},
Order: channelInfo.Ordering.String(),
Version: channelInfo.Version,
CounterpartyVersion: &counterpartyVersion,
ConnectionHops: channelInfo.ConnectionHops,
CounterpartyVersion: counterpartyVersion,
ConnectionID: channelInfo.ConnectionHops[0], // At the moment this list must be of length 1. In the future multi-hop channels may be supported.
})
}

Expand All @@ -137,14 +137,14 @@ func (i IBCHandler) OnChanOpenConfirm(ctx sdk.Context, portID, channelID string)
}
channelInfo, ok := i.channelKeeper.GetChannel(ctx, portID, channelID)
if !ok {
return sdkerrors.Wrap(types.ErrInvalidCounterparty, "not found")
return sdkerrors.Wrap(connectiontypes.ErrInvalidCounterparty, "not found")
}
return i.keeper.OnConnectChannel(ctx, contractAddr, cosmwasm.IBCChannel{
Endpoint: cosmwasm.IBCEndpoint{Port: portID, Channel: channelID},
CounterpartyEndpoint: cosmwasm.IBCEndpoint{Port: channelInfo.Counterparty.PortId, Channel: channelInfo.Counterparty.ChannelId},
Order: channelInfo.Ordering,
return i.keeper.OnConnectChannel(ctx, contractAddr, wasmvmtypes.IBCChannel{
Endpoint: wasmvmtypes.IBCEndpoint{PortID: portID, ChannelID: channelID},
CounterpartyEndpoint: wasmvmtypes.IBCEndpoint{PortID: channelInfo.Counterparty.PortId, ChannelID: channelInfo.Counterparty.ChannelId},
Order: channelInfo.Ordering.String(),
Version: channelInfo.Version,
ConnectionHops: channelInfo.ConnectionHops,
ConnectionID: channelInfo.ConnectionHops[0],
})
}

Expand All @@ -162,7 +162,7 @@ func (i IBCHandler) OnChanCloseConfirm(ctx sdk.Context, portID, channelID string
//if err != nil {
// return sdkerrors.Wrapf(err, "contract port id")
//}
//return i.keeper.OnChannelClose(ctx, contractAddr, cosmwasm.IBCInfo{Port: portID, Channel: channelID})
//return i.keeper.OnChannelClose(ctx, contractAddr, wasmvmtypes.IBCInfo{PortID: portID, ChannelID: channelID})
// any events to send?
panic("not implemented")
}
Expand Down Expand Up @@ -206,7 +206,7 @@ func (i IBCHandler) OnAcknowledgementPacket(ctx sdk.Context, packet channeltypes
return nil, sdkerrors.Wrapf(err, "contract port id")
}

err = i.keeper.OnAckPacket(ctx, contractAddr, cosmwasm.IBCAcknowledgement{
err = i.keeper.OnAckPacket(ctx, contractAddr, wasmvmtypes.IBCAcknowledgement{
Acknowledgement: acknowledgement,
OriginalPacket: newIBCPacket(packet),
})
Expand Down Expand Up @@ -265,17 +265,17 @@ func (i IBCHandler) OnTimeoutPacket(ctx sdk.Context, packet channeltypes.Packet)

}

func newIBCPacket(packet channeltypes.Packet) cosmwasm.IBCPacket {
return cosmwasm.IBCPacket{
Data: packet.Data,
Source: cosmwasm.IBCEndpoint{Channel: packet.SourceChannel, Port: packet.SourcePort},
Destination: cosmwasm.IBCEndpoint{Channel: packet.DestinationChannel, Port: packet.DestinationPort},
Sequence: packet.Sequence,
IBCTimeoutHeight: cosmwasm.IBCTimeoutHeight{
func newIBCPacket(packet channeltypes.Packet) wasmvmtypes.IBCPacket {
return wasmvmtypes.IBCPacket{
Data: packet.Data,
Src: wasmvmtypes.IBCEndpoint{ChannelID: packet.SourceChannel, PortID: packet.SourcePort},
Dest: wasmvmtypes.IBCEndpoint{ChannelID: packet.DestinationChannel, PortID: packet.DestinationPort},
Sequence: packet.Sequence,
TimeoutHeight: &wasmvmtypes.IBCTimeoutHeight{
TimeoutHeight: packet.TimeoutHeight.RevisionHeight,
RevisionNumber: packet.TimeoutHeight.RevisionNumber,
},
TimeoutTimestamp: packet.TimeoutTimestamp,
TimeoutTimestamp: &packet.TimeoutTimestamp,
}
}

Expand Down
1 change: 0 additions & 1 deletion x/wasm/internal/keeper/cosmwasm/README.md

This file was deleted.

86 changes: 0 additions & 86 deletions x/wasm/internal/keeper/cosmwasm/contract.go

This file was deleted.

76 changes: 0 additions & 76 deletions x/wasm/internal/keeper/cosmwasm/msg.go

This file was deleted.

14 changes: 0 additions & 14 deletions x/wasm/internal/keeper/cosmwasm/query.go

This file was deleted.

Loading

0 comments on commit 572400e

Please sign in to comment.