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 10 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 @@ -411,6 +412,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
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
Loading