Start with wasm msg in genesis

This commit is contained in:
Alex Peters
2020-12-16 15:25:34 +01:00
parent 9c0b974e23
commit 57999b26b7
10 changed files with 676 additions and 70 deletions

View File

@@ -411,7 +411,7 @@ func NewWasmApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest b
distr.NewAppModule(appCodec, app.distrKeeper, app.accountKeeper, app.bankKeeper, app.stakingKeeper),
staking.NewAppModule(appCodec, app.stakingKeeper, app.accountKeeper, app.bankKeeper),
upgrade.NewAppModule(app.upgradeKeeper),
wasm.NewAppModule(&app.wasmKeeper),
wasm.NewAppModule(&app.wasmKeeper, app.stakingKeeper),
evidence.NewAppModule(app.evidenceKeeper),
ibc.NewAppModule(app.ibcKeeper),
params.NewAppModule(app.paramsKeeper),
@@ -461,7 +461,7 @@ func NewWasmApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest b
distr.NewAppModule(appCodec, app.distrKeeper, app.accountKeeper, app.bankKeeper, app.stakingKeeper),
slashing.NewAppModule(appCodec, app.slashingKeeper, app.accountKeeper, app.bankKeeper, app.stakingKeeper),
params.NewAppModule(app.paramsKeeper),
wasm.NewAppModule(&app.wasmKeeper),
wasm.NewAppModule(&app.wasmKeeper, app.stakingKeeper),
evidence.NewAppModule(app.evidenceKeeper),
ibc.NewAppModule(app.ibcKeeper),
transferModule,

View File

@@ -7,6 +7,7 @@
- [Code](#cosmwasm.wasm.v1beta1.Code)
- [Contract](#cosmwasm.wasm.v1beta1.Contract)
- [GenesisState](#cosmwasm.wasm.v1beta1.GenesisState)
- [GenesisState.GenMsgs](#cosmwasm.wasm.v1beta1.GenesisState.GenMsgs)
- [Sequence](#cosmwasm.wasm.v1beta1.Sequence)
- [x/wasm/internal/types/msg.proto](#x/wasm/internal/types/msg.proto)
@@ -116,6 +117,25 @@ GenesisState - genesis state of x/wasm
| codes | [Code](#cosmwasm.wasm.v1beta1.Code) | repeated | |
| contracts | [Contract](#cosmwasm.wasm.v1beta1.Contract) | repeated | |
| sequences | [Sequence](#cosmwasm.wasm.v1beta1.Sequence) | repeated | |
| gen_msgs | [GenesisState.GenMsgs](#cosmwasm.wasm.v1beta1.GenesisState.GenMsgs) | repeated | |
<a name="cosmwasm.wasm.v1beta1.GenesisState.GenMsgs"></a>
### GenesisState.GenMsgs
GenMsgs define the messages that can be executed during genesis phase.
The intention is to have more human readable data that is auditable.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| store_code | [MsgStoreCode](#cosmwasm.wasm.v1beta1.MsgStoreCode) | | |
| instantiate_contract | [MsgInstantiateContract](#cosmwasm.wasm.v1beta1.MsgInstantiateContract) | | |
| execute_contract | [MsgExecuteContract](#cosmwasm.wasm.v1beta1.MsgExecuteContract) | | |

View File

@@ -79,7 +79,7 @@ func TestInitGenesis(t *testing.T) {
q2 := newData.module.LegacyQuerierHandler(nil)
// initialize new app with genstate
InitGenesis(newData.ctx, &newData.keeper, *genState)
InitGenesis(newData.ctx, &newData.keeper, *genState, newData.stakingKeeper, newData.module.Route().Handler())
// run same checks again on newdata, to make sure it was reinitialized correctly
assertCodeList(t, q2, newData.ctx, 1)

View File

@@ -4,21 +4,27 @@ import (
"github.com/CosmWasm/wasmd/x/wasm/internal/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
abci "github.com/tendermint/tendermint/abci/types"
// authexported "github.com/cosmos/cosmos-sdk/x/auth/exported"
// "github.com/CosmWasm/wasmd/x/wasm/internal/types"
)
// ValidatorSetSource is a subset of the staking keeper
type ValidatorSetSource interface {
ApplyAndReturnValidatorSetUpdates(sdk.Context) (updates []abci.ValidatorUpdate, err error)
}
// InitGenesis sets supply information for genesis.
//
// CONTRACT: all types of accounts must have been already initialized/created
func InitGenesis(ctx sdk.Context, keeper *Keeper, data types.GenesisState) error {
func InitGenesis(ctx sdk.Context, keeper *Keeper, data types.GenesisState, stakingKeeper ValidatorSetSource, msgHandler sdk.Handler) ([]abci.ValidatorUpdate, error) {
keeper.setParams(ctx, data.Params)
var maxCodeID uint64
for i, code := range data.Codes {
err := keeper.importCode(ctx, code.CodeID, code.CodeInfo, code.CodeBytes)
if err != nil {
return sdkerrors.Wrapf(err, "code %d with id: %d", i, code.CodeID)
return nil, sdkerrors.Wrapf(err, "code %d with id: %d", i, code.CodeID)
}
if code.CodeID > maxCodeID {
maxCodeID = code.CodeID
@@ -29,11 +35,11 @@ func InitGenesis(ctx sdk.Context, keeper *Keeper, data types.GenesisState) error
for i, contract := range data.Contracts {
contractAddr, err := sdk.AccAddressFromBech32(contract.ContractAddress)
if err != nil {
return sdkerrors.Wrapf(err, "address in contract number %d", i)
return nil, sdkerrors.Wrapf(err, "address in contract number %d", i)
}
err = keeper.importContract(ctx, contractAddr, &contract.ContractInfo, contract.ContractState)
if err != nil {
return sdkerrors.Wrapf(err, "contract number %d", i)
return nil, sdkerrors.Wrapf(err, "contract number %d", i)
}
maxContractID = i + 1 // not ideal but max(contractID) is not persisted otherwise
}
@@ -41,18 +47,44 @@ func InitGenesis(ctx sdk.Context, keeper *Keeper, data types.GenesisState) error
for i, seq := range data.Sequences {
err := keeper.importAutoIncrementID(ctx, seq.IDKey, seq.Value)
if err != nil {
return sdkerrors.Wrapf(err, "sequence number %d", i)
return nil, sdkerrors.Wrapf(err, "sequence number %d", i)
}
}
// sanity check seq values
if keeper.peekAutoIncrementID(ctx, types.KeyLastCodeID) <= maxCodeID {
return sdkerrors.Wrapf(types.ErrInvalid, "seq %s must be greater %d ", string(types.KeyLastCodeID), maxCodeID)
return nil, sdkerrors.Wrapf(types.ErrInvalid, "seq %s must be greater %d ", string(types.KeyLastCodeID), maxCodeID)
}
if keeper.peekAutoIncrementID(ctx, types.KeyLastInstanceID) <= uint64(maxContractID) {
return sdkerrors.Wrapf(types.ErrInvalid, "seq %s must be greater %d ", string(types.KeyLastInstanceID), maxContractID)
return nil, sdkerrors.Wrapf(types.ErrInvalid, "seq %s must be greater %d ", string(types.KeyLastInstanceID), maxContractID)
}
if len(data.GenMsgs) == 0 {
return nil, nil
}
for _, genTx := range data.GenMsgs {
msg := asMsg(genTx)
if msg == nil {
return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidType, "unknown message")
}
_, err := msgHandler(ctx, msg)
if err != nil {
return nil, sdkerrors.Wrap(err, "genesis")
}
}
return stakingKeeper.ApplyAndReturnValidatorSetUpdates(ctx)
}
func asMsg(genTx types.GenesisState_GenMsgs) sdk.Msg {
if msg := genTx.GetStoreCode(); msg != nil {
return msg
}
if msg := genTx.GetInstantiateContract(); msg != nil {
return msg
}
if msg := genTx.GetExecuteContract(); msg != nil {
return msg
}
return nil
}

View File

@@ -24,6 +24,7 @@ import (
fuzz "github.com/google/gofuzz"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/log"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
dbm "github.com/tendermint/tm-db"
@@ -96,7 +97,7 @@ func TestGenesisExportImport(t *testing.T) {
var importState wasmTypes.GenesisState
err = json.Unmarshal(exportedGenesis, &importState)
require.NoError(t, err)
InitGenesis(dstCtx, dstKeeper, importState)
InitGenesis(dstCtx, dstKeeper, importState, StakingKeeperMock{}, TestHandler(dstKeeper))
// compare whole DB
for j := range srcStoreKeys {
@@ -362,7 +363,7 @@ func TestFailFastImport(t *testing.T) {
keeper, ctx, _ := setupKeeper(t)
require.NoError(t, types.ValidateGenesis(spec.src))
got := InitGenesis(ctx, keeper, spec.src)
_, got := InitGenesis(ctx, keeper, spec.src, StakingKeeperMock{}, TestHandler(keeper))
if spec.expSuccess {
require.NoError(t, got)
return
@@ -433,7 +434,7 @@ func TestImportContractWithCodeHistoryReset(t *testing.T) {
ctx = ctx.WithBlockHeight(0).WithGasMeter(sdk.NewInfiniteGasMeter())
// when
err = InitGenesis(ctx, keeper, importState)
_, err = InitGenesis(ctx, keeper, importState, StakingKeeperMock{}, TestHandler(keeper))
require.NoError(t, err)
// verify wasm code
@@ -482,6 +483,42 @@ func TestImportContractWithCodeHistoryReset(t *testing.T) {
assert.Equal(t, expHistory, keeper.GetContractHistory(ctx, contractAddr))
}
func TestImportWithGenMsg(t *testing.T) {
wasmCode, err := ioutil.ReadFile("./testdata/hackatom.wasm")
require.NoError(t, err)
myAddress := RandomBech32AccountAddress(t)
importState := types.GenesisState{
Params: types.DefaultParams(),
GenMsgs: []types.GenesisState_GenMsgs{
{
Sum: &types.GenesisState_GenMsgs_StoreCode{
StoreCode: &types.MsgStoreCode{
Sender: myAddress,
WASMByteCode: wasmCode,
},
},
},
// todo: test other messages
},
}
require.NoError(t, importState.ValidateBasic())
keeper, ctx, _ := setupKeeper(t)
ctx = ctx.WithBlockHeight(0).WithGasMeter(sdk.NewInfiniteGasMeter())
// when
_, err = InitGenesis(ctx, keeper, importState, StakingKeeperMock{}, TestHandler(keeper))
require.NoError(t, err)
// verify wasm code
gotWasmCode, err := keeper.GetByteCode(ctx, 1)
require.NoError(t, err)
assert.Equal(t, wasmCode, gotWasmCode)
codeInfo := keeper.GetCodeInfo(ctx, 1)
require.NotNil(t, codeInfo)
}
func setupKeeper(t *testing.T) (*Keeper, sdk.Context, []sdk.StoreKey) {
t.Helper()
tempDir, err := ioutil.TempDir("", "wasm")
@@ -512,3 +549,12 @@ func setupKeeper(t *testing.T) (*Keeper, sdk.Context, []sdk.StoreKey) {
srcKeeper := NewKeeper(encodingConfig.Marshaler, keyWasm, pk.Subspace(wasmTypes.DefaultParamspace), authkeeper.AccountKeeper{}, nil, stakingkeeper.Keeper{}, distributionkeeper.Keeper{}, nil, tempDir, wasmConfig, "", nil, nil)
return &srcKeeper, ctx, []sdk.StoreKey{keyWasm, keyParams}
}
type StakingKeeperMock struct {
err error
validatorUpdate []abci.ValidatorUpdate
}
func (s StakingKeeperMock) ApplyAndReturnValidatorSetUpdates(_ sdk.Context) ([]abci.ValidatorUpdate, error) {
return s.validatorUpdate, s.err
}

View File

@@ -282,14 +282,13 @@ func CreateTestInput(t *testing.T, isCheckTx bool, supportedFeatures string, enc
func TestHandler(k *Keeper) sdk.Handler {
return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) {
ctx = ctx.WithEventManager(sdk.NewEventManager())
switch msg := msg.(type) {
case *types.MsgStoreCode:
return handleStoreCode(ctx, k, msg)
case *types.MsgInstantiateContract:
return handleInstantiate(ctx, k, msg)
case *types.MsgExecuteContract:
return handleExecute(ctx, k, msg)
default:
errMsg := fmt.Sprintf("unrecognized wasm message type: %T", msg)
return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg)
@@ -297,6 +296,23 @@ func TestHandler(k *Keeper) sdk.Handler {
}
}
func handleStoreCode(ctx sdk.Context, k *Keeper, msg *types.MsgStoreCode) (*sdk.Result, error) {
senderAddr, err := sdk.AccAddressFromBech32(msg.Sender)
if err != nil {
return nil, sdkerrors.Wrap(err, "sender")
}
codeID, err := k.Create(ctx, senderAddr, msg.WASMByteCode, msg.Source, msg.Builder, msg.InstantiatePermission)
if err != nil {
return nil, err
}
return &sdk.Result{
Data: []byte(fmt.Sprintf("%d", codeID)),
Events: ctx.EventManager().ABCIEvents(),
}, nil
}
func handleInstantiate(ctx sdk.Context, k *Keeper, msg *types.MsgInstantiateContract) (*sdk.Result, error) {
senderAddr, err := sdk.AccAddressFromBech32(msg.Sender)
if err != nil {

View File

@@ -25,10 +25,11 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
// GenesisState - genesis state of x/wasm
type GenesisState struct {
Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"`
Codes []Code `protobuf:"bytes,2,rep,name=codes,proto3" json:"codes,omitempty"`
Contracts []Contract `protobuf:"bytes,3,rep,name=contracts,proto3" json:"contracts,omitempty"`
Sequences []Sequence `protobuf:"bytes,4,rep,name=sequences,proto3" json:"sequences,omitempty"`
Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"`
Codes []Code `protobuf:"bytes,2,rep,name=codes,proto3" json:"codes,omitempty"`
Contracts []Contract `protobuf:"bytes,3,rep,name=contracts,proto3" json:"contracts,omitempty"`
Sequences []Sequence `protobuf:"bytes,4,rep,name=sequences,proto3" json:"sequences,omitempty"`
GenMsgs []GenesisState_GenMsgs `protobuf:"bytes,5,rep,name=gen_msgs,json=genMsgs,proto3" json:"gen_msgs,omitempty"`
}
func (m *GenesisState) Reset() { *m = GenesisState{} }
@@ -92,6 +93,115 @@ func (m *GenesisState) GetSequences() []Sequence {
return nil
}
func (m *GenesisState) GetGenMsgs() []GenesisState_GenMsgs {
if m != nil {
return m.GenMsgs
}
return nil
}
// GenMsgs define the messages that can be executed during genesis phase.
// The intention is to have more human readable data that is auditable.
type GenesisState_GenMsgs struct {
// sum is a single message
//
// Types that are valid to be assigned to Sum:
// *GenesisState_GenMsgs_StoreCode
// *GenesisState_GenMsgs_InstantiateContract
// *GenesisState_GenMsgs_ExecuteContract
Sum isGenesisState_GenMsgs_Sum `protobuf_oneof:"sum"`
}
func (m *GenesisState_GenMsgs) Reset() { *m = GenesisState_GenMsgs{} }
func (m *GenesisState_GenMsgs) String() string { return proto.CompactTextString(m) }
func (*GenesisState_GenMsgs) ProtoMessage() {}
func (*GenesisState_GenMsgs) Descriptor() ([]byte, []int) {
return fileDescriptor_52f9f2715025dba8, []int{0, 0}
}
func (m *GenesisState_GenMsgs) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *GenesisState_GenMsgs) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_GenesisState_GenMsgs.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalToSizedBuffer(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *GenesisState_GenMsgs) XXX_Merge(src proto.Message) {
xxx_messageInfo_GenesisState_GenMsgs.Merge(m, src)
}
func (m *GenesisState_GenMsgs) XXX_Size() int {
return m.Size()
}
func (m *GenesisState_GenMsgs) XXX_DiscardUnknown() {
xxx_messageInfo_GenesisState_GenMsgs.DiscardUnknown(m)
}
var xxx_messageInfo_GenesisState_GenMsgs proto.InternalMessageInfo
type isGenesisState_GenMsgs_Sum interface {
isGenesisState_GenMsgs_Sum()
MarshalTo([]byte) (int, error)
Size() int
}
type GenesisState_GenMsgs_StoreCode struct {
StoreCode *MsgStoreCode `protobuf:"bytes,1,opt,name=store_code,json=storeCode,proto3,oneof" json:"store_code,omitempty"`
}
type GenesisState_GenMsgs_InstantiateContract struct {
InstantiateContract *MsgInstantiateContract `protobuf:"bytes,2,opt,name=instantiate_contract,json=instantiateContract,proto3,oneof" json:"instantiate_contract,omitempty"`
}
type GenesisState_GenMsgs_ExecuteContract struct {
ExecuteContract *MsgExecuteContract `protobuf:"bytes,3,opt,name=execute_contract,json=executeContract,proto3,oneof" json:"execute_contract,omitempty"`
}
func (*GenesisState_GenMsgs_StoreCode) isGenesisState_GenMsgs_Sum() {}
func (*GenesisState_GenMsgs_InstantiateContract) isGenesisState_GenMsgs_Sum() {}
func (*GenesisState_GenMsgs_ExecuteContract) isGenesisState_GenMsgs_Sum() {}
func (m *GenesisState_GenMsgs) GetSum() isGenesisState_GenMsgs_Sum {
if m != nil {
return m.Sum
}
return nil
}
func (m *GenesisState_GenMsgs) GetStoreCode() *MsgStoreCode {
if x, ok := m.GetSum().(*GenesisState_GenMsgs_StoreCode); ok {
return x.StoreCode
}
return nil
}
func (m *GenesisState_GenMsgs) GetInstantiateContract() *MsgInstantiateContract {
if x, ok := m.GetSum().(*GenesisState_GenMsgs_InstantiateContract); ok {
return x.InstantiateContract
}
return nil
}
func (m *GenesisState_GenMsgs) GetExecuteContract() *MsgExecuteContract {
if x, ok := m.GetSum().(*GenesisState_GenMsgs_ExecuteContract); ok {
return x.ExecuteContract
}
return nil
}
// XXX_OneofWrappers is for the internal use of the proto package.
func (*GenesisState_GenMsgs) XXX_OneofWrappers() []interface{} {
return []interface{}{
(*GenesisState_GenMsgs_StoreCode)(nil),
(*GenesisState_GenMsgs_InstantiateContract)(nil),
(*GenesisState_GenMsgs_ExecuteContract)(nil),
}
}
// Code struct encompasses CodeInfo and CodeBytes
type Code struct {
CodeID uint64 `protobuf:"varint,1,opt,name=code_id,json=codeId,proto3" json:"code_id,omitempty"`
@@ -269,6 +379,7 @@ func (m *Sequence) GetValue() uint64 {
func init() {
proto.RegisterType((*GenesisState)(nil), "cosmwasm.wasm.v1beta1.GenesisState")
proto.RegisterType((*GenesisState_GenMsgs)(nil), "cosmwasm.wasm.v1beta1.GenesisState.GenMsgs")
proto.RegisterType((*Code)(nil), "cosmwasm.wasm.v1beta1.Code")
proto.RegisterType((*Contract)(nil), "cosmwasm.wasm.v1beta1.Contract")
proto.RegisterType((*Sequence)(nil), "cosmwasm.wasm.v1beta1.Sequence")
@@ -279,39 +390,47 @@ func init() {
}
var fileDescriptor_52f9f2715025dba8 = []byte{
// 510 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x93, 0xc1, 0x6f, 0xd3, 0x3e,
0x14, 0xc7, 0x9b, 0x2e, 0xcd, 0xaf, 0xf5, 0xfa, 0x63, 0xc8, 0x0c, 0x11, 0x6d, 0x2c, 0x29, 0xed,
0xa5, 0x48, 0x28, 0x61, 0xe3, 0xc8, 0x89, 0x6c, 0x12, 0xca, 0x26, 0x10, 0xca, 0x0e, 0x48, 0xbb,
0x54, 0x6e, 0xfc, 0x56, 0x22, 0x9a, 0xb8, 0xc4, 0xee, 0x58, 0xfe, 0x09, 0xc4, 0x9f, 0xb5, 0x1b,
0x3d, 0x72, 0xaa, 0x50, 0x7a, 0xe3, 0xaf, 0x40, 0x76, 0xd2, 0x2c, 0x48, 0xeb, 0xb8, 0xa4, 0xf5,
0xf3, 0xf7, 0x7d, 0xfc, 0xde, 0xf7, 0xd9, 0x68, 0x70, 0xed, 0x7e, 0x25, 0x3c, 0x76, 0xa3, 0x44,
0x40, 0x9a, 0x90, 0xa9, 0x2b, 0xb2, 0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 0x8f, 0x9d, 0x90, 0xc5, 0xee, 0x31, 0xe3, 0xf1, 0x47,
0xf9, 0x86, 0x64, 0x69, 0xd4, 0xbd, 0x2e, 0x7f, 0xff, 0x7e, 0x51, 0x63, 0x43, 0x3d, 0xa6, 0x57,
0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x56, 0x37, 0xff, 0x93, 0xc3, 0x03, 0x00, 0x00,
// 639 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x94, 0xc1, 0x6e, 0xd3, 0x40,
0x10, 0x86, 0xe3, 0x26, 0x4e, 0x93, 0x6d, 0xa0, 0xd5, 0xb6, 0x88, 0x28, 0xa5, 0x71, 0x49, 0x2e,
0xad, 0x80, 0x98, 0x96, 0x23, 0x27, 0xdc, 0x22, 0x9a, 0x56, 0x45, 0xc8, 0x95, 0x40, 0xea, 0x25,
0x72, 0xec, 0xa9, 0xb1, 0xa8, 0xbd, 0x21, 0xb3, 0x29, 0xf5, 0x4b, 0x20, 0xc4, 0x53, 0xf5, 0xd8,
0x23, 0xa7, 0x08, 0xa5, 0x37, 0x9e, 0x02, 0xed, 0x7a, 0xed, 0xba, 0x22, 0x2e, 0x17, 0x27, 0x3b,
0xfe, 0xff, 0xcf, 0x33, 0xb3, 0xb3, 0x4b, 0xba, 0x97, 0xe6, 0x37, 0x07, 0x43, 0x33, 0x88, 0x38,
0x8c, 0x23, 0xe7, 0xdc, 0xe4, 0xf1, 0x08, 0xd0, 0xf4, 0x21, 0x02, 0x0c, 0xb0, 0x37, 0x1a, 0x33,
0xce, 0xe8, 0x23, 0x97, 0x61, 0x28, 0x64, 0x3d, 0xf9, 0xb8, 0xd8, 0x19, 0x02, 0x77, 0x76, 0x5a,
0x6b, 0x3e, 0xf3, 0x99, 0x54, 0x98, 0xe2, 0x5f, 0x22, 0x6e, 0x3d, 0x9d, 0x4f, 0x94, 0x4f, 0x25,
0x31, 0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xc7, 0xe9, 0x49, 0x51, 0xd7, 0x99, 0x07, 0xe7, 0x8a, 0x94, 0x65, 0x22, 0xa7, 0xb4,
0x63, 0x91, 0x5a, 0x7a, 0x20, 0xe8, 0x26, 0xa9, 0x06, 0xde, 0xe0, 0x0b, 0xc4, 0xb2, 0x8e, 0x86,
0x55, 0x9f, 0x4d, 0x0d, 0xbd, 0xbf, 0x7f, 0x04, 0xb1, 0xad, 0x07, 0xde, 0x11, 0xc4, 0x74, 0x8d,
0xe8, 0x17, 0xce, 0xf9, 0x04, 0x64, 0x01, 0x15, 0x3b, 0x59, 0x58, 0x87, 0x57, 0xb3, 0xb6, 0x76,
0x3d, 0x6b, 0x6b, 0xbf, 0x67, 0x6d, 0xed, 0xc7, 0x4d, 0xbb, 0x74, 0x7d, 0xd3, 0x2e, 0xfd, 0xba,
0x69, 0x97, 0x4e, 0x5f, 0xfa, 0x01, 0xff, 0x3c, 0x19, 0xf6, 0x5c, 0x16, 0x9a, 0x7b, 0x0c, 0xc3,
0x4f, 0xe2, 0xea, 0x12, 0xa9, 0x79, 0xe6, 0xa5, 0xfa, 0xbd, 0x7b, 0x91, 0x0d, 0xab, 0xf2, 0x16,
0x7b, 0xf5, 0x37, 0x00, 0x00, 0xff, 0xff, 0xc2, 0xba, 0x9d, 0x7b, 0x5d, 0x05, 0x00, 0x00,
}
func (m *GenesisState) Marshal() (dAtA []byte, err error) {
@@ -334,6 +453,20 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) {
_ = i
var l int
_ = l
if len(m.GenMsgs) > 0 {
for iNdEx := len(m.GenMsgs) - 1; iNdEx >= 0; iNdEx-- {
{
size, err := m.GenMsgs[iNdEx].MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintGenesis(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x2a
}
}
if len(m.Sequences) > 0 {
for iNdEx := len(m.Sequences) - 1; iNdEx >= 0; iNdEx-- {
{
@@ -389,6 +522,101 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) {
return len(dAtA) - i, nil
}
func (m *GenesisState_GenMsgs) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalToSizedBuffer(dAtA[:size])
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *GenesisState_GenMsgs) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *GenesisState_GenMsgs) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
if m.Sum != nil {
{
size := m.Sum.Size()
i -= size
if _, err := m.Sum.MarshalTo(dAtA[i:]); err != nil {
return 0, err
}
}
}
return len(dAtA) - i, nil
}
func (m *GenesisState_GenMsgs_StoreCode) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *GenesisState_GenMsgs_StoreCode) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
if m.StoreCode != nil {
{
size, err := m.StoreCode.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintGenesis(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0xa
}
return len(dAtA) - i, nil
}
func (m *GenesisState_GenMsgs_InstantiateContract) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *GenesisState_GenMsgs_InstantiateContract) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
if m.InstantiateContract != nil {
{
size, err := m.InstantiateContract.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintGenesis(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x12
}
return len(dAtA) - i, nil
}
func (m *GenesisState_GenMsgs_ExecuteContract) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *GenesisState_GenMsgs_ExecuteContract) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
if m.ExecuteContract != nil {
{
size, err := m.ExecuteContract.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintGenesis(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x1a
}
return len(dAtA) - i, nil
}
func (m *Code) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
@@ -560,9 +788,63 @@ func (m *GenesisState) Size() (n int) {
n += 1 + l + sovGenesis(uint64(l))
}
}
if len(m.GenMsgs) > 0 {
for _, e := range m.GenMsgs {
l = e.Size()
n += 1 + l + sovGenesis(uint64(l))
}
}
return n
}
func (m *GenesisState_GenMsgs) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.Sum != nil {
n += m.Sum.Size()
}
return n
}
func (m *GenesisState_GenMsgs_StoreCode) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.StoreCode != nil {
l = m.StoreCode.Size()
n += 1 + l + sovGenesis(uint64(l))
}
return n
}
func (m *GenesisState_GenMsgs_InstantiateContract) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.InstantiateContract != nil {
l = m.InstantiateContract.Size()
n += 1 + l + sovGenesis(uint64(l))
}
return n
}
func (m *GenesisState_GenMsgs_ExecuteContract) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.ExecuteContract != nil {
l = m.ExecuteContract.Size()
n += 1 + l + sovGenesis(uint64(l))
}
return n
}
func (m *Code) Size() (n int) {
if m == nil {
return 0
@@ -788,6 +1070,198 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error {
return err
}
iNdEx = postIndex
case 5:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field GenMsgs", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthGenesis
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthGenesis
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.GenMsgs = append(m.GenMsgs, GenesisState_GenMsgs{})
if err := m.GenMsgs[len(m.GenMsgs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipGenesis(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthGenesis
}
if (iNdEx + skippy) < 0 {
return ErrInvalidLengthGenesis
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *GenesisState_GenMsgs) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: GenMsgs: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: GenMsgs: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field StoreCode", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthGenesis
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthGenesis
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
v := &MsgStoreCode{}
if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
m.Sum = &GenesisState_GenMsgs_StoreCode{v}
iNdEx = postIndex
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field InstantiateContract", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthGenesis
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthGenesis
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
v := &MsgInstantiateContract{}
if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
m.Sum = &GenesisState_GenMsgs_InstantiateContract{v}
iNdEx = postIndex
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field ExecuteContract", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthGenesis
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthGenesis
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
v := &MsgExecuteContract{}
if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
m.Sum = &GenesisState_GenMsgs_ExecuteContract{v}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipGenesis(dAtA[iNdEx:])

View File

@@ -3,6 +3,7 @@ package cosmwasm.wasm.v1beta1;
import "gogoproto/gogo.proto";
import "x/wasm/internal/types/types.proto";
import "x/wasm/internal/types/msg.proto";
option go_package = "github.com/CosmWasm/wasmd/x/wasmd/internal/types";
@@ -12,6 +13,18 @@ message GenesisState {
repeated Code codes = 2 [(gogoproto.nullable) = false, (gogoproto.jsontag) = "codes,omitempty"];
repeated Contract contracts = 3 [(gogoproto.nullable) = false, (gogoproto.jsontag) = "contracts,omitempty"];
repeated Sequence sequences = 4 [(gogoproto.nullable) = false, (gogoproto.jsontag) = "sequences,omitempty"];
repeated GenMsgs gen_msgs = 5 [(gogoproto.nullable) = false, (gogoproto.jsontag) = "gen_msgs,omitempty"];
// GenMsgs define the messages that can be executed during genesis phase.
// The intention is to have more human readable data that is auditable.
message GenMsgs {
// sum is a single message
oneof sum {
MsgStoreCode store_code = 1;
MsgInstantiateContract instantiate_contract = 2;
MsgExecuteContract execute_contract = 3;
}
}
}
// Code struct encompasses CodeInfo and CodeBytes

View File

@@ -94,14 +94,16 @@ func (b AppModuleBasic) RegisterInterfaces(registry cdctypes.InterfaceRegistry)
// AppModule implements an application module for the wasm module.
type AppModule struct {
AppModuleBasic
keeper *Keeper
keeper *Keeper
validatorSetSource keeper.ValidatorSetSource
}
// NewAppModule creates a new AppModule object
func NewAppModule(keeper *Keeper) AppModule {
func NewAppModule(keeper *Keeper, validatorSetSource keeper.ValidatorSetSource) AppModule {
return AppModule{
AppModuleBasic: AppModuleBasic{},
keeper: keeper,
AppModuleBasic: AppModuleBasic{},
keeper: keeper,
validatorSetSource: validatorSetSource,
}
}
@@ -131,10 +133,11 @@ func (AppModule) QuerierRoute() string {
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONMarshaler, data json.RawMessage) []abci.ValidatorUpdate {
var genesisState GenesisState
cdc.MustUnmarshalJSON(data, &genesisState)
if err := InitGenesis(ctx, am.keeper, genesisState); err != nil {
validators, err := InitGenesis(ctx, am.keeper, genesisState, am.validatorSetSource, am.Route().Handler())
if err != nil {
panic(err)
}
return []abci.ValidatorUpdate{}
return validators
}
// ExportGenesis returns the exported genesis state as raw bytes for the wasm

View File

@@ -13,6 +13,7 @@ import (
"github.com/cosmos/cosmos-sdk/types/module"
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
"github.com/dvsekhvalnov/jose2go/base64url"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@@ -22,23 +23,24 @@ import (
)
type testData struct {
module module.AppModule
ctx sdk.Context
acctKeeper authkeeper.AccountKeeper
keeper Keeper
bankKeeper bankkeeper.Keeper
module module.AppModule
ctx sdk.Context
acctKeeper authkeeper.AccountKeeper
keeper Keeper
bankKeeper bankkeeper.Keeper
stakingKeeper stakingkeeper.Keeper
}
// returns a cleanup function, which must be defered on
func setupTest(t *testing.T) testData {
ctx, keepers := CreateTestInput(t, false, "staking", nil, nil)
acctKeeper, wasmKeeper, bankKeeper := keepers.AccountKeeper, keepers.WasmKeeper, keepers.BankKeeper
data := testData{
module: NewAppModule(wasmKeeper),
ctx: ctx,
acctKeeper: acctKeeper,
keeper: *wasmKeeper,
bankKeeper: bankKeeper,
module: NewAppModule(keepers.WasmKeeper, keepers.StakingKeeper),
ctx: ctx,
acctKeeper: keepers.AccountKeeper,
keeper: *keepers.WasmKeeper,
bankKeeper: keepers.BankKeeper,
stakingKeeper: keepers.StakingKeeper,
}
return data
}