From e81d1705e6c14cb21cc8084eec49f751613930fb Mon Sep 17 00:00:00 2001 From: Alex Peters Date: Thu, 21 Oct 2021 17:50:49 +0200 Subject: [PATCH 1/7] Introduce RawContractMessage type --- proto/cosmwasm/wasm/v1/ibc.proto | 2 +- proto/cosmwasm/wasm/v1/proposal.proto | 4 +- proto/cosmwasm/wasm/v1/query.proto | 2 +- proto/cosmwasm/wasm/v1/tx.proto | 6 +- proto/cosmwasm/wasm/v1/types.proto | 2 +- x/wasm/client/rest/gov.go | 4 +- x/wasm/keeper/handler_plugin_encoders_test.go | 3 +- x/wasm/keeper/keeper_test.go | 2 +- x/wasm/relay_pingpong_test.go | 2 +- x/wasm/relay_test.go | 2 +- x/wasm/types/ibc.pb.go | 41 +++-- x/wasm/types/proposal.go | 10 +- x/wasm/types/proposal.pb.go | 91 +++++------ x/wasm/types/proposal_test.go | 4 +- x/wasm/types/query.pb.go | 149 +++++++++-------- x/wasm/types/tx.go | 45 +++++- x/wasm/types/tx.pb.go | 101 ++++++------ x/wasm/types/tx_test.go | 39 +++++ x/wasm/types/types.pb.go | 152 +++++++++--------- 19 files changed, 363 insertions(+), 298 deletions(-) diff --git a/proto/cosmwasm/wasm/v1/ibc.proto b/proto/cosmwasm/wasm/v1/ibc.proto index 1b30d315c9..6fb6edf239 100644 --- a/proto/cosmwasm/wasm/v1/ibc.proto +++ b/proto/cosmwasm/wasm/v1/ibc.proto @@ -21,7 +21,7 @@ message MsgIBCSend { [ (gogoproto.moretags) = "yaml:\"timeout_timestamp\"" ]; // data is the payload to transfer - bytes data = 6 [ (gogoproto.casttype) = "encoding/json.RawMessage" ]; + bytes data = 6 [ (gogoproto.casttype) = "RawContractMessage" ]; } // MsgIBCCloseChannel port and channel need to be owned by the contract diff --git a/proto/cosmwasm/wasm/v1/proposal.proto b/proto/cosmwasm/wasm/v1/proposal.proto index 551894ad03..759124c0f8 100644 --- a/proto/cosmwasm/wasm/v1/proposal.proto +++ b/proto/cosmwasm/wasm/v1/proposal.proto @@ -42,7 +42,7 @@ message InstantiateContractProposal { // Label is optional metadata to be stored with a constract instance. string label = 6; // Msg json encoded message to be passed to the contract on instantiation - bytes msg = 7; + bytes msg = 7 [ (gogoproto.casttype) = "RawContractMessage" ]; // Funds coins that are transferred to the contract on instantiation repeated cosmos.base.v1beta1.Coin funds = 8 [ (gogoproto.nullable) = false, @@ -63,7 +63,7 @@ message MigrateContractProposal { // CodeID references the new WASM code uint64 code_id = 5 [ (gogoproto.customname) = "CodeID" ]; // Msg json encoded message to be passed to the contract on migration - bytes msg = 6; + bytes msg = 6 [ (gogoproto.casttype) = "RawContractMessage" ]; } // UpdateAdminProposal gov proposal content type to set an admin for a contract. diff --git a/proto/cosmwasm/wasm/v1/query.proto b/proto/cosmwasm/wasm/v1/query.proto index efeb19bdf4..633517114c 100644 --- a/proto/cosmwasm/wasm/v1/query.proto +++ b/proto/cosmwasm/wasm/v1/query.proto @@ -161,7 +161,7 @@ message QuerySmartContractStateRequest { // Query/SmartContractState RPC method message QuerySmartContractStateResponse { // Data contains the json data returned from the smart contract - bytes data = 1 [ (gogoproto.casttype) = "encoding/json.RawMessage" ]; + bytes data = 1 [ (gogoproto.casttype) = "RawContractMessage" ]; } // QueryCodeRequest is the request type for the Query/Code RPC method diff --git a/proto/cosmwasm/wasm/v1/tx.proto b/proto/cosmwasm/wasm/v1/tx.proto index 768b0a01aa..8295907eb8 100644 --- a/proto/cosmwasm/wasm/v1/tx.proto +++ b/proto/cosmwasm/wasm/v1/tx.proto @@ -55,7 +55,7 @@ message MsgInstantiateContract { // Label is optional metadata to be stored with a contract instance. string label = 4; // Msg json encoded message to be passed to the contract on instantiation - bytes msg = 5; + bytes msg = 5 [ (gogoproto.casttype) = "RawContractMessage" ]; // Funds coins that are transferred to the contract on instantiation repeated cosmos.base.v1beta1.Coin funds = 6 [ (gogoproto.nullable) = false, @@ -77,7 +77,7 @@ message MsgExecuteContract { // Contract is the address of the smart contract string contract = 2; // Msg json encoded message to be passed to the contract - bytes msg = 3; + bytes msg = 3 [ (gogoproto.casttype) = "RawContractMessage" ]; // Funds coins that are transferred to the contract on execution repeated cosmos.base.v1beta1.Coin funds = 5 [ (gogoproto.nullable) = false, @@ -100,7 +100,7 @@ message MsgMigrateContract { // CodeID references the new WASM code uint64 code_id = 3 [ (gogoproto.customname) = "CodeID" ]; // Msg json encoded message to be passed to the contract on migration - bytes msg = 4; + bytes msg = 4 [ (gogoproto.casttype) = "RawContractMessage" ]; } // MsgMigrateContractResponse returns contract migration result data. diff --git a/proto/cosmwasm/wasm/v1/types.proto b/proto/cosmwasm/wasm/v1/types.proto index 482593323a..7ee2f639ee 100644 --- a/proto/cosmwasm/wasm/v1/types.proto +++ b/proto/cosmwasm/wasm/v1/types.proto @@ -117,7 +117,7 @@ message ContractCodeHistoryEntry { uint64 code_id = 2 [ (gogoproto.customname) = "CodeID" ]; // Updated Tx position when the operation was executed. AbsoluteTxPosition updated = 3; - bytes msg = 4 [ (gogoproto.casttype) = "encoding/json.RawMessage" ]; + bytes msg = 4 [ (gogoproto.casttype) = "RawContractMessage" ]; } // AbsoluteTxPosition is a unique transaction position that allows for global diff --git a/x/wasm/client/rest/gov.go b/x/wasm/client/rest/gov.go index 9bc4d6098c..213c41a842 100644 --- a/x/wasm/client/rest/gov.go +++ b/x/wasm/client/rest/gov.go @@ -87,7 +87,7 @@ func (s InstantiateProposalJSONReq) Content() govtypes.Content { Admin: s.Admin, CodeID: s.Code, Label: s.Label, - Msg: s.Msg, + Msg: types.RawContractMessage(s.Msg), Funds: s.Funds, } } @@ -136,7 +136,7 @@ func (s MigrateProposalJSONReq) Content() govtypes.Content { Description: s.Description, Contract: s.Contract, CodeID: s.Code, - Msg: s.Msg, + Msg: types.RawContractMessage(s.Msg), RunAs: s.RunAs, } } diff --git a/x/wasm/keeper/handler_plugin_encoders_test.go b/x/wasm/keeper/handler_plugin_encoders_test.go index 67743171b8..518a7a9c3b 100644 --- a/x/wasm/keeper/handler_plugin_encoders_test.go +++ b/x/wasm/keeper/handler_plugin_encoders_test.go @@ -1,7 +1,6 @@ package keeper import ( - "encoding/json" "testing" codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -35,7 +34,7 @@ func TestEncoding(t *testing.T) { valAddr2 := make(sdk.ValAddress, sdk.AddrLen) valAddr2[1] = 123 - jsonMsg := json.RawMessage(`{"foo": 123}`) + jsonMsg := types.RawContractMessage(`{"foo": 123}`) bankMsg := &banktypes.MsgSend{ FromAddress: addr2.String(), diff --git a/x/wasm/keeper/keeper_test.go b/x/wasm/keeper/keeper_test.go index b205fb8589..18f1c00066 100644 --- a/x/wasm/keeper/keeper_test.go +++ b/x/wasm/keeper/keeper_test.go @@ -324,7 +324,7 @@ func TestInstantiate(t *testing.T) { Operation: types.ContractCodeHistoryOperationTypeInit, CodeID: codeID, Updated: types.NewAbsoluteTxPosition(ctx), - Msg: json.RawMessage(initMsgBz), + Msg: initMsgBz, }} assert.Equal(t, exp, keepers.WasmKeeper.GetContractHistory(ctx, gotContractAddr)) diff --git a/x/wasm/relay_pingpong_test.go b/x/wasm/relay_pingpong_test.go index a592815236..bf8381221c 100644 --- a/x/wasm/relay_pingpong_test.go +++ b/x/wasm/relay_pingpong_test.go @@ -369,7 +369,7 @@ type startGame struct { MaxValue uint64 `json:"max_value,omitempty"` } -func (g startGame) GetBytes() json.RawMessage { +func (g startGame) GetBytes() wasmtypes.RawContractMessage { b, err := json.Marshal(g) if err != nil { panic(err) diff --git a/x/wasm/relay_test.go b/x/wasm/relay_test.go index ecbdd6c260..f8f7d48305 100644 --- a/x/wasm/relay_test.go +++ b/x/wasm/relay_test.go @@ -397,7 +397,7 @@ type startTransfer struct { Timeout uint64 } -func (g startTransfer) GetBytes() json.RawMessage { +func (g startTransfer) GetBytes() types.RawContractMessage { b, err := json.Marshal(g) if err != nil { panic(err) diff --git a/x/wasm/types/ibc.pb.go b/x/wasm/types/ibc.pb.go index f9cf2f1bec..e47eed746c 100644 --- a/x/wasm/types/ibc.pb.go +++ b/x/wasm/types/ibc.pb.go @@ -4,7 +4,6 @@ package types import ( - encoding_json "encoding/json" fmt "fmt" io "io" math "math" @@ -36,7 +35,7 @@ type MsgIBCSend struct { // The timeout is disabled when set to 0. TimeoutTimestamp uint64 `protobuf:"varint,5,opt,name=timeout_timestamp,json=timeoutTimestamp,proto3" json:"timeout_timestamp,omitempty" yaml:"timeout_timestamp"` // data is the payload to transfer - Data encoding_json.RawMessage `protobuf:"bytes,6,opt,name=data,proto3,casttype=encoding/json.RawMessage" json:"data,omitempty"` + Data RawContractMessage `protobuf:"bytes,6,opt,name=data,proto3,casttype=RawContractMessage" json:"data,omitempty"` } func (m *MsgIBCSend) Reset() { *m = MsgIBCSend{} } @@ -118,28 +117,28 @@ func init() { func init() { proto.RegisterFile("cosmwasm/wasm/v1/ibc.proto", fileDescriptor_af0d1c43ea53c4b9) } var fileDescriptor_af0d1c43ea53c4b9 = []byte{ - // 329 bytes of a gzipped FileDescriptorProto + // 323 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4a, 0xce, 0x2f, 0xce, 0x2d, 0x4f, 0x2c, 0xce, 0xd5, 0x07, 0x13, 0x65, 0x86, 0xfa, 0x99, 0x49, 0xc9, 0x7a, 0x05, 0x45, 0xf9, 0x25, 0xf9, 0x42, 0x02, 0x30, 0x39, 0x3d, 0x30, 0x51, 0x66, 0x28, 0x25, 0x92, 0x9e, 0x9f, - 0x9e, 0x0f, 0x96, 0xd4, 0x07, 0xb1, 0x20, 0xea, 0x94, 0x1a, 0x98, 0xb8, 0xb8, 0x7c, 0x8b, 0xd3, - 0x3d, 0x9d, 0x9c, 0x83, 0x53, 0xf3, 0x52, 0x84, 0x8c, 0xb9, 0xd8, 0x93, 0x33, 0x12, 0xf3, 0xf2, - 0x52, 0x73, 0x24, 0x98, 0x14, 0x18, 0x35, 0x38, 0x9d, 0x24, 0x3f, 0xdd, 0x93, 0x17, 0xad, 0x4c, - 0xcc, 0xcd, 0xb1, 0x52, 0x2a, 0xce, 0x2f, 0x2d, 0x4a, 0x4e, 0x8d, 0x87, 0xca, 0x2b, 0x05, 0xc1, - 0x54, 0x0a, 0x39, 0x70, 0xf1, 0x95, 0x64, 0xe6, 0xa6, 0xe6, 0x97, 0x96, 0xc4, 0x67, 0xa4, 0x66, - 0xa6, 0x67, 0x94, 0x48, 0xb0, 0x28, 0x30, 0x6a, 0xb0, 0x20, 0xeb, 0x45, 0x95, 0x57, 0x0a, 0xe2, - 0x85, 0x0a, 0x78, 0x80, 0xf9, 0x42, 0x9e, 0x5c, 0x82, 0x30, 0x15, 0x20, 0xba, 0xb8, 0x24, 0x31, - 0xb7, 0x40, 0x82, 0x15, 0x6c, 0x88, 0xcc, 0xa7, 0x7b, 0xf2, 0x12, 0xa8, 0x86, 0xc0, 0x95, 0x28, - 0x05, 0x09, 0x40, 0xc5, 0x42, 0x60, 0x42, 0x42, 0x06, 0x5c, 0x2c, 0x29, 0x89, 0x25, 0x89, 0x12, - 0x6c, 0x0a, 0x8c, 0x1a, 0x3c, 0x4e, 0x32, 0xbf, 0xee, 0xc9, 0x4b, 0xa4, 0xe6, 0x25, 0xe7, 0xa7, - 0x64, 0xe6, 0xa5, 0xeb, 0x67, 0x15, 0xe7, 0xe7, 0xe9, 0x05, 0x25, 0x96, 0xfb, 0xa6, 0x16, 0x17, - 0x27, 0xa6, 0xa7, 0x06, 0x81, 0x55, 0x2a, 0x79, 0x72, 0x09, 0x41, 0x42, 0xc0, 0x39, 0x27, 0xbf, - 0x38, 0xd5, 0x19, 0xea, 0x29, 0x72, 0x42, 0xc2, 0xc9, 0xe5, 0xc4, 0x43, 0x39, 0x86, 0x13, 0x8f, - 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, - 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88,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x84, 0x84, 0xb4, 0xb8, 0x58, 0x52, 0x12, 0x4b, 0x12, 0x25, + 0xd8, 0x14, 0x18, 0x35, 0x78, 0x9c, 0xc4, 0x7e, 0xdd, 0x93, 0x17, 0x0a, 0x4a, 0x2c, 0x77, 0xce, + 0xcf, 0x2b, 0x29, 0x4a, 0x4c, 0x2e, 0xf1, 0x4d, 0x2d, 0x2e, 0x4e, 0x4c, 0x4f, 0x0d, 0x02, 0xab, + 0x51, 0xf2, 0xe4, 0x12, 0x82, 0xf8, 0xdd, 0x39, 0x27, 0xbf, 0x38, 0xd5, 0x19, 0xea, 0x1d, 0x72, + 0xc2, 0xc0, 0xc9, 0xe5, 0xc4, 0x43, 0x39, 0x86, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, + 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, + 0x63, 0x88, 0x52, 0x4b, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x77, 0xce, + 0x2f, 0xce, 0x0d, 0x87, 0x45, 0x5a, 0x8a, 0x7e, 0x05, 0x24, 0xf2, 0x4a, 0x2a, 0x0b, 0x52, 0x8b, + 0x93, 0xd8, 0xc0, 0x91, 0x62, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa6, 0xec, 0xf9, 0xda, + 0x01, 0x00, 0x00, } func (m *MsgIBCSend) Marshal() (dAtA []byte, err error) { diff --git a/x/wasm/types/proposal.go b/x/wasm/types/proposal.go index 66db4ea609..c3fc543ed9 100644 --- a/x/wasm/types/proposal.go +++ b/x/wasm/types/proposal.go @@ -2,7 +2,6 @@ package types import ( "encoding/base64" - "encoding/json" "fmt" "strings" @@ -172,10 +171,9 @@ func (p InstantiateContractProposal) ValidateBasic() error { return err } } - if !json.Valid(p.Msg) { - return sdkerrors.Wrap(ErrInvalid, "init msg json") + if err := p.Msg.ValidateBasic(); err != nil { + return sdkerrors.Wrap(err, "payload msg") } - return nil } @@ -242,8 +240,8 @@ func (p MigrateContractProposal) ValidateBasic() error { if _, err := sdk.AccAddressFromBech32(p.RunAs); err != nil { return sdkerrors.Wrap(err, "run as") } - if !json.Valid(p.Msg) { - return sdkerrors.Wrap(ErrInvalid, "migrate msg json") + if err := p.Msg.ValidateBasic(); err != nil { + return sdkerrors.Wrap(err, "payload msg") } return nil } diff --git a/x/wasm/types/proposal.pb.go b/x/wasm/types/proposal.pb.go index f1cbbd2b1e..53dd2c1fdf 100644 --- a/x/wasm/types/proposal.pb.go +++ b/x/wasm/types/proposal.pb.go @@ -89,7 +89,7 @@ type InstantiateContractProposal struct { // Label is optional metadata to be stored with a constract instance. Label string `protobuf:"bytes,6,opt,name=label,proto3" json:"label,omitempty"` // Msg json encoded message to be passed to the contract on instantiation - Msg []byte `protobuf:"bytes,7,opt,name=msg,proto3" json:"msg,omitempty"` + Msg RawContractMessage `protobuf:"bytes,7,opt,name=msg,proto3,casttype=RawContractMessage" json:"msg,omitempty"` // Funds coins that are transferred to the contract on instantiation Funds github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,8,rep,name=funds,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"funds"` } @@ -139,7 +139,7 @@ type MigrateContractProposal struct { // CodeID references the new WASM code CodeID uint64 `protobuf:"varint,5,opt,name=code_id,json=codeId,proto3" json:"code_id,omitempty"` // Msg json encoded message to be passed to the contract on migration - Msg []byte `protobuf:"bytes,6,opt,name=msg,proto3" json:"msg,omitempty"` + Msg RawContractMessage `protobuf:"bytes,6,opt,name=msg,proto3,casttype=RawContractMessage" json:"msg,omitempty"` } func (m *MigrateContractProposal) Reset() { *m = MigrateContractProposal{} } @@ -360,50 +360,51 @@ func init() { func init() { proto.RegisterFile("cosmwasm/wasm/v1/proposal.proto", fileDescriptor_be6422d717c730cb) } var fileDescriptor_be6422d717c730cb = []byte{ - // 681 bytes of a gzipped FileDescriptorProto + // 698 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x54, 0xcd, 0x6e, 0xd3, 0x4a, - 0x14, 0x8e, 0x9b, 0xc4, 0x49, 0xa7, 0xd1, 0xbd, 0xbe, 0xbe, 0x69, 0x6f, 0x6e, 0x41, 0x76, 0x64, - 0xa4, 0x2a, 0x1b, 0x6c, 0x52, 0x24, 0x04, 0xec, 0xe2, 0xb0, 0x69, 0x45, 0xa5, 0xca, 0x55, 0x55, - 0x89, 0x4d, 0x34, 0xb1, 0xa7, 0xe9, 0x88, 0x78, 0xc6, 0xf2, 0x4c, 0x5a, 0xf2, 0x16, 0x3c, 0x00, - 0x0f, 0x80, 0xd8, 0x20, 0xd8, 0xf2, 0x02, 0x5d, 0x76, 0xd9, 0x95, 0xa1, 0xe9, 0x1b, 0x64, 0x8f, - 0x84, 0x66, 0xc6, 0x09, 0x69, 0x41, 0x08, 0x89, 0x1f, 0x89, 0x8d, 0xed, 0xe3, 0xf3, 0x9d, 0xf9, - 0xbe, 0xf9, 0xce, 0x99, 0x01, 0x76, 0x48, 0x59, 0x7c, 0x02, 0x59, 0xec, 0xc9, 0xc7, 0x71, 0xdb, - 0x4b, 0x52, 0x9a, 0x50, 0x06, 0x87, 0x6e, 0x92, 0x52, 0x4e, 0x4d, 0x63, 0x06, 0x70, 0xe5, 0xe3, - 0xb8, 0xbd, 0x5e, 0x1f, 0xd0, 0x01, 0x95, 0x49, 0x4f, 0x7c, 0x29, 0xdc, 0xba, 0x25, 0x70, 0x94, - 0x79, 0x7d, 0xc8, 0x90, 0x77, 0xdc, 0xee, 0x23, 0x0e, 0xdb, 0x5e, 0x48, 0x31, 0xc9, 0xf3, 0x37, - 0xbf, 0x20, 0xe2, 0xe3, 0x04, 0x31, 0x95, 0x75, 0x3e, 0x6a, 0xe0, 0x9f, 0x3d, 0x4e, 0x53, 0xd4, - 0xa5, 0x11, 0xda, 0xcd, 0x15, 0x98, 0x75, 0x50, 0xe6, 0x98, 0x0f, 0x51, 0x43, 0x6b, 0x6a, 0xad, - 0xe5, 0x40, 0x05, 0x66, 0x13, 0xac, 0x44, 0x88, 0x85, 0x29, 0x4e, 0x38, 0xa6, 0xa4, 0xb1, 0x24, - 0x73, 0x8b, 0xbf, 0xcc, 0x55, 0xa0, 0xa7, 0x23, 0xd2, 0x83, 0xac, 0x51, 0x54, 0x85, 0xe9, 0x88, - 0x74, 0x98, 0x79, 0x0f, 0xfc, 0x25, 0xb8, 0x7b, 0xfd, 0x31, 0x47, 0xbd, 0x90, 0x46, 0xa8, 0x51, - 0x6a, 0x6a, 0xad, 0x9a, 0x6f, 0x4c, 0x32, 0xbb, 0x76, 0xd0, 0xd9, 0xdb, 0xf1, 0xc7, 0x5c, 0x0a, - 0x08, 0x6a, 0x02, 0x37, 0x8b, 0xcc, 0x7d, 0xb0, 0x86, 0x09, 0xe3, 0x90, 0x70, 0x0c, 0x39, 0xea, - 0x25, 0x28, 0x8d, 0x31, 0x63, 0x82, 0xbb, 0xd2, 0xd4, 0x5a, 0x2b, 0x9b, 0x96, 0x7b, 0xdd, 0x23, - 0xb7, 0x13, 0x86, 0x88, 0xb1, 0x2e, 0x25, 0x87, 0x78, 0x10, 0xac, 0x2e, 0x54, 0xef, 0xce, 0x8b, - 0xb7, 0x4b, 0xd5, 0xb2, 0xa1, 0x6f, 0x97, 0xaa, 0xba, 0x51, 0x71, 0xde, 0x2e, 0x81, 0x1b, 0x5b, - 0x9f, 0x51, 0x5d, 0x4a, 0x78, 0x0a, 0x43, 0xfe, 0xab, 0x9c, 0xa8, 0x83, 0x32, 0x8c, 0x62, 0x4c, - 0xa4, 0x01, 0xcb, 0x81, 0x0a, 0xcc, 0x5b, 0xa0, 0x22, 0x5c, 0xe9, 0xe1, 0xa8, 0x51, 0x6e, 0x6a, - 0xad, 0x92, 0x0f, 0x26, 0x99, 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 0xb1, 0x39, 0xd1, 0xc6, 0x15, - 0x22, 0xdf, 0x98, 0x66, 0x76, 0x4d, 0xed, 0x44, 0xfe, 0x76, 0x66, 0xd4, 0xf7, 0xbf, 0x42, 0xed, - 0xaf, 0x4d, 0x33, 0xdb, 0x54, 0xe8, 0x85, 0xa4, 0x73, 0x55, 0xd2, 0x03, 0x21, 0x49, 0xb6, 0x4d, - 0xf4, 0xba, 0xd8, 0x2a, 0xf9, 0xd6, 0x24, 0xb3, 0x2b, 0xaa, 0x6f, 0x6c, 0x9a, 0xd9, 0x7f, 0xab, - 0x15, 0x66, 0x20, 0x27, 0xa8, 0xa8, 0x5e, 0x32, 0xe7, 0x8d, 0x06, 0xcc, 0x7d, 0x92, 0xfc, 0x49, - 0x9a, 0xfd, 0xc7, 0xa7, 0x17, 0x56, 0xe1, 0xfc, 0xc2, 0x2a, 0xbc, 0x9c, 0x58, 0xda, 0xe9, 0xc4, - 0xd2, 0xce, 0x26, 0x96, 0xf6, 0x61, 0x62, 0x69, 0xcf, 0x2f, 0xad, 0xc2, 0xd9, 0xa5, 0x55, 0x38, - 0xbf, 0xb4, 0x0a, 0x4f, 0x36, 0x16, 0xce, 0x60, 0x97, 0xb2, 0xf8, 0x60, 0x76, 0x61, 0x47, 0xde, - 0x33, 0x75, 0x71, 0xcb, 0x73, 0xd8, 0xd7, 0xe5, 0xb5, 0x7d, 0xf7, 0x53, 0x00, 0x00, 0x00, 0xff, - 0xff, 0x74, 0x84, 0x77, 0xba, 0x3f, 0x06, 0x00, 0x00, + 0x14, 0x8e, 0x9b, 0xc4, 0x49, 0xa7, 0xd1, 0xbd, 0xb9, 0xbe, 0x69, 0x6f, 0x6e, 0x41, 0x76, 0x64, + 0xa4, 0xca, 0x1b, 0x6c, 0x52, 0x24, 0x04, 0xec, 0xe2, 0xb0, 0x69, 0x45, 0xa5, 0xca, 0x55, 0x55, + 0x89, 0x4d, 0x34, 0xb1, 0xa7, 0xa9, 0x45, 0x3c, 0x63, 0x79,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0x52, 0x4b, 0xb1, 0x6a, 0x6e, 0x3d, 0x4b, 0x8d, 0xda, 0x41, 0x67, 0x6f, 0xc7, 0x9d, 0x30, + 0x91, 0x80, 0x57, 0xe3, 0xb8, 0x99, 0xa5, 0xed, 0x83, 0xb5, 0x10, 0x53, 0x06, 0x31, 0x0b, 0x21, + 0x43, 0xbd, 0x18, 0x25, 0x51, 0x48, 0x29, 0xe7, 0xae, 0xb4, 0x14, 0x6b, 0x65, 0x53, 0xb7, 0xaf, + 0x6a, 0x64, 0x77, 0x7c, 0x1f, 0x51, 0xda, 0x25, 0xf8, 0x30, 0x1c, 0x78, 0xab, 0x0b, 0xd1, 0xbb, + 0xf3, 0xe0, 0xed, 0x52, 0xb5, 0x5c, 0x57, 0xb7, 0x4b, 0x55, 0xb5, 0x5e, 0x31, 0x5f, 0x2f, 0x81, + 0x6b, 0x5b, 0x9f, 0x50, 0x5d, 0x82, 0x59, 0x02, 0x7d, 0xf6, 0xab, 0x94, 0x68, 0x80, 0x32, 0x0c, + 0xa2, 0x10, 0x0b, 0x01, 0x96, 0x3d, 0x69, 0x68, 0x37, 0x40, 0x85, 0xab, 0xd2, 0x0b, 0x83, 0x66, + 0xb9, 0xa5, 0x58, 0x25, 0x17, 0x64, 0xa9, 0xa1, 0x72, 0x09, 0xb6, 0x1e, 0x78, 0x2a, 0x77, 0x6d, + 0x05, 0x3c, 0x74, 0x08, 0xfb, 0x68, 0xd8, 0x54, 0x65, 0xa8, 0x30, 0x34, 0x0b, 0x14, 0x23, 0x3a, + 0x10, 0x7a, 0xd4, 0xdc, 0xb5, 0xf7, 0xa9, 0xa1, 0x79, 0x70, 0x3c, 0xab, 0x62, 0x07, 0x51, 0x0a, + 0x07, 0xc8, 0xe3, 0x10, 0x0d, 0x82, 0xf2, 0xe1, 0x08, 0x07, 0xb4, 0x59, 0x6d, 0x15, 0xad, 0x95, + 0xcd, 0xff, 0x6d, 0x39, 0x37, 0x36, 0x9f, 0x1b, 0x3b, 0x9f, 0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x79, 0xc2, 0x0c, 0x64, 0x7a, 0x15, 0xd9, 0x63, 0x6a, 0xbe, 0x52, 0x80, 0xb6, 0x8f, 0xe3, + 0x3f, 0x29, 0x67, 0xf7, 0xe1, 0xc9, 0xb9, 0x5e, 0x38, 0x3b, 0xd7, 0x0b, 0xcf, 0x33, 0x5d, 0x39, + 0xc9, 0x74, 0xe5, 0x34, 0xd3, 0x95, 0x77, 0x99, 0xae, 0x3c, 0xbd, 0xd0, 0x0b, 0xa7, 0x17, 0x7a, + 0xe1, 0xec, 0x42, 0x2f, 0x3c, 0xda, 0x58, 0xb8, 0x9b, 0x5d, 0x42, 0xa3, 0x83, 0xd9, 0x03, 0x1f, + 0x38, 0x4f, 0xe4, 0x43, 0x2f, 0xee, 0x67, 0x5f, 0x15, 0xcf, 0xfc, 0xed, 0x8f, 0x01, 0x00, 0x00, + 0xff, 0xff, 0x9a, 0x01, 0xce, 0x1b, 0x6f, 0x06, 0x00, 0x00, } func (this *StoreCodeProposal) Equal(that interface{}) bool { diff --git a/x/wasm/types/proposal_test.go b/x/wasm/types/proposal_test.go index 0c8d392cfe..b9bd449563 100644 --- a/x/wasm/types/proposal_test.go +++ b/x/wasm/types/proposal_test.go @@ -703,7 +703,7 @@ func TestUnmarshalContentFromJson(t *testing.T) { "admin": "myAdminAddress", "code_id": 1, "funds": [{"denom": "ALX", "amount": "2"},{"denom": "BLX","amount": "3"}], - "msg": "e30=", + "msg": {}, "label": "testing", "run_as": "myRunAsAddress" }`, @@ -726,7 +726,7 @@ func TestUnmarshalContentFromJson(t *testing.T) { "description": "bar", "code_id": 1, "contract": "myContractAddr", - "msg": "e30=", + "msg": {}, "run_as": "myRunAsAddress" }`, got: &MigrateContractProposal{}, diff --git a/x/wasm/types/query.pb.go b/x/wasm/types/query.pb.go index 80f95cda8c..b069fe9d8f 100644 --- a/x/wasm/types/query.pb.go +++ b/x/wasm/types/query.pb.go @@ -6,7 +6,6 @@ package types import ( bytes "bytes" context "context" - encoding_json "encoding/json" fmt "fmt" io "io" math "math" @@ -491,7 +490,7 @@ var xxx_messageInfo_QuerySmartContractStateRequest proto.InternalMessageInfo // Query/SmartContractState RPC method type QuerySmartContractStateResponse struct { // Data contains the json data returned from the smart contract - Data encoding_json.RawMessage `protobuf:"bytes,1,opt,name=data,proto3,casttype=encoding/json.RawMessage" json:"data,omitempty"` + Data RawContractMessage `protobuf:"bytes,1,opt,name=data,proto3,casttype=RawContractMessage" json:"data,omitempty"` } func (m *QuerySmartContractStateResponse) Reset() { *m = QuerySmartContractStateResponse{} } @@ -829,79 +828,79 @@ func init() { func init() { proto.RegisterFile("cosmwasm/wasm/v1/query.proto", fileDescriptor_9677c207036b9f2b) } var fileDescriptor_9677c207036b9f2b = []byte{ - // 1149 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x97, 0xcf, 0x6f, 0x1b, 0x45, - 0x14, 0xc7, 0x3d, 0xa9, 0x13, 0xdb, 0x93, 0xa0, 0x9a, 0x11, 0x22, 0xc6, 0xa4, 0xbb, 0xd1, 0x52, - 0x85, 0x34, 0x0d, 0x3b, 0x49, 0x1a, 0x10, 0xe2, 0xc6, 0xa6, 0xd0, 0x24, 0x52, 0xa5, 0x76, 0x23, - 0x54, 0x01, 0x87, 0x68, 0xec, 0x9d, 0x3a, 0x8b, 0xec, 0x1d, 0x77, 0x67, 0x92, 0xd4, 0x8a, 0x02, - 0xa8, 0x12, 0x37, 0x04, 0x48, 0x88, 0x33, 0x1c, 0x50, 0x81, 0x23, 0xe2, 0x1f, 0xe0, 0x98, 0x63, - 0x24, 0x2e, 0x9c, 0x2c, 0x70, 0x38, 0xa0, 0xfc, 0x03, 0x48, 0x3d, 0xa1, 0x9d, 0x9d, 0x8d, 0xd7, - 0x3f, 0xd6, 0x76, 0x2b, 0xab, 0x97, 0x68, 0x37, 0xf3, 0xde, 0x9b, 0xcf, 0xfb, 0xee, 0x9b, 0xf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0x40, 0x16, 0x25, 0x88, 0x81, 0xe6, 0x87, - 0x95, 0x23, 0xf2, 0xe1, 0xa4, 0x6c, 0x7e, 0x68, 0x50, 0xdc, 0xa8, 0xfd, 0x16, 0xaf, 0x0e, 0x36, - 0x52, 0xbb, 0x6b, 0x72, 0xf7, 0x02, 0x7a, 0xb9, 0xff, 0xee, 0xe8, 0x4b, 0x00, 0xa7, 0x63, 0x7d, - 0x17, 0x5d, 0x4b, 0x88, 0xda, 0xdb, 0xff, 0x8b, 0x4b, 0xa3, 0x98, 0x2a, 0x8c, 0x05, 0x89, 0x31, - 0x8f, 0xb4, 0xfe, 0x18, 0x1c, 0xd7, 0xa5, 0x93, 0xb5, 0x79, 0xf2, 0xb7, 0x96, 0xfa, 0xb9, 0xa5, - 0xa5, 0x4e, 0x5a, 0x1a, 0x38, 0x6d, 0x69, 0xe0, 0xaf, 0x96, 0x06, 0xbe, 0x39, 0xd3, 0x52, 0xa7, - 0x67, 0x5a, 0xea, 0xcf, 0x33, 0x2d, 0xf5, 0xd1, 0x42, 0xec, 0xb6, 0xb1, 0xc1, 0x78, 0xed, 0x5e, - 0x14, 0xcb, 0xc1, 0x0f, 0xc3, 0x98, 0xf2, 0xc7, 0x6e, 0x69, 0x4a, 0xfe, 0x46, 0xbd, 0xf1, 0x7f, - 0x00, 0x00, 0x00, 0xff, 0xff, 0x47, 0xc6, 0xdb, 0xf0, 0x53, 0x0f, 0x00, 0x00, + // 1138 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x97, 0x4f, 0x6f, 0x1b, 0xc5, + 0x1b, 0xc7, 0x3d, 0xa9, 0xe3, 0x3f, 0x93, 0xfc, 0x54, 0xff, 0x46, 0xa8, 0x31, 0x26, 0xdd, 0x8d, + 0x96, 0x2a, 0xa4, 0x6e, 0xd8, 0xad, 0xd3, 0x80, 0x10, 0x37, 0x36, 0x85, 0x26, 0x91, 0x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+ 0x8b, 0x27, 0xe8, 0x67, 0x00, 0xd1, 0xf0, 0x08, 0x44, 0x37, 0x63, 0x76, 0x8f, 0x1d, 0xc4, 0x85, + 0xd2, 0x73, 0x78, 0x48, 0xe2, 0x37, 0x05, 0xf1, 0x4d, 0xa4, 0x8f, 0x95, 0xd4, 0xf7, 0xef, 0x67, + 0x6e, 0xc1, 0xa4, 0x28, 0x52, 0x2d, 0xb6, 0xea, 0x7a, 0x95, 0xf9, 0xea, 0x58, 0x1b, 0x09, 0xb2, + 0x26, 0x40, 0x34, 0xb4, 0x32, 0xa9, 0x1c, 0x91, 0x07, 0xe7, 0x45, 0xf3, 0x43, 0xe3, 0xe2, 0x86, + 0xed, 0xb7, 0x70, 0x6d, 0xbc, 0x91, 0xdc, 0x5d, 0x11, 0xbb, 0xe7, 0xd1, 0x95, 0xd1, 0xbb, 0xa3, + 0xcf, 0x01, 0x5c, 0x88, 0xf4, 0x5d, 0x74, 0x3d, 0x26, 0xea, 0x70, 0xff, 0x2f, 0x14, 0xa7, 0x31, + 0x95, 0x18, 0xab, 0x02, 0x63, 0x05, 0x29, 0xa3, 0x31, 0x98, 0xd1, 0x14, 0x4e, 0xe6, 0xf6, 0xe9, + 0x9f, 0x4a, 0xe2, 0xc7, 0x8e, 0x92, 0x38, 0xed, 0x28, 0xe0, 0xac, 0xa3, 0x80, 0x3f, 0x3a, 0x0a, + 0xf8, 0xea, 0x5c, 0x49, 0x9c, 0x9d, 0x2b, 0x89, 0xdf, 0xcf, 0x95, 0xc4, 0x87, 0xab, 0x91, 0xdb, + 0xc6, 0x16, 0x65, 0x8d, 0x07, 0x61, 0x2c, 0xdb, 0x78, 0x1c, 0xc4, 0x14, 0x3f, 0x73, 0xcb, 0x29, + 0xf1, 0xeb, 0xf4, 0xd6, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xae, 0x9b, 0x1a, 0x28, 0x4d, 0x0f, + 0x00, 0x00, } func (this *QueryContractInfoResponse) Equal(that interface{}) bool { diff --git a/x/wasm/types/tx.go b/x/wasm/types/tx.go index 2599eb42b5..519faa510a 100644 --- a/x/wasm/types/tx.go +++ b/x/wasm/types/tx.go @@ -2,12 +2,43 @@ package types import ( "encoding/json" + "errors" "strings" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) +// RawContractMessage defines a json message that is sent or returned by a wasm contract. +type RawContractMessage []byte + +func (r RawContractMessage) MarshalJSON() ([]byte, error) { + // copied from json.RawMessage#MarshalJSON + if r == nil { + return []byte("null"), nil + } + return r, nil +} + +func (a *RawContractMessage) UnmarshalJSON(b []byte) error { + // copied from json.RawMessage#UnmarshalJSON + if a == nil { + return errors.New("unmarshalJSON on nil pointer") + } + *a = append((*a)[0:0], b...) + return nil +} + +func (r *RawContractMessage) ValidateBasic() error { + if r == nil { + return ErrEmpty + } + if !json.Valid(*r) { + return ErrInvalid + } + return nil +} + func (msg MsgStoreCode) Route() string { return RouterKey } @@ -77,8 +108,8 @@ func (msg MsgInstantiateContract) ValidateBasic() error { return sdkerrors.Wrap(err, "admin") } } - if !json.Valid(msg.Msg) { - return sdkerrors.Wrap(ErrInvalid, "init msg json") + if err := msg.Msg.ValidateBasic(); err != nil { + return sdkerrors.Wrap(err, "payload msg") } return nil } @@ -94,7 +125,6 @@ func (msg MsgInstantiateContract) GetSigners() []sdk.AccAddress { panic(err.Error()) } return []sdk.AccAddress{senderAddr} - } func (msg MsgExecuteContract) Route() string { @@ -116,8 +146,8 @@ func (msg MsgExecuteContract) ValidateBasic() error { if !msg.Funds.IsValid() { return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, "sentFunds") } - if !json.Valid(msg.Msg) { - return sdkerrors.Wrap(ErrInvalid, "msg json") + if err := msg.Msg.ValidateBasic(); err != nil { + return sdkerrors.Wrap(err, "payload msg") } return nil } @@ -154,8 +184,9 @@ func (msg MsgMigrateContract) ValidateBasic() error { if _, err := sdk.AccAddressFromBech32(msg.Contract); err != nil { return sdkerrors.Wrap(err, "contract") } - if !json.Valid(msg.Msg) { - return sdkerrors.Wrap(ErrInvalid, "migrate msg json") + + if err := msg.Msg.ValidateBasic(); err != nil { + return sdkerrors.Wrap(err, "payload msg") } return nil diff --git a/x/wasm/types/tx.pb.go b/x/wasm/types/tx.pb.go index a3d5d127cd..4113f370b5 100644 --- a/x/wasm/types/tx.pb.go +++ b/x/wasm/types/tx.pb.go @@ -126,7 +126,7 @@ type MsgInstantiateContract struct { // Label is optional metadata to be stored with a contract instance. Label string `protobuf:"bytes,4,opt,name=label,proto3" json:"label,omitempty"` // Msg json encoded message to be passed to the contract on instantiation - Msg []byte `protobuf:"bytes,5,opt,name=msg,proto3" json:"msg,omitempty"` + Msg RawContractMessage `protobuf:"bytes,5,opt,name=msg,proto3,casttype=RawContractMessage" json:"msg,omitempty"` // Funds coins that are transferred to the contract on instantiation Funds github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,6,rep,name=funds,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"funds"` } @@ -212,7 +212,7 @@ type MsgExecuteContract struct { // Contract is the address of the smart contract Contract string `protobuf:"bytes,2,opt,name=contract,proto3" json:"contract,omitempty"` // Msg json encoded message to be passed to the contract - Msg []byte `protobuf:"bytes,3,opt,name=msg,proto3" json:"msg,omitempty"` + Msg RawContractMessage `protobuf:"bytes,3,opt,name=msg,proto3,casttype=RawContractMessage" json:"msg,omitempty"` // Funds coins that are transferred to the contract on execution Funds github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,5,rep,name=funds,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"funds"` } @@ -298,7 +298,7 @@ type MsgMigrateContract struct { // CodeID references the new WASM code CodeID uint64 `protobuf:"varint,3,opt,name=code_id,json=codeId,proto3" json:"code_id,omitempty"` // Msg json encoded message to be passed to the contract on migration - Msg []byte `protobuf:"bytes,4,opt,name=msg,proto3" json:"msg,omitempty"` + Msg RawContractMessage `protobuf:"bytes,4,opt,name=msg,proto3,casttype=RawContractMessage" json:"msg,omitempty"` } func (m *MsgMigrateContract) Reset() { *m = MsgMigrateContract{} } @@ -550,54 +550,55 @@ func init() { func init() { proto.RegisterFile("cosmwasm/wasm/v1/tx.proto", fileDescriptor_4f74d82755520264) } var fileDescriptor_4f74d82755520264 = []byte{ - // 741 bytes of a gzipped FileDescriptorProto + // 759 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0xcd, 0x6e, 0xd3, 0x4a, - 0x14, 0x8e, 0x6f, 0x9c, 0x34, 0x39, 0xcd, 0xed, 0x8d, 0x7c, 0xdb, 0x92, 0x1a, 0xe4, 0x44, 0x01, - 0x95, 0x2c, 0xc0, 0x6e, 0x8a, 0xc4, 0x86, 0x55, 0xe3, 0xb2, 0x68, 0x25, 0x23, 0xe4, 0xaa, 0x54, - 0xb0, 0x89, 0x26, 0xf6, 0xd4, 0x58, 0xd4, 0x9e, 0xe0, 0x99, 0xfe, 0xad, 0x78, 0x05, 0x9e, 0x83, - 0x77, 0x60, 0xc1, 0xae, 0x2b, 0xd4, 0x25, 0xab, 0x02, 0xe9, 0x3b, 0xb0, 0x46, 0x1e, 0xff, 0xd4, - 0x4d, 0x9d, 0x34, 0x12, 0x62, 0x63, 0xcf, 0xf1, 0x7c, 0xdf, 0xf9, 0xf9, 0xe6, 0xf8, 0x0c, 0xac, - 0x58, 0x84, 0x7a, 0xc7, 0x88, 0x7a, 0x1a, 0x7f, 0x1c, 0x75, 0x35, 0x76, 0xa2, 0x0e, 0x03, 0xc2, - 0x88, 0x54, 0x4f, 0xb6, 0x54, 0xfe, 0x38, 0xea, 0xca, 0x4a, 0xf8, 0x85, 0x50, 0x6d, 0x80, 0x28, - 0xd6, 0x8e, 0xba, 0x03, 0xcc, 0x50, 0x57, 0xb3, 0x88, 0xeb, 0x47, 0x0c, 0x79, 0xd1, 0x21, 0x0e, - 0xe1,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x22, 0xa6, 0xaa, - 0xc4, 0x29, 0x8f, 0x25, 0x30, 0x35, 0x65, 0x04, 0x0b, 0x06, 0x75, 0x76, 0x87, 0x36, 0x62, 0x78, - 0x83, 0xb7, 0xed, 0xa4, 0x74, 0xef, 0x42, 0xd5, 0xc7, 0xc7, 0xfd, 0x6c, 0xa3, 0x57, 0x7c, 0x7c, - 0x1c, 0x91, 0xb2, 0xb5, 0x14, 0xaf, 0xd7, 0xd2, 0x6e, 0xf0, 0xff, 0x29, 0x13, 0x22, 0x49, 0xa8, - 0xad, 0xc3, 0xbf, 0x06, 0x75, 0xf4, 0x03, 0x8c, 0x82, 0xe9, 0xb1, 0xa7, 0xb9, 0xbf, 0x03, 0x4b, - 0xd7, 0x9c, 0x24, 0xde, 0xd7, 0xbf, 0x8a, 0x50, 0x34, 0xa8, 0x23, 0xed, 0x40, 0xf5, 0x6a, 0x9a, - 0xe5, 0x4c, 0x97, 0xec, 0xa8, 0x90, 0x57, 0xa7, 0xef, 0xa7, 0x5a, 0xbe, 0x87, 0xff, 0xf3, 0x26, - 0x44, 0x27, 0x97, 0x9e, 0x83, 0x94, 0xd7, 0x66, 0x45, 0xa6, 0x21, 0x31, 0xfc, 0x37, 0xfe, 0x2f, - 0x3d, 0xc8, 0x75, 0x32, 0x86, 0x92, 0x1f, 0xcd, 0x82, 0xca, 0x86, 0x19, 0xef, 0xe0, 0xfc, 0x30, - 0x63, 0xa8, 0x09, 0x61, 0x26, 0x35, 0xe3, 0x6b, 0x98, 0xcf, 0x76, 0x5d, 0x2b, 0x97, 0x9c, 0x41, - 0xc8, 0x9d, 0xdb, 0x10, 0xa9, 0xeb, 0x57, 0x00, 0x99, 0x9e, 0x6a, 0xe6, 0xf2, 0xae, 0x00, 0xf2, - 0xc3, 0x5b, 0x00, 0x89, 0xdf, 0xde, 0xe6, 0xd9, 0x4f, 0xa5, 0x70, 0x36, 0x52, 0x84, 0xf3, 0x91, - 0x22, 0xfc, 0x18, 0x29, 0xc2, 0xc7, 0x4b, 0xa5, 0x70, 0x7e, 0xa9, 0x14, 0xbe, 0x5d, 0x2a, 0x85, - 0x37, 0xab, 0x99, 0xf9, 0xa2, 0x13, 0xea, 0xed, 0x25, 0x37, 0xac, 0xad, 0x9d, 0x44, 0x37, 0x2d, - 0x9f, 0x31, 0x83, 0x32, 0xbf, 0x67, 0x9f, 0xfc, 0x0e, 0x00, 0x00, 0xff, 0xff, 0xff, 0xe2, 0xe2, - 0x10, 0xea, 0x07, 0x00, 0x00, + 0x14, 0x8e, 0x1b, 0x27, 0x4d, 0x4e, 0x73, 0x7b, 0x23, 0xdf, 0x36, 0x37, 0xf5, 0xbd, 0x72, 0xa2, + 0x80, 0x8a, 0x17, 0x60, 0x37, 0x45, 0x62, 0xc3, 0xaa, 0x49, 0x59, 0xb4, 0x92, 0x11, 0x72, 0x55, + 0x2a, 0xd8, 0x44, 0x13, 0x7b, 0x6a, 0x2c, 0x1a, 0x4f, 0xf0, 0x71, 0x9b, 0xf6, 0x25, 0x10, 0x3b, + 0xde, 0x81, 0xb7, 0x60, 0xd7, 0x15, 0xea, 0x06, 0x89, 0x55, 0x80, 0xf4, 0x2d, 0x58, 0x21, 0xff, + 0xa5, 0x6e, 0xea, 0xa4, 0x41, 0x88, 0x4d, 0x32, 0xc7, 0xf3, 0x7d, 0xe7, 0xcc, 0xf9, 0xf4, 0xcd, + 0x19, 0x58, 0x33, 0x18, 0xf6, 0x06, 0x04, 0x7b, 0x6a, 0xf0, 0x73, 0xd2, 0x54, 0xbd, 0x53, 0xa5, + 0xef, 0x32, 0x8f, 0x09, 0xe5, 0x78, 0x4b, 0x09, 0x7e, 0x4e, 0x9a, 0xa2, 0xe4, 0x7f, 0x61, 0xa8, + 0x76, 0x09, 0x52, 0xf5, 0xa4, 0xd9, 0xa5, 0x1e, 0x69, 0xaa, 0x06, 0xb3, 0x9d, 0x90, 0x21, 0xae, + 0x58, 0xcc, 0x62, 0xc1, 0x52, 0xf5, 0x57, 0xd1, 0xd7, 0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, 0xe6, 0x7c, 0x24, 0x71, 0x17, + 0x23, 0x89, 0xfb, 0x36, 0x92, 0xb8, 0x77, 0x97, 0x52, 0xe6, 0xe2, 0x52, 0xca, 0x7c, 0xb9, 0x94, + 0x32, 0x2f, 0xd7, 0x13, 0x83, 0xa7, 0xcd, 0xb0, 0x77, 0x10, 0x3f, 0xd5, 0xa6, 0x7a, 0x1a, 0x3e, + 0xd9, 0xc1, 0xf0, 0xe9, 0xe6, 0x83, 0x07, 0xfb, 0xe1, 0xcf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x56, + 0xd2, 0x4b, 0x17, 0x33, 0x08, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/wasm/types/tx_test.go b/x/wasm/types/tx_test.go index 1b901a4f5e..01b878a592 100644 --- a/x/wasm/types/tx_test.go +++ b/x/wasm/types/tx_test.go @@ -501,3 +501,42 @@ func TestMsgMigrateContract(t *testing.T) { }) } } + +func TestMsgJsonSignBytes(t *testing.T) { + const myInnerMsg = `{"foo":"bar"}` + specs := map[string]struct { + src sdk.Msg + exp string + }{ + "MsgInstantiateContract": { + src: &MsgInstantiateContract{Msg: RawContractMessage(myInnerMsg)}, + exp: ` +{ + "type":"wasm/MsgInstantiateContract", + "value": {"msg": {"foo":"bar"}, "funds":[]} +}`, + }, + "MsgExecuteContract": { + src: &MsgExecuteContract{Msg: RawContractMessage(myInnerMsg)}, + exp: ` +{ + "type":"wasm/MsgExecuteContract", + "value": {"msg": {"foo":"bar"}, "funds":[]} +}`, + }, + "MsgMigrateContract": { + src: &MsgMigrateContract{Msg: RawContractMessage(myInnerMsg)}, + exp: ` +{ + "type":"wasm/MsgMigrateContract", + "value": {"msg": {"foo":"bar"}} +}`, + }, + } + for name, spec := range specs { + t.Run(name, func(t *testing.T) { + bz := spec.src.GetSignBytes() + assert.JSONEq(t, spec.exp, string(bz), "raw: %s", string(bz)) + }) + } +} diff --git a/x/wasm/types/types.pb.go b/x/wasm/types/types.pb.go index 94bc80d613..4adacd95e9 100644 --- a/x/wasm/types/types.pb.go +++ b/x/wasm/types/types.pb.go @@ -5,7 +5,6 @@ package types import ( bytes "bytes" - encoding_json "encoding/json" fmt "fmt" io "io" math "math" @@ -315,8 +314,8 @@ type ContractCodeHistoryEntry struct { // CodeID is the reference to the stored WASM code CodeID uint64 `protobuf:"varint,2,opt,name=code_id,json=codeId,proto3" json:"code_id,omitempty"` // Updated Tx position when the operation was executed. - Updated *AbsoluteTxPosition `protobuf:"bytes,3,opt,name=updated,proto3" json:"updated,omitempty"` - Msg encoding_json.RawMessage `protobuf:"bytes,4,opt,name=msg,proto3,casttype=encoding/json.RawMessage" json:"msg,omitempty"` + Updated *AbsoluteTxPosition `protobuf:"bytes,3,opt,name=updated,proto3" json:"updated,omitempty"` + Msg RawContractMessage `protobuf:"bytes,4,opt,name=msg,proto3,casttype=RawContractMessage" json:"msg,omitempty"` } func (m *ContractCodeHistoryEntry) Reset() { *m = ContractCodeHistoryEntry{} } @@ -452,81 +451,80 @@ func init() { func init() { proto.RegisterFile("cosmwasm/wasm/v1/types.proto", fileDescriptor_e6155d98fa173e02) } var fileDescriptor_e6155d98fa173e02 = []byte{ - // 1173 bytes of a gzipped FileDescriptorProto + // 1164 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x56, 0xcb, 0x6f, 0x1b, 0xc5, - 0x1f, 0xf7, 0xda, 0xce, 0xc3, 0xd3, 0xfc, 0x5a, 0x77, 0x7e, 0x89, 0xea, 0x98, 0x60, 0xbb, 0x4b, - 0x81, 0xf4, 0x65, 0xd3, 0x80, 0x00, 0xf5, 0x50, 0xc9, 0x8f, 0xa5, 0xd9, 0x88, 0xd8, 0xd6, 0xd8, - 0xa5, 0x0a, 0x52, 0xb5, 0x1a, 0xef, 0x4e, 0x9c, 0xa1, 0xde, 0x1d, 0x6b, 0x67, 0x9c, 0x7a, 0x7b, - 0xe3, 0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, 0x29, 0x32, 0x14, 0xc4, 0x93, 0x77, 0x6b, 0x41, 0x06, 0x5c, 0x2e, 0xaa, - 0xad, 0x50, 0x9c, 0x6c, 0x85, 0x62, 0xd9, 0x0b, 0x2a, 0xab, 0xbf, 0xfd, 0x72, 0x73, 0x25, 0xda, - 0x14, 0x63, 0x02, 0x43, 0x53, 0x86, 0xdb, 0xc9, 0xbf, 0xc3, 0x27, 0xf4, 0x65, 0x1c, 0x64, 0x26, - 0xae, 0x61, 0x93, 0x36, 0x29, 0x17, 0xcc, 0x0f, 0x0c, 0x4f, 0xf8, 0x01, 0x6c, 0x82, 0x14, 0xeb, - 0x13, 0x1f, 0x8b, 0xe9, 0x3b, 0xdf, 0x38, 0x59, 0xe2, 0x29, 0xf0, 0xc6, 0x04, 0x15, 0xde, 0x71, - 0x34, 0x25, 0x89, 0x4e, 0x27, 0xfe, 0xca, 0xe9, 0xdc, 0x01, 0x0b, 0x83, 0xbe, 0x23, 0xfb, 0x9a, - 0xf8, 0x2f, 0x7d, 0x1d, 0x83, 0x60, 0x11, 0x24, 0x5c, 0xde, 0x95, 0xb3, 0x5a, 0xaa, 0xac, 0xbd, - 0x18, 0xe5, 0x33, 0xc4, 0xb3, 0x99, 0x43, 0xbd, 0x6e, 0xe9, 0x0b, 0xce, 0xbc, 0x22, 0xc2, 0x8f, - 0xb6, 0x09, 0xe7, 0xb8, 0x4b, 0x50, 0xe8, 0xa8, 0x23, 0x00, 0x4f, 0xd2, 0xc1, 0xcb, 0x60, 0xa9, - 0xd3, 0x63, 0xf6, 0x43, 0x6b, 0x8f, 0xd0, 0xee, 0x9e, 0x50, 0xb7, 0x09, 0x9d, 0x93, 0xba, 0x4d, - 0xa9, 0x82, 0xab, 0x60, 0x51, 0x0c, 0x2d, 0xea, 0x39, 0x64, 0xa8, 0xca, 0x41, 0x0b, 0x62, 0x68, - 0x86, 0xa2, 0x4e, 0xc1, 0xdc, 0x36, 0x73, 0x48, 0x0f, 0x6e, 0x81, 0xc4, 0x43, 0x12, 0xa8, 0x27, - 0x53, 0xf9, 0xf8, 0xc5, 0x28, 0xff, 0x41, 0x97, 0x8a, 0xbd, 0x41, 0xa7, 0x68, 0x33, 0xb7, 0x24, - 0x88, 0xe7, 0x84, 0x4f, 0xd8, 0x13, 0xd1, 0x63, 0x8f, 0x76, 0x78, 0xa9, 0x13, 0x08, 0xc2, 0x8b, - 0x9b, 0x64, 0x58, 0x09, 0x0f, 0x28, 0x24, 0x09, 0xaf, 0xa1, 0xda, 0xea, 0x71, 0xf9, 0x00, 0x95, - 0x70, 0xed, 0x1f, 0x0d, 0x80, 0xe9, 0x46, 0x81, 0x1f, 0x82, 0x4b, 0xe5, 0x6a, 0xd5, 0x68, 0xb5, - 0xac, 0xf6, 0x4e, 0xd3, 0xb0, 0xee, 0xd5, 0x5b, 0x4d, 0xa3, 0x6a, 0x7e, 0x62, 0x1a, 0xb5, 0x74, - 0x2c, 0xbb, 0x7a, 0x70, 0x58, 0x58, 0x99, 0x3a, 0xdf, 0xf3, 0x78, 0x9f, 0xd8, 0x74, 0x97, 0x12, - 0x07, 0xde, 0x00, 0x30, 0x8a, 0xab, 0x37, 0x2a, 0x8d, 0xda, 0x4e, 0x5a, 0xcb, 0x2e, 0x1f, 0x1c, - 0x16, 0xd2, 0x53, 0x48, 0x9d, 0x75, 0x98, 0x13, 0xc0, 0x8f, 0x40, 0x26, 0xea, 0xdd, 0xa8, 0x7f, - 0xba, 0x63, 0x95, 0x6b, 0x35, 0x64, 0xb4, 0x5a, 0xe9, 0xf8, 0xcb, 0x61, 0x1a, 0x5e, 0x2f, 0x28, - 0xab, 0xcd, 0x0d, 0x37, 0xc0, 0x4a, 0x14, 0x68, 0x7c, 0x66, 0xa0, 0x1d, 0x19, 0x29, 0x91, 0xbd, - 0x74, 0x70, 0x58, 0xf8, 0xff, 0x14, 0x65, 0xec, 0x13, 0x3f, 0x08, 0x83, 0x65, 0x17, 0xbf, 0xfa, - 0x31, 0x17, 0x7b, 0xf2, 0x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0xcc, 0x42, 0x9c, 0xe3, 0x8a, 0x2e, + 0xbf, 0xa4, 0xa2, 0x1e, 0x67, 0xee, 0x50, 0x90, 0xee, 0xa8, 0xcd, 0x38, 0x15, 0x94, 0xf9, 0x68, + 0x02, 0x82, 0x37, 0xc0, 0x19, 0xda, 0xb3, 0xad, 0x01, 0x0b, 0x44, 0x94, 0xee, 0xbc, 0xbc, 0xf6, + 0xff, 0x3b, 0x1c, 0x17, 0x33, 0x66, 0xad, 0xde, 0x66, 0x81, 0x30, 0x1b, 0x28, 0x43, 0x7b, 0xb6, + 0x3c, 0x3a, 0x70, 0x0b, 0x64, 0xc8, 0x48, 0x10, 0x5f, 0xde, 0xad, 0x05, 0x19, 0x70, 0xb9, 0xac, + 0xb6, 0x42, 0x79, 0xb2, 0x15, 0xca, 0x55, 0x3f, 0xac, 0xad, 0xfe, 0xfa, 0xf3, 0x8d, 0x95, 0x78, + 0x53, 0x8c, 0x09, 0x0c, 0x4d, 0x19, 0x6e, 0xa5, 0xff, 0x8a, 0x9e, 0xd0, 0x3f, 0x1a, 0xc8, 0x4d, + 0x5c, 0xa3, 0x26, 0x6d, 0x50, 0x2e, 0x58, 0x10, 0x1a, 0xbe, 0x08, 0x42, 0xd8, 0x06, 0x19, 0x36, + 0x20, 0x01, 0x16, 0xd3, 0x77, 0xbe, 0x7e, 0xb2, 0xc4, 0x97, 0xc0, 0x5b, 0x13, 0x54, 0x74, 0xc7, + 0xd1, 0x94, 0x24, 0x3e, 0x9d, 0xe4, 0x2b, 0xa7, 0x73, 0x1b, 0x2c, 0x0c, 0x07, 0x8e, 0xec, 0x6b, + 0xea, 0xbf, 0xf4, 0xf5, 0x18, 0x04, 0xd7, 0x40, 0xca, 0xe3, 0x7d, 0x39, 0xab, 0xa5, 0xda, 0x1b, + 0xcf, 0xc7, 0x45, 0x88, 0xf0, 0xc3, 0x49, 0x96, 0x5b, 0x84, 0x73, 0xdc, 0x27, 0x28, 0x72, 0xd1, + 0x11, 0x80, 0x27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x72, 0x58, + 0xd0, 0x9e, 0x1e, 0x16, 0xb4, 0x3f, 0x0e, 0x0b, 0xda, 0xd7, 0xcf, 0x0a, 0x89, 0xa7, 0xcf, 0x0a, + 0x89, 0xdf, 0x9e, 0x15, 0x12, 0x5f, 0xbc, 0x1b, 0x7b, 0x07, 0x75, 0xc6, 0xbd, 0x7b, 0x93, 0xdf, + 0x26, 0xa7, 0x32, 0x52, 0xbf, 0x4f, 0xf2, 0xdf, 0xa9, 0x37, 0x2f, 0xb7, 0xda, 0x07, 0xff, 0x06, + 0x00, 0x00, 0xff, 0xff, 0x18, 0x23, 0xa5, 0x9f, 0x5c, 0x09, 0x00, 0x00, } func (this *AccessTypeParam) Equal(that interface{}) bool { From c6319b641e228e9e5a801fa534fd0e6b3cd73b9e Mon Sep 17 00:00:00 2001 From: Alex Peters Date: Fri, 22 Oct 2021 11:26:04 +0200 Subject: [PATCH 2/7] Add json signbytes test for proposals --- x/wasm/types/proposal_test.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/x/wasm/types/proposal_test.go b/x/wasm/types/proposal_test.go index b9bd449563..8e2aed8f2a 100644 --- a/x/wasm/types/proposal_test.go +++ b/x/wasm/types/proposal_test.go @@ -746,5 +746,38 @@ func TestUnmarshalContentFromJson(t *testing.T) { assert.Equal(t, spec.exp, spec.got) }) } +} + +func TestProposalJsonSignBytes(t *testing.T) { + const myInnerMsg = `{"foo":"bar"}` + specs := map[string]struct { + src govtypes.Content + exp string + }{ + "instantiate contract": { + src: &InstantiateContractProposal{Msg: RawContractMessage(myInnerMsg)}, + exp: ` +{ + "type":"cosmos-sdk/MsgSubmitProposal", + "value":{"content":{"type":"wasm/InstantiateContractProposal","value":{"funds":[],"msg":{"foo":"bar"}}},"initial_deposit":[]} +}`, + }, + "migrate contract": { + src: &MigrateContractProposal{Msg: RawContractMessage(myInnerMsg)}, + exp: ` +{ + "type":"cosmos-sdk/MsgSubmitProposal", + "value":{"content":{"type":"wasm/MigrateContractProposal","value":{"msg":{"foo":"bar"}}},"initial_deposit":[]} +}`, + }, + } + for name, spec := range specs { + t.Run(name, func(t *testing.T) { + msg, err := govtypes.NewMsgSubmitProposal(spec.src, sdk.NewCoins(), []byte{}) + require.NoError(t, err) + bz := msg.GetSignBytes() + assert.JSONEq(t, spec.exp, string(bz), "raw: %s", string(bz)) + }) + } } From 0f5a28a055d98205d8fe8856acd24fdf982c1c7e Mon Sep 17 00:00:00 2001 From: Alex Peters Date: Fri, 22 Oct 2021 12:12:51 +0200 Subject: [PATCH 3/7] No assumptions on MsgIBCSend.data content --- docs/proto/proto-docs.md | 2 +- proto/cosmwasm/wasm/v1/ibc.proto | 5 +++-- x/wasm/types/ibc.pb.go | 27 +++++++++++++-------------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/docs/proto/proto-docs.md b/docs/proto/proto-docs.md index 4202e6cf6e..e9ea878143 100644 --- a/docs/proto/proto-docs.md +++ b/docs/proto/proto-docs.md @@ -617,7 +617,7 @@ MsgIBCSend | `channel` | [string](#string) | | the channel by which the packet will be sent | | `timeout_height` | [uint64](#uint64) | | Timeout height relative to the current block height. The timeout is disabled when set to 0. | | `timeout_timestamp` | [uint64](#uint64) | | Timeout timestamp (in nanoseconds) relative to the current block timestamp. The timeout is disabled when set to 0. | -| `data` | [bytes](#bytes) | | data is the payload to transfer | +| `data` | [bytes](#bytes) | | Data is the payload to transfer. We must not make assumption what format or content is in here. | diff --git a/proto/cosmwasm/wasm/v1/ibc.proto b/proto/cosmwasm/wasm/v1/ibc.proto index 6fb6edf239..d880a7078f 100644 --- a/proto/cosmwasm/wasm/v1/ibc.proto +++ b/proto/cosmwasm/wasm/v1/ibc.proto @@ -20,8 +20,9 @@ message MsgIBCSend { uint64 timeout_timestamp = 5 [ (gogoproto.moretags) = "yaml:\"timeout_timestamp\"" ]; - // data is the payload to transfer - bytes data = 6 [ (gogoproto.casttype) = "RawContractMessage" ]; + // Data is the payload to transfer. We must not make assumption what format or + // content is in here. + bytes data = 6; } // MsgIBCCloseChannel port and channel need to be owned by the contract diff --git a/x/wasm/types/ibc.pb.go b/x/wasm/types/ibc.pb.go index e47eed746c..d9f4a3809a 100644 --- a/x/wasm/types/ibc.pb.go +++ b/x/wasm/types/ibc.pb.go @@ -34,8 +34,9 @@ type MsgIBCSend struct { // Timeout timestamp (in nanoseconds) relative to the current block timestamp. // The timeout is disabled when set to 0. TimeoutTimestamp uint64 `protobuf:"varint,5,opt,name=timeout_timestamp,json=timeoutTimestamp,proto3" json:"timeout_timestamp,omitempty" yaml:"timeout_timestamp"` - // data is the payload to transfer - Data RawContractMessage `protobuf:"bytes,6,opt,name=data,proto3,casttype=RawContractMessage" json:"data,omitempty"` + // Data is the payload to transfer. We must not make assumption what format or + // content is in here. + Data []byte `protobuf:"bytes,6,opt,name=data,proto3" json:"data,omitempty"` } func (m *MsgIBCSend) Reset() { *m = MsgIBCSend{} } @@ -117,11 +118,11 @@ func init() { func init() { proto.RegisterFile("cosmwasm/wasm/v1/ibc.proto", fileDescriptor_af0d1c43ea53c4b9) } var fileDescriptor_af0d1c43ea53c4b9 = []byte{ - // 323 bytes of a gzipped FileDescriptorProto + // 299 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4a, 0xce, 0x2f, 0xce, 0x2d, 0x4f, 0x2c, 0xce, 0xd5, 0x07, 0x13, 0x65, 0x86, 0xfa, 0x99, 0x49, 0xc9, 0x7a, 0x05, 0x45, 0xf9, 0x25, 0xf9, 0x42, 0x02, 0x30, 0x39, 0x3d, 0x30, 0x51, 0x66, 0x28, 0x25, 0x92, 0x9e, 0x9f, - 0x9e, 0x0f, 0x96, 0xd4, 0x07, 0xb1, 0x20, 0xea, 0x94, 0x7e, 0x31, 0x72, 0x71, 0xf9, 0x16, 0xa7, + 0x9e, 0x0f, 0x96, 0xd4, 0x07, 0xb1, 0x20, 0xea, 0x94, 0x1e, 0x31, 0x72, 0x71, 0xf9, 0x16, 0xa7, 0x7b, 0x3a, 0x39, 0x07, 0xa7, 0xe6, 0xa5, 0x08, 0x19, 0x73, 0xb1, 0x27, 0x67, 0x24, 0xe6, 0xe5, 0xa5, 0xe6, 0x48, 0x30, 0x29, 0x30, 0x6a, 0x70, 0x3a, 0x49, 0x7e, 0xba, 0x27, 0x2f, 0x5a, 0x99, 0x98, 0x9b, 0x63, 0xa5, 0x54, 0x9c, 0x5f, 0x5a, 0x94, 0x9c, 0x1a, 0x0f, 0x95, 0x57, 0x0a, 0x82, @@ -129,16 +130,14 @@ var fileDescriptor_af0d1c43ea53c4b9 = []byte{ 0x4c, 0xcf, 0x28, 0x91, 0x60, 0x51, 0x60, 0xd4, 0x60, 0x41, 0xd6, 0x8b, 0x2a, 0xaf, 0x14, 0xc4, 0x0b, 0x15, 0xf0, 0x00, 0xf3, 0x85, 0x3c, 0xb9, 0x04, 0x61, 0x2a, 0x40, 0x74, 0x71, 0x49, 0x62, 0x6e, 0x81, 0x04, 0x2b, 0xd8, 0x10, 0x99, 0x4f, 0xf7, 0xe4, 0x25, 0x50, 0x0d, 0x81, 0x2b, 0x51, - 0x0a, 0x12, 0x80, 0x8a, 0x85, 0xc0, 0x84, 0x84, 0xb4, 0xb8, 0x58, 0x52, 0x12, 0x4b, 0x12, 0x25, - 0xd8, 0x14, 0x18, 0x35, 0x78, 0x9c, 0xc4, 0x7e, 0xdd, 0x93, 0x17, 0x0a, 0x4a, 0x2c, 0x77, 0xce, - 0xcf, 0x2b, 0x29, 0x4a, 0x4c, 0x2e, 0xf1, 0x4d, 0x2d, 0x2e, 0x4e, 0x4c, 0x4f, 0x0d, 0x02, 0xab, - 0x51, 0xf2, 0xe4, 0x12, 0x82, 0xf8, 0xdd, 0x39, 0x27, 0xbf, 0x38, 0xd5, 0x19, 0xea, 0x1d, 0x72, - 0xc2, 0xc0, 0xc9, 0xe5, 0xc4, 0x43, 0x39, 0x86, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, - 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, - 0x63, 0x88, 0x52, 0x4b, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x77, 0xce, - 0x2f, 0xce, 0x0d, 0x87, 0x45, 0x5a, 0x8a, 0x7e, 0x05, 0x24, 0xf2, 0x4a, 0x2a, 0x0b, 0x52, 0x8b, - 0x93, 0xd8, 0xc0, 0x91, 0x62, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa6, 0xec, 0xf9, 0xda, - 0x01, 0x00, 0x00, + 0x0a, 0x12, 0x80, 0x8a, 0x85, 0xc0, 0x84, 0x84, 0x84, 0xb8, 0x58, 0x52, 0x12, 0x4b, 0x12, 0x25, + 0xd8, 0x14, 0x18, 0x35, 0x78, 0x82, 0xc0, 0x6c, 0x25, 0x4f, 0x2e, 0x21, 0x88, 0x1f, 0x9d, 0x73, + 0xf2, 0x8b, 0x53, 0x9d, 0xa1, 0xce, 0x26, 0xc7, 0xaf, 0x4e, 0x2e, 0x27, 0x1e, 0xca, 0x31, 0x9c, + 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, + 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x5a, 0x7a, 0x66, 0x49, 0x46, 0x69, + 0x92, 0x5e, 0x72, 0x7e, 0xae, 0xbe, 0x73, 0x7e, 0x71, 0x6e, 0x38, 0x2c, 0x72, 0x52, 0xf4, 0x2b, + 0x20, 0x91, 0x54, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x0e, 0x7c, 0x63, 0x40, 0x00, 0x00, + 0x00, 0xff, 0xff, 0x4d, 0x60, 0x95, 0x31, 0xc2, 0x01, 0x00, 0x00, } func (m *MsgIBCSend) Marshal() (dAtA []byte, err error) { From 073a94675fb78c53f49da58948694c114b38fde2 Mon Sep 17 00:00:00 2001 From: Alex Peters Date: Fri, 22 Oct 2021 13:31:00 +0200 Subject: [PATCH 4/7] Smart query uses RawContractMessage --- proto/cosmwasm/wasm/v1/query.proto | 2 +- x/wasm/keeper/keeper.go | 2 +- x/wasm/keeper/legacy_querier.go | 20 ++-- x/wasm/keeper/legacy_querier_test.go | 9 +- x/wasm/keeper/querier.go | 3 + x/wasm/keeper/querier_test.go | 13 ++- x/wasm/keeper/query_plugins.go | 8 +- x/wasm/keeper/query_plugins_test.go | 4 +- x/wasm/types/exported_keepers.go | 2 +- x/wasm/types/query.pb.go | 148 +++++++++++++-------------- x/wasm/types/tx.go | 11 +- 11 files changed, 121 insertions(+), 101 deletions(-) diff --git a/proto/cosmwasm/wasm/v1/query.proto b/proto/cosmwasm/wasm/v1/query.proto index 633517114c..dbe7c0fbc4 100644 --- a/proto/cosmwasm/wasm/v1/query.proto +++ b/proto/cosmwasm/wasm/v1/query.proto @@ -154,7 +154,7 @@ message QuerySmartContractStateRequest { // address is the address of the contract string address = 1; // QueryData contains the query data passed to the contract - bytes query_data = 2; + bytes query_data = 2 [ (gogoproto.casttype) = "RawContractMessage" ]; } // QuerySmartContractStateResponse is the response type for the diff --git a/x/wasm/keeper/keeper.go b/x/wasm/keeper/keeper.go index 9c1cdc2c50..420140de1e 100644 --- a/x/wasm/keeper/keeper.go +++ b/x/wasm/keeper/keeper.go @@ -586,7 +586,7 @@ func (k Keeper) getLastContractHistoryEntry(ctx sdk.Context, contractAddr sdk.Ac } // QuerySmart queries the smart contract itself. -func (k Keeper) QuerySmart(ctx sdk.Context, contractAddr sdk.AccAddress, req []byte) ([]byte, error) { +func (k Keeper) QuerySmart(ctx sdk.Context, contractAddr sdk.AccAddress, req types.RawContractMessage) (types.RawContractMessage, error) { defer telemetry.MeasureSince(time.Now(), "wasm", "contract", "query-smart") contractInfo, codeInfo, prefixStore, err := k.contractInstance(ctx, contractAddr) if err != nil { diff --git a/x/wasm/keeper/legacy_querier.go b/x/wasm/keeper/legacy_querier.go index 4c1ba4d8ee..21ae450fe3 100644 --- a/x/wasm/keeper/legacy_querier.go +++ b/x/wasm/keeper/legacy_querier.go @@ -89,9 +89,9 @@ func queryContractState(ctx sdk.Context, bech, queryMethod string, data []byte, return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, bech) } - var resultData []types.Model switch queryMethod { case QueryMethodContractStateAll: + resultData := make([]types.Model, 0) // this returns a serialized json object (which internally encoded binary fields properly) for iter := keeper.GetContractState(ctx, contractAddr); iter.Valid(); iter.Next() { resultData = append(resultData, types.Model{ @@ -99,25 +99,27 @@ func queryContractState(ctx sdk.Context, bech, queryMethod string, data []byte, Value: iter.Value(), }) } - if resultData == nil { - resultData = make([]types.Model, 0) + bz, err := json.Marshal(resultData) + if err != nil { + return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) } + return bz, nil case QueryMethodContractStateRaw: // this returns the raw data from the state, base64-encoded return keeper.QueryRaw(ctx, contractAddr, data), nil case QueryMethodContractStateSmart: // we enforce a subjective gas limit on all queries to avoid infinite loops ctx = ctx.WithGasMeter(sdk.NewGasMeter(gasLimit)) + msg := types.RawContractMessage(data) + if err := msg.ValidateBasic(); err != nil { + return nil, sdkerrors.Wrap(err, "json msg") + } // this returns raw bytes (must be base64-encoded) - return keeper.QuerySmart(ctx, contractAddr, data) + bz, err := keeper.QuerySmart(ctx, contractAddr, msg) + return bz.Bytes(), err default: return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, queryMethod) } - bz, err := json.Marshal(resultData) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - return bz, nil } func queryCodeList(ctx sdk.Context, keeper types.ViewKeeper) ([]types.CodeInfoResponse, error) { diff --git a/x/wasm/keeper/legacy_querier_test.go b/x/wasm/keeper/legacy_querier_test.go index 6638817b7c..3fd0b4ec53 100644 --- a/x/wasm/keeper/legacy_querier_test.go +++ b/x/wasm/keeper/legacy_querier_test.go @@ -3,12 +3,12 @@ package keeper import ( "bytes" "encoding/json" + "errors" "fmt" "io/ioutil" "testing" sdk "github.com/cosmos/cosmos-sdk/types" - sdkErrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" @@ -61,7 +61,7 @@ func TestLegacyQueryContractState(t *testing.T) { // if success and expSmartRes is not set, we parse into []types.Model and compare (all state) expModelLen int expModelContains []types.Model - expErr *sdkErrors.Error + expErr error }{ "query all": { srcPath: []string{QueryGetContractState, addr.String(), QueryMethodContractStateAll}, @@ -94,7 +94,7 @@ func TestLegacyQueryContractState(t *testing.T) { "query smart with invalid json": { srcPath: []string{QueryGetContractState, addr.String(), QueryMethodContractStateSmart}, srcReq: abci.RequestQuery{Data: []byte(`not a json string`)}, - expErr: types.ErrQueryFailed, + expErr: types.ErrInvalid, }, "query non-existent raw key": { srcPath: []string{QueryGetContractState, addr.String(), QueryMethodContractStateRaw}, @@ -121,6 +121,7 @@ func TestLegacyQueryContractState(t *testing.T) { }, "query smart with unknown address": { srcPath: []string{QueryGetContractState, anyAddr.String(), QueryMethodContractStateSmart}, + srcReq: abci.RequestQuery{Data: []byte(`{}`)}, expModelLen: 0, expErr: types.ErrNotFound, }, @@ -130,7 +131,7 @@ func TestLegacyQueryContractState(t *testing.T) { t.Run(msg, func(t *testing.T) { binResult, err := q(ctx, spec.srcPath, spec.srcReq) // require.True(t, spec.expErr.Is(err), "unexpected error") - require.True(t, spec.expErr.Is(err), err) + require.True(t, errors.Is(err, spec.expErr), err) // if smart query, check custom response if spec.srcPath[2] != QueryMethodContractStateAll { diff --git a/x/wasm/keeper/querier.go b/x/wasm/keeper/querier.go index 3047a46bbb..2ed7abd3e1 100644 --- a/x/wasm/keeper/querier.go +++ b/x/wasm/keeper/querier.go @@ -165,6 +165,9 @@ func (q grpcQuerier) SmartContractState(c context.Context, req *types.QuerySmart if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } + if err := req.QueryData.ValidateBasic(); err != nil { + return nil, status.Error(codes.InvalidArgument, "invalid query data") + } contractAddr, err := sdk.AccAddressFromBech32(req.Address) if err != nil { return nil, err diff --git a/x/wasm/keeper/querier_test.go b/x/wasm/keeper/querier_test.go index b415f1b4ab..35ba039a43 100644 --- a/x/wasm/keeper/querier_test.go +++ b/x/wasm/keeper/querier_test.go @@ -3,11 +3,15 @@ package keeper import ( "encoding/base64" "encoding/json" + "errors" "fmt" "io/ioutil" "testing" "time" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + cosmwasm "github.com/CosmWasm/wasmvm" wasmvmtypes "github.com/CosmWasm/wasmvm/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -121,7 +125,7 @@ func TestQuerySmartContractState(t *testing.T) { srcAddr sdk.AccAddress srcQuery *types.QuerySmartContractStateRequest expResp string - expErr *sdkErrors.Error + expErr error }{ "query smart": { srcQuery: &types.QuerySmartContractStateRequest{Address: contractAddr, QueryData: []byte(`{"verifier":{}}`)}, @@ -133,7 +137,7 @@ func TestQuerySmartContractState(t *testing.T) { }, "query smart with invalid json": { srcQuery: &types.QuerySmartContractStateRequest{Address: contractAddr, QueryData: []byte(`not a json string`)}, - expErr: types.ErrQueryFailed, + expErr: status.Error(codes.InvalidArgument, "invalid query data"), }, "query smart with unknown address": { srcQuery: &types.QuerySmartContractStateRequest{Address: RandomBech32AccountAddress(t), QueryData: []byte(`{"verifier":{}}`)}, @@ -143,7 +147,7 @@ func TestQuerySmartContractState(t *testing.T) { for msg, spec := range specs { t.Run(msg, func(t *testing.T) { got, err := q.SmartContractState(sdk.WrapSDKContext(ctx), spec.srcQuery) - require.True(t, spec.expErr.Is(err), "but got %+v", err) + require.True(t, errors.Is(err, spec.expErr), "but got %+v", err) if spec.expErr != nil { return } @@ -188,7 +192,8 @@ func TestQuerySmartContractPanics(t *testing.T) { // when q := Querier(keepers.WasmKeeper) got, err := q.SmartContractState(sdk.WrapSDKContext(ctx), &types.QuerySmartContractStateRequest{ - Address: contractAddr.String(), + Address: contractAddr.String(), + QueryData: types.RawContractMessage("{}"), }) require.True(t, spec.expErr.Is(err), "got error: %+v", err) assert.Nil(t, got) diff --git a/x/wasm/keeper/query_plugins.go b/x/wasm/keeper/query_plugins.go index 6475945a44..7bc768daef 100644 --- a/x/wasm/keeper/query_plugins.go +++ b/x/wasm/keeper/query_plugins.go @@ -81,7 +81,7 @@ type contractMetaDataSource interface { type wasmQueryKeeper interface { contractMetaDataSource QueryRaw(ctx sdk.Context, contractAddress sdk.AccAddress, key []byte) []byte - QuerySmart(ctx sdk.Context, contractAddr sdk.AccAddress, req []byte) ([]byte, error) + QuerySmart(ctx sdk.Context, contractAddr sdk.AccAddress, req types.RawContractMessage) (types.RawContractMessage, error) IsPinnedCode(ctx sdk.Context, codeID uint64) bool } @@ -469,7 +469,11 @@ func WasmQuerier(k wasmQueryKeeper) func(ctx sdk.Context, request *wasmvmtypes.W if err != nil { return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, request.Smart.ContractAddr) } - return k.QuerySmart(ctx, addr, request.Smart.Msg) + msg := types.RawContractMessage(request.Smart.Msg) + if err := msg.ValidateBasic(); err != nil { + return nil, sdkerrors.Wrap(err, "json msg") + } + return k.QuerySmart(ctx, addr, msg) case request.Raw != nil: addr, err := sdk.AccAddressFromBech32(request.Raw.ContractAddr) if err != nil { diff --git a/x/wasm/keeper/query_plugins_test.go b/x/wasm/keeper/query_plugins_test.go index 410631314d..e829cd12e9 100644 --- a/x/wasm/keeper/query_plugins_test.go +++ b/x/wasm/keeper/query_plugins_test.go @@ -445,7 +445,7 @@ func TestContractInfoWasmQuerier(t *testing.T) { type mockWasmQueryKeeper struct { GetContractInfoFn func(ctx sdk.Context, contractAddress sdk.AccAddress) *types.ContractInfo QueryRawFn func(ctx sdk.Context, contractAddress sdk.AccAddress, key []byte) []byte - QuerySmartFn func(ctx sdk.Context, contractAddr sdk.AccAddress, req []byte) ([]byte, error) + QuerySmartFn func(ctx sdk.Context, contractAddr sdk.AccAddress, req types.RawContractMessage) ([]byte, error) IsPinnedCodeFn func(ctx sdk.Context, codeID uint64) bool } @@ -463,7 +463,7 @@ func (m mockWasmQueryKeeper) QueryRaw(ctx sdk.Context, contractAddress sdk.AccAd return m.QueryRawFn(ctx, contractAddress, key) } -func (m mockWasmQueryKeeper) QuerySmart(ctx sdk.Context, contractAddr sdk.AccAddress, req []byte) ([]byte, error) { +func (m mockWasmQueryKeeper) QuerySmart(ctx sdk.Context, contractAddr sdk.AccAddress, req types.RawContractMessage) (types.RawContractMessage, error) { if m.QuerySmartFn == nil { panic("not expected to be called") } diff --git a/x/wasm/types/exported_keepers.go b/x/wasm/types/exported_keepers.go index 02f227648b..e9d60302c6 100644 --- a/x/wasm/types/exported_keepers.go +++ b/x/wasm/types/exported_keepers.go @@ -9,7 +9,7 @@ import ( // ViewKeeper provides read only operations type ViewKeeper interface { GetContractHistory(ctx sdk.Context, contractAddr sdk.AccAddress) []ContractCodeHistoryEntry - QuerySmart(ctx sdk.Context, contractAddr sdk.AccAddress, req []byte) ([]byte, error) + QuerySmart(ctx sdk.Context, contractAddr sdk.AccAddress, req RawContractMessage) (RawContractMessage, error) QueryRaw(ctx sdk.Context, contractAddress sdk.AccAddress, key []byte) []byte HasContractInfo(ctx sdk.Context, contractAddress sdk.AccAddress) bool GetContractInfo(ctx sdk.Context, contractAddress sdk.AccAddress) *ContractInfo diff --git a/x/wasm/types/query.pb.go b/x/wasm/types/query.pb.go index b069fe9d8f..d5e3828e27 100644 --- a/x/wasm/types/query.pb.go +++ b/x/wasm/types/query.pb.go @@ -450,7 +450,7 @@ type QuerySmartContractStateRequest struct { // address is the address of the contract Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` // QueryData contains the query data passed to the contract - QueryData []byte `protobuf:"bytes,2,opt,name=query_data,json=queryData,proto3" json:"query_data,omitempty"` + QueryData RawContractMessage `protobuf:"bytes,2,opt,name=query_data,json=queryData,proto3,casttype=RawContractMessage" json:"query_data,omitempty"` } func (m *QuerySmartContractStateRequest) Reset() { *m = QuerySmartContractStateRequest{} } @@ -828,79 +828,79 @@ func init() { func init() { proto.RegisterFile("cosmwasm/wasm/v1/query.proto", fileDescriptor_9677c207036b9f2b) } var fileDescriptor_9677c207036b9f2b = []byte{ - // 1138 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x97, 0x4f, 0x6f, 0x1b, 0xc5, - 0x1b, 0xc7, 0x3d, 0xa9, 0xe3, 0x3f, 0x93, 0xfc, 0x54, 0xff, 0x46, 0xa8, 0x31, 0x26, 0xdd, 0x8d, - 0x96, 0x2a, 0xa4, 0x6e, 0xd8, 0xad, 0xd3, 0x80, 0x10, 0x37, 0x36, 0x85, 0x26, 0x91, 0x22, 0xb5, - 0x5b, 0xa1, 0x0a, 0x38, 0x44, 0x63, 0xef, 0xd4, 0x5e, 0xc9, 0xde, 0x71, 0x77, 0x26, 0x49, 0xad, - 0x28, 0x80, 0x2a, 0x71, 0x43, 0x80, 0x84, 0x38, 0xc3, 0x01, 0x15, 0x38, 0x22, 0xde, 0x00, 0xc7, - 0x1c, 0x23, 0x71, 0xe1, 0x64, 0x81, 0xc3, 0x01, 0xe5, 0x0d, 0x20, 0xf5, 0x84, 0x76, 0x76, 0xd6, - 0x5e, 0xff, 0x59, 0xdb, 0xad, 0x2c, 0x2e, 0xd1, 0x6e, 0xe6, 0x79, 0x9e, 0xf9, 0x3c, 0xdf, 0x7d, - 0xe6, 0x79, 0xc6, 0x70, 0xb9, 0x42, 0x59, 0xe3, 0x08, 0xb3, 0x86, 0x21, 0xfe, 0x1c, 0x96, 0x8c, - 0x47, 0x07, 0xc4, 0x6b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0xf4, 0x5d, 0x74, 0x3d, 0x26, 0xea, 0x70, 0xff, 0x2f, 0x14, 0xa7, 0x31, - 0x95, 0x18, 0xab, 0x02, 0x63, 0x05, 0x29, 0xa3, 0x31, 0x98, 0xd1, 0x14, 0x4e, 0xe6, 0xf6, 0xe9, - 0x9f, 0x4a, 0xe2, 0xc7, 0x8e, 0x92, 0x38, 0xed, 0x28, 0xe0, 0xac, 0xa3, 0x80, 0x3f, 0x3a, 0x0a, - 0xf8, 0xea, 0x5c, 0x49, 0x9c, 0x9d, 0x2b, 0x89, 0xdf, 0xcf, 0x95, 0xc4, 0x87, 0xab, 0x91, 0xdb, - 0xc6, 0x16, 0x65, 0x8d, 0x07, 0x61, 0x2c, 0xdb, 0x78, 0x1c, 0xc4, 0x14, 0x3f, 0x73, 0xcb, 0x29, - 0xf1, 0xeb, 0xf4, 0xd6, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xae, 0x9b, 0x1a, 0x28, 0x4d, 0x0f, - 0x00, 0x00, + // 1142 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x97, 0x4d, 0x6f, 0x1b, 0x45, + 0x18, 0xc7, 0x3d, 0xa9, 0xe3, 0x97, 0x49, 0x50, 0xcd, 0x08, 0x35, 0xc6, 0xa4, 0xbb, 0xd1, 0x52, + 0x85, 0xd4, 0x0d, 0xbb, 0x75, 0x9a, 0x22, 0xc4, 0x0d, 0xa7, 0xd0, 0x24, 0x52, 0xa4, 0x76, 0x2b, + 0x54, 0x09, 0x0e, 0xd1, 0xd8, 0x3b, 0xb5, 0x57, 0xb2, 0x77, 0x9c, 0x9d, 0x49, 0x52, 0x2b, 0x0a, + 0xa0, 0x4a, 0xdc, 0x10, 0x20, 0x21, 0xce, 0x70, 0x40, 0x05, 0x8e, 0x88, 0x2f, 0xc0, 0x31, 0xc7, + 0x48, 0x5c, 0x38, 0x59, 0xe0, 0x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4d, 0x18, 0x17, 0x4d, 0xaa, 0x45, 0x76, 0x5d, 0xb7, 0x33, 0xdf, 0x1c, + 0x69, 0x23, 0x41, 0x56, 0x04, 0x88, 0x86, 0x96, 0xc6, 0xb5, 0x23, 0x72, 0xe1, 0xac, 0x38, 0xfc, + 0xd0, 0xa8, 0xb8, 0xc1, 0xf1, 0x9b, 0xbb, 0x31, 0xda, 0x48, 0x66, 0x57, 0x44, 0xf6, 0x2c, 0xba, + 0x36, 0x3c, 0x3b, 0xfa, 0x12, 0xc0, 0xb9, 0xd0, 0xb9, 0x8b, 0x6e, 0x46, 0x44, 0x1d, 0x3c, 0xff, + 0x73, 0xf9, 0x49, 0x4c, 0x25, 0xc6, 0xb2, 0xc0, 0x58, 0x42, 0xca, 0x70, 0x0c, 0x66, 0x34, 0x84, + 0x53, 0x71, 0xf3, 0xe4, 0x6f, 0x25, 0xf6, 0x73, 0x5b, 0x89, 0x9d, 0xb4, 0x15, 0x70, 0xda, 0x56, + 0xc0, 0x5f, 0x6d, 0x05, 0x7c, 0x73, 0xa6, 0xc4, 0x4e, 0xcf, 0x94, 0xd8, 0x9f, 0x67, 0x4a, 0xec, + 0xe3, 0xe5, 0xd0, 0x6d, 0x63, 0x83, 0xb2, 0xfa, 0xe3, 0x20, 0x96, 0x65, 0x3c, 0xf5, 0x63, 0x8a, + 0x9f, 0xbf, 0xa5, 0x84, 0xf8, 0xd5, 0x7a, 0xe7, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xe5, 0x33, + 0xf7, 0x66, 0x65, 0x0f, 0x00, 0x00, } func (this *QueryContractInfoResponse) Equal(that interface{}) bool { diff --git a/x/wasm/types/tx.go b/x/wasm/types/tx.go index 519faa510a..33313693be 100644 --- a/x/wasm/types/tx.go +++ b/x/wasm/types/tx.go @@ -20,12 +20,12 @@ func (r RawContractMessage) MarshalJSON() ([]byte, error) { return r, nil } -func (a *RawContractMessage) UnmarshalJSON(b []byte) error { +func (r *RawContractMessage) UnmarshalJSON(b []byte) error { // copied from json.RawMessage#UnmarshalJSON - if a == nil { + if r == nil { return errors.New("unmarshalJSON on nil pointer") } - *a = append((*a)[0:0], b...) + *r = append((*r)[0:0], b...) return nil } @@ -39,6 +39,11 @@ func (r *RawContractMessage) ValidateBasic() error { return nil } +// Bytes returns raw bytes type +func (r RawContractMessage) Bytes() []byte { + return r +} + func (msg MsgStoreCode) Route() string { return RouterKey } From ee19082712919f7b00fdbccb7184029d7a59a533 Mon Sep 17 00:00:00 2001 From: Alex Peters Date: Fri, 22 Oct 2021 13:36:44 +0200 Subject: [PATCH 5/7] Revert method signature change to be consistent --- x/wasm/keeper/keeper.go | 2 +- x/wasm/keeper/legacy_querier.go | 2 +- x/wasm/keeper/query_plugins.go | 2 +- x/wasm/keeper/query_plugins_test.go | 2 +- x/wasm/types/exported_keepers.go | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/x/wasm/keeper/keeper.go b/x/wasm/keeper/keeper.go index 420140de1e..9c1cdc2c50 100644 --- a/x/wasm/keeper/keeper.go +++ b/x/wasm/keeper/keeper.go @@ -586,7 +586,7 @@ func (k Keeper) getLastContractHistoryEntry(ctx sdk.Context, contractAddr sdk.Ac } // QuerySmart queries the smart contract itself. -func (k Keeper) QuerySmart(ctx sdk.Context, contractAddr sdk.AccAddress, req types.RawContractMessage) (types.RawContractMessage, error) { +func (k Keeper) QuerySmart(ctx sdk.Context, contractAddr sdk.AccAddress, req []byte) ([]byte, error) { defer telemetry.MeasureSince(time.Now(), "wasm", "contract", "query-smart") contractInfo, codeInfo, prefixStore, err := k.contractInstance(ctx, contractAddr) if err != nil { diff --git a/x/wasm/keeper/legacy_querier.go b/x/wasm/keeper/legacy_querier.go index 21ae450fe3..768c3def4d 100644 --- a/x/wasm/keeper/legacy_querier.go +++ b/x/wasm/keeper/legacy_querier.go @@ -116,7 +116,7 @@ func queryContractState(ctx sdk.Context, bech, queryMethod string, data []byte, } // this returns raw bytes (must be base64-encoded) bz, err := keeper.QuerySmart(ctx, contractAddr, msg) - return bz.Bytes(), err + return bz, err default: return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, queryMethod) } diff --git a/x/wasm/keeper/query_plugins.go b/x/wasm/keeper/query_plugins.go index 7bc768daef..a83041a964 100644 --- a/x/wasm/keeper/query_plugins.go +++ b/x/wasm/keeper/query_plugins.go @@ -81,7 +81,7 @@ type contractMetaDataSource interface { type wasmQueryKeeper interface { contractMetaDataSource QueryRaw(ctx sdk.Context, contractAddress sdk.AccAddress, key []byte) []byte - QuerySmart(ctx sdk.Context, contractAddr sdk.AccAddress, req types.RawContractMessage) (types.RawContractMessage, error) + QuerySmart(ctx sdk.Context, contractAddr sdk.AccAddress, req []byte) ([]byte, error) IsPinnedCode(ctx sdk.Context, codeID uint64) bool } diff --git a/x/wasm/keeper/query_plugins_test.go b/x/wasm/keeper/query_plugins_test.go index e829cd12e9..f4bad933c7 100644 --- a/x/wasm/keeper/query_plugins_test.go +++ b/x/wasm/keeper/query_plugins_test.go @@ -463,7 +463,7 @@ func (m mockWasmQueryKeeper) QueryRaw(ctx sdk.Context, contractAddress sdk.AccAd return m.QueryRawFn(ctx, contractAddress, key) } -func (m mockWasmQueryKeeper) QuerySmart(ctx sdk.Context, contractAddr sdk.AccAddress, req types.RawContractMessage) (types.RawContractMessage, error) { +func (m mockWasmQueryKeeper) QuerySmart(ctx sdk.Context, contractAddr sdk.AccAddress, req []byte) ([]byte, error) { if m.QuerySmartFn == nil { panic("not expected to be called") } diff --git a/x/wasm/types/exported_keepers.go b/x/wasm/types/exported_keepers.go index e9d60302c6..02f227648b 100644 --- a/x/wasm/types/exported_keepers.go +++ b/x/wasm/types/exported_keepers.go @@ -9,7 +9,7 @@ import ( // ViewKeeper provides read only operations type ViewKeeper interface { GetContractHistory(ctx sdk.Context, contractAddr sdk.AccAddress) []ContractCodeHistoryEntry - QuerySmart(ctx sdk.Context, contractAddr sdk.AccAddress, req RawContractMessage) (RawContractMessage, error) + QuerySmart(ctx sdk.Context, contractAddr sdk.AccAddress, req []byte) ([]byte, error) QueryRaw(ctx sdk.Context, contractAddress sdk.AccAddress, key []byte) []byte HasContractInfo(ctx sdk.Context, contractAddress sdk.AccAddress) bool GetContractInfo(ctx sdk.Context, contractAddress sdk.AccAddress) *ContractInfo From cfaf1577bae4adcf13ac766cc44009b4ff19031c Mon Sep 17 00:00:00 2001 From: Alex Peters Date: Mon, 25 Oct 2021 11:14:06 +0200 Subject: [PATCH 6/7] Review comment --- x/wasm/types/tx.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/x/wasm/types/tx.go b/x/wasm/types/tx.go index 33313693be..83a0ac5f9c 100644 --- a/x/wasm/types/tx.go +++ b/x/wasm/types/tx.go @@ -13,19 +13,18 @@ import ( type RawContractMessage []byte func (r RawContractMessage) MarshalJSON() ([]byte, error) { - // copied from json.RawMessage#MarshalJSON - if r == nil { - return []byte("null"), nil - } - return r, nil + return json.RawMessage(r).MarshalJSON() } func (r *RawContractMessage) UnmarshalJSON(b []byte) error { - // copied from json.RawMessage#UnmarshalJSON if r == nil { return errors.New("unmarshalJSON on nil pointer") } - *r = append((*r)[0:0], b...) + raw := json.RawMessage(*r) + if err := (&raw).UnmarshalJSON(b); err != nil { + return err + } + *r = []byte(raw) return nil } From 481be4d234bf3a5dd998bae6d03c950b869051a5 Mon Sep 17 00:00:00 2001 From: Alex Peters Date: Mon, 25 Oct 2021 13:15:57 +0200 Subject: [PATCH 7/7] Update after discussions --- x/wasm/types/tx.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/x/wasm/types/tx.go b/x/wasm/types/tx.go index 83a0ac5f9c..3461bd4d69 100644 --- a/x/wasm/types/tx.go +++ b/x/wasm/types/tx.go @@ -10,6 +10,8 @@ import ( ) // RawContractMessage defines a json message that is sent or returned by a wasm contract. +// This type can hold any type of bytes. Until validateBasic is called there should not be +// any assumptions made that the data is valid syntax or semantic. type RawContractMessage []byte func (r RawContractMessage) MarshalJSON() ([]byte, error) { @@ -20,11 +22,7 @@ func (r *RawContractMessage) UnmarshalJSON(b []byte) error { if r == nil { return errors.New("unmarshalJSON on nil pointer") } - raw := json.RawMessage(*r) - if err := (&raw).UnmarshalJSON(b); err != nil { - return err - } - *r = []byte(raw) + *r = append((*r)[0:0], b...) return nil }