Update go-cosmwasm to v0.10.0-alpha2 and code compiles

This commit is contained in:
Ethan Frey 2020-07-24 10:51:10 +02:00
parent 5e6a0eb01d
commit fae55715e5
5 changed files with 18 additions and 11 deletions

3
go.mod
View File

@ -3,8 +3,7 @@ module github.com/CosmWasm/wasmd
go 1.13
require (
// Note: update ENV GO_COSMWASM in Dockerfile when updating this
github.com/CosmWasm/go-cosmwasm v0.9.1
github.com/CosmWasm/go-cosmwasm v0.10.0-alpha2
github.com/cosmos/cosmos-sdk v0.39.0
github.com/golang/mock v1.4.3 // indirect
github.com/google/gofuzz v1.0.0

2
go.sum
View File

@ -11,6 +11,8 @@ github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d h1:nalkkPQ
github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4=
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/CosmWasm/go-cosmwasm v0.10.0-alpha2 h1:k069wQF0f24w3A52mjR3AK6AfkuvQ5d0Mdu/rpB5nEk=
github.com/CosmWasm/go-cosmwasm v0.10.0-alpha2/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=

View File

@ -6,15 +6,21 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
)
func humanAddress(canon []byte) (string, error) {
var (
CostHumanize = 5 * GasMultiplier
CostCanonical = 4 * GasMultiplier
)
func humanAddress(canon []byte) (string, uint64, error) {
if len(canon) != sdk.AddrLen {
return "", fmt.Errorf("Expected %d byte address", sdk.AddrLen)
return "", CostHumanize, fmt.Errorf("Expected %d byte address", sdk.AddrLen)
}
return sdk.AccAddress(canon).String(), nil
return sdk.AccAddress(canon).String(), CostHumanize, nil
}
func canonicalAddress(human string) ([]byte, error) {
return sdk.AccAddressFromBech32(human)
func canonicalAddress(human string) ([]byte, uint64, error) {
bz, err := sdk.AccAddressFromBech32(human)
return bz, CostCanonical, err
}
var cosmwasmAPI = cosmwasm.GoAPI{

View File

@ -28,7 +28,7 @@ import (
// Rough timing have 88k gas at 90us, which is equal to 1k sdk gas... (one read)
//
// Please not that all gas prices returned to the wasmer engine should have this multiplied
var GasMultiplier = 100
var GasMultiplier uint64 = 100
// MaxGas for a contract is 10 billion wasmer gas (enforced in rust to prevent overflow)
// The limit for v0.9.3 is defined here: https://github.com/CosmWasm/cosmwasm/blob/v0.9.3/packages/vm/src/backends/singlepass.rs#L15-L23
@ -658,7 +658,7 @@ type MultipiedGasMeter struct {
originalMeter sdk.GasMeter
}
var _ wasmTypes.GasMeter = MultipiedGasMeter{}
var _ wasm.GasMeter = MultipiedGasMeter{}
func (m MultipiedGasMeter) GasConsumed() sdk.Gas {
return m.originalMeter.GasConsumed() * GasMultiplier

View File

@ -203,11 +203,11 @@ func NewEnv(ctx sdk.Context, creator sdk.AccAddress, deposit sdk.Coins, contract
ChainID: ctx.ChainID(),
},
Message: wasmTypes.MessageInfo{
Sender: wasmTypes.CanonicalAddress(creator),
Sender: creator.String(),
SentFunds: NewWasmCoins(deposit),
},
Contract: wasmTypes.ContractInfo{
Address: wasmTypes.CanonicalAddress(contractAddr),
Address: contractAddr.String(),
},
}
return env