Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bump] cosmwasm to v0.15.1 #509

Merged
merged 17 commits into from
Jul 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## [Unreleased]

* (cosmwasm) Bump CosmWasm version to [v0.15.0](https://github.com/CosmWasm/cosmwasm/release/tag/v0.15.0).
* (tendermint) Bump Tendermint version to [v0.34.10](https://github.com/tendermint/tendermint/releases/tag/v0.34.10).
* (cosmos-sdk) Bump Cosmos SDK version to [v0.43.0](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.43.0).
* (cosmwasm) Bump CosmWasm version to [v0.14.0](https://github.com/CosmWasm/cosmwasm/release/tag/v0.14.0).
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ WORKDIR /code
COPY . /code/

# See https://github.com/CosmWasm/wasmvm/releases
ADD https://github.com/CosmWasm/wasmvm/releases/download/v0.14.0/libwasmvm_muslc.a /lib/libwasmvm_muslc.a
RUN sha256sum /lib/libwasmvm_muslc.a | grep 220b85158d1ae72008f099a7ddafe27f6374518816dd5873fd8be272c5418026
ADD https://github.com/CosmWasm/wasmvm/releases/download/v0.15.1/libwasmvm_muslc.a /lib/libwasmvm_muslc.a
RUN sha256sum /lib/libwasmvm_muslc.a | grep 379c61d2e53f87f63639eaa8ba8bbe687e5833158bb10e0dc0523c3377248d01

# force it to use static lib (from above) not standard libgo_cosmwasm.so file
RUN LEDGER_ENABLED=false BUILD_TAGS=muslc make build
Expand Down
2 changes: 2 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ import (

bankwasm "github.com/terra-money/core/custom/bank/wasm"
distrwasm "github.com/terra-money/core/custom/distribution/wasm"
govwasm "github.com/terra-money/core/custom/gov/wasm"
stakingwasm "github.com/terra-money/core/custom/staking/wasm"
marketwasm "github.com/terra-money/core/x/market/wasm"
oraclewasm "github.com/terra-money/core/x/oracle/wasm"
Expand Down Expand Up @@ -416,6 +417,7 @@ func NewTerraApp(
wasmtypes.WasmMsgParserRouteMarket: marketwasm.NewWasmMsgParser(),
wasmtypes.WasmMsgParserRouteWasm: wasmkeeper.NewWasmMsgParser(),
wasmtypes.WasmMsgParserRouteDistribution: distrwasm.NewWasmMsgParser(),
wasmtypes.WasmMsgParserRouteGov: govwasm.NewWasmMsgParser(),
}, wasmkeeper.NewStargateWasmMsgParser(appCodec))
app.WasmKeeper.RegisterQueriers(map[string]wasmtypes.WasmQuerierInterface{
wasmtypes.WasmQueryRouteBank: bankwasm.NewWasmQuerier(app.BankKeeper),
Expand Down
4 changes: 0 additions & 4 deletions custom/bank/wasm/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ func (WasmMsgParser) Parse(contractAddr sdk.AccAddress, wasmMsg wasmvmtypes.Cosm
return nil, sdkerrors.Wrap(wasm.ErrInvalidMsg, "Unknown variant of Bank")
}

if len(msg.Send.Amount) == 0 {
return nil, nil
}

toAddr, stderr := sdk.AccAddressFromBech32(msg.Send.ToAddress)
if stderr != nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, msg.Send.ToAddress)
Expand Down
52 changes: 52 additions & 0 deletions custom/gov/wasm/interface.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package wasm

import (
"encoding/json"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/gov/types"

wasmvmtypes "github.com/CosmWasm/wasmvm/types"

wasm "github.com/terra-money/core/x/wasm/exported"
)

var _ wasm.WasmMsgParserInterface = WasmMsgParser{}

// WasmMsgParser - wasm msg parser for staking msgs
type WasmMsgParser struct{}

// NewWasmMsgParser returns bank wasm msg parser
func NewWasmMsgParser() WasmMsgParser {
return WasmMsgParser{}
}

// Parse implements wasm staking msg parser
func (WasmMsgParser) Parse(contractAddr sdk.AccAddress, wasmMsg wasmvmtypes.CosmosMsg) (sdk.Msg, error) {
msg := wasmMsg.Gov

var option types.VoteOption
switch msg.Vote.Vote {
case wasmvmtypes.Yes:
option = types.OptionYes
case wasmvmtypes.No:
option = types.OptionNo
case wasmvmtypes.NoWithVeto:
option = types.OptionNoWithVeto
case wasmvmtypes.Abstain:
option = types.OptionAbstain
}

cosmosMsg := &types.MsgVote{
ProposalId: msg.Vote.ProposalId,
Voter: contractAddr.String(),
Option: option,
}

return cosmosMsg, cosmosMsg.ValidateBasic()
}

// ParseCustom implements custom parser
func (WasmMsgParser) ParseCustom(_ sdk.AccAddress, _ json.RawMessage) (sdk.Msg, error) {
return nil, nil
}
111 changes: 111 additions & 0 deletions custom/gov/wasm/interface_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
package wasm

import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/crypto/secp256k1"

wasmvmtypes "github.com/CosmWasm/wasmvm/types"

sdk "github.com/cosmos/cosmos-sdk/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
)

func TestEncoding(t *testing.T) {
addrs := []sdk.AccAddress{
sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()),
sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()),
sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()),
}

cases := map[string]struct {
sender sdk.AccAddress
input wasmvmtypes.CosmosMsg
// set if valid
output sdk.Msg
// set if invalid
isError bool
}{
"yes vote": {
sender: addrs[0],
input: wasmvmtypes.CosmosMsg{
Gov: &wasmvmtypes.GovMsg{
Vote: &wasmvmtypes.VoteMsg{
ProposalId: 1,
Vote: wasmvmtypes.Yes,
},
},
},
output: &govtypes.MsgVote{
Voter: addrs[0].String(),
ProposalId: 1,
Option: govtypes.OptionYes,
},
},
"no vote": {
sender: addrs[0],
input: wasmvmtypes.CosmosMsg{
Gov: &wasmvmtypes.GovMsg{
Vote: &wasmvmtypes.VoteMsg{
ProposalId: 1,
Vote: wasmvmtypes.No,
},
},
},
output: &govtypes.MsgVote{
Voter: addrs[0].String(),
ProposalId: 1,
Option: govtypes.OptionNo,
},
},
"no_with_veto vote": {
sender: addrs[0],
input: wasmvmtypes.CosmosMsg{
Gov: &wasmvmtypes.GovMsg{
Vote: &wasmvmtypes.VoteMsg{
ProposalId: 1,
Vote: wasmvmtypes.NoWithVeto,
},
},
},
output: &govtypes.MsgVote{
Voter: addrs[0].String(),
ProposalId: 1,
Option: govtypes.OptionNoWithVeto,
},
},
"abstain vote": {
sender: addrs[0],
input: wasmvmtypes.CosmosMsg{
Gov: &wasmvmtypes.GovMsg{
Vote: &wasmvmtypes.VoteMsg{
ProposalId: 1,
Vote: wasmvmtypes.Abstain,
},
},
},
output: &govtypes.MsgVote{
Voter: addrs[0].String(),
ProposalId: 1,
Option: govtypes.OptionAbstain,
},
},
}

parser := NewWasmMsgParser()
for name, tc := range cases {
tc := tc
t.Run(name, func(t *testing.T) {
res, err := parser.Parse(tc.sender, tc.input)
if tc.isError {
require.Error(t, err)
} else {
require.NoError(t, err)
assert.Equal(t, tc.output, res)
}
})
}

}
20 changes: 0 additions & 20 deletions docs/core/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,6 @@
- [terra/wasm/v1beta1/wasm.proto](#terra/wasm/v1beta1/wasm.proto)
- [CodeInfo](#terra.wasm.v1beta1.CodeInfo)
- [ContractInfo](#terra.wasm.v1beta1.ContractInfo)
- [EventParams](#terra.wasm.v1beta1.EventParams)
- [Params](#terra.wasm.v1beta1.Params)

- [terra/wasm/v1beta1/genesis.proto](#terra/wasm/v1beta1/genesis.proto)
Expand Down Expand Up @@ -13135,23 +13134,6 @@ ContractInfo stores a WASM contract instance



<a name="terra.wasm.v1beta1.EventParams"></a>

### EventParams
EventParams defines the event related parameteres


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `max_attribute_num` | [uint64](#uint64) | | |
| `max_attribute_key_length` | [uint64](#uint64) | | |
| `max_attribute_value_length` | [uint64](#uint64) | | |






<a name="terra.wasm.v1beta1.Params"></a>

### Params
Expand All @@ -13163,8 +13145,6 @@ Params defines the parameters for the wasm module.
| `max_contract_size` | [uint64](#uint64) | | |
| `max_contract_gas` | [uint64](#uint64) | | |
| `max_contract_msg_size` | [uint64](#uint64) | | |
| `max_contract_data_size` | [uint64](#uint64) | | |
| `event_params` | [EventParams](#terra.wasm.v1beta1.EventParams) | | |



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 @@ go 1.16
module github.com/terra-money/core

require (
github.com/CosmWasm/wasmvm v0.14.0
github.com/CosmWasm/wasmvm v0.15.1
github.com/cosmos/cosmos-sdk v0.43.0-beta1
github.com/cosmos/ibc-go v1.0.0-alpha2
github.com/gogo/protobuf v1.3.3
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,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.14.0 h1:oceacwdwD9d9GzqElOrB8Qu1topx4+zM47VEqnJ/9Jo=
github.com/CosmWasm/wasmvm v0.14.0/go.mod h1:Id107qllDJyJjVQQsKMOy2YYF98sqPJ2t+jX1QES40A=
github.com/CosmWasm/wasmvm v0.15.1 h1:5hPBqPzHzVGtISJy/Mr89PbNIe+a3Q6qaFbnOFu/m64=
github.com/CosmWasm/wasmvm v0.15.1/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
11 changes: 0 additions & 11 deletions proto/terra/wasm/v1beta1/wasm.proto
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,6 @@ message Params {
uint64 max_contract_size = 1 [(gogoproto.moretags) = "yaml:\"max_contract_size\""];
uint64 max_contract_gas = 2 [(gogoproto.moretags) = "yaml:\"max_contract_gas\""];
uint64 max_contract_msg_size = 3 [(gogoproto.moretags) = "yaml:\"max_contract_msg_size\""];
uint64 max_contract_data_size = 4 [(gogoproto.moretags) = "yaml:\"max_contract_data_size\""];
EventParams event_params = 5 [(gogoproto.moretags) = "yaml:\"event_params\"", (gogoproto.nullable) = false];
}

// EventParams defines the event related parameteres
message EventParams {
option (gogoproto.equal) = true;

uint64 max_attribute_num = 1 [(gogoproto.moretags) = "yaml:\"max_contract_event_attribute_num\""];
uint64 max_attribute_key_length = 2 [(gogoproto.moretags) = "yaml:\"max_contract_event_attribute_key_length\""];
uint64 max_attribute_value_length = 3 [(gogoproto.moretags) = "yaml:\"max_contract_event_attribute_value_length\""];
}

// CodeInfo is data for the uploaded contract WASM code
Expand Down
3 changes: 2 additions & 1 deletion x/market/legacy/v05/migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/cosmos/cosmos-sdk/client"
Expand Down Expand Up @@ -59,5 +60,5 @@ func TestMigrate(t *testing.T) {
}
}`

require.Equal(t, expected, string(indentedBz))
assert.JSONEq(t, expected, string(indentedBz))
}
Loading