Skip to content

Commit

Permalink
[Feature] Bump cosmwasm to v0.9 (#357)
Browse files Browse the repository at this point in the history
* Bump cosmwasm v0.9.x & append migration feature

* add testcase and client code for migrate & update-owner

* add simulation code for updates

* delete data

* Bump cosmwasm v0.9.2 & go-cosmwasm v0.9.1

* fix swagger example

Co-authored-by: Paul Kim <paul@terra.money>
  • Loading branch information
yys and hanjukim committed Jul 1, 2020
1 parent 8915a48 commit 38447d8
Show file tree
Hide file tree
Showing 42 changed files with 1,386 additions and 327 deletions.
Binary file removed app.test
Binary file not shown.
4 changes: 2 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ func NewTerraApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest
market.NewAppModule(app.marketKeeper, app.accountKeeper, app.oracleKeeper),
oracle.NewAppModule(app.oracleKeeper, app.accountKeeper),
treasury.NewAppModule(app.treasuryKeeper),
wasm.NewAppModule(app.wasmKeeper, app.accountKeeper),
wasm.NewAppModule(app.wasmKeeper, app.accountKeeper, app.bankKeeper),
)

// During begin block slashing happens after distr.BeginBlocker so that
Expand Down Expand Up @@ -307,7 +307,7 @@ func NewTerraApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest
market.NewAppModule(app.marketKeeper, app.accountKeeper, app.oracleKeeper),
oracle.NewAppModule(app.oracleKeeper, app.accountKeeper),
treasury.NewAppModule(app.treasuryKeeper),
wasm.NewAppModule(app.wasmKeeper, app.accountKeeper),
wasm.NewAppModule(app.wasmKeeper, app.accountKeeper, app.bankKeeper),
)

app.sm.RegisterStoreDecoders()
Expand Down
73 changes: 72 additions & 1 deletion client/lcd/swagger-ui/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2726,6 +2726,58 @@ paths:
description: OK
schema:
$ref: "#/definitions/ContractInfo"
/wasm/contracts/{contractAddress}/migrate:
post:
summary: Migrate wasm contract to new code base
tags:
- Wasm
produces:
- application/json
parameters:
- in: path
name: contractAddress
description: contract address you want to migrate
required: true
type: string
- in: body
name: migrate contract request body
schema:
$ref: "#/definitions/MigrateContractReq"
responses:
200:
description: OK
schema:
$ref: "#/definitions/StdTx"
400:
description: Bad request
500:
description: Internal Server Error
/wasm/contracts/{contractAddress}/owner:
post:
summary: Update wasm contract owner to new address
tags:
- Wasm
produces:
- application/json
parameters:
- in: path
name: contractAddress
description: contract address you want to update owner
required: true
type: string
- in: body
name: update contract owner request body
schema:
$ref: "#/definitions/UpdateContractOwnerReq"
responses:
200:
description: OK
schema:
$ref: "#/definitions/StdTx"
400:
description: Bad request
500:
description: Internal Server Error
/wasm/contracts/{contractAddress}/store:
get:
summary: Get stored information with query msg
Expand Down Expand Up @@ -3834,7 +3886,6 @@ definitions:
type: string
description: json formatted string
example: "{}"

ExecuteContractReq:
type: object
properties:
Expand All @@ -3846,5 +3897,25 @@ definitions:
$ref: "#/definitions/Coin"
exec_msg:
type: string
example: "{}"
MigrateContractReq:
type: object
properties:
base_req:
$ref: "#/definitions/BaseReq"
new_code_id:
type: number
format: integer
example: 10
migrate_msg:
type: string
example: "{}"
UpdateContractOwnerReq:
type: object
properties:
base_req:
$ref: "#/definitions/BaseReq"
new_owner:
$ref: "#/definitions/Address"
description: json formatted string
example: "{}"
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/terra-project/core
go 1.13

require (
github.com/CosmWasm/go-cosmwasm v0.8.0
github.com/CosmWasm/go-cosmwasm v0.9.1
github.com/cosmos/cosmos-sdk v0.38.4
github.com/gorilla/mux v1.7.3
github.com/otiai10/copy v1.0.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/ChainSafe/go-schnorrkel v0.0.0-20200102211924-4bcbc698314f h1:4O1om+UVU+Hfcihr1timk8YNXHxzZWgCo7ofnrZRApw=
github.com/ChainSafe/go-schnorrkel v0.0.0-20200102211924-4bcbc698314f/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4=
github.com/CosmWasm/go-cosmwasm v0.8.0 h1:xoufklhgJQ7Sy6xwZw9hRbnXl79ylvxlpGJDcPz9Ipo=
github.com/CosmWasm/go-cosmwasm v0.8.0/go.mod h1:gAFCwllx97ejI+m9SqJQrmd2SBW7HA0fOjvWWJjM2uc=
github.com/CosmWasm/go-cosmwasm v0.9.1 h1:w5s2o7H3cmNexct9yv8F6OLXwgxbdfVApwam7DibPqI=
github.com/CosmWasm/go-cosmwasm v0.9.1/go.mod h1:gAFCwllx97ejI+m9SqJQrmd2SBW7HA0fOjvWWJjM2uc=
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
Expand Down
2 changes: 1 addition & 1 deletion x/auth/ante/tax_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func TestEnsureMempoolFeesInstantiateContract(t *testing.T) {

sendAmount := int64(1000000)
sendCoins := sdk.NewCoins(sdk.NewInt64Coin(core.MicroSDRDenom, sendAmount))
msgs := []sdk.Msg{wasm.NewMsgInstantiateContract(addr1, 0, []byte{}, sendCoins)}
msgs := []sdk.Msg{wasm.NewMsgInstantiateContract(addr1, 0, []byte{}, sendCoins, true)}

fee := auth.NewStdFee(100000, sdk.NewCoins())
tx := types.NewTestTx(ctx, msgs, privs, accNums, seqs, fee)
Expand Down
12 changes: 9 additions & 3 deletions x/wasm/alias.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// nolint
// autogenerated code using github.com/rigelrozanski/multitool
// aliases generated for the following subdirectories:
// ALIASGEN: core/x/wasm/internal/keeper
// ALIASGEN: core/x/wasm/internal/types
// ALIASGEN: github.com/terra-project/core/x/wasm/internal/keeper
// ALIASGEN: github.com/terra-project/core/x/wasm/internal/types
package wasm

import (
Expand Down Expand Up @@ -48,7 +48,7 @@ var (
NewWasmMsgParser = keeper.NewWasmMsgParser
NewWasmQuerier = keeper.NewWasmQuerier
RegisterCodec = types.RegisterCodec
ParseResult = types.ParseResult
ParseEvents = types.ParseEvents
ParseToCoin = types.ParseToCoin
ParseToCoins = types.ParseToCoins
EncodeSdkCoin = types.EncodeSdkCoin
Expand All @@ -66,6 +66,8 @@ var (
NewMsgStoreCode = types.NewMsgStoreCode
NewMsgInstantiateContract = types.NewMsgInstantiateContract
NewMsgExecuteContract = types.NewMsgExecuteContract
NewMsgMigrateContract = types.NewMsgMigrateContract
NewMsgUpdateContractOwner = types.NewMsgUpdateContractOwner
NewModuleMsgParser = types.NewModuleMsgParser
DefaultParams = types.DefaultParams
ParamKeyTable = types.ParamKeyTable
Expand All @@ -87,6 +89,8 @@ var (
ErrInvalidMsg = types.ErrInvalidMsg
ErrNoRegisteredQuerier = types.ErrNoRegisteredQuerier
ErrNoRegisteredParser = types.ErrNoRegisteredParser
ErrMigrationFailed = types.ErrMigrationFailed
ErrNotMigratable = types.ErrNotMigratable
LastCodeIDKey = types.LastCodeIDKey
LastInstanceIDKey = types.LastInstanceIDKey
CodeKey = types.CodeKey
Expand Down Expand Up @@ -114,6 +118,8 @@ type (
MsgStoreCode = types.MsgStoreCode
MsgInstantiateContract = types.MsgInstantiateContract
MsgExecuteContract = types.MsgExecuteContract
MsgMigrateContract = types.MsgMigrateContract
MsgUpdateContractOwner = types.MsgUpdateContractOwner
WasmMsgParserInterface = types.WasmMsgParserInterface
WasmCustomMsg = types.WasmCustomMsg
MsgParser = types.MsgParser
Expand Down
Loading

0 comments on commit 38447d8

Please sign in to comment.