diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml new file mode 100644 index 0000000..7090a36 --- /dev/null +++ b/.github/workflows/main.yaml @@ -0,0 +1,44 @@ +name: Tests & CrossBuild & DockerBuild + +on: [push] + +jobs: + lint: + name: Linter checks + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: golangci-lint + uses: golangci/golangci-lint-action@v2 + with: + version: v1.32 + args: --exclude 'unused' --timeout=10m + + test: + name: Unit tests & Integration tests + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: true + matrix: + go: + - 1.15.11 + os: + - ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Install Go toolchain + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go }} + + - name: Get dependencies + run: | + go mod download + + - name: Run tests + run: | + go test -v ./... diff --git a/Makefile b/Makefile index d5037e7..728b3f3 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,7 @@ LEDGER_ENABLED := false # Common vars DOCKER := $(shell which docker) +PROTOC := $(shell which protoc) # Build version @@ -84,6 +85,22 @@ lint: @echo "--> Running Golang linter (unused variable / function warning are skipped)" @golangci-lint run --exclude 'unused' +tests: + @echo "--> Running tests" + go test ./... -v + proto-gen: + @echo "--> Generating DVM Protobuf files" + @#mkdir -p $(CURDIR)/pkg/types/dvm_proto/types_grpc + @#mkdir -p $(CURDIR)/pkg/types/dvm_proto/compiler_grpc + @#mkdir -p $(CURDIR)/pkg/types/dvm_proto/ds_grpc + @#mkdir -p $(CURDIR)/pkg/types/dvm_proto/metadata_grpc + @#mkdir -p $(CURDIR)/pkg/types/dvm_proto/vm_grpc + @#$(PROTOC) --proto_path=$(CURDIR)/third_party/proto/dvm_proto --go_out=plugins=grpc:$(CURDIR)/pkg/types/dvm_proto/types_grpc --go_opt=paths=source_relative $(CURDIR)/third_party/proto/dvm_proto/common-types.proto + @#$(PROTOC) --proto_path=$(CURDIR)/third_party/proto/dvm_proto --go_out=plugins=grpc:$(CURDIR)/pkg/types/dvm_proto/compiler_grpc --go_opt=paths=source_relative $(CURDIR)/third_party/proto/dvm_proto/compiler.proto + @#$(PROTOC) --proto_path=$(CURDIR)/third_party/proto/dvm_proto --go_out=plugins=grpc:$(CURDIR)/pkg/types/dvm_proto/ds_grpc --go_opt=paths=source_relative $(CURDIR)/third_party/proto/dvm_proto/data-source.proto + @#$(PROTOC) --proto_path=$(CURDIR)/third_party/proto/dvm_proto --go_out=plugins=grpc:$(CURDIR)/pkg/types/dvm_proto/metadata_grpc --go_opt=paths=source_relative $(CURDIR)/third_party/proto/dvm_proto/metadata.proto + @#$(PROTOC) --proto_path=$(CURDIR)/third_party/proto/dvm_proto --go_out=plugins=grpc:$(CURDIR)/pkg/types/dvm_proto/vm_grpc --go_opt=paths=source_relative $(CURDIR)/third_party/proto/dvm_proto/vm.proto + @echo "--> Generating Protobuf files" $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace tendermintdev/sdk-proto-gen sh ./scripts/protocgen.sh diff --git a/app/app.go b/app/app.go index 4f13044..f7f4ed8 100644 --- a/app/app.go +++ b/app/app.go @@ -1,14 +1,19 @@ package app import ( + "fmt" "io" + "math/big" + "net" "net/http" + "time" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/simapp" "github.com/gorilla/mux" "github.com/rakyll/statik/fs" + "google.golang.org/grpc" abci "github.com/tendermint/tendermint/abci/types" tmJson "github.com/tendermint/tendermint/libs/json" @@ -83,6 +88,12 @@ import ( upgradeKeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper" upgradeTypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + "github.com/dfinance/dstation/pkg" + "github.com/dfinance/dstation/x/vm" + vmConfig "github.com/dfinance/dstation/x/vm/config" + vmKeeper "github.com/dfinance/dstation/x/vm/keeper" + vmTypes "github.com/dfinance/dstation/x/vm/types" + // unnamed import of statik for swagger UI support _ "github.com/cosmos/cosmos-sdk/client/docs/statik" ) @@ -112,6 +123,7 @@ var ( evidence.AppModuleBasic{}, transfer.AppModuleBasic{}, vesting.AppModuleBasic{}, + vm.AppModuleBasic{}, ) // module account permissions @@ -123,6 +135,7 @@ var ( stakingTypes.NotBondedPoolName: {authTypes.Burner, authTypes.Staking}, govTypes.ModuleName: {authTypes.Burner}, ibcTransferTypes.ModuleName: {authTypes.Minter, authTypes.Burner}, + vmTypes.DelPoolName: {authTypes.Staking}, } ) @@ -162,6 +175,7 @@ type DnApp struct { // nolint: golint IBCKeeper *ibcKeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly EvidenceKeeper evidenceKeeper.Keeper TransferKeeper ibcTransferKeeper.Keeper + VmKeeper vmKeeper.Keeper // make scoped keepers public for test purposes ScopedIBCKeeper capabilityKeeper.ScopedKeeper @@ -172,6 +186,11 @@ type DnApp struct { // nolint: golint // simulation manager sm *module.SimulationManager + + // vm connections + vmConfig *vmConfig.VMConfig + vmConn *grpc.ClientConn + dsListener net.Listener } // Name returns the name of the App. @@ -297,10 +316,66 @@ func (app *DnApp) RegisterTendermintService(clientCtx client.Context) { tmservice.RegisterTendermintService(app.BaseApp.GRPCQueryRouter(), clientCtx, app.interfaceRegistry) } +// Initialize connection to VM server. +func (app *DnApp) InitializeVMConnection(addr string, appOpts serverTypes.AppOptions) { + // Custom (used for mock connection) + if obj := appOpts.Get(FlagCustomVMConnection); obj != nil { + conn, ok := obj.(*grpc.ClientConn) + if !ok { + panic(fmt.Errorf("%s appOpt: type assertion failed: %T", FlagCustomVMConnection, obj)) + } + app.vmConn = conn + return + } + + // gRPC connection + app.Logger().Info(fmt.Sprintf("Creating VM connection, address: %s", addr)) + conn, err := pkg.GetGRpcClientConnection(addr, 1*time.Second) + if err != nil { + panic(err) + } + app.vmConn = conn + + app.Logger().Info(fmt.Sprintf("Non-blocking connection initialized, status: %s", app.vmConn.GetState())) +} + +// Initialize listener to listen for connections from VM for data server. +func (app *DnApp) InitializeVMDataServer(addr string, appOpts serverTypes.AppOptions) { + // Custom (used for mock connection) + if obj := appOpts.Get(FlagCustomDSListener); obj != nil { + listener, ok := obj.(net.Listener) + if !ok { + panic(fmt.Errorf("%s appOpt: type assertion failed: %T", FlagCustomDSListener, obj)) + } + app.dsListener = listener + return + } + + app.Logger().Info(fmt.Sprintf("Starting VM data server listener, address: %s", addr)) + listener, err := pkg.GetGRpcNetListener(addr) + if err != nil { + panic(err) + } + app.dsListener = listener + + app.Logger().Info("VM data server is running") +} + +// CloseConnections closes VM connection and stops DS server. +func (app DnApp) CloseConnections() { + app.VmKeeper.StopDSServer() + if app.dsListener != nil { + app.dsListener.Close() + } + if app.vmConn != nil { + app.vmConn.Close() + } +} + // NewDnApp returns a reference to an initialized Dnode service. func NewDnApp( logger log.Logger, db tmDb.DB, traceStore io.Writer, loadLatest bool, skipUpgradeHeights map[int64]bool, - homePath string, invCheckPeriod uint, encodingConfig EncodingConfig, appOpts serverTypes.AppOptions, baseAppOptions ...func(*baseapp.BaseApp), + homePath string, invCheckPeriod uint, encodingConfig EncodingConfig, vmConfig *vmConfig.VMConfig, appOpts serverTypes.AppOptions, baseAppOptions ...func(*baseapp.BaseApp), ) *DnApp { appCodec := encodingConfig.Marshaler @@ -317,6 +392,7 @@ func NewDnApp( mintTypes.StoreKey, distrTypes.StoreKey, slashingTypes.StoreKey, govTypes.StoreKey, paramsTypes.StoreKey, ibcHost.StoreKey, upgradeTypes.StoreKey, evidenceTypes.StoreKey, ibcTransferTypes.StoreKey, capabilityTypes.StoreKey, + vmTypes.StoreKey, ) tkeys := sdk.NewTransientStoreKeys(paramsTypes.TStoreKey) memKeys := sdk.NewMemoryStoreKeys(capabilityTypes.MemStoreKey) @@ -330,8 +406,17 @@ func NewDnApp( keys: keys, tkeys: tkeys, memKeys: memKeys, + vmConfig: vmConfig, } + // Initialize VM connections + app.InitializeVMDataServer(vmConfig.DataListen, appOpts) + app.InitializeVMConnection(vmConfig.Address, appOpts) + + // Reduce ConsensusPower reduction coefficient (1 xfi == 1 power unit) + // 1 xfi == 1000000000000000000 (exp == 18) + sdk.PowerReduction = sdk.NewIntFromBigInt(new(big.Int).Exp(big.NewInt(10), big.NewInt(18), nil)) + app.ParamsKeeper = initParamsKeeper(appCodec, legacyAmino, keys[paramsTypes.StoreKey], tkeys[paramsTypes.TStoreKey]) // set the BaseApp's parameter store bApp.SetParamStore(app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramsKeeper.ConsensusParamsKeyTable())) @@ -341,7 +426,7 @@ func NewDnApp( scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibcHost.ModuleName) scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibcTransferTypes.ModuleName) - // add keepers + // Add keepers app.AccountKeeper = authKeeper.NewAccountKeeper( appCodec, keys[authTypes.StoreKey], app.GetSubspace(authTypes.ModuleName), authTypes.ProtoBaseAccount, maccPerms, ) @@ -367,7 +452,7 @@ func NewDnApp( ) app.UpgradeKeeper = upgradeKeeper.NewKeeper(skipUpgradeHeights, keys[upgradeTypes.StoreKey], appCodec, homePath) - // register the staking hooks + // Register the staking hooks // NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks app.StakingKeeper = *stakingKeeper.SetHooks( stakingTypes.NewMultiStakingHooks(app.DistrKeeper.Hooks(), app.SlashingKeeper.Hooks()), @@ -378,13 +463,18 @@ func NewDnApp( appCodec, keys[ibcHost.StoreKey], app.GetSubspace(ibcHost.ModuleName), app.StakingKeeper, scopedIBCKeeper, ) - // register the proposal types + app.VmKeeper = vmKeeper.NewKeeper( + appCodec, keys[vmTypes.StoreKey], app.vmConn, app.dsListener, app.vmConfig, app.AccountKeeper, app.BankKeeper, + ) + + // Register the proposal types govRouter := govTypes.NewRouter() govRouter.AddRoute(govTypes.RouterKey, govTypes.ProposalHandler). AddRoute(paramsProposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)). AddRoute(distrTypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.DistrKeeper)). AddRoute(upgradeTypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)). - AddRoute(ibcHost.RouterKey, ibcClient.NewClientUpdateProposalHandler(app.IBCKeeper.ClientKeeper)) + AddRoute(ibcHost.RouterKey, ibcClient.NewClientUpdateProposalHandler(app.IBCKeeper.ClientKeeper)). + AddRoute(vmTypes.RouterKey, vm.NewGovHandler(app.VmKeeper)) app.GovKeeper = govKeeper.NewKeeper( appCodec, keys[govTypes.StoreKey], app.GetSubspace(govTypes.ModuleName), app.AccountKeeper, app.BankKeeper, &stakingKeeper, govRouter, @@ -418,9 +508,6 @@ func NewDnApp( skipGenesisInvariants = opt } - // NOTE: Any module instantiated in the module manager that is later modified - // must be passed by reference here. - // NOTE: Any module instantiated in the module manager that is later modified // must be passed by reference here. app.mm = module.NewManager( @@ -443,6 +530,7 @@ func NewDnApp( ibc.NewAppModule(app.IBCKeeper), params.NewAppModule(app.ParamsKeeper), transferModule, + vm.NewAppModule(appCodec, app.VmKeeper, app.AccountKeeper, app.BankKeeper), ) // During begin block slashing happens after distr.BeginBlocker so that @@ -450,10 +538,20 @@ func NewDnApp( // CanWithdrawInvariant invariant. // NOTE: staking module is required if HistoricalEntries param > 0 app.mm.SetOrderBeginBlockers( - upgradeTypes.ModuleName, mintTypes.ModuleName, distrTypes.ModuleName, slashingTypes.ModuleName, - evidenceTypes.ModuleName, stakingTypes.ModuleName, ibcHost.ModuleName, + upgradeTypes.ModuleName, + mintTypes.ModuleName, + distrTypes.ModuleName, + slashingTypes.ModuleName, + evidenceTypes.ModuleName, + stakingTypes.ModuleName, + ibcHost.ModuleName, + vmTypes.ModuleName, + ) + app.mm.SetOrderEndBlockers( + crisisTypes.ModuleName, + govTypes.ModuleName, + stakingTypes.ModuleName, ) - app.mm.SetOrderEndBlockers(crisisTypes.ModuleName, govTypes.ModuleName, stakingTypes.ModuleName) // NOTE: The genutils module must occur after staking so that pools are // properly initialized with tokens from genesis accounts. @@ -461,9 +559,20 @@ func NewDnApp( // so that other modules that want to create or claim capabilities afterwards in InitChain // can do so safely. app.mm.SetOrderInitGenesis( - capabilityTypes.ModuleName, authTypes.ModuleName, bankTypes.ModuleName, distrTypes.ModuleName, stakingTypes.ModuleName, - slashingTypes.ModuleName, govTypes.ModuleName, mintTypes.ModuleName, crisisTypes.ModuleName, - ibcHost.ModuleName, genutilTypes.ModuleName, evidenceTypes.ModuleName, ibcTransferTypes.ModuleName, + capabilityTypes.ModuleName, + authTypes.ModuleName, + bankTypes.ModuleName, + distrTypes.ModuleName, + stakingTypes.ModuleName, + slashingTypes.ModuleName, + govTypes.ModuleName, + mintTypes.ModuleName, + crisisTypes.ModuleName, + ibcHost.ModuleName, + genutilTypes.ModuleName, + evidenceTypes.ModuleName, + ibcTransferTypes.ModuleName, + vmTypes.ModuleName, ) app.mm.RegisterInvariants(&app.CrisisKeeper) @@ -525,6 +634,9 @@ func NewDnApp( app.ScopedIBCKeeper = scopedIBCKeeper app.ScopedTransferKeeper = scopedTransferKeeper + // Start the VM data source server after all the initialization is done + app.VmKeeper.StartDSServer() + return app } diff --git a/app/options.go b/app/options.go new file mode 100644 index 0000000..c6a1a5e --- /dev/null +++ b/app/options.go @@ -0,0 +1,26 @@ +package app + +import ( + "github.com/cosmos/cosmos-sdk/baseapp" + + vmTypes "github.com/dfinance/dstation/x/vm/types" +) + +const ( + FlagCustomVMConnection = "custom-vm-connection" + FlagCustomDSListener = "custom-ds-listener" +) + +func VMCrashHandleBaseAppOption() func(*baseapp.BaseApp) { + return func(app *baseapp.BaseApp) { + app.AddRunTxRecoveryHandler(func(recoveryObj interface{}) error { + if err, ok := recoveryObj.(error); ok { + if vmTypes.ErrVMCrashed.Is(err) { + panic(recoveryObj) + } + } + + return nil + }) + } +} diff --git a/cmd/dstation/cmd/genesis.go b/cmd/dstation/cmd/genesis.go index 9528ac2..4a7e08e 100644 --- a/cmd/dstation/cmd/genesis.go +++ b/cmd/dstation/cmd/genesis.go @@ -1,6 +1,7 @@ package cmd import ( + "encoding/json" "fmt" "github.com/cosmos/cosmos-sdk/client" @@ -11,7 +12,9 @@ import ( "github.com/tendermint/tendermint/libs/cli" "github.com/tendermint/tendermint/types" + "github.com/dfinance/dstation/app" dnConfig "github.com/dfinance/dstation/cmd/dstation/config" + vmConfig "github.com/dfinance/dstation/x/vm/config" ) // SetGenesisDefaultsCmd returns set-genesis-defaults cobra Command. @@ -30,17 +33,35 @@ func SetGenesisDefaultsCmd(defaultNodeHome string) *cobra.Command { return fmt.Errorf("failed to read genesis doc from file: %w", err) } - appState, err := dnConfig.SetGenesisDefaults(clientCtx.JSONMarshaler.(codec.Marshaler), genDoc.AppState) + consParams, err := dnConfig.SetConsensusDefaults(genDoc.ConsensusParams) + if err != nil { + return fmt.Errorf("failed to set default consesnsus params:: %w", err) + } + genDoc.ConsensusParams = consParams + + var genState app.GenesisState + if err := json.Unmarshal(genDoc.AppState, &genState); err != nil { + return fmt.Errorf("genDoc.AppState json unmarshal: %w", err) + } + + appState, err := dnConfig.SetGenesisDefaults(clientCtx.JSONMarshaler.(codec.Marshaler), genState) if err != nil { return fmt.Errorf("failed to set default genesis params:: %w", err) } - genDoc.AppState = appState + + appStateBz, err := json.MarshalIndent(appState, "", " ") + if err != nil { + return fmt.Errorf("appState json marshal: %w", err) + } + genDoc.AppState = appStateBz if err = genutil.ExportGenesisFile(genDoc, genFile); err != nil { return fmt.Errorf("failed to export gensis file: %w", err) } - return clientCtx.PrintString(string(appState)) + vmConfig.ReadVMConfig(serverCtx.Config.RootDir) + + return clientCtx.PrintString(string(appStateBz)) }, } diff --git a/cmd/dstation/cmd/root.go b/cmd/dstation/cmd/root.go index b718d5a..9099bf5 100644 --- a/cmd/dstation/cmd/root.go +++ b/cmd/dstation/cmd/root.go @@ -1,9 +1,11 @@ package cmd import ( + "fmt" "io" "os" "path/filepath" + "strconv" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" @@ -23,18 +25,25 @@ import ( bankTypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/cosmos-sdk/x/crisis" genutilCli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli" + paramsCli "github.com/cosmos/cosmos-sdk/x/params/client/cli" "github.com/spf13/cast" "github.com/spf13/cobra" + "github.com/spf13/viper" tmCli "github.com/tendermint/tendermint/libs/cli" "github.com/tendermint/tendermint/libs/log" tmDb "github.com/tendermint/tm-db" "github.com/dfinance/dstation/app" - "github.com/dfinance/dstation/cmd/dstation/config" + dnConfig "github.com/dfinance/dstation/cmd/dstation/config" + vmConfig "github.com/dfinance/dstation/x/vm/config" ) // NewRootCmd creates a new root command for simd. It is called once in the main function. func NewRootCmd() (*cobra.Command, app.EncodingConfig) { + sdkConfig := sdk.GetConfig() + dnConfig.SetConfigBech32Prefixes(sdkConfig) + sdkConfig.Seal() + encodingConfig := app.MakeEncodingConfig() authClient.Codec = encodingConfig.Marshaler @@ -46,7 +55,7 @@ func NewRootCmd() (*cobra.Command, app.EncodingConfig) { WithInput(os.Stdin). WithAccountRetriever(types.AccountRetriever{}). WithBroadcastMode(flags.BroadcastBlock). - WithHomeDir(config.DefaultNodeHome) + WithHomeDir(dnConfig.DefaultNodeHome) rootCmd := &cobra.Command{ Use: "dstation", @@ -61,23 +70,23 @@ func NewRootCmd() (*cobra.Command, app.EncodingConfig) { } rootCmd.AddCommand( - genutilCli.InitCmd(app.ModuleBasics, config.DefaultNodeHome), - genutilCli.CollectGenTxsCmd(bankTypes.GenesisBalancesIterator{}, config.DefaultNodeHome), - genutilCli.GenTxCmd(app.ModuleBasics, encodingConfig.TxConfig, bankTypes.GenesisBalancesIterator{}, config.DefaultNodeHome), + genutilCli.InitCmd(app.ModuleBasics, dnConfig.DefaultNodeHome), + genutilCli.CollectGenTxsCmd(bankTypes.GenesisBalancesIterator{}, dnConfig.DefaultNodeHome), + genutilCli.GenTxCmd(app.ModuleBasics, encodingConfig.TxConfig, bankTypes.GenesisBalancesIterator{}, dnConfig.DefaultNodeHome), genutilCli.ValidateGenesisCmd(app.ModuleBasics), - SetGenesisDefaultsCmd(config.DefaultNodeHome), - AddGenesisAccountCmd(config.DefaultNodeHome), + SetGenesisDefaultsCmd(dnConfig.DefaultNodeHome), + AddGenesisAccountCmd(dnConfig.DefaultNodeHome), rpc.StatusCommand(), - keys.Commands(config.DefaultNodeHome), + keys.Commands(dnConfig.DefaultNodeHome), debug.Cmd(), tmCli.NewCompletionCmd(rootCmd, true), queryCommand(), txCommand(), ) - server.AddCommands(rootCmd, config.DefaultNodeHome, newApp, appExporter, serverFlags) + server.AddCommands(rootCmd, dnConfig.DefaultNodeHome, newApp, appExporter, serverFlags) return rootCmd, encodingConfig } @@ -87,17 +96,19 @@ func appExporter( logger log.Logger, db tmDb.DB, traceStore io.Writer, height int64, forZeroHeight bool, jailAllowedAddrs []string, appOpts serverTypes.AppOptions, ) (serverTypes.ExportedApp, error) { + vmConfig := vmConfig.ReadVMConfig(viper.GetString(flags.FlagHome)) + encCfg := app.MakeEncodingConfig() // Ideally, we would reuse the one created by NewRootCmd. encCfg.Marshaler = codec.NewProtoCodec(encCfg.InterfaceRegistry) var dnApp *app.DnApp if height != -1 { - dnApp = app.NewDnApp(logger, db, traceStore, false, map[int64]bool{}, "", cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)), encCfg, appOpts) + dnApp = app.NewDnApp(logger, db, traceStore, false, map[int64]bool{}, "", cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)), encCfg, &vmConfig, appOpts) if err := dnApp.LoadHeight(height); err != nil { return serverTypes.ExportedApp{}, err } } else { - dnApp = app.NewDnApp(logger, db, traceStore, true, map[int64]bool{}, "", cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)), encCfg, appOpts) + dnApp = app.NewDnApp(logger, db, traceStore, true, map[int64]bool{}, "", cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)), encCfg, &vmConfig, appOpts) } return dnApp.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs) @@ -153,18 +164,48 @@ func txCommand() *cobra.Command { authCmd.GetBroadcastCommand(), authCmd.GetEncodeCommand(), authCmd.GetDecodeCommand(), + paramsCli.NewSubmitParamChangeProposalTxCmd(), ) app.ModuleBasics.AddTxCommands(cmd) cmd.PersistentFlags().String(flags.FlagChainID, "", "The network chain ID") + setDefaultTxCmdFlags(cmd) return cmd } +// setDefaultTxCmdFlags overwrites tx command and it's sub-command flags. +func setDefaultTxCmdFlags(cmd *cobra.Command) { + if feesFlag := cmd.Flag(flags.FlagFees); feesFlag != nil { + feesFlag.DefValue = dnConfig.FeeCoin.String() + feesFlag.Usage = "Fees to pay along with transaction" + + if err := feesFlag.Value.Set(dnConfig.FeeCoin.String()); err != nil { + panic(fmt.Errorf("overwrite %s flag defaults for %s cmd: %w", flags.FlagFees, cmd.Name(), err)) + } + } + + if gasFlag := cmd.Flag(flags.FlagGas); gasFlag != nil { + defGasStr := strconv.Itoa(dnConfig.CliGas) + gasFlag.DefValue = defGasStr + gasFlag.Usage = fmt.Sprintf("gas limit to set per-transaction; set to %q to calculate sufficient gas automatically", flags.GasFlagAuto) + + if err := gasFlag.Value.Set(defGasStr); err != nil { + panic(fmt.Errorf("overwrite %s flag defaults for %s cmd: %w", flags.FlagGas, cmd.Name(), err)) + } + } + + for _, child := range cmd.Commands() { + setDefaultTxCmdFlags(child) + } +} + // newApp returns an AppCreator. func newApp(logger log.Logger, db tmDb.DB, traceStore io.Writer, appOpts serverTypes.AppOptions) serverTypes.Application { var cache sdk.MultiStorePersistentCache + vmConfig := vmConfig.ReadVMConfig(viper.GetString(flags.FlagHome)) + if cast.ToBool(appOpts.Get(server.FlagInterBlockCache)) { cache = store.NewCommitKVStoreCacheManager() } @@ -194,6 +235,7 @@ func newApp(logger log.Logger, db tmDb.DB, traceStore io.Writer, appOpts serverT cast.ToString(appOpts.Get(flags.FlagHome)), cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)), app.MakeEncodingConfig(), // Ideally, we would reuse the one created by NewRootCmd. + &vmConfig, appOpts, baseapp.SetPruning(pruningOpts), baseapp.SetMinGasPrices(cast.ToString(appOpts.Get(server.FlagMinGasPrices))), @@ -206,5 +248,6 @@ func newApp(logger log.Logger, db tmDb.DB, traceStore io.Writer, appOpts serverT baseapp.SetSnapshotStore(snapshotStore), baseapp.SetSnapshotInterval(cast.ToUint64(appOpts.Get(server.FlagStateSyncSnapshotInterval))), baseapp.SetSnapshotKeepRecent(cast.ToUint32(appOpts.Get(server.FlagStateSyncSnapshotKeepRecent))), + app.VMCrashHandleBaseAppOption(), ) } diff --git a/cmd/dstation/config/bech32.go b/cmd/dstation/config/bech32.go new file mode 100644 index 0000000..3d0a2eb --- /dev/null +++ b/cmd/dstation/config/bech32.go @@ -0,0 +1,20 @@ +package config + +import sdk "github.com/cosmos/cosmos-sdk/types" + +const ( + MainPrefix = "wallet" // Main prefix for all addresses. + Bech32PrefixAccAddr = MainPrefix // Bech32 prefix for account addresses. + Bech32PrefixAccPub = MainPrefix + sdk.PrefixPublic // Bech32 prefix for accounts pub keys. + Bech32PrefixValAddr = MainPrefix + sdk.PrefixValidator + sdk.PrefixOperator // Bech32 prefix for validators addresses. + Bech32PrefixValPub = MainPrefix + sdk.PrefixValidator + sdk.PrefixOperator + sdk.PrefixPublic // Bech32 prefix for validator pub keys. + Bech32PrefixConsAddr = MainPrefix + sdk.PrefixValidator + sdk.PrefixConsensus // Bech32 prefix for consensus addresses. + Bech32PrefixConsPub = MainPrefix + sdk.PrefixValidator + sdk.PrefixConsensus + sdk.PrefixPublic // Bech32 prefix for consensus pub keys. +) + +// SetConfigBech32Prefixes sets default SDK config Bech32 prefixes. +func SetConfigBech32Prefixes(config *sdk.Config) { + config.SetBech32PrefixForAccount(Bech32PrefixAccAddr, Bech32PrefixAccPub) + config.SetBech32PrefixForValidator(Bech32PrefixValAddr, Bech32PrefixValPub) + config.SetBech32PrefixForConsensusNode(Bech32PrefixConsAddr, Bech32PrefixConsPub) +} diff --git a/cmd/dstation/config/common.go b/cmd/dstation/config/common.go index cc3652f..f002f60 100644 --- a/cmd/dstation/config/common.go +++ b/cmd/dstation/config/common.go @@ -1,7 +1,6 @@ package config import ( - "encoding/json" "fmt" stdlog "log" "os" @@ -14,13 +13,17 @@ import ( govTypes "github.com/cosmos/cosmos-sdk/x/gov/types" mintTypes "github.com/cosmos/cosmos-sdk/x/mint/types" stakingTypes "github.com/cosmos/cosmos-sdk/x/staking/types" + tmProto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/dfinance/dstation/app" ) // Chain defaults const ( - MainDenom = "xfi" // 12 decimals + MainDenom = "xfi" // 18 decimals + EthDenom = "eth" // 18 decimals + BtcDenom = "btc" // 8 decimals + UsdtDenom = "usdt" // 6 decimals // Min TX fee FeeAmount = "100000000000000" // 0.0001 @@ -29,7 +32,8 @@ const ( // Crisis: invariants check TX fee InvariantCheckAmount = "1000000000000000000000" // 1000.0 - MaxGas = 10000000 + CliGas = 500000 // Gas CLI flag default + MaxGas = 10000000 // Gas limit for block ) var ( @@ -41,13 +45,22 @@ var ( InvariantCheckCoin sdk.Coin ) -// SetGenesisDefaults takes default app genesis state and overwrites Cosmos SDK / Dfinance params. -func SetGenesisDefaults(cdc codec.Marshaler, appStateBz json.RawMessage) (json.RawMessage, error) { - var genState app.GenesisState - if err := json.Unmarshal(appStateBz, &genState); err != nil { - return nil, fmt.Errorf("appStateBz json unmarshal: %w", err) +// SetConsensusDefaults takes default consensus params and overwrites Cosmos SDK. +func SetConsensusDefaults(params *tmProto.ConsensusParams) (*tmProto.ConsensusParams, error) { + if params == nil { + return nil, fmt.Errorf("params: nil") } + // Block + { + params.Block.MaxGas = MaxGas + } + + return params, nil +} + +// SetGenesisDefaults takes default app genesis state and overwrites Cosmos SDK / Dfinance params. +func SetGenesisDefaults(cdc codec.Marshaler, genState app.GenesisState) (app.GenesisState, error) { // Bank module genesis { moduleName, moduleState := bankTypes.ModuleName, bankTypes.GenesisState{} @@ -324,12 +337,7 @@ func SetGenesisDefaults(cdc codec.Marshaler, appStateBz json.RawMessage) (json.R } } - genStateBz, err := json.MarshalIndent(genState, "", " ") - if err != nil { - return nil, fmt.Errorf("genState json marshal: %w", err) - } - - return genStateBz, nil + return genState, nil } func init() { diff --git a/docs/proto/proto-docs.md b/docs/proto/proto-docs.md new file mode 100644 index 0000000..049dc35 --- /dev/null +++ b/docs/proto/proto-docs.md @@ -0,0 +1,1504 @@ + +# Protobuf Documentation + + +## Table of Contents + +- [dfinance/dvm/common-types.proto](#dfinance/dvm/common-types.proto) + - [u128](#dfinance.dvm.u128) + + - [VMTypeTag](#dfinance.dvm.VMTypeTag) + +- [dfinance/dvm/compiler.proto](#dfinance/dvm/compiler.proto) + - [CompilationResult](#dfinance.dvm.CompilationResult) + - [CompilationUnit](#dfinance.dvm.CompilationUnit) + - [CompiledUnit](#dfinance.dvm.CompiledUnit) + - [SourceFiles](#dfinance.dvm.SourceFiles) + + - [DvmCompiler](#dfinance.dvm.DvmCompiler) + +- [dfinance/dvm/data-source.proto](#dfinance/dvm/data-source.proto) + - [CurrencyInfo](#dfinance.dvm.CurrencyInfo) + - [CurrencyInfoRequest](#dfinance.dvm.CurrencyInfoRequest) + - [CurrencyInfoResponse](#dfinance.dvm.CurrencyInfoResponse) + - [DSAccessPath](#dfinance.dvm.DSAccessPath) + - [DSAccessPaths](#dfinance.dvm.DSAccessPaths) + - [DSRawResponse](#dfinance.dvm.DSRawResponse) + - [DSRawResponses](#dfinance.dvm.DSRawResponses) + - [NativeBalanceRequest](#dfinance.dvm.NativeBalanceRequest) + - [NativeBalanceResponse](#dfinance.dvm.NativeBalanceResponse) + - [OraclePriceRequest](#dfinance.dvm.OraclePriceRequest) + - [OraclePriceResponse](#dfinance.dvm.OraclePriceResponse) + + - [ErrorCode](#dfinance.dvm.ErrorCode) + + - [DSService](#dfinance.dvm.DSService) + +- [dfinance/dvm/metadata.proto](#dfinance/dvm/metadata.proto) + - [Bytecode](#dfinance.dvm.Bytecode) + - [Field](#dfinance.dvm.Field) + - [Function](#dfinance.dvm.Function) + - [Metadata](#dfinance.dvm.Metadata) + - [ModuleMeta](#dfinance.dvm.ModuleMeta) + - [ScriptMeta](#dfinance.dvm.ScriptMeta) + - [Struct](#dfinance.dvm.Struct) + + - [DVMBytecodeMetadata](#dfinance.dvm.DVMBytecodeMetadata) + +- [dfinance/dvm/vm.proto](#dfinance/dvm/vm.proto) + - [Abort](#dfinance.dvm.Abort) + - [AbortLocation](#dfinance.dvm.AbortLocation) + - [Failure](#dfinance.dvm.Failure) + - [FunctionLoc](#dfinance.dvm.FunctionLoc) + - [LcsTag](#dfinance.dvm.LcsTag) + - [Message](#dfinance.dvm.Message) + - [ModuleIdent](#dfinance.dvm.ModuleIdent) + - [MoveError](#dfinance.dvm.MoveError) + - [MultipleCompilationResult](#dfinance.dvm.MultipleCompilationResult) + - [StructIdent](#dfinance.dvm.StructIdent) + - [VMAccessPath](#dfinance.dvm.VMAccessPath) + - [VMArgs](#dfinance.dvm.VMArgs) + - [VMBalanceChange](#dfinance.dvm.VMBalanceChange) + - [VMBalanceChangeSet](#dfinance.dvm.VMBalanceChangeSet) + - [VMEvent](#dfinance.dvm.VMEvent) + - [VMExecuteResponse](#dfinance.dvm.VMExecuteResponse) + - [VMExecuteScript](#dfinance.dvm.VMExecuteScript) + - [VMPublishModule](#dfinance.dvm.VMPublishModule) + - [VMStatus](#dfinance.dvm.VMStatus) + - [VMValue](#dfinance.dvm.VMValue) + + - [LcsType](#dfinance.dvm.LcsType) + - [VmWriteOp](#dfinance.dvm.VmWriteOp) + + - [VMModulePublisher](#dfinance.dvm.VMModulePublisher) + - [VMScriptExecutor](#dfinance.dvm.VMScriptExecutor) + +- [dfinance/vm/genesis.proto](#dfinance/vm/genesis.proto) + - [GenesisState](#dfinance.vm.v1beta1.GenesisState) + - [GenesisState.WriteOp](#dfinance.vm.v1beta1.GenesisState.WriteOp) + +- [dfinance/vm/gov.proto](#dfinance/vm/gov.proto) + - [PlannedProposal](#dfinance.vm.v1beta1.PlannedProposal) + - [StdLibUpdateProposal](#dfinance.vm.v1beta1.StdLibUpdateProposal) + +- [dfinance/vm/vm.proto](#dfinance/vm/vm.proto) + - [CompiledItem](#dfinance.vm.v1beta1.CompiledItem) + - [MsgDeployModule](#dfinance.vm.v1beta1.MsgDeployModule) + - [MsgExecuteScript](#dfinance.vm.v1beta1.MsgExecuteScript) + - [MsgExecuteScript.ScriptArg](#dfinance.vm.v1beta1.MsgExecuteScript.ScriptArg) + - [TxVmStatus](#dfinance.vm.v1beta1.TxVmStatus) + - [VmStatus](#dfinance.vm.v1beta1.VmStatus) + + - [CompiledItem.CodeType](#dfinance.vm.v1beta1.CompiledItem.CodeType) + +- [dfinance/vm/query.proto](#dfinance/vm/query.proto) + - [QueryCompileRequest](#dfinance.vm.v1beta1.QueryCompileRequest) + - [QueryCompileResponse](#dfinance.vm.v1beta1.QueryCompileResponse) + - [QueryDataRequest](#dfinance.vm.v1beta1.QueryDataRequest) + - [QueryDataResponse](#dfinance.vm.v1beta1.QueryDataResponse) + - [QueryDelegatedPoolSupplyRequest](#dfinance.vm.v1beta1.QueryDelegatedPoolSupplyRequest) + - [QueryDelegatedPoolSupplyResponse](#dfinance.vm.v1beta1.QueryDelegatedPoolSupplyResponse) + - [QueryMetadataRequest](#dfinance.vm.v1beta1.QueryMetadataRequest) + - [QueryMetadataResponse](#dfinance.vm.v1beta1.QueryMetadataResponse) + - [QueryTxVmStatusRequest](#dfinance.vm.v1beta1.QueryTxVmStatusRequest) + - [QueryTxVmStatusResponse](#dfinance.vm.v1beta1.QueryTxVmStatusResponse) + + - [Query](#dfinance.vm.v1beta1.Query) + +- [dfinance/vm/tx.proto](#dfinance/vm/tx.proto) + - [MsgDeployModuleResponse](#dfinance.vm.v1beta1.MsgDeployModuleResponse) + - [MsgExecuteScriptResponse](#dfinance.vm.v1beta1.MsgExecuteScriptResponse) + + - [Msg](#dfinance.vm.v1beta1.Msg) + +- [Scalar Value Types](#scalar-value-types) + + + + +

Top

+ +## dfinance/dvm/common-types.proto + + + + + +### u128 +u128 type. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `buf` | [bytes](#bytes) | | Little-endian unsigned 128. | + + + + + + + + + + +### VMTypeTag +Type of contract argument. + +| Name | Number | Description | +| ---- | ------ | ----------- | +| Bool | 0 | Bool 0x0 - false, 0x1 - true. | +| U64 | 1 | Uint64. Little-endian unsigned 64 bits integer. | +| Vector | 2 | Vector of bytes. | +| Address | 3 | Address, in bech32 form. 20 bytes. | +| U8 | 4 | U8 | +| U128 | 5 | U128 Little-endian unsigned 128 bits integer. | + + + + + + + + + + + +

Top

+ +## dfinance/dvm/compiler.proto + + + + + +### CompilationResult + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `units` | [CompiledUnit](#dfinance.dvm.CompiledUnit) | repeated | | +| `errors` | [string](#string) | repeated | list of error messages, empty if successful | + + + + + + + + +### CompilationUnit +Compilation unit. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `text` | [string](#string) | | utf8 encoded source code with libra/bech32 addresses | +| `name` | [string](#string) | | name of the unit. | + + + + + + + + +### CompiledUnit +Compiled source. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `name` | [string](#string) | | name of the module/script. | +| `bytecode` | [bytes](#bytes) | | bytecode of the compiled module/script | + + + + + + + + +### SourceFiles +Compiler API + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `units` | [CompilationUnit](#dfinance.dvm.CompilationUnit) | repeated | Compilation units. | +| `address` | [bytes](#bytes) | | address of the sender, in bech32 form | + + + + + + + + + + + + + + +### DvmCompiler + + +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `Compile` | [SourceFiles](#dfinance.dvm.SourceFiles) | [CompilationResult](#dfinance.dvm.CompilationResult) | | | + + + + + + +

Top

+ +## dfinance/dvm/data-source.proto + + + + + +### CurrencyInfo + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `denom` | [bytes](#bytes) | | | +| `decimals` | [uint32](#uint32) | | | +| `is_token` | [bool](#bool) | | | +| `address` | [bytes](#bytes) | | | +| `total_supply` | [u128](#dfinance.dvm.u128) | | | + + + + + + + + +### CurrencyInfoRequest + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `ticker` | [string](#string) | | | + + + + + + + + +### CurrencyInfoResponse + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `info` | [CurrencyInfo](#dfinance.dvm.CurrencyInfo) | | | +| `error_code` | [ErrorCode](#dfinance.dvm.ErrorCode) | | | +| `error_message` | [string](#string) | | error message from libra, empty if ErrorCode::None | + + + + + + + + +### DSAccessPath + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `address` | [bytes](#bytes) | | AccountAddress | +| `path` | [bytes](#bytes) | | | + + + + + + + + +### DSAccessPaths + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `paths` | [DSAccessPath](#dfinance.dvm.DSAccessPath) | repeated | | + + + + + + + + +### DSRawResponse + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `blob` | [bytes](#bytes) | | | +| `error_code` | [ErrorCode](#dfinance.dvm.ErrorCode) | | | +| `error_message` | [string](#string) | | error message from libra, empty if ErrorCode::None | + + + + + + + + +### DSRawResponses + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `blobs` | [bytes](#bytes) | repeated | | + + + + + + + + +### NativeBalanceRequest + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `address` | [bytes](#bytes) | | | +| `ticker` | [string](#string) | | | + + + + + + + + +### NativeBalanceResponse + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `balance` | [u128](#dfinance.dvm.u128) | | | +| `error_code` | [ErrorCode](#dfinance.dvm.ErrorCode) | | | +| `error_message` | [string](#string) | | error message from libra, empty if ErrorCode::None | + + + + + + + + +### OraclePriceRequest + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `currency_1` | [string](#string) | | | +| `currency_2` | [string](#string) | | | + + + + + + + + +### OraclePriceResponse + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `price` | [u128](#dfinance.dvm.u128) | | | +| `error_code` | [ErrorCode](#dfinance.dvm.ErrorCode) | | | +| `error_message` | [string](#string) | | error message from libra, empty if ErrorCode::None | + + + + + + + + + + +### ErrorCode + + +| Name | Number | Description | +| ---- | ------ | ----------- | +| NONE | 0 | no error | +| BAD_REQUEST | 1 | crash of compilation, logs will show stacktrace | +| NO_DATA | 2 | no such module | + + + + + + + + + +### DSService +GRPC service + +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `GetRaw` | [DSAccessPath](#dfinance.dvm.DSAccessPath) | [DSRawResponse](#dfinance.dvm.DSRawResponse) | | | +| `MultiGetRaw` | [DSAccessPaths](#dfinance.dvm.DSAccessPaths) | [DSRawResponses](#dfinance.dvm.DSRawResponses) | | | +| `GetOraclePrice` | [OraclePriceRequest](#dfinance.dvm.OraclePriceRequest) | [OraclePriceResponse](#dfinance.dvm.OraclePriceResponse) | | | +| `GetNativeBalance` | [NativeBalanceRequest](#dfinance.dvm.NativeBalanceRequest) | [NativeBalanceResponse](#dfinance.dvm.NativeBalanceResponse) | | | +| `GetCurrencyInfo` | [CurrencyInfoRequest](#dfinance.dvm.CurrencyInfoRequest) | [CurrencyInfoResponse](#dfinance.dvm.CurrencyInfoResponse) | | | + + + + + + +

Top

+ +## dfinance/dvm/metadata.proto + + + + + +### Bytecode +Bytecode. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `code` | [bytes](#bytes) | | bytecode of script | + + + + + + + + +### Field +Struct field. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `name` | [string](#string) | | | +| `type` | [string](#string) | | | + + + + + + + + +### Function +Function representation. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `name` | [string](#string) | | | +| `isPublic` | [bool](#bool) | | | +| `isNative` | [bool](#bool) | | | +| `type_parameters` | [string](#string) | repeated | | +| `arguments` | [string](#string) | repeated | | +| `returns` | [string](#string) | repeated | | + + + + + + + + +### Metadata +Bytecode metadata. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `script` | [ScriptMeta](#dfinance.dvm.ScriptMeta) | | In case the provided bytecode is a script. | +| `module` | [ModuleMeta](#dfinance.dvm.ModuleMeta) | | In case the provided bytecode is a module. | + + + + + + + + +### ModuleMeta +Module metadata. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `name` | [string](#string) | | module name. | +| `types` | [Struct](#dfinance.dvm.Struct) | repeated | Types defined in a module. | +| `functions` | [Function](#dfinance.dvm.Function) | repeated | Functions defined in a module. | + + + + + + + + +### ScriptMeta +Script metadata. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `signers_count` | [uint32](#uint32) | | | +| `type_parameters` | [string](#string) | repeated | | +| `arguments` | [VMTypeTag](#dfinance.dvm.VMTypeTag) | repeated | | + + + + + + + + +### Struct +Struct representation. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `name` | [string](#string) | | | +| `isResource` | [bool](#bool) | | | +| `type_parameters` | [string](#string) | repeated | | +| `field` | [Field](#dfinance.dvm.Field) | repeated | | + + + + + + + + + + + + + + +### DVMBytecodeMetadata +Returns bytecode metadata. + +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `GetMetadata` | [Bytecode](#dfinance.dvm.Bytecode) | [Metadata](#dfinance.dvm.Metadata) | | | + + + + + + +

Top

+ +## dfinance/dvm/vm.proto + + + + + +### Abort +VmStatus `MoveAbort` case. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `abort_location` | [AbortLocation](#dfinance.dvm.AbortLocation) | | Abort location. (optional). Null if abort occurred in the script. | +| `abort_code` | [uint64](#uint64) | | Abort code. | + + + + + + + + +### AbortLocation +An `AbortLocation` specifies where a Move program `abort` occurred, either in a function in +a module, or in a script. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `address` | [bytes](#bytes) | | Indicates `abort` occurred in the specified module. | +| `module` | [string](#string) | | Indicates the `abort` occurred in a script. | + + + + + + + + +### Failure +VmStatus `ExecutionFailure` case. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `status_code` | [uint64](#uint64) | | Status code. | +| `abort_location` | [AbortLocation](#dfinance.dvm.AbortLocation) | | Abort location. (optional). Null if abort occurred in the script. | +| `function_loc` | [FunctionLoc](#dfinance.dvm.FunctionLoc) | | Function location. | + + + + + + + + +### FunctionLoc +Function location. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `function` | [uint64](#uint64) | | Function index. | +| `code_offset` | [uint64](#uint64) | | Code offset. | + + + + + + + + +### LcsTag + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `type_tag` | [LcsType](#dfinance.dvm.LcsType) | | type tag. | +| `vector_type` | [LcsTag](#dfinance.dvm.LcsTag) | | vector type. Has a non-null value if the type_tag is equal to a LcsVector. | +| `struct_ident` | [StructIdent](#dfinance.dvm.StructIdent) | | struct identifier. Has a non-null value if the type_tag is equal to a LcsStruct. | + + + + + + + + +### Message +Message. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `text` | [string](#string) | | Message with error details if needed. | + + + + + + + + +### ModuleIdent +Module identifier. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `address` | [bytes](#bytes) | | module address. | +| `name` | [string](#string) | | module name. | + + + + + + + + +### MoveError +VmStatus `Error` case. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `status_code` | [uint64](#uint64) | | Status code. | + + + + + + + + +### MultipleCompilationResult + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `units` | [CompiledUnit](#dfinance.dvm.CompiledUnit) | repeated | | +| `errors` | [string](#string) | repeated | list of error messages, empty if successful | + + + + + + + + +### StructIdent +Full name of the structure. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `address` | [bytes](#bytes) | | address of module owner | +| `module` | [string](#string) | | module name. | +| `name` | [string](#string) | | name of structure. | +| `type_params` | [LcsTag](#dfinance.dvm.LcsTag) | repeated | Structure type parameters. | + + + + + + + + +### VMAccessPath +Storage path + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `address` | [bytes](#bytes) | | account address. | +| `path` | [bytes](#bytes) | | storage path. | + + + + + + + + +### VMArgs +Contract arguments. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `type` | [VMTypeTag](#dfinance.dvm.VMTypeTag) | | Argument type. | +| `value` | [bytes](#bytes) | | Argument value. | + + + + + + + + +### VMBalanceChange + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `address` | [bytes](#bytes) | | | +| `ticker` | [string](#string) | | | +| `deposit` | [u128](#dfinance.dvm.u128) | | | +| `withdraw` | [u128](#dfinance.dvm.u128) | | | + + + + + + + + +### VMBalanceChangeSet + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `change_set` | [VMBalanceChange](#dfinance.dvm.VMBalanceChange) | repeated | | + + + + + + + + +### VMEvent +VM event returns after contract execution. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `sender_address` | [bytes](#bytes) | | Event sender address. | +| `sender_module` | [ModuleIdent](#dfinance.dvm.ModuleIdent) | | sender module. | +| `event_type` | [LcsTag](#dfinance.dvm.LcsTag) | | Type of value inside event. | +| `event_data` | [bytes](#bytes) | | Event data in bytes to parse. | + + + + + + + + +### VMExecuteResponse +Response from VM contains write_set, events, gas used and status for specific contract. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `write_set` | [VMValue](#dfinance.dvm.VMValue) | repeated | using string instead of bytes for now, as map support only ints and strings as keys | +| `events` | [VMEvent](#dfinance.dvm.VMEvent) | repeated | list of events executed during contract execution | +| `balance_change_set` | [VMBalanceChange](#dfinance.dvm.VMBalanceChange) | repeated | list of native balance updates. | +| `gas_used` | [uint64](#uint64) | | Gas used during execution. | +| `status` | [VMStatus](#dfinance.dvm.VMStatus) | | Main status of execution, might contain an error. | + + + + + + + + +### VMExecuteScript +VM contract object to process. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `senders` | [bytes](#bytes) | repeated | owners of contract. | +| `max_gas_amount` | [uint64](#uint64) | | maximal total gas specified by wallet to spend for this transaction. | +| `gas_unit_price` | [uint64](#uint64) | | maximal price can be paid per gas. | +| `block` | [uint64](#uint64) | | block. | +| `timestamp` | [uint64](#uint64) | | timestamp. | +| `code` | [bytes](#bytes) | | compiled contract code. | +| `type_params` | [StructIdent](#dfinance.dvm.StructIdent) | repeated | type parameters. | +| `args` | [VMArgs](#dfinance.dvm.VMArgs) | repeated | Contract arguments. | + + + + + + + + +### VMPublishModule +Publish module. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `sender` | [bytes](#bytes) | | owner of contract. | +| `max_gas_amount` | [uint64](#uint64) | | maximal total gas specified by wallet to spend for this transaction. | +| `gas_unit_price` | [uint64](#uint64) | | maximal price can be paid per gas. | +| `code` | [bytes](#bytes) | | compiled contract code. | + + + + + + + + +### VMStatus +A `VMStatus` is represented as either +- `Null` indicating successful execution. +- `Error` indicating an error from the VM itself. +- `MoveAbort` indicating an `abort` ocurred inside of a Move program +- `ExecutionFailure` indicating an runtime error. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `move_error` | [MoveError](#dfinance.dvm.MoveError) | | Indicates an error from the VM, e.g. OUT_OF_GAS, INVALID_AUTH_KEY, RET_TYPE_MISMATCH_ERROR etc. The code will neither EXECUTED nor ABORTED | +| `abort` | [Abort](#dfinance.dvm.Abort) | | Indicates an error from the VM, e.g. OUT_OF_GAS, INVALID_AUTH_KEY, RET_TYPE_MISMATCH_ERROR etc. The code will neither EXECUTED nor ABORTED | +| `execution_failure` | [Failure](#dfinance.dvm.Failure) | | Indicates an failure from inside Move code, where the VM could not continue exection, e.g. dividing by zero or a missing resource | +| `message` | [Message](#dfinance.dvm.Message) | | Message with error details if needed (optional). | + + + + + + + + +### VMValue +VM value should be passed before execution and return after execution (with opcodes), write_set in nutshell. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `type` | [VmWriteOp](#dfinance.dvm.VmWriteOp) | | Type of operation | +| `value` | [bytes](#bytes) | | Value returns from vm. | +| `path` | [VMAccessPath](#dfinance.dvm.VMAccessPath) | | Access path. | + + + + + + + + + + +### LcsType + + +| Name | Number | Description | +| ---- | ------ | ----------- | +| LcsBool | 0 | Bool | +| LcsU64 | 1 | Uint64 | +| LcsVector | 2 | Vector of bytes. | +| LcsAddress | 3 | Address, in bech32 form | +| LcsU8 | 4 | U8 | +| LcsU128 | 5 | U128 | +| LcsSigner | 6 | Signer. | +| LcsStruct | 7 | Struct. | + + + + + +### VmWriteOp +Write set operation type. + +| Name | Number | Description | +| ---- | ------ | ----------- | +| Value | 0 | Insert or update value | +| Deletion | 1 | Delete. | + + + + + + + + + +### VMModulePublisher +GRPC service + +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `PublishModule` | [VMPublishModule](#dfinance.dvm.VMPublishModule) | [VMExecuteResponse](#dfinance.dvm.VMExecuteResponse) | | | + + + + +### VMScriptExecutor + + +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `ExecuteScript` | [VMExecuteScript](#dfinance.dvm.VMExecuteScript) | [VMExecuteResponse](#dfinance.dvm.VMExecuteResponse) | | | + + + + + + +

Top

+ +## dfinance/vm/genesis.proto + + + + + +### GenesisState + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `write_set` | [GenesisState.WriteOp](#dfinance.vm.v1beta1.GenesisState.WriteOp) | repeated | | + + + + + + + + +### GenesisState.WriteOp + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `address` | [string](#string) | | Move address (HEX string) | +| `path` | [string](#string) | | Move module path (HEX string) | +| `value` | [string](#string) | | Module code (HEX string) | + + + + + + + + + + + + + + + + +

Top

+ +## dfinance/vm/gov.proto + + + + + +### PlannedProposal +PlannedProposal defines VM Gov proposal with apply schedule and wrapped proposal content. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `height` | [int64](#int64) | | Height is a block height proposal should be applied at | +| `content` | [google.protobuf.Any](#google.protobuf.Any) | | Content is a Gov proposal content | + + + + + + + + +### StdLibUpdateProposal + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `url` | [string](#string) | | Url contains Stdlib update source code | +| `update_description` | [string](#string) | | UpdateDescription contains some update description | +| `code` | [bytes](#bytes) | repeated | Code is a DVM byteCode of updated modules | + + + + + + + + + + + + + + + + +

Top

+ +## dfinance/vm/vm.proto + + + + + +### CompiledItem +CompiledItem contains VM compilation result. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `byte_code` | [bytes](#bytes) | | | +| `name` | [string](#string) | | | +| `methods` | [dfinance.dvm.Function](#dfinance.dvm.Function) | repeated | | +| `types` | [dfinance.dvm.Struct](#dfinance.dvm.Struct) | repeated | | +| `code_type` | [CompiledItem.CodeType](#dfinance.vm.v1beta1.CompiledItem.CodeType) | | | + + + + + + + + +### MsgDeployModule +MsgDeployModule defines a SDK message to deploy a module (contract) to VM. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `signer` | [string](#string) | | Script sender address | +| `modules` | [bytes](#bytes) | repeated | Module code | + + + + + + + + +### MsgExecuteScript +MsgExecuteScript defines a SDK message to execute a script with args to VM. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `signer` | [string](#string) | | Script sender address | +| `script` | [bytes](#bytes) | | Script code | +| `args` | [MsgExecuteScript.ScriptArg](#dfinance.vm.v1beta1.MsgExecuteScript.ScriptArg) | repeated | | + + + + + + + + +### MsgExecuteScript.ScriptArg + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `type` | [dfinance.dvm.VMTypeTag](#dfinance.dvm.VMTypeTag) | | | +| `value` | [bytes](#bytes) | | | + + + + + + + + +### TxVmStatus +TxVmStatus keeps VM statuses and errors for Tx. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `hash` | [string](#string) | | Tx hash [HEX string] | +| `vm_statuses` | [VmStatus](#dfinance.vm.v1beta1.VmStatus) | repeated | VM statuses for the Tx | + + + + + + + + +### VmStatus +VmStatus is a VM error response. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `status` | [string](#string) | | Error Status: error / discard | +| `major_code` | [string](#string) | | Major code | +| `sub_code` | [string](#string) | | Sub code | +| `str_code` | [string](#string) | | Detailed explanation of major code | +| `message` | [string](#string) | | Error message | + + + + + + + + + + +### CompiledItem.CodeType + + +| Name | Number | Description | +| ---- | ------ | ----------- | +| MODULE | 0 | | +| SCRIPT | 1 | | + + + + + + + + + + + +

Top

+ +## dfinance/vm/query.proto + + + + + +### QueryCompileRequest +QueryCompileRequest is request type for Query/Compile RPC method. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `address` | [bytes](#bytes) | | VM address (Libra address) | +| `code` | [string](#string) | | Move code [Plain text] | + + + + + + + + +### QueryCompileResponse +QueryCompileResponse is response type for Query/Compile RPC method. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `compiled_items` | [CompiledItem](#dfinance.vm.v1beta1.CompiledItem) | repeated | Compiled items | + + + + + + + + +### QueryDataRequest +QueryDataRequest is request type for Query/Data RPC method. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `address` | [bytes](#bytes) | | VM address (Libra address) | +| `path` | [bytes](#bytes) | | VM path | + + + + + + + + +### QueryDataResponse +QueryDataResponse is response type for Query/Data RPC method. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `value` | [bytes](#bytes) | | VMStorage value for address:path pair | + + + + + + + + +### QueryDelegatedPoolSupplyRequest +QueryDelegatedPoolSupplyRequest is request type for Query/DelegatedPoolSupply RPC method. + + + + + + + + +### QueryDelegatedPoolSupplyResponse +QueryDelegatedPoolSupplyResponse is response type for Query/DelegatedPoolSupply RPC method. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `coins` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | + + + + + + + + +### QueryMetadataRequest +QueryMetadataRequest is request type for Query/Metadata RPC method. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `code` | [bytes](#bytes) | | | + + + + + + + + +### QueryMetadataResponse +QueryMetadataResponse is response type for Query/Metadata RPC method. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `metadata` | [dfinance.dvm.Metadata](#dfinance.dvm.Metadata) | | | + + + + + + + + +### QueryTxVmStatusRequest +QueryTxVmStatusRequest is request type for Query/TxVmStatus RPC method. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `tx_meta` | [cosmos.base.abci.v1beta1.TxResponse](#cosmos.base.abci.v1beta1.TxResponse) | | Tx meta received from /cosmos/tx/v1beta1/txs/{hash} | + + + + + + + + +### QueryTxVmStatusResponse +QueryTxVmStatusResponse is response type for Query/TxVmStatus RPC method. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `vm_status` | [TxVmStatus](#dfinance.vm.v1beta1.TxVmStatus) | | | + + + + + + + + + + + + + + +### Query +Query defines the gRPC querier service. + +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `Data` | [QueryDataRequest](#dfinance.vm.v1beta1.QueryDataRequest) | [QueryDataResponse](#dfinance.vm.v1beta1.QueryDataResponse) | Data queries VMStorage value | GET|/dfinance/vm/v1beta1/data| +| `TxVmStatus` | [QueryTxVmStatusRequest](#dfinance.vm.v1beta1.QueryTxVmStatusRequest) | [QueryTxVmStatusResponse](#dfinance.vm.v1beta1.QueryTxVmStatusResponse) | TxVmStatus queries VM status for Tx | GET|/dfinance/vm/v1beta1/tx_vm_status| +| `Compile` | [QueryCompileRequest](#dfinance.vm.v1beta1.QueryCompileRequest) | [QueryCompileResponse](#dfinance.vm.v1beta1.QueryCompileResponse) | Compile compiles provided Move code and returns byte code. | GET|/dfinance/vm/v1beta1/compile| +| `Metadata` | [QueryMetadataRequest](#dfinance.vm.v1beta1.QueryMetadataRequest) | [QueryMetadataResponse](#dfinance.vm.v1beta1.QueryMetadataResponse) | Metadata queries VM for byteCode metadata (metadata.proto/GetMetadata RPC wrapper). | | +| `DelegatedPoolSupply` | [QueryDelegatedPoolSupplyRequest](#dfinance.vm.v1beta1.QueryDelegatedPoolSupplyRequest) | [QueryDelegatedPoolSupplyResponse](#dfinance.vm.v1beta1.QueryDelegatedPoolSupplyResponse) | DelegatedPoolSupply queries Delegated pool module balance. | | + + + + + + +

Top

+ +## dfinance/vm/tx.proto + + + + + +### MsgDeployModuleResponse + + + + + + + + + +### MsgExecuteScriptResponse + + + + + + + + + + + + + + + +### Msg +Msg defines the VM module Msg service. + +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `DeployModule` | [MsgDeployModule](#dfinance.vm.v1beta1.MsgDeployModule) | [MsgDeployModuleResponse](#dfinance.vm.v1beta1.MsgDeployModuleResponse) | DeployModule deploys Move module/modules to VMStorage. | | +| `ExecuteScript` | [MsgExecuteScript](#dfinance.vm.v1beta1.MsgExecuteScript) | [MsgExecuteScriptResponse](#dfinance.vm.v1beta1.MsgExecuteScriptResponse) | ExecuteScript executes provided Move script. | | + + + + + +## Scalar Value Types + +| .proto Type | Notes | C++ | Java | Python | Go | C# | PHP | Ruby | +| ----------- | ----- | --- | ---- | ------ | -- | -- | --- | ---- | +| double | | double | double | float | float64 | double | float | Float | +| float | | float | float | float | float32 | float | float | Float | +| int32 | Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint32 instead. | int32 | int | int | int32 | int | integer | Bignum or Fixnum (as required) | +| int64 | Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint64 instead. | int64 | long | int/long | int64 | long | integer/string | Bignum | +| uint32 | Uses variable-length encoding. | uint32 | int | int/long | uint32 | uint | integer | Bignum or Fixnum (as required) | +| uint64 | Uses variable-length encoding. | uint64 | long | int/long | uint64 | ulong | integer/string | Bignum or Fixnum (as required) | +| sint32 | Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int32s. | int32 | int | int | int32 | int | integer | Bignum or Fixnum (as required) | +| sint64 | Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int64s. | int64 | long | int/long | int64 | long | integer/string | Bignum | +| fixed32 | Always four bytes. More efficient than uint32 if values are often greater than 2^28. | uint32 | int | int | uint32 | uint | integer | Bignum or Fixnum (as required) | +| fixed64 | Always eight bytes. More efficient than uint64 if values are often greater than 2^56. | uint64 | long | int/long | uint64 | ulong | integer/string | Bignum | +| sfixed32 | Always four bytes. | int32 | int | int | int32 | int | integer | Bignum or Fixnum (as required) | +| sfixed64 | Always eight bytes. | int64 | long | int/long | int64 | long | integer/string | Bignum | +| bool | | bool | boolean | boolean | bool | bool | boolean | TrueClass/FalseClass | +| string | A string must always contain UTF-8 encoded or 7-bit ASCII text. | string | String | str/unicode | string | string | string | String (UTF-8) | +| bytes | May contain any arbitrary sequence of bytes. | string | ByteString | str | []byte | ByteString | string | String (ASCII-8BIT) | + diff --git a/go.mod b/go.mod index 3fe1005..d6ed00a 100644 --- a/go.mod +++ b/go.mod @@ -3,19 +3,25 @@ module github.com/dfinance/dstation go 1.15 require ( + github.com/OneOfOne/xxhash v1.2.2 github.com/cosmos/cosmos-sdk v0.42.2 - github.com/dfinance/dvm-proto/go v0.0.0-20201007122036-27be7297df4e - github.com/dfinance/glav v0.0.0-20200814081332-c4701f6c12a6 - github.com/dfinance/lcs v0.1.7-big + github.com/fsouza/go-dockerclient v1.7.2 github.com/gogo/protobuf v1.3.3 + github.com/golang/protobuf v1.4.3 github.com/gorilla/mux v1.8.0 + github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/rakyll/statik v0.1.7 - github.com/regen-network/cosmos-proto v0.3.1 // indirect + github.com/regen-network/cosmos-proto v0.3.1 github.com/spf13/cast v1.3.1 github.com/spf13/cobra v1.1.3 + github.com/spf13/pflag v1.0.5 + github.com/spf13/viper v1.7.1 github.com/stretchr/testify v1.7.0 github.com/tendermint/tendermint v0.34.8 github.com/tendermint/tm-db v0.6.4 + google.golang.org/genproto v0.0.0-20210114201628-6edceaf6022f + google.golang.org/grpc v1.35.0 + google.golang.org/protobuf v1.25.0 ) replace google.golang.org/grpc => google.golang.org/grpc v1.33.2 diff --git a/go.sum b/go.sum index c33cb7f..483faba 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,4 @@ +bazil.org/fuse v0.0.0-20160811212531-371fbbdaa898/go.mod h1:Xbm+BRKSBEpa4q4hTSxohYNQpsxXPbPry4JJWOB3LB8= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= @@ -12,6 +13,8 @@ cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiy dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/99designs/keyring v1.1.6 h1:kVDC2uCgVwecxCk+9zoCt2uEL6dt+dfVzMvGgnVcIuM= github.com/99designs/keyring v1.1.6/go.mod h1:16e0ds7LGQQcT59QqkTg72Hh5ShM51Byv5PEmW6uoRU= +github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 h1:w+iIsaOQNcT7OZ575w+acHgRric5iCyQh+xv+KJ4HB8= +github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= @@ -22,6 +25,11 @@ github.com/DataDog/zstd v1.4.1/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ= github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= +github.com/Microsoft/go-winio v0.4.16-0.20201130162521-d1ffc52c7331/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugXOPRXwdLnMv0= +github.com/Microsoft/go-winio v0.4.16 h1:FtSW/jqD+l4ba5iPBj9CODVtgfYAD8w2wS923g/cFDk= +github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugXOPRXwdLnMv0= +github.com/Microsoft/hcsshim v0.8.14 h1:lbPVK25c1cu5xTLITwpUcxoA9vKrKErASPYygvouJns= +github.com/Microsoft/hcsshim v0.8.14/go.mod h1:NtVKoYxQuTLx6gEq0L96c9Ju4JbRJ4nY2ow3VK6a9Lg= github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= @@ -80,6 +88,7 @@ github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cilium/ebpf v0.0.0-20200110133405-4032b1d8aae3/go.mod h1:MA5e5Lr8slmEg9bt0VpxxWqJlO4iwu3FBdHUzV7wQVg= github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE= @@ -89,6 +98,19 @@ github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE github.com/confio/ics23/go v0.0.0-20200817220745-f173e6211efb/go.mod h1:E45NqnlpxGnpfTWL/xauN7MRwEE28T4Dd4uraToOaKg= github.com/confio/ics23/go v0.6.3 h1:PuGK2V1NJWZ8sSkNDq91jgT/cahFEW9RGp4Y5jxulf0= github.com/confio/ics23/go v0.6.3/go.mod h1:E45NqnlpxGnpfTWL/xauN7MRwEE28T4Dd4uraToOaKg= +github.com/containerd/cgroups v0.0.0-20200531161412-0dbf7f05ba59 h1:qWj4qVYZ95vLWwqyNJCQg7rDsG5wPdze0UaPolH7DUk= +github.com/containerd/cgroups v0.0.0-20200531161412-0dbf7f05ba59/go.mod h1:pA0z1pT8KYB3TCXK/ocprsh7MAkoW8bZVzPdih9snmM= +github.com/containerd/console v0.0.0-20180822173158-c12b1e7919c1/go.mod h1:Tj/on1eG8kiEhd0+fhSDzsPAFESxzBBvdyEgyryXffw= +github.com/containerd/containerd v1.3.2/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA= +github.com/containerd/containerd v1.4.3 h1:ijQT13JedHSHrQGWFcGEwzcNKrAGIiZ+jSD5QQG07SY= +github.com/containerd/containerd v1.4.3/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA= +github.com/containerd/continuity v0.0.0-20190426062206-aaeac12a7ffc/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y= +github.com/containerd/continuity v0.0.0-20210208174643-50096c924a4e h1:6JKvHHt396/qabvMhnhUZvWaHZzfVfldxE60TK8YLhg= +github.com/containerd/continuity v0.0.0-20210208174643-50096c924a4e/go.mod h1:EXlVlkqNba9rJe3j7w3Xa924itAMLgZH4UD/Q4PExuQ= +github.com/containerd/fifo v0.0.0-20190226154929-a9fb20d87448/go.mod h1:ODA38xgv3Kuk8dQz2ZQXpnv/UZZUHUCL7pnLehbXgQI= +github.com/containerd/go-runc v0.0.0-20180907222934-5a6d9f37cfa3/go.mod h1:IV7qH3hrUgRmyYrtgEeGWJfWbgcHL9CSRruz2Vqcph0= +github.com/containerd/ttrpc v0.0.0-20190828154514-0e0f228740de/go.mod h1:PvCDdDGpgqzQIzDW1TphrGLssLDZp2GuS+X5DkEJB8o= +github.com/containerd/typeurl v0.0.0-20180627222232-a93fcdb778cd/go.mod h1:Cm3kwCdlkCfMSHURc+r6fwoGH6/F1hH3S4sg0rLFWPc= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= @@ -97,6 +119,7 @@ github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3Ee github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/go-systemd/v22 v22.0.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cosmos/cosmos-sdk v0.42.2 h1:t2jIxV5DGN1ynOwuSIvQUUHr7tAePN1AG5ArM7o8qos= @@ -116,6 +139,8 @@ github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwc github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= +github.com/creack/pty v1.1.11 h1:07n33Z8lZxZ2qwegKbObQohDhXDQxiMMz1NOUGYlesw= +github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/danieljoos/wincred v1.0.2 h1:zf4bhty2iLuwgjgpraD2E9UbvO+fe54XXGJbOwe23fU= github.com/danieljoos/wincred v1.0.2/go.mod h1:SnuYRW9lp1oJrZX/dXJqr0cPK5gYXqx3EJbmjhLdK9U= github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -123,11 +148,6 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218= -github.com/dfinance/dvm-proto/go v0.0.0-20201007122036-27be7297df4e h1:PT57lhHduRU0zBUO1zPHlXj48rpocTRclcAx0HLwLfQ= -github.com/dfinance/dvm-proto/go v0.0.0-20201007122036-27be7297df4e/go.mod h1:Vt1T0G56AYXbsduNKzSkq1RDTNa8PFraSqB9DaTCV0U= -github.com/dfinance/glav v0.0.0-20200814081332-c4701f6c12a6 h1:fZIYncA5BRad0+YnP88cfBfo0ZPgxPSVeuh/jvoGrLc= -github.com/dfinance/glav v0.0.0-20200814081332-c4701f6c12a6/go.mod h1:/0gr38+QzVxCNSNKc/WjGKtdTfV8NtMagCNO0/VjOQU= -github.com/dfinance/lcs v0.1.7-big/go.mod h1:0Ir8JvbtxibZYvgTrRbbjNjk2EImCEXOJc3WHuUaSzI= github.com/dgraph-io/badger/v2 v2.2007.1/go.mod h1:26P/7fbL4kUZVEVKLAKXkBXKOydDmM2p1e+NhhnBCAE= github.com/dgraph-io/badger/v2 v2.2007.2 h1:EjjK0KqwaFMlPin1ajhP943VPENHJdEz1KLIegjaI3k= github.com/dgraph-io/badger/v2 v2.2007.2/go.mod h1:26P/7fbL4kUZVEVKLAKXkBXKOydDmM2p1e+NhhnBCAE= @@ -139,6 +159,12 @@ github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUn github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 h1:fAjc9m62+UWV/WAFKLNi6ZS0675eEUC9y3AlwSbQu1Y= github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= +github.com/docker/docker v20.10.3-0.20210216175712-646072ed6524+incompatible h1:Yu2uGErhwEoOT/OxAFe+/SiJCqRLs+pgcS5XKrDXnG4= +github.com/docker/docker v20.10.3-0.20210216175712-646072ed6524+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= +github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= +github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw= +github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= @@ -168,6 +194,8 @@ github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2 github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= +github.com/fsouza/go-dockerclient v1.7.2 h1:bBEAcqLTkpq205jooP5RVroUKiVEWgGecHyeZc4OFjo= +github.com/fsouza/go-dockerclient v1.7.2/go.mod h1:+ugtMCVRwnPfY7d8/baCzZ3uwB0BrG5DB8OzbtxaRz8= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -184,11 +212,13 @@ github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 h1:ZpnhV/YsD2/4cESfV5+Hoeu/iUR3ruzNvZ+yQfO03a0= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2/go.mod h1:bBOAhwG1umN6/6ZUMtDFBMQR8jRg9O75tm9K00oMsK4= +github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gogo/gateway v1.1.0 h1:u0SuhL9+Il+UbjM9VIE3ntfRujKbvVpFvNB4HbjeVQ0= github.com/gogo/gateway v1.1.0/go.mod h1:S7rR8FRQyG3QFESeSv4l2WnsyzlCLG0CzBbUUo/mbic= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6 h1:ZgQEtGgCBiWRM39fZuwSd1LwSqqSW0hOdXCYYDX0R3I= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= @@ -199,7 +229,6 @@ github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= @@ -223,6 +252,8 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -326,6 +357,7 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= github.com/kkdai/bstream v1.0.0/go.mod h1:FDnDOHt5Yx4p3FaHcioFT0QjDOtgUpvjeZqAs+NVZZA= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= @@ -364,10 +396,18 @@ github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0Qu github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/moby/sys/mount v0.2.0 h1:WhCW5B355jtxndN5ovugJlMFJawbUODuW8fSnEH6SSM= +github.com/moby/sys/mount v0.2.0/go.mod h1:aAivFE2LB3W4bACsUXChRHQ0qKWsetY4Y9V7sxOougM= +github.com/moby/sys/mountinfo v0.4.0 h1:1KInV3Huv18akCu58V7lzNlt+jFmqlu1EaErnEHE/VM= +github.com/moby/sys/mountinfo v0.4.0/go.mod h1:rEr8tzG/lsIZHBtN/JjGG+LMYx9eXgW2JI+6q0qou+A= +github.com/moby/term v0.0.0-20201216013528-df9cb8a40635 h1:rzf0wL0CHVc8CEsgyygG0Mn9CNCCPZqOPaz8RiiHYQk= +github.com/moby/term v0.0.0-20201216013528-df9cb8a40635/go.mod h1:FBS0z0QWA44HXygs7VXDUOGoN/1TV3RuWkLO04am3wc= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= +github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= github.com/mtibben/percent v0.2.1 h1:5gssi8Nqo8QU/r2pynCm+hBQHpkB/uNK7BJCFogWdzs= github.com/mtibben/percent v0.2.1/go.mod h1:KG9uO+SZkUp+VkRHsCdYQV3XSZrrSpR3O9ibNBTZrns= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= @@ -398,6 +438,15 @@ github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7J github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= +github.com/opencontainers/go-digest v0.0.0-20180430190053-c9281466c8b2/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= +github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= +github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= +github.com/opencontainers/image-spec v1.0.1 h1:JMemWkRwHx4Zj+fVxWoMCFm/8sYGGrUVojFA6h/TRcI= +github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= +github.com/opencontainers/runc v0.0.0-20190115041553-12f6a991201f/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U= +github.com/opencontainers/runc v0.1.1 h1:GlxAyO6x8rfZYN9Tt0Kti5a/cP41iuiO2yYT0IJGY8Y= +github.com/opencontainers/runc v0.1.1/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U= +github.com/opencontainers/runtime-spec v1.0.2/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis= github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= @@ -462,6 +511,7 @@ github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB8 github.com/prometheus/common v0.14.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= github.com/prometheus/common v0.15.0 h1:4fgOnadei3EZvgRwxJ7RMpG1k1pOZth5Pc13tyspaKM= github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= +github.com/prometheus/procfs v0.0.0-20180125133057-cb4147076ac7/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= @@ -498,8 +548,11 @@ github.com/sasha-s/go-deadlock v0.2.1-0.20190427202633-1595213edefa/go.mod h1:F7 github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= +github.com/sirupsen/logrus v1.7.0 h1:ShrD1U9pZB12TX0cVy0DtePoCH97K8EtX+mg7ZARUtM= +github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= @@ -516,6 +569,7 @@ github.com/spf13/afero v1.3.4/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng= github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= +github.com/spf13/cobra v0.0.2-0.20171109065643-2da4a54c5cee/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= @@ -525,6 +579,7 @@ github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSW github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= +github.com/spf13/pflag v1.0.1-0.20171106142849-4c012f6dcd95/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= @@ -544,7 +599,6 @@ github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoH github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= @@ -576,6 +630,7 @@ github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGr github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= +github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -591,6 +646,7 @@ go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= +go.opencensus.io v0.22.2 h1:75k/FF0Q2YM8QYo07VPddOLBslDt1MZOdEslOHvmzAs= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= @@ -663,6 +719,7 @@ golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191002035440-2ec189313ef0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20191004110552-13f9640d40b9/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200421231249-e086a090c8fd/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= @@ -682,6 +739,7 @@ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9 h1:SQFwaSi55rU7vdNs9Yr0Z324VNlrF+0wMqRXT4St8ck= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -705,13 +763,16 @@ golang.org/x/sys v0.0.0-20190712062909-fae7ac547cb7/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191022100944-742c48ecaeb7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200120151820-655fe14d7479/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -720,9 +781,16 @@ golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200831180312-196b9ba8737a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200909081042-eff7692f9009/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200922070232-aee5d888a860/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201015000850-e3ed0017c211 h1:9UQO31fZ+0aKQOFldThf7BKPMJTiBfWycGh/u3UoO88= golang.org/x/sys v0.0.0-20201015000850-e3ed0017c211/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210216224549-f992740a1bac h1:9glrpwtNjBYgRpb67AZJKHfzj1stG/8BL5H7In2oTC4= +golang.org/x/sys v0.0.0-20210216224549-f992740a1bac/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/term v0.0.0-20201113234701-d7a72108b828/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221 h1:/ZHdbVpdR/jk3g30/d4yUL0JU9kksj8+F/bnQUVLGDM= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -745,6 +813,7 @@ golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBn golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190624222133-a101b041ded4/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20190828213141-aed303cbaa74/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= @@ -835,6 +904,11 @@ gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= +gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= +gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk= +gotest.tools/v3 v3.0.3 h1:4AuOwCGf4lLR9u3YOe2awrHygurzhO/HeQ6laiA6Sx0= +gotest.tools/v3 v3.0.3/go.mod h1:Z7Lb0S5l+klDB31fvDQX8ss/FlKDxtlFlw3Oa8Ymbl8= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/pkg/grpc.go b/pkg/grpc.go new file mode 100644 index 0000000..d77e69d --- /dev/null +++ b/pkg/grpc.go @@ -0,0 +1,92 @@ +package pkg + +import ( + "context" + "fmt" + "net" + "net/url" + "os" + "strings" + "time" + + "google.golang.org/grpc" + "google.golang.org/grpc/keepalive" +) + +// GetGRpcNetListener returns net.Listener for UNIX/TCP address string. +func GetGRpcNetListener(addr string) (net.Listener, error) { + schema, address, err := parseGRpcAddress(addr) + if err != nil { + return nil, err + } + + // Remove socket file if exists + if schema == "unix" { + os.Remove(address) + } + + listener, err := net.Listen(schema, address) + if err != nil { + return nil, fmt.Errorf("net.Listen failed: %w", err) + } + + return listener, nil +} + +// GetGRpcClientConnection returns gRPC client connection for UNIX/TCP address string. +// Keep alive option is not added if {keepAlivePeriod} == 0. +func GetGRpcClientConnection(addr string, keepAlivePeriod time.Duration) (*grpc.ClientConn, error) { + schema, address, err := parseGRpcAddress(addr) + if err != nil { + return nil, err + } + + dialOptions := []grpc.DialOption{ + grpc.WithInsecure(), + grpc.WithContextDialer(func(ctx context.Context, _ string) (net.Conn, error) { + timeout := time.Duration(0) + if deadline, ok := ctx.Deadline(); ok { + timeout = time.Until(deadline) + } + + return net.DialTimeout(schema, address, timeout) + }), + } + + if keepAlivePeriod > 0 { + kpParams := keepalive.ClientParameters{ + Time: keepAlivePeriod, // send pings every 1 second if there is no activity + Timeout: keepAlivePeriod, // wait 1 second for ping ack before considering the connection dead + PermitWithoutStream: true, // send pings even without active streams + } + + dialOptions = append(dialOptions, grpc.WithKeepaliveParams(kpParams)) + } + + // Bypass Rust h2 library UDS limitations: uri validation failure causing PROTOCOL_ERROR gRPC error + dialAddress := address + if schema == "unix" { + dialAddress = "127.0.0.1" // faking filePath with valid URL + } + + return grpc.Dial(dialAddress, dialOptions...) +} + +func parseGRpcAddress(addr string) (retSchema, retAddress string, retErr error) { + // Handling default VM config for previous version + if !strings.Contains(addr, "://") { + addr = "tcp://" + addr + } + + u, err := url.Parse(addr) + if err != nil { + retErr = fmt.Errorf("url parse failed: %w", err) + return + } + retSchema = u.Scheme + + // u.Path / u.Host depends on u.Scheme, so we combine them + retAddress = u.Host + u.Path + + return +} diff --git a/pkg/input_parsers.go b/pkg/input_parsers.go new file mode 100644 index 0000000..a703155 --- /dev/null +++ b/pkg/input_parsers.go @@ -0,0 +1,373 @@ +package pkg + +import ( + "encoding/hex" + "fmt" + "io/ioutil" + "os" + "strconv" + "strings" + "time" + + cli "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + sdk "github.com/cosmos/cosmos-sdk/types" + authTypes "github.com/cosmos/cosmos-sdk/x/auth/types" + govCli "github.com/cosmos/cosmos-sdk/x/gov/client/cli" + "github.com/spf13/cobra" + "github.com/spf13/pflag" + tmtime "github.com/tendermint/tendermint/types/time" + + dnTypes "github.com/dfinance/dstation/pkg/types" +) + +type ParamType string + +const ( + ParamTypeCliFlag ParamType = "flag" + ParamTypeCliArg ParamType = "argument" + ParamTypeRequest ParamType = "request param" +) + +// ParseFromFlag parses --from flag. +func ParseFromFlag(clientCtx cli.Context) (sdk.AccAddress, error) { + accAddr := clientCtx.GetFromAddress() + accRetriever := authTypes.AccountRetriever{} + + if !clientCtx.GenerateOnly { + if err := accRetriever.EnsureExists(clientCtx, accAddr); err != nil { + return sdk.AccAddress{}, fmt.Errorf("%s %s: %w", flags.FlagFrom, ParamTypeCliFlag, err) + } + } + + return accAddr, nil +} + +// ParseDepositFlag parses --deposit flag. +func ParseDepositFlag(flags *pflag.FlagSet) (sdk.Coins, error) { + depositStr, err := flags.GetString(govCli.FlagDeposit) + if err != nil { + return sdk.Coins{}, fmt.Errorf("%s %s: %w", govCli.FlagDeposit, ParamTypeCliFlag, err) + } + deposit, err := sdk.ParseCoinsNormalized(depositStr) + if err != nil { + return sdk.Coins{}, fmt.Errorf("%s %s %q: parsing Coins: %w", govCli.FlagDeposit, ParamTypeCliFlag, depositStr, err) + } + + return deposit, nil +} + +// ParsePaginationParams parses --page, --limit flags. +func ParsePaginationParams(pageStr, limitStr string, paramType ParamType) (page, limit sdk.Uint, retErr error) { + parseUint := func(paramName, paramValue string) (sdk.Uint, error) { + valueInt, ok := sdk.NewIntFromString(paramValue) + if !ok { + return sdk.Uint{}, fmt.Errorf("%s %s %q: Int parsing: failed", paramName, paramType, paramValue) + } + if valueInt.LT(sdk.OneInt()) { + return sdk.Uint{}, fmt.Errorf("%s %s %q: Uint parsing: value is less than 1", paramName, paramType, paramValue) + } + return sdk.NewUintFromBigInt(valueInt.BigInt()), nil + } + + if pageStr == "" { + pageStr = "1" + } + if limitStr == "" { + limitStr = "100" + } + + page, retErr = parseUint("page", pageStr) + if retErr != nil { + return + } + + limit, retErr = parseUint("limit", limitStr) + if retErr != nil { + return + } + + return +} + +// ParseSdkIntParam parses sdk.Int param. +func ParseSdkIntParam(argName, argValue string, paramType ParamType) (sdk.Int, error) { + v, ok := sdk.NewIntFromString(argValue) + if !ok { + return sdk.Int{}, fmt.Errorf("%s %s %q: parsing Int: failed", argName, paramType, argValue) + } + + return v, nil +} + +// ParseSdkDecParam parses sdk.Dec param. +func ParseSdkDecParam(argName, argValue string, paramType ParamType) (sdk.Dec, error) { + v, err := sdk.NewDecFromStr(argValue) + if err != nil { + return sdk.Dec{}, fmt.Errorf("%s %s %q: parsing Dec: failed(%s)", argName, paramType, argValue, err.Error()) + } + + return v, nil +} + +// ParseSdkIntParam parses sdk.Uint param. +func ParseSdkUintParam(argName, argValue string, paramType ParamType) (sdk.Uint, error) { + vInt, ok := sdk.NewIntFromString(argValue) + if !ok { + return sdk.Uint{}, fmt.Errorf("%s %s %q: parsing Uint: failed", argName, paramType, argValue) + } + + if vInt.LT(sdk.ZeroInt()) { + return sdk.Uint{}, fmt.Errorf("%s %s %q: parsing Uint: less than zero", argName, paramType, argValue) + } + + return sdk.NewUintFromBigInt(vInt.BigInt()), nil +} + +// ParseUint8Param parses uint8 param. +func ParseUint8Param(argName, argValue string, paramType ParamType) (uint8, error) { + v, err := strconv.ParseUint(argValue, 10, 8) + if err != nil { + return uint8(0), fmt.Errorf("%s %s %q: uint8 parsing: %w", argName, paramType, argValue, err) + } + + return uint8(v), nil +} + +// ParseUint64Param parses uint64 param. +func ParseUint64Param(argName, argValue string, paramType ParamType) (uint64, error) { + v, err := strconv.ParseUint(argValue, 10, 64) + if err != nil { + return uint64(0), fmt.Errorf("%s %s %q: uint64 parsing: %w", argName, paramType, argValue, err) + } + + return v, nil +} + +// ParseInt64Param parses int64 param. +func ParseInt64Param(argName, argValue string, paramType ParamType) (int64, error) { + v, err := strconv.ParseInt(argValue, 10, 64) + if err != nil { + return int64(0), fmt.Errorf("%s %s %q: int64 parsing: %w", argName, paramType, argValue, err) + } + + return v, nil +} + +// ParseSdkAddressParam parses sdk.AccAddress param. +func ParseSdkAddressParam(argName, argValue string, paramType ParamType) (retAddr sdk.AccAddress, retErr error) { + defer func() { + if retAddr.Empty() { + retErr = fmt.Errorf("%s %s %q: parsing Bech32 / HEX account address: failed", argName, paramType, argValue) + } + }() + + if v, err := sdk.AccAddressFromBech32(argValue); err == nil { + retAddr = v + return + } + + argValueNorm := strings.TrimPrefix(argValue, "0x") + if v, err := sdk.AccAddressFromHex(argValueNorm); err == nil { + retAddr = v + return + } + + return +} + +// ParseSdkAddressesParams parses sdk.AccAddress comma separated slice. +func ParseSdkAddressesParams(argName, argValue string, paramType ParamType) (retAddrs []sdk.AccAddress, retErr error) { + for i, addressStr := range strings.Split(argValue, ",") { + addressStr = strings.TrimSpace(addressStr) + addr, err := ParseSdkAddressParam(fmt.Sprintf("address[%d]", i), addressStr, paramType) + if err != nil { + retErr = fmt.Errorf("%s %s %q: %w", argName, paramType, argValue, err) + return + } + retAddrs = append(retAddrs, addr) + } + + return +} + +// ParseEthereumAddressParam parses and validates Ethereum address param. +func ParseEthereumAddressParam(argName, argValue string, paramType ParamType) (string, error) { + if !IsEthereumAddress(argValue) { + return "", fmt.Errorf("%s %s %q: ethereum address validation failed", argName, paramType, argValue) + } + + return argValue, nil +} + +// ParseDnIDParam parses dnTypes.ID param. +func ParseDnIDParam(argName, argValue string, paramType ParamType) (dnTypes.ID, error) { + id, err := dnTypes.NewIDFromString(argValue) + if err != nil { + return dnTypes.ID{}, fmt.Errorf("%s %s %q: %v", argName, paramType, argValue, err) + } + + return id, nil +} + +// ValidateDenomParam validates currency denomination symbol. +func ValidateDenomParam(argName, argValue string, paramType ParamType) error { + if err := dnTypes.DenomFilter(argValue); err != nil { + return fmt.Errorf("%s %s %q: %v", argName, paramType, argValue, err) + } + + return nil +} + +// ParseHexStringParam parses HEX string param. +func ParseHexStringParam(argName, argValue string, paramType ParamType) (string, []byte, error) { + argValueNorm := strings.TrimPrefix(argValue, "0x") + argValueBytes, err := hex.DecodeString(argValueNorm) + if err != nil { + return "", nil, fmt.Errorf("%s %s %q: %v", argName, paramType, argValue, err) + } + + return argValueNorm, argValueBytes, nil +} + +// ParseAssetCodeParam parses assetCode and validates it. +func ParseAssetCodeParam(argName, argValue string, paramType ParamType) (dnTypes.AssetCode, error) { + assetCode := dnTypes.AssetCode(strings.ToLower(argValue)) + if err := assetCode.Validate(); err != nil { + return "", fmt.Errorf("%s %s %q: %v", argName, paramType, argValue, err) + } + + return assetCode, nil +} + +// ParseCoinParam parses sdk.Coin param and validates it. +func ParseCoinParam(argName, argValue string, paramType ParamType) (retCoin sdk.Coin, retErr error) { + defer func() { + if r := recover(); r != nil { + retErr = fmt.Errorf("%s %s %q: parsing coin failed", argName, paramType, argValue) + } + }() + + coin, err := sdk.ParseCoinNormalized(argValue) + if err != nil { + return sdk.Coin{}, fmt.Errorf("%s %s %q: parsing coin: %v", argName, paramType, argValue, err) + } + + if err := dnTypes.DenomFilter(coin.Denom); err != nil { + return sdk.Coin{}, fmt.Errorf("%s %s %q: validating denom: %v", argName, paramType, argValue, err) + } + + if coin.Amount.LT(sdk.ZeroInt()) { + return sdk.Coin{}, fmt.Errorf("%s %s %q: amount is LT zero", argName, paramType, argValue) + } + + return coin, nil +} + +// ParseUnixTimestamp parses UNIX timestamp in seconds. +func ParseUnixTimestamp(argName, argValue string, paramType ParamType) (time.Time, error) { + ts, err := ParseSdkIntParam(argName, argValue, paramType) + if err != nil { + return time.Time{}, err + } + tsCanonical := tmtime.Canonical(time.Unix(ts.Int64(), 0)) + + return tsCanonical, nil +} + +// ParseFilePath opens file. +func ParseFilePath(argName, argValue string, paramType ParamType) ([]byte, error) { + file, err := os.Open(argValue) + if err != nil { + return nil, fmt.Errorf("%s %s %q: file open: %w", argName, paramType, argValue, err) + } + defer file.Close() + + content, err := ioutil.ReadAll(file) + if err != nil { + return nil, fmt.Errorf("%s %s %q: file read: %w", argName, paramType, argValue, err) + } + + return content, nil +} + +// CheckFileExists checks that file exists and it is not a directory. +func CheckFileExists(argName, argValue string, paramType ParamType) error { + info, err := os.Stat(argValue) + if err != nil { + if os.IsNotExist(err) { + return fmt.Errorf("%s %s %q: file not found", argName, paramType, argValue) + } + return fmt.Errorf("%s %s %q: reading file stats: %w", argName, paramType, argValue, err) + } + + if info.IsDir() { + return fmt.Errorf("%s %s %q: file is a directory", argName, paramType, argValue) + } + + return nil +} + +// BuildError builds an error in unified error style. +func BuildError(argName, argValue string, paramType ParamType, errMsg string) error { + return fmt.Errorf("%s %s %q: %s", argName, paramType, argValue, errMsg) +} + +// AddPaginationCmdFlags adds --page --limit flags to Cobra command. +func AddPaginationCmdFlags(cmd *cobra.Command) { + cmd.Flags().String(flags.FlagPage, "1", "pagination page of objects list to to query for (first page: 1)") + cmd.Flags().String(flags.FlagLimit, "100", "pagination limit of objects list to query for") +} + +// BuildCmdHelp add long description to Cobra command using short description and provided strings. +func BuildCmdHelp(cmd *cobra.Command, argDescriptions []string) { + args := strings.Split(cmd.Use, " ") + args = args[1:] + + if len(argDescriptions) != len(args) { + panic(fmt.Errorf("building Help for cmd %q, argDescriptions len mismatch %d / %d: ", cmd.Use, len(argDescriptions), len(args))) + } + + helpBuilder := strings.Builder{} + helpBuilder.WriteString(fmt.Sprintf("%s:\n", cmd.Short)) + for argIdx, arg := range args { + argDesc := argDescriptions[argIdx] + helpBuilder.WriteString(fmt.Sprintf(" %s - %s\n", arg, argDesc)) + } + + cmd.Long = helpBuilder.String() +} + +// PaginateSlice returns slice start/end indices for slice checking int limits. +// Should be used for queries with pagination, where slice objects index doesn't exists. +func PaginateSlice(sliceLen int, page, limit sdk.Uint) (start, end uint64, retErr error) { + if sliceLen < 0 { + retErr = fmt.Errorf("sliceLen: LT zero") + return + } + if page.IsZero() { + retErr = fmt.Errorf("page: is zero") + return + } + if limit.IsZero() { + retErr = fmt.Errorf("limit: is zero") + return + } + if sliceLen == 0 { + return + } + + start = (page.Uint64() - 1) * limit.Uint64() + end = limit.Uint64() + start + + if start >= uint64(sliceLen) { + start, end = 0, 0 + return + } + + if end >= uint64(sliceLen) { + end = uint64(sliceLen) + } + + return +} diff --git a/pkg/mock/vm_server.go b/pkg/mock/vm_server.go new file mode 100644 index 0000000..e8b5c37 --- /dev/null +++ b/pkg/mock/vm_server.go @@ -0,0 +1,205 @@ +package mock + +import ( + "context" + "math/rand" + "net" + "sync" + "time" + + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + grpcStatus "google.golang.org/grpc/status" + "google.golang.org/grpc/test/bufconn" + + dvmTypes "github.com/dfinance/dstation/pkg/types/dvm" +) + +const ( + VMAddressLength = 20 + // + bufferedListenerSize = 1024 * 1024 +) + +var ( + VMStdLibAddress = make([]byte, VMAddressLength) +) + +type VMServer struct { + sync.Mutex + // + response *dvmTypes.VMExecuteResponse + responseDelay time.Duration + failCountdown uint + // + vmListener *bufconn.Listener + dsListener *bufconn.Listener + vmGrpcServer *grpc.Server +} + +func (s *VMServer) PublishModule(context.Context, *dvmTypes.VMPublishModule) (*dvmTypes.VMExecuteResponse, error) { + return s.buildResponse() +} + +func (s *VMServer) ExecuteScript(context.Context, *dvmTypes.VMExecuteScript) (*dvmTypes.VMExecuteResponse, error) { + return s.buildResponse() +} + +func (s *VMServer) SetResponse(resp *dvmTypes.VMExecuteResponse) { + s.Lock() + defer s.Unlock() + + s.response = resp +} + +func (s *VMServer) SetFailCountdown(value uint) { + s.Lock() + defer s.Unlock() + + s.failCountdown = value +} + +func (s *VMServer) SetResponseDelay(dur time.Duration) { + s.Lock() + defer s.Unlock() + + s.responseDelay = dur +} + +func (s *VMServer) Stop() { + s.Lock() + defer s.Unlock() + + if s.vmGrpcServer != nil { + s.vmGrpcServer.Stop() + } + if s.vmListener != nil { + s.vmListener.Close() + } +} + +func (s *VMServer) GetVMListener() net.Listener { return s.vmListener } + +func (s *VMServer) GetDSListener() net.Listener { return s.dsListener } + +func (s *VMServer) GetVMClientConnection() *grpc.ClientConn { + bufDialer := func(ctx context.Context, url string) (net.Conn, error) { + return s.vmListener.Dial() + } + + ctx := context.TODO() + conn, err := grpc.DialContext(ctx, "", grpc.WithContextDialer(bufDialer), grpc.WithInsecure()) + if err != nil { + panic(err) + } + + return conn +} + +func (s *VMServer) GetDSClientConnection() *grpc.ClientConn { + bufDialer := func(ctx context.Context, url string) (net.Conn, error) { + return s.dsListener.Dial() + } + + ctx := context.TODO() + conn, err := grpc.DialContext(ctx, "", grpc.WithContextDialer(bufDialer), grpc.WithInsecure()) + if err != nil { + panic(err) + } + + return conn +} + +func (s *VMServer) buildResponse() (*dvmTypes.VMExecuteResponse, error) { + s.Lock() + defer s.Unlock() + + time.Sleep(s.responseDelay) + + if s.failCountdown > 0 { + s.failCountdown-- + return nil, grpcStatus.Errorf(codes.Internal, "failing gRPC execution") + } + + resp := s.response + if resp == nil { + resp = s.getDefaultResponse() + } + + return resp, nil +} + +func (s *VMServer) getDefaultResponse() *dvmTypes.VMExecuteResponse { + values := []*dvmTypes.VMValue{ + { + Type: dvmTypes.VmWriteOp_Value, + Value: GetRandomBytes(8), + Path: GetRandomVMAccessPath(), + }, + { + Type: dvmTypes.VmWriteOp_Value, + Value: GetRandomBytes(32), + Path: GetRandomVMAccessPath(), + }, + } + + events := []*dvmTypes.VMEvent{ + { + SenderAddress: VMStdLibAddress, + EventType: &dvmTypes.LcsTag{ + TypeTag: dvmTypes.LcsType_LcsVector, + VectorType: &dvmTypes.LcsTag{ + TypeTag: dvmTypes.LcsType_LcsU8, + }, + }, + EventData: GetRandomBytes(32), + }, + } + + return &dvmTypes.VMExecuteResponse{ + WriteSet: values, + Events: events, + GasUsed: 10000, + Status: &dvmTypes.VMStatus{}, + } +} + +func NewVMServer() *VMServer { + vmServer := &VMServer{ + dsListener: bufconn.Listen(bufferedListenerSize), + vmListener: bufconn.Listen(bufferedListenerSize), + vmGrpcServer: grpc.NewServer(), + } + dvmTypes.RegisterVMModulePublisherServer(vmServer.vmGrpcServer, vmServer) + dvmTypes.RegisterVMScriptExecutorServer(vmServer.vmGrpcServer, vmServer) + + go func() { + if err := vmServer.vmGrpcServer.Serve(vmServer.vmListener); err != nil { + panic(err) + } + }() + + return vmServer +} + +func GetRandomVMAccessPath() *dvmTypes.VMAccessPath { + return &dvmTypes.VMAccessPath{ + Address: GetRandomBytes(VMAddressLength), + Path: GetRandomBytes(VMAddressLength), + } +} + +func GetRandomBytes(len int) []byte { + rndBytes := make([]byte, len) + + _, err := rand.Read(rndBytes) + if err != nil { + panic(err) + } + + return rndBytes +} + +func init() { + VMStdLibAddress[VMAddressLength-1] = 1 +} diff --git a/pkg/tests/app_opts.go b/pkg/tests/app_opts.go new file mode 100644 index 0000000..ce9a1d8 --- /dev/null +++ b/pkg/tests/app_opts.go @@ -0,0 +1,23 @@ +package tests + +// AppOptionsProvider provides options for the app. +type AppOptionsProvider struct { + storage map[string]interface{} +} + +// Set sets app option. +func (ao AppOptionsProvider) Set(key string, value interface{}) { + ao.storage[key] = value +} + +// Get implements AppOptions. +func (ao AppOptionsProvider) Get(key string) interface{} { + return ao.storage[key] +} + +// NewAppOptionsProvider creates a new AppOptionsProvider. +func NewAppOptionsProvider() AppOptionsProvider { + return AppOptionsProvider{ + storage: make(map[string]interface{}), + } +} diff --git a/pkg/tests/dsimapp.go b/pkg/tests/dsimapp.go new file mode 100644 index 0000000..236e8cc --- /dev/null +++ b/pkg/tests/dsimapp.go @@ -0,0 +1,126 @@ +package tests + +import ( + "encoding/json" + "time" + + "github.com/cosmos/cosmos-sdk/simapp" + sdk "github.com/cosmos/cosmos-sdk/types" + 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" + + dnApp "github.com/dfinance/dstation/app" + dnConfig "github.com/dfinance/dstation/cmd/dstation/config" + "github.com/dfinance/dstation/pkg/mock" + vmConfig "github.com/dfinance/dstation/x/vm/config" +) + +// DSimAppOption defines functional arguments for DSimApp constructor. +type DSimAppOption func(app *DSimApp) + +// DSimApp wraps DnApp, provides VM environment and helper functions. +type DSimApp struct { + DnApp *dnApp.DnApp + encCfg dnApp.EncodingConfig + // + MockVMServer *mock.VMServer + // + appOptions AppOptionsProvider + genesisState dnApp.GenesisState + vmConfig vmConfig.VMConfig + // + curBlockHeight int64 + curBlockTime time.Time +} + +// GetContext creates a new sdk.Context. +func (app *DSimApp) GetContext(checkTx bool) sdk.Context { + return app.DnApp.NewUncachedContext(checkTx, tmProto.Header{ + Height: app.curBlockHeight, + Time: app.curBlockTime, + }) +} + +// GetCurrentBlockHeightTime returns current block height and time (set at the BeginBlock). +func (app *DSimApp) GetCurrentBlockHeightTime() (int64, time.Time) { + return app.curBlockHeight, app.curBlockTime +} + +// GetNextBlockHeightTime returns next block height and time (as DeliverTx begins / ends a new block, that func peeks a new values). +func (app *DSimApp) GetNextBlockHeightTime() (int64, time.Time) { + return app.curBlockHeight + 1, app.curBlockTime.Add(5 * time.Second) +} + +// SetCustomVMRetryParams alters VM config params. +func (app *DSimApp) SetCustomVMRetryParams(maxAttempts, reqTimeoutInMs uint) { + app.vmConfig.MaxAttempts = maxAttempts + app.vmConfig.ReqTimeoutInMs = reqTimeoutInMs +} + +// TearDown stops VM, servers and closes all connections. +func (app *DSimApp) TearDown() { + app.DnApp.CloseConnections() + if app.MockVMServer != nil { + app.MockVMServer.Stop() + } +} + +// SetupDSimApp creates a new DSimApp, setups VM environment. +func SetupDSimApp(opts ...DSimAppOption) *DSimApp { + // Create simApp with defaults + app := &DSimApp{ + encCfg: dnApp.MakeEncodingConfig(), + appOptions: NewAppOptionsProvider(), + vmConfig: vmConfig.DefaultVMConfig(), + curBlockHeight: 0, + curBlockTime: time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC), + } + + genState, err := dnConfig.SetGenesisDefaults(app.encCfg.Marshaler, dnApp.NewDefaultGenesisState()) + if err != nil { + panic(err) + } + app.genesisState = genState + + // Apply simApp options + for _, opt := range opts { + opt(app) + } + + // Init the main app + app.DnApp = dnApp.NewDnApp( + log.NewNopLogger(), + dbm.NewMemDB(), + nil, + true, + map[int64]bool{}, + dnConfig.DefaultNodeHome, + 1, + app.encCfg, + &app.vmConfig, + app.appOptions, + dnApp.VMCrashHandleBaseAppOption(), + ) + + // Init chain + appStateBz, err := json.MarshalIndent(app.genesisState, "", " ") + if err != nil { + panic(err) + } + + app.DnApp.InitChain( + abci.RequestInitChain{ + Validators: []abci.ValidatorUpdate{}, + ConsensusParams: simapp.DefaultConsensusParams, + AppStateBytes: appStateBz, + }, + ) + + // Skip the genesis block + app.BeginBlock() + app.EndBlock() + + return app +} diff --git a/pkg/tests/dsimapp_account.go b/pkg/tests/dsimapp_account.go new file mode 100644 index 0000000..8b6d086 --- /dev/null +++ b/pkg/tests/dsimapp_account.go @@ -0,0 +1,29 @@ +package tests + +import ( + "fmt" + + cryptoTypes "github.com/cosmos/cosmos-sdk/crypto/types" + sdk "github.com/cosmos/cosmos-sdk/types" + authTypes "github.com/cosmos/cosmos-sdk/x/auth/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" +) + +// AddAccount creates a new account, sets account initial balance and updates totalSupply (if defined). +func (app *DSimApp) AddAccount(ctx sdk.Context, coins ...sdk.Coin) (authTypes.AccountI, cryptoTypes.PrivKey) { + addr, _, privKey := GenAccAddress() + + acc := app.DnApp.AccountKeeper.NewAccountWithAddress(ctx, addr) + app.DnApp.AccountKeeper.SetAccount(ctx, acc) + + if len(coins) > 0 { + if err := app.DnApp.BankKeeper.AddCoins(ctx, addr, coins); err != nil { + panic(fmt.Errorf("generating test account with coins (%s): %w", sdk.Coins(coins).String(), err)) + } + + prevSupply := app.DnApp.BankKeeper.GetSupply(ctx) + app.DnApp.BankKeeper.SetSupply(ctx, banktypes.NewSupply(prevSupply.GetTotal().Add(coins...))) + } + + return acc, privKey +} \ No newline at end of file diff --git a/pkg/tests/dsimapp_options.go b/pkg/tests/dsimapp_options.go new file mode 100644 index 0000000..2889b70 --- /dev/null +++ b/pkg/tests/dsimapp_options.go @@ -0,0 +1,24 @@ +package tests + +import ( + dnApp "github.com/dfinance/dstation/app" + "github.com/dfinance/dstation/pkg/mock" + vmConfig "github.com/dfinance/dstation/x/vm/config" +) + +// WithMockVM adds the mock VMServer to DSimApp environment. +func WithMockVM() DSimAppOption { + return func(app *DSimApp) { + app.MockVMServer = mock.NewVMServer() + + app.appOptions.Set(dnApp.FlagCustomVMConnection, app.MockVMServer.GetVMClientConnection()) + app.appOptions.Set(dnApp.FlagCustomDSListener, app.MockVMServer.GetDSListener()) + } +} + +// WithDVMConfig sets DVM config. +func WithDVMConfig(cfg vmConfig.VMConfig) DSimAppOption { + return func(app *DSimApp) { + app.vmConfig = cfg + } +} diff --git a/pkg/tests/dsimapp_tx.go b/pkg/tests/dsimapp_tx.go new file mode 100644 index 0000000..4eec1ec --- /dev/null +++ b/pkg/tests/dsimapp_tx.go @@ -0,0 +1,84 @@ +package tests + +import ( + "fmt" + + cryptoTypes "github.com/cosmos/cosmos-sdk/crypto/types" + "github.com/cosmos/cosmos-sdk/simapp/helpers" + sdk "github.com/cosmos/cosmos-sdk/types" + abci "github.com/tendermint/tendermint/abci/types" + tmProto "github.com/tendermint/tendermint/proto/tendermint/types" + + dnConfig "github.com/dfinance/dstation/cmd/dstation/config" +) + +// DeliverTxOption defines DeliverTx functional arguments. +type DeliverTxOption func(gasLimit *uint64) + +// BeginBlock starts a new block. +func (app *DSimApp) BeginBlock() { + app.curBlockHeight, app.curBlockTime = app.GetNextBlockHeightTime() + + app.DnApp.BeginBlock( + abci.RequestBeginBlock{ + Header: tmProto.Header{ + Height: app.curBlockHeight, + Time: app.curBlockTime, + }, + }, + ) +} + +// EndBlock ends the current block. +func (app *DSimApp) EndBlock() { + app.DnApp.EndBlock(abci.RequestEndBlock{}) + app.DnApp.Commit() +} + +// DeliverTx generates, signs and sends Tx containing messages. +func (app *DSimApp) DeliverTx(ctx sdk.Context, accAddr sdk.AccAddress, accPrivKey cryptoTypes.PrivKey, msgs []sdk.Msg, options ...DeliverTxOption) (sdk.GasInfo, *sdk.Result, error) { + txCfg := app.encCfg.TxConfig + + // Get the latest account data + acc := app.DnApp.AccountKeeper.GetAccount(ctx, accAddr) + if acc == nil { + panic(fmt.Errorf("account (%s): not found", accAddr)) + } + + // Apply options + gasLimit := uint64(helpers.DefaultGenTxGas) + for _, opt := range options { + opt(&gasLimit) + } + + // Generate and sign Tx + feeCoin := sdk.Coins{sdk.NewInt64Coin(dnConfig.MainDenom, 1)} + tx, err := helpers.GenTx(txCfg, msgs, feeCoin, gasLimit, "", []uint64{acc.GetAccountNumber()}, []uint64{acc.GetSequence()}, accPrivKey) + if err != nil { + panic(fmt.Errorf("generating Tx: %w", err)) + } + + // Simulate Tx + txBytes, err := txCfg.TxEncoder()(tx) + if err != nil { + panic(fmt.Errorf("encoding Tx: %w", err)) + } + + gasInfo, res, err := app.DnApp.Simulate(txBytes) + if err != nil { + return gasInfo, res, err + } + + // Deliver Tx + app.BeginBlock() + gasInfo, res, err = app.DnApp.Deliver(txCfg.TxEncoder(), tx) + app.EndBlock() + + return gasInfo, res, err +} + +func TxWithGasLimit(limit uint64) DeliverTxOption { + return func(gasLimit *uint64) { + *gasLimit = limit + } +} diff --git a/pkg/tests/dvm.go b/pkg/tests/dvm.go new file mode 100644 index 0000000..0722902 --- /dev/null +++ b/pkg/tests/dvm.go @@ -0,0 +1,113 @@ +package tests + +import ( + "fmt" + "os" +) + +const ( + EnvDvmIntegUse = "DN_DVM_INTEG_TESTS_USE" // defines which DVM runner is used: "binary", "docker","" (not integ tests) + EnvDvmIntegDockerRegistry = "DN_DVM_INTEG_TESTS_DOCKER_REGISTRY" // Docker runner: registry + EnvDvmIntegDockerTag = "DN_DVM_INTEG_TESTS_DOCKER_TAG" // Docker runner: DVM tag + EnvDvmIntegBinaryPath = "DN_DVM_INTEG_TESTS_BINARY_PATH" // Binary runner: directory path containing DVM binary (dvm), if empty - $PATH is used + // + EnvDvmIntegUseDocker = "docker" + EnvDvmIntegUseBinary = "binary" + // + TestErrFmt = "Launching DVM over %s with %s transport" +) + +func LaunchDVMWithNetTransport(connectPort, dsServerPort string, printLogs bool, args ...string) (stopFunc func() error, retErr error) { + transportLabel := "Net" + + if ok, registry, tag, errMsg := dvmDockerLaunchEnvParams(transportLabel); ok { + container, err := NewDockerDVMWithNetTransport(registry, tag, connectPort, dsServerPort, printLogs, args...) + if err != nil { + retErr = fmt.Errorf("%s: %w", errMsg, err) + return + } + + stopFunc = func() error { + return container.Stop() + } + + return + } + + if ok, path, errMsg := dvmBinaryLaunchEnvParams(transportLabel); ok { + cmd, err := NewBinaryDVMWithNetTransport(path, connectPort, dsServerPort, printLogs, args...) + if err != nil { + retErr = fmt.Errorf("%s: %w", errMsg, err) + return + } + + stopFunc = func() error { + return cmd.Stop() + } + + return + } + + retErr = fmt.Errorf("Docker / Binary DVM launch option not specified: %s", os.Getenv(EnvDvmIntegUse)) + + return +} + +func LaunchDVMWithUDSTransport(socketsDir, connectSocketName, dsSocketName string, printLogs bool, args ...string) (stopFunc func() error, retErr error) { + transportLabel := "UDS" + + if ok, registry, tag, errMsg := dvmDockerLaunchEnvParams(transportLabel); ok { + container, err := NewDockerDVMWithUDSTransport(registry, tag, socketsDir, connectSocketName, dsSocketName, printLogs, args...) + if err != nil { + retErr = fmt.Errorf("%s: %w", errMsg, err) + return + } + + stopFunc = func() error { + return container.Stop() + } + + return + } + + if ok, cmdPath, errMsg := dvmBinaryLaunchEnvParams(transportLabel); ok { + cmd, err := NewBinaryDVMWithUDSTransport(cmdPath, socketsDir, connectSocketName, dsSocketName, printLogs, args...) + if err != nil { + retErr = fmt.Errorf("%s: %w", errMsg, err) + return + } + + stopFunc = func() error { + return cmd.Stop() + } + + return + } + + retErr = fmt.Errorf("Docker / Binary DVM launch option not specified: %s", os.Getenv(EnvDvmIntegUse)) + + return +} + +func dvmDockerLaunchEnvParams(transportLabel string) (enabled bool, registry, tag, errMsg string) { + if os.Getenv(EnvDvmIntegUse) != EnvDvmIntegUseDocker { + return + } + enabled = true + registry = os.Getenv(EnvDvmIntegDockerRegistry) + tag = os.Getenv(EnvDvmIntegDockerTag) + errMsg = fmt.Sprintf(TestErrFmt, EnvDvmIntegUseDocker, transportLabel) + + return +} + +func dvmBinaryLaunchEnvParams(transportLabel string) (enabled bool, path, errMsg string) { + if os.Getenv(EnvDvmIntegUse) != EnvDvmIntegUseBinary { + return + } + enabled = true + path = os.Getenv(EnvDvmIntegBinaryPath) + errMsg = fmt.Sprintf(TestErrFmt, EnvDvmIntegUseBinary, transportLabel) + + return +} diff --git a/pkg/tests/proc_binary.go b/pkg/tests/proc_binary.go new file mode 100644 index 0000000..51117b7 --- /dev/null +++ b/pkg/tests/proc_binary.go @@ -0,0 +1,169 @@ +package tests + +import ( + "bufio" + "fmt" + "io" + "os/exec" + "path" + "strings" + "time" +) + +const ( + DvmBinaryStartTimeout = 2 * time.Second +) + +// BinaryCmdOption defines functional arguments for NewBinaryCmd. +type BinaryCmdOption func(*BinaryCmd) error + +// BinaryCmd keeps process metadata. +type BinaryCmd struct { + cmd string + args []string + proc *exec.Cmd + printLogs bool +} + +func (c *BinaryCmd) String() string { + return fmt.Sprintf("binary %s %s", c.cmd, strings.Join(c.args, " ")) +} + +// Start starts a new process in background. +func (c *BinaryCmd) Start() error { + if c.proc != nil { + return fmt.Errorf("%s: process already started", c) + } + c.proc = exec.Command(c.cmd, c.args...) + + if c.printLogs { + stdoutPipe, err := c.proc.StdoutPipe() + if err != nil { + return fmt.Errorf("%s: getting stdout pipe: %w", c, err) + } + stderrPipe, err := c.proc.StderrPipe() + if err != nil { + return fmt.Errorf("%s: getting stderr pipe: %w", c, err) + } + + c.startLogWorker(FmtInfColorPrefix, stdoutPipe) + c.startLogWorker(FmtWrnColorPrefix, stderrPipe) + } + + if err := c.proc.Start(); err != nil { + return fmt.Errorf("%s: starting process: %w", c, err) + } + + return nil +} + +// Stop sends SIGKILL to a running process. +func (c *BinaryCmd) Stop() error { + if c.proc == nil { + return nil + } + + if err := c.proc.Process.Kill(); err != nil { + return fmt.Errorf("%s: stop failed: %w", c, err) + } + + return nil +} + +// startLogWorker starts the logs pipe logger (to the Host stdout). +func (c *BinaryCmd) startLogWorker(msgFmtPrefix string, pipe io.ReadCloser) { + msgFmt := msgFmtPrefix + "%s: %s" + FmtColorEndLine + buf := bufio.NewReader(pipe) + + go func() { + for { + line, _, err := buf.ReadLine() + if err != nil { + if err == io.EOF { + return + } + + fmt.Printf("%s: broken pipe: %v", c, err.Error()) + return + } + + fmt.Printf(msgFmt, path.Base(c.cmd), line) + } + }() +} + +// NewBinaryCmd creates a new BinaryCmd (no Start). +func NewBinaryCmd(cmd string, options ...BinaryCmdOption) (*BinaryCmd, error) { + c := &BinaryCmd{ + cmd: cmd, + } + + for _, option := range options { + if err := option(c); err != nil { + return nil, fmt.Errorf("%s: option apply failed: %w", c, err) + } + } + + return c, nil +} + +// BinaryWithArgs sets process arguments. +func BinaryWithArgs(args ...string) BinaryCmdOption { + return func(c *BinaryCmd) error { + c.args = args + return nil + } +} + +// BinaryWithConsoleLogs redirects process stdout / stderr to the current stdout. +func BinaryWithConsoleLogs(enabled bool) BinaryCmdOption { + return func(c *BinaryCmd) error { + c.printLogs = enabled + return nil + } +} + +// NewBinaryDVMWithNetTransport creates and starts a new DVM BinaryCmd with TCP connection. +func NewBinaryDVMWithNetTransport(basePath, connectPort, dsServerPort string, printLogs bool, args ...string) (*BinaryCmd, error) { + cmdArgs := []string{ + "http://127.0.0.1:" + connectPort, + "http://127.0.0.1:" + dsServerPort, + } + cmdArgs = append(cmdArgs, args...) + + c, err := NewBinaryCmd(path.Join(basePath, "dvm"), BinaryWithArgs(cmdArgs...), BinaryWithConsoleLogs(printLogs)) + if err != nil { + return nil, err + } + + if err := c.Start(); err != nil { + return nil, err + } + time.Sleep(DvmBinaryStartTimeout) + + return c, nil +} + +// NewBinaryDVMWithUDSTransport creates and starts a new DVM BinaryCmd with UDS connection. +func NewBinaryDVMWithUDSTransport(basePath, socketsDir, connectSocketName, dsSocketName string, printLogs bool, args ...string) (*BinaryCmd, error) { + cmdArgs := []string{ + "ipc:/" + path.Join(socketsDir, connectSocketName), + "ipc:/" + path.Join(socketsDir, dsSocketName), + } + cmdArgs = append(cmdArgs, args...) + + c, err := NewBinaryCmd(path.Join(basePath, "dvm"), BinaryWithArgs(cmdArgs...), BinaryWithConsoleLogs(printLogs)) + if err != nil { + return nil, err + } + + if err := c.Start(); err != nil { + return nil, err + } + + if err := WaitForFileExists(path.Join(socketsDir, connectSocketName), DvmBinaryStartTimeout); err != nil { + return nil, fmt.Errorf("%s: waiting for UDS server to start-up: %v", c.Start(), err) + } + + return c, nil +} diff --git a/pkg/tests/proc_docker.go b/pkg/tests/proc_docker.go new file mode 100644 index 0000000..4931a22 --- /dev/null +++ b/pkg/tests/proc_docker.go @@ -0,0 +1,389 @@ +package tests + +import ( + "bytes" + "fmt" + "io" + "os" + "path" + "runtime" + "strings" + "time" + + docker "github.com/fsouza/go-dockerclient" +) + +const ( + DvmDockerStartTimeout = 5 * time.Second +) + +// DockerContainerOption defines functional arguments for NewDockerContainer. +type DockerContainerOption func(*DockerContainer) error + +// DockerContainer keeps Docker container metadata. +type DockerContainer struct { + dClient *docker.Client + dContainer *docker.Container + dOptions docker.CreateContainerOptions + printLogs bool + logsStreamStopCh chan bool +} + +func (c *DockerContainer) String() string { + return "container " + c.dOptions.Config.Image +} + +// Start starts a new container with timeout. +func (c *DockerContainer) Start(startTimeout time.Duration) error { + if c.dClient != nil { + return fmt.Errorf("%s: already started", c.String()) + } + + client, err := docker.NewClientFromEnv() + if err != nil { + return fmt.Errorf("%s: connecting to docker: %w", c.String(), err) + } + + container, err := client.CreateContainer(c.dOptions) + if err != nil { + return fmt.Errorf("%s: creating container: %w", c.String(), err) + } + + if err := client.StartContainer(container.ID, nil); err != nil { + return fmt.Errorf("%s: starting container: %w", c.String(), err) + } + + if c.printLogs { + var stdoutBuf, stderrBuf bytes.Buffer + opts := docker.LogsOptions{ + Container: container.ID, + OutputStream: &stdoutBuf, + ErrorStream: &stderrBuf, + Follow: true, + Stdout: true, + Stderr: true, + } + + c.logsStreamStopCh = make(chan bool) + go func() { + if err := client.Logs(opts); err != nil { + fmt.Printf("%s: logs worker: %v\n", c.String(), err) + } + }() + + c.startLogWorker(FmtInfColorPrefix, &stdoutBuf, c.logsStreamStopCh) + c.startLogWorker(FmtWrnColorPrefix, &stderrBuf, c.logsStreamStopCh) + } + + // Wait for container to start + timeoutCh := time.NewTimer(startTimeout).C + for { + inspectContainer, err := client.InspectContainerWithOptions(docker.InspectContainerOptions{ID: container.ID}) + if err != nil { + return fmt.Errorf("%s: wait for container to start: %w", c, err) + } + if inspectContainer.State.Running { + break + } + + select { + case <-timeoutCh: + return fmt.Errorf("%s: wait for container to start: timeout reached (%v)", c, startTimeout) + default: + time.Sleep(100 * time.Millisecond) + } + } + + // Wait for all TCP port to be reachable + portReports := make(map[docker.Port]string) + for p := range c.dOptions.Config.ExposedPorts { + portReports[p] = "not checked" + } + for { + cnt := len(portReports) + for p, status := range portReports { + if status == "OK" { + cnt-- + continue + } + + if err := PingTcpAddress("127.0.0.1:"+p.Port(), 500*time.Millisecond); err != nil { + portReports[p] = err.Error() + } else { + portReports[p] = "OK" + cnt-- + continue + } + + select { + case <-timeoutCh: + reports := make([]string, 0, len(portReports)) + for p, status := range portReports { + reports = append(reports, fmt.Sprintf("%s: %s", p.Port(), status)) + } + + return fmt.Errorf( + "%s: wait for container TCP ports to be rechable: timeout reached (%v): %s", + c, startTimeout, strings.Join(reports, ", "), + ) + default: + time.Sleep(100 * time.Millisecond) + } + } + if cnt == 0 { + break + } + } + + c.dClient = client + c.dContainer = container + + return nil +} + +// Stop stops a running container. +func (c *DockerContainer) Stop() error { + if c.dClient == nil { + return fmt.Errorf("%s: not started", c) + } + + if c.logsStreamStopCh != nil { + close(c.logsStreamStopCh) + } + err := c.dClient.RemoveContainer(docker.RemoveContainerOptions{ + ID: c.dContainer.ID, + Force: true, + }) + if err != nil { + return fmt.Errorf("%s: removing container: %w", c, err) + } + + return nil +} + +// startLogWorker starts the logs buffer logger (to the Host stdout). +func (c *DockerContainer) startLogWorker(msgFmtPrefix string, buf *bytes.Buffer, stopCh chan bool) { + logCh := make(chan string) + msgFmt := msgFmtPrefix + "%s: %s" + FmtColorEndLine + + go func() { + for msg := range logCh { + fmt.Printf(msgFmt, c, msg) + } + }() + + go func() { + defer close(logCh) + + for { + select { + case <-stopCh: + return + default: + line, err := buf.ReadString('\n') + if err != nil && err != io.EOF { + return + } + + line = strings.TrimSpace(line) + if line != "" { + logCh <- line + } + } + } + }() +} + +// NewDockerContainer creates a new DockerContainer object (no Start). +func NewDockerContainer(options ...DockerContainerOption) (*DockerContainer, error) { + c := DockerContainer{} + + c.dOptions = docker.CreateContainerOptions{ + Config: &docker.Config{}, + HostConfig: &docker.HostConfig{}, + } + + for _, options := range options { + if err := options(&c); err != nil { + return nil, err + } + } + + return &c, nil +} + +// DockerWithCreds sets container registry, name and tag. +func DockerWithCreds(registry, name, tag string) DockerContainerOption { + return func(c *DockerContainer) error { + c.dOptions.Config.Image = fmt.Sprintf("%s/%s:%s", registry, name, tag) + return nil + } +} + +// DockerWithCmdArgs sets container cmd arguments. +func DockerWithCmdArgs(cmdArgs []string) DockerContainerOption { + return func(c *DockerContainer) error { + c.dOptions.Config.Cmd = cmdArgs + return nil + } +} + +// DockerWithVolume mounts Docker volume to a container. +func DockerWithVolume(hostPath, containerPath string) DockerContainerOption { + return func(c *DockerContainer) error { + c.dOptions.HostConfig.VolumeDriver = "bind" + c.dOptions.HostConfig.Binds = append( + c.dOptions.HostConfig.Binds, + fmt.Sprintf("%s:%s", hostPath, containerPath), + ) + + return nil + } +} + +// DockerWithTcpPorts bridges TCP ports from the Host to a container. +func DockerWithTcpPorts(tcpPorts []string) DockerContainerOption { + return func(c *DockerContainer) error { + ports := make(map[docker.Port]struct{}, len(tcpPorts)) + portBindings := make(map[docker.Port][]docker.PortBinding, len(tcpPorts)) + for _, p := range tcpPorts { + dPort := docker.Port(fmt.Sprintf("%s/tcp", p)) + + ports[dPort] = struct{}{} + portBindings[dPort] = []docker.PortBinding{ + { + HostIP: "0.0.0.0", + HostPort: dPort.Port(), + }, + } + } + + c.dOptions.Config.ExposedPorts = ports + c.dOptions.HostConfig.PortBindings = portBindings + + return nil + } +} + +// DockerWithHostNetwork sets the Host address and network mode. +func DockerWithHostNetwork() DockerContainerOption { + return func(c *DockerContainer) error { + _, mode, err := HostMachineDockerUrl() + if err != nil { + return err + } + + c.dOptions.HostConfig.NetworkMode = mode + + return nil + } +} + +// DockerWithUser sets custom UID and GID for a container. +func DockerWithUser() DockerContainerOption { + return func(c *DockerContainer) error { + userUid, userGid := os.Getuid(), os.Getgid() + if userUid < 0 { + return fmt.Errorf("invalid user UID: %d", userUid) + } + if userGid < 0 { + return fmt.Errorf("invalid user GID: %d", userGid) + } + + c.dOptions.Config.User = fmt.Sprintf("%d:%d", userUid, userGid) + + return nil + } +} + +// DockerWithConsoleLogs enables container logs print to the Host stdout. +func DockerWithConsoleLogs(enabled bool) DockerContainerOption { + return func(c *DockerContainer) error { + c.printLogs = enabled + return nil + } +} + +// NewDockerDVMWithNetTransport creates and starts a new DVM DockerContainer with TCP connection. +func NewDockerDVMWithNetTransport(registry, tag, connectPort, dsServerPort string, printLogs bool, args ...string) (*DockerContainer, error) { + if registry == "" || tag == "" { + return nil, fmt.Errorf("registry / tag: not specified") + } + + hostUrl, _, _ := HostMachineDockerUrl() + dsServerAddress := fmt.Sprintf("%s:%s", hostUrl, dsServerPort) + cmdArgs := []string{"./dvm", "http://0.0.0.0:" + connectPort, dsServerAddress} + if len(args) > 0 { + cmdArgs = append(cmdArgs, strings.Join(args, " ")) + } + + container, err := NewDockerContainer( + DockerWithCreds(registry, "dfinance/dvm", tag), + DockerWithCmdArgs(cmdArgs), + DockerWithTcpPorts([]string{connectPort}), + DockerWithHostNetwork(), + DockerWithConsoleLogs(printLogs), + ) + if err != nil { + return nil, fmt.Errorf("creating DVM container over Net: %v", err) + } + + if err := container.Start(DvmDockerStartTimeout); err != nil { + return nil, fmt.Errorf("starting DVM container over Net: %v", err) + } + + return container, nil +} + +// NewDockerDVMWithUDSTransport creates and starts a new DVM DockerContainer with UDS connection. +func NewDockerDVMWithUDSTransport(registry, tag, volumePath, vmFileName, dsFileName string, printLogs bool, args ...string) (*DockerContainer, error) { + const defVolumePath = "/tmp/dn-uds" + + if registry == "" || tag == "" { + return nil, fmt.Errorf("registry / tag: not specified") + } + + vmFilePath := path.Join(defVolumePath, vmFileName) + dsFilePath := path.Join(defVolumePath, dsFileName) + + // one '/' is omitted on purpose + cmdArgs := []string{"./dvm", "ipc:/" + vmFilePath, "ipc:/" + dsFilePath} + if len(args) > 0 { + cmdArgs = append(cmdArgs, strings.Join(args, " ")) + } + + container, err := NewDockerContainer( + DockerWithCreds(registry, "dfinance/dvm", tag), + DockerWithCmdArgs(cmdArgs), + DockerWithVolume(volumePath, defVolumePath), + DockerWithUser(), + DockerWithConsoleLogs(printLogs), + ) + if err != nil { + return nil, fmt.Errorf("creating DVM container over UDS: %v", err) + } + + if err := container.Start(DvmDockerStartTimeout); err != nil { + return nil, fmt.Errorf("starting DVM container over UDS: %v", err) + } + + if err := WaitForFileExists(path.Join(volumePath, vmFileName), DvmDockerStartTimeout); err != nil { + return nil, fmt.Errorf("creating DVM container over UDS: %v", err) + } + + return container, nil +} + +// HostMachineDockerUrl returns the Host address and network mode (OS-dependant). +func HostMachineDockerUrl() (hostUrl, hostNetworkMode string, err error) { + switch runtime.GOOS { + case "darwin", "windows": + hostUrl, hostNetworkMode = "http://host.docker.internal", "" + case "linux": + hostUrl, hostNetworkMode = "http://localhost", "host" + default: + err = fmt.Errorf("unsupported OS: %s", runtime.GOOS) + } + + return +} diff --git a/pkg/tests/testify.go b/pkg/tests/testify.go new file mode 100644 index 0000000..5e5495e --- /dev/null +++ b/pkg/tests/testify.go @@ -0,0 +1,21 @@ +package tests + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func CheckPanicErrorContains(t *testing.T, handler func(), errSubStr string) { + defer func() { + r := recover() + require.NotNil(t, r, "handler did not panic") + + err, ok := r.(error) + require.True(t, ok, "panic obj is not an error") + + require.Contains(t, err.Error(), errSubStr) + }() + + handler() +} diff --git a/pkg/tests/utils.go b/pkg/tests/utils.go new file mode 100644 index 0000000..c4b0e7b --- /dev/null +++ b/pkg/tests/utils.go @@ -0,0 +1,75 @@ +package tests + +import ( + "fmt" + "net" + "os" + "strings" + "time" + + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + cryptoTypes "github.com/cosmos/cosmos-sdk/crypto/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +const ( + FmtInfColorPrefix = "\033[1;34m" + FmtWrnColorPrefix = "\033[1;33m" + FmtColorEndLine = "\033[0m\n" +) + +// GenAccAddress generates an sdk.AccAddress with its public / private keys. +func GenAccAddress() (sdk.AccAddress, cryptoTypes.PubKey, cryptoTypes.PrivKey) { + pk := secp256k1.GenPrivKey() + //pk := ed25519.GenPrivKey() + + return sdk.AccAddress(pk.PubKey().Address()), pk.PubKey(), pk +} + +// WaitForFileExists waits for a file to be created. +func WaitForFileExists(filePath string, timeoutDur time.Duration) error { + timeoutCh := time.After(timeoutDur) + + for { + select { + case <-timeoutCh: + return fmt.Errorf("file %q did not appear after %v", filePath, timeoutDur) + default: + if _, err := os.Stat(filePath); err == nil { + return nil + } + } + } +} + +// PingTcpAddress check the TCP connection (Dial with retry). +func PingTcpAddress(address string, timeout time.Duration) error { + const dialTimeout = 500 * time.Millisecond + + // remove scheme prefix + if i := strings.Index(address, "://"); i != -1 { + address = address[i+3:] + } + + retryCount := int(timeout / dialTimeout) + connected := false + for i := 0; i < retryCount; i++ { + conn, err := net.DialTimeout("tcp", address, dialTimeout) + if err == nil { + connected = true + } + if conn != nil { + conn.Close() + } + + if connected { + break + } + } + + if !connected { + return fmt.Errorf("TCP ping to %s failed after %d retry attempts with %v timeout", address, retryCount, dialTimeout) + } + + return nil +} diff --git a/pkg/types/dvm/common-types.pb.go b/pkg/types/dvm/common-types.pb.go new file mode 100644 index 0000000..e594e2d --- /dev/null +++ b/pkg/types/dvm/common-types.pb.go @@ -0,0 +1,361 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: dfinance/dvm/common-types.proto + +package dvm + +import ( + fmt "fmt" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Type of contract argument. +type VMTypeTag int32 + +const ( + VMTypeTag_Bool VMTypeTag = 0 + VMTypeTag_U64 VMTypeTag = 1 + VMTypeTag_Vector VMTypeTag = 2 + VMTypeTag_Address VMTypeTag = 3 + VMTypeTag_U8 VMTypeTag = 4 + VMTypeTag_U128 VMTypeTag = 5 +) + +var VMTypeTag_name = map[int32]string{ + 0: "Bool", + 1: "U64", + 2: "Vector", + 3: "Address", + 4: "U8", + 5: "U128", +} + +var VMTypeTag_value = map[string]int32{ + "Bool": 0, + "U64": 1, + "Vector": 2, + "Address": 3, + "U8": 4, + "U128": 5, +} + +func (x VMTypeTag) String() string { + return proto.EnumName(VMTypeTag_name, int32(x)) +} + +func (VMTypeTag) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_9c41ce4bb2a9f467, []int{0} +} + +/// u128 type. +type U128 struct { + Buf []byte `protobuf:"bytes,1,opt,name=buf,proto3" json:"buf,omitempty"` +} + +func (m *U128) Reset() { *m = U128{} } +func (m *U128) String() string { return proto.CompactTextString(m) } +func (*U128) ProtoMessage() {} +func (*U128) Descriptor() ([]byte, []int) { + return fileDescriptor_9c41ce4bb2a9f467, []int{0} +} +func (m *U128) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *U128) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_U128.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 *U128) XXX_Merge(src proto.Message) { + xxx_messageInfo_U128.Merge(m, src) +} +func (m *U128) XXX_Size() int { + return m.Size() +} +func (m *U128) XXX_DiscardUnknown() { + xxx_messageInfo_U128.DiscardUnknown(m) +} + +var xxx_messageInfo_U128 proto.InternalMessageInfo + +func (m *U128) GetBuf() []byte { + if m != nil { + return m.Buf + } + return nil +} + +func init() { + proto.RegisterEnum("dfinance.dvm.VMTypeTag", VMTypeTag_name, VMTypeTag_value) + proto.RegisterType((*U128)(nil), "dfinance.dvm.u128") +} + +func init() { proto.RegisterFile("dfinance/dvm/common-types.proto", fileDescriptor_9c41ce4bb2a9f467) } + +var fileDescriptor_9c41ce4bb2a9f467 = []byte{ + // 226 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4f, 0x49, 0xcb, 0xcc, + 0x4b, 0xcc, 0x4b, 0x4e, 0xd5, 0x4f, 0x29, 0xcb, 0xd5, 0x4f, 0xce, 0xcf, 0xcd, 0xcd, 0xcf, 0xd3, + 0x2d, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x81, 0x29, 0xd0, + 0x4b, 0x29, 0xcb, 0x55, 0x92, 0xe0, 0x62, 0x29, 0x35, 0x34, 0xb2, 0x10, 0x12, 0xe0, 0x62, 0x4e, + 0x2a, 0x4d, 0x93, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x09, 0x02, 0x31, 0xb5, 0x3c, 0xb9, 0x38, 0xc3, + 0x7c, 0x43, 0x2a, 0x0b, 0x52, 0x43, 0x12, 0xd3, 0x85, 0x38, 0xb8, 0x58, 0x9c, 0xf2, 0xf3, 0x73, + 0x04, 0x18, 0x84, 0xd8, 0xb9, 0x98, 0x43, 0xcd, 0x4c, 0x04, 0x18, 0x85, 0xb8, 0xb8, 0xd8, 0xc2, + 0x52, 0x93, 0x4b, 0xf2, 0x8b, 0x04, 0x98, 0x84, 0xb8, 0xb9, 0xd8, 0x1d, 0x53, 0x52, 0x8a, 0x52, + 0x8b, 0x8b, 0x05, 0x98, 0x85, 0xd8, 0xb8, 0x98, 0x42, 0x2d, 0x04, 0x58, 0x40, 0x7a, 0x42, 0x0d, + 0x8d, 0x2c, 0x04, 0x58, 0x9d, 0x5c, 0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, + 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, + 0x4a, 0x2b, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x1f, 0xe1, 0xf0, 0xe2, + 0x92, 0xc4, 0x92, 0xcc, 0xfc, 0x3c, 0xfd, 0x82, 0xec, 0x74, 0x7d, 0xb0, 0xd3, 0x41, 0x7e, 0x49, + 0x62, 0x03, 0xbb, 0xdf, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0xf3, 0x76, 0xdc, 0xee, 0xe2, 0x00, + 0x00, 0x00, +} + +func (m *U128) 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 *U128) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *U128) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Buf) > 0 { + i -= len(m.Buf) + copy(dAtA[i:], m.Buf) + i = encodeVarintCommonTypes(dAtA, i, uint64(len(m.Buf))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintCommonTypes(dAtA []byte, offset int, v uint64) int { + offset -= sovCommonTypes(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *U128) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Buf) + if l > 0 { + n += 1 + l + sovCommonTypes(uint64(l)) + } + return n +} + +func sovCommonTypes(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozCommonTypes(x uint64) (n int) { + return sovCommonTypes(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *U128) 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 ErrIntOverflowCommonTypes + } + 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: u128: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: u128: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Buf", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCommonTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthCommonTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthCommonTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Buf = append(m.Buf[:0], dAtA[iNdEx:postIndex]...) + if m.Buf == nil { + m.Buf = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipCommonTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthCommonTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipCommonTypes(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowCommonTypes + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowCommonTypes + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowCommonTypes + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthCommonTypes + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupCommonTypes + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthCommonTypes + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthCommonTypes = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowCommonTypes = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupCommonTypes = fmt.Errorf("proto: unexpected end of group") +) diff --git a/pkg/types/dvm/compiler.pb.go b/pkg/types/dvm/compiler.pb.go new file mode 100644 index 0000000..d533f42 --- /dev/null +++ b/pkg/types/dvm/compiler.pb.go @@ -0,0 +1,1157 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: dfinance/dvm/compiler.proto + +package dvm + +import ( + context "context" + fmt "fmt" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Compilation unit. +type CompilationUnit struct { + Text string `protobuf:"bytes,1,opt,name=text,proto3" json:"text,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` +} + +func (m *CompilationUnit) Reset() { *m = CompilationUnit{} } +func (m *CompilationUnit) String() string { return proto.CompactTextString(m) } +func (*CompilationUnit) ProtoMessage() {} +func (*CompilationUnit) Descriptor() ([]byte, []int) { + return fileDescriptor_8a4d9f4d9267a592, []int{0} +} +func (m *CompilationUnit) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CompilationUnit) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CompilationUnit.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 *CompilationUnit) XXX_Merge(src proto.Message) { + xxx_messageInfo_CompilationUnit.Merge(m, src) +} +func (m *CompilationUnit) XXX_Size() int { + return m.Size() +} +func (m *CompilationUnit) XXX_DiscardUnknown() { + xxx_messageInfo_CompilationUnit.DiscardUnknown(m) +} + +var xxx_messageInfo_CompilationUnit proto.InternalMessageInfo + +func (m *CompilationUnit) GetText() string { + if m != nil { + return m.Text + } + return "" +} + +func (m *CompilationUnit) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +// Compiler API +type SourceFiles struct { + Units []*CompilationUnit `protobuf:"bytes,1,rep,name=units,proto3" json:"units,omitempty"` + Address []byte `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` +} + +func (m *SourceFiles) Reset() { *m = SourceFiles{} } +func (m *SourceFiles) String() string { return proto.CompactTextString(m) } +func (*SourceFiles) ProtoMessage() {} +func (*SourceFiles) Descriptor() ([]byte, []int) { + return fileDescriptor_8a4d9f4d9267a592, []int{1} +} +func (m *SourceFiles) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SourceFiles) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SourceFiles.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 *SourceFiles) XXX_Merge(src proto.Message) { + xxx_messageInfo_SourceFiles.Merge(m, src) +} +func (m *SourceFiles) XXX_Size() int { + return m.Size() +} +func (m *SourceFiles) XXX_DiscardUnknown() { + xxx_messageInfo_SourceFiles.DiscardUnknown(m) +} + +var xxx_messageInfo_SourceFiles proto.InternalMessageInfo + +func (m *SourceFiles) GetUnits() []*CompilationUnit { + if m != nil { + return m.Units + } + return nil +} + +func (m *SourceFiles) GetAddress() []byte { + if m != nil { + return m.Address + } + return nil +} + +// Compiled source. +type CompiledUnit struct { + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Bytecode []byte `protobuf:"bytes,2,opt,name=bytecode,proto3" json:"bytecode,omitempty"` +} + +func (m *CompiledUnit) Reset() { *m = CompiledUnit{} } +func (m *CompiledUnit) String() string { return proto.CompactTextString(m) } +func (*CompiledUnit) ProtoMessage() {} +func (*CompiledUnit) Descriptor() ([]byte, []int) { + return fileDescriptor_8a4d9f4d9267a592, []int{2} +} +func (m *CompiledUnit) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CompiledUnit) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CompiledUnit.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 *CompiledUnit) XXX_Merge(src proto.Message) { + xxx_messageInfo_CompiledUnit.Merge(m, src) +} +func (m *CompiledUnit) XXX_Size() int { + return m.Size() +} +func (m *CompiledUnit) XXX_DiscardUnknown() { + xxx_messageInfo_CompiledUnit.DiscardUnknown(m) +} + +var xxx_messageInfo_CompiledUnit proto.InternalMessageInfo + +func (m *CompiledUnit) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *CompiledUnit) GetBytecode() []byte { + if m != nil { + return m.Bytecode + } + return nil +} + +type CompilationResult struct { + Units []*CompiledUnit `protobuf:"bytes,1,rep,name=units,proto3" json:"units,omitempty"` + Errors []string `protobuf:"bytes,2,rep,name=errors,proto3" json:"errors,omitempty"` +} + +func (m *CompilationResult) Reset() { *m = CompilationResult{} } +func (m *CompilationResult) String() string { return proto.CompactTextString(m) } +func (*CompilationResult) ProtoMessage() {} +func (*CompilationResult) Descriptor() ([]byte, []int) { + return fileDescriptor_8a4d9f4d9267a592, []int{3} +} +func (m *CompilationResult) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CompilationResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CompilationResult.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 *CompilationResult) XXX_Merge(src proto.Message) { + xxx_messageInfo_CompilationResult.Merge(m, src) +} +func (m *CompilationResult) XXX_Size() int { + return m.Size() +} +func (m *CompilationResult) XXX_DiscardUnknown() { + xxx_messageInfo_CompilationResult.DiscardUnknown(m) +} + +var xxx_messageInfo_CompilationResult proto.InternalMessageInfo + +func (m *CompilationResult) GetUnits() []*CompiledUnit { + if m != nil { + return m.Units + } + return nil +} + +func (m *CompilationResult) GetErrors() []string { + if m != nil { + return m.Errors + } + return nil +} + +func init() { + proto.RegisterType((*CompilationUnit)(nil), "dfinance.dvm.CompilationUnit") + proto.RegisterType((*SourceFiles)(nil), "dfinance.dvm.SourceFiles") + proto.RegisterType((*CompiledUnit)(nil), "dfinance.dvm.CompiledUnit") + proto.RegisterType((*CompilationResult)(nil), "dfinance.dvm.CompilationResult") +} + +func init() { proto.RegisterFile("dfinance/dvm/compiler.proto", fileDescriptor_8a4d9f4d9267a592) } + +var fileDescriptor_8a4d9f4d9267a592 = []byte{ + // 325 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x91, 0xb1, 0x4e, 0xc3, 0x30, + 0x10, 0x86, 0x63, 0x0a, 0x2d, 0xbd, 0x56, 0x42, 0x78, 0x40, 0xa1, 0x88, 0x50, 0x65, 0xaa, 0x18, + 0x12, 0xd4, 0x4e, 0x2c, 0x0c, 0x50, 0xc1, 0x1e, 0x04, 0x03, 0x82, 0x21, 0x8d, 0x8f, 0x62, 0xd1, + 0xc4, 0x91, 0xed, 0x54, 0xf4, 0x2d, 0x78, 0x2c, 0xc6, 0x8e, 0x8c, 0xa8, 0x7d, 0x11, 0x14, 0x27, + 0xa1, 0x2d, 0x82, 0xed, 0xce, 0xe7, 0xff, 0xfe, 0x4f, 0xf7, 0xc3, 0x11, 0x7b, 0xe6, 0x49, 0x98, + 0x44, 0xe8, 0xb3, 0x69, 0xec, 0x47, 0x22, 0x4e, 0xf9, 0x04, 0xa5, 0x97, 0x4a, 0xa1, 0x05, 0x6d, + 0x57, 0x43, 0x8f, 0x4d, 0x63, 0xf7, 0x1c, 0xf6, 0xae, 0xcc, 0x3c, 0xd4, 0x5c, 0x24, 0x77, 0x09, + 0xd7, 0x94, 0xc2, 0xb6, 0xc6, 0x37, 0x6d, 0x93, 0x2e, 0xe9, 0x35, 0x03, 0x53, 0xe7, 0x6f, 0x49, + 0x18, 0xa3, 0xbd, 0x55, 0xbc, 0xe5, 0xb5, 0xfb, 0x08, 0xad, 0x5b, 0x91, 0xc9, 0x08, 0xaf, 0xf9, + 0x04, 0x15, 0x1d, 0xc0, 0x4e, 0x96, 0x70, 0xad, 0x6c, 0xd2, 0xad, 0xf5, 0x5a, 0xfd, 0x63, 0x6f, + 0xdd, 0xc7, 0xfb, 0x65, 0x12, 0x14, 0x7f, 0xa9, 0x0d, 0x8d, 0x90, 0x31, 0x89, 0x4a, 0x99, 0xd5, + 0xed, 0xa0, 0x6a, 0xdd, 0x0b, 0x68, 0x17, 0x1a, 0x64, 0x15, 0x95, 0x21, 0x20, 0x2b, 0x02, 0xda, + 0x81, 0xdd, 0xd1, 0x4c, 0x63, 0x24, 0x18, 0x96, 0xf2, 0x9f, 0xde, 0x7d, 0x82, 0xfd, 0x35, 0xcf, + 0x00, 0x55, 0x36, 0xd1, 0xf4, 0x6c, 0x93, 0xb1, 0xf3, 0x17, 0x63, 0xe1, 0x57, 0x01, 0x1e, 0x40, + 0x1d, 0xa5, 0x14, 0x32, 0xe7, 0xab, 0xf5, 0x9a, 0x41, 0xd9, 0xf5, 0xef, 0xa1, 0x35, 0x9c, 0xc6, + 0xa5, 0x42, 0xd2, 0x1b, 0x68, 0x94, 0x35, 0x3d, 0xdc, 0x5c, 0xba, 0x76, 0xa2, 0xce, 0xc9, 0xbf, + 0x37, 0x29, 0xf8, 0x5c, 0xeb, 0x72, 0xf8, 0xb1, 0x70, 0xc8, 0x7c, 0xe1, 0x90, 0xaf, 0x85, 0x43, + 0xde, 0x97, 0x8e, 0x35, 0x5f, 0x3a, 0xd6, 0xe7, 0xd2, 0xb1, 0x1e, 0x4e, 0xc7, 0x5c, 0xbf, 0x64, + 0x23, 0x2f, 0x12, 0xb1, 0xbf, 0xca, 0x57, 0x69, 0xa3, 0xf7, 0xd3, 0xd7, 0xb1, 0xaf, 0x67, 0x29, + 0xaa, 0x3c, 0xf2, 0x51, 0xdd, 0x44, 0x3d, 0xf8, 0x0e, 0x00, 0x00, 0xff, 0xff, 0x63, 0xd7, 0x29, + 0x3c, 0x09, 0x02, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// DvmCompilerClient is the client API for DvmCompiler service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type DvmCompilerClient interface { + Compile(ctx context.Context, in *SourceFiles, opts ...grpc.CallOption) (*CompilationResult, error) +} + +type dvmCompilerClient struct { + cc grpc1.ClientConn +} + +func NewDvmCompilerClient(cc grpc1.ClientConn) DvmCompilerClient { + return &dvmCompilerClient{cc} +} + +func (c *dvmCompilerClient) Compile(ctx context.Context, in *SourceFiles, opts ...grpc.CallOption) (*CompilationResult, error) { + out := new(CompilationResult) + err := c.cc.Invoke(ctx, "/dfinance.dvm.DvmCompiler/Compile", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// DvmCompilerServer is the server API for DvmCompiler service. +type DvmCompilerServer interface { + Compile(context.Context, *SourceFiles) (*CompilationResult, error) +} + +// UnimplementedDvmCompilerServer can be embedded to have forward compatible implementations. +type UnimplementedDvmCompilerServer struct { +} + +func (*UnimplementedDvmCompilerServer) Compile(ctx context.Context, req *SourceFiles) (*CompilationResult, error) { + return nil, status.Errorf(codes.Unimplemented, "method Compile not implemented") +} + +func RegisterDvmCompilerServer(s grpc1.Server, srv DvmCompilerServer) { + s.RegisterService(&_DvmCompiler_serviceDesc, srv) +} + +func _DvmCompiler_Compile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SourceFiles) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DvmCompilerServer).Compile(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/dfinance.dvm.DvmCompiler/Compile", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DvmCompilerServer).Compile(ctx, req.(*SourceFiles)) + } + return interceptor(ctx, in, info, handler) +} + +var _DvmCompiler_serviceDesc = grpc.ServiceDesc{ + ServiceName: "dfinance.dvm.DvmCompiler", + HandlerType: (*DvmCompilerServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Compile", + Handler: _DvmCompiler_Compile_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "dfinance/dvm/compiler.proto", +} + +func (m *CompilationUnit) 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 *CompilationUnit) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CompilationUnit) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintCompiler(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0x12 + } + if len(m.Text) > 0 { + i -= len(m.Text) + copy(dAtA[i:], m.Text) + i = encodeVarintCompiler(dAtA, i, uint64(len(m.Text))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *SourceFiles) 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 *SourceFiles) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SourceFiles) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintCompiler(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0x12 + } + if len(m.Units) > 0 { + for iNdEx := len(m.Units) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Units[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintCompiler(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *CompiledUnit) 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 *CompiledUnit) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CompiledUnit) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Bytecode) > 0 { + i -= len(m.Bytecode) + copy(dAtA[i:], m.Bytecode) + i = encodeVarintCompiler(dAtA, i, uint64(len(m.Bytecode))) + i-- + dAtA[i] = 0x12 + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintCompiler(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *CompilationResult) 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 *CompilationResult) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CompilationResult) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Errors) > 0 { + for iNdEx := len(m.Errors) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Errors[iNdEx]) + copy(dAtA[i:], m.Errors[iNdEx]) + i = encodeVarintCompiler(dAtA, i, uint64(len(m.Errors[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } + if len(m.Units) > 0 { + for iNdEx := len(m.Units) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Units[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintCompiler(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintCompiler(dAtA []byte, offset int, v uint64) int { + offset -= sovCompiler(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *CompilationUnit) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Text) + if l > 0 { + n += 1 + l + sovCompiler(uint64(l)) + } + l = len(m.Name) + if l > 0 { + n += 1 + l + sovCompiler(uint64(l)) + } + return n +} + +func (m *SourceFiles) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Units) > 0 { + for _, e := range m.Units { + l = e.Size() + n += 1 + l + sovCompiler(uint64(l)) + } + } + l = len(m.Address) + if l > 0 { + n += 1 + l + sovCompiler(uint64(l)) + } + return n +} + +func (m *CompiledUnit) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovCompiler(uint64(l)) + } + l = len(m.Bytecode) + if l > 0 { + n += 1 + l + sovCompiler(uint64(l)) + } + return n +} + +func (m *CompilationResult) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Units) > 0 { + for _, e := range m.Units { + l = e.Size() + n += 1 + l + sovCompiler(uint64(l)) + } + } + if len(m.Errors) > 0 { + for _, s := range m.Errors { + l = len(s) + n += 1 + l + sovCompiler(uint64(l)) + } + } + return n +} + +func sovCompiler(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozCompiler(x uint64) (n int) { + return sovCompiler(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *CompilationUnit) 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 ErrIntOverflowCompiler + } + 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: CompilationUnit: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CompilationUnit: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Text", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompiler + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthCompiler + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCompiler + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Text = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompiler + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthCompiler + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCompiler + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipCompiler(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthCompiler + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *SourceFiles) 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 ErrIntOverflowCompiler + } + 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: SourceFiles: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SourceFiles: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Units", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompiler + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthCompiler + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthCompiler + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Units = append(m.Units, &CompilationUnit{}) + if err := m.Units[len(m.Units)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompiler + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthCompiler + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthCompiler + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = append(m.Address[:0], dAtA[iNdEx:postIndex]...) + if m.Address == nil { + m.Address = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipCompiler(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthCompiler + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CompiledUnit) 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 ErrIntOverflowCompiler + } + 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: CompiledUnit: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CompiledUnit: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompiler + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthCompiler + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCompiler + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Bytecode", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompiler + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthCompiler + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthCompiler + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Bytecode = append(m.Bytecode[:0], dAtA[iNdEx:postIndex]...) + if m.Bytecode == nil { + m.Bytecode = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipCompiler(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthCompiler + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CompilationResult) 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 ErrIntOverflowCompiler + } + 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: CompilationResult: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CompilationResult: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Units", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompiler + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthCompiler + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthCompiler + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Units = append(m.Units, &CompiledUnit{}) + if err := m.Units[len(m.Units)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Errors", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompiler + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthCompiler + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCompiler + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Errors = append(m.Errors, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipCompiler(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthCompiler + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipCompiler(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowCompiler + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowCompiler + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowCompiler + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthCompiler + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupCompiler + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthCompiler + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthCompiler = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowCompiler = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupCompiler = fmt.Errorf("proto: unexpected end of group") +) diff --git a/pkg/types/dvm/data-source.pb.go b/pkg/types/dvm/data-source.pb.go new file mode 100644 index 0000000..b85a8de --- /dev/null +++ b/pkg/types/dvm/data-source.pb.go @@ -0,0 +1,3046 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: dfinance/dvm/data-source.proto + +package dvm + +import ( + context "context" + fmt "fmt" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type ErrorCode int32 + +const ( + ErrorCode_NONE ErrorCode = 0 + ErrorCode_BAD_REQUEST ErrorCode = 1 + ErrorCode_NO_DATA ErrorCode = 2 +) + +var ErrorCode_name = map[int32]string{ + 0: "NONE", + 1: "BAD_REQUEST", + 2: "NO_DATA", +} + +var ErrorCode_value = map[string]int32{ + "NONE": 0, + "BAD_REQUEST": 1, + "NO_DATA": 2, +} + +func (x ErrorCode) String() string { + return proto.EnumName(ErrorCode_name, int32(x)) +} + +func (ErrorCode) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_1f281398717634ce, []int{0} +} + +type DSAccessPath struct { + Address []byte `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + Path []byte `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"` +} + +func (m *DSAccessPath) Reset() { *m = DSAccessPath{} } +func (m *DSAccessPath) String() string { return proto.CompactTextString(m) } +func (*DSAccessPath) ProtoMessage() {} +func (*DSAccessPath) Descriptor() ([]byte, []int) { + return fileDescriptor_1f281398717634ce, []int{0} +} +func (m *DSAccessPath) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DSAccessPath) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DSAccessPath.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 *DSAccessPath) XXX_Merge(src proto.Message) { + xxx_messageInfo_DSAccessPath.Merge(m, src) +} +func (m *DSAccessPath) XXX_Size() int { + return m.Size() +} +func (m *DSAccessPath) XXX_DiscardUnknown() { + xxx_messageInfo_DSAccessPath.DiscardUnknown(m) +} + +var xxx_messageInfo_DSAccessPath proto.InternalMessageInfo + +func (m *DSAccessPath) GetAddress() []byte { + if m != nil { + return m.Address + } + return nil +} + +func (m *DSAccessPath) GetPath() []byte { + if m != nil { + return m.Path + } + return nil +} + +type DSRawResponse struct { + Blob []byte `protobuf:"bytes,1,opt,name=blob,proto3" json:"blob,omitempty"` + ErrorCode ErrorCode `protobuf:"varint,2,opt,name=error_code,json=errorCode,proto3,enum=dfinance.dvm.ErrorCode" json:"error_code,omitempty"` + ErrorMessage string `protobuf:"bytes,3,opt,name=error_message,json=errorMessage,proto3" json:"error_message,omitempty"` +} + +func (m *DSRawResponse) Reset() { *m = DSRawResponse{} } +func (m *DSRawResponse) String() string { return proto.CompactTextString(m) } +func (*DSRawResponse) ProtoMessage() {} +func (*DSRawResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_1f281398717634ce, []int{1} +} +func (m *DSRawResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DSRawResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DSRawResponse.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 *DSRawResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_DSRawResponse.Merge(m, src) +} +func (m *DSRawResponse) XXX_Size() int { + return m.Size() +} +func (m *DSRawResponse) XXX_DiscardUnknown() { + xxx_messageInfo_DSRawResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_DSRawResponse proto.InternalMessageInfo + +func (m *DSRawResponse) GetBlob() []byte { + if m != nil { + return m.Blob + } + return nil +} + +func (m *DSRawResponse) GetErrorCode() ErrorCode { + if m != nil { + return m.ErrorCode + } + return ErrorCode_NONE +} + +func (m *DSRawResponse) GetErrorMessage() string { + if m != nil { + return m.ErrorMessage + } + return "" +} + +type DSAccessPaths struct { + Paths []*DSAccessPath `protobuf:"bytes,1,rep,name=paths,proto3" json:"paths,omitempty"` +} + +func (m *DSAccessPaths) Reset() { *m = DSAccessPaths{} } +func (m *DSAccessPaths) String() string { return proto.CompactTextString(m) } +func (*DSAccessPaths) ProtoMessage() {} +func (*DSAccessPaths) Descriptor() ([]byte, []int) { + return fileDescriptor_1f281398717634ce, []int{2} +} +func (m *DSAccessPaths) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DSAccessPaths) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DSAccessPaths.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 *DSAccessPaths) XXX_Merge(src proto.Message) { + xxx_messageInfo_DSAccessPaths.Merge(m, src) +} +func (m *DSAccessPaths) XXX_Size() int { + return m.Size() +} +func (m *DSAccessPaths) XXX_DiscardUnknown() { + xxx_messageInfo_DSAccessPaths.DiscardUnknown(m) +} + +var xxx_messageInfo_DSAccessPaths proto.InternalMessageInfo + +func (m *DSAccessPaths) GetPaths() []*DSAccessPath { + if m != nil { + return m.Paths + } + return nil +} + +type DSRawResponses struct { + Blobs [][]byte `protobuf:"bytes,1,rep,name=blobs,proto3" json:"blobs,omitempty"` +} + +func (m *DSRawResponses) Reset() { *m = DSRawResponses{} } +func (m *DSRawResponses) String() string { return proto.CompactTextString(m) } +func (*DSRawResponses) ProtoMessage() {} +func (*DSRawResponses) Descriptor() ([]byte, []int) { + return fileDescriptor_1f281398717634ce, []int{3} +} +func (m *DSRawResponses) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DSRawResponses) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DSRawResponses.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 *DSRawResponses) XXX_Merge(src proto.Message) { + xxx_messageInfo_DSRawResponses.Merge(m, src) +} +func (m *DSRawResponses) XXX_Size() int { + return m.Size() +} +func (m *DSRawResponses) XXX_DiscardUnknown() { + xxx_messageInfo_DSRawResponses.DiscardUnknown(m) +} + +var xxx_messageInfo_DSRawResponses proto.InternalMessageInfo + +func (m *DSRawResponses) GetBlobs() [][]byte { + if m != nil { + return m.Blobs + } + return nil +} + +type OraclePriceRequest struct { + Currency_1 string `protobuf:"bytes,1,opt,name=currency_1,json=currency1,proto3" json:"currency_1,omitempty"` + Currency_2 string `protobuf:"bytes,2,opt,name=currency_2,json=currency2,proto3" json:"currency_2,omitempty"` +} + +func (m *OraclePriceRequest) Reset() { *m = OraclePriceRequest{} } +func (m *OraclePriceRequest) String() string { return proto.CompactTextString(m) } +func (*OraclePriceRequest) ProtoMessage() {} +func (*OraclePriceRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_1f281398717634ce, []int{4} +} +func (m *OraclePriceRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *OraclePriceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_OraclePriceRequest.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 *OraclePriceRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_OraclePriceRequest.Merge(m, src) +} +func (m *OraclePriceRequest) XXX_Size() int { + return m.Size() +} +func (m *OraclePriceRequest) XXX_DiscardUnknown() { + xxx_messageInfo_OraclePriceRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_OraclePriceRequest proto.InternalMessageInfo + +func (m *OraclePriceRequest) GetCurrency_1() string { + if m != nil { + return m.Currency_1 + } + return "" +} + +func (m *OraclePriceRequest) GetCurrency_2() string { + if m != nil { + return m.Currency_2 + } + return "" +} + +type OraclePriceResponse struct { + Price *U128 `protobuf:"bytes,1,opt,name=price,proto3" json:"price,omitempty"` + ErrorCode ErrorCode `protobuf:"varint,2,opt,name=error_code,json=errorCode,proto3,enum=dfinance.dvm.ErrorCode" json:"error_code,omitempty"` + ErrorMessage string `protobuf:"bytes,3,opt,name=error_message,json=errorMessage,proto3" json:"error_message,omitempty"` +} + +func (m *OraclePriceResponse) Reset() { *m = OraclePriceResponse{} } +func (m *OraclePriceResponse) String() string { return proto.CompactTextString(m) } +func (*OraclePriceResponse) ProtoMessage() {} +func (*OraclePriceResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_1f281398717634ce, []int{5} +} +func (m *OraclePriceResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *OraclePriceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_OraclePriceResponse.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 *OraclePriceResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_OraclePriceResponse.Merge(m, src) +} +func (m *OraclePriceResponse) XXX_Size() int { + return m.Size() +} +func (m *OraclePriceResponse) XXX_DiscardUnknown() { + xxx_messageInfo_OraclePriceResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_OraclePriceResponse proto.InternalMessageInfo + +func (m *OraclePriceResponse) GetPrice() *U128 { + if m != nil { + return m.Price + } + return nil +} + +func (m *OraclePriceResponse) GetErrorCode() ErrorCode { + if m != nil { + return m.ErrorCode + } + return ErrorCode_NONE +} + +func (m *OraclePriceResponse) GetErrorMessage() string { + if m != nil { + return m.ErrorMessage + } + return "" +} + +type NativeBalanceRequest struct { + Address []byte `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + Ticker string `protobuf:"bytes,2,opt,name=ticker,proto3" json:"ticker,omitempty"` +} + +func (m *NativeBalanceRequest) Reset() { *m = NativeBalanceRequest{} } +func (m *NativeBalanceRequest) String() string { return proto.CompactTextString(m) } +func (*NativeBalanceRequest) ProtoMessage() {} +func (*NativeBalanceRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_1f281398717634ce, []int{6} +} +func (m *NativeBalanceRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *NativeBalanceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_NativeBalanceRequest.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 *NativeBalanceRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_NativeBalanceRequest.Merge(m, src) +} +func (m *NativeBalanceRequest) XXX_Size() int { + return m.Size() +} +func (m *NativeBalanceRequest) XXX_DiscardUnknown() { + xxx_messageInfo_NativeBalanceRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_NativeBalanceRequest proto.InternalMessageInfo + +func (m *NativeBalanceRequest) GetAddress() []byte { + if m != nil { + return m.Address + } + return nil +} + +func (m *NativeBalanceRequest) GetTicker() string { + if m != nil { + return m.Ticker + } + return "" +} + +type NativeBalanceResponse struct { + Balance *U128 `protobuf:"bytes,1,opt,name=balance,proto3" json:"balance,omitempty"` + ErrorCode ErrorCode `protobuf:"varint,2,opt,name=error_code,json=errorCode,proto3,enum=dfinance.dvm.ErrorCode" json:"error_code,omitempty"` + ErrorMessage string `protobuf:"bytes,3,opt,name=error_message,json=errorMessage,proto3" json:"error_message,omitempty"` +} + +func (m *NativeBalanceResponse) Reset() { *m = NativeBalanceResponse{} } +func (m *NativeBalanceResponse) String() string { return proto.CompactTextString(m) } +func (*NativeBalanceResponse) ProtoMessage() {} +func (*NativeBalanceResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_1f281398717634ce, []int{7} +} +func (m *NativeBalanceResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *NativeBalanceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_NativeBalanceResponse.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 *NativeBalanceResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_NativeBalanceResponse.Merge(m, src) +} +func (m *NativeBalanceResponse) XXX_Size() int { + return m.Size() +} +func (m *NativeBalanceResponse) XXX_DiscardUnknown() { + xxx_messageInfo_NativeBalanceResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_NativeBalanceResponse proto.InternalMessageInfo + +func (m *NativeBalanceResponse) GetBalance() *U128 { + if m != nil { + return m.Balance + } + return nil +} + +func (m *NativeBalanceResponse) GetErrorCode() ErrorCode { + if m != nil { + return m.ErrorCode + } + return ErrorCode_NONE +} + +func (m *NativeBalanceResponse) GetErrorMessage() string { + if m != nil { + return m.ErrorMessage + } + return "" +} + +type CurrencyInfoRequest struct { + Ticker string `protobuf:"bytes,2,opt,name=ticker,proto3" json:"ticker,omitempty"` +} + +func (m *CurrencyInfoRequest) Reset() { *m = CurrencyInfoRequest{} } +func (m *CurrencyInfoRequest) String() string { return proto.CompactTextString(m) } +func (*CurrencyInfoRequest) ProtoMessage() {} +func (*CurrencyInfoRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_1f281398717634ce, []int{8} +} +func (m *CurrencyInfoRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CurrencyInfoRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CurrencyInfoRequest.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 *CurrencyInfoRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_CurrencyInfoRequest.Merge(m, src) +} +func (m *CurrencyInfoRequest) XXX_Size() int { + return m.Size() +} +func (m *CurrencyInfoRequest) XXX_DiscardUnknown() { + xxx_messageInfo_CurrencyInfoRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_CurrencyInfoRequest proto.InternalMessageInfo + +func (m *CurrencyInfoRequest) GetTicker() string { + if m != nil { + return m.Ticker + } + return "" +} + +type CurrencyInfo struct { + Denom []byte `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` + Decimals uint32 `protobuf:"varint,2,opt,name=decimals,proto3" json:"decimals,omitempty"` + IsToken bool `protobuf:"varint,3,opt,name=is_token,json=isToken,proto3" json:"is_token,omitempty"` + Address []byte `protobuf:"bytes,4,opt,name=address,proto3" json:"address,omitempty"` + TotalSupply *U128 `protobuf:"bytes,5,opt,name=total_supply,json=totalSupply,proto3" json:"total_supply,omitempty"` +} + +func (m *CurrencyInfo) Reset() { *m = CurrencyInfo{} } +func (m *CurrencyInfo) String() string { return proto.CompactTextString(m) } +func (*CurrencyInfo) ProtoMessage() {} +func (*CurrencyInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_1f281398717634ce, []int{9} +} +func (m *CurrencyInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CurrencyInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CurrencyInfo.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 *CurrencyInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_CurrencyInfo.Merge(m, src) +} +func (m *CurrencyInfo) XXX_Size() int { + return m.Size() +} +func (m *CurrencyInfo) XXX_DiscardUnknown() { + xxx_messageInfo_CurrencyInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_CurrencyInfo proto.InternalMessageInfo + +func (m *CurrencyInfo) GetDenom() []byte { + if m != nil { + return m.Denom + } + return nil +} + +func (m *CurrencyInfo) GetDecimals() uint32 { + if m != nil { + return m.Decimals + } + return 0 +} + +func (m *CurrencyInfo) GetIsToken() bool { + if m != nil { + return m.IsToken + } + return false +} + +func (m *CurrencyInfo) GetAddress() []byte { + if m != nil { + return m.Address + } + return nil +} + +func (m *CurrencyInfo) GetTotalSupply() *U128 { + if m != nil { + return m.TotalSupply + } + return nil +} + +type CurrencyInfoResponse struct { + Info *CurrencyInfo `protobuf:"bytes,1,opt,name=info,proto3" json:"info,omitempty"` + ErrorCode ErrorCode `protobuf:"varint,2,opt,name=error_code,json=errorCode,proto3,enum=dfinance.dvm.ErrorCode" json:"error_code,omitempty"` + ErrorMessage string `protobuf:"bytes,3,opt,name=error_message,json=errorMessage,proto3" json:"error_message,omitempty"` +} + +func (m *CurrencyInfoResponse) Reset() { *m = CurrencyInfoResponse{} } +func (m *CurrencyInfoResponse) String() string { return proto.CompactTextString(m) } +func (*CurrencyInfoResponse) ProtoMessage() {} +func (*CurrencyInfoResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_1f281398717634ce, []int{10} +} +func (m *CurrencyInfoResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CurrencyInfoResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CurrencyInfoResponse.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 *CurrencyInfoResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_CurrencyInfoResponse.Merge(m, src) +} +func (m *CurrencyInfoResponse) XXX_Size() int { + return m.Size() +} +func (m *CurrencyInfoResponse) XXX_DiscardUnknown() { + xxx_messageInfo_CurrencyInfoResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_CurrencyInfoResponse proto.InternalMessageInfo + +func (m *CurrencyInfoResponse) GetInfo() *CurrencyInfo { + if m != nil { + return m.Info + } + return nil +} + +func (m *CurrencyInfoResponse) GetErrorCode() ErrorCode { + if m != nil { + return m.ErrorCode + } + return ErrorCode_NONE +} + +func (m *CurrencyInfoResponse) GetErrorMessage() string { + if m != nil { + return m.ErrorMessage + } + return "" +} + +func init() { + proto.RegisterEnum("dfinance.dvm.ErrorCode", ErrorCode_name, ErrorCode_value) + proto.RegisterType((*DSAccessPath)(nil), "dfinance.dvm.DSAccessPath") + proto.RegisterType((*DSRawResponse)(nil), "dfinance.dvm.DSRawResponse") + proto.RegisterType((*DSAccessPaths)(nil), "dfinance.dvm.DSAccessPaths") + proto.RegisterType((*DSRawResponses)(nil), "dfinance.dvm.DSRawResponses") + proto.RegisterType((*OraclePriceRequest)(nil), "dfinance.dvm.OraclePriceRequest") + proto.RegisterType((*OraclePriceResponse)(nil), "dfinance.dvm.OraclePriceResponse") + proto.RegisterType((*NativeBalanceRequest)(nil), "dfinance.dvm.NativeBalanceRequest") + proto.RegisterType((*NativeBalanceResponse)(nil), "dfinance.dvm.NativeBalanceResponse") + proto.RegisterType((*CurrencyInfoRequest)(nil), "dfinance.dvm.CurrencyInfoRequest") + proto.RegisterType((*CurrencyInfo)(nil), "dfinance.dvm.CurrencyInfo") + proto.RegisterType((*CurrencyInfoResponse)(nil), "dfinance.dvm.CurrencyInfoResponse") +} + +func init() { proto.RegisterFile("dfinance/dvm/data-source.proto", fileDescriptor_1f281398717634ce) } + +var fileDescriptor_1f281398717634ce = []byte{ + // 724 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0xc1, 0x4e, 0xdb, 0x4c, + 0x10, 0x8e, 0x21, 0x21, 0xc9, 0x24, 0x40, 0xb4, 0xf0, 0xff, 0x4d, 0x43, 0x9b, 0x82, 0x91, 0xaa, + 0x08, 0x95, 0xa4, 0x04, 0xb5, 0xea, 0xa1, 0x97, 0x40, 0xa2, 0xb4, 0x95, 0x08, 0x74, 0x43, 0x55, + 0x09, 0xa9, 0x8a, 0x36, 0xf6, 0x02, 0x16, 0xb1, 0xd7, 0xf5, 0xae, 0x83, 0xb8, 0xf5, 0x11, 0xfa, + 0x00, 0x3d, 0xb5, 0xd7, 0x1e, 0xfa, 0x18, 0x3d, 0x72, 0xec, 0xb1, 0x82, 0x17, 0xa9, 0xbc, 0xb6, + 0x83, 0x4d, 0x1b, 0xdf, 0xb8, 0xed, 0xcc, 0x7c, 0xf3, 0x79, 0xbe, 0xd9, 0x1d, 0x0f, 0x54, 0xf5, + 0x63, 0xc3, 0x22, 0x96, 0x46, 0x1b, 0xfa, 0xd8, 0x6c, 0xe8, 0x44, 0x90, 0x4d, 0xce, 0x5c, 0x47, + 0xa3, 0x75, 0xdb, 0x61, 0x82, 0xa1, 0x62, 0x18, 0xaf, 0xeb, 0x63, 0xb3, 0xf2, 0x28, 0x86, 0xd6, + 0x98, 0x69, 0x32, 0x6b, 0x53, 0x5c, 0xd8, 0x94, 0xfb, 0x70, 0xf5, 0x25, 0x14, 0xdb, 0xfd, 0x96, + 0xa6, 0x51, 0xce, 0x0f, 0x88, 0x38, 0x45, 0x65, 0xc8, 0x12, 0x5d, 0x77, 0x28, 0xe7, 0x65, 0x65, + 0x55, 0xa9, 0x15, 0x71, 0x68, 0x22, 0x04, 0x69, 0x9b, 0x88, 0xd3, 0xf2, 0x8c, 0x74, 0xcb, 0xb3, + 0xfa, 0x49, 0x81, 0xf9, 0x76, 0x1f, 0x93, 0x73, 0x4c, 0xb9, 0xcd, 0x2c, 0x4e, 0x3d, 0xd4, 0x70, + 0xc4, 0x86, 0x41, 0xb2, 0x3c, 0xa3, 0xe7, 0x00, 0xd4, 0x71, 0x98, 0x33, 0xd0, 0x98, 0x4e, 0x65, + 0xfe, 0x42, 0xf3, 0x5e, 0x3d, 0x5a, 0x67, 0xbd, 0xe3, 0xc5, 0x77, 0x99, 0x4e, 0x71, 0x9e, 0x86, + 0x47, 0xb4, 0x0e, 0xf3, 0x7e, 0x9e, 0x49, 0x39, 0x27, 0x27, 0xb4, 0x3c, 0xbb, 0xaa, 0xd4, 0xf2, + 0xb8, 0x28, 0x9d, 0x7b, 0xbe, 0x4f, 0x6d, 0x79, 0x15, 0xdc, 0x08, 0xe0, 0xe8, 0x29, 0x64, 0xbc, + 0xda, 0xbc, 0xfa, 0x67, 0x6b, 0x85, 0x66, 0x25, 0xfe, 0xa1, 0x28, 0x16, 0xfb, 0x40, 0xf5, 0x31, + 0x2c, 0xc4, 0x44, 0x70, 0xb4, 0x0c, 0x19, 0xaf, 0x72, 0x9f, 0xa3, 0x88, 0x7d, 0x43, 0xc5, 0x80, + 0xf6, 0x1d, 0xa2, 0x8d, 0xe8, 0x81, 0x63, 0x68, 0x14, 0xd3, 0x8f, 0x2e, 0xe5, 0x02, 0x3d, 0x04, + 0xd0, 0x5c, 0xc7, 0xa1, 0x96, 0x76, 0x31, 0xd8, 0x92, 0xba, 0xf3, 0x38, 0x1f, 0x7a, 0xb6, 0x62, + 0xe1, 0xa6, 0x14, 0x1f, 0x09, 0x37, 0xd5, 0x2f, 0x0a, 0x2c, 0xc5, 0x48, 0x83, 0x3e, 0xd6, 0x20, + 0x63, 0x7b, 0x0e, 0x49, 0x58, 0x68, 0xa2, 0xb8, 0x0a, 0x77, 0xab, 0xf9, 0x02, 0xfb, 0x80, 0xbb, + 0xed, 0xee, 0x2b, 0x58, 0xee, 0x11, 0x61, 0x8c, 0xe9, 0x0e, 0x19, 0x79, 0x74, 0xa1, 0xe8, 0xe9, + 0xcf, 0xe4, 0x7f, 0x98, 0x13, 0x86, 0x76, 0x46, 0x9d, 0x40, 0x6b, 0x60, 0xa9, 0x5f, 0x15, 0xf8, + 0xef, 0x16, 0x55, 0x20, 0xf5, 0x09, 0x64, 0x87, 0xbe, 0x2b, 0x41, 0x6c, 0x08, 0xb9, 0x5b, 0xb9, + 0x9b, 0xb0, 0xb4, 0x1b, 0x5c, 0xcd, 0x6b, 0xeb, 0x98, 0x85, 0x6a, 0xa7, 0x69, 0xfa, 0xae, 0x40, + 0x31, 0x8a, 0xf7, 0xde, 0x8d, 0x4e, 0x2d, 0x66, 0x06, 0x4d, 0xf1, 0x0d, 0x54, 0x81, 0x9c, 0x4e, + 0x35, 0xc3, 0x24, 0x23, 0x2e, 0x09, 0xe6, 0xf1, 0xc4, 0x46, 0xf7, 0x21, 0x67, 0xf0, 0x81, 0x60, + 0x67, 0xd4, 0x92, 0x15, 0xe5, 0x70, 0xd6, 0xe0, 0x87, 0x9e, 0x19, 0xed, 0x71, 0x3a, 0xde, 0xe3, + 0x67, 0x50, 0x14, 0x4c, 0x90, 0xd1, 0x80, 0xbb, 0xb6, 0x3d, 0xba, 0x28, 0x67, 0xa6, 0xb6, 0xad, + 0x20, 0x71, 0x7d, 0x09, 0x53, 0xbf, 0x29, 0xb0, 0x1c, 0x97, 0x17, 0xdc, 0x40, 0x1d, 0xd2, 0x86, + 0x75, 0xcc, 0x82, 0xf6, 0xdf, 0x9a, 0x98, 0x58, 0x86, 0xc4, 0xdd, 0xe9, 0x1d, 0x6c, 0x6c, 0x43, + 0x7e, 0x92, 0x8c, 0x72, 0x90, 0xee, 0xed, 0xf7, 0x3a, 0xa5, 0x14, 0x5a, 0x84, 0xc2, 0x4e, 0xab, + 0x3d, 0xc0, 0x9d, 0xb7, 0xef, 0x3a, 0xfd, 0xc3, 0x92, 0x82, 0x0a, 0x90, 0xed, 0xed, 0x0f, 0xda, + 0xad, 0xc3, 0x56, 0x69, 0xa6, 0xf9, 0x63, 0x16, 0xf2, 0xed, 0x7e, 0x9f, 0x3a, 0x63, 0x6f, 0x24, + 0x76, 0x61, 0xae, 0x4b, 0x05, 0x26, 0xe7, 0x28, 0x61, 0xfa, 0x2b, 0x2b, 0xb7, 0x63, 0x91, 0x5f, + 0x80, 0x9a, 0x42, 0x6f, 0xa0, 0xb0, 0xe7, 0x8e, 0x84, 0x11, 0x30, 0xad, 0x4c, 0x67, 0xe2, 0x95, + 0x07, 0x09, 0x54, 0x5c, 0x4d, 0xa1, 0xf7, 0xb0, 0xd0, 0xa5, 0x22, 0x32, 0xe7, 0x68, 0x35, 0x9e, + 0xf1, 0xf7, 0x7f, 0xa5, 0xb2, 0x96, 0x80, 0x98, 0x14, 0xf9, 0x01, 0x4a, 0x5d, 0x2a, 0x62, 0x73, + 0x85, 0xd4, 0x78, 0xe2, 0xbf, 0xe6, 0xb7, 0xb2, 0x9e, 0x88, 0x99, 0xd0, 0x1f, 0xc1, 0x62, 0x97, + 0x8a, 0xd8, 0x13, 0x5f, 0x4b, 0x78, 0x1d, 0x01, 0xb9, 0x9a, 0x04, 0x09, 0xb9, 0x77, 0xda, 0x3f, + 0xaf, 0xaa, 0xca, 0xe5, 0x55, 0x55, 0xf9, 0x7d, 0x55, 0x55, 0x3e, 0x5f, 0x57, 0x53, 0x97, 0xd7, + 0xd5, 0xd4, 0xaf, 0xeb, 0x6a, 0xea, 0x68, 0xe3, 0xc4, 0x10, 0xa7, 0xee, 0xb0, 0xae, 0x31, 0xb3, + 0x71, 0xb3, 0xbf, 0xb8, 0x20, 0xc2, 0x60, 0x56, 0xc3, 0x3e, 0x3b, 0x69, 0xc8, 0x0d, 0xe6, 0xad, + 0xb4, 0xe1, 0x9c, 0x5c, 0x63, 0xdb, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x7c, 0x5c, 0x17, 0x67, + 0x17, 0x07, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// DSServiceClient is the client API for DSService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type DSServiceClient interface { + GetRaw(ctx context.Context, in *DSAccessPath, opts ...grpc.CallOption) (*DSRawResponse, error) + MultiGetRaw(ctx context.Context, in *DSAccessPaths, opts ...grpc.CallOption) (*DSRawResponses, error) + GetOraclePrice(ctx context.Context, in *OraclePriceRequest, opts ...grpc.CallOption) (*OraclePriceResponse, error) + GetNativeBalance(ctx context.Context, in *NativeBalanceRequest, opts ...grpc.CallOption) (*NativeBalanceResponse, error) + GetCurrencyInfo(ctx context.Context, in *CurrencyInfoRequest, opts ...grpc.CallOption) (*CurrencyInfoResponse, error) +} + +type dSServiceClient struct { + cc grpc1.ClientConn +} + +func NewDSServiceClient(cc grpc1.ClientConn) DSServiceClient { + return &dSServiceClient{cc} +} + +func (c *dSServiceClient) GetRaw(ctx context.Context, in *DSAccessPath, opts ...grpc.CallOption) (*DSRawResponse, error) { + out := new(DSRawResponse) + err := c.cc.Invoke(ctx, "/dfinance.dvm.DSService/GetRaw", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *dSServiceClient) MultiGetRaw(ctx context.Context, in *DSAccessPaths, opts ...grpc.CallOption) (*DSRawResponses, error) { + out := new(DSRawResponses) + err := c.cc.Invoke(ctx, "/dfinance.dvm.DSService/MultiGetRaw", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *dSServiceClient) GetOraclePrice(ctx context.Context, in *OraclePriceRequest, opts ...grpc.CallOption) (*OraclePriceResponse, error) { + out := new(OraclePriceResponse) + err := c.cc.Invoke(ctx, "/dfinance.dvm.DSService/GetOraclePrice", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *dSServiceClient) GetNativeBalance(ctx context.Context, in *NativeBalanceRequest, opts ...grpc.CallOption) (*NativeBalanceResponse, error) { + out := new(NativeBalanceResponse) + err := c.cc.Invoke(ctx, "/dfinance.dvm.DSService/GetNativeBalance", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *dSServiceClient) GetCurrencyInfo(ctx context.Context, in *CurrencyInfoRequest, opts ...grpc.CallOption) (*CurrencyInfoResponse, error) { + out := new(CurrencyInfoResponse) + err := c.cc.Invoke(ctx, "/dfinance.dvm.DSService/GetCurrencyInfo", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// DSServiceServer is the server API for DSService service. +type DSServiceServer interface { + GetRaw(context.Context, *DSAccessPath) (*DSRawResponse, error) + MultiGetRaw(context.Context, *DSAccessPaths) (*DSRawResponses, error) + GetOraclePrice(context.Context, *OraclePriceRequest) (*OraclePriceResponse, error) + GetNativeBalance(context.Context, *NativeBalanceRequest) (*NativeBalanceResponse, error) + GetCurrencyInfo(context.Context, *CurrencyInfoRequest) (*CurrencyInfoResponse, error) +} + +// UnimplementedDSServiceServer can be embedded to have forward compatible implementations. +type UnimplementedDSServiceServer struct { +} + +func (*UnimplementedDSServiceServer) GetRaw(ctx context.Context, req *DSAccessPath) (*DSRawResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetRaw not implemented") +} +func (*UnimplementedDSServiceServer) MultiGetRaw(ctx context.Context, req *DSAccessPaths) (*DSRawResponses, error) { + return nil, status.Errorf(codes.Unimplemented, "method MultiGetRaw not implemented") +} +func (*UnimplementedDSServiceServer) GetOraclePrice(ctx context.Context, req *OraclePriceRequest) (*OraclePriceResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetOraclePrice not implemented") +} +func (*UnimplementedDSServiceServer) GetNativeBalance(ctx context.Context, req *NativeBalanceRequest) (*NativeBalanceResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetNativeBalance not implemented") +} +func (*UnimplementedDSServiceServer) GetCurrencyInfo(ctx context.Context, req *CurrencyInfoRequest) (*CurrencyInfoResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetCurrencyInfo not implemented") +} + +func RegisterDSServiceServer(s grpc1.Server, srv DSServiceServer) { + s.RegisterService(&_DSService_serviceDesc, srv) +} + +func _DSService_GetRaw_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DSAccessPath) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DSServiceServer).GetRaw(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/dfinance.dvm.DSService/GetRaw", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DSServiceServer).GetRaw(ctx, req.(*DSAccessPath)) + } + return interceptor(ctx, in, info, handler) +} + +func _DSService_MultiGetRaw_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DSAccessPaths) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DSServiceServer).MultiGetRaw(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/dfinance.dvm.DSService/MultiGetRaw", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DSServiceServer).MultiGetRaw(ctx, req.(*DSAccessPaths)) + } + return interceptor(ctx, in, info, handler) +} + +func _DSService_GetOraclePrice_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(OraclePriceRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DSServiceServer).GetOraclePrice(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/dfinance.dvm.DSService/GetOraclePrice", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DSServiceServer).GetOraclePrice(ctx, req.(*OraclePriceRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _DSService_GetNativeBalance_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(NativeBalanceRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DSServiceServer).GetNativeBalance(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/dfinance.dvm.DSService/GetNativeBalance", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DSServiceServer).GetNativeBalance(ctx, req.(*NativeBalanceRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _DSService_GetCurrencyInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CurrencyInfoRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DSServiceServer).GetCurrencyInfo(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/dfinance.dvm.DSService/GetCurrencyInfo", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DSServiceServer).GetCurrencyInfo(ctx, req.(*CurrencyInfoRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _DSService_serviceDesc = grpc.ServiceDesc{ + ServiceName: "dfinance.dvm.DSService", + HandlerType: (*DSServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetRaw", + Handler: _DSService_GetRaw_Handler, + }, + { + MethodName: "MultiGetRaw", + Handler: _DSService_MultiGetRaw_Handler, + }, + { + MethodName: "GetOraclePrice", + Handler: _DSService_GetOraclePrice_Handler, + }, + { + MethodName: "GetNativeBalance", + Handler: _DSService_GetNativeBalance_Handler, + }, + { + MethodName: "GetCurrencyInfo", + Handler: _DSService_GetCurrencyInfo_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "dfinance/dvm/data-source.proto", +} + +func (m *DSAccessPath) 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 *DSAccessPath) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DSAccessPath) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Path) > 0 { + i -= len(m.Path) + copy(dAtA[i:], m.Path) + i = encodeVarintDataSource(dAtA, i, uint64(len(m.Path))) + i-- + dAtA[i] = 0x12 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintDataSource(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *DSRawResponse) 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 *DSRawResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DSRawResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ErrorMessage) > 0 { + i -= len(m.ErrorMessage) + copy(dAtA[i:], m.ErrorMessage) + i = encodeVarintDataSource(dAtA, i, uint64(len(m.ErrorMessage))) + i-- + dAtA[i] = 0x1a + } + if m.ErrorCode != 0 { + i = encodeVarintDataSource(dAtA, i, uint64(m.ErrorCode)) + i-- + dAtA[i] = 0x10 + } + if len(m.Blob) > 0 { + i -= len(m.Blob) + copy(dAtA[i:], m.Blob) + i = encodeVarintDataSource(dAtA, i, uint64(len(m.Blob))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *DSAccessPaths) 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 *DSAccessPaths) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DSAccessPaths) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Paths) > 0 { + for iNdEx := len(m.Paths) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Paths[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintDataSource(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *DSRawResponses) 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 *DSRawResponses) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DSRawResponses) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Blobs) > 0 { + for iNdEx := len(m.Blobs) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Blobs[iNdEx]) + copy(dAtA[i:], m.Blobs[iNdEx]) + i = encodeVarintDataSource(dAtA, i, uint64(len(m.Blobs[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *OraclePriceRequest) 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 *OraclePriceRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *OraclePriceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Currency_2) > 0 { + i -= len(m.Currency_2) + copy(dAtA[i:], m.Currency_2) + i = encodeVarintDataSource(dAtA, i, uint64(len(m.Currency_2))) + i-- + dAtA[i] = 0x12 + } + if len(m.Currency_1) > 0 { + i -= len(m.Currency_1) + copy(dAtA[i:], m.Currency_1) + i = encodeVarintDataSource(dAtA, i, uint64(len(m.Currency_1))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *OraclePriceResponse) 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 *OraclePriceResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *OraclePriceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ErrorMessage) > 0 { + i -= len(m.ErrorMessage) + copy(dAtA[i:], m.ErrorMessage) + i = encodeVarintDataSource(dAtA, i, uint64(len(m.ErrorMessage))) + i-- + dAtA[i] = 0x1a + } + if m.ErrorCode != 0 { + i = encodeVarintDataSource(dAtA, i, uint64(m.ErrorCode)) + i-- + dAtA[i] = 0x10 + } + if m.Price != nil { + { + size, err := m.Price.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintDataSource(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *NativeBalanceRequest) 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 *NativeBalanceRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *NativeBalanceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Ticker) > 0 { + i -= len(m.Ticker) + copy(dAtA[i:], m.Ticker) + i = encodeVarintDataSource(dAtA, i, uint64(len(m.Ticker))) + i-- + dAtA[i] = 0x12 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintDataSource(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *NativeBalanceResponse) 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 *NativeBalanceResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *NativeBalanceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ErrorMessage) > 0 { + i -= len(m.ErrorMessage) + copy(dAtA[i:], m.ErrorMessage) + i = encodeVarintDataSource(dAtA, i, uint64(len(m.ErrorMessage))) + i-- + dAtA[i] = 0x1a + } + if m.ErrorCode != 0 { + i = encodeVarintDataSource(dAtA, i, uint64(m.ErrorCode)) + i-- + dAtA[i] = 0x10 + } + if m.Balance != nil { + { + size, err := m.Balance.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintDataSource(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *CurrencyInfoRequest) 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 *CurrencyInfoRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CurrencyInfoRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Ticker) > 0 { + i -= len(m.Ticker) + copy(dAtA[i:], m.Ticker) + i = encodeVarintDataSource(dAtA, i, uint64(len(m.Ticker))) + i-- + dAtA[i] = 0x12 + } + return len(dAtA) - i, nil +} + +func (m *CurrencyInfo) 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 *CurrencyInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CurrencyInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.TotalSupply != nil { + { + size, err := m.TotalSupply.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintDataSource(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintDataSource(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0x22 + } + if m.IsToken { + i-- + if m.IsToken { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x18 + } + if m.Decimals != 0 { + i = encodeVarintDataSource(dAtA, i, uint64(m.Decimals)) + i-- + dAtA[i] = 0x10 + } + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintDataSource(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *CurrencyInfoResponse) 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 *CurrencyInfoResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CurrencyInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ErrorMessage) > 0 { + i -= len(m.ErrorMessage) + copy(dAtA[i:], m.ErrorMessage) + i = encodeVarintDataSource(dAtA, i, uint64(len(m.ErrorMessage))) + i-- + dAtA[i] = 0x1a + } + if m.ErrorCode != 0 { + i = encodeVarintDataSource(dAtA, i, uint64(m.ErrorCode)) + i-- + dAtA[i] = 0x10 + } + if m.Info != nil { + { + size, err := m.Info.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintDataSource(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintDataSource(dAtA []byte, offset int, v uint64) int { + offset -= sovDataSource(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *DSAccessPath) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovDataSource(uint64(l)) + } + l = len(m.Path) + if l > 0 { + n += 1 + l + sovDataSource(uint64(l)) + } + return n +} + +func (m *DSRawResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Blob) + if l > 0 { + n += 1 + l + sovDataSource(uint64(l)) + } + if m.ErrorCode != 0 { + n += 1 + sovDataSource(uint64(m.ErrorCode)) + } + l = len(m.ErrorMessage) + if l > 0 { + n += 1 + l + sovDataSource(uint64(l)) + } + return n +} + +func (m *DSAccessPaths) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Paths) > 0 { + for _, e := range m.Paths { + l = e.Size() + n += 1 + l + sovDataSource(uint64(l)) + } + } + return n +} + +func (m *DSRawResponses) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Blobs) > 0 { + for _, b := range m.Blobs { + l = len(b) + n += 1 + l + sovDataSource(uint64(l)) + } + } + return n +} + +func (m *OraclePriceRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Currency_1) + if l > 0 { + n += 1 + l + sovDataSource(uint64(l)) + } + l = len(m.Currency_2) + if l > 0 { + n += 1 + l + sovDataSource(uint64(l)) + } + return n +} + +func (m *OraclePriceResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Price != nil { + l = m.Price.Size() + n += 1 + l + sovDataSource(uint64(l)) + } + if m.ErrorCode != 0 { + n += 1 + sovDataSource(uint64(m.ErrorCode)) + } + l = len(m.ErrorMessage) + if l > 0 { + n += 1 + l + sovDataSource(uint64(l)) + } + return n +} + +func (m *NativeBalanceRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovDataSource(uint64(l)) + } + l = len(m.Ticker) + if l > 0 { + n += 1 + l + sovDataSource(uint64(l)) + } + return n +} + +func (m *NativeBalanceResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Balance != nil { + l = m.Balance.Size() + n += 1 + l + sovDataSource(uint64(l)) + } + if m.ErrorCode != 0 { + n += 1 + sovDataSource(uint64(m.ErrorCode)) + } + l = len(m.ErrorMessage) + if l > 0 { + n += 1 + l + sovDataSource(uint64(l)) + } + return n +} + +func (m *CurrencyInfoRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Ticker) + if l > 0 { + n += 1 + l + sovDataSource(uint64(l)) + } + return n +} + +func (m *CurrencyInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovDataSource(uint64(l)) + } + if m.Decimals != 0 { + n += 1 + sovDataSource(uint64(m.Decimals)) + } + if m.IsToken { + n += 2 + } + l = len(m.Address) + if l > 0 { + n += 1 + l + sovDataSource(uint64(l)) + } + if m.TotalSupply != nil { + l = m.TotalSupply.Size() + n += 1 + l + sovDataSource(uint64(l)) + } + return n +} + +func (m *CurrencyInfoResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Info != nil { + l = m.Info.Size() + n += 1 + l + sovDataSource(uint64(l)) + } + if m.ErrorCode != 0 { + n += 1 + sovDataSource(uint64(m.ErrorCode)) + } + l = len(m.ErrorMessage) + if l > 0 { + n += 1 + l + sovDataSource(uint64(l)) + } + return n +} + +func sovDataSource(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozDataSource(x uint64) (n int) { + return sovDataSource(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *DSAccessPath) 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 ErrIntOverflowDataSource + } + 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: DSAccessPath: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DSAccessPath: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDataSource + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthDataSource + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthDataSource + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = append(m.Address[:0], dAtA[iNdEx:postIndex]...) + if m.Address == nil { + m.Address = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Path", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDataSource + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthDataSource + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthDataSource + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Path = append(m.Path[:0], dAtA[iNdEx:postIndex]...) + if m.Path == nil { + m.Path = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipDataSource(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthDataSource + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DSRawResponse) 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 ErrIntOverflowDataSource + } + 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: DSRawResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DSRawResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Blob", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDataSource + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthDataSource + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthDataSource + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Blob = append(m.Blob[:0], dAtA[iNdEx:postIndex]...) + if m.Blob == nil { + m.Blob = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ErrorCode", wireType) + } + m.ErrorCode = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDataSource + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ErrorCode |= ErrorCode(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ErrorMessage", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDataSource + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthDataSource + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDataSource + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ErrorMessage = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipDataSource(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthDataSource + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DSAccessPaths) 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 ErrIntOverflowDataSource + } + 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: DSAccessPaths: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DSAccessPaths: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Paths", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDataSource + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthDataSource + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthDataSource + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Paths = append(m.Paths, &DSAccessPath{}) + if err := m.Paths[len(m.Paths)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipDataSource(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthDataSource + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DSRawResponses) 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 ErrIntOverflowDataSource + } + 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: DSRawResponses: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DSRawResponses: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Blobs", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDataSource + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthDataSource + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthDataSource + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Blobs = append(m.Blobs, make([]byte, postIndex-iNdEx)) + copy(m.Blobs[len(m.Blobs)-1], dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipDataSource(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthDataSource + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *OraclePriceRequest) 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 ErrIntOverflowDataSource + } + 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: OraclePriceRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: OraclePriceRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Currency_1", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDataSource + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthDataSource + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDataSource + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Currency_1 = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Currency_2", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDataSource + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthDataSource + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDataSource + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Currency_2 = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipDataSource(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthDataSource + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *OraclePriceResponse) 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 ErrIntOverflowDataSource + } + 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: OraclePriceResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: OraclePriceResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Price", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDataSource + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthDataSource + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthDataSource + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Price == nil { + m.Price = &U128{} + } + if err := m.Price.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ErrorCode", wireType) + } + m.ErrorCode = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDataSource + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ErrorCode |= ErrorCode(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ErrorMessage", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDataSource + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthDataSource + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDataSource + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ErrorMessage = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipDataSource(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthDataSource + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *NativeBalanceRequest) 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 ErrIntOverflowDataSource + } + 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: NativeBalanceRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: NativeBalanceRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDataSource + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthDataSource + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthDataSource + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = append(m.Address[:0], dAtA[iNdEx:postIndex]...) + if m.Address == nil { + m.Address = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Ticker", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDataSource + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthDataSource + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDataSource + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Ticker = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipDataSource(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthDataSource + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *NativeBalanceResponse) 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 ErrIntOverflowDataSource + } + 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: NativeBalanceResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: NativeBalanceResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Balance", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDataSource + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthDataSource + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthDataSource + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Balance == nil { + m.Balance = &U128{} + } + if err := m.Balance.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ErrorCode", wireType) + } + m.ErrorCode = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDataSource + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ErrorCode |= ErrorCode(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ErrorMessage", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDataSource + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthDataSource + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDataSource + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ErrorMessage = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipDataSource(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthDataSource + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CurrencyInfoRequest) 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 ErrIntOverflowDataSource + } + 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: CurrencyInfoRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CurrencyInfoRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Ticker", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDataSource + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthDataSource + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDataSource + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Ticker = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipDataSource(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthDataSource + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CurrencyInfo) 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 ErrIntOverflowDataSource + } + 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: CurrencyInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CurrencyInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDataSource + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthDataSource + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthDataSource + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Denom = append(m.Denom[:0], dAtA[iNdEx:postIndex]...) + if m.Denom == nil { + m.Denom = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Decimals", wireType) + } + m.Decimals = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDataSource + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Decimals |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsToken", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDataSource + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsToken = bool(v != 0) + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDataSource + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthDataSource + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthDataSource + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = append(m.Address[:0], dAtA[iNdEx:postIndex]...) + if m.Address == nil { + m.Address = []byte{} + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalSupply", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDataSource + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthDataSource + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthDataSource + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.TotalSupply == nil { + m.TotalSupply = &U128{} + } + if err := m.TotalSupply.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipDataSource(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthDataSource + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CurrencyInfoResponse) 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 ErrIntOverflowDataSource + } + 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: CurrencyInfoResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CurrencyInfoResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Info", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDataSource + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthDataSource + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthDataSource + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Info == nil { + m.Info = &CurrencyInfo{} + } + if err := m.Info.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ErrorCode", wireType) + } + m.ErrorCode = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDataSource + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ErrorCode |= ErrorCode(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ErrorMessage", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDataSource + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthDataSource + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDataSource + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ErrorMessage = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipDataSource(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthDataSource + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipDataSource(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowDataSource + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowDataSource + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowDataSource + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthDataSource + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupDataSource + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthDataSource + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthDataSource = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowDataSource = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupDataSource = fmt.Errorf("proto: unexpected end of group") +) diff --git a/pkg/types/dvm/metadata.pb.go b/pkg/types/dvm/metadata.pb.go new file mode 100644 index 0000000..1f067da --- /dev/null +++ b/pkg/types/dvm/metadata.pb.go @@ -0,0 +1,2320 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: dfinance/dvm/metadata.proto + +package dvm + +import ( + context "context" + fmt "fmt" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Bytecode. +type Bytecode struct { + Code []byte `protobuf:"bytes,1,opt,name=code,proto3" json:"code,omitempty"` +} + +func (m *Bytecode) Reset() { *m = Bytecode{} } +func (m *Bytecode) String() string { return proto.CompactTextString(m) } +func (*Bytecode) ProtoMessage() {} +func (*Bytecode) Descriptor() ([]byte, []int) { + return fileDescriptor_4b64f53b3e4f31a3, []int{0} +} +func (m *Bytecode) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Bytecode) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Bytecode.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 *Bytecode) XXX_Merge(src proto.Message) { + xxx_messageInfo_Bytecode.Merge(m, src) +} +func (m *Bytecode) XXX_Size() int { + return m.Size() +} +func (m *Bytecode) XXX_DiscardUnknown() { + xxx_messageInfo_Bytecode.DiscardUnknown(m) +} + +var xxx_messageInfo_Bytecode proto.InternalMessageInfo + +func (m *Bytecode) GetCode() []byte { + if m != nil { + return m.Code + } + return nil +} + +// Struct field. +type Field struct { + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` +} + +func (m *Field) Reset() { *m = Field{} } +func (m *Field) String() string { return proto.CompactTextString(m) } +func (*Field) ProtoMessage() {} +func (*Field) Descriptor() ([]byte, []int) { + return fileDescriptor_4b64f53b3e4f31a3, []int{1} +} +func (m *Field) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Field) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Field.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 *Field) XXX_Merge(src proto.Message) { + xxx_messageInfo_Field.Merge(m, src) +} +func (m *Field) XXX_Size() int { + return m.Size() +} +func (m *Field) XXX_DiscardUnknown() { + xxx_messageInfo_Field.DiscardUnknown(m) +} + +var xxx_messageInfo_Field proto.InternalMessageInfo + +func (m *Field) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *Field) GetType() string { + if m != nil { + return m.Type + } + return "" +} + +/// Struct representation. +type Struct struct { + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + IsResource bool `protobuf:"varint,2,opt,name=isResource,proto3" json:"isResource,omitempty"` + TypeParameters []string `protobuf:"bytes,3,rep,name=type_parameters,json=typeParameters,proto3" json:"type_parameters,omitempty"` + Field []*Field `protobuf:"bytes,4,rep,name=field,proto3" json:"field,omitempty"` +} + +func (m *Struct) Reset() { *m = Struct{} } +func (m *Struct) String() string { return proto.CompactTextString(m) } +func (*Struct) ProtoMessage() {} +func (*Struct) Descriptor() ([]byte, []int) { + return fileDescriptor_4b64f53b3e4f31a3, []int{2} +} +func (m *Struct) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Struct) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Struct.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 *Struct) XXX_Merge(src proto.Message) { + xxx_messageInfo_Struct.Merge(m, src) +} +func (m *Struct) XXX_Size() int { + return m.Size() +} +func (m *Struct) XXX_DiscardUnknown() { + xxx_messageInfo_Struct.DiscardUnknown(m) +} + +var xxx_messageInfo_Struct proto.InternalMessageInfo + +func (m *Struct) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *Struct) GetIsResource() bool { + if m != nil { + return m.IsResource + } + return false +} + +func (m *Struct) GetTypeParameters() []string { + if m != nil { + return m.TypeParameters + } + return nil +} + +func (m *Struct) GetField() []*Field { + if m != nil { + return m.Field + } + return nil +} + +/// Function representation. +type Function struct { + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + IsPublic bool `protobuf:"varint,2,opt,name=isPublic,proto3" json:"isPublic,omitempty"` + IsNative bool `protobuf:"varint,3,opt,name=isNative,proto3" json:"isNative,omitempty"` + TypeParameters []string `protobuf:"bytes,4,rep,name=type_parameters,json=typeParameters,proto3" json:"type_parameters,omitempty"` + Arguments []string `protobuf:"bytes,5,rep,name=arguments,proto3" json:"arguments,omitempty"` + Returns []string `protobuf:"bytes,6,rep,name=returns,proto3" json:"returns,omitempty"` +} + +func (m *Function) Reset() { *m = Function{} } +func (m *Function) String() string { return proto.CompactTextString(m) } +func (*Function) ProtoMessage() {} +func (*Function) Descriptor() ([]byte, []int) { + return fileDescriptor_4b64f53b3e4f31a3, []int{3} +} +func (m *Function) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Function) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Function.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 *Function) XXX_Merge(src proto.Message) { + xxx_messageInfo_Function.Merge(m, src) +} +func (m *Function) XXX_Size() int { + return m.Size() +} +func (m *Function) XXX_DiscardUnknown() { + xxx_messageInfo_Function.DiscardUnknown(m) +} + +var xxx_messageInfo_Function proto.InternalMessageInfo + +func (m *Function) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *Function) GetIsPublic() bool { + if m != nil { + return m.IsPublic + } + return false +} + +func (m *Function) GetIsNative() bool { + if m != nil { + return m.IsNative + } + return false +} + +func (m *Function) GetTypeParameters() []string { + if m != nil { + return m.TypeParameters + } + return nil +} + +func (m *Function) GetArguments() []string { + if m != nil { + return m.Arguments + } + return nil +} + +func (m *Function) GetReturns() []string { + if m != nil { + return m.Returns + } + return nil +} + +// Script metadata. +type ScriptMeta struct { + SignersCount uint32 `protobuf:"varint,1,opt,name=signers_count,json=signersCount,proto3" json:"signers_count,omitempty"` + TypeParameters []string `protobuf:"bytes,2,rep,name=type_parameters,json=typeParameters,proto3" json:"type_parameters,omitempty"` + Arguments []VMTypeTag `protobuf:"varint,3,rep,packed,name=arguments,proto3,enum=dfinance.dvm.VMTypeTag" json:"arguments,omitempty"` +} + +func (m *ScriptMeta) Reset() { *m = ScriptMeta{} } +func (m *ScriptMeta) String() string { return proto.CompactTextString(m) } +func (*ScriptMeta) ProtoMessage() {} +func (*ScriptMeta) Descriptor() ([]byte, []int) { + return fileDescriptor_4b64f53b3e4f31a3, []int{4} +} +func (m *ScriptMeta) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ScriptMeta) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ScriptMeta.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 *ScriptMeta) XXX_Merge(src proto.Message) { + xxx_messageInfo_ScriptMeta.Merge(m, src) +} +func (m *ScriptMeta) XXX_Size() int { + return m.Size() +} +func (m *ScriptMeta) XXX_DiscardUnknown() { + xxx_messageInfo_ScriptMeta.DiscardUnknown(m) +} + +var xxx_messageInfo_ScriptMeta proto.InternalMessageInfo + +func (m *ScriptMeta) GetSignersCount() uint32 { + if m != nil { + return m.SignersCount + } + return 0 +} + +func (m *ScriptMeta) GetTypeParameters() []string { + if m != nil { + return m.TypeParameters + } + return nil +} + +func (m *ScriptMeta) GetArguments() []VMTypeTag { + if m != nil { + return m.Arguments + } + return nil +} + +// Module metadata. +type ModuleMeta struct { + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Types []*Struct `protobuf:"bytes,2,rep,name=types,proto3" json:"types,omitempty"` + Functions []*Function `protobuf:"bytes,3,rep,name=functions,proto3" json:"functions,omitempty"` +} + +func (m *ModuleMeta) Reset() { *m = ModuleMeta{} } +func (m *ModuleMeta) String() string { return proto.CompactTextString(m) } +func (*ModuleMeta) ProtoMessage() {} +func (*ModuleMeta) Descriptor() ([]byte, []int) { + return fileDescriptor_4b64f53b3e4f31a3, []int{5} +} +func (m *ModuleMeta) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ModuleMeta) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ModuleMeta.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 *ModuleMeta) XXX_Merge(src proto.Message) { + xxx_messageInfo_ModuleMeta.Merge(m, src) +} +func (m *ModuleMeta) XXX_Size() int { + return m.Size() +} +func (m *ModuleMeta) XXX_DiscardUnknown() { + xxx_messageInfo_ModuleMeta.DiscardUnknown(m) +} + +var xxx_messageInfo_ModuleMeta proto.InternalMessageInfo + +func (m *ModuleMeta) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *ModuleMeta) GetTypes() []*Struct { + if m != nil { + return m.Types + } + return nil +} + +func (m *ModuleMeta) GetFunctions() []*Function { + if m != nil { + return m.Functions + } + return nil +} + +// Bytecode metadata. +type Metadata struct { + // Types that are valid to be assigned to Meta: + // *Metadata_Script + // *Metadata_Module + Meta isMetadata_Meta `protobuf_oneof:"meta"` +} + +func (m *Metadata) Reset() { *m = Metadata{} } +func (m *Metadata) String() string { return proto.CompactTextString(m) } +func (*Metadata) ProtoMessage() {} +func (*Metadata) Descriptor() ([]byte, []int) { + return fileDescriptor_4b64f53b3e4f31a3, []int{6} +} +func (m *Metadata) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Metadata) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Metadata.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 *Metadata) XXX_Merge(src proto.Message) { + xxx_messageInfo_Metadata.Merge(m, src) +} +func (m *Metadata) XXX_Size() int { + return m.Size() +} +func (m *Metadata) XXX_DiscardUnknown() { + xxx_messageInfo_Metadata.DiscardUnknown(m) +} + +var xxx_messageInfo_Metadata proto.InternalMessageInfo + +type isMetadata_Meta interface { + isMetadata_Meta() + MarshalTo([]byte) (int, error) + Size() int +} + +type Metadata_Script struct { + Script *ScriptMeta `protobuf:"bytes,1,opt,name=script,proto3,oneof" json:"script,omitempty"` +} +type Metadata_Module struct { + Module *ModuleMeta `protobuf:"bytes,2,opt,name=module,proto3,oneof" json:"module,omitempty"` +} + +func (*Metadata_Script) isMetadata_Meta() {} +func (*Metadata_Module) isMetadata_Meta() {} + +func (m *Metadata) GetMeta() isMetadata_Meta { + if m != nil { + return m.Meta + } + return nil +} + +func (m *Metadata) GetScript() *ScriptMeta { + if x, ok := m.GetMeta().(*Metadata_Script); ok { + return x.Script + } + return nil +} + +func (m *Metadata) GetModule() *ModuleMeta { + if x, ok := m.GetMeta().(*Metadata_Module); ok { + return x.Module + } + return nil +} + +// XXX_OneofWrappers is for the internal use of the proto package. +func (*Metadata) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*Metadata_Script)(nil), + (*Metadata_Module)(nil), + } +} + +func init() { + proto.RegisterType((*Bytecode)(nil), "dfinance.dvm.Bytecode") + proto.RegisterType((*Field)(nil), "dfinance.dvm.Field") + proto.RegisterType((*Struct)(nil), "dfinance.dvm.Struct") + proto.RegisterType((*Function)(nil), "dfinance.dvm.Function") + proto.RegisterType((*ScriptMeta)(nil), "dfinance.dvm.ScriptMeta") + proto.RegisterType((*ModuleMeta)(nil), "dfinance.dvm.ModuleMeta") + proto.RegisterType((*Metadata)(nil), "dfinance.dvm.Metadata") +} + +func init() { proto.RegisterFile("dfinance/dvm/metadata.proto", fileDescriptor_4b64f53b3e4f31a3) } + +var fileDescriptor_4b64f53b3e4f31a3 = []byte{ + // 541 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x93, 0xcd, 0x8e, 0xd3, 0x30, + 0x10, 0xc7, 0x9b, 0xed, 0x07, 0xed, 0x74, 0x77, 0x91, 0xb2, 0x08, 0xa2, 0x82, 0x42, 0x15, 0x0e, + 0x94, 0x95, 0x68, 0xa4, 0x00, 0x67, 0xa4, 0xb2, 0x5a, 0xb8, 0x14, 0xad, 0xb2, 0xab, 0x1e, 0xb8, + 0xac, 0xdc, 0xc4, 0x2d, 0x11, 0xb5, 0x1d, 0xd9, 0x4e, 0xa5, 0x72, 0xe4, 0x09, 0x96, 0xa7, 0xe1, + 0x15, 0x38, 0xee, 0x91, 0x23, 0x6a, 0x5f, 0x04, 0xd9, 0x4e, 0xd2, 0x0f, 0x72, 0x8a, 0xfd, 0x9f, + 0xff, 0x38, 0xbf, 0x19, 0x7b, 0xe0, 0x69, 0x3c, 0x4b, 0x28, 0xa2, 0x11, 0xf6, 0xe3, 0x25, 0xf1, + 0x09, 0x96, 0x28, 0x46, 0x12, 0x0d, 0x53, 0xce, 0x24, 0xb3, 0x8f, 0x8b, 0xe0, 0x30, 0x5e, 0x92, + 0xde, 0xf3, 0x3d, 0x6b, 0xc4, 0x08, 0x61, 0xf4, 0xb5, 0x5c, 0xa5, 0x58, 0x18, 0xbb, 0xe7, 0x42, + 0x7b, 0xb4, 0x92, 0x38, 0x62, 0x31, 0xb6, 0x6d, 0x68, 0xa8, 0xaf, 0x63, 0xf5, 0xad, 0xc1, 0x71, + 0xa8, 0xd7, 0x9e, 0x0f, 0xcd, 0xcb, 0x04, 0x2f, 0x62, 0x15, 0xa4, 0x88, 0x98, 0x60, 0x27, 0xd4, + 0x6b, 0xa5, 0xa9, 0xb3, 0x9c, 0x23, 0xa3, 0xa9, 0xb5, 0x77, 0x67, 0x41, 0xeb, 0x5a, 0xf2, 0x2c, + 0x92, 0x95, 0x29, 0x2e, 0x40, 0x22, 0x42, 0x2c, 0x58, 0xc6, 0x23, 0x93, 0xd8, 0x0e, 0x77, 0x14, + 0xfb, 0x25, 0x3c, 0x54, 0xc7, 0xdc, 0xa6, 0x88, 0x23, 0x82, 0x25, 0xe6, 0xc2, 0xa9, 0xf7, 0xeb, + 0x83, 0x4e, 0x78, 0xaa, 0xe4, 0xab, 0x52, 0xb5, 0x5f, 0x41, 0x73, 0xa6, 0xc0, 0x9c, 0x46, 0xbf, + 0x3e, 0xe8, 0x06, 0x67, 0xc3, 0xdd, 0xba, 0x87, 0x9a, 0x39, 0x34, 0x0e, 0xef, 0x97, 0x05, 0xed, + 0xcb, 0x8c, 0x46, 0x32, 0x61, 0xb4, 0x12, 0xaa, 0x07, 0xed, 0x44, 0x5c, 0x65, 0xd3, 0x45, 0x12, + 0xe5, 0x48, 0xe5, 0xde, 0xc4, 0x3e, 0x23, 0x99, 0x2c, 0xb1, 0x53, 0x2f, 0x62, 0x66, 0x5f, 0x05, + 0xdb, 0xa8, 0x84, 0x7d, 0x06, 0x1d, 0xc4, 0xe7, 0x19, 0xc1, 0x54, 0x0a, 0xa7, 0xa9, 0x2d, 0x5b, + 0xc1, 0x76, 0xe0, 0x01, 0xc7, 0x32, 0xe3, 0x54, 0x38, 0x2d, 0x1d, 0x2b, 0xb6, 0xde, 0x4f, 0x0b, + 0xe0, 0x3a, 0xe2, 0x49, 0x2a, 0xc7, 0x58, 0x22, 0xfb, 0x05, 0x9c, 0x88, 0x64, 0x4e, 0x31, 0x17, + 0xb7, 0x11, 0xcb, 0xa8, 0xd4, 0x45, 0x9c, 0x84, 0xc7, 0xb9, 0xf8, 0x41, 0x69, 0x55, 0x50, 0x47, + 0x95, 0x50, 0xef, 0x76, 0xa1, 0x54, 0x93, 0x4f, 0x83, 0x27, 0xfb, 0x5d, 0x9c, 0x8c, 0x6f, 0x56, + 0x29, 0xbe, 0x41, 0xf3, 0x1d, 0x5a, 0xef, 0x87, 0x05, 0x30, 0x66, 0x71, 0xb6, 0xc0, 0x9a, 0xa9, + 0xaa, 0x9f, 0xe7, 0xd0, 0xd4, 0x6f, 0x4c, 0xff, 0xb8, 0x1b, 0x3c, 0xda, 0x3f, 0xd5, 0xbc, 0x8e, + 0xd0, 0x58, 0xec, 0xb7, 0xd0, 0x99, 0xe5, 0x77, 0x63, 0x28, 0xba, 0xc1, 0xe3, 0x83, 0xbb, 0xcc, + 0xc3, 0xe1, 0xd6, 0xe8, 0x7d, 0x87, 0xf6, 0x38, 0x7f, 0xf7, 0x76, 0x00, 0x2d, 0xa1, 0x7b, 0xa4, + 0x19, 0xba, 0x81, 0x73, 0xf0, 0xbb, 0xb2, 0x7f, 0x9f, 0x6a, 0x61, 0xee, 0x54, 0x39, 0x44, 0xd7, + 0xa0, 0xef, 0xfb, 0xbf, 0x9c, 0x6d, 0x7d, 0x2a, 0xc7, 0x38, 0x47, 0x2d, 0x68, 0xa8, 0x59, 0x0b, + 0x26, 0x70, 0x76, 0x31, 0x19, 0x17, 0x53, 0x53, 0x62, 0xbc, 0x87, 0xee, 0x47, 0x2c, 0xcb, 0xed, + 0x41, 0x11, 0x85, 0xbd, 0x77, 0xa0, 0x17, 0x7e, 0xaf, 0x36, 0xba, 0xf8, 0xbd, 0x76, 0xad, 0xfb, + 0xb5, 0x6b, 0xfd, 0x5d, 0xbb, 0xd6, 0xdd, 0xc6, 0xad, 0xdd, 0x6f, 0xdc, 0xda, 0x9f, 0x8d, 0x5b, + 0xfb, 0x72, 0x3e, 0x4f, 0xe4, 0xd7, 0x6c, 0x3a, 0x8c, 0x18, 0xf1, 0xb7, 0x03, 0x2d, 0x24, 0x52, + 0xcd, 0xf0, 0xd3, 0x6f, 0x73, 0x5f, 0xf7, 0x52, 0xcd, 0xf8, 0xb4, 0xa5, 0xe7, 0xfa, 0xcd, 0xbf, + 0x00, 0x00, 0x00, 0xff, 0xff, 0x6d, 0xd1, 0x0a, 0x76, 0x25, 0x04, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// DVMBytecodeMetadataClient is the client API for DVMBytecodeMetadata service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type DVMBytecodeMetadataClient interface { + GetMetadata(ctx context.Context, in *Bytecode, opts ...grpc.CallOption) (*Metadata, error) +} + +type dVMBytecodeMetadataClient struct { + cc grpc1.ClientConn +} + +func NewDVMBytecodeMetadataClient(cc grpc1.ClientConn) DVMBytecodeMetadataClient { + return &dVMBytecodeMetadataClient{cc} +} + +func (c *dVMBytecodeMetadataClient) GetMetadata(ctx context.Context, in *Bytecode, opts ...grpc.CallOption) (*Metadata, error) { + out := new(Metadata) + err := c.cc.Invoke(ctx, "/dfinance.dvm.DVMBytecodeMetadata/GetMetadata", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// DVMBytecodeMetadataServer is the server API for DVMBytecodeMetadata service. +type DVMBytecodeMetadataServer interface { + GetMetadata(context.Context, *Bytecode) (*Metadata, error) +} + +// UnimplementedDVMBytecodeMetadataServer can be embedded to have forward compatible implementations. +type UnimplementedDVMBytecodeMetadataServer struct { +} + +func (*UnimplementedDVMBytecodeMetadataServer) GetMetadata(ctx context.Context, req *Bytecode) (*Metadata, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetMetadata not implemented") +} + +func RegisterDVMBytecodeMetadataServer(s grpc1.Server, srv DVMBytecodeMetadataServer) { + s.RegisterService(&_DVMBytecodeMetadata_serviceDesc, srv) +} + +func _DVMBytecodeMetadata_GetMetadata_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(Bytecode) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DVMBytecodeMetadataServer).GetMetadata(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/dfinance.dvm.DVMBytecodeMetadata/GetMetadata", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DVMBytecodeMetadataServer).GetMetadata(ctx, req.(*Bytecode)) + } + return interceptor(ctx, in, info, handler) +} + +var _DVMBytecodeMetadata_serviceDesc = grpc.ServiceDesc{ + ServiceName: "dfinance.dvm.DVMBytecodeMetadata", + HandlerType: (*DVMBytecodeMetadataServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetMetadata", + Handler: _DVMBytecodeMetadata_GetMetadata_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "dfinance/dvm/metadata.proto", +} + +func (m *Bytecode) 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 *Bytecode) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Bytecode) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Code) > 0 { + i -= len(m.Code) + copy(dAtA[i:], m.Code) + i = encodeVarintMetadata(dAtA, i, uint64(len(m.Code))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Field) 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 *Field) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Field) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Type) > 0 { + i -= len(m.Type) + copy(dAtA[i:], m.Type) + i = encodeVarintMetadata(dAtA, i, uint64(len(m.Type))) + i-- + dAtA[i] = 0x12 + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintMetadata(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Struct) 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 *Struct) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Struct) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Field) > 0 { + for iNdEx := len(m.Field) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Field[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintMetadata(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + if len(m.TypeParameters) > 0 { + for iNdEx := len(m.TypeParameters) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.TypeParameters[iNdEx]) + copy(dAtA[i:], m.TypeParameters[iNdEx]) + i = encodeVarintMetadata(dAtA, i, uint64(len(m.TypeParameters[iNdEx]))) + i-- + dAtA[i] = 0x1a + } + } + if m.IsResource { + i-- + if m.IsResource { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x10 + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintMetadata(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Function) 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 *Function) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Function) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Returns) > 0 { + for iNdEx := len(m.Returns) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Returns[iNdEx]) + copy(dAtA[i:], m.Returns[iNdEx]) + i = encodeVarintMetadata(dAtA, i, uint64(len(m.Returns[iNdEx]))) + i-- + dAtA[i] = 0x32 + } + } + if len(m.Arguments) > 0 { + for iNdEx := len(m.Arguments) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Arguments[iNdEx]) + copy(dAtA[i:], m.Arguments[iNdEx]) + i = encodeVarintMetadata(dAtA, i, uint64(len(m.Arguments[iNdEx]))) + i-- + dAtA[i] = 0x2a + } + } + if len(m.TypeParameters) > 0 { + for iNdEx := len(m.TypeParameters) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.TypeParameters[iNdEx]) + copy(dAtA[i:], m.TypeParameters[iNdEx]) + i = encodeVarintMetadata(dAtA, i, uint64(len(m.TypeParameters[iNdEx]))) + i-- + dAtA[i] = 0x22 + } + } + if m.IsNative { + i-- + if m.IsNative { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x18 + } + if m.IsPublic { + i-- + if m.IsPublic { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x10 + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintMetadata(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *ScriptMeta) 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 *ScriptMeta) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ScriptMeta) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Arguments) > 0 { + dAtA2 := make([]byte, len(m.Arguments)*10) + var j1 int + for _, num := range m.Arguments { + for num >= 1<<7 { + dAtA2[j1] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j1++ + } + dAtA2[j1] = uint8(num) + j1++ + } + i -= j1 + copy(dAtA[i:], dAtA2[:j1]) + i = encodeVarintMetadata(dAtA, i, uint64(j1)) + i-- + dAtA[i] = 0x1a + } + if len(m.TypeParameters) > 0 { + for iNdEx := len(m.TypeParameters) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.TypeParameters[iNdEx]) + copy(dAtA[i:], m.TypeParameters[iNdEx]) + i = encodeVarintMetadata(dAtA, i, uint64(len(m.TypeParameters[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } + if m.SignersCount != 0 { + i = encodeVarintMetadata(dAtA, i, uint64(m.SignersCount)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *ModuleMeta) 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 *ModuleMeta) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ModuleMeta) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Functions) > 0 { + for iNdEx := len(m.Functions) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Functions[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintMetadata(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.Types) > 0 { + for iNdEx := len(m.Types) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Types[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintMetadata(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintMetadata(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Metadata) 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 *Metadata) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Metadata) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Meta != nil { + { + size := m.Meta.Size() + i -= size + if _, err := m.Meta.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + } + } + return len(dAtA) - i, nil +} + +func (m *Metadata_Script) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Metadata_Script) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.Script != nil { + { + size, err := m.Script.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintMetadata(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} +func (m *Metadata_Module) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Metadata_Module) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.Module != nil { + { + size, err := m.Module.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintMetadata(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + return len(dAtA) - i, nil +} +func encodeVarintMetadata(dAtA []byte, offset int, v uint64) int { + offset -= sovMetadata(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Bytecode) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Code) + if l > 0 { + n += 1 + l + sovMetadata(uint64(l)) + } + return n +} + +func (m *Field) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovMetadata(uint64(l)) + } + l = len(m.Type) + if l > 0 { + n += 1 + l + sovMetadata(uint64(l)) + } + return n +} + +func (m *Struct) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovMetadata(uint64(l)) + } + if m.IsResource { + n += 2 + } + if len(m.TypeParameters) > 0 { + for _, s := range m.TypeParameters { + l = len(s) + n += 1 + l + sovMetadata(uint64(l)) + } + } + if len(m.Field) > 0 { + for _, e := range m.Field { + l = e.Size() + n += 1 + l + sovMetadata(uint64(l)) + } + } + return n +} + +func (m *Function) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovMetadata(uint64(l)) + } + if m.IsPublic { + n += 2 + } + if m.IsNative { + n += 2 + } + if len(m.TypeParameters) > 0 { + for _, s := range m.TypeParameters { + l = len(s) + n += 1 + l + sovMetadata(uint64(l)) + } + } + if len(m.Arguments) > 0 { + for _, s := range m.Arguments { + l = len(s) + n += 1 + l + sovMetadata(uint64(l)) + } + } + if len(m.Returns) > 0 { + for _, s := range m.Returns { + l = len(s) + n += 1 + l + sovMetadata(uint64(l)) + } + } + return n +} + +func (m *ScriptMeta) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.SignersCount != 0 { + n += 1 + sovMetadata(uint64(m.SignersCount)) + } + if len(m.TypeParameters) > 0 { + for _, s := range m.TypeParameters { + l = len(s) + n += 1 + l + sovMetadata(uint64(l)) + } + } + if len(m.Arguments) > 0 { + l = 0 + for _, e := range m.Arguments { + l += sovMetadata(uint64(e)) + } + n += 1 + sovMetadata(uint64(l)) + l + } + return n +} + +func (m *ModuleMeta) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovMetadata(uint64(l)) + } + if len(m.Types) > 0 { + for _, e := range m.Types { + l = e.Size() + n += 1 + l + sovMetadata(uint64(l)) + } + } + if len(m.Functions) > 0 { + for _, e := range m.Functions { + l = e.Size() + n += 1 + l + sovMetadata(uint64(l)) + } + } + return n +} + +func (m *Metadata) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Meta != nil { + n += m.Meta.Size() + } + return n +} + +func (m *Metadata_Script) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Script != nil { + l = m.Script.Size() + n += 1 + l + sovMetadata(uint64(l)) + } + return n +} +func (m *Metadata_Module) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Module != nil { + l = m.Module.Size() + n += 1 + l + sovMetadata(uint64(l)) + } + return n +} + +func sovMetadata(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozMetadata(x uint64) (n int) { + return sovMetadata(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Bytecode) 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 ErrIntOverflowMetadata + } + 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: Bytecode: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Bytecode: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Code", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthMetadata + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Code = append(m.Code[:0], dAtA[iNdEx:postIndex]...) + if m.Code == nil { + m.Code = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipMetadata(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMetadata + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Field) 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 ErrIntOverflowMetadata + } + 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: Field: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Field: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMetadata + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMetadata + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Type = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipMetadata(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMetadata + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Struct) 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 ErrIntOverflowMetadata + } + 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: Struct: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Struct: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMetadata + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsResource", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsResource = bool(v != 0) + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TypeParameters", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMetadata + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TypeParameters = append(m.TypeParameters, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Field", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthMetadata + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Field = append(m.Field, &Field{}) + if err := m.Field[len(m.Field)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipMetadata(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMetadata + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Function) 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 ErrIntOverflowMetadata + } + 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: Function: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Function: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMetadata + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsPublic", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsPublic = bool(v != 0) + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsNative", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsNative = bool(v != 0) + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TypeParameters", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMetadata + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TypeParameters = append(m.TypeParameters, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Arguments", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMetadata + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Arguments = append(m.Arguments, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Returns", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMetadata + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Returns = append(m.Returns, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipMetadata(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMetadata + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ScriptMeta) 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 ErrIntOverflowMetadata + } + 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: ScriptMeta: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ScriptMeta: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SignersCount", wireType) + } + m.SignersCount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SignersCount |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TypeParameters", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMetadata + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TypeParameters = append(m.TypeParameters, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 3: + if wireType == 0 { + var v VMTypeTag + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= VMTypeTag(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Arguments = append(m.Arguments, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthMetadata + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + if elementCount != 0 && len(m.Arguments) == 0 { + m.Arguments = make([]VMTypeTag, 0, elementCount) + } + for iNdEx < postIndex { + var v VMTypeTag + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= VMTypeTag(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Arguments = append(m.Arguments, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field Arguments", wireType) + } + default: + iNdEx = preIndex + skippy, err := skipMetadata(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMetadata + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ModuleMeta) 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 ErrIntOverflowMetadata + } + 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: ModuleMeta: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ModuleMeta: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMetadata + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Types", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthMetadata + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Types = append(m.Types, &Struct{}) + if err := m.Types[len(m.Types)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Functions", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthMetadata + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Functions = append(m.Functions, &Function{}) + if err := m.Functions[len(m.Functions)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipMetadata(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMetadata + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Metadata) 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 ErrIntOverflowMetadata + } + 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: Metadata: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Metadata: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Script", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthMetadata + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &ScriptMeta{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Meta = &Metadata_Script{v} + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Module", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthMetadata + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &ModuleMeta{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Meta = &Metadata_Module{v} + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipMetadata(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMetadata + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipMetadata(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowMetadata + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowMetadata + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowMetadata + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthMetadata + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupMetadata + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthMetadata + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthMetadata = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowMetadata = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupMetadata = fmt.Errorf("proto: unexpected end of group") +) diff --git a/pkg/types/dvm/vm.pb.go b/pkg/types/dvm/vm.pb.go new file mode 100644 index 0000000..c48e95f --- /dev/null +++ b/pkg/types/dvm/vm.pb.go @@ -0,0 +1,6056 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: dfinance/dvm/vm.proto + +package dvm + +import ( + context "context" + fmt "fmt" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type LcsType int32 + +const ( + LcsType_LcsBool LcsType = 0 + LcsType_LcsU64 LcsType = 1 + LcsType_LcsVector LcsType = 2 + LcsType_LcsAddress LcsType = 3 + LcsType_LcsU8 LcsType = 4 + LcsType_LcsU128 LcsType = 5 + LcsType_LcsSigner LcsType = 6 + LcsType_LcsStruct LcsType = 7 +) + +var LcsType_name = map[int32]string{ + 0: "LcsBool", + 1: "LcsU64", + 2: "LcsVector", + 3: "LcsAddress", + 4: "LcsU8", + 5: "LcsU128", + 6: "LcsSigner", + 7: "LcsStruct", +} + +var LcsType_value = map[string]int32{ + "LcsBool": 0, + "LcsU64": 1, + "LcsVector": 2, + "LcsAddress": 3, + "LcsU8": 4, + "LcsU128": 5, + "LcsSigner": 6, + "LcsStruct": 7, +} + +func (x LcsType) String() string { + return proto.EnumName(LcsType_name, int32(x)) +} + +func (LcsType) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_6aa38fa9ac8218d6, []int{0} +} + +// Write set operation type. +type VmWriteOp int32 + +const ( + VmWriteOp_Value VmWriteOp = 0 + VmWriteOp_Deletion VmWriteOp = 1 +) + +var VmWriteOp_name = map[int32]string{ + 0: "Value", + 1: "Deletion", +} + +var VmWriteOp_value = map[string]int32{ + "Value": 0, + "Deletion": 1, +} + +func (x VmWriteOp) String() string { + return proto.EnumName(VmWriteOp_name, int32(x)) +} + +func (VmWriteOp) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_6aa38fa9ac8218d6, []int{1} +} + +// An `AbortLocation` specifies where a Move program `abort` occurred, either in a function in +// a module, or in a script. +type AbortLocation struct { + Address []byte `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + Module string `protobuf:"bytes,2,opt,name=module,proto3" json:"module,omitempty"` +} + +func (m *AbortLocation) Reset() { *m = AbortLocation{} } +func (m *AbortLocation) String() string { return proto.CompactTextString(m) } +func (*AbortLocation) ProtoMessage() {} +func (*AbortLocation) Descriptor() ([]byte, []int) { + return fileDescriptor_6aa38fa9ac8218d6, []int{0} +} +func (m *AbortLocation) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AbortLocation) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AbortLocation.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 *AbortLocation) XXX_Merge(src proto.Message) { + xxx_messageInfo_AbortLocation.Merge(m, src) +} +func (m *AbortLocation) XXX_Size() int { + return m.Size() +} +func (m *AbortLocation) XXX_DiscardUnknown() { + xxx_messageInfo_AbortLocation.DiscardUnknown(m) +} + +var xxx_messageInfo_AbortLocation proto.InternalMessageInfo + +func (m *AbortLocation) GetAddress() []byte { + if m != nil { + return m.Address + } + return nil +} + +func (m *AbortLocation) GetModule() string { + if m != nil { + return m.Module + } + return "" +} + +// Function location. +type FunctionLoc struct { + Function uint64 `protobuf:"varint,1,opt,name=function,proto3" json:"function,omitempty"` + CodeOffset uint64 `protobuf:"varint,2,opt,name=code_offset,json=codeOffset,proto3" json:"code_offset,omitempty"` +} + +func (m *FunctionLoc) Reset() { *m = FunctionLoc{} } +func (m *FunctionLoc) String() string { return proto.CompactTextString(m) } +func (*FunctionLoc) ProtoMessage() {} +func (*FunctionLoc) Descriptor() ([]byte, []int) { + return fileDescriptor_6aa38fa9ac8218d6, []int{1} +} +func (m *FunctionLoc) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *FunctionLoc) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_FunctionLoc.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 *FunctionLoc) XXX_Merge(src proto.Message) { + xxx_messageInfo_FunctionLoc.Merge(m, src) +} +func (m *FunctionLoc) XXX_Size() int { + return m.Size() +} +func (m *FunctionLoc) XXX_DiscardUnknown() { + xxx_messageInfo_FunctionLoc.DiscardUnknown(m) +} + +var xxx_messageInfo_FunctionLoc proto.InternalMessageInfo + +func (m *FunctionLoc) GetFunction() uint64 { + if m != nil { + return m.Function + } + return 0 +} + +func (m *FunctionLoc) GetCodeOffset() uint64 { + if m != nil { + return m.CodeOffset + } + return 0 +} + +// VmStatus `Error` case. +type MoveError struct { + // Status code. + StatusCode uint64 `protobuf:"varint,2,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` +} + +func (m *MoveError) Reset() { *m = MoveError{} } +func (m *MoveError) String() string { return proto.CompactTextString(m) } +func (*MoveError) ProtoMessage() {} +func (*MoveError) Descriptor() ([]byte, []int) { + return fileDescriptor_6aa38fa9ac8218d6, []int{2} +} +func (m *MoveError) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MoveError) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MoveError.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 *MoveError) XXX_Merge(src proto.Message) { + xxx_messageInfo_MoveError.Merge(m, src) +} +func (m *MoveError) XXX_Size() int { + return m.Size() +} +func (m *MoveError) XXX_DiscardUnknown() { + xxx_messageInfo_MoveError.DiscardUnknown(m) +} + +var xxx_messageInfo_MoveError proto.InternalMessageInfo + +func (m *MoveError) GetStatusCode() uint64 { + if m != nil { + return m.StatusCode + } + return 0 +} + +// VmStatus `MoveAbort` case. +type Abort struct { + // Abort location. (optional). Null if abort occurred in the script. + AbortLocation *AbortLocation `protobuf:"bytes,1,opt,name=abort_location,json=abortLocation,proto3" json:"abort_location,omitempty"` + // Abort code. + AbortCode uint64 `protobuf:"varint,2,opt,name=abort_code,json=abortCode,proto3" json:"abort_code,omitempty"` +} + +func (m *Abort) Reset() { *m = Abort{} } +func (m *Abort) String() string { return proto.CompactTextString(m) } +func (*Abort) ProtoMessage() {} +func (*Abort) Descriptor() ([]byte, []int) { + return fileDescriptor_6aa38fa9ac8218d6, []int{3} +} +func (m *Abort) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Abort) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Abort.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 *Abort) XXX_Merge(src proto.Message) { + xxx_messageInfo_Abort.Merge(m, src) +} +func (m *Abort) XXX_Size() int { + return m.Size() +} +func (m *Abort) XXX_DiscardUnknown() { + xxx_messageInfo_Abort.DiscardUnknown(m) +} + +var xxx_messageInfo_Abort proto.InternalMessageInfo + +func (m *Abort) GetAbortLocation() *AbortLocation { + if m != nil { + return m.AbortLocation + } + return nil +} + +func (m *Abort) GetAbortCode() uint64 { + if m != nil { + return m.AbortCode + } + return 0 +} + +// VmStatus `ExecutionFailure` case. +type Failure struct { + // Status code. + StatusCode uint64 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` + // Abort location. (optional). Null if abort occurred in the script. + AbortLocation *AbortLocation `protobuf:"bytes,2,opt,name=abort_location,json=abortLocation,proto3" json:"abort_location,omitempty"` + // Function location. + FunctionLoc *FunctionLoc `protobuf:"bytes,3,opt,name=function_loc,json=functionLoc,proto3" json:"function_loc,omitempty"` +} + +func (m *Failure) Reset() { *m = Failure{} } +func (m *Failure) String() string { return proto.CompactTextString(m) } +func (*Failure) ProtoMessage() {} +func (*Failure) Descriptor() ([]byte, []int) { + return fileDescriptor_6aa38fa9ac8218d6, []int{4} +} +func (m *Failure) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Failure) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Failure.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 *Failure) XXX_Merge(src proto.Message) { + xxx_messageInfo_Failure.Merge(m, src) +} +func (m *Failure) XXX_Size() int { + return m.Size() +} +func (m *Failure) XXX_DiscardUnknown() { + xxx_messageInfo_Failure.DiscardUnknown(m) +} + +var xxx_messageInfo_Failure proto.InternalMessageInfo + +func (m *Failure) GetStatusCode() uint64 { + if m != nil { + return m.StatusCode + } + return 0 +} + +func (m *Failure) GetAbortLocation() *AbortLocation { + if m != nil { + return m.AbortLocation + } + return nil +} + +func (m *Failure) GetFunctionLoc() *FunctionLoc { + if m != nil { + return m.FunctionLoc + } + return nil +} + +/// Message. +type Message struct { + // Message with error details if needed. + Text string `protobuf:"bytes,1,opt,name=text,proto3" json:"text,omitempty"` +} + +func (m *Message) Reset() { *m = Message{} } +func (m *Message) String() string { return proto.CompactTextString(m) } +func (*Message) ProtoMessage() {} +func (*Message) Descriptor() ([]byte, []int) { + return fileDescriptor_6aa38fa9ac8218d6, []int{5} +} +func (m *Message) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Message) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Message.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 *Message) XXX_Merge(src proto.Message) { + xxx_messageInfo_Message.Merge(m, src) +} +func (m *Message) XXX_Size() int { + return m.Size() +} +func (m *Message) XXX_DiscardUnknown() { + xxx_messageInfo_Message.DiscardUnknown(m) +} + +var xxx_messageInfo_Message proto.InternalMessageInfo + +func (m *Message) GetText() string { + if m != nil { + return m.Text + } + return "" +} + +// A `VMStatus` is represented as either +// - `Null` indicating successful execution. +// - `Error` indicating an error from the VM itself. +// - `MoveAbort` indicating an `abort` ocurred inside of a Move program +// - `ExecutionFailure` indicating an runtime error. +type VMStatus struct { + // Types that are valid to be assigned to Error: + // *VMStatus_MoveError + // *VMStatus_Abort + // *VMStatus_ExecutionFailure + Error isVMStatus_Error `protobuf_oneof:"error"` + // Message with error details if needed (optional). + Message *Message `protobuf:"bytes,4,opt,name=message,proto3" json:"message,omitempty"` +} + +func (m *VMStatus) Reset() { *m = VMStatus{} } +func (m *VMStatus) String() string { return proto.CompactTextString(m) } +func (*VMStatus) ProtoMessage() {} +func (*VMStatus) Descriptor() ([]byte, []int) { + return fileDescriptor_6aa38fa9ac8218d6, []int{6} +} +func (m *VMStatus) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *VMStatus) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_VMStatus.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 *VMStatus) XXX_Merge(src proto.Message) { + xxx_messageInfo_VMStatus.Merge(m, src) +} +func (m *VMStatus) XXX_Size() int { + return m.Size() +} +func (m *VMStatus) XXX_DiscardUnknown() { + xxx_messageInfo_VMStatus.DiscardUnknown(m) +} + +var xxx_messageInfo_VMStatus proto.InternalMessageInfo + +type isVMStatus_Error interface { + isVMStatus_Error() + MarshalTo([]byte) (int, error) + Size() int +} + +type VMStatus_MoveError struct { + MoveError *MoveError `protobuf:"bytes,1,opt,name=move_error,json=moveError,proto3,oneof" json:"move_error,omitempty"` +} +type VMStatus_Abort struct { + Abort *Abort `protobuf:"bytes,2,opt,name=abort,proto3,oneof" json:"abort,omitempty"` +} +type VMStatus_ExecutionFailure struct { + ExecutionFailure *Failure `protobuf:"bytes,3,opt,name=execution_failure,json=executionFailure,proto3,oneof" json:"execution_failure,omitempty"` +} + +func (*VMStatus_MoveError) isVMStatus_Error() {} +func (*VMStatus_Abort) isVMStatus_Error() {} +func (*VMStatus_ExecutionFailure) isVMStatus_Error() {} + +func (m *VMStatus) GetError() isVMStatus_Error { + if m != nil { + return m.Error + } + return nil +} + +func (m *VMStatus) GetMoveError() *MoveError { + if x, ok := m.GetError().(*VMStatus_MoveError); ok { + return x.MoveError + } + return nil +} + +func (m *VMStatus) GetAbort() *Abort { + if x, ok := m.GetError().(*VMStatus_Abort); ok { + return x.Abort + } + return nil +} + +func (m *VMStatus) GetExecutionFailure() *Failure { + if x, ok := m.GetError().(*VMStatus_ExecutionFailure); ok { + return x.ExecutionFailure + } + return nil +} + +func (m *VMStatus) GetMessage() *Message { + if m != nil { + return m.Message + } + return nil +} + +// XXX_OneofWrappers is for the internal use of the proto package. +func (*VMStatus) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*VMStatus_MoveError)(nil), + (*VMStatus_Abort)(nil), + (*VMStatus_ExecutionFailure)(nil), + } +} + +/// Full name of the structure. +type StructIdent struct { + Address []byte `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + Module string `protobuf:"bytes,2,opt,name=module,proto3" json:"module,omitempty"` + Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` + TypeParams []*LcsTag `protobuf:"bytes,4,rep,name=type_params,json=typeParams,proto3" json:"type_params,omitempty"` +} + +func (m *StructIdent) Reset() { *m = StructIdent{} } +func (m *StructIdent) String() string { return proto.CompactTextString(m) } +func (*StructIdent) ProtoMessage() {} +func (*StructIdent) Descriptor() ([]byte, []int) { + return fileDescriptor_6aa38fa9ac8218d6, []int{7} +} +func (m *StructIdent) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *StructIdent) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_StructIdent.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 *StructIdent) XXX_Merge(src proto.Message) { + xxx_messageInfo_StructIdent.Merge(m, src) +} +func (m *StructIdent) XXX_Size() int { + return m.Size() +} +func (m *StructIdent) XXX_DiscardUnknown() { + xxx_messageInfo_StructIdent.DiscardUnknown(m) +} + +var xxx_messageInfo_StructIdent proto.InternalMessageInfo + +func (m *StructIdent) GetAddress() []byte { + if m != nil { + return m.Address + } + return nil +} + +func (m *StructIdent) GetModule() string { + if m != nil { + return m.Module + } + return "" +} + +func (m *StructIdent) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *StructIdent) GetTypeParams() []*LcsTag { + if m != nil { + return m.TypeParams + } + return nil +} + +type LcsTag struct { + TypeTag LcsType `protobuf:"varint,1,opt,name=type_tag,json=typeTag,proto3,enum=dfinance.dvm.LcsType" json:"type_tag,omitempty"` + VectorType *LcsTag `protobuf:"bytes,2,opt,name=vector_type,json=vectorType,proto3" json:"vector_type,omitempty"` + StructIdent *StructIdent `protobuf:"bytes,3,opt,name=struct_ident,json=structIdent,proto3" json:"struct_ident,omitempty"` +} + +func (m *LcsTag) Reset() { *m = LcsTag{} } +func (m *LcsTag) String() string { return proto.CompactTextString(m) } +func (*LcsTag) ProtoMessage() {} +func (*LcsTag) Descriptor() ([]byte, []int) { + return fileDescriptor_6aa38fa9ac8218d6, []int{8} +} +func (m *LcsTag) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *LcsTag) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_LcsTag.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 *LcsTag) XXX_Merge(src proto.Message) { + xxx_messageInfo_LcsTag.Merge(m, src) +} +func (m *LcsTag) XXX_Size() int { + return m.Size() +} +func (m *LcsTag) XXX_DiscardUnknown() { + xxx_messageInfo_LcsTag.DiscardUnknown(m) +} + +var xxx_messageInfo_LcsTag proto.InternalMessageInfo + +func (m *LcsTag) GetTypeTag() LcsType { + if m != nil { + return m.TypeTag + } + return LcsType_LcsBool +} + +func (m *LcsTag) GetVectorType() *LcsTag { + if m != nil { + return m.VectorType + } + return nil +} + +func (m *LcsTag) GetStructIdent() *StructIdent { + if m != nil { + return m.StructIdent + } + return nil +} + +/// Module identifier. +type ModuleIdent struct { + Address []byte `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` +} + +func (m *ModuleIdent) Reset() { *m = ModuleIdent{} } +func (m *ModuleIdent) String() string { return proto.CompactTextString(m) } +func (*ModuleIdent) ProtoMessage() {} +func (*ModuleIdent) Descriptor() ([]byte, []int) { + return fileDescriptor_6aa38fa9ac8218d6, []int{9} +} +func (m *ModuleIdent) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ModuleIdent) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ModuleIdent.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 *ModuleIdent) XXX_Merge(src proto.Message) { + xxx_messageInfo_ModuleIdent.Merge(m, src) +} +func (m *ModuleIdent) XXX_Size() int { + return m.Size() +} +func (m *ModuleIdent) XXX_DiscardUnknown() { + xxx_messageInfo_ModuleIdent.DiscardUnknown(m) +} + +var xxx_messageInfo_ModuleIdent proto.InternalMessageInfo + +func (m *ModuleIdent) GetAddress() []byte { + if m != nil { + return m.Address + } + return nil +} + +func (m *ModuleIdent) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +// VM event returns after contract execution. +type VMEvent struct { + SenderAddress []byte `protobuf:"bytes,1,opt,name=sender_address,json=senderAddress,proto3" json:"sender_address,omitempty"` + SenderModule *ModuleIdent `protobuf:"bytes,2,opt,name=sender_module,json=senderModule,proto3" json:"sender_module,omitempty"` + EventType *LcsTag `protobuf:"bytes,3,opt,name=event_type,json=eventType,proto3" json:"event_type,omitempty"` + EventData []byte `protobuf:"bytes,4,opt,name=event_data,json=eventData,proto3" json:"event_data,omitempty"` +} + +func (m *VMEvent) Reset() { *m = VMEvent{} } +func (m *VMEvent) String() string { return proto.CompactTextString(m) } +func (*VMEvent) ProtoMessage() {} +func (*VMEvent) Descriptor() ([]byte, []int) { + return fileDescriptor_6aa38fa9ac8218d6, []int{10} +} +func (m *VMEvent) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *VMEvent) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_VMEvent.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 *VMEvent) XXX_Merge(src proto.Message) { + xxx_messageInfo_VMEvent.Merge(m, src) +} +func (m *VMEvent) XXX_Size() int { + return m.Size() +} +func (m *VMEvent) XXX_DiscardUnknown() { + xxx_messageInfo_VMEvent.DiscardUnknown(m) +} + +var xxx_messageInfo_VMEvent proto.InternalMessageInfo + +func (m *VMEvent) GetSenderAddress() []byte { + if m != nil { + return m.SenderAddress + } + return nil +} + +func (m *VMEvent) GetSenderModule() *ModuleIdent { + if m != nil { + return m.SenderModule + } + return nil +} + +func (m *VMEvent) GetEventType() *LcsTag { + if m != nil { + return m.EventType + } + return nil +} + +func (m *VMEvent) GetEventData() []byte { + if m != nil { + return m.EventData + } + return nil +} + +// Storage path +type VMAccessPath struct { + Address []byte `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + Path []byte `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"` +} + +func (m *VMAccessPath) Reset() { *m = VMAccessPath{} } +func (m *VMAccessPath) String() string { return proto.CompactTextString(m) } +func (*VMAccessPath) ProtoMessage() {} +func (*VMAccessPath) Descriptor() ([]byte, []int) { + return fileDescriptor_6aa38fa9ac8218d6, []int{11} +} +func (m *VMAccessPath) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *VMAccessPath) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_VMAccessPath.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 *VMAccessPath) XXX_Merge(src proto.Message) { + xxx_messageInfo_VMAccessPath.Merge(m, src) +} +func (m *VMAccessPath) XXX_Size() int { + return m.Size() +} +func (m *VMAccessPath) XXX_DiscardUnknown() { + xxx_messageInfo_VMAccessPath.DiscardUnknown(m) +} + +var xxx_messageInfo_VMAccessPath proto.InternalMessageInfo + +func (m *VMAccessPath) GetAddress() []byte { + if m != nil { + return m.Address + } + return nil +} + +func (m *VMAccessPath) GetPath() []byte { + if m != nil { + return m.Path + } + return nil +} + +// VM value should be passed before execution and return after execution (with opcodes), write_set in nutshell. +type VMValue struct { + Type VmWriteOp `protobuf:"varint,2,opt,name=type,proto3,enum=dfinance.dvm.VmWriteOp" json:"type,omitempty"` + Value []byte `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"` + Path *VMAccessPath `protobuf:"bytes,3,opt,name=path,proto3" json:"path,omitempty"` +} + +func (m *VMValue) Reset() { *m = VMValue{} } +func (m *VMValue) String() string { return proto.CompactTextString(m) } +func (*VMValue) ProtoMessage() {} +func (*VMValue) Descriptor() ([]byte, []int) { + return fileDescriptor_6aa38fa9ac8218d6, []int{12} +} +func (m *VMValue) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *VMValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_VMValue.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 *VMValue) XXX_Merge(src proto.Message) { + xxx_messageInfo_VMValue.Merge(m, src) +} +func (m *VMValue) XXX_Size() int { + return m.Size() +} +func (m *VMValue) XXX_DiscardUnknown() { + xxx_messageInfo_VMValue.DiscardUnknown(m) +} + +var xxx_messageInfo_VMValue proto.InternalMessageInfo + +func (m *VMValue) GetType() VmWriteOp { + if m != nil { + return m.Type + } + return VmWriteOp_Value +} + +func (m *VMValue) GetValue() []byte { + if m != nil { + return m.Value + } + return nil +} + +func (m *VMValue) GetPath() *VMAccessPath { + if m != nil { + return m.Path + } + return nil +} + +// Contract arguments. +type VMArgs struct { + Type VMTypeTag `protobuf:"varint,1,opt,name=type,proto3,enum=dfinance.dvm.VMTypeTag" json:"type,omitempty"` + Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` +} + +func (m *VMArgs) Reset() { *m = VMArgs{} } +func (m *VMArgs) String() string { return proto.CompactTextString(m) } +func (*VMArgs) ProtoMessage() {} +func (*VMArgs) Descriptor() ([]byte, []int) { + return fileDescriptor_6aa38fa9ac8218d6, []int{13} +} +func (m *VMArgs) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *VMArgs) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_VMArgs.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 *VMArgs) XXX_Merge(src proto.Message) { + xxx_messageInfo_VMArgs.Merge(m, src) +} +func (m *VMArgs) XXX_Size() int { + return m.Size() +} +func (m *VMArgs) XXX_DiscardUnknown() { + xxx_messageInfo_VMArgs.DiscardUnknown(m) +} + +var xxx_messageInfo_VMArgs proto.InternalMessageInfo + +func (m *VMArgs) GetType() VMTypeTag { + if m != nil { + return m.Type + } + return VMTypeTag_Bool +} + +func (m *VMArgs) GetValue() []byte { + if m != nil { + return m.Value + } + return nil +} + +// Publish module. +type VMPublishModule struct { + Sender []byte `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + MaxGasAmount uint64 `protobuf:"varint,2,opt,name=max_gas_amount,json=maxGasAmount,proto3" json:"max_gas_amount,omitempty"` + GasUnitPrice uint64 `protobuf:"varint,3,opt,name=gas_unit_price,json=gasUnitPrice,proto3" json:"gas_unit_price,omitempty"` + Code []byte `protobuf:"bytes,4,opt,name=code,proto3" json:"code,omitempty"` +} + +func (m *VMPublishModule) Reset() { *m = VMPublishModule{} } +func (m *VMPublishModule) String() string { return proto.CompactTextString(m) } +func (*VMPublishModule) ProtoMessage() {} +func (*VMPublishModule) Descriptor() ([]byte, []int) { + return fileDescriptor_6aa38fa9ac8218d6, []int{14} +} +func (m *VMPublishModule) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *VMPublishModule) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_VMPublishModule.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 *VMPublishModule) XXX_Merge(src proto.Message) { + xxx_messageInfo_VMPublishModule.Merge(m, src) +} +func (m *VMPublishModule) XXX_Size() int { + return m.Size() +} +func (m *VMPublishModule) XXX_DiscardUnknown() { + xxx_messageInfo_VMPublishModule.DiscardUnknown(m) +} + +var xxx_messageInfo_VMPublishModule proto.InternalMessageInfo + +func (m *VMPublishModule) GetSender() []byte { + if m != nil { + return m.Sender + } + return nil +} + +func (m *VMPublishModule) GetMaxGasAmount() uint64 { + if m != nil { + return m.MaxGasAmount + } + return 0 +} + +func (m *VMPublishModule) GetGasUnitPrice() uint64 { + if m != nil { + return m.GasUnitPrice + } + return 0 +} + +func (m *VMPublishModule) GetCode() []byte { + if m != nil { + return m.Code + } + return nil +} + +// VM contract object to process. +type VMExecuteScript struct { + Senders [][]byte `protobuf:"bytes,1,rep,name=senders,proto3" json:"senders,omitempty"` + MaxGasAmount uint64 `protobuf:"varint,2,opt,name=max_gas_amount,json=maxGasAmount,proto3" json:"max_gas_amount,omitempty"` + GasUnitPrice uint64 `protobuf:"varint,3,opt,name=gas_unit_price,json=gasUnitPrice,proto3" json:"gas_unit_price,omitempty"` + Block uint64 `protobuf:"varint,4,opt,name=block,proto3" json:"block,omitempty"` + Timestamp uint64 `protobuf:"varint,5,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + Code []byte `protobuf:"bytes,6,opt,name=code,proto3" json:"code,omitempty"` + TypeParams []*StructIdent `protobuf:"bytes,7,rep,name=type_params,json=typeParams,proto3" json:"type_params,omitempty"` + Args []*VMArgs `protobuf:"bytes,8,rep,name=args,proto3" json:"args,omitempty"` +} + +func (m *VMExecuteScript) Reset() { *m = VMExecuteScript{} } +func (m *VMExecuteScript) String() string { return proto.CompactTextString(m) } +func (*VMExecuteScript) ProtoMessage() {} +func (*VMExecuteScript) Descriptor() ([]byte, []int) { + return fileDescriptor_6aa38fa9ac8218d6, []int{15} +} +func (m *VMExecuteScript) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *VMExecuteScript) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_VMExecuteScript.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 *VMExecuteScript) XXX_Merge(src proto.Message) { + xxx_messageInfo_VMExecuteScript.Merge(m, src) +} +func (m *VMExecuteScript) XXX_Size() int { + return m.Size() +} +func (m *VMExecuteScript) XXX_DiscardUnknown() { + xxx_messageInfo_VMExecuteScript.DiscardUnknown(m) +} + +var xxx_messageInfo_VMExecuteScript proto.InternalMessageInfo + +func (m *VMExecuteScript) GetSenders() [][]byte { + if m != nil { + return m.Senders + } + return nil +} + +func (m *VMExecuteScript) GetMaxGasAmount() uint64 { + if m != nil { + return m.MaxGasAmount + } + return 0 +} + +func (m *VMExecuteScript) GetGasUnitPrice() uint64 { + if m != nil { + return m.GasUnitPrice + } + return 0 +} + +func (m *VMExecuteScript) GetBlock() uint64 { + if m != nil { + return m.Block + } + return 0 +} + +func (m *VMExecuteScript) GetTimestamp() uint64 { + if m != nil { + return m.Timestamp + } + return 0 +} + +func (m *VMExecuteScript) GetCode() []byte { + if m != nil { + return m.Code + } + return nil +} + +func (m *VMExecuteScript) GetTypeParams() []*StructIdent { + if m != nil { + return m.TypeParams + } + return nil +} + +func (m *VMExecuteScript) GetArgs() []*VMArgs { + if m != nil { + return m.Args + } + return nil +} + +type VMBalanceChange struct { + Address []byte `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + Ticker string `protobuf:"bytes,2,opt,name=ticker,proto3" json:"ticker,omitempty"` + // Types that are valid to be assigned to Op: + // *VMBalanceChange_Deposit + // *VMBalanceChange_Withdraw + Op isVMBalanceChange_Op `protobuf_oneof:"op"` +} + +func (m *VMBalanceChange) Reset() { *m = VMBalanceChange{} } +func (m *VMBalanceChange) String() string { return proto.CompactTextString(m) } +func (*VMBalanceChange) ProtoMessage() {} +func (*VMBalanceChange) Descriptor() ([]byte, []int) { + return fileDescriptor_6aa38fa9ac8218d6, []int{16} +} +func (m *VMBalanceChange) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *VMBalanceChange) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_VMBalanceChange.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 *VMBalanceChange) XXX_Merge(src proto.Message) { + xxx_messageInfo_VMBalanceChange.Merge(m, src) +} +func (m *VMBalanceChange) XXX_Size() int { + return m.Size() +} +func (m *VMBalanceChange) XXX_DiscardUnknown() { + xxx_messageInfo_VMBalanceChange.DiscardUnknown(m) +} + +var xxx_messageInfo_VMBalanceChange proto.InternalMessageInfo + +type isVMBalanceChange_Op interface { + isVMBalanceChange_Op() + MarshalTo([]byte) (int, error) + Size() int +} + +type VMBalanceChange_Deposit struct { + Deposit *U128 `protobuf:"bytes,3,opt,name=deposit,proto3,oneof" json:"deposit,omitempty"` +} +type VMBalanceChange_Withdraw struct { + Withdraw *U128 `protobuf:"bytes,4,opt,name=withdraw,proto3,oneof" json:"withdraw,omitempty"` +} + +func (*VMBalanceChange_Deposit) isVMBalanceChange_Op() {} +func (*VMBalanceChange_Withdraw) isVMBalanceChange_Op() {} + +func (m *VMBalanceChange) GetOp() isVMBalanceChange_Op { + if m != nil { + return m.Op + } + return nil +} + +func (m *VMBalanceChange) GetAddress() []byte { + if m != nil { + return m.Address + } + return nil +} + +func (m *VMBalanceChange) GetTicker() string { + if m != nil { + return m.Ticker + } + return "" +} + +func (m *VMBalanceChange) GetDeposit() *U128 { + if x, ok := m.GetOp().(*VMBalanceChange_Deposit); ok { + return x.Deposit + } + return nil +} + +func (m *VMBalanceChange) GetWithdraw() *U128 { + if x, ok := m.GetOp().(*VMBalanceChange_Withdraw); ok { + return x.Withdraw + } + return nil +} + +// XXX_OneofWrappers is for the internal use of the proto package. +func (*VMBalanceChange) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*VMBalanceChange_Deposit)(nil), + (*VMBalanceChange_Withdraw)(nil), + } +} + +type VMBalanceChangeSet struct { + ChangeSet []*VMBalanceChange `protobuf:"bytes,1,rep,name=change_set,json=changeSet,proto3" json:"change_set,omitempty"` +} + +func (m *VMBalanceChangeSet) Reset() { *m = VMBalanceChangeSet{} } +func (m *VMBalanceChangeSet) String() string { return proto.CompactTextString(m) } +func (*VMBalanceChangeSet) ProtoMessage() {} +func (*VMBalanceChangeSet) Descriptor() ([]byte, []int) { + return fileDescriptor_6aa38fa9ac8218d6, []int{17} +} +func (m *VMBalanceChangeSet) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *VMBalanceChangeSet) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_VMBalanceChangeSet.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 *VMBalanceChangeSet) XXX_Merge(src proto.Message) { + xxx_messageInfo_VMBalanceChangeSet.Merge(m, src) +} +func (m *VMBalanceChangeSet) XXX_Size() int { + return m.Size() +} +func (m *VMBalanceChangeSet) XXX_DiscardUnknown() { + xxx_messageInfo_VMBalanceChangeSet.DiscardUnknown(m) +} + +var xxx_messageInfo_VMBalanceChangeSet proto.InternalMessageInfo + +func (m *VMBalanceChangeSet) GetChangeSet() []*VMBalanceChange { + if m != nil { + return m.ChangeSet + } + return nil +} + +// Response from VM contains write_set, events, gas used and status for specific contract. +type VMExecuteResponse struct { + WriteSet []*VMValue `protobuf:"bytes,1,rep,name=write_set,json=writeSet,proto3" json:"write_set,omitempty"` + Events []*VMEvent `protobuf:"bytes,2,rep,name=events,proto3" json:"events,omitempty"` + BalanceChangeSet []*VMBalanceChange `protobuf:"bytes,3,rep,name=balance_change_set,json=balanceChangeSet,proto3" json:"balance_change_set,omitempty"` + GasUsed uint64 `protobuf:"varint,4,opt,name=gas_used,json=gasUsed,proto3" json:"gas_used,omitempty"` + Status *VMStatus `protobuf:"bytes,5,opt,name=status,proto3" json:"status,omitempty"` +} + +func (m *VMExecuteResponse) Reset() { *m = VMExecuteResponse{} } +func (m *VMExecuteResponse) String() string { return proto.CompactTextString(m) } +func (*VMExecuteResponse) ProtoMessage() {} +func (*VMExecuteResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_6aa38fa9ac8218d6, []int{18} +} +func (m *VMExecuteResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *VMExecuteResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_VMExecuteResponse.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 *VMExecuteResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_VMExecuteResponse.Merge(m, src) +} +func (m *VMExecuteResponse) XXX_Size() int { + return m.Size() +} +func (m *VMExecuteResponse) XXX_DiscardUnknown() { + xxx_messageInfo_VMExecuteResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_VMExecuteResponse proto.InternalMessageInfo + +func (m *VMExecuteResponse) GetWriteSet() []*VMValue { + if m != nil { + return m.WriteSet + } + return nil +} + +func (m *VMExecuteResponse) GetEvents() []*VMEvent { + if m != nil { + return m.Events + } + return nil +} + +func (m *VMExecuteResponse) GetBalanceChangeSet() []*VMBalanceChange { + if m != nil { + return m.BalanceChangeSet + } + return nil +} + +func (m *VMExecuteResponse) GetGasUsed() uint64 { + if m != nil { + return m.GasUsed + } + return 0 +} + +func (m *VMExecuteResponse) GetStatus() *VMStatus { + if m != nil { + return m.Status + } + return nil +} + +type MultipleCompilationResult struct { + Units []*CompiledUnit `protobuf:"bytes,1,rep,name=units,proto3" json:"units,omitempty"` + Errors []string `protobuf:"bytes,2,rep,name=errors,proto3" json:"errors,omitempty"` +} + +func (m *MultipleCompilationResult) Reset() { *m = MultipleCompilationResult{} } +func (m *MultipleCompilationResult) String() string { return proto.CompactTextString(m) } +func (*MultipleCompilationResult) ProtoMessage() {} +func (*MultipleCompilationResult) Descriptor() ([]byte, []int) { + return fileDescriptor_6aa38fa9ac8218d6, []int{19} +} +func (m *MultipleCompilationResult) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MultipleCompilationResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MultipleCompilationResult.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 *MultipleCompilationResult) XXX_Merge(src proto.Message) { + xxx_messageInfo_MultipleCompilationResult.Merge(m, src) +} +func (m *MultipleCompilationResult) XXX_Size() int { + return m.Size() +} +func (m *MultipleCompilationResult) XXX_DiscardUnknown() { + xxx_messageInfo_MultipleCompilationResult.DiscardUnknown(m) +} + +var xxx_messageInfo_MultipleCompilationResult proto.InternalMessageInfo + +func (m *MultipleCompilationResult) GetUnits() []*CompiledUnit { + if m != nil { + return m.Units + } + return nil +} + +func (m *MultipleCompilationResult) GetErrors() []string { + if m != nil { + return m.Errors + } + return nil +} + +func init() { + proto.RegisterEnum("dfinance.dvm.LcsType", LcsType_name, LcsType_value) + proto.RegisterEnum("dfinance.dvm.VmWriteOp", VmWriteOp_name, VmWriteOp_value) + proto.RegisterType((*AbortLocation)(nil), "dfinance.dvm.AbortLocation") + proto.RegisterType((*FunctionLoc)(nil), "dfinance.dvm.FunctionLoc") + proto.RegisterType((*MoveError)(nil), "dfinance.dvm.MoveError") + proto.RegisterType((*Abort)(nil), "dfinance.dvm.Abort") + proto.RegisterType((*Failure)(nil), "dfinance.dvm.Failure") + proto.RegisterType((*Message)(nil), "dfinance.dvm.Message") + proto.RegisterType((*VMStatus)(nil), "dfinance.dvm.VMStatus") + proto.RegisterType((*StructIdent)(nil), "dfinance.dvm.StructIdent") + proto.RegisterType((*LcsTag)(nil), "dfinance.dvm.LcsTag") + proto.RegisterType((*ModuleIdent)(nil), "dfinance.dvm.ModuleIdent") + proto.RegisterType((*VMEvent)(nil), "dfinance.dvm.VMEvent") + proto.RegisterType((*VMAccessPath)(nil), "dfinance.dvm.VMAccessPath") + proto.RegisterType((*VMValue)(nil), "dfinance.dvm.VMValue") + proto.RegisterType((*VMArgs)(nil), "dfinance.dvm.VMArgs") + proto.RegisterType((*VMPublishModule)(nil), "dfinance.dvm.VMPublishModule") + proto.RegisterType((*VMExecuteScript)(nil), "dfinance.dvm.VMExecuteScript") + proto.RegisterType((*VMBalanceChange)(nil), "dfinance.dvm.VMBalanceChange") + proto.RegisterType((*VMBalanceChangeSet)(nil), "dfinance.dvm.VMBalanceChangeSet") + proto.RegisterType((*VMExecuteResponse)(nil), "dfinance.dvm.VMExecuteResponse") + proto.RegisterType((*MultipleCompilationResult)(nil), "dfinance.dvm.MultipleCompilationResult") +} + +func init() { proto.RegisterFile("dfinance/dvm/vm.proto", fileDescriptor_6aa38fa9ac8218d6) } + +var fileDescriptor_6aa38fa9ac8218d6 = []byte{ + // 1333 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x57, 0xdd, 0x6e, 0x1b, 0x45, + 0x14, 0xf6, 0x3a, 0xfe, 0xdb, 0x63, 0x27, 0xb8, 0x43, 0x5b, 0xdc, 0x94, 0xa4, 0xd5, 0xaa, 0x48, + 0x51, 0x4b, 0x1d, 0xea, 0x52, 0x14, 0x41, 0x85, 0x94, 0x34, 0x2d, 0x81, 0xc6, 0x6a, 0x98, 0xb4, + 0x46, 0xe2, 0x66, 0x35, 0xde, 0x1d, 0x3b, 0x4b, 0xbd, 0x3b, 0xab, 0x9d, 0x59, 0x27, 0x95, 0x78, + 0x01, 0xb8, 0x40, 0xbc, 0x04, 0x57, 0x20, 0xf1, 0x12, 0x5c, 0x70, 0xd9, 0x4b, 0x2e, 0x51, 0xfb, + 0x04, 0xbc, 0x01, 0x9a, 0x9f, 0x75, 0xbc, 0x5b, 0x37, 0xb4, 0x12, 0x77, 0x7b, 0xce, 0x7e, 0xe7, + 0xef, 0x3b, 0x67, 0xce, 0xec, 0xc2, 0x05, 0x7f, 0x14, 0x44, 0x24, 0xf2, 0xe8, 0xa6, 0x3f, 0x0d, + 0x37, 0xa7, 0x61, 0x37, 0x4e, 0x98, 0x60, 0xa8, 0x95, 0xa9, 0xbb, 0xfe, 0x34, 0x5c, 0xbd, 0x92, + 0x03, 0x79, 0x2c, 0x0c, 0x59, 0x74, 0x53, 0x3c, 0x8b, 0x29, 0xd7, 0xf0, 0xd5, 0xcb, 0x45, 0x40, + 0x1c, 0x4c, 0x68, 0xa2, 0x5f, 0x3a, 0xdb, 0xb0, 0xbc, 0x3d, 0x64, 0x89, 0xd8, 0x67, 0x1e, 0x11, + 0x01, 0x8b, 0x50, 0x07, 0xea, 0xc4, 0xf7, 0x13, 0xca, 0x79, 0xc7, 0xba, 0x6a, 0x6d, 0xb4, 0x70, + 0x26, 0xa2, 0x8b, 0x50, 0x0b, 0x99, 0x9f, 0x4e, 0x68, 0xa7, 0x7c, 0xd5, 0xda, 0xb0, 0xb1, 0x91, + 0x9c, 0xaf, 0xa0, 0xf9, 0x20, 0x8d, 0x3c, 0x69, 0xbd, 0xcf, 0x3c, 0xb4, 0x0a, 0x8d, 0x91, 0x11, + 0x95, 0x87, 0x0a, 0x9e, 0xc9, 0xe8, 0x0a, 0x34, 0x3d, 0xe6, 0x53, 0x97, 0x8d, 0x46, 0x9c, 0x0a, + 0xe5, 0xa7, 0x82, 0x41, 0xaa, 0x1e, 0x29, 0x8d, 0xf3, 0x21, 0xd8, 0x7d, 0x36, 0xa5, 0xf7, 0x93, + 0x84, 0x25, 0x12, 0xcd, 0x05, 0x11, 0x29, 0x77, 0x25, 0x22, 0x43, 0x6b, 0xd5, 0x3d, 0xe6, 0x53, + 0xe7, 0x3b, 0xa8, 0xaa, 0xe4, 0xd1, 0x0e, 0xac, 0x10, 0xf9, 0xe0, 0x4e, 0x4c, 0x19, 0x2a, 0x72, + 0xb3, 0x77, 0xb9, 0x3b, 0x4f, 0x55, 0x37, 0x57, 0x29, 0x5e, 0x26, 0xb9, 0xc2, 0xd7, 0x00, 0xb4, + 0x8f, 0xb9, 0x60, 0xb6, 0xd2, 0xa8, 0x58, 0xbf, 0x59, 0x50, 0x7f, 0x40, 0x82, 0x49, 0x9a, 0xd0, + 0x62, 0x62, 0x56, 0x31, 0xb1, 0x05, 0xf9, 0x94, 0xdf, 0x3a, 0x9f, 0xbb, 0xd0, 0xca, 0x78, 0x93, + 0x6e, 0x3a, 0x4b, 0xca, 0xc3, 0xa5, 0xbc, 0x87, 0x39, 0xe2, 0x71, 0x73, 0x74, 0x2a, 0x38, 0x6b, + 0x50, 0xef, 0x53, 0xce, 0xc9, 0x98, 0x22, 0x04, 0x15, 0x41, 0x4f, 0x84, 0x4a, 0xd3, 0xc6, 0xea, + 0xd9, 0xf9, 0xc7, 0x82, 0xc6, 0xa0, 0x7f, 0xa8, 0x32, 0x46, 0x5b, 0x00, 0x21, 0x9b, 0x52, 0x97, + 0x4a, 0xd6, 0x0d, 0x73, 0xef, 0xe5, 0xe3, 0xcc, 0x9a, 0xb2, 0x57, 0xc2, 0x76, 0x38, 0xeb, 0xd0, + 0x0d, 0xa8, 0xaa, 0xa4, 0x4d, 0x79, 0xef, 0x2e, 0x28, 0x6f, 0xaf, 0x84, 0x35, 0x06, 0xed, 0xc2, + 0x39, 0x7a, 0x42, 0xbd, 0x54, 0x55, 0x34, 0xd2, 0x54, 0x9a, 0xaa, 0x2e, 0x14, 0xaa, 0xd2, 0x2f, + 0xf7, 0x4a, 0xb8, 0x3d, 0xb3, 0xc8, 0xb8, 0xdf, 0x84, 0x7a, 0xa8, 0x0b, 0xeb, 0x54, 0x16, 0xd9, + 0x9a, 0xaa, 0x71, 0x86, 0xda, 0xa9, 0x43, 0x55, 0x15, 0xe6, 0xfc, 0x68, 0x41, 0xf3, 0x50, 0x24, + 0xa9, 0x27, 0xbe, 0xf4, 0x69, 0x24, 0xde, 0x7e, 0xd2, 0x25, 0x93, 0x11, 0x09, 0x75, 0xd2, 0x36, + 0x56, 0xcf, 0xe8, 0x0e, 0x34, 0xe5, 0x61, 0x73, 0x63, 0x92, 0x90, 0x90, 0x77, 0x2a, 0x57, 0x97, + 0x36, 0x9a, 0xbd, 0xf3, 0xf9, 0x9c, 0xf6, 0x3d, 0xfe, 0x98, 0x8c, 0x31, 0x48, 0xe0, 0x81, 0xc2, + 0x39, 0xbf, 0x5b, 0x50, 0xd3, 0x6a, 0xf4, 0x11, 0x34, 0x94, 0x07, 0x41, 0xc6, 0x2a, 0x91, 0x95, + 0x62, 0x49, 0x12, 0xf7, 0x2c, 0xa6, 0xb8, 0x2e, 0x61, 0xd2, 0xe2, 0x0e, 0x34, 0xa7, 0xd4, 0x13, + 0x2c, 0x71, 0xa5, 0xc6, 0x90, 0xff, 0x9a, 0x98, 0x1a, 0x28, 0xed, 0xe5, 0x44, 0x71, 0x55, 0xbf, + 0x1b, 0x48, 0x02, 0x16, 0x4f, 0xd4, 0x1c, 0x43, 0xb8, 0xc9, 0x4f, 0x05, 0xe7, 0x33, 0x68, 0xf6, + 0x15, 0x0d, 0xff, 0xc5, 0x5e, 0xc6, 0x52, 0xf9, 0x94, 0x25, 0xe7, 0x0f, 0x0b, 0xea, 0x83, 0xfe, + 0xfd, 0xa9, 0xb4, 0xfc, 0x00, 0x56, 0x38, 0x8d, 0x7c, 0x9a, 0xb8, 0x79, 0x07, 0xcb, 0x5a, 0xbb, + 0x6d, 0xdc, 0x7c, 0x0e, 0x46, 0xe1, 0xce, 0xf5, 0xe2, 0x95, 0x74, 0xe7, 0x52, 0xc2, 0x2d, 0x8d, + 0xd7, 0x2a, 0x74, 0x1b, 0x80, 0xca, 0x78, 0x9a, 0xa3, 0xa5, 0x33, 0x38, 0xb2, 0x15, 0x4e, 0x51, + 0xb4, 0x96, 0x19, 0xf9, 0x44, 0x10, 0x35, 0x60, 0x2d, 0xf3, 0x7a, 0x97, 0x08, 0xe2, 0xdc, 0x85, + 0xd6, 0xa0, 0xbf, 0xed, 0x79, 0x94, 0xf3, 0x03, 0x22, 0x8e, 0xce, 0x26, 0x21, 0x26, 0xe2, 0x48, + 0x25, 0xdd, 0xc2, 0xea, 0xd9, 0xf9, 0x5e, 0x72, 0x30, 0x20, 0x93, 0x94, 0xa2, 0x1b, 0x50, 0x99, + 0xb5, 0x6e, 0xa5, 0x78, 0xd8, 0x06, 0xe1, 0x37, 0x49, 0x20, 0xe8, 0xa3, 0x18, 0x2b, 0x10, 0x3a, + 0x0f, 0xd5, 0xa9, 0xb4, 0x32, 0x31, 0xb4, 0x80, 0xba, 0x26, 0x82, 0xae, 0x6c, 0xb5, 0xe0, 0x62, + 0x2e, 0x4b, 0x13, 0xfd, 0x21, 0xd4, 0x06, 0xfd, 0xed, 0x64, 0xcc, 0x67, 0xc1, 0xad, 0x85, 0xc1, + 0xfb, 0x8f, 0xf5, 0x94, 0x15, 0x83, 0x97, 0xe7, 0x82, 0x3b, 0x3f, 0x58, 0xf0, 0xce, 0xa0, 0x7f, + 0x90, 0x0e, 0x27, 0x01, 0x3f, 0x32, 0x84, 0x5f, 0x84, 0x9a, 0x6e, 0x80, 0xc9, 0xd3, 0x48, 0xe8, + 0x1a, 0xac, 0x84, 0xe4, 0xc4, 0x1d, 0x13, 0xee, 0x92, 0x90, 0xa5, 0x51, 0xb6, 0xf7, 0x5b, 0x21, + 0x39, 0xf9, 0x82, 0xf0, 0x6d, 0xa5, 0x93, 0x28, 0x89, 0x48, 0xa3, 0x40, 0xb8, 0x71, 0x12, 0x78, + 0xba, 0x65, 0x15, 0xdc, 0x1a, 0x13, 0xfe, 0x24, 0x0a, 0xc4, 0x81, 0xd4, 0x49, 0x5a, 0xd5, 0xca, + 0xd5, 0x9d, 0x51, 0xcf, 0xce, 0x2f, 0x65, 0x99, 0xcb, 0x7d, 0xb5, 0x28, 0xe8, 0xa1, 0x97, 0x04, + 0xb1, 0x9a, 0x4e, 0x1d, 0x5d, 0x36, 0x66, 0x49, 0x36, 0xc6, 0x88, 0xff, 0x6b, 0x36, 0xe7, 0xa1, + 0x3a, 0x9c, 0x30, 0xef, 0xa9, 0x4a, 0xa7, 0x82, 0xb5, 0x80, 0xde, 0x07, 0x5b, 0x04, 0x21, 0xe5, + 0x82, 0x84, 0x71, 0xa7, 0xaa, 0xef, 0x91, 0x99, 0x62, 0x56, 0x41, 0xed, 0xb4, 0x02, 0xf4, 0x69, + 0x7e, 0x87, 0xd4, 0xd5, 0x0e, 0x39, 0xe3, 0x5c, 0xce, 0x2d, 0x12, 0xb4, 0x01, 0x15, 0x92, 0x8c, + 0x79, 0xa7, 0xb1, 0x68, 0xf1, 0xe8, 0x86, 0x63, 0x85, 0x70, 0x7e, 0x55, 0x3d, 0xdb, 0x21, 0x13, + 0xf9, 0xfa, 0xde, 0x11, 0x89, 0xc6, 0xf4, 0xec, 0x1d, 0x28, 0x02, 0xef, 0x29, 0x4d, 0xb2, 0x1d, + 0xa8, 0x25, 0xd4, 0x85, 0xba, 0x4f, 0x63, 0xc6, 0x83, 0x6c, 0x7f, 0xa0, 0x7c, 0xc8, 0xf4, 0x56, + 0x6f, 0x6b, 0xaf, 0x84, 0x33, 0x90, 0xdc, 0x6e, 0xc7, 0x81, 0x38, 0xf2, 0x13, 0x72, 0x6c, 0x16, + 0xf6, 0x62, 0x83, 0x19, 0x6a, 0xa7, 0x02, 0x65, 0x16, 0x3b, 0x18, 0x50, 0x21, 0xd9, 0x43, 0x2a, + 0xd0, 0x5d, 0x00, 0x4f, 0x09, 0xae, 0xfc, 0x7e, 0xb0, 0x54, 0xcd, 0x6b, 0xc5, 0x9a, 0x73, 0x56, + 0xd8, 0xf6, 0x32, 0x6b, 0xe7, 0xa7, 0x32, 0x9c, 0x9b, 0x4d, 0x0a, 0xa6, 0x3c, 0x66, 0x11, 0xa7, + 0xa8, 0x07, 0xf6, 0xb1, 0x3c, 0x6f, 0x73, 0x2e, 0x2f, 0x14, 0x5d, 0xaa, 0x53, 0x8b, 0x1b, 0x0a, + 0x27, 0xf3, 0xb8, 0x09, 0x35, 0xb5, 0x15, 0x78, 0xa7, 0xbc, 0xd8, 0x40, 0xad, 0x3a, 0x6c, 0x40, + 0xe8, 0x21, 0xa0, 0xa1, 0x4e, 0xca, 0x9d, 0x4b, 0x7f, 0xe9, 0x4d, 0xd2, 0x6f, 0x0f, 0x8b, 0x1c, + 0x5c, 0x82, 0x86, 0x9a, 0x4d, 0x4e, 0x7d, 0x33, 0x78, 0x75, 0x39, 0x95, 0x9c, 0xfa, 0xa8, 0x0b, + 0x35, 0xfd, 0x15, 0xa2, 0xe6, 0xae, 0xd9, 0xbb, 0x58, 0xf4, 0xad, 0x6f, 0x7c, 0x6c, 0x50, 0x0e, + 0x85, 0x4b, 0xfd, 0x74, 0x22, 0x82, 0x78, 0x42, 0xef, 0xa9, 0xef, 0x42, 0xfd, 0x25, 0x42, 0x79, + 0x3a, 0x91, 0x9d, 0xab, 0xca, 0xf9, 0xe7, 0x86, 0x93, 0xc2, 0x86, 0xd1, 0x78, 0xea, 0xcb, 0xd3, + 0x80, 0x35, 0x50, 0xce, 0x8c, 0xba, 0x6a, 0x35, 0x2b, 0x36, 0x36, 0xd2, 0xf5, 0x63, 0xa8, 0x9b, + 0x3b, 0x0c, 0x35, 0xd5, 0xe3, 0x0e, 0x63, 0x93, 0x76, 0x09, 0x81, 0xba, 0x03, 0x9f, 0x7c, 0xf2, + 0x71, 0xdb, 0x42, 0xcb, 0x60, 0xef, 0x7b, 0x7c, 0xa0, 0x6e, 0xab, 0x76, 0x19, 0xad, 0x00, 0xec, + 0x7b, 0xdc, 0xdc, 0x05, 0xed, 0x25, 0x64, 0x43, 0x55, 0x42, 0xb7, 0xda, 0x15, 0xe3, 0xe2, 0xc9, + 0xad, 0xde, 0x56, 0xbb, 0x6a, 0xcc, 0x0e, 0x83, 0x71, 0x44, 0x93, 0x76, 0x2d, 0x13, 0xd5, 0x59, + 0x69, 0xd7, 0xaf, 0x5f, 0x03, 0x7b, 0xb6, 0x4c, 0xa5, 0x0b, 0xd5, 0xc6, 0x76, 0x09, 0xb5, 0xa0, + 0xb1, 0x4b, 0x27, 0x54, 0x16, 0xdb, 0xb6, 0x7a, 0x23, 0x39, 0x15, 0x7a, 0x89, 0x99, 0x8d, 0x46, + 0x13, 0xf4, 0x35, 0x2c, 0xe7, 0xd7, 0xdb, 0x2b, 0x7d, 0xca, 0xbd, 0x5e, 0xbd, 0xf2, 0xca, 0x04, + 0xe4, 0xc7, 0xcc, 0x29, 0xf5, 0x28, 0xb4, 0x07, 0x7d, 0xbd, 0xa0, 0xf4, 0x4b, 0xa6, 0xc2, 0xe4, + 0x37, 0xd7, 0xda, 0x6b, 0xfc, 0xe8, 0xd7, 0x6f, 0x10, 0x66, 0x67, 0xf7, 0xcf, 0x17, 0xeb, 0xd6, + 0xf3, 0x17, 0xeb, 0xd6, 0xdf, 0x2f, 0xd6, 0xad, 0x9f, 0x5f, 0xae, 0x97, 0x9e, 0xbf, 0x5c, 0x2f, + 0xfd, 0xf5, 0x72, 0xbd, 0xf4, 0xed, 0xf5, 0x71, 0x20, 0x8e, 0xd2, 0x61, 0xd7, 0x63, 0xe1, 0xe6, + 0xe9, 0x4f, 0x81, 0x9c, 0x85, 0x80, 0x45, 0x9b, 0xf1, 0xd3, 0xf1, 0xa6, 0xfa, 0x6f, 0x90, 0xff, + 0x09, 0xc3, 0x9a, 0xfa, 0x3f, 0xb8, 0xfd, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x17, 0x1d, 0xb3, + 0xac, 0x84, 0x0c, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// VMModulePublisherClient is the client API for VMModulePublisher service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type VMModulePublisherClient interface { + PublishModule(ctx context.Context, in *VMPublishModule, opts ...grpc.CallOption) (*VMExecuteResponse, error) +} + +type vMModulePublisherClient struct { + cc grpc1.ClientConn +} + +func NewVMModulePublisherClient(cc grpc1.ClientConn) VMModulePublisherClient { + return &vMModulePublisherClient{cc} +} + +func (c *vMModulePublisherClient) PublishModule(ctx context.Context, in *VMPublishModule, opts ...grpc.CallOption) (*VMExecuteResponse, error) { + out := new(VMExecuteResponse) + err := c.cc.Invoke(ctx, "/dfinance.dvm.VMModulePublisher/PublishModule", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// VMModulePublisherServer is the server API for VMModulePublisher service. +type VMModulePublisherServer interface { + PublishModule(context.Context, *VMPublishModule) (*VMExecuteResponse, error) +} + +// UnimplementedVMModulePublisherServer can be embedded to have forward compatible implementations. +type UnimplementedVMModulePublisherServer struct { +} + +func (*UnimplementedVMModulePublisherServer) PublishModule(ctx context.Context, req *VMPublishModule) (*VMExecuteResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PublishModule not implemented") +} + +func RegisterVMModulePublisherServer(s grpc1.Server, srv VMModulePublisherServer) { + s.RegisterService(&_VMModulePublisher_serviceDesc, srv) +} + +func _VMModulePublisher_PublishModule_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(VMPublishModule) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(VMModulePublisherServer).PublishModule(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/dfinance.dvm.VMModulePublisher/PublishModule", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(VMModulePublisherServer).PublishModule(ctx, req.(*VMPublishModule)) + } + return interceptor(ctx, in, info, handler) +} + +var _VMModulePublisher_serviceDesc = grpc.ServiceDesc{ + ServiceName: "dfinance.dvm.VMModulePublisher", + HandlerType: (*VMModulePublisherServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "PublishModule", + Handler: _VMModulePublisher_PublishModule_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "dfinance/dvm/vm.proto", +} + +// VMScriptExecutorClient is the client API for VMScriptExecutor service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type VMScriptExecutorClient interface { + ExecuteScript(ctx context.Context, in *VMExecuteScript, opts ...grpc.CallOption) (*VMExecuteResponse, error) +} + +type vMScriptExecutorClient struct { + cc grpc1.ClientConn +} + +func NewVMScriptExecutorClient(cc grpc1.ClientConn) VMScriptExecutorClient { + return &vMScriptExecutorClient{cc} +} + +func (c *vMScriptExecutorClient) ExecuteScript(ctx context.Context, in *VMExecuteScript, opts ...grpc.CallOption) (*VMExecuteResponse, error) { + out := new(VMExecuteResponse) + err := c.cc.Invoke(ctx, "/dfinance.dvm.VMScriptExecutor/ExecuteScript", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// VMScriptExecutorServer is the server API for VMScriptExecutor service. +type VMScriptExecutorServer interface { + ExecuteScript(context.Context, *VMExecuteScript) (*VMExecuteResponse, error) +} + +// UnimplementedVMScriptExecutorServer can be embedded to have forward compatible implementations. +type UnimplementedVMScriptExecutorServer struct { +} + +func (*UnimplementedVMScriptExecutorServer) ExecuteScript(ctx context.Context, req *VMExecuteScript) (*VMExecuteResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ExecuteScript not implemented") +} + +func RegisterVMScriptExecutorServer(s grpc1.Server, srv VMScriptExecutorServer) { + s.RegisterService(&_VMScriptExecutor_serviceDesc, srv) +} + +func _VMScriptExecutor_ExecuteScript_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(VMExecuteScript) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(VMScriptExecutorServer).ExecuteScript(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/dfinance.dvm.VMScriptExecutor/ExecuteScript", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(VMScriptExecutorServer).ExecuteScript(ctx, req.(*VMExecuteScript)) + } + return interceptor(ctx, in, info, handler) +} + +var _VMScriptExecutor_serviceDesc = grpc.ServiceDesc{ + ServiceName: "dfinance.dvm.VMScriptExecutor", + HandlerType: (*VMScriptExecutorServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "ExecuteScript", + Handler: _VMScriptExecutor_ExecuteScript_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "dfinance/dvm/vm.proto", +} + +func (m *AbortLocation) 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 *AbortLocation) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AbortLocation) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Module) > 0 { + i -= len(m.Module) + copy(dAtA[i:], m.Module) + i = encodeVarintVm(dAtA, i, uint64(len(m.Module))) + i-- + dAtA[i] = 0x12 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintVm(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *FunctionLoc) 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 *FunctionLoc) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *FunctionLoc) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.CodeOffset != 0 { + i = encodeVarintVm(dAtA, i, uint64(m.CodeOffset)) + i-- + dAtA[i] = 0x10 + } + if m.Function != 0 { + i = encodeVarintVm(dAtA, i, uint64(m.Function)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *MoveError) 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 *MoveError) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MoveError) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.StatusCode != 0 { + i = encodeVarintVm(dAtA, i, uint64(m.StatusCode)) + i-- + dAtA[i] = 0x10 + } + return len(dAtA) - i, nil +} + +func (m *Abort) 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 *Abort) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Abort) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.AbortCode != 0 { + i = encodeVarintVm(dAtA, i, uint64(m.AbortCode)) + i-- + dAtA[i] = 0x10 + } + if m.AbortLocation != nil { + { + size, err := m.AbortLocation.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintVm(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Failure) 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 *Failure) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Failure) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.FunctionLoc != nil { + { + size, err := m.FunctionLoc.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintVm(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if m.AbortLocation != nil { + { + size, err := m.AbortLocation.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintVm(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.StatusCode != 0 { + i = encodeVarintVm(dAtA, i, uint64(m.StatusCode)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *Message) 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 *Message) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Message) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Text) > 0 { + i -= len(m.Text) + copy(dAtA[i:], m.Text) + i = encodeVarintVm(dAtA, i, uint64(len(m.Text))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *VMStatus) 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 *VMStatus) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *VMStatus) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Message != nil { + { + size, err := m.Message.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintVm(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + if m.Error != nil { + { + size := m.Error.Size() + i -= size + if _, err := m.Error.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + } + } + return len(dAtA) - i, nil +} + +func (m *VMStatus_MoveError) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *VMStatus_MoveError) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.MoveError != nil { + { + size, err := m.MoveError.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintVm(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} +func (m *VMStatus_Abort) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *VMStatus_Abort) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.Abort != nil { + { + size, err := m.Abort.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintVm(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + return len(dAtA) - i, nil +} +func (m *VMStatus_ExecutionFailure) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *VMStatus_ExecutionFailure) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.ExecutionFailure != nil { + { + size, err := m.ExecutionFailure.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintVm(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + return len(dAtA) - i, nil +} +func (m *StructIdent) 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 *StructIdent) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StructIdent) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.TypeParams) > 0 { + for iNdEx := len(m.TypeParams) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.TypeParams[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintVm(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintVm(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0x1a + } + if len(m.Module) > 0 { + i -= len(m.Module) + copy(dAtA[i:], m.Module) + i = encodeVarintVm(dAtA, i, uint64(len(m.Module))) + i-- + dAtA[i] = 0x12 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintVm(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *LcsTag) 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 *LcsTag) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *LcsTag) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.StructIdent != nil { + { + size, err := m.StructIdent.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintVm(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if m.VectorType != nil { + { + size, err := m.VectorType.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintVm(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.TypeTag != 0 { + i = encodeVarintVm(dAtA, i, uint64(m.TypeTag)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *ModuleIdent) 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 *ModuleIdent) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ModuleIdent) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintVm(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0x12 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintVm(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *VMEvent) 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 *VMEvent) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *VMEvent) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.EventData) > 0 { + i -= len(m.EventData) + copy(dAtA[i:], m.EventData) + i = encodeVarintVm(dAtA, i, uint64(len(m.EventData))) + i-- + dAtA[i] = 0x22 + } + if m.EventType != nil { + { + size, err := m.EventType.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintVm(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if m.SenderModule != nil { + { + size, err := m.SenderModule.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintVm(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.SenderAddress) > 0 { + i -= len(m.SenderAddress) + copy(dAtA[i:], m.SenderAddress) + i = encodeVarintVm(dAtA, i, uint64(len(m.SenderAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *VMAccessPath) 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 *VMAccessPath) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *VMAccessPath) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Path) > 0 { + i -= len(m.Path) + copy(dAtA[i:], m.Path) + i = encodeVarintVm(dAtA, i, uint64(len(m.Path))) + i-- + dAtA[i] = 0x12 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintVm(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *VMValue) 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 *VMValue) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *VMValue) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Path != nil { + { + size, err := m.Path.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintVm(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if m.Type != 0 { + i = encodeVarintVm(dAtA, i, uint64(m.Type)) + i-- + dAtA[i] = 0x10 + } + if len(m.Value) > 0 { + i -= len(m.Value) + copy(dAtA[i:], m.Value) + i = encodeVarintVm(dAtA, i, uint64(len(m.Value))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *VMArgs) 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 *VMArgs) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *VMArgs) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Value) > 0 { + i -= len(m.Value) + copy(dAtA[i:], m.Value) + i = encodeVarintVm(dAtA, i, uint64(len(m.Value))) + i-- + dAtA[i] = 0x12 + } + if m.Type != 0 { + i = encodeVarintVm(dAtA, i, uint64(m.Type)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *VMPublishModule) 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 *VMPublishModule) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *VMPublishModule) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Code) > 0 { + i -= len(m.Code) + copy(dAtA[i:], m.Code) + i = encodeVarintVm(dAtA, i, uint64(len(m.Code))) + i-- + dAtA[i] = 0x22 + } + if m.GasUnitPrice != 0 { + i = encodeVarintVm(dAtA, i, uint64(m.GasUnitPrice)) + i-- + dAtA[i] = 0x18 + } + if m.MaxGasAmount != 0 { + i = encodeVarintVm(dAtA, i, uint64(m.MaxGasAmount)) + i-- + dAtA[i] = 0x10 + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintVm(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *VMExecuteScript) 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 *VMExecuteScript) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *VMExecuteScript) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Args) > 0 { + for iNdEx := len(m.Args) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Args[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintVm(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x42 + } + } + if len(m.TypeParams) > 0 { + for iNdEx := len(m.TypeParams) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.TypeParams[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintVm(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + } + } + if len(m.Code) > 0 { + i -= len(m.Code) + copy(dAtA[i:], m.Code) + i = encodeVarintVm(dAtA, i, uint64(len(m.Code))) + i-- + dAtA[i] = 0x32 + } + if m.Timestamp != 0 { + i = encodeVarintVm(dAtA, i, uint64(m.Timestamp)) + i-- + dAtA[i] = 0x28 + } + if m.Block != 0 { + i = encodeVarintVm(dAtA, i, uint64(m.Block)) + i-- + dAtA[i] = 0x20 + } + if m.GasUnitPrice != 0 { + i = encodeVarintVm(dAtA, i, uint64(m.GasUnitPrice)) + i-- + dAtA[i] = 0x18 + } + if m.MaxGasAmount != 0 { + i = encodeVarintVm(dAtA, i, uint64(m.MaxGasAmount)) + i-- + dAtA[i] = 0x10 + } + if len(m.Senders) > 0 { + for iNdEx := len(m.Senders) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Senders[iNdEx]) + copy(dAtA[i:], m.Senders[iNdEx]) + i = encodeVarintVm(dAtA, i, uint64(len(m.Senders[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *VMBalanceChange) 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 *VMBalanceChange) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *VMBalanceChange) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Op != nil { + { + size := m.Op.Size() + i -= size + if _, err := m.Op.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + } + } + if len(m.Ticker) > 0 { + i -= len(m.Ticker) + copy(dAtA[i:], m.Ticker) + i = encodeVarintVm(dAtA, i, uint64(len(m.Ticker))) + i-- + dAtA[i] = 0x12 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintVm(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *VMBalanceChange_Deposit) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *VMBalanceChange_Deposit) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.Deposit != nil { + { + size, err := m.Deposit.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintVm(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + return len(dAtA) - i, nil +} +func (m *VMBalanceChange_Withdraw) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *VMBalanceChange_Withdraw) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.Withdraw != nil { + { + size, err := m.Withdraw.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintVm(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + return len(dAtA) - i, nil +} +func (m *VMBalanceChangeSet) 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 *VMBalanceChangeSet) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *VMBalanceChangeSet) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ChangeSet) > 0 { + for iNdEx := len(m.ChangeSet) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.ChangeSet[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintVm(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *VMExecuteResponse) 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 *VMExecuteResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *VMExecuteResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Status != nil { + { + size, err := m.Status.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintVm(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + if m.GasUsed != 0 { + i = encodeVarintVm(dAtA, i, uint64(m.GasUsed)) + i-- + dAtA[i] = 0x20 + } + if len(m.BalanceChangeSet) > 0 { + for iNdEx := len(m.BalanceChangeSet) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.BalanceChangeSet[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintVm(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.Events) > 0 { + for iNdEx := len(m.Events) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Events[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintVm(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.WriteSet) > 0 { + for iNdEx := len(m.WriteSet) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.WriteSet[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintVm(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *MultipleCompilationResult) 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 *MultipleCompilationResult) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MultipleCompilationResult) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Errors) > 0 { + for iNdEx := len(m.Errors) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Errors[iNdEx]) + copy(dAtA[i:], m.Errors[iNdEx]) + i = encodeVarintVm(dAtA, i, uint64(len(m.Errors[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } + if len(m.Units) > 0 { + for iNdEx := len(m.Units) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Units[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintVm(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintVm(dAtA []byte, offset int, v uint64) int { + offset -= sovVm(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *AbortLocation) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovVm(uint64(l)) + } + l = len(m.Module) + if l > 0 { + n += 1 + l + sovVm(uint64(l)) + } + return n +} + +func (m *FunctionLoc) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Function != 0 { + n += 1 + sovVm(uint64(m.Function)) + } + if m.CodeOffset != 0 { + n += 1 + sovVm(uint64(m.CodeOffset)) + } + return n +} + +func (m *MoveError) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.StatusCode != 0 { + n += 1 + sovVm(uint64(m.StatusCode)) + } + return n +} + +func (m *Abort) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.AbortLocation != nil { + l = m.AbortLocation.Size() + n += 1 + l + sovVm(uint64(l)) + } + if m.AbortCode != 0 { + n += 1 + sovVm(uint64(m.AbortCode)) + } + return n +} + +func (m *Failure) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.StatusCode != 0 { + n += 1 + sovVm(uint64(m.StatusCode)) + } + if m.AbortLocation != nil { + l = m.AbortLocation.Size() + n += 1 + l + sovVm(uint64(l)) + } + if m.FunctionLoc != nil { + l = m.FunctionLoc.Size() + n += 1 + l + sovVm(uint64(l)) + } + return n +} + +func (m *Message) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Text) + if l > 0 { + n += 1 + l + sovVm(uint64(l)) + } + return n +} + +func (m *VMStatus) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Error != nil { + n += m.Error.Size() + } + if m.Message != nil { + l = m.Message.Size() + n += 1 + l + sovVm(uint64(l)) + } + return n +} + +func (m *VMStatus_MoveError) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.MoveError != nil { + l = m.MoveError.Size() + n += 1 + l + sovVm(uint64(l)) + } + return n +} +func (m *VMStatus_Abort) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Abort != nil { + l = m.Abort.Size() + n += 1 + l + sovVm(uint64(l)) + } + return n +} +func (m *VMStatus_ExecutionFailure) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ExecutionFailure != nil { + l = m.ExecutionFailure.Size() + n += 1 + l + sovVm(uint64(l)) + } + return n +} +func (m *StructIdent) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovVm(uint64(l)) + } + l = len(m.Module) + if l > 0 { + n += 1 + l + sovVm(uint64(l)) + } + l = len(m.Name) + if l > 0 { + n += 1 + l + sovVm(uint64(l)) + } + if len(m.TypeParams) > 0 { + for _, e := range m.TypeParams { + l = e.Size() + n += 1 + l + sovVm(uint64(l)) + } + } + return n +} + +func (m *LcsTag) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.TypeTag != 0 { + n += 1 + sovVm(uint64(m.TypeTag)) + } + if m.VectorType != nil { + l = m.VectorType.Size() + n += 1 + l + sovVm(uint64(l)) + } + if m.StructIdent != nil { + l = m.StructIdent.Size() + n += 1 + l + sovVm(uint64(l)) + } + return n +} + +func (m *ModuleIdent) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovVm(uint64(l)) + } + l = len(m.Name) + if l > 0 { + n += 1 + l + sovVm(uint64(l)) + } + return n +} + +func (m *VMEvent) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.SenderAddress) + if l > 0 { + n += 1 + l + sovVm(uint64(l)) + } + if m.SenderModule != nil { + l = m.SenderModule.Size() + n += 1 + l + sovVm(uint64(l)) + } + if m.EventType != nil { + l = m.EventType.Size() + n += 1 + l + sovVm(uint64(l)) + } + l = len(m.EventData) + if l > 0 { + n += 1 + l + sovVm(uint64(l)) + } + return n +} + +func (m *VMAccessPath) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovVm(uint64(l)) + } + l = len(m.Path) + if l > 0 { + n += 1 + l + sovVm(uint64(l)) + } + return n +} + +func (m *VMValue) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Value) + if l > 0 { + n += 1 + l + sovVm(uint64(l)) + } + if m.Type != 0 { + n += 1 + sovVm(uint64(m.Type)) + } + if m.Path != nil { + l = m.Path.Size() + n += 1 + l + sovVm(uint64(l)) + } + return n +} + +func (m *VMArgs) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Type != 0 { + n += 1 + sovVm(uint64(m.Type)) + } + l = len(m.Value) + if l > 0 { + n += 1 + l + sovVm(uint64(l)) + } + return n +} + +func (m *VMPublishModule) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovVm(uint64(l)) + } + if m.MaxGasAmount != 0 { + n += 1 + sovVm(uint64(m.MaxGasAmount)) + } + if m.GasUnitPrice != 0 { + n += 1 + sovVm(uint64(m.GasUnitPrice)) + } + l = len(m.Code) + if l > 0 { + n += 1 + l + sovVm(uint64(l)) + } + return n +} + +func (m *VMExecuteScript) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Senders) > 0 { + for _, b := range m.Senders { + l = len(b) + n += 1 + l + sovVm(uint64(l)) + } + } + if m.MaxGasAmount != 0 { + n += 1 + sovVm(uint64(m.MaxGasAmount)) + } + if m.GasUnitPrice != 0 { + n += 1 + sovVm(uint64(m.GasUnitPrice)) + } + if m.Block != 0 { + n += 1 + sovVm(uint64(m.Block)) + } + if m.Timestamp != 0 { + n += 1 + sovVm(uint64(m.Timestamp)) + } + l = len(m.Code) + if l > 0 { + n += 1 + l + sovVm(uint64(l)) + } + if len(m.TypeParams) > 0 { + for _, e := range m.TypeParams { + l = e.Size() + n += 1 + l + sovVm(uint64(l)) + } + } + if len(m.Args) > 0 { + for _, e := range m.Args { + l = e.Size() + n += 1 + l + sovVm(uint64(l)) + } + } + return n +} + +func (m *VMBalanceChange) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovVm(uint64(l)) + } + l = len(m.Ticker) + if l > 0 { + n += 1 + l + sovVm(uint64(l)) + } + if m.Op != nil { + n += m.Op.Size() + } + return n +} + +func (m *VMBalanceChange_Deposit) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Deposit != nil { + l = m.Deposit.Size() + n += 1 + l + sovVm(uint64(l)) + } + return n +} +func (m *VMBalanceChange_Withdraw) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Withdraw != nil { + l = m.Withdraw.Size() + n += 1 + l + sovVm(uint64(l)) + } + return n +} +func (m *VMBalanceChangeSet) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.ChangeSet) > 0 { + for _, e := range m.ChangeSet { + l = e.Size() + n += 1 + l + sovVm(uint64(l)) + } + } + return n +} + +func (m *VMExecuteResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.WriteSet) > 0 { + for _, e := range m.WriteSet { + l = e.Size() + n += 1 + l + sovVm(uint64(l)) + } + } + if len(m.Events) > 0 { + for _, e := range m.Events { + l = e.Size() + n += 1 + l + sovVm(uint64(l)) + } + } + if len(m.BalanceChangeSet) > 0 { + for _, e := range m.BalanceChangeSet { + l = e.Size() + n += 1 + l + sovVm(uint64(l)) + } + } + if m.GasUsed != 0 { + n += 1 + sovVm(uint64(m.GasUsed)) + } + if m.Status != nil { + l = m.Status.Size() + n += 1 + l + sovVm(uint64(l)) + } + return n +} + +func (m *MultipleCompilationResult) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Units) > 0 { + for _, e := range m.Units { + l = e.Size() + n += 1 + l + sovVm(uint64(l)) + } + } + if len(m.Errors) > 0 { + for _, s := range m.Errors { + l = len(s) + n += 1 + l + sovVm(uint64(l)) + } + } + return n +} + +func sovVm(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozVm(x uint64) (n int) { + return sovVm(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *AbortLocation) 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 ErrIntOverflowVm + } + 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: AbortLocation: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AbortLocation: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = append(m.Address[:0], dAtA[iNdEx:postIndex]...) + if m.Address == nil { + m.Address = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Module", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Module = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipVm(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthVm + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *FunctionLoc) 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 ErrIntOverflowVm + } + 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: FunctionLoc: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: FunctionLoc: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Function", wireType) + } + m.Function = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Function |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CodeOffset", wireType) + } + m.CodeOffset = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CodeOffset |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipVm(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthVm + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MoveError) 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 ErrIntOverflowVm + } + 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: MoveError: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MoveError: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field StatusCode", wireType) + } + m.StatusCode = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.StatusCode |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipVm(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthVm + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Abort) 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 ErrIntOverflowVm + } + 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: Abort: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Abort: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AbortLocation", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.AbortLocation == nil { + m.AbortLocation = &AbortLocation{} + } + if err := m.AbortLocation.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AbortCode", wireType) + } + m.AbortCode = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AbortCode |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipVm(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthVm + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Failure) 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 ErrIntOverflowVm + } + 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: Failure: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Failure: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field StatusCode", wireType) + } + m.StatusCode = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.StatusCode |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AbortLocation", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.AbortLocation == nil { + m.AbortLocation = &AbortLocation{} + } + if err := m.AbortLocation.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FunctionLoc", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.FunctionLoc == nil { + m.FunctionLoc = &FunctionLoc{} + } + if err := m.FunctionLoc.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipVm(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthVm + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Message) 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 ErrIntOverflowVm + } + 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: Message: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Message: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Text", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Text = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipVm(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthVm + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *VMStatus) 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 ErrIntOverflowVm + } + 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: VMStatus: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: VMStatus: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MoveError", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &MoveError{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Error = &VMStatus_MoveError{v} + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Abort", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &Abort{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Error = &VMStatus_Abort{v} + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ExecutionFailure", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &Failure{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Error = &VMStatus_ExecutionFailure{v} + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Message", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Message == nil { + m.Message = &Message{} + } + if err := m.Message.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipVm(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthVm + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *StructIdent) 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 ErrIntOverflowVm + } + 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: StructIdent: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StructIdent: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = append(m.Address[:0], dAtA[iNdEx:postIndex]...) + if m.Address == nil { + m.Address = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Module", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Module = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TypeParams", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TypeParams = append(m.TypeParams, &LcsTag{}) + if err := m.TypeParams[len(m.TypeParams)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipVm(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthVm + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *LcsTag) 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 ErrIntOverflowVm + } + 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: LcsTag: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: LcsTag: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TypeTag", wireType) + } + m.TypeTag = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TypeTag |= LcsType(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field VectorType", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.VectorType == nil { + m.VectorType = &LcsTag{} + } + if err := m.VectorType.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StructIdent", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.StructIdent == nil { + m.StructIdent = &StructIdent{} + } + if err := m.StructIdent.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipVm(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthVm + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ModuleIdent) 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 ErrIntOverflowVm + } + 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: ModuleIdent: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ModuleIdent: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = append(m.Address[:0], dAtA[iNdEx:postIndex]...) + if m.Address == nil { + m.Address = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipVm(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthVm + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *VMEvent) 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 ErrIntOverflowVm + } + 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: VMEvent: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: VMEvent: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SenderAddress", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SenderAddress = append(m.SenderAddress[:0], dAtA[iNdEx:postIndex]...) + if m.SenderAddress == nil { + m.SenderAddress = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SenderModule", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.SenderModule == nil { + m.SenderModule = &ModuleIdent{} + } + if err := m.SenderModule.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EventType", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.EventType == nil { + m.EventType = &LcsTag{} + } + if err := m.EventType.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EventData", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.EventData = append(m.EventData[:0], dAtA[iNdEx:postIndex]...) + if m.EventData == nil { + m.EventData = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipVm(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthVm + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *VMAccessPath) 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 ErrIntOverflowVm + } + 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: VMAccessPath: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: VMAccessPath: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = append(m.Address[:0], dAtA[iNdEx:postIndex]...) + if m.Address == nil { + m.Address = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Path", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Path = append(m.Path[:0], dAtA[iNdEx:postIndex]...) + if m.Path == nil { + m.Path = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipVm(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthVm + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *VMValue) 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 ErrIntOverflowVm + } + 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: VMValue: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: VMValue: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Value = append(m.Value[:0], dAtA[iNdEx:postIndex]...) + if m.Value == nil { + m.Value = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) + } + m.Type = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Type |= VmWriteOp(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Path", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Path == nil { + m.Path = &VMAccessPath{} + } + if err := m.Path.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipVm(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthVm + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *VMArgs) 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 ErrIntOverflowVm + } + 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: VMArgs: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: VMArgs: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) + } + m.Type = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Type |= VMTypeTag(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Value = append(m.Value[:0], dAtA[iNdEx:postIndex]...) + if m.Value == nil { + m.Value = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipVm(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthVm + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *VMPublishModule) 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 ErrIntOverflowVm + } + 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: VMPublishModule: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: VMPublishModule: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = append(m.Sender[:0], dAtA[iNdEx:postIndex]...) + if m.Sender == nil { + m.Sender = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxGasAmount", wireType) + } + m.MaxGasAmount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxGasAmount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GasUnitPrice", wireType) + } + m.GasUnitPrice = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GasUnitPrice |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Code", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Code = append(m.Code[:0], dAtA[iNdEx:postIndex]...) + if m.Code == nil { + m.Code = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipVm(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthVm + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *VMExecuteScript) 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 ErrIntOverflowVm + } + 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: VMExecuteScript: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: VMExecuteScript: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Senders", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Senders = append(m.Senders, make([]byte, postIndex-iNdEx)) + copy(m.Senders[len(m.Senders)-1], dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxGasAmount", wireType) + } + m.MaxGasAmount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxGasAmount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GasUnitPrice", wireType) + } + m.GasUnitPrice = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GasUnitPrice |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Block", wireType) + } + m.Block = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Block |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Timestamp", wireType) + } + m.Timestamp = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Timestamp |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Code", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Code = append(m.Code[:0], dAtA[iNdEx:postIndex]...) + if m.Code == nil { + m.Code = []byte{} + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TypeParams", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TypeParams = append(m.TypeParams, &StructIdent{}) + if err := m.TypeParams[len(m.TypeParams)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Args", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Args = append(m.Args, &VMArgs{}) + if err := m.Args[len(m.Args)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipVm(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthVm + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *VMBalanceChange) 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 ErrIntOverflowVm + } + 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: VMBalanceChange: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: VMBalanceChange: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = append(m.Address[:0], dAtA[iNdEx:postIndex]...) + if m.Address == nil { + m.Address = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Ticker", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Ticker = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Deposit", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &U128{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Op = &VMBalanceChange_Deposit{v} + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Withdraw", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &U128{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Op = &VMBalanceChange_Withdraw{v} + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipVm(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthVm + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *VMBalanceChangeSet) 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 ErrIntOverflowVm + } + 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: VMBalanceChangeSet: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: VMBalanceChangeSet: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChangeSet", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChangeSet = append(m.ChangeSet, &VMBalanceChange{}) + if err := m.ChangeSet[len(m.ChangeSet)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipVm(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthVm + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *VMExecuteResponse) 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 ErrIntOverflowVm + } + 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: VMExecuteResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: VMExecuteResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field WriteSet", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.WriteSet = append(m.WriteSet, &VMValue{}) + if err := m.WriteSet[len(m.WriteSet)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Events", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Events = append(m.Events, &VMEvent{}) + if err := m.Events[len(m.Events)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BalanceChangeSet", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BalanceChangeSet = append(m.BalanceChangeSet, &VMBalanceChange{}) + if err := m.BalanceChangeSet[len(m.BalanceChangeSet)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GasUsed", wireType) + } + m.GasUsed = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GasUsed |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Status == nil { + m.Status = &VMStatus{} + } + if err := m.Status.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipVm(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthVm + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MultipleCompilationResult) 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 ErrIntOverflowVm + } + 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: MultipleCompilationResult: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MultipleCompilationResult: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Units", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Units = append(m.Units, &CompiledUnit{}) + if err := m.Units[len(m.Units)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Errors", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Errors = append(m.Errors, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipVm(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthVm + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipVm(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowVm + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowVm + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowVm + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthVm + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupVm + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthVm + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthVm = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowVm = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupVm = fmt.Errorf("proto: unexpected end of group") +) diff --git a/proto/dfinance/dvm/common-types.proto b/proto/dfinance/dvm/common-types.proto new file mode 100644 index 0000000..0d2c789 --- /dev/null +++ b/proto/dfinance/dvm/common-types.proto @@ -0,0 +1,20 @@ +syntax = "proto3"; + +package dfinance.dvm; + +option go_package = "github.com/dfinance/dstation/pkg/types/dvm"; + +// Type of contract argument. +enum VMTypeTag { + Bool = 0; // Bool 0x0 - false, 0x1 - true. + U64 = 1; // Uint64. Little-endian unsigned 64 bits integer. + Vector = 2; // Vector of bytes. + Address = 3; // Address, in bech32 form. 20 bytes. + U8 = 4; // U8 + U128 = 5; // U128 Little-endian unsigned 128 bits integer. +} + +/// u128 type. +message u128 { + bytes buf = 1; // Little-endian unsigned 128. +} diff --git a/proto/dfinance/dvm/compiler.proto b/proto/dfinance/dvm/compiler.proto new file mode 100644 index 0000000..d39453c --- /dev/null +++ b/proto/dfinance/dvm/compiler.proto @@ -0,0 +1,33 @@ +syntax = "proto3"; + +package dfinance.dvm; + +option go_package = "github.com/dfinance/dstation/pkg/types/dvm"; + +// Compilation unit. +message CompilationUnit { + string text = 1; // utf8 encoded source code with libra/bech32 addresses + string name = 2; // name of the unit. +} + +// Compiler API +message SourceFiles { + repeated CompilationUnit units = 1; // Compilation units. + bytes address = 2; // address of the sender, in bech32 form +} + +// Compiled source. +message CompiledUnit { + string name = 1; // name of the module/script. + bytes bytecode = 2; // bytecode of the compiled module/script +} + +message CompilationResult { + repeated CompiledUnit units = 1; + repeated string errors = 2; // list of error messages, empty if successful +} + +service DvmCompiler { + rpc Compile (SourceFiles) returns (CompilationResult) { + } +} \ No newline at end of file diff --git a/proto/dfinance/dvm/data-source.proto b/proto/dfinance/dvm/data-source.proto new file mode 100644 index 0000000..d324636 --- /dev/null +++ b/proto/dfinance/dvm/data-source.proto @@ -0,0 +1,82 @@ +syntax = "proto3"; + +package dfinance.dvm; + +import "dfinance/dvm/common-types.proto"; + +option go_package = "github.com/dfinance/dstation/pkg/types/dvm"; + +message DSAccessPath { + bytes address = 1; // AccountAddress + bytes path = 2; +} + +enum ErrorCode { + NONE = 0; // no error + BAD_REQUEST = 1; // crash of compilation, logs will show stacktrace + NO_DATA = 2; // no such module +} + +message DSRawResponse { + bytes blob = 1; + ErrorCode error_code = 2; + string error_message = 3; // error message from libra, empty if ErrorCode::None +} + + +message DSAccessPaths { + repeated DSAccessPath paths = 1; +} + +message DSRawResponses { + repeated bytes blobs = 1; +} + +message OraclePriceRequest { + string currency_1 = 1; + string currency_2 = 2; +} + +message OraclePriceResponse { + dvm.u128 price = 1; + ErrorCode error_code = 2; + string error_message = 3; // error message from libra, empty if ErrorCode::None +} + +message NativeBalanceRequest { + bytes address = 1; + string ticker = 2; +} + +message NativeBalanceResponse { + dvm.u128 balance = 1; + ErrorCode error_code = 2; + string error_message = 3; // error message from libra, empty if ErrorCode::None +} + +message CurrencyInfoRequest { + string ticker = 2; +} + +message CurrencyInfo { + bytes denom = 1; + uint32 decimals = 2; + bool is_token = 3; + bytes address = 4; + dvm.u128 total_supply = 5; +} + +message CurrencyInfoResponse { + CurrencyInfo info = 1; + ErrorCode error_code = 2; + string error_message = 3; // error message from libra, empty if ErrorCode::None +} + +// GRPC service +service DSService { + rpc GetRaw (DSAccessPath) returns (DSRawResponse) {} + rpc MultiGetRaw (DSAccessPaths) returns (DSRawResponses) {} + rpc GetOraclePrice (OraclePriceRequest) returns (OraclePriceResponse) {} + rpc GetNativeBalance (NativeBalanceRequest) returns (NativeBalanceResponse) {} + rpc GetCurrencyInfo (CurrencyInfoRequest) returns (CurrencyInfoResponse) {} +} diff --git a/proto/dfinance/dvm/metadata.proto b/proto/dfinance/dvm/metadata.proto new file mode 100644 index 0000000..c17b06e --- /dev/null +++ b/proto/dfinance/dvm/metadata.proto @@ -0,0 +1,66 @@ +syntax = "proto3"; + +package dfinance.dvm; + +import "dfinance/dvm/common-types.proto"; + +option go_package = "github.com/dfinance/dstation/pkg/types/dvm"; + +// Bytecode. +message Bytecode { + bytes code = 1; // bytecode of script +} + +// Struct field. +message Field { + string name = 1; + string type = 2; +} + +/// Struct representation. +message Struct { + string name = 1; + bool isResource = 2; + repeated string type_parameters = 3; + repeated Field field = 4; +} + +/// Function representation. +message Function { + string name = 1; + bool isPublic = 2; + bool isNative = 3; + repeated string type_parameters = 4; + repeated string arguments = 5; + repeated string returns = 6; +} + +// Script metadata. +message ScriptMeta { + uint32 signers_count = 1; + repeated string type_parameters = 2; + repeated dvm.VMTypeTag arguments = 3; +} + +// Module metadata. +message ModuleMeta { + string name = 1; // module name. + repeated Struct types = 2; // Types defined in a module. + repeated Function functions = 3; // Functions defined in a module. +} + +// Bytecode metadata. +message Metadata { + oneof meta { + // In case the provided bytecode is a script. + ScriptMeta script = 1; + // In case the provided bytecode is a module. + ModuleMeta module = 2; + } +} + +// Returns bytecode metadata. +service DVMBytecodeMetadata { + rpc GetMetadata (Bytecode) returns (Metadata) { + } +} \ No newline at end of file diff --git a/proto/dfinance/dvm/vm.proto b/proto/dfinance/dvm/vm.proto new file mode 100644 index 0000000..b9317f1 --- /dev/null +++ b/proto/dfinance/dvm/vm.proto @@ -0,0 +1,197 @@ +syntax = "proto3"; + +package dfinance.dvm; + +import "dfinance/dvm/common-types.proto"; +import "dfinance/dvm/compiler.proto"; + +option go_package = "github.com/dfinance/dstation/pkg/types/dvm"; + +// An `AbortLocation` specifies where a Move program `abort` occurred, either in a function in +// a module, or in a script. +message AbortLocation { + bytes address = 1; // Indicates `abort` occurred in the specified module. + string module = 2; // Indicates the `abort` occurred in a script. +} + +// Function location. +message FunctionLoc { + uint64 function = 1; // Function index. + uint64 code_offset = 2; // Code offset. + +} + +// VmStatus `Error` case. +message MoveError { + // Status code. + uint64 status_code = 2; +} + +// VmStatus `MoveAbort` case. +message Abort { + // Abort location. (optional). Null if abort occurred in the script. + AbortLocation abort_location = 1; + // Abort code. + uint64 abort_code = 2; +} + +// VmStatus `ExecutionFailure` case. +message Failure { + // Status code. + uint64 status_code = 1; + // Abort location. (optional). Null if abort occurred in the script. + AbortLocation abort_location = 2; + // Function location. + FunctionLoc function_loc = 3; +} + +/// Message. +message Message { + // Message with error details if needed. + string text = 1; +} + +// A `VMStatus` is represented as either +// - `Null` indicating successful execution. +// - `Error` indicating an error from the VM itself. +// - `MoveAbort` indicating an `abort` ocurred inside of a Move program +// - `ExecutionFailure` indicating an runtime error. +message VMStatus { + oneof error { + // Indicates an error from the VM, e.g. OUT_OF_GAS, INVALID_AUTH_KEY, RET_TYPE_MISMATCH_ERROR + // etc. + // The code will neither EXECUTED nor ABORTED + MoveError move_error = 1; + // Indicates an error from the VM, e.g. OUT_OF_GAS, INVALID_AUTH_KEY, RET_TYPE_MISMATCH_ERROR + // etc. + // The code will neither EXECUTED nor ABORTED + Abort abort = 2; + // Indicates an failure from inside Move code, where the VM could not continue exection, e.g. + // dividing by zero or a missing resource + Failure execution_failure = 3; + } + // Message with error details if needed (optional). + Message message = 4; +} + +/// Full name of the structure. +message StructIdent { + bytes address = 1; // address of module owner + string module = 2; // module name. + string name = 3; // name of structure. + repeated LcsTag type_params = 4; // Structure type parameters. +} + +enum LcsType { + LcsBool = 0; // Bool + LcsU64 = 1; // Uint64 + LcsVector = 2; // Vector of bytes. + LcsAddress = 3; // Address, in bech32 form + LcsU8 = 4; // U8 + LcsU128 = 5; // U128 + LcsSigner = 6; // Signer. + LcsStruct = 7; // Struct. +} + +message LcsTag { + LcsType type_tag = 1; // type tag. + LcsTag vector_type = 2; // vector type. Has a non-null value if the type_tag is equal to a LcsVector. + StructIdent struct_ident = 3; // struct identifier. Has a non-null value if the type_tag is equal to a LcsStruct. +} + +/// Module identifier. +message ModuleIdent { + bytes address = 1; // module address. + string name = 2; // module name. +} + +// VM event returns after contract execution. +message VMEvent { + bytes sender_address = 1; // Event sender address. + ModuleIdent sender_module = 2; // sender module. + LcsTag event_type = 3; // Type of value inside event. + bytes event_data = 4; // Event data in bytes to parse. +} + +// Write set operation type. +enum VmWriteOp { + Value = 0; // Insert or update value + Deletion = 1; // Delete. +} + +// Storage path +message VMAccessPath { + bytes address = 1; // account address. + bytes path = 2; // storage path. +} + +// VM value should be passed before execution and return after execution (with opcodes), write_set in nutshell. +message VMValue { + VmWriteOp type = 2; // Type of operation + bytes value = 1; // Value returns from vm. + VMAccessPath path = 3; // Access path. +} + +// Contract arguments. +message VMArgs { + dvm.VMTypeTag type = 1; // Argument type. + bytes value = 2; // Argument value. +} + +// Publish module. +message VMPublishModule { + bytes sender = 1; // owner of contract. + uint64 max_gas_amount = 2; // maximal total gas specified by wallet to spend for this transaction. + uint64 gas_unit_price = 3; // maximal price can be paid per gas. + bytes code = 4; // compiled contract code. +} + +// VM contract object to process. +message VMExecuteScript { + repeated bytes senders = 1; // owners of contract. + uint64 max_gas_amount = 2; // maximal total gas specified by wallet to spend for this transaction. + uint64 gas_unit_price = 3; // maximal price can be paid per gas. + uint64 block = 4; // block. + uint64 timestamp = 5; // timestamp. + bytes code = 6; // compiled contract code. + repeated StructIdent type_params = 7; // type parameters. + repeated VMArgs args = 8; // Contract arguments. +} + +message VMBalanceChange { + bytes address = 1; + string ticker = 2; + oneof op { + dvm.u128 deposit = 3; + dvm.u128 withdraw = 4; + } +} + +message VMBalanceChangeSet { + repeated VMBalanceChange change_set = 1; +} + +// Response from VM contains write_set, events, gas used and status for specific contract. +message VMExecuteResponse { + repeated VMValue write_set = 1; // using string instead of bytes for now, as map support only ints and strings as keys + repeated VMEvent events = 2; // list of events executed during contract execution + repeated VMBalanceChange balance_change_set = 3; // list of native balance updates. + uint64 gas_used = 4; // Gas used during execution. + VMStatus status = 5; // Main status of execution, might contain an error. +} + +// GRPC service +service VMModulePublisher { + rpc PublishModule (VMPublishModule) returns (VMExecuteResponse) { + } +} + +service VMScriptExecutor { + rpc ExecuteScript (VMExecuteScript) returns (VMExecuteResponse) { + } +} + +message MultipleCompilationResult { + repeated dvm.CompiledUnit units = 1; + repeated string errors = 2; // list of error messages, empty if successful +} diff --git a/proto/dfinance/vm/genesis.proto b/proto/dfinance/vm/genesis.proto new file mode 100644 index 0000000..c74aeed --- /dev/null +++ b/proto/dfinance/vm/genesis.proto @@ -0,0 +1,42 @@ +syntax = "proto3"; +package dfinance.vm.v1beta1; + +import "google/protobuf/any.proto"; +import "google/protobuf/timestamp.proto"; +import "gogoproto/gogo.proto"; + +import "cosmos_proto/cosmos.proto"; +import "cosmos/base/v1beta1/coin.proto"; + +option go_package = "github.com/dfinance/dstation/x/vm/types"; + +message GenesisState { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + message WriteOp { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = false; + + // Move address (HEX string) + string address = 1 [ + (gogoproto.moretags) = "yaml:\"address\"" + ]; + + // Move module path (HEX string) + string path = 2 [ + (gogoproto.moretags) = "yaml:\"path\"" + ]; + + // Module code (HEX string) + string value = 3 [ + (gogoproto.moretags) = "yaml:\"value\"" + ]; + } + + repeated WriteOp write_set = 1 [ + (gogoproto.moretags) = "yaml:\"write_set\"", + (gogoproto.nullable) = false + ]; +} diff --git a/proto/dfinance/vm/gov.proto b/proto/dfinance/vm/gov.proto new file mode 100644 index 0000000..3da487c --- /dev/null +++ b/proto/dfinance/vm/gov.proto @@ -0,0 +1,45 @@ +syntax = "proto3"; +package dfinance.vm.v1beta1; + +import "gogoproto/gogo.proto"; +import "google/protobuf/any.proto"; +import "cosmos_proto/cosmos.proto"; + +option go_package = "github.com/dfinance/dstation/x/vm/types"; + +// PlannedProposal defines VM Gov proposal with apply schedule and wrapped proposal content. +message PlannedProposal { + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = false; + + // Height is a block height proposal should be applied at + int64 height = 1 [ + (gogoproto.moretags) = "yaml:\"height\"" + ]; + + // Content is a Gov proposal content + google.protobuf.Any content = 2 [ + (gogoproto.moretags) = "yaml:\"content\"", + (cosmos_proto.accepts_interface) = "Content" + ]; +} + +message StdLibUpdateProposal { + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = false; + + // Url contains Stdlib update source code + string url = 2 [ + (gogoproto.moretags) = "yaml:\"url\"" + ]; + + // UpdateDescription contains some update description + string update_description = 3 [ + (gogoproto.moretags) = "yaml:\"update_description\"" + ]; + + // Code is a DVM byteCode of updated modules + repeated bytes code = 4 [ + (gogoproto.moretags) = "yaml:\"code\"" + ]; +} \ No newline at end of file diff --git a/proto/dfinance/vm/query.proto b/proto/dfinance/vm/query.proto new file mode 100644 index 0000000..7bcda09 --- /dev/null +++ b/proto/dfinance/vm/query.proto @@ -0,0 +1,103 @@ +syntax = "proto3"; +package dfinance.vm.v1beta1; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; + +import "cosmos/base/abci/v1beta1/abci.proto"; +import "cosmos/base/v1beta1/coin.proto"; + +import "dfinance/vm/vm.proto"; +import "dfinance/dvm/metadata.proto"; + +option go_package = "github.com/dfinance/dstation/x/vm/types"; + +// Query defines the gRPC querier service. +service Query { + // Data queries VMStorage value + rpc Data(QueryDataRequest) returns (QueryDataResponse) { + option (google.api.http).get = "/dfinance/vm/v1beta1/data"; + } + + // TxVmStatus queries VM status for Tx + rpc TxVmStatus(QueryTxVmStatusRequest) returns (QueryTxVmStatusResponse) { + option (google.api.http).get = "/dfinance/vm/v1beta1/tx_vm_status"; + } + + // Compile compiles provided Move code and returns byte code. + rpc Compile(QueryCompileRequest) returns (QueryCompileResponse) { + option (google.api.http).get = "/dfinance/vm/v1beta1/compile"; + } + + // Metadata queries VM for byteCode metadata (metadata.proto/GetMetadata RPC wrapper). + rpc Metadata(QueryMetadataRequest) returns (QueryMetadataResponse); + + // DelegatedPoolSupply queries Delegated pool module balance. + rpc DelegatedPoolSupply(QueryDelegatedPoolSupplyRequest) returns (QueryDelegatedPoolSupplyResponse); +} + +// QueryDataRequest is request type for Query/Data RPC method. +message QueryDataRequest { + // VM address (Libra address) + bytes address = 1; + // VM path + bytes path = 2; +} + +// QueryDataResponse is response type for Query/Data RPC method. +message QueryDataResponse { + // VMStorage value for address:path pair + bytes value = 1; +} + +// QueryTxVmStatusRequest is request type for Query/TxVmStatus RPC method. +message QueryTxVmStatusRequest { + // Tx meta received from /cosmos/tx/v1beta1/txs/{hash} + cosmos.base.abci.v1beta1.TxResponse tx_meta = 1 [ + (gogoproto.nullable) = false + ]; +} + +// QueryTxVmStatusResponse is response type for Query/TxVmStatus RPC method. +message QueryTxVmStatusResponse { + TxVmStatus vm_status = 1 [ + (gogoproto.nullable) = false + ]; +} + +// QueryCompileRequest is request type for Query/Compile RPC method. +message QueryCompileRequest { + // VM address (Libra address) + bytes address = 1; + // Move code [Plain text] + string code = 2; +} + +// QueryCompileResponse is response type for Query/Compile RPC method. +message QueryCompileResponse { + // Compiled items + repeated CompiledItem compiled_items = 1 [ + (gogoproto.nullable) = false + ]; +} + +// QueryMetadataRequest is request type for Query/Metadata RPC method. +message QueryMetadataRequest { + bytes code = 1; +} + +// QueryMetadataResponse is response type for Query/Metadata RPC method. +message QueryMetadataResponse { + dvm.Metadata metadata = 1; +} + +// QueryDelegatedPoolSupplyRequest is request type for Query/DelegatedPoolSupply RPC method. +message QueryDelegatedPoolSupplyRequest {} + +// QueryDelegatedPoolSupplyResponse is response type for Query/DelegatedPoolSupply RPC method. +message QueryDelegatedPoolSupplyResponse { + repeated cosmos.base.v1beta1.Coin coins = 1 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; +} \ No newline at end of file diff --git a/proto/dfinance/vm/tx.proto b/proto/dfinance/vm/tx.proto new file mode 100644 index 0000000..7116066 --- /dev/null +++ b/proto/dfinance/vm/tx.proto @@ -0,0 +1,24 @@ +syntax = "proto3"; +package dfinance.vm.v1beta1; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; + +import "cosmos/base/abci/v1beta1/abci.proto"; + +import "dfinance/vm/vm.proto"; + +option go_package = "github.com/dfinance/dstation/x/vm/types"; + +// Msg defines the VM module Msg service. +service Msg { + // DeployModule deploys Move module/modules to VMStorage. + rpc DeployModule(MsgDeployModule) returns (MsgDeployModuleResponse); + + // ExecuteScript executes provided Move script. + rpc ExecuteScript(MsgExecuteScript) returns (MsgExecuteScriptResponse); +} + +message MsgDeployModuleResponse {} + +message MsgExecuteScriptResponse {} diff --git a/proto/dfinance/vm/vm.proto b/proto/dfinance/vm/vm.proto new file mode 100644 index 0000000..a634e1e --- /dev/null +++ b/proto/dfinance/vm/vm.proto @@ -0,0 +1,126 @@ +syntax = "proto3"; +package dfinance.vm.v1beta1; + +import "google/protobuf/any.proto"; +import "google/protobuf/timestamp.proto"; +import "gogoproto/gogo.proto"; + +import "cosmos_proto/cosmos.proto"; + +import "dfinance/dvm/common-types.proto"; +import "dfinance/dvm/metadata.proto"; + +option go_package = "github.com/dfinance/dstation/x/vm/types"; + +// MsgExecuteScript defines a SDK message to execute a script with args to VM. +message MsgExecuteScript { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + message ScriptArg { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + dvm.VMTypeTag type = 1 [ + (gogoproto.moretags) = "yaml:\"type\"" + ]; + bytes value = 2 [ + (gogoproto.moretags) = "yaml:\"value\"" + ]; + } + + // Script sender address + string signer = 1 [ + (gogoproto.moretags) = "yaml:\"signer\"" + ]; + + // Script code + bytes script = 2 [ + (gogoproto.moretags) = "yaml:\"script\"" + ]; + + repeated ScriptArg args = 3 [ + (gogoproto.moretags) = "yaml:\"args\"", + (gogoproto.nullable) = false + ]; +} + +// MsgDeployModule defines a SDK message to deploy a module (contract) to VM. +message MsgDeployModule { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // Script sender address + string signer = 1 [ + (gogoproto.moretags) = "yaml:\"signer\"" + ]; + + // Module code + repeated bytes modules = 2 [ + (gogoproto.moretags) = "yaml:\"modules\"" + ]; +} + +// TxVmStatus keeps VM statuses and errors for Tx. +message TxVmStatus { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = false; + + // Tx hash [HEX string] + string hash = 1 [ + (gogoproto.moretags) = "yaml:\"hash\"" + ]; + + // VM statuses for the Tx + repeated VmStatus vm_statuses = 2 [ + (gogoproto.moretags) = "yaml:\"vm_statuses\"", + (gogoproto.nullable) = false + ]; +} + +// VmStatus is a VM error response. +message VmStatus { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = false; + + // Error Status: error / discard + string status = 1 [ + (gogoproto.moretags) = "yaml:\"status\"" + ]; + + // Major code + string major_code = 2 [ + (gogoproto.moretags) = "yaml:\"major_code\"" + ]; + + // Sub code + string sub_code = 3 [ + (gogoproto.moretags) = "yaml:\"sub_code\"" + ]; + + // Detailed explanation of major code + string str_code = 4 [ + (gogoproto.moretags) = "yaml:\"str_code\"" + ]; + + // Error message + string message = 5 [ + (gogoproto.moretags) = "yaml:\"message\"" + ]; +} + +// CompiledItem contains VM compilation result. +message CompiledItem { + enum CodeType { + MODULE = 0; + SCRIPT = 1; + } + + bytes byte_code = 1; + string name = 2; + repeated dvm.Function methods = 3; + repeated dvm.Struct types = 4; + CodeType code_type = 5; +} diff --git a/third_party/proto/cosmos/auth/v1beta1/auth.proto b/third_party/proto/cosmos/auth/v1beta1/auth.proto new file mode 100644 index 0000000..72e1d9e --- /dev/null +++ b/third_party/proto/cosmos/auth/v1beta1/auth.proto @@ -0,0 +1,50 @@ +syntax = "proto3"; +package cosmos.auth.v1beta1; + +import "cosmos_proto/cosmos.proto"; +import "gogoproto/gogo.proto"; +import "google/protobuf/any.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/auth/types"; + +// BaseAccount defines a base account type. It contains all the necessary fields +// for basic account functionality. Any custom account type should extend this +// type for additional functionality (e.g. vesting). +message BaseAccount { + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = false; + option (gogoproto.equal) = false; + + option (cosmos_proto.implements_interface) = "AccountI"; + + string address = 1; + google.protobuf.Any pub_key = 2 + [(gogoproto.jsontag) = "public_key,omitempty", (gogoproto.moretags) = "yaml:\"public_key\""]; + uint64 account_number = 3 [(gogoproto.moretags) = "yaml:\"account_number\""]; + uint64 sequence = 4; +} + +// ModuleAccount defines an account for modules that holds coins on a pool. +message ModuleAccount { + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = false; + option (cosmos_proto.implements_interface) = "ModuleAccountI"; + + BaseAccount base_account = 1 [(gogoproto.embed) = true, (gogoproto.moretags) = "yaml:\"base_account\""]; + string name = 2; + repeated string permissions = 3; +} + +// Params defines the parameters for the auth module. +message Params { + option (gogoproto.equal) = true; + option (gogoproto.goproto_stringer) = false; + + uint64 max_memo_characters = 1 [(gogoproto.moretags) = "yaml:\"max_memo_characters\""]; + uint64 tx_sig_limit = 2 [(gogoproto.moretags) = "yaml:\"tx_sig_limit\""]; + uint64 tx_size_cost_per_byte = 3 [(gogoproto.moretags) = "yaml:\"tx_size_cost_per_byte\""]; + uint64 sig_verify_cost_ed25519 = 4 + [(gogoproto.customname) = "SigVerifyCostED25519", (gogoproto.moretags) = "yaml:\"sig_verify_cost_ed25519\""]; + uint64 sig_verify_cost_secp256k1 = 5 + [(gogoproto.customname) = "SigVerifyCostSecp256k1", (gogoproto.moretags) = "yaml:\"sig_verify_cost_secp256k1\""]; +} diff --git a/third_party/proto/cosmos/auth/v1beta1/genesis.proto b/third_party/proto/cosmos/auth/v1beta1/genesis.proto new file mode 100644 index 0000000..c88b94e --- /dev/null +++ b/third_party/proto/cosmos/auth/v1beta1/genesis.proto @@ -0,0 +1,17 @@ +syntax = "proto3"; +package cosmos.auth.v1beta1; + +import "google/protobuf/any.proto"; +import "gogoproto/gogo.proto"; +import "cosmos/auth/v1beta1/auth.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/auth/types"; + +// GenesisState defines the auth module's genesis state. +message GenesisState { + // params defines all the paramaters of the module. + Params params = 1 [(gogoproto.nullable) = false]; + + // accounts are the accounts present at genesis. + repeated google.protobuf.Any accounts = 2; +} diff --git a/third_party/proto/cosmos/auth/v1beta1/query.proto b/third_party/proto/cosmos/auth/v1beta1/query.proto new file mode 100644 index 0000000..a885792 --- /dev/null +++ b/third_party/proto/cosmos/auth/v1beta1/query.proto @@ -0,0 +1,47 @@ +syntax = "proto3"; +package cosmos.auth.v1beta1; + +import "gogoproto/gogo.proto"; +import "google/protobuf/any.proto"; +import "google/api/annotations.proto"; +import "cosmos/auth/v1beta1/auth.proto"; +import "cosmos_proto/cosmos.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/auth/types"; + +// Query defines the gRPC querier service. +service Query { + // Account returns account details based on address. + rpc Account(QueryAccountRequest) returns (QueryAccountResponse) { + option (google.api.http).get = "/cosmos/auth/v1beta1/accounts/{address}"; + } + + // Params queries all parameters. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/cosmos/auth/v1beta1/params"; + } +} + +// QueryAccountRequest is the request type for the Query/Account RPC method. +message QueryAccountRequest { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // address defines the address to query for. + string address = 1; +} + +// QueryAccountResponse is the response type for the Query/Account RPC method. +message QueryAccountResponse { + // account defines the account of the corresponding address. + google.protobuf.Any account = 1 [(cosmos_proto.accepts_interface) = "AccountI"]; +} + +// QueryParamsRequest is the request type for the Query/Params RPC method. +message QueryParamsRequest {} + +// QueryParamsResponse is the response type for the Query/Params RPC method. +message QueryParamsResponse { + // params defines the parameters of the module. + Params params = 1 [(gogoproto.nullable) = false]; +} diff --git a/third_party/proto/cosmos/bank/v1beta1/bank.proto b/third_party/proto/cosmos/bank/v1beta1/bank.proto new file mode 100644 index 0000000..5a93833 --- /dev/null +++ b/third_party/proto/cosmos/bank/v1beta1/bank.proto @@ -0,0 +1,85 @@ +syntax = "proto3"; +package cosmos.bank.v1beta1; + +import "gogoproto/gogo.proto"; +import "cosmos_proto/cosmos.proto"; +import "cosmos/base/v1beta1/coin.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/bank/types"; + +// Params defines the parameters for the bank module. +message Params { + option (gogoproto.goproto_stringer) = false; + repeated SendEnabled send_enabled = 1 [(gogoproto.moretags) = "yaml:\"send_enabled,omitempty\""]; + bool default_send_enabled = 2 [(gogoproto.moretags) = "yaml:\"default_send_enabled,omitempty\""]; +} + +// SendEnabled maps coin denom to a send_enabled status (whether a denom is +// sendable). +message SendEnabled { + option (gogoproto.equal) = true; + option (gogoproto.goproto_stringer) = false; + string denom = 1; + bool enabled = 2; +} + +// Input models transaction input. +message Input { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string address = 1; + repeated cosmos.base.v1beta1.Coin coins = 2 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; +} + +// Output models transaction outputs. +message Output { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string address = 1; + repeated cosmos.base.v1beta1.Coin coins = 2 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; +} + +// Supply represents a struct that passively keeps track of the total supply +// amounts in the network. +message Supply { + option (gogoproto.equal) = true; + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = false; + + option (cosmos_proto.implements_interface) = "*github.com/cosmos/cosmos-sdk/x/bank/exported.SupplyI"; + + repeated cosmos.base.v1beta1.Coin total = 1 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; +} + +// DenomUnit represents a struct that describes a given +// denomination unit of the basic token. +message DenomUnit { + // denom represents the string name of the given denom unit (e.g uatom). + string denom = 1; + // exponent represents power of 10 exponent that one must + // raise the base_denom to in order to equal the given DenomUnit's denom + // 1 denom = 1^exponent base_denom + // (e.g. with a base_denom of uatom, one can create a DenomUnit of 'atom' with + // exponent = 6, thus: 1 atom = 10^6 uatom). + uint32 exponent = 2; + // aliases is a list of string aliases for the given denom + repeated string aliases = 3; +} + +// Metadata represents a struct that describes +// a basic token. +message Metadata { + string description = 1; + // denom_units represents the list of DenomUnit's for a given coin + repeated DenomUnit denom_units = 2; + // base represents the base denom (should be the DenomUnit with exponent = 0). + string base = 3; + // display indicates the suggested denom that should be + // displayed in clients. + string display = 4; +} diff --git a/third_party/proto/cosmos/bank/v1beta1/genesis.proto b/third_party/proto/cosmos/bank/v1beta1/genesis.proto new file mode 100644 index 0000000..25c80a3 --- /dev/null +++ b/third_party/proto/cosmos/bank/v1beta1/genesis.proto @@ -0,0 +1,38 @@ +syntax = "proto3"; +package cosmos.bank.v1beta1; + +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; +import "cosmos/bank/v1beta1/bank.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/bank/types"; + +// GenesisState defines the bank module's genesis state. +message GenesisState { + // params defines all the paramaters of the module. + Params params = 1 [(gogoproto.nullable) = false]; + + // balances is an array containing the balances of all the accounts. + repeated Balance balances = 2 [(gogoproto.nullable) = false]; + + // supply represents the total supply. + repeated cosmos.base.v1beta1.Coin supply = 3 + [(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", (gogoproto.nullable) = false]; + + // denom_metadata defines the metadata of the differents coins. + repeated Metadata denom_metadata = 4 [(gogoproto.moretags) = "yaml:\"denom_metadata\"", (gogoproto.nullable) = false]; +} + +// Balance defines an account address and balance pair used in the bank module's +// genesis state. +message Balance { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // address is the address of the balance holder. + string address = 1; + + // coins defines the different coins this balance holds. + repeated cosmos.base.v1beta1.Coin coins = 2 + [(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", (gogoproto.nullable) = false]; +} diff --git a/third_party/proto/cosmos/bank/v1beta1/query.proto b/third_party/proto/cosmos/bank/v1beta1/query.proto new file mode 100644 index 0000000..bc5e291 --- /dev/null +++ b/third_party/proto/cosmos/bank/v1beta1/query.proto @@ -0,0 +1,150 @@ +syntax = "proto3"; +package cosmos.bank.v1beta1; + +import "cosmos/base/query/v1beta1/pagination.proto"; +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "cosmos/base/v1beta1/coin.proto"; +import "cosmos/bank/v1beta1/bank.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/bank/types"; + +// Query defines the gRPC querier service. +service Query { + // Balance queries the balance of a single coin for a single account. + rpc Balance(QueryBalanceRequest) returns (QueryBalanceResponse) { + option (google.api.http).get = "/cosmos/bank/v1beta1/balances/{address}/{denom}"; + } + + // AllBalances queries the balance of all coins for a single account. + rpc AllBalances(QueryAllBalancesRequest) returns (QueryAllBalancesResponse) { + option (google.api.http).get = "/cosmos/bank/v1beta1/balances/{address}"; + } + + // TotalSupply queries the total supply of all coins. + rpc TotalSupply(QueryTotalSupplyRequest) returns (QueryTotalSupplyResponse) { + option (google.api.http).get = "/cosmos/bank/v1beta1/supply"; + } + + // SupplyOf queries the supply of a single coin. + rpc SupplyOf(QuerySupplyOfRequest) returns (QuerySupplyOfResponse) { + option (google.api.http).get = "/cosmos/bank/v1beta1/supply/{denom}"; + } + + // Params queries the parameters of x/bank module. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/cosmos/bank/v1beta1/params"; + } + + // DenomsMetadata queries the client metadata of a given coin denomination. + rpc DenomMetadata(QueryDenomMetadataRequest) returns (QueryDenomMetadataResponse) { + option (google.api.http).get = "/cosmos/bank/v1beta1/denoms_metadata/{denom}"; + } + + // DenomsMetadata queries the client metadata for all registered coin denominations. + rpc DenomsMetadata(QueryDenomsMetadataRequest) returns (QueryDenomsMetadataResponse) { + option (google.api.http).get = "/cosmos/bank/v1beta1/denoms_metadata"; + } +} + +// QueryBalanceRequest is the request type for the Query/Balance RPC method. +message QueryBalanceRequest { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // address is the address to query balances for. + string address = 1; + + // denom is the coin denom to query balances for. + string denom = 2; +} + +// QueryBalanceResponse is the response type for the Query/Balance RPC method. +message QueryBalanceResponse { + // balance is the balance of the coin. + cosmos.base.v1beta1.Coin balance = 1; +} + +// QueryBalanceRequest is the request type for the Query/AllBalances RPC method. +message QueryAllBalancesRequest { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // address is the address to query balances for. + string address = 1; + + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// QueryAllBalancesResponse is the response type for the Query/AllBalances RPC +// method. +message QueryAllBalancesResponse { + // balances is the balances of all the coins. + repeated cosmos.base.v1beta1.Coin balances = 1 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryTotalSupplyRequest is the request type for the Query/TotalSupply RPC +// method. +message QueryTotalSupplyRequest {} + +// QueryTotalSupplyResponse is the response type for the Query/TotalSupply RPC +// method +message QueryTotalSupplyResponse { + // supply is the supply of the coins + repeated cosmos.base.v1beta1.Coin supply = 1 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; +} + +// QuerySupplyOfRequest is the request type for the Query/SupplyOf RPC method. +message QuerySupplyOfRequest { + // denom is the coin denom to query balances for. + string denom = 1; +} + +// QuerySupplyOfResponse is the response type for the Query/SupplyOf RPC method. +message QuerySupplyOfResponse { + // amount is the supply of the coin. + cosmos.base.v1beta1.Coin amount = 1 [(gogoproto.nullable) = false]; +} + +// QueryParamsRequest defines the request type for querying x/bank parameters. +message QueryParamsRequest {} + +// QueryParamsResponse defines the response type for querying x/bank parameters. +message QueryParamsResponse { + Params params = 1 [(gogoproto.nullable) = false]; +} + +// QueryDenomsMetadataRequest is the request type for the Query/DenomsMetadata RPC method. +message QueryDenomsMetadataRequest { + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 1; +} + +// QueryDenomsMetadataResponse is the response type for the Query/DenomsMetadata RPC +// method. +message QueryDenomsMetadataResponse { + // metadata provides the client information for all the registered tokens. + repeated Metadata metadatas = 1 [(gogoproto.nullable) = false]; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryDenomMetadataRequest is the request type for the Query/DenomMetadata RPC method. +message QueryDenomMetadataRequest { + // denom is the coin denom to query the metadata for. + string denom = 1; +} + +// QueryDenomMetadataResponse is the response type for the Query/DenomMetadata RPC +// method. +message QueryDenomMetadataResponse { + // metadata describes and provides all the client information for the requested token. + Metadata metadata = 1 [(gogoproto.nullable) = false]; +} diff --git a/third_party/proto/cosmos/bank/v1beta1/tx.proto b/third_party/proto/cosmos/bank/v1beta1/tx.proto new file mode 100644 index 0000000..26b2ab4 --- /dev/null +++ b/third_party/proto/cosmos/bank/v1beta1/tx.proto @@ -0,0 +1,42 @@ +syntax = "proto3"; +package cosmos.bank.v1beta1; + +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; +import "cosmos/bank/v1beta1/bank.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/bank/types"; + +// Msg defines the bank Msg service. +service Msg { + // Send defines a method for sending coins from one account to another account. + rpc Send(MsgSend) returns (MsgSendResponse); + + // MultiSend defines a method for sending coins from some accounts to other accounts. + rpc MultiSend(MsgMultiSend) returns (MsgMultiSendResponse); +} + +// MsgSend represents a message to send coins from one account to another. +message MsgSend { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string from_address = 1 [(gogoproto.moretags) = "yaml:\"from_address\""]; + string to_address = 2 [(gogoproto.moretags) = "yaml:\"to_address\""]; + repeated cosmos.base.v1beta1.Coin amount = 3 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; +} + +// MsgSendResponse defines the Msg/Send response type. +message MsgSendResponse {} + +// MsgMultiSend represents an arbitrary multi-in, multi-out send message. +message MsgMultiSend { + option (gogoproto.equal) = false; + + repeated Input inputs = 1 [(gogoproto.nullable) = false]; + repeated Output outputs = 2 [(gogoproto.nullable) = false]; +} + +// MsgMultiSendResponse defines the Msg/MultiSend response type. +message MsgMultiSendResponse {} diff --git a/third_party/proto/cosmos/base/abci/v1beta1/abci.proto b/third_party/proto/cosmos/base/abci/v1beta1/abci.proto new file mode 100644 index 0000000..72da2aa --- /dev/null +++ b/third_party/proto/cosmos/base/abci/v1beta1/abci.proto @@ -0,0 +1,137 @@ +syntax = "proto3"; +package cosmos.base.abci.v1beta1; + +import "gogoproto/gogo.proto"; +import "tendermint/abci/types.proto"; +import "google/protobuf/any.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/types"; +option (gogoproto.goproto_stringer_all) = false; + +// TxResponse defines a structure containing relevant tx data and metadata. The +// tags are stringified and the log is JSON decoded. +message TxResponse { + option (gogoproto.goproto_getters) = false; + // The block height + int64 height = 1; + // The transaction hash. + string txhash = 2 [(gogoproto.customname) = "TxHash"]; + // Namespace for the Code + string codespace = 3; + // Response code. + uint32 code = 4; + // Result bytes, if any. + string data = 5; + // The output of the application's logger (raw string). May be + // non-deterministic. + string raw_log = 6; + // The output of the application's logger (typed). May be non-deterministic. + repeated ABCIMessageLog logs = 7 [(gogoproto.castrepeated) = "ABCIMessageLogs", (gogoproto.nullable) = false]; + // Additional information. May be non-deterministic. + string info = 8; + // Amount of gas requested for transaction. + int64 gas_wanted = 9; + // Amount of gas consumed by transaction. + int64 gas_used = 10; + // The request transaction bytes. + google.protobuf.Any tx = 11; + // Time of the previous block. For heights > 1, it's the weighted median of + // the timestamps of the valid votes in the block.LastCommit. For height == 1, + // it's genesis time. + string timestamp = 12; +} + +// ABCIMessageLog defines a structure containing an indexed tx ABCI message log. +message ABCIMessageLog { + option (gogoproto.stringer) = true; + + uint32 msg_index = 1; + string log = 2; + + // Events contains a slice of Event objects that were emitted during some + // execution. + repeated StringEvent events = 3 [(gogoproto.castrepeated) = "StringEvents", (gogoproto.nullable) = false]; +} + +// StringEvent defines en Event object wrapper where all the attributes +// contain key/value pairs that are strings instead of raw bytes. +message StringEvent { + option (gogoproto.stringer) = true; + + string type = 1; + repeated Attribute attributes = 2 [(gogoproto.nullable) = false]; +} + +// Attribute defines an attribute wrapper where the key and value are +// strings instead of raw bytes. +message Attribute { + string key = 1; + string value = 2; +} + +// GasInfo defines tx execution gas context. +message GasInfo { + // GasWanted is the maximum units of work we allow this tx to perform. + uint64 gas_wanted = 1 [(gogoproto.moretags) = "yaml:\"gas_wanted\""]; + + // GasUsed is the amount of gas actually consumed. + uint64 gas_used = 2 [(gogoproto.moretags) = "yaml:\"gas_used\""]; +} + +// Result is the union of ResponseFormat and ResponseCheckTx. +message Result { + option (gogoproto.goproto_getters) = false; + + // Data is any data returned from message or handler execution. It MUST be + // length prefixed in order to separate data from multiple message executions. + bytes data = 1; + + // Log contains the log information from message or handler execution. + string log = 2; + + // Events contains a slice of Event objects that were emitted during message + // or handler execution. + repeated tendermint.abci.Event events = 3 [(gogoproto.nullable) = false]; +} + +// SimulationResponse defines the response generated when a transaction is +// successfully simulated. +message SimulationResponse { + GasInfo gas_info = 1 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; + Result result = 2; +} + +// MsgData defines the data returned in a Result object during message +// execution. +message MsgData { + option (gogoproto.stringer) = true; + + string msg_type = 1; + bytes data = 2; +} + +// TxMsgData defines a list of MsgData. A transaction will have a MsgData object +// for each message. +message TxMsgData { + option (gogoproto.stringer) = true; + + repeated MsgData data = 1; +} + +// SearchTxsResult defines a structure for querying txs pageable +message SearchTxsResult { + option (gogoproto.stringer) = true; + + // Count of all txs + uint64 total_count = 1 [(gogoproto.moretags) = "yaml:\"total_count\"", (gogoproto.jsontag) = "total_count"]; + // Count of txs in current page + uint64 count = 2; + // Index of current page, start from 1 + uint64 page_number = 3 [(gogoproto.moretags) = "yaml:\"page_number\"", (gogoproto.jsontag) = "page_number"]; + // Count of total pages + uint64 page_total = 4 [(gogoproto.moretags) = "yaml:\"page_total\"", (gogoproto.jsontag) = "page_total"]; + // Max count txs per page + uint64 limit = 5; + // List of txs in current page + repeated TxResponse txs = 6; +} diff --git a/third_party/proto/cosmos/base/kv/v1beta1/kv.proto b/third_party/proto/cosmos/base/kv/v1beta1/kv.proto new file mode 100644 index 0000000..4e9b8d2 --- /dev/null +++ b/third_party/proto/cosmos/base/kv/v1beta1/kv.proto @@ -0,0 +1,17 @@ +syntax = "proto3"; +package cosmos.base.kv.v1beta1; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/types/kv"; + +// Pairs defines a repeated slice of Pair objects. +message Pairs { + repeated Pair pairs = 1 [(gogoproto.nullable) = false]; +} + +// Pair defines a key/value bytes tuple. +message Pair { + bytes key = 1; + bytes value = 2; +} diff --git a/third_party/proto/cosmos/base/query/v1beta1/pagination.proto b/third_party/proto/cosmos/base/query/v1beta1/pagination.proto new file mode 100644 index 0000000..2a8cbcc --- /dev/null +++ b/third_party/proto/cosmos/base/query/v1beta1/pagination.proto @@ -0,0 +1,50 @@ +syntax = "proto3"; +package cosmos.base.query.v1beta1; + +option go_package = "github.com/cosmos/cosmos-sdk/types/query"; + +// PageRequest is to be embedded in gRPC request messages for efficient +// pagination. Ex: +// +// message SomeRequest { +// Foo some_parameter = 1; +// PageRequest pagination = 2; +// } +message PageRequest { + // key is a value returned in PageResponse.next_key to begin + // querying the next page most efficiently. Only one of offset or key + // should be set. + bytes key = 1; + + // offset is a numeric offset that can be used when key is unavailable. + // It is less efficient than using key. Only one of offset or key should + // be set. + uint64 offset = 2; + + // limit is the total number of results to be returned in the result page. + // If left empty it will default to a value to be set by each app. + uint64 limit = 3; + + // count_total is set to true to indicate that the result set should include + // a count of the total number of items available for pagination in UIs. + // count_total is only respected when offset is used. It is ignored when key + // is set. + bool count_total = 4; +} + +// PageResponse is to be embedded in gRPC response messages where the +// corresponding request message has used PageRequest. +// +// message SomeResponse { +// repeated Bar results = 1; +// PageResponse page = 2; +// } +message PageResponse { + // next_key is the key to be passed to PageRequest.key to + // query the next page most efficiently + bytes next_key = 1; + + // total is total number of results available if PageRequest.count_total + // was set, its value is undefined otherwise + uint64 total = 2; +} diff --git a/third_party/proto/cosmos/base/reflection/v1beta1/reflection.proto b/third_party/proto/cosmos/base/reflection/v1beta1/reflection.proto new file mode 100644 index 0000000..22670e7 --- /dev/null +++ b/third_party/proto/cosmos/base/reflection/v1beta1/reflection.proto @@ -0,0 +1,44 @@ +syntax = "proto3"; +package cosmos.base.reflection.v1beta1; + +import "google/api/annotations.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/client/grpc/reflection"; + +// ReflectionService defines a service for interface reflection. +service ReflectionService { + // ListAllInterfaces lists all the interfaces registered in the interface + // registry. + rpc ListAllInterfaces(ListAllInterfacesRequest) returns (ListAllInterfacesResponse) { + option (google.api.http).get = "/cosmos/base/reflection/v1beta1/interfaces"; + }; + + // ListImplementations list all the concrete types that implement a given + // interface. + rpc ListImplementations(ListImplementationsRequest) returns (ListImplementationsResponse) { + option (google.api.http).get = "/cosmos/base/reflection/v1beta1/interfaces/" + "{interface_name}/implementations"; + }; +} + +// ListAllInterfacesRequest is the request type of the ListAllInterfaces RPC. +message ListAllInterfacesRequest {} + +// ListAllInterfacesResponse is the response type of the ListAllInterfaces RPC. +message ListAllInterfacesResponse { + // interface_names is an array of all the registered interfaces. + repeated string interface_names = 1; +} + +// ListImplementationsRequest is the request type of the ListImplementations +// RPC. +message ListImplementationsRequest { + // interface_name defines the interface to query the implementations for. + string interface_name = 1; +} + +// ListImplementationsResponse is the response type of the ListImplementations +// RPC. +message ListImplementationsResponse { + repeated string implementation_message_names = 1; +} diff --git a/third_party/proto/cosmos/base/snapshots/v1beta1/snapshot.proto b/third_party/proto/cosmos/base/snapshots/v1beta1/snapshot.proto new file mode 100644 index 0000000..9ac5a7c --- /dev/null +++ b/third_party/proto/cosmos/base/snapshots/v1beta1/snapshot.proto @@ -0,0 +1,20 @@ +syntax = "proto3"; +package cosmos.base.snapshots.v1beta1; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/snapshots/types"; + +// Snapshot contains Tendermint state sync snapshot info. +message Snapshot { + uint64 height = 1; + uint32 format = 2; + uint32 chunks = 3; + bytes hash = 4; + Metadata metadata = 5 [(gogoproto.nullable) = false]; +} + +// Metadata contains SDK-specific snapshot metadata. +message Metadata { + repeated bytes chunk_hashes = 1; // SHA-256 chunk hashes +} \ No newline at end of file diff --git a/third_party/proto/cosmos/base/store/v1beta1/commit_info.proto b/third_party/proto/cosmos/base/store/v1beta1/commit_info.proto new file mode 100644 index 0000000..98a33d3 --- /dev/null +++ b/third_party/proto/cosmos/base/store/v1beta1/commit_info.proto @@ -0,0 +1,29 @@ +syntax = "proto3"; +package cosmos.base.store.v1beta1; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/store/types"; + +// CommitInfo defines commit information used by the multi-store when committing +// a version/height. +message CommitInfo { + int64 version = 1; + repeated StoreInfo store_infos = 2 [(gogoproto.nullable) = false]; +} + +// StoreInfo defines store-specific commit information. It contains a reference +// between a store name and the commit ID. +message StoreInfo { + string name = 1; + CommitID commit_id = 2 [(gogoproto.nullable) = false]; +} + +// CommitID defines the committment information when a specific store is +// committed. +message CommitID { + option (gogoproto.goproto_stringer) = false; + + int64 version = 1; + bytes hash = 2; +} diff --git a/third_party/proto/cosmos/base/store/v1beta1/snapshot.proto b/third_party/proto/cosmos/base/store/v1beta1/snapshot.proto new file mode 100644 index 0000000..8348550 --- /dev/null +++ b/third_party/proto/cosmos/base/store/v1beta1/snapshot.proto @@ -0,0 +1,28 @@ +syntax = "proto3"; +package cosmos.base.store.v1beta1; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/store/types"; + +// SnapshotItem is an item contained in a rootmulti.Store snapshot. +message SnapshotItem { + // item is the specific type of snapshot item. + oneof item { + SnapshotStoreItem store = 1; + SnapshotIAVLItem iavl = 2 [(gogoproto.customname) = "IAVL"]; + } +} + +// SnapshotStoreItem contains metadata about a snapshotted store. +message SnapshotStoreItem { + string name = 1; +} + +// SnapshotIAVLItem is an exported IAVL node. +message SnapshotIAVLItem { + bytes key = 1; + bytes value = 2; + int64 version = 3; + int32 height = 4; +} \ No newline at end of file diff --git a/third_party/proto/cosmos/base/tendermint/v1beta1/query.proto b/third_party/proto/cosmos/base/tendermint/v1beta1/query.proto new file mode 100644 index 0000000..50cb585 --- /dev/null +++ b/third_party/proto/cosmos/base/tendermint/v1beta1/query.proto @@ -0,0 +1,136 @@ +syntax = "proto3"; +package cosmos.base.tendermint.v1beta1; + +import "gogoproto/gogo.proto"; +import "google/protobuf/any.proto"; +import "google/api/annotations.proto"; +import "tendermint/p2p/types.proto"; +import "tendermint/types/block.proto"; +import "tendermint/types/types.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/client/grpc/tmservice"; + +// Service defines the gRPC querier service for tendermint queries. +service Service { + // GetNodeInfo queries the current node info. + rpc GetNodeInfo(GetNodeInfoRequest) returns (GetNodeInfoResponse) { + option (google.api.http).get = "/cosmos/base/tendermint/v1beta1/node_info"; + } + // GetSyncing queries node syncing. + rpc GetSyncing(GetSyncingRequest) returns (GetSyncingResponse) { + option (google.api.http).get = "/cosmos/base/tendermint/v1beta1/syncing"; + } + // GetLatestBlock returns the latest block. + rpc GetLatestBlock(GetLatestBlockRequest) returns (GetLatestBlockResponse) { + option (google.api.http).get = "/cosmos/base/tendermint/v1beta1/blocks/latest"; + } + // GetBlockByHeight queries block for given height. + rpc GetBlockByHeight(GetBlockByHeightRequest) returns (GetBlockByHeightResponse) { + option (google.api.http).get = "/cosmos/base/tendermint/v1beta1/blocks/{height}"; + } + + // GetLatestValidatorSet queries latest validator-set. + rpc GetLatestValidatorSet(GetLatestValidatorSetRequest) returns (GetLatestValidatorSetResponse) { + option (google.api.http).get = "/cosmos/base/tendermint/v1beta1/validatorsets/latest"; + } + // GetValidatorSetByHeight queries validator-set at a given height. + rpc GetValidatorSetByHeight(GetValidatorSetByHeightRequest) returns (GetValidatorSetByHeightResponse) { + option (google.api.http).get = "/cosmos/base/tendermint/v1beta1/validatorsets/{height}"; + } +} + +// GetValidatorSetByHeightRequest is the request type for the Query/GetValidatorSetByHeight RPC method. +message GetValidatorSetByHeightRequest { + int64 height = 1; + // pagination defines an pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// GetValidatorSetByHeightResponse is the response type for the Query/GetValidatorSetByHeight RPC method. +message GetValidatorSetByHeightResponse { + int64 block_height = 1; + repeated Validator validators = 2; + // pagination defines an pagination for the response. + cosmos.base.query.v1beta1.PageResponse pagination = 3; +} + +// GetLatestValidatorSetRequest is the request type for the Query/GetValidatorSetByHeight RPC method. +message GetLatestValidatorSetRequest { + // pagination defines an pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 1; +} + +// GetLatestValidatorSetResponse is the response type for the Query/GetValidatorSetByHeight RPC method. +message GetLatestValidatorSetResponse { + int64 block_height = 1; + repeated Validator validators = 2; + // pagination defines an pagination for the response. + cosmos.base.query.v1beta1.PageResponse pagination = 3; +} + +// Validator is the type for the validator-set. +message Validator { + string address = 1; + google.protobuf.Any pub_key = 2; + int64 voting_power = 3; + int64 proposer_priority = 4; +} + +// GetBlockByHeightRequest is the request type for the Query/GetBlockByHeight RPC method. +message GetBlockByHeightRequest { + int64 height = 1; +} + +// GetBlockByHeightResponse is the response type for the Query/GetBlockByHeight RPC method. +message GetBlockByHeightResponse { + .tendermint.types.BlockID block_id = 1; + .tendermint.types.Block block = 2; +} + +// GetLatestBlockRequest is the request type for the Query/GetLatestBlock RPC method. +message GetLatestBlockRequest {} + +// GetLatestBlockResponse is the response type for the Query/GetLatestBlock RPC method. +message GetLatestBlockResponse { + .tendermint.types.BlockID block_id = 1; + .tendermint.types.Block block = 2; +} + +// GetSyncingRequest is the request type for the Query/GetSyncing RPC method. +message GetSyncingRequest {} + +// GetSyncingResponse is the response type for the Query/GetSyncing RPC method. +message GetSyncingResponse { + bool syncing = 1; +} + +// GetNodeInfoRequest is the request type for the Query/GetNodeInfo RPC method. +message GetNodeInfoRequest {} + +// GetNodeInfoResponse is the request type for the Query/GetNodeInfo RPC method. +message GetNodeInfoResponse { + .tendermint.p2p.DefaultNodeInfo default_node_info = 1; + VersionInfo application_version = 2; +} + +// VersionInfo is the type for the GetNodeInfoResponse message. +message VersionInfo { + string name = 1; + string app_name = 2; + string version = 3; + string git_commit = 4; + string build_tags = 5; + string go_version = 6; + repeated Module build_deps = 7; +} + +// Module is the type for VersionInfo +message Module { + // module path + string path = 1; + // module version + string version = 2; + // checksum + string sum = 3; +} diff --git a/third_party/proto/cosmos/base/v1beta1/coin.proto b/third_party/proto/cosmos/base/v1beta1/coin.proto new file mode 100644 index 0000000..fab7528 --- /dev/null +++ b/third_party/proto/cosmos/base/v1beta1/coin.proto @@ -0,0 +1,40 @@ +syntax = "proto3"; +package cosmos.base.v1beta1; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/types"; +option (gogoproto.goproto_stringer_all) = false; +option (gogoproto.stringer_all) = false; + +// Coin defines a token with a denomination and an amount. +// +// NOTE: The amount field is an Int which implements the custom method +// signatures required by gogoproto. +message Coin { + option (gogoproto.equal) = true; + + string denom = 1; + string amount = 2 [(gogoproto.customtype) = "Int", (gogoproto.nullable) = false]; +} + +// DecCoin defines a token with a denomination and a decimal amount. +// +// NOTE: The amount field is an Dec which implements the custom method +// signatures required by gogoproto. +message DecCoin { + option (gogoproto.equal) = true; + + string denom = 1; + string amount = 2 [(gogoproto.customtype) = "Dec", (gogoproto.nullable) = false]; +} + +// IntProto defines a Protobuf wrapper around an Int object. +message IntProto { + string int = 1 [(gogoproto.customtype) = "Int", (gogoproto.nullable) = false]; +} + +// DecProto defines a Protobuf wrapper around a Dec object. +message DecProto { + string dec = 1 [(gogoproto.customtype) = "Dec", (gogoproto.nullable) = false]; +} diff --git a/third_party/proto/cosmos/capability/v1beta1/capability.proto b/third_party/proto/cosmos/capability/v1beta1/capability.proto new file mode 100644 index 0000000..1c8332f --- /dev/null +++ b/third_party/proto/cosmos/capability/v1beta1/capability.proto @@ -0,0 +1,30 @@ +syntax = "proto3"; +package cosmos.capability.v1beta1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/capability/types"; + +import "gogoproto/gogo.proto"; + +// Capability defines an implementation of an object capability. The index +// provided to a Capability must be globally unique. +message Capability { + option (gogoproto.goproto_stringer) = false; + + uint64 index = 1 [(gogoproto.moretags) = "yaml:\"index\""]; +} + +// Owner defines a single capability owner. An owner is defined by the name of +// capability and the module name. +message Owner { + option (gogoproto.goproto_stringer) = false; + option (gogoproto.goproto_getters) = false; + + string module = 1 [(gogoproto.moretags) = "yaml:\"module\""]; + string name = 2 [(gogoproto.moretags) = "yaml:\"name\""]; +} + +// CapabilityOwners defines a set of owners of a single Capability. The set of +// owners must be unique. +message CapabilityOwners { + repeated Owner owners = 1 [(gogoproto.nullable) = false]; +} diff --git a/third_party/proto/cosmos/capability/v1beta1/genesis.proto b/third_party/proto/cosmos/capability/v1beta1/genesis.proto new file mode 100644 index 0000000..05bb0af --- /dev/null +++ b/third_party/proto/cosmos/capability/v1beta1/genesis.proto @@ -0,0 +1,26 @@ +syntax = "proto3"; +package cosmos.capability.v1beta1; + +import "gogoproto/gogo.proto"; +import "cosmos/capability/v1beta1/capability.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/capability/types"; + +// GenesisOwners defines the capability owners with their corresponding index. +message GenesisOwners { + // index is the index of the capability owner. + uint64 index = 1; + + // index_owners are the owners at the given index. + CapabilityOwners index_owners = 2 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"index_owners\""]; +} + +// GenesisState defines the capability module's genesis state. +message GenesisState { + // index is the capability global index. + uint64 index = 1; + + // owners represents a map from index to owners of the capability index + // index key is string to allow amino marshalling. + repeated GenesisOwners owners = 2 [(gogoproto.nullable) = false]; +} diff --git a/third_party/proto/cosmos/crisis/v1beta1/genesis.proto b/third_party/proto/cosmos/crisis/v1beta1/genesis.proto new file mode 100644 index 0000000..5b0ff7e --- /dev/null +++ b/third_party/proto/cosmos/crisis/v1beta1/genesis.proto @@ -0,0 +1,15 @@ +syntax = "proto3"; +package cosmos.crisis.v1beta1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/crisis/types"; + +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; + +// GenesisState defines the crisis module's genesis state. +message GenesisState { + // constant_fee is the fee used to verify the invariant in the crisis + // module. + cosmos.base.v1beta1.Coin constant_fee = 3 + [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"constant_fee\""]; +} diff --git a/third_party/proto/cosmos/crisis/v1beta1/tx.proto b/third_party/proto/cosmos/crisis/v1beta1/tx.proto new file mode 100644 index 0000000..26457ad --- /dev/null +++ b/third_party/proto/cosmos/crisis/v1beta1/tx.proto @@ -0,0 +1,25 @@ +syntax = "proto3"; +package cosmos.crisis.v1beta1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/crisis/types"; + +import "gogoproto/gogo.proto"; + +// Msg defines the bank Msg service. +service Msg { + // VerifyInvariant defines a method to verify a particular invariance. + rpc VerifyInvariant(MsgVerifyInvariant) returns (MsgVerifyInvariantResponse); +} + +// MsgVerifyInvariant represents a message to verify a particular invariance. +message MsgVerifyInvariant { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string sender = 1; + string invariant_module_name = 2 [(gogoproto.moretags) = "yaml:\"invariant_module_name\""]; + string invariant_route = 3 [(gogoproto.moretags) = "yaml:\"invariant_route\""]; +} + +// MsgVerifyInvariantResponse defines the Msg/VerifyInvariant response type. +message MsgVerifyInvariantResponse {} diff --git a/third_party/proto/cosmos/crypto/ed25519/keys.proto b/third_party/proto/cosmos/crypto/ed25519/keys.proto new file mode 100644 index 0000000..bed9c29 --- /dev/null +++ b/third_party/proto/cosmos/crypto/ed25519/keys.proto @@ -0,0 +1,22 @@ +syntax = "proto3"; +package cosmos.crypto.ed25519; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"; + +// PubKey defines a ed25519 public key +// Key is the compressed form of the pubkey. The first byte depends is a 0x02 byte +// if the y-coordinate is the lexicographically largest of the two associated with +// the x-coordinate. Otherwise the first byte is a 0x03. +// This prefix is followed with the x-coordinate. +message PubKey { + option (gogoproto.goproto_stringer) = false; + + bytes key = 1 [(gogoproto.casttype) = "crypto/ed25519.PublicKey"]; +} + +// PrivKey defines a ed25519 private key. +message PrivKey { + bytes key = 1 [(gogoproto.casttype) = "crypto/ed25519.PrivateKey"]; +} diff --git a/third_party/proto/cosmos/crypto/multisig/keys.proto b/third_party/proto/cosmos/crypto/multisig/keys.proto new file mode 100644 index 0000000..f8398e8 --- /dev/null +++ b/third_party/proto/cosmos/crypto/multisig/keys.proto @@ -0,0 +1,18 @@ +syntax = "proto3"; +package cosmos.crypto.multisig; + +import "gogoproto/gogo.proto"; +import "google/protobuf/any.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/crypto/keys/multisig"; + +// LegacyAminoPubKey specifies a public key type +// which nests multiple public keys and a threshold, +// it uses legacy amino address rules. +message LegacyAminoPubKey { + option (gogoproto.goproto_getters) = false; + + uint32 threshold = 1 [(gogoproto.moretags) = "yaml:\"threshold\""]; + repeated google.protobuf.Any public_keys = 2 + [(gogoproto.customname) = "PubKeys", (gogoproto.moretags) = "yaml:\"pubkeys\""]; +} diff --git a/third_party/proto/cosmos/crypto/multisig/v1beta1/multisig.proto b/third_party/proto/cosmos/crypto/multisig/v1beta1/multisig.proto new file mode 100644 index 0000000..bf671f1 --- /dev/null +++ b/third_party/proto/cosmos/crypto/multisig/v1beta1/multisig.proto @@ -0,0 +1,25 @@ +syntax = "proto3"; +package cosmos.crypto.multisig.v1beta1; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/crypto/types"; + +// MultiSignature wraps the signatures from a multisig.LegacyAminoPubKey. +// See cosmos.tx.v1betata1.ModeInfo.Multi for how to specify which signers +// signed and with which modes. +message MultiSignature { + option (gogoproto.goproto_unrecognized) = true; + repeated bytes signatures = 1; +} + +// CompactBitArray is an implementation of a space efficient bit array. +// This is used to ensure that the encoded data takes up a minimal amount of +// space after proto encoding. +// This is not thread safe, and is not intended for concurrent usage. +message CompactBitArray { + option (gogoproto.goproto_stringer) = false; + + uint32 extra_bits_stored = 1; + bytes elems = 2; +} diff --git a/third_party/proto/cosmos/crypto/secp256k1/keys.proto b/third_party/proto/cosmos/crypto/secp256k1/keys.proto new file mode 100644 index 0000000..a227257 --- /dev/null +++ b/third_party/proto/cosmos/crypto/secp256k1/keys.proto @@ -0,0 +1,22 @@ +syntax = "proto3"; +package cosmos.crypto.secp256k1; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"; + +// PubKey defines a secp256k1 public key +// Key is the compressed form of the pubkey. The first byte depends is a 0x02 byte +// if the y-coordinate is the lexicographically largest of the two associated with +// the x-coordinate. Otherwise the first byte is a 0x03. +// This prefix is followed with the x-coordinate. +message PubKey { + option (gogoproto.goproto_stringer) = false; + + bytes key = 1; +} + +// PrivKey defines a secp256k1 private key. +message PrivKey { + bytes key = 1; +} diff --git a/third_party/proto/cosmos/distribution/v1beta1/distribution.proto b/third_party/proto/cosmos/distribution/v1beta1/distribution.proto new file mode 100644 index 0000000..ae98ec0 --- /dev/null +++ b/third_party/proto/cosmos/distribution/v1beta1/distribution.proto @@ -0,0 +1,157 @@ +syntax = "proto3"; +package cosmos.distribution.v1beta1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/distribution/types"; +option (gogoproto.equal_all) = true; + +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; + +// Params defines the set of params for the distribution module. +message Params { + option (gogoproto.goproto_stringer) = false; + string community_tax = 1 [ + (gogoproto.moretags) = "yaml:\"community_tax\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + string base_proposer_reward = 2 [ + (gogoproto.moretags) = "yaml:\"base_proposer_reward\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + string bonus_proposer_reward = 3 [ + (gogoproto.moretags) = "yaml:\"bonus_proposer_reward\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + bool withdraw_addr_enabled = 4 [(gogoproto.moretags) = "yaml:\"withdraw_addr_enabled\""]; +} + +// ValidatorHistoricalRewards represents historical rewards for a validator. +// Height is implicit within the store key. +// Cumulative reward ratio is the sum from the zeroeth period +// until this period of rewards / tokens, per the spec. +// The reference count indicates the number of objects +// which might need to reference this historical entry at any point. +// ReferenceCount = +// number of outstanding delegations which ended the associated period (and +// might need to read that record) +// + number of slashes which ended the associated period (and might need to +// read that record) +// + one per validator for the zeroeth period, set on initialization +message ValidatorHistoricalRewards { + repeated cosmos.base.v1beta1.DecCoin cumulative_reward_ratio = 1 [ + (gogoproto.moretags) = "yaml:\"cumulative_reward_ratio\"", + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", + (gogoproto.nullable) = false + ]; + uint32 reference_count = 2 [(gogoproto.moretags) = "yaml:\"reference_count\""]; +} + +// ValidatorCurrentRewards represents current rewards and current +// period for a validator kept as a running counter and incremented +// each block as long as the validator's tokens remain constant. +message ValidatorCurrentRewards { + repeated cosmos.base.v1beta1.DecCoin rewards = 1 + [(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", (gogoproto.nullable) = false]; + uint64 period = 2; +} + +// ValidatorAccumulatedCommission represents accumulated commission +// for a validator kept as a running counter, can be withdrawn at any time. +message ValidatorAccumulatedCommission { + repeated cosmos.base.v1beta1.DecCoin commission = 1 + [(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", (gogoproto.nullable) = false]; +} + +// ValidatorOutstandingRewards represents outstanding (un-withdrawn) rewards +// for a validator inexpensive to track, allows simple sanity checks. +message ValidatorOutstandingRewards { + repeated cosmos.base.v1beta1.DecCoin rewards = 1 [ + (gogoproto.moretags) = "yaml:\"rewards\"", + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", + (gogoproto.nullable) = false + ]; +} + +// ValidatorSlashEvent represents a validator slash event. +// Height is implicit within the store key. +// This is needed to calculate appropriate amount of staking tokens +// for delegations which are withdrawn after a slash has occurred. +message ValidatorSlashEvent { + uint64 validator_period = 1 [(gogoproto.moretags) = "yaml:\"validator_period\""]; + string fraction = 2 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; +} + +// ValidatorSlashEvents is a collection of ValidatorSlashEvent messages. +message ValidatorSlashEvents { + option (gogoproto.goproto_stringer) = false; + repeated ValidatorSlashEvent validator_slash_events = 1 + [(gogoproto.moretags) = "yaml:\"validator_slash_events\"", (gogoproto.nullable) = false]; +} + +// FeePool is the global fee pool for distribution. +message FeePool { + repeated cosmos.base.v1beta1.DecCoin community_pool = 1 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", + (gogoproto.moretags) = "yaml:\"community_pool\"" + ]; +} + +// CommunityPoolSpendProposal details a proposal for use of community funds, +// together with how many coins are proposed to be spent, and to which +// recipient account. +message CommunityPoolSpendProposal { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = false; + + string title = 1; + string description = 2; + string recipient = 3; + repeated cosmos.base.v1beta1.Coin amount = 4 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; +} + +// DelegatorStartingInfo represents the starting info for a delegator reward +// period. It tracks the previous validator period, the delegation's amount of +// staking token, and the creation height (to check later on if any slashes have +// occurred). NOTE: Even though validators are slashed to whole staking tokens, +// the delegators within the validator may be left with less than a full token, +// thus sdk.Dec is used. +message DelegatorStartingInfo { + uint64 previous_period = 1 [(gogoproto.moretags) = "yaml:\"previous_period\""]; + string stake = 2 [ + (gogoproto.moretags) = "yaml:\"stake\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + uint64 height = 3 [(gogoproto.moretags) = "yaml:\"creation_height\"", (gogoproto.jsontag) = "creation_height"]; +} + +// DelegationDelegatorReward represents the properties +// of a delegator's delegation reward. +message DelegationDelegatorReward { + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = true; + + string validator_address = 1 [(gogoproto.moretags) = "yaml:\"validator_address\""]; + + repeated cosmos.base.v1beta1.DecCoin reward = 2 + [(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", (gogoproto.nullable) = false]; +} + +// CommunityPoolSpendProposalWithDeposit defines a CommunityPoolSpendProposal +// with a deposit +message CommunityPoolSpendProposalWithDeposit { + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = true; + + string title = 1 [(gogoproto.moretags) = "yaml:\"title\""]; + string description = 2 [(gogoproto.moretags) = "yaml:\"description\""]; + string recipient = 3 [(gogoproto.moretags) = "yaml:\"recipient\""]; + string amount = 4 [(gogoproto.moretags) = "yaml:\"amount\""]; + string deposit = 5 [(gogoproto.moretags) = "yaml:\"deposit\""]; +} diff --git a/third_party/proto/cosmos/distribution/v1beta1/genesis.proto b/third_party/proto/cosmos/distribution/v1beta1/genesis.proto new file mode 100644 index 0000000..c0b17cd --- /dev/null +++ b/third_party/proto/cosmos/distribution/v1beta1/genesis.proto @@ -0,0 +1,155 @@ +syntax = "proto3"; +package cosmos.distribution.v1beta1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/distribution/types"; +option (gogoproto.equal_all) = true; + +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; +import "cosmos/distribution/v1beta1/distribution.proto"; + +// DelegatorWithdrawInfo is the address for where distributions rewards are +// withdrawn to by default this struct is only used at genesis to feed in +// default withdraw addresses. +message DelegatorWithdrawInfo { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // delegator_address is the address of the delegator. + string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""]; + + // withdraw_address is the address to withdraw the delegation rewards to. + string withdraw_address = 2 [(gogoproto.moretags) = "yaml:\"withdraw_address\""]; +} + +// ValidatorOutstandingRewardsRecord is used for import/export via genesis json. +message ValidatorOutstandingRewardsRecord { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // validator_address is the address of the validator. + string validator_address = 1 [(gogoproto.moretags) = "yaml:\"validator_address\""]; + + // outstanding_rewards represents the oustanding rewards of a validator. + repeated cosmos.base.v1beta1.DecCoin outstanding_rewards = 2 [ + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"outstanding_rewards\"" + ]; +} + +// ValidatorAccumulatedCommissionRecord is used for import / export via genesis +// json. +message ValidatorAccumulatedCommissionRecord { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // validator_address is the address of the validator. + string validator_address = 1 [(gogoproto.moretags) = "yaml:\"validator_address\""]; + + // accumulated is the accumulated commission of a validator. + ValidatorAccumulatedCommission accumulated = 2 + [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"accumulated\""]; +} + +// ValidatorHistoricalRewardsRecord is used for import / export via genesis +// json. +message ValidatorHistoricalRewardsRecord { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // validator_address is the address of the validator. + string validator_address = 1 [(gogoproto.moretags) = "yaml:\"validator_address\""]; + + // period defines the period the historical rewards apply to. + uint64 period = 2; + + // rewards defines the historical rewards of a validator. + ValidatorHistoricalRewards rewards = 3 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"rewards\""]; +} + +// ValidatorCurrentRewardsRecord is used for import / export via genesis json. +message ValidatorCurrentRewardsRecord { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // validator_address is the address of the validator. + string validator_address = 1 [(gogoproto.moretags) = "yaml:\"validator_address\""]; + + // rewards defines the current rewards of a validator. + ValidatorCurrentRewards rewards = 2 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"rewards\""]; +} + +// DelegatorStartingInfoRecord used for import / export via genesis json. +message DelegatorStartingInfoRecord { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // delegator_address is the address of the delegator. + string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""]; + + // validator_address is the address of the validator. + string validator_address = 2 [(gogoproto.moretags) = "yaml:\"validator_address\""]; + + // starting_info defines the starting info of a delegator. + DelegatorStartingInfo starting_info = 3 + [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"starting_info\""]; +} + +// ValidatorSlashEventRecord is used for import / export via genesis json. +message ValidatorSlashEventRecord { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // validator_address is the address of the validator. + string validator_address = 1 [(gogoproto.moretags) = "yaml:\"validator_address\""]; + // height defines the block height at which the slash event occured. + uint64 height = 2; + // period is the period of the slash event. + uint64 period = 3; + // validator_slash_event describes the slash event. + ValidatorSlashEvent validator_slash_event = 4 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"event\""]; +} + +// GenesisState defines the distribution module's genesis state. +message GenesisState { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // params defines all the paramaters of the module. + Params params = 1 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"params\""]; + + // fee_pool defines the fee pool at genesis. + FeePool fee_pool = 2 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"fee_pool\""]; + + // fee_pool defines the delegator withdraw infos at genesis. + repeated DelegatorWithdrawInfo delegator_withdraw_infos = 3 + [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"delegator_withdraw_infos\""]; + + // fee_pool defines the previous proposer at genesis. + string previous_proposer = 4 [(gogoproto.moretags) = "yaml:\"previous_proposer\""]; + + // fee_pool defines the outstanding rewards of all validators at genesis. + repeated ValidatorOutstandingRewardsRecord outstanding_rewards = 5 + [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"outstanding_rewards\""]; + + // fee_pool defines the accumulated commisions of all validators at genesis. + repeated ValidatorAccumulatedCommissionRecord validator_accumulated_commissions = 6 + [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"validator_accumulated_commissions\""]; + + // fee_pool defines the historical rewards of all validators at genesis. + repeated ValidatorHistoricalRewardsRecord validator_historical_rewards = 7 + [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"validator_historical_rewards\""]; + + // fee_pool defines the current rewards of all validators at genesis. + repeated ValidatorCurrentRewardsRecord validator_current_rewards = 8 + [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"validator_current_rewards\""]; + + // fee_pool defines the delegator starting infos at genesis. + repeated DelegatorStartingInfoRecord delegator_starting_infos = 9 + [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"delegator_starting_infos\""]; + + // fee_pool defines the validator slash events at genesis. + repeated ValidatorSlashEventRecord validator_slash_events = 10 + [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"validator_slash_events\""]; +} diff --git a/third_party/proto/cosmos/distribution/v1beta1/query.proto b/third_party/proto/cosmos/distribution/v1beta1/query.proto new file mode 100644 index 0000000..2991218 --- /dev/null +++ b/third_party/proto/cosmos/distribution/v1beta1/query.proto @@ -0,0 +1,218 @@ +syntax = "proto3"; +package cosmos.distribution.v1beta1; + +import "cosmos/base/query/v1beta1/pagination.proto"; +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "cosmos/base/v1beta1/coin.proto"; +import "cosmos/distribution/v1beta1/distribution.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/distribution/types"; + +// Query defines the gRPC querier service for distribution module. +service Query { + // Params queries params of the distribution module. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/cosmos/distribution/v1beta1/params"; + } + + // ValidatorOutstandingRewards queries rewards of a validator address. + rpc ValidatorOutstandingRewards(QueryValidatorOutstandingRewardsRequest) + returns (QueryValidatorOutstandingRewardsResponse) { + option (google.api.http).get = "/cosmos/distribution/v1beta1/validators/" + "{validator_address}/outstanding_rewards"; + } + + // ValidatorCommission queries accumulated commission for a validator. + rpc ValidatorCommission(QueryValidatorCommissionRequest) returns (QueryValidatorCommissionResponse) { + option (google.api.http).get = "/cosmos/distribution/v1beta1/validators/" + "{validator_address}/commission"; + } + + // ValidatorSlashes queries slash events of a validator. + rpc ValidatorSlashes(QueryValidatorSlashesRequest) returns (QueryValidatorSlashesResponse) { + option (google.api.http).get = "/cosmos/distribution/v1beta1/validators/{validator_address}/slashes"; + } + + // DelegationRewards queries the total rewards accrued by a delegation. + rpc DelegationRewards(QueryDelegationRewardsRequest) returns (QueryDelegationRewardsResponse) { + option (google.api.http).get = "/cosmos/distribution/v1beta1/delegators/{delegator_address}/rewards/" + "{validator_address}"; + } + + // DelegationTotalRewards queries the total rewards accrued by a each + // validator. + rpc DelegationTotalRewards(QueryDelegationTotalRewardsRequest) returns (QueryDelegationTotalRewardsResponse) { + option (google.api.http).get = "/cosmos/distribution/v1beta1/delegators/{delegator_address}/rewards"; + } + + // DelegatorValidators queries the validators of a delegator. + rpc DelegatorValidators(QueryDelegatorValidatorsRequest) returns (QueryDelegatorValidatorsResponse) { + option (google.api.http).get = "/cosmos/distribution/v1beta1/delegators/" + "{delegator_address}/validators"; + } + + // DelegatorWithdrawAddress queries withdraw address of a delegator. + rpc DelegatorWithdrawAddress(QueryDelegatorWithdrawAddressRequest) returns (QueryDelegatorWithdrawAddressResponse) { + option (google.api.http).get = "/cosmos/distribution/v1beta1/delegators/" + "{delegator_address}/withdraw_address"; + } + + // CommunityPool queries the community pool coins. + rpc CommunityPool(QueryCommunityPoolRequest) returns (QueryCommunityPoolResponse) { + option (google.api.http).get = "/cosmos/distribution/v1beta1/community_pool"; + } +} + +// QueryParamsRequest is the request type for the Query/Params RPC method. +message QueryParamsRequest {} + +// QueryParamsResponse is the response type for the Query/Params RPC method. +message QueryParamsResponse { + // params defines the parameters of the module. + Params params = 1 [(gogoproto.nullable) = false]; +} + +// QueryValidatorOutstandingRewardsRequest is the request type for the +// Query/ValidatorOutstandingRewards RPC method. +message QueryValidatorOutstandingRewardsRequest { + // validator_address defines the validator address to query for. + string validator_address = 1; +} + +// QueryValidatorOutstandingRewardsResponse is the response type for the +// Query/ValidatorOutstandingRewards RPC method. +message QueryValidatorOutstandingRewardsResponse { + ValidatorOutstandingRewards rewards = 1 [(gogoproto.nullable) = false]; +} + +// QueryValidatorCommissionRequest is the request type for the +// Query/ValidatorCommission RPC method +message QueryValidatorCommissionRequest { + // validator_address defines the validator address to query for. + string validator_address = 1; +} + +// QueryValidatorCommissionResponse is the response type for the +// Query/ValidatorCommission RPC method +message QueryValidatorCommissionResponse { + // commission defines the commision the validator received. + ValidatorAccumulatedCommission commission = 1 [(gogoproto.nullable) = false]; +} + +// QueryValidatorSlashesRequest is the request type for the +// Query/ValidatorSlashes RPC method +message QueryValidatorSlashesRequest { + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = true; + + // validator_address defines the validator address to query for. + string validator_address = 1; + // starting_height defines the optional starting height to query the slashes. + uint64 starting_height = 2; + // starting_height defines the optional ending height to query the slashes. + uint64 ending_height = 3; + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 4; +} + +// QueryValidatorSlashesResponse is the response type for the +// Query/ValidatorSlashes RPC method. +message QueryValidatorSlashesResponse { + // slashes defines the slashes the validator received. + repeated ValidatorSlashEvent slashes = 1 [(gogoproto.nullable) = false]; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryDelegationRewardsRequest is the request type for the +// Query/DelegationRewards RPC method. +message QueryDelegationRewardsRequest { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // delegator_address defines the delegator address to query for. + string delegator_address = 1; + // validator_address defines the validator address to query for. + string validator_address = 2; +} + +// QueryDelegationRewardsResponse is the response type for the +// Query/DelegationRewards RPC method. +message QueryDelegationRewardsResponse { + // rewards defines the rewards accrued by a delegation. + repeated cosmos.base.v1beta1.DecCoin rewards = 1 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins"]; +} + +// QueryDelegationTotalRewardsRequest is the request type for the +// Query/DelegationTotalRewards RPC method. +message QueryDelegationTotalRewardsRequest { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + // delegator_address defines the delegator address to query for. + string delegator_address = 1; +} + +// QueryDelegationTotalRewardsResponse is the response type for the +// Query/DelegationTotalRewards RPC method. +message QueryDelegationTotalRewardsResponse { + // rewards defines all the rewards accrued by a delegator. + repeated DelegationDelegatorReward rewards = 1 [(gogoproto.nullable) = false]; + // total defines the sum of all the rewards. + repeated cosmos.base.v1beta1.DecCoin total = 2 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins"]; +} + +// QueryDelegatorValidatorsRequest is the request type for the +// Query/DelegatorValidators RPC method. +message QueryDelegatorValidatorsRequest { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // delegator_address defines the delegator address to query for. + string delegator_address = 1; +} + +// QueryDelegatorValidatorsResponse is the response type for the +// Query/DelegatorValidators RPC method. +message QueryDelegatorValidatorsResponse { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // validators defines the validators a delegator is delegating for. + repeated string validators = 1; +} + +// QueryDelegatorWithdrawAddressRequest is the request type for the +// Query/DelegatorWithdrawAddress RPC method. +message QueryDelegatorWithdrawAddressRequest { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // delegator_address defines the delegator address to query for. + string delegator_address = 1; +} + +// QueryDelegatorWithdrawAddressResponse is the response type for the +// Query/DelegatorWithdrawAddress RPC method. +message QueryDelegatorWithdrawAddressResponse { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // withdraw_address defines the delegator address to query for. + string withdraw_address = 1; +} + +// QueryCommunityPoolRequest is the request type for the Query/CommunityPool RPC +// method. +message QueryCommunityPoolRequest {} + +// QueryCommunityPoolResponse is the response type for the Query/CommunityPool +// RPC method. +message QueryCommunityPoolResponse { + // pool defines community pool's coins. + repeated cosmos.base.v1beta1.DecCoin pool = 1 + [(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", (gogoproto.nullable) = false]; +} diff --git a/third_party/proto/cosmos/distribution/v1beta1/tx.proto b/third_party/proto/cosmos/distribution/v1beta1/tx.proto new file mode 100644 index 0000000..e6ce478 --- /dev/null +++ b/third_party/proto/cosmos/distribution/v1beta1/tx.proto @@ -0,0 +1,79 @@ +syntax = "proto3"; +package cosmos.distribution.v1beta1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/distribution/types"; +option (gogoproto.equal_all) = true; + +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; + +// Msg defines the distribution Msg service. +service Msg { + // SetWithdrawAddress defines a method to change the withdraw address + // for a delegator (or validator self-delegation). + rpc SetWithdrawAddress(MsgSetWithdrawAddress) returns (MsgSetWithdrawAddressResponse); + + // WithdrawDelegatorReward defines a method to withdraw rewards of delegator + // from a single validator. + rpc WithdrawDelegatorReward(MsgWithdrawDelegatorReward) returns (MsgWithdrawDelegatorRewardResponse); + + // WithdrawValidatorCommission defines a method to withdraw the + // full commission to the validator address. + rpc WithdrawValidatorCommission(MsgWithdrawValidatorCommission) returns (MsgWithdrawValidatorCommissionResponse); + + // FundCommunityPool defines a method to allow an account to directly + // fund the community pool. + rpc FundCommunityPool(MsgFundCommunityPool) returns (MsgFundCommunityPoolResponse); +} + +// MsgSetWithdrawAddress sets the withdraw address for +// a delegator (or validator self-delegation). +message MsgSetWithdrawAddress { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""]; + string withdraw_address = 2 [(gogoproto.moretags) = "yaml:\"withdraw_address\""]; +} + +// MsgSetWithdrawAddressResponse defines the Msg/SetWithdrawAddress response type. +message MsgSetWithdrawAddressResponse {} + +// MsgWithdrawDelegatorReward represents delegation withdrawal to a delegator +// from a single validator. +message MsgWithdrawDelegatorReward { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""]; + string validator_address = 2 [(gogoproto.moretags) = "yaml:\"validator_address\""]; +} + +// MsgWithdrawDelegatorRewardResponse defines the Msg/WithdrawDelegatorReward response type. +message MsgWithdrawDelegatorRewardResponse {} + +// MsgWithdrawValidatorCommission withdraws the full commission to the validator +// address. +message MsgWithdrawValidatorCommission { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string validator_address = 1 [(gogoproto.moretags) = "yaml:\"validator_address\""]; +} + +// MsgWithdrawValidatorCommissionResponse defines the Msg/WithdrawValidatorCommission response type. +message MsgWithdrawValidatorCommissionResponse {} + +// MsgFundCommunityPool allows an account to directly +// fund the community pool. +message MsgFundCommunityPool { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + repeated cosmos.base.v1beta1.Coin amount = 1 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; + string depositor = 2; +} + +// MsgFundCommunityPoolResponse defines the Msg/FundCommunityPool response type. +message MsgFundCommunityPoolResponse {} diff --git a/third_party/proto/cosmos/evidence/v1beta1/evidence.proto b/third_party/proto/cosmos/evidence/v1beta1/evidence.proto new file mode 100644 index 0000000..14612c3 --- /dev/null +++ b/third_party/proto/cosmos/evidence/v1beta1/evidence.proto @@ -0,0 +1,21 @@ +syntax = "proto3"; +package cosmos.evidence.v1beta1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/evidence/types"; +option (gogoproto.equal_all) = true; + +import "gogoproto/gogo.proto"; +import "google/protobuf/timestamp.proto"; + +// Equivocation implements the Evidence interface and defines evidence of double +// signing misbehavior. +message Equivocation { + option (gogoproto.goproto_stringer) = false; + option (gogoproto.goproto_getters) = false; + option (gogoproto.equal) = false; + + int64 height = 1; + google.protobuf.Timestamp time = 2 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; + int64 power = 3; + string consensus_address = 4 [(gogoproto.moretags) = "yaml:\"consensus_address\""]; +} \ No newline at end of file diff --git a/third_party/proto/cosmos/evidence/v1beta1/genesis.proto b/third_party/proto/cosmos/evidence/v1beta1/genesis.proto new file mode 100644 index 0000000..199f446 --- /dev/null +++ b/third_party/proto/cosmos/evidence/v1beta1/genesis.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; +package cosmos.evidence.v1beta1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/evidence/types"; + +import "google/protobuf/any.proto"; + +// GenesisState defines the evidence module's genesis state. +message GenesisState { + // evidence defines all the evidence at genesis. + repeated google.protobuf.Any evidence = 1; +} diff --git a/third_party/proto/cosmos/evidence/v1beta1/query.proto b/third_party/proto/cosmos/evidence/v1beta1/query.proto new file mode 100644 index 0000000..eda0054 --- /dev/null +++ b/third_party/proto/cosmos/evidence/v1beta1/query.proto @@ -0,0 +1,51 @@ +syntax = "proto3"; +package cosmos.evidence.v1beta1; + +import "cosmos/base/query/v1beta1/pagination.proto"; +import "gogoproto/gogo.proto"; +import "google/protobuf/any.proto"; +import "google/api/annotations.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/evidence/types"; + +// Query defines the gRPC querier service. +service Query { + // Evidence queries evidence based on evidence hash. + rpc Evidence(QueryEvidenceRequest) returns (QueryEvidenceResponse) { + option (google.api.http).get = "/cosmos/evidence/v1beta1/evidence/{evidence_hash}"; + } + + // AllEvidence queries all evidence. + rpc AllEvidence(QueryAllEvidenceRequest) returns (QueryAllEvidenceResponse) { + option (google.api.http).get = "/cosmos/evidence/v1beta1/evidence"; + } +} + +// QueryEvidenceRequest is the request type for the Query/Evidence RPC method. +message QueryEvidenceRequest { + // evidence_hash defines the hash of the requested evidence. + bytes evidence_hash = 1 [(gogoproto.casttype) = "github.com/tendermint/tendermint/libs/bytes.HexBytes"]; +} + +// QueryEvidenceResponse is the response type for the Query/Evidence RPC method. +message QueryEvidenceResponse { + // evidence returns the requested evidence. + google.protobuf.Any evidence = 1; +} + +// QueryEvidenceRequest is the request type for the Query/AllEvidence RPC +// method. +message QueryAllEvidenceRequest { + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 1; +} + +// QueryAllEvidenceResponse is the response type for the Query/AllEvidence RPC +// method. +message QueryAllEvidenceResponse { + // evidence returns all evidences. + repeated google.protobuf.Any evidence = 1; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} diff --git a/third_party/proto/cosmos/evidence/v1beta1/tx.proto b/third_party/proto/cosmos/evidence/v1beta1/tx.proto new file mode 100644 index 0000000..38795f2 --- /dev/null +++ b/third_party/proto/cosmos/evidence/v1beta1/tx.proto @@ -0,0 +1,32 @@ +syntax = "proto3"; +package cosmos.evidence.v1beta1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/evidence/types"; +option (gogoproto.equal_all) = true; + +import "gogoproto/gogo.proto"; +import "google/protobuf/any.proto"; +import "cosmos_proto/cosmos.proto"; + +// Msg defines the evidence Msg service. +service Msg { + // SubmitEvidence submits an arbitrary Evidence of misbehavior such as equivocation or + // counterfactual signing. + rpc SubmitEvidence(MsgSubmitEvidence) returns (MsgSubmitEvidenceResponse); +} + +// MsgSubmitEvidence represents a message that supports submitting arbitrary +// Evidence of misbehavior such as equivocation or counterfactual signing. +message MsgSubmitEvidence { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string submitter = 1; + google.protobuf.Any evidence = 2 [(cosmos_proto.accepts_interface) = "Evidence"]; +} + +// MsgSubmitEvidenceResponse defines the Msg/SubmitEvidence response type. +message MsgSubmitEvidenceResponse { + // hash defines the hash of the evidence. + bytes hash = 4; +} diff --git a/third_party/proto/cosmos/genutil/v1beta1/genesis.proto b/third_party/proto/cosmos/genutil/v1beta1/genesis.proto new file mode 100644 index 0000000..a020779 --- /dev/null +++ b/third_party/proto/cosmos/genutil/v1beta1/genesis.proto @@ -0,0 +1,16 @@ +syntax = "proto3"; +package cosmos.genutil.v1beta1; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/genutil/types"; + +// GenesisState defines the raw genesis transaction in JSON. +message GenesisState { + // gen_txs defines the genesis transactions. + repeated bytes gen_txs = 1 [ + (gogoproto.casttype) = "encoding/json.RawMessage", + (gogoproto.jsontag) = "gentxs", + (gogoproto.moretags) = "yaml:\"gentxs\"" + ]; +} diff --git a/third_party/proto/cosmos/gov/v1beta1/genesis.proto b/third_party/proto/cosmos/gov/v1beta1/genesis.proto new file mode 100644 index 0000000..a999500 --- /dev/null +++ b/third_party/proto/cosmos/gov/v1beta1/genesis.proto @@ -0,0 +1,26 @@ +syntax = "proto3"; + +package cosmos.gov.v1beta1; + +import "gogoproto/gogo.proto"; +import "cosmos/gov/v1beta1/gov.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types"; + +// GenesisState defines the gov module's genesis state. +message GenesisState { + // starting_proposal_id is the ID of the starting proposal. + uint64 starting_proposal_id = 1 [(gogoproto.moretags) = "yaml:\"starting_proposal_id\""]; + // deposits defines all the deposits present at genesis. + repeated Deposit deposits = 2 [(gogoproto.castrepeated) = "Deposits", (gogoproto.nullable) = false]; + // votes defines all the votes present at genesis. + repeated Vote votes = 3 [(gogoproto.castrepeated) = "Votes", (gogoproto.nullable) = false]; + // proposals defines all the proposals present at genesis. + repeated Proposal proposals = 4 [(gogoproto.castrepeated) = "Proposals", (gogoproto.nullable) = false]; + // params defines all the paramaters of related to deposit. + DepositParams deposit_params = 5 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"deposit_params\""]; + // params defines all the paramaters of related to voting. + VotingParams voting_params = 6 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"voting_params\""]; + // params defines all the paramaters of related to tally. + TallyParams tally_params = 7 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"tally_params\""]; +} diff --git a/third_party/proto/cosmos/gov/v1beta1/gov.proto b/third_party/proto/cosmos/gov/v1beta1/gov.proto new file mode 100644 index 0000000..1d72e64 --- /dev/null +++ b/third_party/proto/cosmos/gov/v1beta1/gov.proto @@ -0,0 +1,183 @@ +syntax = "proto3"; +package cosmos.gov.v1beta1; + +import "cosmos/base/v1beta1/coin.proto"; +import "gogoproto/gogo.proto"; +import "cosmos_proto/cosmos.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/any.proto"; +import "google/protobuf/duration.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types"; +option (gogoproto.goproto_stringer_all) = false; +option (gogoproto.stringer_all) = false; +option (gogoproto.goproto_getters_all) = false; + +// VoteOption enumerates the valid vote options for a given governance proposal. +enum VoteOption { + option (gogoproto.goproto_enum_prefix) = false; + + // VOTE_OPTION_UNSPECIFIED defines a no-op vote option. + VOTE_OPTION_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "OptionEmpty"]; + // VOTE_OPTION_YES defines a yes vote option. + VOTE_OPTION_YES = 1 [(gogoproto.enumvalue_customname) = "OptionYes"]; + // VOTE_OPTION_ABSTAIN defines an abstain vote option. + VOTE_OPTION_ABSTAIN = 2 [(gogoproto.enumvalue_customname) = "OptionAbstain"]; + // VOTE_OPTION_NO defines a no vote option. + VOTE_OPTION_NO = 3 [(gogoproto.enumvalue_customname) = "OptionNo"]; + // VOTE_OPTION_NO_WITH_VETO defines a no with veto vote option. + VOTE_OPTION_NO_WITH_VETO = 4 [(gogoproto.enumvalue_customname) = "OptionNoWithVeto"]; +} + +// TextProposal defines a standard text proposal whose changes need to be +// manually updated in case of approval. +message TextProposal { + option (cosmos_proto.implements_interface) = "Content"; + + option (gogoproto.equal) = true; + + string title = 1; + string description = 2; +} + +// Deposit defines an amount deposited by an account address to an active +// proposal. +message Deposit { + option (gogoproto.goproto_getters) = false; + option (gogoproto.equal) = false; + + uint64 proposal_id = 1 [(gogoproto.moretags) = "yaml:\"proposal_id\""]; + string depositor = 2; + repeated cosmos.base.v1beta1.Coin amount = 3 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; +} + +// Proposal defines the core field members of a governance proposal. +message Proposal { + option (gogoproto.equal) = true; + + uint64 proposal_id = 1 [(gogoproto.jsontag) = "id", (gogoproto.moretags) = "yaml:\"id\""]; + google.protobuf.Any content = 2 [(cosmos_proto.accepts_interface) = "Content"]; + ProposalStatus status = 3 [(gogoproto.moretags) = "yaml:\"proposal_status\""]; + TallyResult final_tally_result = 4 + [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"final_tally_result\""]; + google.protobuf.Timestamp submit_time = 5 + [(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"submit_time\""]; + google.protobuf.Timestamp deposit_end_time = 6 + [(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"deposit_end_time\""]; + repeated cosmos.base.v1beta1.Coin total_deposit = 7 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", + (gogoproto.moretags) = "yaml:\"total_deposit\"" + ]; + google.protobuf.Timestamp voting_start_time = 8 + [(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"voting_start_time\""]; + google.protobuf.Timestamp voting_end_time = 9 + [(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"voting_end_time\""]; +} + +// ProposalStatus enumerates the valid statuses of a proposal. +enum ProposalStatus { + option (gogoproto.goproto_enum_prefix) = false; + + // PROPOSAL_STATUS_UNSPECIFIED defines the default propopsal status. + PROPOSAL_STATUS_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "StatusNil"]; + // PROPOSAL_STATUS_DEPOSIT_PERIOD defines a proposal status during the deposit + // period. + PROPOSAL_STATUS_DEPOSIT_PERIOD = 1 [(gogoproto.enumvalue_customname) = "StatusDepositPeriod"]; + // PROPOSAL_STATUS_VOTING_PERIOD defines a proposal status during the voting + // period. + PROPOSAL_STATUS_VOTING_PERIOD = 2 [(gogoproto.enumvalue_customname) = "StatusVotingPeriod"]; + // PROPOSAL_STATUS_PASSED defines a proposal status of a proposal that has + // passed. + PROPOSAL_STATUS_PASSED = 3 [(gogoproto.enumvalue_customname) = "StatusPassed"]; + // PROPOSAL_STATUS_REJECTED defines a proposal status of a proposal that has + // been rejected. + PROPOSAL_STATUS_REJECTED = 4 [(gogoproto.enumvalue_customname) = "StatusRejected"]; + // PROPOSAL_STATUS_FAILED defines a proposal status of a proposal that has + // failed. + PROPOSAL_STATUS_FAILED = 5 [(gogoproto.enumvalue_customname) = "StatusFailed"]; +} + +// TallyResult defines a standard tally for a governance proposal. +message TallyResult { + option (gogoproto.equal) = true; + + string yes = 1 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; + string abstain = 2 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; + string no = 3 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; + string no_with_veto = 4 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"no_with_veto\"" + ]; +} + +// Vote defines a vote on a governance proposal. +// A Vote consists of a proposal ID, the voter, and the vote option. +message Vote { + option (gogoproto.goproto_stringer) = false; + option (gogoproto.equal) = false; + + uint64 proposal_id = 1 [(gogoproto.moretags) = "yaml:\"proposal_id\""]; + string voter = 2; + VoteOption option = 3; +} + +// DepositParams defines the params for deposits on governance proposals. +message DepositParams { + // Minimum deposit for a proposal to enter voting period. + repeated cosmos.base.v1beta1.Coin min_deposit = 1 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", + (gogoproto.moretags) = "yaml:\"min_deposit\"", + (gogoproto.jsontag) = "min_deposit,omitempty" + ]; + + // Maximum period for Atom holders to deposit on a proposal. Initial value: 2 + // months. + google.protobuf.Duration max_deposit_period = 2 [ + (gogoproto.nullable) = false, + (gogoproto.stdduration) = true, + (gogoproto.jsontag) = "max_deposit_period,omitempty", + (gogoproto.moretags) = "yaml:\"max_deposit_period\"" + ]; +} + +// VotingParams defines the params for voting on governance proposals. +message VotingParams { + // Length of the voting period. + google.protobuf.Duration voting_period = 1 [ + (gogoproto.nullable) = false, + (gogoproto.stdduration) = true, + (gogoproto.jsontag) = "voting_period,omitempty", + (gogoproto.moretags) = "yaml:\"voting_period\"" + ]; +} + +// TallyParams defines the params for tallying votes on governance proposals. +message TallyParams { + // Minimum percentage of total stake needed to vote for a result to be + // considered valid. + bytes quorum = 1 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false, + (gogoproto.jsontag) = "quorum,omitempty" + ]; + + // Minimum proportion of Yes votes for proposal to pass. Default value: 0.5. + bytes threshold = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false, + (gogoproto.jsontag) = "threshold,omitempty" + ]; + + // Minimum value of Veto votes to Total votes ratio for proposal to be + // vetoed. Default value: 1/3. + bytes veto_threshold = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false, + (gogoproto.jsontag) = "veto_threshold,omitempty", + (gogoproto.moretags) = "yaml:\"veto_threshold\"" + ]; +} diff --git a/third_party/proto/cosmos/gov/v1beta1/query.proto b/third_party/proto/cosmos/gov/v1beta1/query.proto new file mode 100644 index 0000000..da62bdb --- /dev/null +++ b/third_party/proto/cosmos/gov/v1beta1/query.proto @@ -0,0 +1,190 @@ +syntax = "proto3"; +package cosmos.gov.v1beta1; + +import "cosmos/base/query/v1beta1/pagination.proto"; +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "cosmos/gov/v1beta1/gov.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types"; + +// Query defines the gRPC querier service for gov module +service Query { + // Proposal queries proposal details based on ProposalID. + rpc Proposal(QueryProposalRequest) returns (QueryProposalResponse) { + option (google.api.http).get = "/cosmos/gov/v1beta1/proposals/{proposal_id}"; + } + + // Proposals queries all proposals based on given status. + rpc Proposals(QueryProposalsRequest) returns (QueryProposalsResponse) { + option (google.api.http).get = "/cosmos/gov/v1beta1/proposals"; + } + + // Vote queries voted information based on proposalID, voterAddr. + rpc Vote(QueryVoteRequest) returns (QueryVoteResponse) { + option (google.api.http).get = "/cosmos/gov/v1beta1/proposals/{proposal_id}/votes/{voter}"; + } + + // Votes queries votes of a given proposal. + rpc Votes(QueryVotesRequest) returns (QueryVotesResponse) { + option (google.api.http).get = "/cosmos/gov/v1beta1/proposals/{proposal_id}/votes"; + } + + // Params queries all parameters of the gov module. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/cosmos/gov/v1beta1/params/{params_type}"; + } + + // Deposit queries single deposit information based proposalID, depositAddr. + rpc Deposit(QueryDepositRequest) returns (QueryDepositResponse) { + option (google.api.http).get = "/cosmos/gov/v1beta1/proposals/{proposal_id}/deposits/{depositor}"; + } + + // Deposits queries all deposits of a single proposal. + rpc Deposits(QueryDepositsRequest) returns (QueryDepositsResponse) { + option (google.api.http).get = "/cosmos/gov/v1beta1/proposals/{proposal_id}/deposits"; + } + + // TallyResult queries the tally of a proposal vote. + rpc TallyResult(QueryTallyResultRequest) returns (QueryTallyResultResponse) { + option (google.api.http).get = "/cosmos/gov/v1beta1/proposals/{proposal_id}/tally"; + } +} + +// QueryProposalRequest is the request type for the Query/Proposal RPC method. +message QueryProposalRequest { + // proposal_id defines the unique id of the proposal. + uint64 proposal_id = 1; +} + +// QueryProposalResponse is the response type for the Query/Proposal RPC method. +message QueryProposalResponse { + Proposal proposal = 1 [(gogoproto.nullable) = false]; +} + +// QueryProposalsRequest is the request type for the Query/Proposals RPC method. +message QueryProposalsRequest { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // proposal_status defines the status of the proposals. + ProposalStatus proposal_status = 1; + + // voter defines the voter address for the proposals. + string voter = 2; + + // depositor defines the deposit addresses from the proposals. + string depositor = 3; + + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 4; +} + +// QueryProposalsResponse is the response type for the Query/Proposals RPC +// method. +message QueryProposalsResponse { + repeated Proposal proposals = 1 [(gogoproto.nullable) = false]; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryVoteRequest is the request type for the Query/Vote RPC method. +message QueryVoteRequest { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // proposal_id defines the unique id of the proposal. + uint64 proposal_id = 1; + + // voter defines the oter address for the proposals. + string voter = 2; +} + +// QueryVoteResponse is the response type for the Query/Vote RPC method. +message QueryVoteResponse { + // vote defined the queried vote. + Vote vote = 1 [(gogoproto.nullable) = false]; +} + +// QueryVotesRequest is the request type for the Query/Votes RPC method. +message QueryVotesRequest { + // proposal_id defines the unique id of the proposal. + uint64 proposal_id = 1; + + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// QueryVotesResponse is the response type for the Query/Votes RPC method. +message QueryVotesResponse { + // votes defined the queried votes. + repeated Vote votes = 1 [(gogoproto.nullable) = false]; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryParamsRequest is the request type for the Query/Params RPC method. +message QueryParamsRequest { + // params_type defines which parameters to query for, can be one of "voting", + // "tallying" or "deposit". + string params_type = 1; +} + +// QueryParamsResponse is the response type for the Query/Params RPC method. +message QueryParamsResponse { + // voting_params defines the parameters related to voting. + VotingParams voting_params = 1 [(gogoproto.nullable) = false]; + // deposit_params defines the parameters related to deposit. + DepositParams deposit_params = 2 [(gogoproto.nullable) = false]; + // tally_params defines the parameters related to tally. + TallyParams tally_params = 3 [(gogoproto.nullable) = false]; +} + +// QueryDepositRequest is the request type for the Query/Deposit RPC method. +message QueryDepositRequest { + option (gogoproto.goproto_getters) = false; + option (gogoproto.equal) = false; + + // proposal_id defines the unique id of the proposal. + uint64 proposal_id = 1; + + // depositor defines the deposit addresses from the proposals. + string depositor = 2; +} + +// QueryDepositResponse is the response type for the Query/Deposit RPC method. +message QueryDepositResponse { + // deposit defines the requested deposit. + Deposit deposit = 1 [(gogoproto.nullable) = false]; +} + +// QueryDepositsRequest is the request type for the Query/Deposits RPC method. +message QueryDepositsRequest { + // proposal_id defines the unique id of the proposal. + uint64 proposal_id = 1; + + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// QueryDepositsResponse is the response type for the Query/Deposits RPC method. +message QueryDepositsResponse { + repeated Deposit deposits = 1 [(gogoproto.nullable) = false]; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryTallyResultRequest is the request type for the Query/Tally RPC method. +message QueryTallyResultRequest { + // proposal_id defines the unique id of the proposal. + uint64 proposal_id = 1; +} + +// QueryTallyResultResponse is the response type for the Query/Tally RPC method. +message QueryTallyResultResponse { + // tally defines the requested tally. + TallyResult tally = 1 [(gogoproto.nullable) = false]; +} diff --git a/third_party/proto/cosmos/gov/v1beta1/tx.proto b/third_party/proto/cosmos/gov/v1beta1/tx.proto new file mode 100644 index 0000000..d4f0c1f --- /dev/null +++ b/third_party/proto/cosmos/gov/v1beta1/tx.proto @@ -0,0 +1,75 @@ +syntax = "proto3"; +package cosmos.gov.v1beta1; + +import "cosmos/base/v1beta1/coin.proto"; +import "cosmos/gov/v1beta1/gov.proto"; +import "cosmos_proto/cosmos.proto"; +import "gogoproto/gogo.proto"; +import "google/protobuf/any.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types"; + +// Msg defines the bank Msg service. +service Msg { + // SubmitProposal defines a method to create new proposal given a content. + rpc SubmitProposal(MsgSubmitProposal) returns (MsgSubmitProposalResponse); + + // Vote defines a method to add a vote on a specific proposal. + rpc Vote(MsgVote) returns (MsgVoteResponse); + + // Deposit defines a method to add deposit on a specific proposal. + rpc Deposit(MsgDeposit) returns (MsgDepositResponse); +} + +// MsgSubmitProposal defines an sdk.Msg type that supports submitting arbitrary +// proposal Content. +message MsgSubmitProposal { + option (gogoproto.equal) = false; + option (gogoproto.goproto_stringer) = false; + option (gogoproto.stringer) = false; + option (gogoproto.goproto_getters) = false; + + google.protobuf.Any content = 1 [(cosmos_proto.accepts_interface) = "Content"]; + repeated cosmos.base.v1beta1.Coin initial_deposit = 2 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", + (gogoproto.moretags) = "yaml:\"initial_deposit\"" + ]; + string proposer = 3; +} + +// MsgSubmitProposalResponse defines the Msg/SubmitProposal response type. +message MsgSubmitProposalResponse { + uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (gogoproto.moretags) = "yaml:\"proposal_id\""]; +} + +// MsgVote defines a message to cast a vote. +message MsgVote { + option (gogoproto.equal) = false; + option (gogoproto.goproto_stringer) = false; + option (gogoproto.stringer) = false; + option (gogoproto.goproto_getters) = false; + + uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (gogoproto.moretags) = "yaml:\"proposal_id\""]; + string voter = 2; + VoteOption option = 3; +} + +// MsgVoteResponse defines the Msg/Vote response type. +message MsgVoteResponse {} + +// MsgDeposit defines a message to submit a deposit to an existing proposal. +message MsgDeposit { + option (gogoproto.equal) = false; + option (gogoproto.goproto_stringer) = false; + option (gogoproto.stringer) = false; + option (gogoproto.goproto_getters) = false; + + uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (gogoproto.moretags) = "yaml:\"proposal_id\""]; + string depositor = 2; + repeated cosmos.base.v1beta1.Coin amount = 3 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; +} + +// MsgDepositResponse defines the Msg/Deposit response type. +message MsgDepositResponse {} diff --git a/third_party/proto/cosmos/mint/v1beta1/genesis.proto b/third_party/proto/cosmos/mint/v1beta1/genesis.proto new file mode 100644 index 0000000..4e783fb --- /dev/null +++ b/third_party/proto/cosmos/mint/v1beta1/genesis.proto @@ -0,0 +1,16 @@ +syntax = "proto3"; +package cosmos.mint.v1beta1; + +import "gogoproto/gogo.proto"; +import "cosmos/mint/v1beta1/mint.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/mint/types"; + +// GenesisState defines the mint module's genesis state. +message GenesisState { + // minter is a space for holding current inflation information. + Minter minter = 1 [(gogoproto.nullable) = false]; + + // params defines all the paramaters of the module. + Params params = 2 [(gogoproto.nullable) = false]; +} diff --git a/third_party/proto/cosmos/mint/v1beta1/mint.proto b/third_party/proto/cosmos/mint/v1beta1/mint.proto new file mode 100644 index 0000000..f94d4ae --- /dev/null +++ b/third_party/proto/cosmos/mint/v1beta1/mint.proto @@ -0,0 +1,53 @@ +syntax = "proto3"; +package cosmos.mint.v1beta1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/mint/types"; + +import "gogoproto/gogo.proto"; + +// Minter represents the minting state. +message Minter { + // current annual inflation rate + string inflation = 1 + [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; + // current annual expected provisions + string annual_provisions = 2 [ + (gogoproto.moretags) = "yaml:\"annual_provisions\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; +} + +// Params holds parameters for the mint module. +message Params { + option (gogoproto.goproto_stringer) = false; + + // type of coin to mint + string mint_denom = 1; + // maximum annual change in inflation rate + string inflation_rate_change = 2 [ + (gogoproto.moretags) = "yaml:\"inflation_rate_change\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + // maximum inflation rate + string inflation_max = 3 [ + (gogoproto.moretags) = "yaml:\"inflation_max\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + // minimum inflation rate + string inflation_min = 4 [ + (gogoproto.moretags) = "yaml:\"inflation_min\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + // goal of percent bonded atoms + string goal_bonded = 5 [ + (gogoproto.moretags) = "yaml:\"goal_bonded\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + // expected blocks per year + uint64 blocks_per_year = 6 [(gogoproto.moretags) = "yaml:\"blocks_per_year\""]; +} diff --git a/third_party/proto/cosmos/mint/v1beta1/query.proto b/third_party/proto/cosmos/mint/v1beta1/query.proto new file mode 100644 index 0000000..acd341d --- /dev/null +++ b/third_party/proto/cosmos/mint/v1beta1/query.proto @@ -0,0 +1,57 @@ +syntax = "proto3"; +package cosmos.mint.v1beta1; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "cosmos/mint/v1beta1/mint.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/mint/types"; + +// Query provides defines the gRPC querier service. +service Query { + // Params returns the total set of minting parameters. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/cosmos/mint/v1beta1/params"; + } + + // Inflation returns the current minting inflation value. + rpc Inflation(QueryInflationRequest) returns (QueryInflationResponse) { + option (google.api.http).get = "/cosmos/mint/v1beta1/inflation"; + } + + // AnnualProvisions current minting annual provisions value. + rpc AnnualProvisions(QueryAnnualProvisionsRequest) returns (QueryAnnualProvisionsResponse) { + option (google.api.http).get = "/cosmos/mint/v1beta1/annual_provisions"; + } +} + +// QueryParamsRequest is the request type for the Query/Params RPC method. +message QueryParamsRequest {} + +// QueryParamsResponse is the response type for the Query/Params RPC method. +message QueryParamsResponse { + // params defines the parameters of the module. + Params params = 1 [(gogoproto.nullable) = false]; +} + +// QueryInflationRequest is the request type for the Query/Inflation RPC method. +message QueryInflationRequest {} + +// QueryInflationResponse is the response type for the Query/Inflation RPC +// method. +message QueryInflationResponse { + // inflation is the current minting inflation value. + bytes inflation = 1 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; +} + +// QueryAnnualProvisionsRequest is the request type for the +// Query/AnnualProvisions RPC method. +message QueryAnnualProvisionsRequest {} + +// QueryAnnualProvisionsResponse is the response type for the +// Query/AnnualProvisions RPC method. +message QueryAnnualProvisionsResponse { + // annual_provisions is the current minting annual provisions value. + bytes annual_provisions = 1 + [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; +} diff --git a/third_party/proto/cosmos/params/v1beta1/params.proto b/third_party/proto/cosmos/params/v1beta1/params.proto new file mode 100644 index 0000000..5382fd7 --- /dev/null +++ b/third_party/proto/cosmos/params/v1beta1/params.proto @@ -0,0 +1,27 @@ +syntax = "proto3"; +package cosmos.params.v1beta1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/params/types/proposal"; +option (gogoproto.equal_all) = true; + +import "gogoproto/gogo.proto"; + +// ParameterChangeProposal defines a proposal to change one or more parameters. +message ParameterChangeProposal { + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = false; + + string title = 1; + string description = 2; + repeated ParamChange changes = 3 [(gogoproto.nullable) = false]; +} + +// ParamChange defines an individual parameter change, for use in +// ParameterChangeProposal. +message ParamChange { + option (gogoproto.goproto_stringer) = false; + + string subspace = 1; + string key = 2; + string value = 3; +} diff --git a/third_party/proto/cosmos/params/v1beta1/query.proto b/third_party/proto/cosmos/params/v1beta1/query.proto new file mode 100644 index 0000000..1078e02 --- /dev/null +++ b/third_party/proto/cosmos/params/v1beta1/query.proto @@ -0,0 +1,32 @@ +syntax = "proto3"; +package cosmos.params.v1beta1; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "cosmos/params/v1beta1/params.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/params/types/proposal"; + +// Query defines the gRPC querier service. +service Query { + // Params queries a specific parameter of a module, given its subspace and + // key. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/cosmos/params/v1beta1/params"; + } +} + +// QueryParamsRequest is request type for the Query/Params RPC method. +message QueryParamsRequest { + // subspace defines the module to query the parameter for. + string subspace = 1; + + // key defines the key of the parameter in the subspace. + string key = 2; +} + +// QueryParamsResponse is response type for the Query/Params RPC method. +message QueryParamsResponse { + // param defines the queried parameter. + ParamChange param = 1 [(gogoproto.nullable) = false]; +} diff --git a/third_party/proto/cosmos/slashing/v1beta1/genesis.proto b/third_party/proto/cosmos/slashing/v1beta1/genesis.proto new file mode 100644 index 0000000..c813561 --- /dev/null +++ b/third_party/proto/cosmos/slashing/v1beta1/genesis.proto @@ -0,0 +1,50 @@ +syntax = "proto3"; +package cosmos.slashing.v1beta1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/slashing/types"; + +import "gogoproto/gogo.proto"; +import "cosmos/slashing/v1beta1/slashing.proto"; + +// GenesisState defines the slashing module's genesis state. +message GenesisState { + // params defines all the paramaters of related to deposit. + Params params = 1 [(gogoproto.nullable) = false]; + + // signing_infos represents a map between validator addresses and their + // signing infos. + repeated SigningInfo signing_infos = 2 + [(gogoproto.moretags) = "yaml:\"signing_infos\"", (gogoproto.nullable) = false]; + + // signing_infos represents a map between validator addresses and their + // missed blocks. + repeated ValidatorMissedBlocks missed_blocks = 3 + [(gogoproto.moretags) = "yaml:\"missed_blocks\"", (gogoproto.nullable) = false]; +} + +// SigningInfo stores validator signing info of corresponding address. +message SigningInfo { + // address is the validator address. + string address = 1; + // validator_signing_info represents the signing info of this validator. + ValidatorSigningInfo validator_signing_info = 2 + [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"validator_signing_info\""]; +} + +// ValidatorMissedBlocks contains array of missed blocks of corresponding +// address. +message ValidatorMissedBlocks { + // address is the validator address. + string address = 1; + // missed_blocks is an array of missed blocks by the validator. + repeated MissedBlock missed_blocks = 2 + [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"missed_blocks\""]; +} + +// MissedBlock contains height and missed status as boolean. +message MissedBlock { + // index is the height at which the block was missed. + int64 index = 1; + // missed is the missed status. + bool missed = 2; +} diff --git a/third_party/proto/cosmos/slashing/v1beta1/query.proto b/third_party/proto/cosmos/slashing/v1beta1/query.proto new file mode 100644 index 0000000..869049a --- /dev/null +++ b/third_party/proto/cosmos/slashing/v1beta1/query.proto @@ -0,0 +1,63 @@ +syntax = "proto3"; +package cosmos.slashing.v1beta1; + +import "cosmos/base/query/v1beta1/pagination.proto"; +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "cosmos/slashing/v1beta1/slashing.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/slashing/types"; + +// Query provides defines the gRPC querier service +service Query { + // Params queries the parameters of slashing module + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/cosmos/slashing/v1beta1/params"; + } + + // SigningInfo queries the signing info of given cons address + rpc SigningInfo(QuerySigningInfoRequest) returns (QuerySigningInfoResponse) { + option (google.api.http).get = "/cosmos/slashing/v1beta1/signing_infos/{cons_address}"; + } + + // SigningInfos queries signing info of all validators + rpc SigningInfos(QuerySigningInfosRequest) returns (QuerySigningInfosResponse) { + option (google.api.http).get = "/cosmos/slashing/v1beta1/signing_infos"; + } +} + +// QueryParamsRequest is the request type for the Query/Params RPC method +message QueryParamsRequest {} + +// QueryParamsResponse is the response type for the Query/Params RPC method +message QueryParamsResponse { + Params params = 1 [(gogoproto.nullable) = false]; +} + +// QuerySigningInfoRequest is the request type for the Query/SigningInfo RPC +// method +message QuerySigningInfoRequest { + // cons_address is the address to query signing info of + string cons_address = 1; +} + +// QuerySigningInfoResponse is the response type for the Query/SigningInfo RPC +// method +message QuerySigningInfoResponse { + // val_signing_info is the signing info of requested val cons address + ValidatorSigningInfo val_signing_info = 1 [(gogoproto.nullable) = false]; +} + +// QuerySigningInfosRequest is the request type for the Query/SigningInfos RPC +// method +message QuerySigningInfosRequest { + cosmos.base.query.v1beta1.PageRequest pagination = 1; +} + +// QuerySigningInfosResponse is the response type for the Query/SigningInfos RPC +// method +message QuerySigningInfosResponse { + // info is the signing info of all validators + repeated cosmos.slashing.v1beta1.ValidatorSigningInfo info = 1 [(gogoproto.nullable) = false]; + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} diff --git a/third_party/proto/cosmos/slashing/v1beta1/slashing.proto b/third_party/proto/cosmos/slashing/v1beta1/slashing.proto new file mode 100644 index 0000000..657a90f --- /dev/null +++ b/third_party/proto/cosmos/slashing/v1beta1/slashing.proto @@ -0,0 +1,55 @@ +syntax = "proto3"; +package cosmos.slashing.v1beta1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/slashing/types"; +option (gogoproto.equal_all) = true; + +import "gogoproto/gogo.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; + +// ValidatorSigningInfo defines a validator's signing info for monitoring their +// liveness activity. +message ValidatorSigningInfo { + option (gogoproto.equal) = true; + option (gogoproto.goproto_stringer) = false; + + string address = 1; + // height at which validator was first a candidate OR was unjailed + int64 start_height = 2 [(gogoproto.moretags) = "yaml:\"start_height\""]; + // index offset into signed block bit array + int64 index_offset = 3 [(gogoproto.moretags) = "yaml:\"index_offset\""]; + // timestamp validator cannot be unjailed until + google.protobuf.Timestamp jailed_until = 4 + [(gogoproto.moretags) = "yaml:\"jailed_until\"", (gogoproto.stdtime) = true, (gogoproto.nullable) = false]; + // whether or not a validator has been tombstoned (killed out of validator + // set) + bool tombstoned = 5; + // missed blocks counter (to avoid scanning the array every time) + int64 missed_blocks_counter = 6 [(gogoproto.moretags) = "yaml:\"missed_blocks_counter\""]; +} + +// Params represents the parameters used for by the slashing module. +message Params { + int64 signed_blocks_window = 1 [(gogoproto.moretags) = "yaml:\"signed_blocks_window\""]; + bytes min_signed_per_window = 2 [ + (gogoproto.moretags) = "yaml:\"min_signed_per_window\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + google.protobuf.Duration downtime_jail_duration = 3 [ + (gogoproto.nullable) = false, + (gogoproto.stdduration) = true, + (gogoproto.moretags) = "yaml:\"downtime_jail_duration\"" + ]; + bytes slash_fraction_double_sign = 4 [ + (gogoproto.moretags) = "yaml:\"slash_fraction_double_sign\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + bytes slash_fraction_downtime = 5 [ + (gogoproto.moretags) = "yaml:\"slash_fraction_downtime\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; +} diff --git a/third_party/proto/cosmos/slashing/v1beta1/tx.proto b/third_party/proto/cosmos/slashing/v1beta1/tx.proto new file mode 100644 index 0000000..4d63370 --- /dev/null +++ b/third_party/proto/cosmos/slashing/v1beta1/tx.proto @@ -0,0 +1,26 @@ +syntax = "proto3"; +package cosmos.slashing.v1beta1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/slashing/types"; +option (gogoproto.equal_all) = true; + +import "gogoproto/gogo.proto"; + +// Msg defines the slashing Msg service. +service Msg { + // Unjail defines a method for unjailing a jailed validator, thus returning + // them into the bonded validator set, so they can begin receiving provisions + // and rewards again. + rpc Unjail(MsgUnjail) returns (MsgUnjailResponse); +} + +// MsgUnjail defines the Msg/Unjail request type +message MsgUnjail { + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = true; + + string validator_addr = 1 [(gogoproto.moretags) = "yaml:\"address\"", (gogoproto.jsontag) = "address"]; +} + +// MsgUnjailResponse defines the Msg/Unjail response type +message MsgUnjailResponse {} \ No newline at end of file diff --git a/third_party/proto/cosmos/staking/v1beta1/genesis.proto b/third_party/proto/cosmos/staking/v1beta1/genesis.proto new file mode 100644 index 0000000..d1563db --- /dev/null +++ b/third_party/proto/cosmos/staking/v1beta1/genesis.proto @@ -0,0 +1,53 @@ +syntax = "proto3"; +package cosmos.staking.v1beta1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/staking/types"; + +import "gogoproto/gogo.proto"; +import "cosmos/staking/v1beta1/staking.proto"; + +// GenesisState defines the staking module's genesis state. +message GenesisState { + // params defines all the paramaters of related to deposit. + Params params = 1 [(gogoproto.nullable) = false]; + + // last_total_power tracks the total amounts of bonded tokens recorded during + // the previous end block. + bytes last_total_power = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.moretags) = "yaml:\"last_total_power\"", + (gogoproto.nullable) = false + ]; + + // last_validator_powers is a special index that provides a historical list + // of the last-block's bonded validators. + repeated LastValidatorPower last_validator_powers = 3 + [(gogoproto.moretags) = "yaml:\"last_validator_powers\"", (gogoproto.nullable) = false]; + + // delegations defines the validator set at genesis. + repeated Validator validators = 4 [(gogoproto.nullable) = false]; + + // delegations defines the delegations active at genesis. + repeated Delegation delegations = 5 [(gogoproto.nullable) = false]; + + // unbonding_delegations defines the unbonding delegations active at genesis. + repeated UnbondingDelegation unbonding_delegations = 6 + [(gogoproto.moretags) = "yaml:\"unbonding_delegations\"", (gogoproto.nullable) = false]; + + // redelegations defines the redelegations active at genesis. + repeated Redelegation redelegations = 7 [(gogoproto.nullable) = false]; + + bool exported = 8; +} + +// LastValidatorPower required for validator set update logic. +message LastValidatorPower { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // address is the address of the validator. + string address = 1; + + // power defines the power of the validator. + int64 power = 2; +} diff --git a/third_party/proto/cosmos/staking/v1beta1/query.proto b/third_party/proto/cosmos/staking/v1beta1/query.proto new file mode 100644 index 0000000..4852c53 --- /dev/null +++ b/third_party/proto/cosmos/staking/v1beta1/query.proto @@ -0,0 +1,348 @@ +syntax = "proto3"; +package cosmos.staking.v1beta1; + +import "cosmos/base/query/v1beta1/pagination.proto"; +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "cosmos/staking/v1beta1/staking.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/staking/types"; + +// Query defines the gRPC querier service. +service Query { + // Validators queries all validators that match the given status. + rpc Validators(QueryValidatorsRequest) returns (QueryValidatorsResponse) { + option (google.api.http).get = "/cosmos/staking/v1beta1/validators"; + } + + // Validator queries validator info for given validator address. + rpc Validator(QueryValidatorRequest) returns (QueryValidatorResponse) { + option (google.api.http).get = "/cosmos/staking/v1beta1/validators/{validator_addr}"; + } + + // ValidatorDelegations queries delegate info for given validator. + rpc ValidatorDelegations(QueryValidatorDelegationsRequest) returns (QueryValidatorDelegationsResponse) { + option (google.api.http).get = "/cosmos/staking/v1beta1/validators/{validator_addr}/delegations"; + } + + // ValidatorUnbondingDelegations queries unbonding delegations of a validator. + rpc ValidatorUnbondingDelegations(QueryValidatorUnbondingDelegationsRequest) + returns (QueryValidatorUnbondingDelegationsResponse) { + option (google.api.http).get = "/cosmos/staking/v1beta1/validators/" + "{validator_addr}/unbonding_delegations"; + } + + // Delegation queries delegate info for given validator delegator pair. + rpc Delegation(QueryDelegationRequest) returns (QueryDelegationResponse) { + option (google.api.http).get = "/cosmos/staking/v1beta1/validators/{validator_addr}/delegations/" + "{delegator_addr}"; + } + + // UnbondingDelegation queries unbonding info for given validator delegator + // pair. + rpc UnbondingDelegation(QueryUnbondingDelegationRequest) returns (QueryUnbondingDelegationResponse) { + option (google.api.http).get = "/cosmos/staking/v1beta1/validators/{validator_addr}/delegations/" + "{delegator_addr}/unbonding_delegation"; + } + + // DelegatorDelegations queries all delegations of a given delegator address. + rpc DelegatorDelegations(QueryDelegatorDelegationsRequest) returns (QueryDelegatorDelegationsResponse) { + option (google.api.http).get = "/cosmos/staking/v1beta1/delegations/{delegator_addr}"; + } + + // DelegatorUnbondingDelegations queries all unbonding delegations of a given + // delegator address. + rpc DelegatorUnbondingDelegations(QueryDelegatorUnbondingDelegationsRequest) + returns (QueryDelegatorUnbondingDelegationsResponse) { + option (google.api.http).get = "/cosmos/staking/v1beta1/delegators/" + "{delegator_addr}/unbonding_delegations"; + } + + // Redelegations queries redelegations of given address. + rpc Redelegations(QueryRedelegationsRequest) returns (QueryRedelegationsResponse) { + option (google.api.http).get = "/cosmos/staking/v1beta1/delegators/{delegator_addr}/redelegations"; + } + + // DelegatorValidators queries all validators info for given delegator + // address. + rpc DelegatorValidators(QueryDelegatorValidatorsRequest) returns (QueryDelegatorValidatorsResponse) { + option (google.api.http).get = "/cosmos/staking/v1beta1/delegators/{delegator_addr}/validators"; + } + + // DelegatorValidator queries validator info for given delegator validator + // pair. + rpc DelegatorValidator(QueryDelegatorValidatorRequest) returns (QueryDelegatorValidatorResponse) { + option (google.api.http).get = "/cosmos/staking/v1beta1/delegators/{delegator_addr}/validators/" + "{validator_addr}"; + } + + // HistoricalInfo queries the historical info for given height. + rpc HistoricalInfo(QueryHistoricalInfoRequest) returns (QueryHistoricalInfoResponse) { + option (google.api.http).get = "/cosmos/staking/v1beta1/historical_info/{height}"; + } + + // Pool queries the pool info. + rpc Pool(QueryPoolRequest) returns (QueryPoolResponse) { + option (google.api.http).get = "/cosmos/staking/v1beta1/pool"; + } + + // Parameters queries the staking parameters. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/cosmos/staking/v1beta1/params"; + } +} + +// QueryValidatorsRequest is request type for Query/Validators RPC method. +message QueryValidatorsRequest { + // status enables to query for validators matching a given status. + string status = 1; + + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// QueryValidatorsResponse is response type for the Query/Validators RPC method +message QueryValidatorsResponse { + // validators contains all the queried validators. + repeated Validator validators = 1 [(gogoproto.nullable) = false]; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryValidatorRequest is response type for the Query/Validator RPC method +message QueryValidatorRequest { + // validator_addr defines the validator address to query for. + string validator_addr = 1; +} + +// QueryValidatorResponse is response type for the Query/Validator RPC method +message QueryValidatorResponse { + // validator defines the the validator info. + Validator validator = 1 [(gogoproto.nullable) = false]; +} + +// QueryValidatorDelegationsRequest is request type for the +// Query/ValidatorDelegations RPC method +message QueryValidatorDelegationsRequest { + // validator_addr defines the validator address to query for. + string validator_addr = 1; + + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// QueryValidatorDelegationsResponse is response type for the +// Query/ValidatorDelegations RPC method +message QueryValidatorDelegationsResponse { + repeated DelegationResponse delegation_responses = 1 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "DelegationResponses"]; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryValidatorUnbondingDelegationsRequest is required type for the +// Query/ValidatorUnbondingDelegations RPC method +message QueryValidatorUnbondingDelegationsRequest { + // validator_addr defines the validator address to query for. + string validator_addr = 1; + + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// QueryValidatorUnbondingDelegationsResponse is response type for the +// Query/ValidatorUnbondingDelegations RPC method. +message QueryValidatorUnbondingDelegationsResponse { + repeated UnbondingDelegation unbonding_responses = 1 [(gogoproto.nullable) = false]; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryDelegationRequest is request type for the Query/Delegation RPC method. +message QueryDelegationRequest { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // delegator_addr defines the delegator address to query for. + string delegator_addr = 1; + + // validator_addr defines the validator address to query for. + string validator_addr = 2; +} + +// QueryDelegationResponse is response type for the Query/Delegation RPC method. +message QueryDelegationResponse { + // delegation_responses defines the delegation info of a delegation. + DelegationResponse delegation_response = 1; +} + +// QueryUnbondingDelegationRequest is request type for the +// Query/UnbondingDelegation RPC method. +message QueryUnbondingDelegationRequest { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // delegator_addr defines the delegator address to query for. + string delegator_addr = 1; + + // validator_addr defines the validator address to query for. + string validator_addr = 2; +} + +// QueryDelegationResponse is response type for the Query/UnbondingDelegation +// RPC method. +message QueryUnbondingDelegationResponse { + // unbond defines the unbonding information of a delegation. + UnbondingDelegation unbond = 1 [(gogoproto.nullable) = false]; +} + +// QueryDelegatorDelegationsRequest is request type for the +// Query/DelegatorDelegations RPC method. +message QueryDelegatorDelegationsRequest { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // delegator_addr defines the delegator address to query for. + string delegator_addr = 1; + + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// QueryDelegatorDelegationsResponse is response type for the +// Query/DelegatorDelegations RPC method. +message QueryDelegatorDelegationsResponse { + // delegation_responses defines all the delegations' info of a delegator. + repeated DelegationResponse delegation_responses = 1 [(gogoproto.nullable) = false]; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryDelegatorUnbondingDelegationsRequest is request type for the +// Query/DelegatorUnbondingDelegations RPC method. +message QueryDelegatorUnbondingDelegationsRequest { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // delegator_addr defines the delegator address to query for. + string delegator_addr = 1; + + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// QueryUnbondingDelegatorDelegationsResponse is response type for the +// Query/UnbondingDelegatorDelegations RPC method. +message QueryDelegatorUnbondingDelegationsResponse { + repeated UnbondingDelegation unbonding_responses = 1 [(gogoproto.nullable) = false]; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryRedelegationsRequest is request type for the Query/Redelegations RPC +// method. +message QueryRedelegationsRequest { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // delegator_addr defines the delegator address to query for. + string delegator_addr = 1; + + // src_validator_addr defines the validator address to redelegate from. + string src_validator_addr = 2; + + // dst_validator_addr defines the validator address to redelegate to. + string dst_validator_addr = 3; + + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 4; +} + +// QueryRedelegationsResponse is response type for the Query/Redelegations RPC +// method. +message QueryRedelegationsResponse { + repeated RedelegationResponse redelegation_responses = 1 [(gogoproto.nullable) = false]; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryDelegatorValidatorsRequest is request type for the +// Query/DelegatorValidators RPC method. +message QueryDelegatorValidatorsRequest { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // delegator_addr defines the delegator address to query for. + string delegator_addr = 1; + + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// QueryDelegatorValidatorsResponse is response type for the +// Query/DelegatorValidators RPC method. +message QueryDelegatorValidatorsResponse { + // validators defines the the validators' info of a delegator. + repeated Validator validators = 1 [(gogoproto.nullable) = false]; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryDelegatorValidatorRequest is request type for the +// Query/DelegatorValidator RPC method. +message QueryDelegatorValidatorRequest { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // delegator_addr defines the delegator address to query for. + string delegator_addr = 1; + + // validator_addr defines the validator address to query for. + string validator_addr = 2; +} + +// QueryDelegatorValidatorResponse response type for the +// Query/DelegatorValidator RPC method. +message QueryDelegatorValidatorResponse { + // validator defines the the validator info. + Validator validator = 1 [(gogoproto.nullable) = false]; +} + +// QueryHistoricalInfoRequest is request type for the Query/HistoricalInfo RPC +// method. +message QueryHistoricalInfoRequest { + // height defines at which height to query the historical info. + int64 height = 1; +} + +// QueryHistoricalInfoResponse is response type for the Query/HistoricalInfo RPC +// method. +message QueryHistoricalInfoResponse { + // hist defines the historical info at the given height. + HistoricalInfo hist = 1; +} + +// QueryPoolRequest is request type for the Query/Pool RPC method. +message QueryPoolRequest {} + +// QueryPoolResponse is response type for the Query/Pool RPC method. +message QueryPoolResponse { + // pool defines the pool info. + Pool pool = 1 [(gogoproto.nullable) = false]; +} + +// QueryParamsRequest is request type for the Query/Params RPC method. +message QueryParamsRequest {} + +// QueryParamsResponse is response type for the Query/Params RPC method. +message QueryParamsResponse { + // params holds all the parameters of this module. + Params params = 1 [(gogoproto.nullable) = false]; +} diff --git a/third_party/proto/cosmos/staking/v1beta1/staking.proto b/third_party/proto/cosmos/staking/v1beta1/staking.proto new file mode 100644 index 0000000..e37b28b --- /dev/null +++ b/third_party/proto/cosmos/staking/v1beta1/staking.proto @@ -0,0 +1,334 @@ +syntax = "proto3"; +package cosmos.staking.v1beta1; + +import "gogoproto/gogo.proto"; +import "google/protobuf/any.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; + +import "cosmos_proto/cosmos.proto"; +import "cosmos/base/v1beta1/coin.proto"; +import "tendermint/types/types.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/staking/types"; + +// HistoricalInfo contains header and validator information for a given block. +// It is stored as part of staking module's state, which persists the `n` most +// recent HistoricalInfo +// (`n` is set by the staking module's `historical_entries` parameter). +message HistoricalInfo { + tendermint.types.Header header = 1 [(gogoproto.nullable) = false]; + repeated Validator valset = 2 [(gogoproto.nullable) = false]; +} + +// CommissionRates defines the initial commission rates to be used for creating +// a validator. +message CommissionRates { + option (gogoproto.equal) = true; + option (gogoproto.goproto_stringer) = false; + + // rate is the commission rate charged to delegators, as a fraction. + string rate = 1 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; + // max_rate defines the maximum commission rate which validator can ever charge, as a fraction. + string max_rate = 2 [ + (gogoproto.moretags) = "yaml:\"max_rate\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + // max_change_rate defines the maximum daily increase of the validator commission, as a fraction. + string max_change_rate = 3 [ + (gogoproto.moretags) = "yaml:\"max_change_rate\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; +} + +// Commission defines commission parameters for a given validator. +message Commission { + option (gogoproto.equal) = true; + option (gogoproto.goproto_stringer) = false; + + // commission_rates defines the initial commission rates to be used for creating a validator. + CommissionRates commission_rates = 1 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; + // update_time is the last time the commission rate was changed. + google.protobuf.Timestamp update_time = 2 + [(gogoproto.nullable) = false, (gogoproto.stdtime) = true, (gogoproto.moretags) = "yaml:\"update_time\""]; +} + +// Description defines a validator description. +message Description { + option (gogoproto.equal) = true; + option (gogoproto.goproto_stringer) = false; + + // moniker defines a human-readable name for the validator. + string moniker = 1; + // identity defines an optional identity signature (ex. UPort or Keybase). + string identity = 2; + // website defines an optional website link. + string website = 3; + // security_contact defines an optional email for security contact. + string security_contact = 4 [(gogoproto.moretags) = "yaml:\"security_contact\""]; + // details define other optional details. + string details = 5; +} + +// Validator defines a validator, together with the total amount of the +// Validator's bond shares and their exchange rate to coins. Slashing results in +// a decrease in the exchange rate, allowing correct calculation of future +// undelegations without iterating over delegators. When coins are delegated to +// this validator, the validator is credited with a delegation whose number of +// bond shares is based on the amount of coins delegated divided by the current +// exchange rate. Voting power can be calculated as total bonded shares +// multiplied by exchange rate. +message Validator { + option (gogoproto.equal) = false; + option (gogoproto.goproto_stringer) = false; + option (gogoproto.goproto_getters) = false; + + // operator_address defines the address of the validator's operator; bech encoded in JSON. + string operator_address = 1 [(gogoproto.moretags) = "yaml:\"operator_address\""]; + // consensus_pubkey is the consensus public key of the validator, as a Protobuf Any. + google.protobuf.Any consensus_pubkey = 2 + [(cosmos_proto.accepts_interface) = "cosmos.crypto.PubKey", (gogoproto.moretags) = "yaml:\"consensus_pubkey\""]; + // jailed defined whether the validator has been jailed from bonded status or not. + bool jailed = 3; + // status is the validator status (bonded/unbonding/unbonded). + BondStatus status = 4; + // tokens define the delegated tokens (incl. self-delegation). + string tokens = 5 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; + // delegator_shares defines total shares issued to a validator's delegators. + string delegator_shares = 6 [ + (gogoproto.moretags) = "yaml:\"delegator_shares\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + // description defines the description terms for the validator. + Description description = 7 [(gogoproto.nullable) = false]; + // unbonding_height defines, if unbonding, the height at which this validator has begun unbonding. + int64 unbonding_height = 8 [(gogoproto.moretags) = "yaml:\"unbonding_height\""]; + // unbonding_time defines, if unbonding, the min time for the validator to complete unbonding. + google.protobuf.Timestamp unbonding_time = 9 + [(gogoproto.nullable) = false, (gogoproto.stdtime) = true, (gogoproto.moretags) = "yaml:\"unbonding_time\""]; + // commission defines the commission parameters. + Commission commission = 10 [(gogoproto.nullable) = false]; + // min_self_delegation is the validator's self declared minimum self delegation. + string min_self_delegation = 11 [ + (gogoproto.moretags) = "yaml:\"min_self_delegation\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; +} + +// BondStatus is the status of a validator. +enum BondStatus { + option (gogoproto.goproto_enum_prefix) = false; + + // UNSPECIFIED defines an invalid validator status. + BOND_STATUS_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "Unspecified"]; + // UNBONDED defines a validator that is not bonded. + BOND_STATUS_UNBONDED = 1 [(gogoproto.enumvalue_customname) = "Unbonded"]; + // UNBONDING defines a validator that is unbonding. + BOND_STATUS_UNBONDING = 2 [(gogoproto.enumvalue_customname) = "Unbonding"]; + // BONDED defines a validator that is bonded. + BOND_STATUS_BONDED = 3 [(gogoproto.enumvalue_customname) = "Bonded"]; +} + +// ValAddresses defines a repeated set of validator addresses. +message ValAddresses { + option (gogoproto.goproto_stringer) = false; + option (gogoproto.stringer) = true; + + repeated string addresses = 1; +} + +// DVPair is struct that just has a delegator-validator pair with no other data. +// It is intended to be used as a marshalable pointer. For example, a DVPair can +// be used to construct the key to getting an UnbondingDelegation from state. +message DVPair { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = false; + + string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""]; + string validator_address = 2 [(gogoproto.moretags) = "yaml:\"validator_address\""]; +} + +// DVPairs defines an array of DVPair objects. +message DVPairs { + repeated DVPair pairs = 1 [(gogoproto.nullable) = false]; +} + +// DVVTriplet is struct that just has a delegator-validator-validator triplet +// with no other data. It is intended to be used as a marshalable pointer. For +// example, a DVVTriplet can be used to construct the key to getting a +// Redelegation from state. +message DVVTriplet { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = false; + + string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""]; + string validator_src_address = 2 [(gogoproto.moretags) = "yaml:\"validator_src_address\""]; + string validator_dst_address = 3 [(gogoproto.moretags) = "yaml:\"validator_dst_address\""]; +} + +// DVVTriplets defines an array of DVVTriplet objects. +message DVVTriplets { + repeated DVVTriplet triplets = 1 [(gogoproto.nullable) = false]; +} + +// Delegation represents the bond with tokens held by an account. It is +// owned by one delegator, and is associated with the voting power of one +// validator. +message Delegation { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = false; + + // delegator_address is the bech32-encoded address of the delegator. + string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""]; + // validator_address is the bech32-encoded address of the validator. + string validator_address = 2 [(gogoproto.moretags) = "yaml:\"validator_address\""]; + // shares define the delegation shares received. + string shares = 3 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; +} + +// UnbondingDelegation stores all of a single delegator's unbonding bonds +// for a single validator in an time-ordered list. +message UnbondingDelegation { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = false; + + // delegator_address is the bech32-encoded address of the delegator. + string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""]; + // validator_address is the bech32-encoded address of the validator. + string validator_address = 2 [(gogoproto.moretags) = "yaml:\"validator_address\""]; + // entries are the unbonding delegation entries. + repeated UnbondingDelegationEntry entries = 3 [(gogoproto.nullable) = false]; // unbonding delegation entries +} + +// UnbondingDelegationEntry defines an unbonding object with relevant metadata. +message UnbondingDelegationEntry { + option (gogoproto.equal) = true; + option (gogoproto.goproto_stringer) = false; + + // creation_height is the height which the unbonding took place. + int64 creation_height = 1 [(gogoproto.moretags) = "yaml:\"creation_height\""]; + // completion_time is the unix time for unbonding completion. + google.protobuf.Timestamp completion_time = 2 + [(gogoproto.nullable) = false, (gogoproto.stdtime) = true, (gogoproto.moretags) = "yaml:\"completion_time\""]; + // initial_balance defines the tokens initially scheduled to receive at completion. + string initial_balance = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"initial_balance\"" + ]; + // balance defines the tokens to receive at completion. + string balance = 4 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; +} + +// RedelegationEntry defines a redelegation object with relevant metadata. +message RedelegationEntry { + option (gogoproto.equal) = true; + option (gogoproto.goproto_stringer) = false; + + // creation_height defines the height which the redelegation took place. + int64 creation_height = 1 [(gogoproto.moretags) = "yaml:\"creation_height\""]; + // completion_time defines the unix time for redelegation completion. + google.protobuf.Timestamp completion_time = 2 + [(gogoproto.nullable) = false, (gogoproto.stdtime) = true, (gogoproto.moretags) = "yaml:\"completion_time\""]; + // initial_balance defines the initial balance when redelegation started. + string initial_balance = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"initial_balance\"" + ]; + // shares_dst is the amount of destination-validator shares created by redelegation. + string shares_dst = 4 + [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; +} + +// Redelegation contains the list of a particular delegator's redelegating bonds +// from a particular source validator to a particular destination validator. +message Redelegation { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = false; + + // delegator_address is the bech32-encoded address of the delegator. + string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""]; + // validator_src_address is the validator redelegation source operator address. + string validator_src_address = 2 [(gogoproto.moretags) = "yaml:\"validator_src_address\""]; + // validator_dst_address is the validator redelegation destination operator address. + string validator_dst_address = 3 [(gogoproto.moretags) = "yaml:\"validator_dst_address\""]; + // entries are the redelegation entries. + repeated RedelegationEntry entries = 4 [(gogoproto.nullable) = false]; // redelegation entries +} + +// Params defines the parameters for the staking module. +message Params { + option (gogoproto.equal) = true; + option (gogoproto.goproto_stringer) = false; + + // unbonding_time is the time duration of unbonding. + google.protobuf.Duration unbonding_time = 1 + [(gogoproto.nullable) = false, (gogoproto.stdduration) = true, (gogoproto.moretags) = "yaml:\"unbonding_time\""]; + // max_validators is the maximum number of validators. + uint32 max_validators = 2 [(gogoproto.moretags) = "yaml:\"max_validators\""]; + // max_entries is the max entries for either unbonding delegation or redelegation (per pair/trio). + uint32 max_entries = 3 [(gogoproto.moretags) = "yaml:\"max_entries\""]; + // historical_entries is the number of historical entries to persist. + uint32 historical_entries = 4 [(gogoproto.moretags) = "yaml:\"historical_entries\""]; + // bond_denom defines the bondable coin denomination. + string bond_denom = 5 [(gogoproto.moretags) = "yaml:\"bond_denom\""]; +} + +// DelegationResponse is equivalent to Delegation except that it contains a +// balance in addition to shares which is more suitable for client responses. +message DelegationResponse { + option (gogoproto.equal) = false; + option (gogoproto.goproto_stringer) = false; + + Delegation delegation = 1 [(gogoproto.nullable) = false]; + + cosmos.base.v1beta1.Coin balance = 2 [(gogoproto.nullable) = false]; +} + +// RedelegationEntryResponse is equivalent to a RedelegationEntry except that it +// contains a balance in addition to shares which is more suitable for client +// responses. +message RedelegationEntryResponse { + option (gogoproto.equal) = true; + + RedelegationEntry redelegation_entry = 1 [(gogoproto.nullable) = false]; + string balance = 4 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; +} + +// RedelegationResponse is equivalent to a Redelegation except that its entries +// contain a balance in addition to shares which is more suitable for client +// responses. +message RedelegationResponse { + option (gogoproto.equal) = false; + + Redelegation redelegation = 1 [(gogoproto.nullable) = false]; + repeated RedelegationEntryResponse entries = 2 [(gogoproto.nullable) = false]; +} + +// Pool is used for tracking bonded and not-bonded token supply of the bond +// denomination. +message Pool { + option (gogoproto.description) = true; + option (gogoproto.equal) = true; + string not_bonded_tokens = 1 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.jsontag) = "not_bonded_tokens", + (gogoproto.nullable) = false + ]; + string bonded_tokens = 2 [ + (gogoproto.jsontag) = "bonded_tokens", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"bonded_tokens\"" + ]; +} diff --git a/third_party/proto/cosmos/staking/v1beta1/tx.proto b/third_party/proto/cosmos/staking/v1beta1/tx.proto new file mode 100644 index 0000000..7b05d89 --- /dev/null +++ b/third_party/proto/cosmos/staking/v1beta1/tx.proto @@ -0,0 +1,126 @@ +syntax = "proto3"; +package cosmos.staking.v1beta1; + +import "google/protobuf/any.proto"; +import "google/protobuf/timestamp.proto"; +import "gogoproto/gogo.proto"; + +import "cosmos_proto/cosmos.proto"; +import "cosmos/base/v1beta1/coin.proto"; +import "cosmos/staking/v1beta1/staking.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/staking/types"; + +// Msg defines the staking Msg service. +service Msg { + // CreateValidator defines a method for creating a new validator. + rpc CreateValidator(MsgCreateValidator) returns (MsgCreateValidatorResponse); + + // EditValidator defines a method for editing an existing validator. + rpc EditValidator(MsgEditValidator) returns (MsgEditValidatorResponse); + + // Delegate defines a method for performing a delegation of coins + // from a delegator to a validator. + rpc Delegate(MsgDelegate) returns (MsgDelegateResponse); + + // BeginRedelegate defines a method for performing a redelegation + // of coins from a delegator and source validator to a destination validator. + rpc BeginRedelegate(MsgBeginRedelegate) returns (MsgBeginRedelegateResponse); + + // Undelegate defines a method for performing an undelegation from a + // delegate and a validator. + rpc Undelegate(MsgUndelegate) returns (MsgUndelegateResponse); +} + +// MsgCreateValidator defines a SDK message for creating a new validator. +message MsgCreateValidator { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + Description description = 1 [(gogoproto.nullable) = false]; + CommissionRates commission = 2 [(gogoproto.nullable) = false]; + string min_self_delegation = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.moretags) = "yaml:\"min_self_delegation\"", + (gogoproto.nullable) = false + ]; + string delegator_address = 4 [(gogoproto.moretags) = "yaml:\"delegator_address\""]; + string validator_address = 5 [(gogoproto.moretags) = "yaml:\"validator_address\""]; + google.protobuf.Any pubkey = 6 [(cosmos_proto.accepts_interface) = "cosmos.crypto.PubKey"]; + cosmos.base.v1beta1.Coin value = 7 [(gogoproto.nullable) = false]; +} + +// MsgCreateValidatorResponse defines the Msg/CreateValidator response type. +message MsgCreateValidatorResponse {} + +// MsgEditValidator defines a SDK message for editing an existing validator. +message MsgEditValidator { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + Description description = 1 [(gogoproto.nullable) = false]; + string validator_address = 2 [(gogoproto.moretags) = "yaml:\"address\""]; + + // We pass a reference to the new commission rate and min self delegation as + // it's not mandatory to update. If not updated, the deserialized rate will be + // zero with no way to distinguish if an update was intended. + // REF: #2373 + string commission_rate = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.moretags) = "yaml:\"commission_rate\"" + ]; + string min_self_delegation = 4 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.moretags) = "yaml:\"min_self_delegation\"" + ]; +} + +// MsgEditValidatorResponse defines the Msg/EditValidator response type. +message MsgEditValidatorResponse {} + +// MsgDelegate defines a SDK message for performing a delegation of coins +// from a delegator to a validator. +message MsgDelegate { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""]; + string validator_address = 2 [(gogoproto.moretags) = "yaml:\"validator_address\""]; + cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false]; +} + +// MsgDelegateResponse defines the Msg/Delegate response type. +message MsgDelegateResponse {} + +// MsgBeginRedelegate defines a SDK message for performing a redelegation +// of coins from a delegator and source validator to a destination validator. +message MsgBeginRedelegate { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""]; + string validator_src_address = 2 [(gogoproto.moretags) = "yaml:\"validator_src_address\""]; + string validator_dst_address = 3 [(gogoproto.moretags) = "yaml:\"validator_dst_address\""]; + cosmos.base.v1beta1.Coin amount = 4 [(gogoproto.nullable) = false]; +} + +// MsgBeginRedelegateResponse defines the Msg/BeginRedelegate response type. +message MsgBeginRedelegateResponse { + google.protobuf.Timestamp completion_time = 1 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; +} + +// MsgUndelegate defines a SDK message for performing an undelegation from a +// delegate and a validator. +message MsgUndelegate { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""]; + string validator_address = 2 [(gogoproto.moretags) = "yaml:\"validator_address\""]; + cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false]; +} + +// MsgUndelegateResponse defines the Msg/Undelegate response type. +message MsgUndelegateResponse { + google.protobuf.Timestamp completion_time = 1 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; +} diff --git a/third_party/proto/cosmos/tx/signing/v1beta1/signing.proto b/third_party/proto/cosmos/tx/signing/v1beta1/signing.proto new file mode 100644 index 0000000..4c1be40 --- /dev/null +++ b/third_party/proto/cosmos/tx/signing/v1beta1/signing.proto @@ -0,0 +1,79 @@ +syntax = "proto3"; +package cosmos.tx.signing.v1beta1; + +import "cosmos/crypto/multisig/v1beta1/multisig.proto"; +import "google/protobuf/any.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/types/tx/signing"; + +// SignMode represents a signing mode with its own security guarantees. +enum SignMode { + // SIGN_MODE_UNSPECIFIED specifies an unknown signing mode and will be + // rejected + SIGN_MODE_UNSPECIFIED = 0; + + // SIGN_MODE_DIRECT specifies a signing mode which uses SignDoc and is + // verified with raw bytes from Tx + SIGN_MODE_DIRECT = 1; + + // SIGN_MODE_TEXTUAL is a future signing mode that will verify some + // human-readable textual representation on top of the binary representation + // from SIGN_MODE_DIRECT + SIGN_MODE_TEXTUAL = 2; + + // SIGN_MODE_LEGACY_AMINO_JSON is a backwards compatibility mode which uses + // Amino JSON and will be removed in the future + SIGN_MODE_LEGACY_AMINO_JSON = 127; +} + +// SignatureDescriptors wraps multiple SignatureDescriptor's. +message SignatureDescriptors { + // signatures are the signature descriptors + repeated SignatureDescriptor signatures = 1; +} + +// SignatureDescriptor is a convenience type which represents the full data for +// a signature including the public key of the signer, signing modes and the +// signature itself. It is primarily used for coordinating signatures between +// clients. +message SignatureDescriptor { + // public_key is the public key of the signer + google.protobuf.Any public_key = 1; + + Data data = 2; + + // sequence is the sequence of the account, which describes the + // number of committed transactions signed by a given address. It is used to prevent + // replay attacks. + uint64 sequence = 3; + + // Data represents signature data + message Data { + // sum is the oneof that specifies whether this represents single or multi-signature data + oneof sum { + // single represents a single signer + Single single = 1; + + // multi represents a multisig signer + Multi multi = 2; + } + + // Single is the signature data for a single signer + message Single { + // mode is the signing mode of the single signer + SignMode mode = 1; + + // signature is the raw signature bytes + bytes signature = 2; + } + + // Multi is the signature data for a multisig public key + message Multi { + // bitarray specifies which keys within the multisig are signing + cosmos.crypto.multisig.v1beta1.CompactBitArray bitarray = 1; + + // signatures is the signatures of the multi-signature + repeated Data signatures = 2; + } + } +} diff --git a/third_party/proto/cosmos/tx/v1beta1/service.proto b/third_party/proto/cosmos/tx/v1beta1/service.proto new file mode 100644 index 0000000..25214c4 --- /dev/null +++ b/third_party/proto/cosmos/tx/v1beta1/service.proto @@ -0,0 +1,129 @@ +syntax = "proto3"; +package cosmos.tx.v1beta1; + +import "google/api/annotations.proto"; +import "cosmos/base/abci/v1beta1/abci.proto"; +import "cosmos/tx/v1beta1/tx.proto"; +import "gogoproto/gogo.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; + +option (gogoproto.goproto_registration) = true; +option go_package = "github.com/cosmos/cosmos-sdk/types/tx"; + +// Service defines a gRPC service for interacting with transactions. +service Service { + // Simulate simulates executing a transaction for estimating gas usage. + rpc Simulate(SimulateRequest) returns (SimulateResponse) { + option (google.api.http) = { + post: "/cosmos/tx/v1beta1/simulate" + body: "*" + }; + } + // GetTx fetches a tx by hash. + rpc GetTx(GetTxRequest) returns (GetTxResponse) { + option (google.api.http).get = "/cosmos/tx/v1beta1/txs/{hash}"; + } + // BroadcastTx broadcast transaction. + rpc BroadcastTx(BroadcastTxRequest) returns (BroadcastTxResponse) { + option (google.api.http) = { + post: "/cosmos/tx/v1beta1/txs" + body: "*" + }; + } + // GetTxsEvent fetches txs by event. + rpc GetTxsEvent(GetTxsEventRequest) returns (GetTxsEventResponse) { + option (google.api.http).get = "/cosmos/tx/v1beta1/txs"; + } +} + +// GetTxsEventRequest is the request type for the Service.TxsByEvents +// RPC method. +message GetTxsEventRequest { + // events is the list of transaction event type. + repeated string events = 1; + // pagination defines an pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; + OrderBy order_by = 3; +} + +// OrderBy defines the sorting order +enum OrderBy { + // ORDER_BY_UNSPECIFIED specifies an unknown sorting order. OrderBy defaults to ASC in this case. + ORDER_BY_UNSPECIFIED = 0; + // ORDER_BY_ASC defines ascending order + ORDER_BY_ASC = 1; + // ORDER_BY_DESC defines descending order + ORDER_BY_DESC = 2; +} + +// GetTxsEventResponse is the response type for the Service.TxsByEvents +// RPC method. +message GetTxsEventResponse { + // txs is the list of queried transactions. + repeated cosmos.tx.v1beta1.Tx txs = 1; + // tx_responses is the list of queried TxResponses. + repeated cosmos.base.abci.v1beta1.TxResponse tx_responses = 2; + // pagination defines an pagination for the response. + cosmos.base.query.v1beta1.PageResponse pagination = 3; +} + +// BroadcastTxRequest is the request type for the Service.BroadcastTxRequest +// RPC method. +message BroadcastTxRequest { + // tx_bytes is the raw transaction. + bytes tx_bytes = 1; + BroadcastMode mode = 2; +} + +// BroadcastMode specifies the broadcast mode for the TxService.Broadcast RPC method. +enum BroadcastMode { + // zero-value for mode ordering + BROADCAST_MODE_UNSPECIFIED = 0; + // BROADCAST_MODE_BLOCK defines a tx broadcasting mode where the client waits for + // the tx to be committed in a block. + BROADCAST_MODE_BLOCK = 1; + // BROADCAST_MODE_SYNC defines a tx broadcasting mode where the client waits for + // a CheckTx execution response only. + BROADCAST_MODE_SYNC = 2; + // BROADCAST_MODE_ASYNC defines a tx broadcasting mode where the client returns + // immediately. + BROADCAST_MODE_ASYNC = 3; +} + +// BroadcastTxResponse is the response type for the +// Service.BroadcastTx method. +message BroadcastTxResponse { + // tx_response is the queried TxResponses. + cosmos.base.abci.v1beta1.TxResponse tx_response = 1; +} + +// SimulateRequest is the request type for the Service.Simulate +// RPC method. +message SimulateRequest { + // tx is the transaction to simulate. + cosmos.tx.v1beta1.Tx tx = 1; +} + +// SimulateResponse is the response type for the +// Service.SimulateRPC method. +message SimulateResponse { + // gas_info is the information about gas used in the simulation. + cosmos.base.abci.v1beta1.GasInfo gas_info = 1; + // result is the result of the simulation. + cosmos.base.abci.v1beta1.Result result = 2; +} + +// GetTxRequest is the request type for the Service.GetTx +// RPC method. +message GetTxRequest { + // hash is the tx hash to query, encoded as a hex string. + string hash = 1; +} + +// GetTxResponse is the response type for the Service.GetTx method. +message GetTxResponse { + // tx is the queried transaction. + cosmos.tx.v1beta1.Tx tx = 1; + // tx_response is the queried TxResponses. + cosmos.base.abci.v1beta1.TxResponse tx_response = 2; +} \ No newline at end of file diff --git a/third_party/proto/cosmos/tx/v1beta1/tx.proto b/third_party/proto/cosmos/tx/v1beta1/tx.proto new file mode 100644 index 0000000..2b02874 --- /dev/null +++ b/third_party/proto/cosmos/tx/v1beta1/tx.proto @@ -0,0 +1,181 @@ +syntax = "proto3"; +package cosmos.tx.v1beta1; + +import "gogoproto/gogo.proto"; +import "cosmos/crypto/multisig/v1beta1/multisig.proto"; +import "cosmos/base/v1beta1/coin.proto"; +import "cosmos/tx/signing/v1beta1/signing.proto"; +import "google/protobuf/any.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/types/tx"; + +// Tx is the standard type used for broadcasting transactions. +message Tx { + // body is the processable content of the transaction + TxBody body = 1; + + // auth_info is the authorization related content of the transaction, + // specifically signers, signer modes and fee + AuthInfo auth_info = 2; + + // signatures is a list of signatures that matches the length and order of + // AuthInfo's signer_infos to allow connecting signature meta information like + // public key and signing mode by position. + repeated bytes signatures = 3; +} + +// TxRaw is a variant of Tx that pins the signer's exact binary representation +// of body and auth_info. This is used for signing, broadcasting and +// verification. The binary `serialize(tx: TxRaw)` is stored in Tendermint and +// the hash `sha256(serialize(tx: TxRaw))` becomes the "txhash", commonly used +// as the transaction ID. +message TxRaw { + // body_bytes is a protobuf serialization of a TxBody that matches the + // representation in SignDoc. + bytes body_bytes = 1; + + // auth_info_bytes is a protobuf serialization of an AuthInfo that matches the + // representation in SignDoc. + bytes auth_info_bytes = 2; + + // signatures is a list of signatures that matches the length and order of + // AuthInfo's signer_infos to allow connecting signature meta information like + // public key and signing mode by position. + repeated bytes signatures = 3; +} + +// SignDoc is the type used for generating sign bytes for SIGN_MODE_DIRECT. +message SignDoc { + // body_bytes is protobuf serialization of a TxBody that matches the + // representation in TxRaw. + bytes body_bytes = 1; + + // auth_info_bytes is a protobuf serialization of an AuthInfo that matches the + // representation in TxRaw. + bytes auth_info_bytes = 2; + + // chain_id is the unique identifier of the chain this transaction targets. + // It prevents signed transactions from being used on another chain by an + // attacker + string chain_id = 3; + + // account_number is the account number of the account in state + uint64 account_number = 4; +} + +// TxBody is the body of a transaction that all signers sign over. +message TxBody { + // messages is a list of messages to be executed. The required signers of + // those messages define the number and order of elements in AuthInfo's + // signer_infos and Tx's signatures. Each required signer address is added to + // the list only the first time it occurs. + // By convention, the first required signer (usually from the first message) + // is referred to as the primary signer and pays the fee for the whole + // transaction. + repeated google.protobuf.Any messages = 1; + + // memo is any arbitrary memo to be added to the transaction + string memo = 2; + + // timeout is the block height after which this transaction will not + // be processed by the chain + uint64 timeout_height = 3; + + // extension_options are arbitrary options that can be added by chains + // when the default options are not sufficient. If any of these are present + // and can't be handled, the transaction will be rejected + repeated google.protobuf.Any extension_options = 1023; + + // extension_options are arbitrary options that can be added by chains + // when the default options are not sufficient. If any of these are present + // and can't be handled, they will be ignored + repeated google.protobuf.Any non_critical_extension_options = 2047; +} + +// AuthInfo describes the fee and signer modes that are used to sign a +// transaction. +message AuthInfo { + // signer_infos defines the signing modes for the required signers. The number + // and order of elements must match the required signers from TxBody's + // messages. The first element is the primary signer and the one which pays + // the fee. + repeated SignerInfo signer_infos = 1; + + // Fee is the fee and gas limit for the transaction. The first signer is the + // primary signer and the one which pays the fee. The fee can be calculated + // based on the cost of evaluating the body and doing signature verification + // of the signers. This can be estimated via simulation. + Fee fee = 2; +} + +// SignerInfo describes the public key and signing mode of a single top-level +// signer. +message SignerInfo { + // public_key is the public key of the signer. It is optional for accounts + // that already exist in state. If unset, the verifier can use the required \ + // signer address for this position and lookup the public key. + google.protobuf.Any public_key = 1; + + // mode_info describes the signing mode of the signer and is a nested + // structure to support nested multisig pubkey's + ModeInfo mode_info = 2; + + // sequence is the sequence of the account, which describes the + // number of committed transactions signed by a given address. It is used to + // prevent replay attacks. + uint64 sequence = 3; +} + +// ModeInfo describes the signing mode of a single or nested multisig signer. +message ModeInfo { + // sum is the oneof that specifies whether this represents a single or nested + // multisig signer + oneof sum { + // single represents a single signer + Single single = 1; + + // multi represents a nested multisig signer + Multi multi = 2; + } + + // Single is the mode info for a single signer. It is structured as a message + // to allow for additional fields such as locale for SIGN_MODE_TEXTUAL in the + // future + message Single { + // mode is the signing mode of the single signer + cosmos.tx.signing.v1beta1.SignMode mode = 1; + } + + // Multi is the mode info for a multisig public key + message Multi { + // bitarray specifies which keys within the multisig are signing + cosmos.crypto.multisig.v1beta1.CompactBitArray bitarray = 1; + + // mode_infos is the corresponding modes of the signers of the multisig + // which could include nested multisig public keys + repeated ModeInfo mode_infos = 2; + } +} + +// Fee includes the amount of coins paid in fees and the maximum +// gas to be used by the transaction. The ratio yields an effective "gasprice", +// which must be above some miminum to be accepted into the mempool. +message Fee { + // amount is the amount of coins to be paid as a fee + repeated cosmos.base.v1beta1.Coin amount = 1 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; + + // gas_limit is the maximum gas that can be used in transaction processing + // before an out of gas error occurs + uint64 gas_limit = 2; + + // if unset, the first signer is responsible for paying the fees. If set, the specified account must pay the fees. + // the payer must be a tx signer (and thus have signed this field in AuthInfo). + // setting this field does *not* change the ordering of required signers for the transaction. + string payer = 3; + + // if set, the fee payer (either the first signer or the value of the payer field) requests that a fee grant be used + // to pay fees instead of the fee payer's own balance. If an appropriate fee grant does not exist or the chain does + // not support fee grants, this will fail + string granter = 4; +} diff --git a/third_party/proto/cosmos/upgrade/v1beta1/query.proto b/third_party/proto/cosmos/upgrade/v1beta1/query.proto new file mode 100644 index 0000000..9eab27e --- /dev/null +++ b/third_party/proto/cosmos/upgrade/v1beta1/query.proto @@ -0,0 +1,68 @@ +syntax = "proto3"; +package cosmos.upgrade.v1beta1; + +import "google/protobuf/any.proto"; +import "google/api/annotations.proto"; +import "cosmos/upgrade/v1beta1/upgrade.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/upgrade/types"; + +// Query defines the gRPC upgrade querier service. +service Query { + // CurrentPlan queries the current upgrade plan. + rpc CurrentPlan(QueryCurrentPlanRequest) returns (QueryCurrentPlanResponse) { + option (google.api.http).get = "/cosmos/upgrade/v1beta1/current_plan"; + } + + // AppliedPlan queries a previously applied upgrade plan by its name. + rpc AppliedPlan(QueryAppliedPlanRequest) returns (QueryAppliedPlanResponse) { + option (google.api.http).get = "/cosmos/upgrade/v1beta1/applied_plan/{name}"; + } + + // UpgradedConsensusState queries the consensus state that will serve + // as a trusted kernel for the next version of this chain. It will only be + // stored at the last height of this chain. + // UpgradedConsensusState RPC not supported with legacy querier + rpc UpgradedConsensusState(QueryUpgradedConsensusStateRequest) returns (QueryUpgradedConsensusStateResponse) { + option (google.api.http).get = "/cosmos/upgrade/v1beta1/upgraded_consensus_state/{last_height}"; + } +} + +// QueryCurrentPlanRequest is the request type for the Query/CurrentPlan RPC +// method. +message QueryCurrentPlanRequest {} + +// QueryCurrentPlanResponse is the response type for the Query/CurrentPlan RPC +// method. +message QueryCurrentPlanResponse { + // plan is the current upgrade plan. + Plan plan = 1; +} + +// QueryCurrentPlanRequest is the request type for the Query/AppliedPlan RPC +// method. +message QueryAppliedPlanRequest { + // name is the name of the applied plan to query for. + string name = 1; +} + +// QueryAppliedPlanResponse is the response type for the Query/AppliedPlan RPC +// method. +message QueryAppliedPlanResponse { + // height is the block height at which the plan was applied. + int64 height = 1; +} + +// QueryUpgradedConsensusStateRequest is the request type for the Query/UpgradedConsensusState +// RPC method. +message QueryUpgradedConsensusStateRequest { + // last height of the current chain must be sent in request + // as this is the height under which next consensus state is stored + int64 last_height = 1; +} + +// QueryUpgradedConsensusStateResponse is the response type for the Query/UpgradedConsensusState +// RPC method. +message QueryUpgradedConsensusStateResponse { + google.protobuf.Any upgraded_consensus_state = 1; +} diff --git a/third_party/proto/cosmos/upgrade/v1beta1/upgrade.proto b/third_party/proto/cosmos/upgrade/v1beta1/upgrade.proto new file mode 100644 index 0000000..6d6839c --- /dev/null +++ b/third_party/proto/cosmos/upgrade/v1beta1/upgrade.proto @@ -0,0 +1,62 @@ +syntax = "proto3"; +package cosmos.upgrade.v1beta1; + +import "google/protobuf/any.proto"; +import "gogoproto/gogo.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/upgrade/types"; +option (gogoproto.goproto_stringer_all) = false; +option (gogoproto.goproto_getters_all) = false; + +// Plan specifies information about a planned upgrade and when it should occur. +message Plan { + option (gogoproto.equal) = true; + + // Sets the name for the upgrade. This name will be used by the upgraded + // version of the software to apply any special "on-upgrade" commands during + // the first BeginBlock method after the upgrade is applied. It is also used + // to detect whether a software version can handle a given upgrade. If no + // upgrade handler with this name has been set in the software, it will be + // assumed that the software is out-of-date when the upgrade Time or Height is + // reached and the software will exit. + string name = 1; + + // The time after which the upgrade must be performed. + // Leave set to its zero value to use a pre-defined Height instead. + google.protobuf.Timestamp time = 2 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; + + // The height at which the upgrade must be performed. + // Only used if Time is not set. + int64 height = 3; + + // Any application specific upgrade info to be included on-chain + // such as a git commit that validators could automatically upgrade to + string info = 4; + + // IBC-enabled chains can opt-in to including the upgraded client state in its upgrade plan + // This will make the chain commit to the correct upgraded (self) client state before the upgrade occurs, + // so that connecting chains can verify that the new upgraded client is valid by verifying a proof on the + // previous version of the chain. + // This will allow IBC connections to persist smoothly across planned chain upgrades + google.protobuf.Any upgraded_client_state = 5 [(gogoproto.moretags) = "yaml:\"upgraded_client_state\""]; +} + +// SoftwareUpgradeProposal is a gov Content type for initiating a software +// upgrade. +message SoftwareUpgradeProposal { + option (gogoproto.equal) = true; + + string title = 1; + string description = 2; + Plan plan = 3 [(gogoproto.nullable) = false]; +} + +// CancelSoftwareUpgradeProposal is a gov Content type for cancelling a software +// upgrade. +message CancelSoftwareUpgradeProposal { + option (gogoproto.equal) = true; + + string title = 1; + string description = 2; +} diff --git a/third_party/proto/cosmos/vesting/v1beta1/tx.proto b/third_party/proto/cosmos/vesting/v1beta1/tx.proto new file mode 100644 index 0000000..c49be80 --- /dev/null +++ b/third_party/proto/cosmos/vesting/v1beta1/tx.proto @@ -0,0 +1,31 @@ +syntax = "proto3"; +package cosmos.vesting.v1beta1; + +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"; + +// Msg defines the bank Msg service. +service Msg { + // CreateVestingAccount defines a method that enables creating a vesting + // account. + rpc CreateVestingAccount(MsgCreateVestingAccount) returns (MsgCreateVestingAccountResponse); +} + +// MsgCreateVestingAccount defines a message that enables creating a vesting +// account. +message MsgCreateVestingAccount { + option (gogoproto.equal) = true; + + string from_address = 1 [(gogoproto.moretags) = "yaml:\"from_address\""]; + string to_address = 2 [(gogoproto.moretags) = "yaml:\"to_address\""]; + repeated cosmos.base.v1beta1.Coin amount = 3 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; + + int64 end_time = 4 [(gogoproto.moretags) = "yaml:\"end_time\""]; + bool delayed = 5; +} + +// MsgCreateVestingAccountResponse defines the Msg/CreateVestingAccount response type. +message MsgCreateVestingAccountResponse {} \ No newline at end of file diff --git a/third_party/proto/cosmos/vesting/v1beta1/vesting.proto b/third_party/proto/cosmos/vesting/v1beta1/vesting.proto new file mode 100644 index 0000000..6bdbbf0 --- /dev/null +++ b/third_party/proto/cosmos/vesting/v1beta1/vesting.proto @@ -0,0 +1,73 @@ +syntax = "proto3"; +package cosmos.vesting.v1beta1; + +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; +import "cosmos/auth/v1beta1/auth.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"; + +// BaseVestingAccount implements the VestingAccount interface. It contains all +// the necessary fields needed for any vesting account implementation. +message BaseVestingAccount { + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = false; + + cosmos.auth.v1beta1.BaseAccount base_account = 1 [(gogoproto.embed) = true]; + repeated cosmos.base.v1beta1.Coin original_vesting = 2 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", + (gogoproto.moretags) = "yaml:\"original_vesting\"" + ]; + repeated cosmos.base.v1beta1.Coin delegated_free = 3 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", + (gogoproto.moretags) = "yaml:\"delegated_free\"" + ]; + repeated cosmos.base.v1beta1.Coin delegated_vesting = 4 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", + (gogoproto.moretags) = "yaml:\"delegated_vesting\"" + ]; + int64 end_time = 5 [(gogoproto.moretags) = "yaml:\"end_time\""]; +} + +// ContinuousVestingAccount implements the VestingAccount interface. It +// continuously vests by unlocking coins linearly with respect to time. +message ContinuousVestingAccount { + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = false; + + BaseVestingAccount base_vesting_account = 1 [(gogoproto.embed) = true]; + int64 start_time = 2 [(gogoproto.moretags) = "yaml:\"start_time\""]; +} + +// DelayedVestingAccount implements the VestingAccount interface. It vests all +// coins after a specific time, but non prior. In other words, it keeps them +// locked until a specified time. +message DelayedVestingAccount { + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = false; + + BaseVestingAccount base_vesting_account = 1 [(gogoproto.embed) = true]; +} + +// Period defines a length of time and amount of coins that will vest. +message Period { + option (gogoproto.goproto_stringer) = false; + + int64 length = 1; + repeated cosmos.base.v1beta1.Coin amount = 2 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; +} + +// PeriodicVestingAccount implements the VestingAccount interface. It +// periodically vests by unlocking coins during each specified period. +message PeriodicVestingAccount { + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = false; + + BaseVestingAccount base_vesting_account = 1 [(gogoproto.embed) = true]; + int64 start_time = 2 [(gogoproto.moretags) = "yaml:\"start_time\""]; + repeated Period vesting_periods = 3 [(gogoproto.moretags) = "yaml:\"vesting_periods\"", (gogoproto.nullable) = false]; +} diff --git a/third_party/proto/ibc/applications/transfer/v1/genesis.proto b/third_party/proto/ibc/applications/transfer/v1/genesis.proto new file mode 100644 index 0000000..98cf229 --- /dev/null +++ b/third_party/proto/ibc/applications/transfer/v1/genesis.proto @@ -0,0 +1,18 @@ +syntax = "proto3"; +package ibc.applications.transfer.v1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/applications/transfer/types"; + +import "gogoproto/gogo.proto"; +import "ibc/applications/transfer/v1/transfer.proto"; + +// GenesisState defines the ibc-transfer genesis state +message GenesisState { + string port_id = 1 [(gogoproto.moretags) = "yaml:\"port_id\""]; + repeated DenomTrace denom_traces = 2 [ + (gogoproto.castrepeated) = "Traces", + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"denom_traces\"" + ]; + Params params = 3 [(gogoproto.nullable) = false]; +} diff --git a/third_party/proto/ibc/applications/transfer/v1/query.proto b/third_party/proto/ibc/applications/transfer/v1/query.proto new file mode 100644 index 0000000..e9cbd02 --- /dev/null +++ b/third_party/proto/ibc/applications/transfer/v1/query.proto @@ -0,0 +1,66 @@ +syntax = "proto3"; +package ibc.applications.transfer.v1; + +import "gogoproto/gogo.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; +import "ibc/applications/transfer/v1/transfer.proto"; +import "google/api/annotations.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/applications/transfer/types"; + +// Query provides defines the gRPC querier service. +service Query { + // DenomTrace queries a denomination trace information. + rpc DenomTrace(QueryDenomTraceRequest) returns (QueryDenomTraceResponse) { + option (google.api.http).get = "/ibc/applications/transfer/v1beta1/denom_traces/{hash}"; + } + + // DenomTraces queries all denomination traces. + rpc DenomTraces(QueryDenomTracesRequest) returns (QueryDenomTracesResponse) { + option (google.api.http).get = "/ibc/applications/transfer/v1beta1/denom_traces"; + } + + // Params queries all parameters of the ibc-transfer module. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/ibc/applications/transfer/v1beta1/params"; + } +} + +// QueryDenomTraceRequest is the request type for the Query/DenomTrace RPC +// method +message QueryDenomTraceRequest { + // hash (in hex format) of the denomination trace information. + string hash = 1; +} + +// QueryDenomTraceResponse is the response type for the Query/DenomTrace RPC +// method. +message QueryDenomTraceResponse { + // denom_trace returns the requested denomination trace information. + DenomTrace denom_trace = 1; +} + +// QueryConnectionsRequest is the request type for the Query/DenomTraces RPC +// method +message QueryDenomTracesRequest { + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 1; +} + +// QueryConnectionsResponse is the response type for the Query/DenomTraces RPC +// method. +message QueryDenomTracesResponse { + // denom_traces returns all denominations trace information. + repeated DenomTrace denom_traces = 1 [(gogoproto.castrepeated) = "Traces", (gogoproto.nullable) = false]; + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryParamsRequest is the request type for the Query/Params RPC method. +message QueryParamsRequest {} + +// QueryParamsResponse is the response type for the Query/Params RPC method. +message QueryParamsResponse { + // params defines the parameters of the module. + Params params = 1; +} diff --git a/third_party/proto/ibc/applications/transfer/v1/transfer.proto b/third_party/proto/ibc/applications/transfer/v1/transfer.proto new file mode 100644 index 0000000..b388c3b --- /dev/null +++ b/third_party/proto/ibc/applications/transfer/v1/transfer.proto @@ -0,0 +1,43 @@ +syntax = "proto3"; +package ibc.applications.transfer.v1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/applications/transfer/types"; + +import "gogoproto/gogo.proto"; + +// FungibleTokenPacketData defines a struct for the packet payload +// See FungibleTokenPacketData spec: +// https://github.com/cosmos/ics/tree/master/spec/ics-020-fungible-token-transfer#data-structures +message FungibleTokenPacketData { + // the token denomination to be transferred + string denom = 1; + // the token amount to be transferred + uint64 amount = 2; + // the sender address + string sender = 3; + // the recipient address on the destination chain + string receiver = 4; +} + +// DenomTrace contains the base denomination for ICS20 fungible tokens and the +// source tracing information path. +message DenomTrace { + // path defines the chain of port/channel identifiers used for tracing the + // source of the fungible token. + string path = 1; + // base denomination of the relayed fungible token. + string base_denom = 2; +} + +// Params defines the set of IBC transfer parameters. +// NOTE: To prevent a single token from being transferred, set the +// TransfersEnabled parameter to true and then set the bank module's SendEnabled +// parameter for the denomination to false. +message Params { + // send_enabled enables or disables all cross-chain token transfers from this + // chain. + bool send_enabled = 1 [(gogoproto.moretags) = "yaml:\"send_enabled\""]; + // receive_enabled enables or disables all cross-chain token transfers to this + // chain. + bool receive_enabled = 2 [(gogoproto.moretags) = "yaml:\"receive_enabled\""]; +} diff --git a/third_party/proto/ibc/applications/transfer/v1/tx.proto b/third_party/proto/ibc/applications/transfer/v1/tx.proto new file mode 100644 index 0000000..a0f0827 --- /dev/null +++ b/third_party/proto/ibc/applications/transfer/v1/tx.proto @@ -0,0 +1,43 @@ +syntax = "proto3"; +package ibc.applications.transfer.v1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/applications/transfer/types"; + +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; +import "ibc/core/client/v1/client.proto"; + +// Msg defines the ibc/transfer Msg service. +service Msg { + // Transfer defines a rpc handler method for MsgTransfer. + rpc Transfer(MsgTransfer) returns (MsgTransferResponse); +} + +// MsgTransfer defines a msg to transfer fungible tokens (i.e Coins) between +// ICS20 enabled chains. See ICS Spec here: +// https://github.com/cosmos/ics/tree/master/spec/ics-020-fungible-token-transfer#data-structures +message MsgTransfer { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // the port on which the packet will be sent + string source_port = 1 [(gogoproto.moretags) = "yaml:\"source_port\""]; + // the channel by which the packet will be sent + string source_channel = 2 [(gogoproto.moretags) = "yaml:\"source_channel\""]; + // the tokens to be transferred + cosmos.base.v1beta1.Coin token = 3 [(gogoproto.nullable) = false]; + // the sender address + string sender = 4; + // the recipient address on the destination chain + string receiver = 5; + // Timeout height relative to the current block height. + // The timeout is disabled when set to 0. + ibc.core.client.v1.Height timeout_height = 6 + [(gogoproto.moretags) = "yaml:\"timeout_height\"", (gogoproto.nullable) = false]; + // Timeout timestamp (in nanoseconds) relative to the current block timestamp. + // The timeout is disabled when set to 0. + uint64 timeout_timestamp = 7 [(gogoproto.moretags) = "yaml:\"timeout_timestamp\""]; +} + +// MsgTransferResponse defines the Msg/Transfer response type. +message MsgTransferResponse {} diff --git a/third_party/proto/ibc/core/channel/v1/channel.proto b/third_party/proto/ibc/core/channel/v1/channel.proto new file mode 100644 index 0000000..302a480 --- /dev/null +++ b/third_party/proto/ibc/core/channel/v1/channel.proto @@ -0,0 +1,147 @@ +syntax = "proto3"; +package ibc.core.channel.v1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/core/04-channel/types"; + +import "gogoproto/gogo.proto"; +import "ibc/core/client/v1/client.proto"; + +// Channel defines pipeline for exactly-once packet delivery between specific +// modules on separate blockchains, which has at least one end capable of +// sending packets and one end capable of receiving packets. +message Channel { + option (gogoproto.goproto_getters) = false; + + // current state of the channel end + State state = 1; + // whether the channel is ordered or unordered + Order ordering = 2; + // counterparty channel end + Counterparty counterparty = 3 [(gogoproto.nullable) = false]; + // list of connection identifiers, in order, along which packets sent on + // this channel will travel + repeated string connection_hops = 4 [(gogoproto.moretags) = "yaml:\"connection_hops\""]; + // opaque channel version, which is agreed upon during the handshake + string version = 5; +} + +// IdentifiedChannel defines a channel with additional port and channel +// identifier fields. +message IdentifiedChannel { + option (gogoproto.goproto_getters) = false; + + // current state of the channel end + State state = 1; + // whether the channel is ordered or unordered + Order ordering = 2; + // counterparty channel end + Counterparty counterparty = 3 [(gogoproto.nullable) = false]; + // list of connection identifiers, in order, along which packets sent on + // this channel will travel + repeated string connection_hops = 4 [(gogoproto.moretags) = "yaml:\"connection_hops\""]; + // opaque channel version, which is agreed upon during the handshake + string version = 5; + // port identifier + string port_id = 6; + // channel identifier + string channel_id = 7; +} + +// State defines if a channel is in one of the following states: +// CLOSED, INIT, TRYOPEN, OPEN or UNINITIALIZED. +enum State { + option (gogoproto.goproto_enum_prefix) = false; + + // Default State + STATE_UNINITIALIZED_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "UNINITIALIZED"]; + // A channel has just started the opening handshake. + STATE_INIT = 1 [(gogoproto.enumvalue_customname) = "INIT"]; + // A channel has acknowledged the handshake step on the counterparty chain. + STATE_TRYOPEN = 2 [(gogoproto.enumvalue_customname) = "TRYOPEN"]; + // A channel has completed the handshake. Open channels are + // ready to send and receive packets. + STATE_OPEN = 3 [(gogoproto.enumvalue_customname) = "OPEN"]; + // A channel has been closed and can no longer be used to send or receive + // packets. + STATE_CLOSED = 4 [(gogoproto.enumvalue_customname) = "CLOSED"]; +} + +// Order defines if a channel is ORDERED or UNORDERED +enum Order { + option (gogoproto.goproto_enum_prefix) = false; + + // zero-value for channel ordering + ORDER_NONE_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "NONE"]; + // packets can be delivered in any order, which may differ from the order in + // which they were sent. + ORDER_UNORDERED = 1 [(gogoproto.enumvalue_customname) = "UNORDERED"]; + // packets are delivered exactly in the order which they were sent + ORDER_ORDERED = 2 [(gogoproto.enumvalue_customname) = "ORDERED"]; +} + +// Counterparty defines a channel end counterparty +message Counterparty { + option (gogoproto.goproto_getters) = false; + + // port on the counterparty chain which owns the other end of the channel. + string port_id = 1 [(gogoproto.moretags) = "yaml:\"port_id\""]; + // channel end on the counterparty chain + string channel_id = 2 [(gogoproto.moretags) = "yaml:\"channel_id\""]; +} + +// Packet defines a type that carries data across different chains through IBC +message Packet { + option (gogoproto.goproto_getters) = false; + + // number corresponds to the order of sends and receives, where a Packet + // with an earlier sequence number must be sent and received before a Packet + // with a later sequence number. + uint64 sequence = 1; + // identifies the port on the sending chain. + string source_port = 2 [(gogoproto.moretags) = "yaml:\"source_port\""]; + // identifies the channel end on the sending chain. + string source_channel = 3 [(gogoproto.moretags) = "yaml:\"source_channel\""]; + // identifies the port on the receiving chain. + string destination_port = 4 [(gogoproto.moretags) = "yaml:\"destination_port\""]; + // identifies the channel end on the receiving chain. + string destination_channel = 5 [(gogoproto.moretags) = "yaml:\"destination_channel\""]; + // actual opaque bytes transferred directly to the application module + bytes data = 6; + // block height after which the packet times out + ibc.core.client.v1.Height timeout_height = 7 + [(gogoproto.moretags) = "yaml:\"timeout_height\"", (gogoproto.nullable) = false]; + // block timestamp (in nanoseconds) after which the packet times out + uint64 timeout_timestamp = 8 [(gogoproto.moretags) = "yaml:\"timeout_timestamp\""]; +} + +// PacketState defines the generic type necessary to retrieve and store +// packet commitments, acknowledgements, and receipts. +// Caller is responsible for knowing the context necessary to interpret this +// state as a commitment, acknowledgement, or a receipt. +message PacketState { + option (gogoproto.goproto_getters) = false; + + // channel port identifier. + string port_id = 1 [(gogoproto.moretags) = "yaml:\"port_id\""]; + // channel unique identifier. + string channel_id = 2 [(gogoproto.moretags) = "yaml:\"channel_id\""]; + // packet sequence. + uint64 sequence = 3; + // embedded data that represents packet state. + bytes data = 4; +} + +// Acknowledgement is the recommended acknowledgement format to be used by +// app-specific protocols. +// NOTE: The field numbers 21 and 22 were explicitly chosen to avoid accidental +// conflicts with other protobuf message formats used for acknowledgements. +// The first byte of any message with this format will be the non-ASCII values +// `0xaa` (result) or `0xb2` (error). Implemented as defined by ICS: +// https://github.com/cosmos/ics/tree/master/spec/ics-004-channel-and-packet-semantics#acknowledgement-envelope +message Acknowledgement { + // response contains either a result or an error and must be non-empty + oneof response { + bytes result = 21; + string error = 22; + } +} diff --git a/third_party/proto/ibc/core/channel/v1/genesis.proto b/third_party/proto/ibc/core/channel/v1/genesis.proto new file mode 100644 index 0000000..d3b2c04 --- /dev/null +++ b/third_party/proto/ibc/core/channel/v1/genesis.proto @@ -0,0 +1,31 @@ +syntax = "proto3"; +package ibc.core.channel.v1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/core/04-channel/types"; + +import "gogoproto/gogo.proto"; +import "ibc/core/channel/v1/channel.proto"; + +// GenesisState defines the ibc channel submodule's genesis state. +message GenesisState { + repeated IdentifiedChannel channels = 1 [(gogoproto.casttype) = "IdentifiedChannel", (gogoproto.nullable) = false]; + repeated PacketState acknowledgements = 2 [(gogoproto.nullable) = false]; + repeated PacketState commitments = 3 [(gogoproto.nullable) = false]; + repeated PacketState receipts = 4 [(gogoproto.nullable) = false]; + repeated PacketSequence send_sequences = 5 + [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"send_sequences\""]; + repeated PacketSequence recv_sequences = 6 + [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"recv_sequences\""]; + repeated PacketSequence ack_sequences = 7 + [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"ack_sequences\""]; + // the sequence for the next generated channel identifier + uint64 next_channel_sequence = 8 [(gogoproto.moretags) = "yaml:\"next_channel_sequence\""]; +} + +// PacketSequence defines the genesis type necessary to retrieve and store +// next send and receive sequences. +message PacketSequence { + string port_id = 1 [(gogoproto.moretags) = "yaml:\"port_id\""]; + string channel_id = 2 [(gogoproto.moretags) = "yaml:\"channel_id\""]; + uint64 sequence = 3; +} diff --git a/third_party/proto/ibc/core/channel/v1/query.proto b/third_party/proto/ibc/core/channel/v1/query.proto new file mode 100644 index 0000000..d9e3ceb --- /dev/null +++ b/third_party/proto/ibc/core/channel/v1/query.proto @@ -0,0 +1,367 @@ +syntax = "proto3"; +package ibc.core.channel.v1; + +import "ibc/core/client/v1/client.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; +import "ibc/core/channel/v1/channel.proto"; +import "google/api/annotations.proto"; +import "google/protobuf/any.proto"; +import "gogoproto/gogo.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/core/04-channel/types"; + +// Query provides defines the gRPC querier service +service Query { + // Channel queries an IBC Channel. + rpc Channel(QueryChannelRequest) returns (QueryChannelResponse) { + option (google.api.http).get = "/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}"; + } + + // Channels queries all the IBC channels of a chain. + rpc Channels(QueryChannelsRequest) returns (QueryChannelsResponse) { + option (google.api.http).get = "/ibc/core/channel/v1beta1/channels"; + } + + // ConnectionChannels queries all the channels associated with a connection + // end. + rpc ConnectionChannels(QueryConnectionChannelsRequest) returns (QueryConnectionChannelsResponse) { + option (google.api.http).get = "/ibc/core/channel/v1beta1/connections/{connection}/channels"; + } + + // ChannelClientState queries for the client state for the channel associated + // with the provided channel identifiers. + rpc ChannelClientState(QueryChannelClientStateRequest) returns (QueryChannelClientStateResponse) { + option (google.api.http).get = "/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/client_state"; + } + + // ChannelConsensusState queries for the consensus state for the channel + // associated with the provided channel identifiers. + rpc ChannelConsensusState(QueryChannelConsensusStateRequest) returns (QueryChannelConsensusStateResponse) { + option (google.api.http).get = + "/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/consensus_state/revision/" + "{revision_number}/height/{revision_height}"; + } + + // PacketCommitment queries a stored packet commitment hash. + rpc PacketCommitment(QueryPacketCommitmentRequest) returns (QueryPacketCommitmentResponse) { + option (google.api.http).get = + "/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_commitments/{sequence}"; + } + + // PacketCommitments returns all the packet commitments hashes associated + // with a channel. + rpc PacketCommitments(QueryPacketCommitmentsRequest) returns (QueryPacketCommitmentsResponse) { + option (google.api.http).get = "/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_commitments"; + } + + // PacketReceipt queries if a given packet sequence has been received on the queried chain + rpc PacketReceipt(QueryPacketReceiptRequest) returns (QueryPacketReceiptResponse) { + option (google.api.http).get = + "/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_receipts/{sequence}"; + } + + // PacketAcknowledgement queries a stored packet acknowledgement hash. + rpc PacketAcknowledgement(QueryPacketAcknowledgementRequest) returns (QueryPacketAcknowledgementResponse) { + option (google.api.http).get = + "/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_acks/{sequence}"; + } + + // PacketAcknowledgements returns all the packet acknowledgements associated + // with a channel. + rpc PacketAcknowledgements(QueryPacketAcknowledgementsRequest) returns (QueryPacketAcknowledgementsResponse) { + option (google.api.http).get = + "/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_acknowledgements"; + } + + // UnreceivedPackets returns all the unreceived IBC packets associated with a + // channel and sequences. + rpc UnreceivedPackets(QueryUnreceivedPacketsRequest) returns (QueryUnreceivedPacketsResponse) { + option (google.api.http).get = "/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_commitments/" + "{packet_commitment_sequences}/unreceived_packets"; + } + + // UnreceivedAcks returns all the unreceived IBC acknowledgements associated with a + // channel and sequences. + rpc UnreceivedAcks(QueryUnreceivedAcksRequest) returns (QueryUnreceivedAcksResponse) { + option (google.api.http).get = "/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_commitments/" + "{packet_ack_sequences}/unreceived_acks"; + } + + // NextSequenceReceive returns the next receive sequence for a given channel. + rpc NextSequenceReceive(QueryNextSequenceReceiveRequest) returns (QueryNextSequenceReceiveResponse) { + option (google.api.http).get = "/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/next_sequence"; + } +} + +// QueryChannelRequest is the request type for the Query/Channel RPC method +message QueryChannelRequest { + // port unique identifier + string port_id = 1; + // channel unique identifier + string channel_id = 2; +} + +// QueryChannelResponse is the response type for the Query/Channel RPC method. +// Besides the Channel end, it includes a proof and the height from which the +// proof was retrieved. +message QueryChannelResponse { + // channel associated with the request identifiers + ibc.core.channel.v1.Channel channel = 1; + // merkle proof of existence + bytes proof = 2; + // height at which the proof was retrieved + ibc.core.client.v1.Height proof_height = 3 [(gogoproto.nullable) = false]; +} + +// QueryChannelsRequest is the request type for the Query/Channels RPC method +message QueryChannelsRequest { + // pagination request + cosmos.base.query.v1beta1.PageRequest pagination = 1; +} + +// QueryChannelsResponse is the response type for the Query/Channels RPC method. +message QueryChannelsResponse { + // list of stored channels of the chain. + repeated ibc.core.channel.v1.IdentifiedChannel channels = 1; + // pagination response + cosmos.base.query.v1beta1.PageResponse pagination = 2; + // query block height + ibc.core.client.v1.Height height = 3 [(gogoproto.nullable) = false]; +} + +// QueryConnectionChannelsRequest is the request type for the +// Query/QueryConnectionChannels RPC method +message QueryConnectionChannelsRequest { + // connection unique identifier + string connection = 1; + // pagination request + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// QueryConnectionChannelsResponse is the Response type for the +// Query/QueryConnectionChannels RPC method +message QueryConnectionChannelsResponse { + // list of channels associated with a connection. + repeated ibc.core.channel.v1.IdentifiedChannel channels = 1; + // pagination response + cosmos.base.query.v1beta1.PageResponse pagination = 2; + // query block height + ibc.core.client.v1.Height height = 3 [(gogoproto.nullable) = false]; +} + +// QueryChannelClientStateRequest is the request type for the Query/ClientState +// RPC method +message QueryChannelClientStateRequest { + // port unique identifier + string port_id = 1; + // channel unique identifier + string channel_id = 2; +} + +// QueryChannelClientStateResponse is the Response type for the +// Query/QueryChannelClientState RPC method +message QueryChannelClientStateResponse { + // client state associated with the channel + ibc.core.client.v1.IdentifiedClientState identified_client_state = 1; + // merkle proof of existence + bytes proof = 2; + // height at which the proof was retrieved + ibc.core.client.v1.Height proof_height = 3 [(gogoproto.nullable) = false]; +} + +// QueryChannelConsensusStateRequest is the request type for the +// Query/ConsensusState RPC method +message QueryChannelConsensusStateRequest { + // port unique identifier + string port_id = 1; + // channel unique identifier + string channel_id = 2; + // revision number of the consensus state + uint64 revision_number = 3; + // revision height of the consensus state + uint64 revision_height = 4; +} + +// QueryChannelClientStateResponse is the Response type for the +// Query/QueryChannelClientState RPC method +message QueryChannelConsensusStateResponse { + // consensus state associated with the channel + google.protobuf.Any consensus_state = 1; + // client ID associated with the consensus state + string client_id = 2; + // merkle proof of existence + bytes proof = 3; + // height at which the proof was retrieved + ibc.core.client.v1.Height proof_height = 4 [(gogoproto.nullable) = false]; +} + +// QueryPacketCommitmentRequest is the request type for the +// Query/PacketCommitment RPC method +message QueryPacketCommitmentRequest { + // port unique identifier + string port_id = 1; + // channel unique identifier + string channel_id = 2; + // packet sequence + uint64 sequence = 3; +} + +// QueryPacketCommitmentResponse defines the client query response for a packet +// which also includes a proof and the height from which the proof was +// retrieved +message QueryPacketCommitmentResponse { + // packet associated with the request fields + bytes commitment = 1; + // merkle proof of existence + bytes proof = 2; + // height at which the proof was retrieved + ibc.core.client.v1.Height proof_height = 3 [(gogoproto.nullable) = false]; +} + +// QueryPacketCommitmentsRequest is the request type for the +// Query/QueryPacketCommitments RPC method +message QueryPacketCommitmentsRequest { + // port unique identifier + string port_id = 1; + // channel unique identifier + string channel_id = 2; + // pagination request + cosmos.base.query.v1beta1.PageRequest pagination = 3; +} + +// QueryPacketCommitmentsResponse is the request type for the +// Query/QueryPacketCommitments RPC method +message QueryPacketCommitmentsResponse { + repeated ibc.core.channel.v1.PacketState commitments = 1; + // pagination response + cosmos.base.query.v1beta1.PageResponse pagination = 2; + // query block height + ibc.core.client.v1.Height height = 3 [(gogoproto.nullable) = false]; +} + +// QueryPacketReceiptRequest is the request type for the +// Query/PacketReceipt RPC method +message QueryPacketReceiptRequest { + // port unique identifier + string port_id = 1; + // channel unique identifier + string channel_id = 2; + // packet sequence + uint64 sequence = 3; +} + +// QueryPacketReceiptResponse defines the client query response for a packet receipt +// which also includes a proof, and the height from which the proof was +// retrieved +message QueryPacketReceiptResponse { + // success flag for if receipt exists + bool received = 2; + // merkle proof of existence + bytes proof = 3; + // height at which the proof was retrieved + ibc.core.client.v1.Height proof_height = 4 [(gogoproto.nullable) = false]; +} + +// QueryPacketAcknowledgementRequest is the request type for the +// Query/PacketAcknowledgement RPC method +message QueryPacketAcknowledgementRequest { + // port unique identifier + string port_id = 1; + // channel unique identifier + string channel_id = 2; + // packet sequence + uint64 sequence = 3; +} + +// QueryPacketAcknowledgementResponse defines the client query response for a +// packet which also includes a proof and the height from which the +// proof was retrieved +message QueryPacketAcknowledgementResponse { + // packet associated with the request fields + bytes acknowledgement = 1; + // merkle proof of existence + bytes proof = 2; + // height at which the proof was retrieved + ibc.core.client.v1.Height proof_height = 3 [(gogoproto.nullable) = false]; +} + +// QueryPacketAcknowledgementsRequest is the request type for the +// Query/QueryPacketCommitments RPC method +message QueryPacketAcknowledgementsRequest { + // port unique identifier + string port_id = 1; + // channel unique identifier + string channel_id = 2; + // pagination request + cosmos.base.query.v1beta1.PageRequest pagination = 3; +} + +// QueryPacketAcknowledgemetsResponse is the request type for the +// Query/QueryPacketAcknowledgements RPC method +message QueryPacketAcknowledgementsResponse { + repeated ibc.core.channel.v1.PacketState acknowledgements = 1; + // pagination response + cosmos.base.query.v1beta1.PageResponse pagination = 2; + // query block height + ibc.core.client.v1.Height height = 3 [(gogoproto.nullable) = false]; +} + +// QueryUnreceivedPacketsRequest is the request type for the +// Query/UnreceivedPackets RPC method +message QueryUnreceivedPacketsRequest { + // port unique identifier + string port_id = 1; + // channel unique identifier + string channel_id = 2; + // list of packet sequences + repeated uint64 packet_commitment_sequences = 3; +} + +// QueryUnreceivedPacketsResponse is the response type for the +// Query/UnreceivedPacketCommitments RPC method +message QueryUnreceivedPacketsResponse { + // list of unreceived packet sequences + repeated uint64 sequences = 1; + // query block height + ibc.core.client.v1.Height height = 2 [(gogoproto.nullable) = false]; +} + +// QueryUnreceivedAcks is the request type for the +// Query/UnreceivedAcks RPC method +message QueryUnreceivedAcksRequest { + // port unique identifier + string port_id = 1; + // channel unique identifier + string channel_id = 2; + // list of acknowledgement sequences + repeated uint64 packet_ack_sequences = 3; +} + +// QueryUnreceivedAcksResponse is the response type for the +// Query/UnreceivedAcks RPC method +message QueryUnreceivedAcksResponse { + // list of unreceived acknowledgement sequences + repeated uint64 sequences = 1; + // query block height + ibc.core.client.v1.Height height = 2 [(gogoproto.nullable) = false]; +} + +// QueryNextSequenceReceiveRequest is the request type for the +// Query/QueryNextSequenceReceiveRequest RPC method +message QueryNextSequenceReceiveRequest { + // port unique identifier + string port_id = 1; + // channel unique identifier + string channel_id = 2; +} + +// QuerySequenceResponse is the request type for the +// Query/QueryNextSequenceReceiveResponse RPC method +message QueryNextSequenceReceiveResponse { + // next sequence receive number + uint64 next_sequence_receive = 1; + // merkle proof of existence + bytes proof = 2; + // height at which the proof was retrieved + ibc.core.client.v1.Height proof_height = 3 [(gogoproto.nullable) = false]; +} diff --git a/third_party/proto/ibc/core/channel/v1/tx.proto b/third_party/proto/ibc/core/channel/v1/tx.proto new file mode 100644 index 0000000..5f84264 --- /dev/null +++ b/third_party/proto/ibc/core/channel/v1/tx.proto @@ -0,0 +1,207 @@ +syntax = "proto3"; +package ibc.core.channel.v1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/core/04-channel/types"; + +import "gogoproto/gogo.proto"; +import "ibc/core/client/v1/client.proto"; +import "ibc/core/channel/v1/channel.proto"; + +// Msg defines the ibc/channel Msg service. +service Msg { + // ChannelOpenInit defines a rpc handler method for MsgChannelOpenInit. + rpc ChannelOpenInit(MsgChannelOpenInit) returns (MsgChannelOpenInitResponse); + + // ChannelOpenTry defines a rpc handler method for MsgChannelOpenTry. + rpc ChannelOpenTry(MsgChannelOpenTry) returns (MsgChannelOpenTryResponse); + + // ChannelOpenAck defines a rpc handler method for MsgChannelOpenAck. + rpc ChannelOpenAck(MsgChannelOpenAck) returns (MsgChannelOpenAckResponse); + + // ChannelOpenConfirm defines a rpc handler method for MsgChannelOpenConfirm. + rpc ChannelOpenConfirm(MsgChannelOpenConfirm) returns (MsgChannelOpenConfirmResponse); + + // ChannelCloseInit defines a rpc handler method for MsgChannelCloseInit. + rpc ChannelCloseInit(MsgChannelCloseInit) returns (MsgChannelCloseInitResponse); + + // ChannelCloseConfirm defines a rpc handler method for MsgChannelCloseConfirm. + rpc ChannelCloseConfirm(MsgChannelCloseConfirm) returns (MsgChannelCloseConfirmResponse); + + // RecvPacket defines a rpc handler method for MsgRecvPacket. + rpc RecvPacket(MsgRecvPacket) returns (MsgRecvPacketResponse); + + // Timeout defines a rpc handler method for MsgTimeout. + rpc Timeout(MsgTimeout) returns (MsgTimeoutResponse); + + // TimeoutOnClose defines a rpc handler method for MsgTimeoutOnClose. + rpc TimeoutOnClose(MsgTimeoutOnClose) returns (MsgTimeoutOnCloseResponse); + + // Acknowledgement defines a rpc handler method for MsgAcknowledgement. + rpc Acknowledgement(MsgAcknowledgement) returns (MsgAcknowledgementResponse); +} + +// MsgChannelOpenInit defines an sdk.Msg to initialize a channel handshake. It +// is called by a relayer on Chain A. +message MsgChannelOpenInit { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string port_id = 1 [(gogoproto.moretags) = "yaml:\"port_id\""]; + Channel channel = 2 [(gogoproto.nullable) = false]; + string signer = 3; +} + +// MsgChannelOpenInitResponse defines the Msg/ChannelOpenInit response type. +message MsgChannelOpenInitResponse {} + +// MsgChannelOpenInit defines a msg sent by a Relayer to try to open a channel +// on Chain B. +message MsgChannelOpenTry { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string port_id = 1 [(gogoproto.moretags) = "yaml:\"port_id\""]; + // in the case of crossing hello's, when both chains call OpenInit, we need the channel identifier + // of the previous channel in state INIT + string previous_channel_id = 2 [(gogoproto.moretags) = "yaml:\"previous_channel_id\""]; + Channel channel = 3 [(gogoproto.nullable) = false]; + string counterparty_version = 4 [(gogoproto.moretags) = "yaml:\"counterparty_version\""]; + bytes proof_init = 5 [(gogoproto.moretags) = "yaml:\"proof_init\""]; + ibc.core.client.v1.Height proof_height = 6 + [(gogoproto.moretags) = "yaml:\"proof_height\"", (gogoproto.nullable) = false]; + string signer = 7; +} + +// MsgChannelOpenTryResponse defines the Msg/ChannelOpenTry response type. +message MsgChannelOpenTryResponse {} + +// MsgChannelOpenAck defines a msg sent by a Relayer to Chain A to acknowledge +// the change of channel state to TRYOPEN on Chain B. +message MsgChannelOpenAck { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string port_id = 1 [(gogoproto.moretags) = "yaml:\"port_id\""]; + string channel_id = 2 [(gogoproto.moretags) = "yaml:\"channel_id\""]; + string counterparty_channel_id = 3 [(gogoproto.moretags) = "yaml:\"counterparty_channel_id\""]; + string counterparty_version = 4 [(gogoproto.moretags) = "yaml:\"counterparty_version\""]; + bytes proof_try = 5 [(gogoproto.moretags) = "yaml:\"proof_try\""]; + ibc.core.client.v1.Height proof_height = 6 + [(gogoproto.moretags) = "yaml:\"proof_height\"", (gogoproto.nullable) = false]; + string signer = 7; +} + +// MsgChannelOpenAckResponse defines the Msg/ChannelOpenAck response type. +message MsgChannelOpenAckResponse {} + +// MsgChannelOpenConfirm defines a msg sent by a Relayer to Chain B to +// acknowledge the change of channel state to OPEN on Chain A. +message MsgChannelOpenConfirm { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string port_id = 1 [(gogoproto.moretags) = "yaml:\"port_id\""]; + string channel_id = 2 [(gogoproto.moretags) = "yaml:\"channel_id\""]; + bytes proof_ack = 3 [(gogoproto.moretags) = "yaml:\"proof_ack\""]; + ibc.core.client.v1.Height proof_height = 4 + [(gogoproto.moretags) = "yaml:\"proof_height\"", (gogoproto.nullable) = false]; + string signer = 5; +} + +// MsgChannelOpenConfirmResponse defines the Msg/ChannelOpenConfirm response type. +message MsgChannelOpenConfirmResponse {} + +// MsgChannelCloseInit defines a msg sent by a Relayer to Chain A +// to close a channel with Chain B. +message MsgChannelCloseInit { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string port_id = 1 [(gogoproto.moretags) = "yaml:\"port_id\""]; + string channel_id = 2 [(gogoproto.moretags) = "yaml:\"channel_id\""]; + string signer = 3; +} + +// MsgChannelCloseInitResponse defines the Msg/ChannelCloseInit response type. +message MsgChannelCloseInitResponse {} + +// MsgChannelCloseConfirm defines a msg sent by a Relayer to Chain B +// to acknowledge the change of channel state to CLOSED on Chain A. +message MsgChannelCloseConfirm { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string port_id = 1 [(gogoproto.moretags) = "yaml:\"port_id\""]; + string channel_id = 2 [(gogoproto.moretags) = "yaml:\"channel_id\""]; + bytes proof_init = 3 [(gogoproto.moretags) = "yaml:\"proof_init\""]; + ibc.core.client.v1.Height proof_height = 4 + [(gogoproto.moretags) = "yaml:\"proof_height\"", (gogoproto.nullable) = false]; + string signer = 5; +} + +// MsgChannelCloseConfirmResponse defines the Msg/ChannelCloseConfirm response type. +message MsgChannelCloseConfirmResponse {} + +// MsgRecvPacket receives incoming IBC packet +message MsgRecvPacket { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + Packet packet = 1 [(gogoproto.nullable) = false]; + bytes proof_commitment = 2 [(gogoproto.moretags) = "yaml:\"proof_commitment\""]; + ibc.core.client.v1.Height proof_height = 3 + [(gogoproto.moretags) = "yaml:\"proof_height\"", (gogoproto.nullable) = false]; + string signer = 4; +} + +// MsgRecvPacketResponse defines the Msg/RecvPacket response type. +message MsgRecvPacketResponse {} + +// MsgTimeout receives timed-out packet +message MsgTimeout { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + Packet packet = 1 [(gogoproto.nullable) = false]; + bytes proof_unreceived = 2 [(gogoproto.moretags) = "yaml:\"proof_unreceived\""]; + ibc.core.client.v1.Height proof_height = 3 + [(gogoproto.moretags) = "yaml:\"proof_height\"", (gogoproto.nullable) = false]; + uint64 next_sequence_recv = 4 [(gogoproto.moretags) = "yaml:\"next_sequence_recv\""]; + string signer = 5; +} + +// MsgTimeoutResponse defines the Msg/Timeout response type. +message MsgTimeoutResponse {} + +// MsgTimeoutOnClose timed-out packet upon counterparty channel closure. +message MsgTimeoutOnClose { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + Packet packet = 1 [(gogoproto.nullable) = false]; + bytes proof_unreceived = 2 [(gogoproto.moretags) = "yaml:\"proof_unreceived\""]; + bytes proof_close = 3 [(gogoproto.moretags) = "yaml:\"proof_close\""]; + ibc.core.client.v1.Height proof_height = 4 + [(gogoproto.moretags) = "yaml:\"proof_height\"", (gogoproto.nullable) = false]; + uint64 next_sequence_recv = 5 [(gogoproto.moretags) = "yaml:\"next_sequence_recv\""]; + string signer = 6; +} + +// MsgTimeoutOnCloseResponse defines the Msg/TimeoutOnClose response type. +message MsgTimeoutOnCloseResponse {} + +// MsgAcknowledgement receives incoming IBC acknowledgement +message MsgAcknowledgement { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + Packet packet = 1 [(gogoproto.nullable) = false]; + bytes acknowledgement = 2; + bytes proof_acked = 3 [(gogoproto.moretags) = "yaml:\"proof_acked\""]; + ibc.core.client.v1.Height proof_height = 4 + [(gogoproto.moretags) = "yaml:\"proof_height\"", (gogoproto.nullable) = false]; + string signer = 5; +} + +// MsgAcknowledgementResponse defines the Msg/Acknowledgement response type. +message MsgAcknowledgementResponse {} diff --git a/third_party/proto/ibc/core/client/v1/client.proto b/third_party/proto/ibc/core/client/v1/client.proto new file mode 100644 index 0000000..11d2195 --- /dev/null +++ b/third_party/proto/ibc/core/client/v1/client.proto @@ -0,0 +1,74 @@ +syntax = "proto3"; +package ibc.core.client.v1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types"; + +import "gogoproto/gogo.proto"; +import "google/protobuf/any.proto"; + +// IdentifiedClientState defines a client state with an additional client +// identifier field. +message IdentifiedClientState { + // client identifier + string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""]; + // client state + google.protobuf.Any client_state = 2 [(gogoproto.moretags) = "yaml:\"client_state\""]; +} + +// ConsensusStateWithHeight defines a consensus state with an additional height field. +message ConsensusStateWithHeight { + // consensus state height + Height height = 1 [(gogoproto.nullable) = false]; + // consensus state + google.protobuf.Any consensus_state = 2 [(gogoproto.moretags) = "yaml\"consensus_state\""]; +} + +// ClientConsensusStates defines all the stored consensus states for a given +// client. +message ClientConsensusStates { + // client identifier + string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""]; + // consensus states and their heights associated with the client + repeated ConsensusStateWithHeight consensus_states = 2 + [(gogoproto.moretags) = "yaml:\"consensus_states\"", (gogoproto.nullable) = false]; +} + +// ClientUpdateProposal is a governance proposal. If it passes, the client is +// updated with the provided header. The update may fail if the header is not +// valid given certain conditions specified by the client implementation. +message ClientUpdateProposal { + option (gogoproto.goproto_getters) = false; + // the title of the update proposal + string title = 1; + // the description of the proposal + string description = 2; + // the client identifier for the client to be updated if the proposal passes + string client_id = 3 [(gogoproto.moretags) = "yaml:\"client_id\""]; + // the header used to update the client if the proposal passes + google.protobuf.Any header = 4; +} + +// Height is a monotonically increasing data type +// that can be compared against another Height for the purposes of updating and +// freezing clients +// +// Normally the RevisionHeight is incremented at each height while keeping RevisionNumber +// the same. However some consensus algorithms may choose to reset the +// height in certain conditions e.g. hard forks, state-machine breaking changes +// In these cases, the RevisionNumber is incremented so that height continues to +// be monitonically increasing even as the RevisionHeight gets reset +message Height { + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = false; + + // the revision that the client is currently on + uint64 revision_number = 1 [(gogoproto.moretags) = "yaml:\"revision_number\""]; + // the height within the given revision + uint64 revision_height = 2 [(gogoproto.moretags) = "yaml:\"revision_height\""]; +} + +// Params defines the set of IBC light client parameters. +message Params { + // allowed_clients defines the list of allowed client state types. + repeated string allowed_clients = 1 [(gogoproto.moretags) = "yaml:\"allowed_clients\""]; +} diff --git a/third_party/proto/ibc/core/client/v1/genesis.proto b/third_party/proto/ibc/core/client/v1/genesis.proto new file mode 100644 index 0000000..16febbc --- /dev/null +++ b/third_party/proto/ibc/core/client/v1/genesis.proto @@ -0,0 +1,46 @@ +syntax = "proto3"; +package ibc.core.client.v1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types"; + +import "ibc/core/client/v1/client.proto"; +import "gogoproto/gogo.proto"; + +// GenesisState defines the ibc client submodule's genesis state. +message GenesisState { + // client states with their corresponding identifiers + repeated IdentifiedClientState clients = 1 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "IdentifiedClientStates"]; + // consensus states from each client + repeated ClientConsensusStates clients_consensus = 2 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "ClientsConsensusStates", + (gogoproto.moretags) = "yaml:\"clients_consensus\"" + ]; + // metadata from each client + repeated IdentifiedGenesisMetadata clients_metadata = 3 + [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"clients_metadata\""]; + Params params = 4 [(gogoproto.nullable) = false]; + // create localhost on initialization + bool create_localhost = 5 [(gogoproto.moretags) = "yaml:\"create_localhost\""]; + // the sequence for the next generated client identifier + uint64 next_client_sequence = 6 [(gogoproto.moretags) = "yaml:\"next_client_sequence\""]; +} + +// GenesisMetadata defines the genesis type for metadata that clients may return +// with ExportMetadata +message GenesisMetadata { + option (gogoproto.goproto_getters) = false; + + // store key of metadata without clientID-prefix + bytes key = 1; + // metadata value + bytes value = 2; +} + +// IdentifiedGenesisMetadata has the client metadata with the corresponding client id. +message IdentifiedGenesisMetadata { + string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""]; + repeated GenesisMetadata client_metadata = 2 + [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"client_metadata\""]; +} \ No newline at end of file diff --git a/third_party/proto/ibc/core/client/v1/query.proto b/third_party/proto/ibc/core/client/v1/query.proto new file mode 100644 index 0000000..97f3acd --- /dev/null +++ b/third_party/proto/ibc/core/client/v1/query.proto @@ -0,0 +1,130 @@ +syntax = "proto3"; +package ibc.core.client.v1; + +import "cosmos/base/query/v1beta1/pagination.proto"; +import "ibc/core/client/v1/client.proto"; +import "google/protobuf/any.proto"; +import "google/api/annotations.proto"; +import "gogoproto/gogo.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types"; + +// Query provides defines the gRPC querier service +service Query { + // ClientState queries an IBC light client. + rpc ClientState(QueryClientStateRequest) returns (QueryClientStateResponse) { + option (google.api.http).get = "/ibc/core/client/v1beta1/client_states/{client_id}"; + } + + // ClientStates queries all the IBC light clients of a chain. + rpc ClientStates(QueryClientStatesRequest) returns (QueryClientStatesResponse) { + option (google.api.http).get = "/ibc/core/client/v1beta1/client_states"; + } + + // ConsensusState queries a consensus state associated with a client state at + // a given height. + rpc ConsensusState(QueryConsensusStateRequest) returns (QueryConsensusStateResponse) { + option (google.api.http).get = "/ibc/core/client/v1beta1/consensus_states/{client_id}/revision/{revision_number}/" + "height/{revision_height}"; + } + + // ConsensusStates queries all the consensus state associated with a given + // client. + rpc ConsensusStates(QueryConsensusStatesRequest) returns (QueryConsensusStatesResponse) { + option (google.api.http).get = "/ibc/core/client/v1beta1/consensus_states/{client_id}"; + } + + // ClientParams queries all parameters of the ibc client. + rpc ClientParams(QueryClientParamsRequest) returns (QueryClientParamsResponse) { + option (google.api.http).get = "/ibc/client/v1beta1/params"; + } +} + +// QueryClientStateRequest is the request type for the Query/ClientState RPC +// method +message QueryClientStateRequest { + // client state unique identifier + string client_id = 1; +} + +// QueryClientStateResponse is the response type for the Query/ClientState RPC +// method. Besides the client state, it includes a proof and the height from +// which the proof was retrieved. +message QueryClientStateResponse { + // client state associated with the request identifier + google.protobuf.Any client_state = 1; + // merkle proof of existence + bytes proof = 2; + // height at which the proof was retrieved + ibc.core.client.v1.Height proof_height = 3 [(gogoproto.nullable) = false]; +} + +// QueryClientStatesRequest is the request type for the Query/ClientStates RPC +// method +message QueryClientStatesRequest { + // pagination request + cosmos.base.query.v1beta1.PageRequest pagination = 1; +} + +// QueryClientStatesResponse is the response type for the Query/ClientStates RPC +// method. +message QueryClientStatesResponse { + // list of stored ClientStates of the chain. + repeated IdentifiedClientState client_states = 1 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "IdentifiedClientStates"]; + // pagination response + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryConsensusStateRequest is the request type for the Query/ConsensusState +// RPC method. Besides the consensus state, it includes a proof and the height +// from which the proof was retrieved. +message QueryConsensusStateRequest { + // client identifier + string client_id = 1; + // consensus state revision number + uint64 revision_number = 2; + // consensus state revision height + uint64 revision_height = 3; + // latest_height overrrides the height field and queries the latest stored + // ConsensusState + bool latest_height = 4; +} + +// QueryConsensusStateResponse is the response type for the Query/ConsensusState +// RPC method +message QueryConsensusStateResponse { + // consensus state associated with the client identifier at the given height + google.protobuf.Any consensus_state = 1; + // merkle proof of existence + bytes proof = 2; + // height at which the proof was retrieved + ibc.core.client.v1.Height proof_height = 3 [(gogoproto.nullable) = false]; +} + +// QueryConsensusStatesRequest is the request type for the Query/ConsensusStates +// RPC method. +message QueryConsensusStatesRequest { + // client identifier + string client_id = 1; + // pagination request + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// QueryConsensusStatesResponse is the response type for the +// Query/ConsensusStates RPC method +message QueryConsensusStatesResponse { + // consensus states associated with the identifier + repeated ConsensusStateWithHeight consensus_states = 1 [(gogoproto.nullable) = false]; + // pagination response + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryClientParamsRequest is the request type for the Query/ClientParams RPC method. +message QueryClientParamsRequest {} + +// QueryClientParamsResponse is the response type for the Query/ClientParams RPC method. +message QueryClientParamsResponse { + // params defines the parameters of the module. + Params params = 1; +} diff --git a/third_party/proto/ibc/core/client/v1/tx.proto b/third_party/proto/ibc/core/client/v1/tx.proto new file mode 100644 index 0000000..a30ec8b --- /dev/null +++ b/third_party/proto/ibc/core/client/v1/tx.proto @@ -0,0 +1,96 @@ +syntax = "proto3"; +package ibc.core.client.v1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types"; + +import "gogoproto/gogo.proto"; +import "google/protobuf/any.proto"; +import "ibc/core/client/v1/client.proto"; + +// Msg defines the ibc/client Msg service. +service Msg { + // CreateClient defines a rpc handler method for MsgCreateClient. + rpc CreateClient(MsgCreateClient) returns (MsgCreateClientResponse); + + // UpdateClient defines a rpc handler method for MsgUpdateClient. + rpc UpdateClient(MsgUpdateClient) returns (MsgUpdateClientResponse); + + // UpgradeClient defines a rpc handler method for MsgUpgradeClient. + rpc UpgradeClient(MsgUpgradeClient) returns (MsgUpgradeClientResponse); + + // SubmitMisbehaviour defines a rpc handler method for MsgSubmitMisbehaviour. + rpc SubmitMisbehaviour(MsgSubmitMisbehaviour) returns (MsgSubmitMisbehaviourResponse); +} + +// MsgCreateClient defines a message to create an IBC client +message MsgCreateClient { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // light client state + google.protobuf.Any client_state = 1 [(gogoproto.moretags) = "yaml:\"client_state\""]; + // consensus state associated with the client that corresponds to a given + // height. + google.protobuf.Any consensus_state = 2 [(gogoproto.moretags) = "yaml:\"consensus_state\""]; + // signer address + string signer = 3; +} + +// MsgCreateClientResponse defines the Msg/CreateClient response type. +message MsgCreateClientResponse {} + +// MsgUpdateClient defines an sdk.Msg to update a IBC client state using +// the given header. +message MsgUpdateClient { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // client unique identifier + string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""]; + // header to update the light client + google.protobuf.Any header = 2; + // signer address + string signer = 3; +} + +// MsgUpdateClientResponse defines the Msg/UpdateClient response type. +message MsgUpdateClientResponse {} + +// MsgUpgradeClient defines an sdk.Msg to upgrade an IBC client to a new client state +message MsgUpgradeClient { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // client unique identifier + string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""]; + // upgraded client state + google.protobuf.Any client_state = 2 [(gogoproto.moretags) = "yaml:\"client_state\""]; + // upgraded consensus state, only contains enough information to serve as a basis of trust in update logic + google.protobuf.Any consensus_state = 3 [(gogoproto.moretags) = "yaml:\"consensus_state\""]; + // proof that old chain committed to new client + bytes proof_upgrade_client = 4 [(gogoproto.moretags) = "yaml:\"proof_upgrade_client\""]; + // proof that old chain committed to new consensus state + bytes proof_upgrade_consensus_state = 5 [(gogoproto.moretags) = "yaml:\"proof_upgrade_consensus_state\""]; + // signer address + string signer = 6; +} + +// MsgUpgradeClientResponse defines the Msg/UpgradeClient response type. +message MsgUpgradeClientResponse {} + +// MsgSubmitMisbehaviour defines an sdk.Msg type that submits Evidence for +// light client misbehaviour. +message MsgSubmitMisbehaviour { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // client unique identifier + string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""]; + // misbehaviour used for freezing the light client + google.protobuf.Any misbehaviour = 2; + // signer address + string signer = 3; +} + +// MsgSubmitMisbehaviourResponse defines the Msg/SubmitMisbehaviour response type. +message MsgSubmitMisbehaviourResponse {} diff --git a/third_party/proto/ibc/core/commitment/v1/commitment.proto b/third_party/proto/ibc/core/commitment/v1/commitment.proto new file mode 100644 index 0000000..51c1027 --- /dev/null +++ b/third_party/proto/ibc/core/commitment/v1/commitment.proto @@ -0,0 +1,40 @@ +syntax = "proto3"; +package ibc.core.commitment.v1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/core/23-commitment/types"; + +import "gogoproto/gogo.proto"; +import "confio/proofs.proto"; + +// MerkleRoot defines a merkle root hash. +// In the Cosmos SDK, the AppHash of a block header becomes the root. +message MerkleRoot { + option (gogoproto.goproto_getters) = false; + + bytes hash = 1; +} + +// MerklePrefix is merkle path prefixed to the key. +// The constructed key from the Path and the key will be append(Path.KeyPath, +// append(Path.KeyPrefix, key...)) +message MerklePrefix { + bytes key_prefix = 1 [(gogoproto.moretags) = "yaml:\"key_prefix\""]; +} + +// MerklePath is the path used to verify commitment proofs, which can be an +// arbitrary structured object (defined by a commitment type). +// MerklePath is represented from root-to-leaf +message MerklePath { + option (gogoproto.goproto_stringer) = false; + + repeated string key_path = 1 [(gogoproto.moretags) = "yaml:\"key_path\""]; +} + +// MerkleProof is a wrapper type over a chain of CommitmentProofs. +// It demonstrates membership or non-membership for an element or set of +// elements, verifiable in conjunction with a known commitment root. Proofs +// should be succinct. +// MerkleProofs are ordered from leaf-to-root +message MerkleProof { + repeated ics23.CommitmentProof proofs = 1; +} \ No newline at end of file diff --git a/third_party/proto/ibc/core/connection/v1/connection.proto b/third_party/proto/ibc/core/connection/v1/connection.proto new file mode 100644 index 0000000..d21e595 --- /dev/null +++ b/third_party/proto/ibc/core/connection/v1/connection.proto @@ -0,0 +1,104 @@ +syntax = "proto3"; +package ibc.core.connection.v1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/core/03-connection/types"; + +import "gogoproto/gogo.proto"; +import "ibc/core/commitment/v1/commitment.proto"; + +// ICS03 - Connection Data Structures as defined in +// https://github.com/cosmos/ics/tree/master/spec/ics-003-connection-semantics#data-structures + +// ConnectionEnd defines a stateful object on a chain connected to another +// separate one. +// NOTE: there must only be 2 defined ConnectionEnds to establish +// a connection between two chains. +message ConnectionEnd { + option (gogoproto.goproto_getters) = false; + // client associated with this connection. + string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""]; + // IBC version which can be utilised to determine encodings or protocols for + // channels or packets utilising this connection. + repeated Version versions = 2; + // current state of the connection end. + State state = 3; + // counterparty chain associated with this connection. + Counterparty counterparty = 4 [(gogoproto.nullable) = false]; + // delay period that must pass before a consensus state can be used for packet-verification + // NOTE: delay period logic is only implemented by some clients. + uint64 delay_period = 5 [(gogoproto.moretags) = "yaml:\"delay_period\""]; +} + +// IdentifiedConnection defines a connection with additional connection +// identifier field. +message IdentifiedConnection { + option (gogoproto.goproto_getters) = false; + // connection identifier. + string id = 1 [(gogoproto.moretags) = "yaml:\"id\""]; + // client associated with this connection. + string client_id = 2 [(gogoproto.moretags) = "yaml:\"client_id\""]; + // IBC version which can be utilised to determine encodings or protocols for + // channels or packets utilising this connection + repeated Version versions = 3; + // current state of the connection end. + State state = 4; + // counterparty chain associated with this connection. + Counterparty counterparty = 5 [(gogoproto.nullable) = false]; + // delay period associated with this connection. + uint64 delay_period = 6 [(gogoproto.moretags) = "yaml:\"delay_period\""]; +} + +// State defines if a connection is in one of the following states: +// INIT, TRYOPEN, OPEN or UNINITIALIZED. +enum State { + option (gogoproto.goproto_enum_prefix) = false; + + // Default State + STATE_UNINITIALIZED_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "UNINITIALIZED"]; + // A connection end has just started the opening handshake. + STATE_INIT = 1 [(gogoproto.enumvalue_customname) = "INIT"]; + // A connection end has acknowledged the handshake step on the counterparty + // chain. + STATE_TRYOPEN = 2 [(gogoproto.enumvalue_customname) = "TRYOPEN"]; + // A connection end has completed the handshake. + STATE_OPEN = 3 [(gogoproto.enumvalue_customname) = "OPEN"]; +} + +// Counterparty defines the counterparty chain associated with a connection end. +message Counterparty { + option (gogoproto.goproto_getters) = false; + + // identifies the client on the counterparty chain associated with a given + // connection. + string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""]; + // identifies the connection end on the counterparty chain associated with a + // given connection. + string connection_id = 2 [(gogoproto.moretags) = "yaml:\"connection_id\""]; + // commitment merkle prefix of the counterparty chain. + ibc.core.commitment.v1.MerklePrefix prefix = 3 [(gogoproto.nullable) = false]; +} + +// ClientPaths define all the connection paths for a client state. +message ClientPaths { + // list of connection paths + repeated string paths = 1; +} + +// ConnectionPaths define all the connection paths for a given client state. +message ConnectionPaths { + // client state unique identifier + string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""]; + // list of connection paths + repeated string paths = 2; +} + +// Version defines the versioning scheme used to negotiate the IBC verison in +// the connection handshake. +message Version { + option (gogoproto.goproto_getters) = false; + + // unique version identifier + string identifier = 1; + // list of features compatible with the specified identifier + repeated string features = 2; +} diff --git a/third_party/proto/ibc/core/connection/v1/genesis.proto b/third_party/proto/ibc/core/connection/v1/genesis.proto new file mode 100644 index 0000000..11df4ba --- /dev/null +++ b/third_party/proto/ibc/core/connection/v1/genesis.proto @@ -0,0 +1,16 @@ +syntax = "proto3"; +package ibc.core.connection.v1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/core/03-connection/types"; + +import "gogoproto/gogo.proto"; +import "ibc/core/connection/v1/connection.proto"; + +// GenesisState defines the ibc connection submodule's genesis state. +message GenesisState { + repeated IdentifiedConnection connections = 1 [(gogoproto.nullable) = false]; + repeated ConnectionPaths client_connection_paths = 2 + [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"client_connection_paths\""]; + // the sequence for the next generated connection identifier + uint64 next_connection_sequence = 3 [(gogoproto.moretags) = "yaml:\"next_connection_sequence\""]; +} diff --git a/third_party/proto/ibc/core/connection/v1/query.proto b/third_party/proto/ibc/core/connection/v1/query.proto new file mode 100644 index 0000000..c5085a1 --- /dev/null +++ b/third_party/proto/ibc/core/connection/v1/query.proto @@ -0,0 +1,137 @@ +syntax = "proto3"; +package ibc.core.connection.v1; + +import "gogoproto/gogo.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; +import "ibc/core/client/v1/client.proto"; +import "ibc/core/connection/v1/connection.proto"; +import "google/api/annotations.proto"; +import "google/protobuf/any.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/core/03-connection/types"; + +// Query provides defines the gRPC querier service +service Query { + // Connection queries an IBC connection end. + rpc Connection(QueryConnectionRequest) returns (QueryConnectionResponse) { + option (google.api.http).get = "/ibc/core/connection/v1beta1/connections/{connection_id}"; + } + + // Connections queries all the IBC connections of a chain. + rpc Connections(QueryConnectionsRequest) returns (QueryConnectionsResponse) { + option (google.api.http).get = "/ibc/core/connection/v1beta1/connections"; + } + + // ClientConnections queries the connection paths associated with a client + // state. + rpc ClientConnections(QueryClientConnectionsRequest) returns (QueryClientConnectionsResponse) { + option (google.api.http).get = "/ibc/core/connection/v1beta1/client_connections/{client_id}"; + } + + // ConnectionClientState queries the client state associated with the + // connection. + rpc ConnectionClientState(QueryConnectionClientStateRequest) returns (QueryConnectionClientStateResponse) { + option (google.api.http).get = "/ibc/core/connection/v1beta1/connections/{connection_id}/client_state"; + } + + // ConnectionConsensusState queries the consensus state associated with the + // connection. + rpc ConnectionConsensusState(QueryConnectionConsensusStateRequest) returns (QueryConnectionConsensusStateResponse) { + option (google.api.http).get = "/ibc/core/connection/v1beta1/connections/{connection_id}/consensus_state/" + "revision/{revision_number}/height/{revision_height}"; + } +} + +// QueryConnectionRequest is the request type for the Query/Connection RPC +// method +message QueryConnectionRequest { + // connection unique identifier + string connection_id = 1; +} + +// QueryConnectionResponse is the response type for the Query/Connection RPC +// method. Besides the connection end, it includes a proof and the height from +// which the proof was retrieved. +message QueryConnectionResponse { + // connection associated with the request identifier + ibc.core.connection.v1.ConnectionEnd connection = 1; + // merkle proof of existence + bytes proof = 2; + // height at which the proof was retrieved + ibc.core.client.v1.Height proof_height = 3 [(gogoproto.nullable) = false]; +} + +// QueryConnectionsRequest is the request type for the Query/Connections RPC +// method +message QueryConnectionsRequest { + cosmos.base.query.v1beta1.PageRequest pagination = 1; +} + +// QueryConnectionsResponse is the response type for the Query/Connections RPC +// method. +message QueryConnectionsResponse { + // list of stored connections of the chain. + repeated ibc.core.connection.v1.IdentifiedConnection connections = 1; + // pagination response + cosmos.base.query.v1beta1.PageResponse pagination = 2; + // query block height + ibc.core.client.v1.Height height = 3 [(gogoproto.nullable) = false]; +} + +// QueryClientConnectionsRequest is the request type for the +// Query/ClientConnections RPC method +message QueryClientConnectionsRequest { + // client identifier associated with a connection + string client_id = 1; +} + +// QueryClientConnectionsResponse is the response type for the +// Query/ClientConnections RPC method +message QueryClientConnectionsResponse { + // slice of all the connection paths associated with a client. + repeated string connection_paths = 1; + // merkle proof of existence + bytes proof = 2; + // height at which the proof was generated + ibc.core.client.v1.Height proof_height = 3 [(gogoproto.nullable) = false]; +} + +// QueryConnectionClientStateRequest is the request type for the +// Query/ConnectionClientState RPC method +message QueryConnectionClientStateRequest { + // connection identifier + string connection_id = 1 [(gogoproto.moretags) = "yaml:\"connection_id\""]; +} + +// QueryConnectionClientStateResponse is the response type for the +// Query/ConnectionClientState RPC method +message QueryConnectionClientStateResponse { + // client state associated with the channel + ibc.core.client.v1.IdentifiedClientState identified_client_state = 1; + // merkle proof of existence + bytes proof = 2; + // height at which the proof was retrieved + ibc.core.client.v1.Height proof_height = 3 [(gogoproto.nullable) = false]; +} + +// QueryConnectionConsensusStateRequest is the request type for the +// Query/ConnectionConsensusState RPC method +message QueryConnectionConsensusStateRequest { + // connection identifier + string connection_id = 1 [(gogoproto.moretags) = "yaml:\"connection_id\""]; + uint64 revision_number = 2; + uint64 revision_height = 3; +} + +// QueryConnectionConsensusStateResponse is the response type for the +// Query/ConnectionConsensusState RPC method +message QueryConnectionConsensusStateResponse { + // consensus state associated with the channel + google.protobuf.Any consensus_state = 1; + // client ID associated with the consensus state + string client_id = 2; + // merkle proof of existence + bytes proof = 3; + // height at which the proof was retrieved + ibc.core.client.v1.Height proof_height = 4 [(gogoproto.nullable) = false]; +} diff --git a/third_party/proto/ibc/core/connection/v1/tx.proto b/third_party/proto/ibc/core/connection/v1/tx.proto new file mode 100644 index 0000000..19b40c6 --- /dev/null +++ b/third_party/proto/ibc/core/connection/v1/tx.proto @@ -0,0 +1,115 @@ +syntax = "proto3"; +package ibc.core.connection.v1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/core/03-connection/types"; + +import "gogoproto/gogo.proto"; +import "google/protobuf/any.proto"; +import "ibc/core/client/v1/client.proto"; +import "ibc/core/connection/v1/connection.proto"; + +// Msg defines the ibc/connection Msg service. +service Msg { + // ConnectionOpenInit defines a rpc handler method for MsgConnectionOpenInit. + rpc ConnectionOpenInit(MsgConnectionOpenInit) returns (MsgConnectionOpenInitResponse); + + // ConnectionOpenTry defines a rpc handler method for MsgConnectionOpenTry. + rpc ConnectionOpenTry(MsgConnectionOpenTry) returns (MsgConnectionOpenTryResponse); + + // ConnectionOpenAck defines a rpc handler method for MsgConnectionOpenAck. + rpc ConnectionOpenAck(MsgConnectionOpenAck) returns (MsgConnectionOpenAckResponse); + + // ConnectionOpenConfirm defines a rpc handler method for MsgConnectionOpenConfirm. + rpc ConnectionOpenConfirm(MsgConnectionOpenConfirm) returns (MsgConnectionOpenConfirmResponse); +} + +// MsgConnectionOpenInit defines the msg sent by an account on Chain A to +// initialize a connection with Chain B. +message MsgConnectionOpenInit { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""]; + Counterparty counterparty = 2 [(gogoproto.nullable) = false]; + Version version = 3; + uint64 delay_period = 4 [(gogoproto.moretags) = "yaml:\"delay_period\""]; + string signer = 5; +} + +// MsgConnectionOpenInitResponse defines the Msg/ConnectionOpenInit response type. +message MsgConnectionOpenInitResponse {} + +// MsgConnectionOpenTry defines a msg sent by a Relayer to try to open a +// connection on Chain B. +message MsgConnectionOpenTry { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""]; + // in the case of crossing hello's, when both chains call OpenInit, we need the connection identifier + // of the previous connection in state INIT + string previous_connection_id = 2 [(gogoproto.moretags) = "yaml:\"previous_connection_id\""]; + google.protobuf.Any client_state = 3 [(gogoproto.moretags) = "yaml:\"client_state\""]; + Counterparty counterparty = 4 [(gogoproto.nullable) = false]; + uint64 delay_period = 5 [(gogoproto.moretags) = "yaml:\"delay_period\""]; + repeated Version counterparty_versions = 6 [(gogoproto.moretags) = "yaml:\"counterparty_versions\""]; + ibc.core.client.v1.Height proof_height = 7 + [(gogoproto.moretags) = "yaml:\"proof_height\"", (gogoproto.nullable) = false]; + // proof of the initialization the connection on Chain A: `UNITIALIZED -> + // INIT` + bytes proof_init = 8 [(gogoproto.moretags) = "yaml:\"proof_init\""]; + // proof of client state included in message + bytes proof_client = 9 [(gogoproto.moretags) = "yaml:\"proof_client\""]; + // proof of client consensus state + bytes proof_consensus = 10 [(gogoproto.moretags) = "yaml:\"proof_consensus\""]; + ibc.core.client.v1.Height consensus_height = 11 + [(gogoproto.moretags) = "yaml:\"consensus_height\"", (gogoproto.nullable) = false]; + string signer = 12; +} + +// MsgConnectionOpenTryResponse defines the Msg/ConnectionOpenTry response type. +message MsgConnectionOpenTryResponse {} + +// MsgConnectionOpenAck defines a msg sent by a Relayer to Chain A to +// acknowledge the change of connection state to TRYOPEN on Chain B. +message MsgConnectionOpenAck { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string connection_id = 1 [(gogoproto.moretags) = "yaml:\"connection_id\""]; + string counterparty_connection_id = 2 [(gogoproto.moretags) = "yaml:\"counterparty_connection_id\""]; + Version version = 3; + google.protobuf.Any client_state = 4 [(gogoproto.moretags) = "yaml:\"client_state\""]; + ibc.core.client.v1.Height proof_height = 5 + [(gogoproto.moretags) = "yaml:\"proof_height\"", (gogoproto.nullable) = false]; + // proof of the initialization the connection on Chain B: `UNITIALIZED -> + // TRYOPEN` + bytes proof_try = 6 [(gogoproto.moretags) = "yaml:\"proof_try\""]; + // proof of client state included in message + bytes proof_client = 7 [(gogoproto.moretags) = "yaml:\"proof_client\""]; + // proof of client consensus state + bytes proof_consensus = 8 [(gogoproto.moretags) = "yaml:\"proof_consensus\""]; + ibc.core.client.v1.Height consensus_height = 9 + [(gogoproto.moretags) = "yaml:\"consensus_height\"", (gogoproto.nullable) = false]; + string signer = 10; +} + +// MsgConnectionOpenAckResponse defines the Msg/ConnectionOpenAck response type. +message MsgConnectionOpenAckResponse {} + +// MsgConnectionOpenConfirm defines a msg sent by a Relayer to Chain B to +// acknowledge the change of connection state to OPEN on Chain A. +message MsgConnectionOpenConfirm { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string connection_id = 1 [(gogoproto.moretags) = "yaml:\"connection_id\""]; + // proof for the change of the connection state on Chain A: `INIT -> OPEN` + bytes proof_ack = 2 [(gogoproto.moretags) = "yaml:\"proof_ack\""]; + ibc.core.client.v1.Height proof_height = 3 + [(gogoproto.moretags) = "yaml:\"proof_height\"", (gogoproto.nullable) = false]; + string signer = 4; +} + +// MsgConnectionOpenConfirmResponse defines the Msg/ConnectionOpenConfirm response type. +message MsgConnectionOpenConfirmResponse {} diff --git a/third_party/proto/ibc/core/types/v1/genesis.proto b/third_party/proto/ibc/core/types/v1/genesis.proto new file mode 100644 index 0000000..ace5085 --- /dev/null +++ b/third_party/proto/ibc/core/types/v1/genesis.proto @@ -0,0 +1,22 @@ +syntax = "proto3"; +package ibc.core.types.v1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/core/types"; + +import "gogoproto/gogo.proto"; +import "ibc/core/client/v1/genesis.proto"; +import "ibc/core/connection/v1/genesis.proto"; +import "ibc/core/channel/v1/genesis.proto"; + +// GenesisState defines the ibc module's genesis state. +message GenesisState { + // ICS002 - Clients genesis state + ibc.core.client.v1.GenesisState client_genesis = 1 + [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"client_genesis\""]; + // ICS003 - Connections genesis state + ibc.core.connection.v1.GenesisState connection_genesis = 2 + [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"connection_genesis\""]; + // ICS004 - Channel genesis state + ibc.core.channel.v1.GenesisState channel_genesis = 3 + [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"channel_genesis\""]; +} diff --git a/third_party/proto/ibc/lightclients/localhost/v1/localhost.proto b/third_party/proto/ibc/lightclients/localhost/v1/localhost.proto new file mode 100644 index 0000000..d48a1c0 --- /dev/null +++ b/third_party/proto/ibc/lightclients/localhost/v1/localhost.proto @@ -0,0 +1,17 @@ +syntax = "proto3"; +package ibc.lightclients.localhost.v1; + +import "gogoproto/gogo.proto"; +import "ibc/core/client/v1/client.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/light-clients/09-localhost/types"; + +// ClientState defines a loopback (localhost) client. It requires (read-only) +// access to keys outside the client prefix. +message ClientState { + option (gogoproto.goproto_getters) = false; + // self chain ID + string chain_id = 1 [(gogoproto.moretags) = "yaml:\"chain_id\""]; + // self latest block height + ibc.core.client.v1.Height height = 2 [(gogoproto.nullable) = false]; +} diff --git a/third_party/proto/ibc/lightclients/solomachine/v1/solomachine.proto b/third_party/proto/ibc/lightclients/solomachine/v1/solomachine.proto new file mode 100644 index 0000000..89686f3 --- /dev/null +++ b/third_party/proto/ibc/lightclients/solomachine/v1/solomachine.proto @@ -0,0 +1,186 @@ +syntax = "proto3"; +package ibc.lightclients.solomachine.v1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/light-clients/06-solomachine/types"; + +import "ibc/core/connection/v1/connection.proto"; +import "ibc/core/channel/v1/channel.proto"; +import "gogoproto/gogo.proto"; +import "google/protobuf/any.proto"; + +// ClientState defines a solo machine client that tracks the current consensus +// state and if the client is frozen. +message ClientState { + option (gogoproto.goproto_getters) = false; + // latest sequence of the client state + uint64 sequence = 1; + // frozen sequence of the solo machine + uint64 frozen_sequence = 2 [(gogoproto.moretags) = "yaml:\"frozen_sequence\""]; + ConsensusState consensus_state = 3 [(gogoproto.moretags) = "yaml:\"consensus_state\""]; + // when set to true, will allow governance to update a solo machine client. + // The client will be unfrozen if it is frozen. + bool allow_update_after_proposal = 4 [(gogoproto.moretags) = "yaml:\"allow_update_after_proposal\""]; +} + +// ConsensusState defines a solo machine consensus state. The sequence of a consensus state +// is contained in the "height" key used in storing the consensus state. +message ConsensusState { + option (gogoproto.goproto_getters) = false; + // public key of the solo machine + google.protobuf.Any public_key = 1 [(gogoproto.moretags) = "yaml:\"public_key\""]; + // diversifier allows the same public key to be re-used across different solo machine clients + // (potentially on different chains) without being considered misbehaviour. + string diversifier = 2; + uint64 timestamp = 3; +} + +// Header defines a solo machine consensus header +message Header { + option (gogoproto.goproto_getters) = false; + // sequence to update solo machine public key at + uint64 sequence = 1; + uint64 timestamp = 2; + bytes signature = 3; + google.protobuf.Any new_public_key = 4 [(gogoproto.moretags) = "yaml:\"new_public_key\""]; + string new_diversifier = 5 [(gogoproto.moretags) = "yaml:\"new_diversifier\""]; +} + +// Misbehaviour defines misbehaviour for a solo machine which consists +// of a sequence and two signatures over different messages at that sequence. +message Misbehaviour { + option (gogoproto.goproto_getters) = false; + string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""]; + uint64 sequence = 2; + SignatureAndData signature_one = 3 [(gogoproto.moretags) = "yaml:\"signature_one\""]; + SignatureAndData signature_two = 4 [(gogoproto.moretags) = "yaml:\"signature_two\""]; +} + +// SignatureAndData contains a signature and the data signed over to create that +// signature. +message SignatureAndData { + option (gogoproto.goproto_getters) = false; + bytes signature = 1; + DataType data_type = 2 [(gogoproto.moretags) = "yaml:\"data_type\""]; + bytes data = 3; + uint64 timestamp = 4; +} + +// TimestampedSignatureData contains the signature data and the timestamp of the +// signature. +message TimestampedSignatureData { + option (gogoproto.goproto_getters) = false; + bytes signature_data = 1 [(gogoproto.moretags) = "yaml:\"signature_data\""]; + uint64 timestamp = 2; +} + +// SignBytes defines the signed bytes used for signature verification. +message SignBytes { + option (gogoproto.goproto_getters) = false; + + uint64 sequence = 1; + uint64 timestamp = 2; + string diversifier = 3; + // type of the data used + DataType data_type = 4 [(gogoproto.moretags) = "yaml:\"data_type\""]; + // marshaled data + bytes data = 5; +} + +// DataType defines the type of solo machine proof being created. This is done to preserve uniqueness of different +// data sign byte encodings. +enum DataType { + option (gogoproto.goproto_enum_prefix) = false; + + // Default State + DATA_TYPE_UNINITIALIZED_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "UNSPECIFIED"]; + // Data type for client state verification + DATA_TYPE_CLIENT_STATE = 1 [(gogoproto.enumvalue_customname) = "CLIENT"]; + // Data type for consensus state verification + DATA_TYPE_CONSENSUS_STATE = 2 [(gogoproto.enumvalue_customname) = "CONSENSUS"]; + // Data type for connection state verification + DATA_TYPE_CONNECTION_STATE = 3 [(gogoproto.enumvalue_customname) = "CONNECTION"]; + // Data type for channel state verification + DATA_TYPE_CHANNEL_STATE = 4 [(gogoproto.enumvalue_customname) = "CHANNEL"]; + // Data type for packet commitment verification + DATA_TYPE_PACKET_COMMITMENT = 5 [(gogoproto.enumvalue_customname) = "PACKETCOMMITMENT"]; + // Data type for packet acknowledgement verification + DATA_TYPE_PACKET_ACKNOWLEDGEMENT = 6 [(gogoproto.enumvalue_customname) = "PACKETACKNOWLEDGEMENT"]; + // Data type for packet receipt absence verification + DATA_TYPE_PACKET_RECEIPT_ABSENCE = 7 [(gogoproto.enumvalue_customname) = "PACKETRECEIPTABSENCE"]; + // Data type for next sequence recv verification + DATA_TYPE_NEXT_SEQUENCE_RECV = 8 [(gogoproto.enumvalue_customname) = "NEXTSEQUENCERECV"]; + // Data type for header verification + DATA_TYPE_HEADER = 9 [(gogoproto.enumvalue_customname) = "HEADER"]; +} + +// HeaderData returns the SignBytes data for update verification. +message HeaderData { + option (gogoproto.goproto_getters) = false; + + // header public key + google.protobuf.Any new_pub_key = 1 [(gogoproto.moretags) = "yaml:\"new_pub_key\""]; + // header diversifier + string new_diversifier = 2 [(gogoproto.moretags) = "yaml:\"new_diversifier\""]; +} + +// ClientStateData returns the SignBytes data for client state verification. +message ClientStateData { + option (gogoproto.goproto_getters) = false; + + bytes path = 1; + google.protobuf.Any client_state = 2 [(gogoproto.moretags) = "yaml:\"client_state\""]; +} + +// ConsensusStateData returns the SignBytes data for consensus state +// verification. +message ConsensusStateData { + option (gogoproto.goproto_getters) = false; + + bytes path = 1; + google.protobuf.Any consensus_state = 2 [(gogoproto.moretags) = "yaml:\"consensus_state\""]; +} + +// ConnectionStateData returns the SignBytes data for connection state +// verification. +message ConnectionStateData { + option (gogoproto.goproto_getters) = false; + + bytes path = 1; + ibc.core.connection.v1.ConnectionEnd connection = 2; +} + +// ChannelStateData returns the SignBytes data for channel state +// verification. +message ChannelStateData { + option (gogoproto.goproto_getters) = false; + + bytes path = 1; + ibc.core.channel.v1.Channel channel = 2; +} + +// PacketCommitmentData returns the SignBytes data for packet commitment +// verification. +message PacketCommitmentData { + bytes path = 1; + bytes commitment = 2; +} + +// PacketAcknowledgementData returns the SignBytes data for acknowledgement +// verification. +message PacketAcknowledgementData { + bytes path = 1; + bytes acknowledgement = 2; +} + +// PacketReceiptAbsenceData returns the SignBytes data for +// packet receipt absence verification. +message PacketReceiptAbsenceData { + bytes path = 1; +} + +// NextSequenceRecvData returns the SignBytes data for verification of the next +// sequence to be received. +message NextSequenceRecvData { + bytes path = 1; + uint64 next_seq_recv = 2 [(gogoproto.moretags) = "yaml:\"next_seq_recv\""]; +} diff --git a/third_party/proto/ibc/lightclients/tendermint/v1/tendermint.proto b/third_party/proto/ibc/lightclients/tendermint/v1/tendermint.proto new file mode 100644 index 0000000..a6882bf --- /dev/null +++ b/third_party/proto/ibc/lightclients/tendermint/v1/tendermint.proto @@ -0,0 +1,111 @@ +syntax = "proto3"; +package ibc.lightclients.tendermint.v1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/light-clients/07-tendermint/types"; + +import "tendermint/types/validator.proto"; +import "tendermint/types/types.proto"; +import "confio/proofs.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; +import "ibc/core/client/v1/client.proto"; +import "ibc/core/commitment/v1/commitment.proto"; +import "gogoproto/gogo.proto"; + +// ClientState from Tendermint tracks the current validator set, latest height, +// and a possible frozen height. +message ClientState { + option (gogoproto.goproto_getters) = false; + + string chain_id = 1; + Fraction trust_level = 2 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"trust_level\""]; + // duration of the period since the LastestTimestamp during which the + // submitted headers are valid for upgrade + google.protobuf.Duration trusting_period = 3 + [(gogoproto.nullable) = false, (gogoproto.stdduration) = true, (gogoproto.moretags) = "yaml:\"trusting_period\""]; + // duration of the staking unbonding period + google.protobuf.Duration unbonding_period = 4 [ + (gogoproto.nullable) = false, + (gogoproto.stdduration) = true, + (gogoproto.moretags) = "yaml:\"unbonding_period\"" + ]; + // defines how much new (untrusted) header's Time can drift into the future. + google.protobuf.Duration max_clock_drift = 5 + [(gogoproto.nullable) = false, (gogoproto.stdduration) = true, (gogoproto.moretags) = "yaml:\"max_clock_drift\""]; + // Block height when the client was frozen due to a misbehaviour + ibc.core.client.v1.Height frozen_height = 6 + [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"frozen_height\""]; + // Latest height the client was updated to + ibc.core.client.v1.Height latest_height = 7 + [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"latest_height\""]; + + // Proof specifications used in verifying counterparty state + repeated ics23.ProofSpec proof_specs = 8 [(gogoproto.moretags) = "yaml:\"proof_specs\""]; + + // Path at which next upgraded client will be committed. + // Each element corresponds to the key for a single CommitmentProof in the chained proof. + // NOTE: ClientState must stored under `{upgradePath}/{upgradeHeight}/clientState` + // ConsensusState must be stored under `{upgradepath}/{upgradeHeight}/consensusState` + // For SDK chains using the default upgrade module, upgrade_path should be []string{"upgrade", "upgradedIBCState"}` + repeated string upgrade_path = 9 [(gogoproto.moretags) = "yaml:\"upgrade_path\""]; + + // This flag, when set to true, will allow governance to recover a client + // which has expired + bool allow_update_after_expiry = 10 [(gogoproto.moretags) = "yaml:\"allow_update_after_expiry\""]; + // This flag, when set to true, will allow governance to unfreeze a client + // whose chain has experienced a misbehaviour event + bool allow_update_after_misbehaviour = 11 [(gogoproto.moretags) = "yaml:\"allow_update_after_misbehaviour\""]; +} + +// ConsensusState defines the consensus state from Tendermint. +message ConsensusState { + option (gogoproto.goproto_getters) = false; + + // timestamp that corresponds to the block height in which the ConsensusState + // was stored. + google.protobuf.Timestamp timestamp = 1 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; + // commitment root (i.e app hash) + ibc.core.commitment.v1.MerkleRoot root = 2 [(gogoproto.nullable) = false]; + bytes next_validators_hash = 3 [ + (gogoproto.casttype) = "github.com/tendermint/tendermint/libs/bytes.HexBytes", + (gogoproto.moretags) = "yaml:\"next_validators_hash\"" + ]; +} + +// Misbehaviour is a wrapper over two conflicting Headers +// that implements Misbehaviour interface expected by ICS-02 +message Misbehaviour { + option (gogoproto.goproto_getters) = false; + + string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""]; + Header header_1 = 2 [(gogoproto.customname) = "Header1", (gogoproto.moretags) = "yaml:\"header_1\""]; + Header header_2 = 3 [(gogoproto.customname) = "Header2", (gogoproto.moretags) = "yaml:\"header_2\""]; +} + +// Header defines the Tendermint client consensus Header. +// It encapsulates all the information necessary to update from a trusted +// Tendermint ConsensusState. The inclusion of TrustedHeight and +// TrustedValidators allows this update to process correctly, so long as the +// ConsensusState for the TrustedHeight exists, this removes race conditions +// among relayers The SignedHeader and ValidatorSet are the new untrusted update +// fields for the client. The TrustedHeight is the height of a stored +// ConsensusState on the client that will be used to verify the new untrusted +// header. The Trusted ConsensusState must be within the unbonding period of +// current time in order to correctly verify, and the TrustedValidators must +// hash to TrustedConsensusState.NextValidatorsHash since that is the last +// trusted validator set at the TrustedHeight. +message Header { + .tendermint.types.SignedHeader signed_header = 1 + [(gogoproto.embed) = true, (gogoproto.moretags) = "yaml:\"signed_header\""]; + + .tendermint.types.ValidatorSet validator_set = 2 [(gogoproto.moretags) = "yaml:\"validator_set\""]; + ibc.core.client.v1.Height trusted_height = 3 + [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"trusted_height\""]; + .tendermint.types.ValidatorSet trusted_validators = 4 [(gogoproto.moretags) = "yaml:\"trusted_validators\""]; +} + +// Fraction defines the protobuf message type for tmmath.Fraction that only supports positive values. +message Fraction { + uint64 numerator = 1; + uint64 denominator = 2; +} diff --git a/x/common/vm_storage/storage.go b/x/common/vm_storage/storage.go deleted file mode 100644 index e393e47..0000000 --- a/x/common/vm_storage/storage.go +++ /dev/null @@ -1,110 +0,0 @@ -package vm_storage - -import ( - "bytes" - "fmt" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/dfinance/dvm-proto/go/vm_grpc" -) - -const ( - // Default address length (Move address length) - VMAddressLength = 20 -) - -var ( - // Storage keys - KeyDelimiter = []byte(":") // we should rely on this delimiter (for bytes.Split for example) as VM accessPath.Path might include symbols like: [':', '@',..] - VMKey = []byte("vm") - // Move stdlib addresses - StdLibAddress = make([]byte, VMAddressLength) - StdLibAddressShortStr = "0x1" -) - -// DSDataMiddleware defines prototype for DataSource server middleware. -type DSDataMiddleware func(ctx sdk.Context, path *vm_grpc.VMAccessPath) ([]byte, error) - -// VMStorage interface used by other keepers to get/set VM data. -type VMStorage interface { - // Setters / getters for a VM storage values - SetValue(ctx sdk.Context, accessPath *vm_grpc.VMAccessPath, value []byte) - GetValue(ctx sdk.Context, accessPath *vm_grpc.VMAccessPath) []byte - - // Delete VM value from a VM storage - DelValue(ctx sdk.Context, accessPath *vm_grpc.VMAccessPath) - - // Check value in a VM storage exists - HasValue(ctx sdk.Context, accessPath *vm_grpc.VMAccessPath) bool -} - -// GetPathKey returns storage key for VM values from VM AccessPath. -func GetPathKey(path *vm_grpc.VMAccessPath) []byte { - return bytes.Join( - [][]byte{ - VMKey, - path.Address, - path.Path, - }, - KeyDelimiter, - ) -} - -// GetPathPrefixKey returns storage key prefix for VM values (used for iteration). -func GetPathPrefixKey() []byte { - return append(VMKey, KeyDelimiter...) -} - -// MustParsePathKey parses VM storage key and panics on failure. -func MustParsePathKey(key []byte) *vm_grpc.VMAccessPath { - accessPath := vm_grpc.VMAccessPath{} - - // we expect key to be correct: vm:{address_20bytes}:{path_at_least_1byte} - expectedMinLen := len(VMKey) + len(KeyDelimiter) + VMAddressLength + len(KeyDelimiter) + 1 - if len(key) < expectedMinLen { - panic(fmt.Errorf("key %q: invalid length: min expected: %d", string(key), expectedMinLen)) - } - - // calc indices (end index is the next one of the real end idx) - prefixStartIdx := 0 - prefixEndIdx := prefixStartIdx + len(VMKey) - delimiterFirstStartIdx := prefixEndIdx - delimiterFirstEndIdx := delimiterFirstStartIdx + len(KeyDelimiter) - addressStartIdx := delimiterFirstEndIdx - addressEndIdx := addressStartIdx + VMAddressLength - delimiterSecondStartIdx := addressEndIdx - delimiterSecondEndIdx := delimiterSecondStartIdx + len(KeyDelimiter) - pathStartIdx := delimiterSecondEndIdx - - // split key - prefixValue := key[prefixStartIdx:prefixEndIdx] - delimiterFirstValue := key[delimiterFirstStartIdx:delimiterFirstEndIdx] - addressValue := key[addressStartIdx:addressEndIdx] - delimiterSecondValue := key[delimiterSecondStartIdx:delimiterSecondEndIdx] - pathValue := key[pathStartIdx:] - - // validate - if !bytes.Equal(prefixValue, VMKey) { - panic(fmt.Errorf("key %q: prefix: invalid", string(key))) - } - if !bytes.Equal(delimiterFirstValue, KeyDelimiter) { - panic(fmt.Errorf("key %q: 1st delimiter: invalid", string(key))) - } - if !bytes.Equal(delimiterSecondValue, KeyDelimiter) { - panic(fmt.Errorf("key %q: 2nd delimiter: invalid", string(key))) - } - - accessPath.Address = addressValue - accessPath.Path = pathValue - - return &accessPath -} - -// Bech32ToLibra converts Bech32 to Libra hex. -func Bech32ToLibra(addr sdk.AccAddress) []byte { - return addr.Bytes() -} - -func init() { - StdLibAddress[VMAddressLength-1] = 1 -} diff --git a/x/vm/abci.go b/x/vm/abci.go new file mode 100644 index 0000000..3e669dc --- /dev/null +++ b/x/vm/abci.go @@ -0,0 +1,65 @@ +package vm + +import ( + "fmt" + "time" + + "github.com/cosmos/cosmos-sdk/telemetry" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/dfinance/dstation/x/vm/keeper" + "github.com/dfinance/dstation/x/vm/types" +) + +// BeginBlocker set dataSource server storage context and handles gov proposal scheduler +// iterating over plannedProposals and checking if it is time to execute. +func BeginBlocker(ctx sdk.Context, k keeper.Keeper) { + defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker) + + // Update DS server storage context + k.SetDSContext(ctx) + + // Gov proposals processing + k.IterateProposalsQueue(ctx, func(id uint64, pProposal *types.PlannedProposal) { + if !pProposal.ShouldExecute(ctx) { + return + } + + var err error + c := pProposal.GetContent() + switch c.ProposalType() { + case types.ProposalTypeStdlibUpdate: + err = handleStdlibUpdateProposalExecution(ctx, k, pProposal) + default: + panic(fmt.Errorf("unsupported proposal type for PlannedProposal: %s", c.ProposalType())) + } + + if err != nil { + k.Logger(ctx).Error(fmt.Sprintf("%s\n\nExecution status: failed: %v", pProposal.String(), err)) + } else { + k.SetDSContext(ctx) + k.Logger(ctx).Info(fmt.Sprintf("%s\n\nExecution status: done", pProposal.String())) + } + + k.RemoveProposalFromQueue(ctx, id) + }) +} + +// handleStdlibUpdateProposalExecution requests DVM to update stdlib. +func handleStdlibUpdateProposalExecution(ctx sdk.Context, k keeper.Keeper, pProposal *types.PlannedProposal) error { + updateProposal, ok := pProposal.GetContent().(*types.StdLibUpdateProposal) + if !ok { + return fmt.Errorf("type assert to %s proposal for PlannedProposal failed: %T", types.ProposalTypeStdlibUpdate, pProposal.GetContent()) + } + + msg := types.NewMsgDeployModule(types.StdLibAddress, updateProposal.Code...) + if err := msg.ValidateBasic(); err != nil { + return fmt.Errorf("module deploy: validation: %w", err) + } + + if err := k.DeployContract(ctx, msg); err != nil { + return fmt.Errorf("module deploy: %w", err) + } + + return nil +} diff --git a/x/vm/client/args.go b/x/vm/client/args.go new file mode 100644 index 0000000..40253b1 --- /dev/null +++ b/x/vm/client/args.go @@ -0,0 +1,219 @@ +package client + +import ( + "encoding/binary" + "encoding/hex" + "fmt" + "strconv" + "strings" + + "github.com/OneOfOne/xxhash" + sdk "github.com/cosmos/cosmos-sdk/types" + + dvmTypes "github.com/dfinance/dstation/pkg/types/dvm" + "github.com/dfinance/dstation/x/vm/types" +) + +// NewAddressScriptArg convert string to address ScriptTag. +func NewAddressScriptArg(value string) (types.MsgExecuteScript_ScriptArg, error) { + argTypeCode := dvmTypes.VMTypeTag_Address + argTypeName := dvmTypes.VMTypeTag_name[int32(argTypeCode)] + + if value == "" { + return types.MsgExecuteScript_ScriptArg{}, fmt.Errorf("parsing argument %q of type %q: empty", value, argTypeName) + } + + addr, err := sdk.AccAddressFromBech32(value) + if err != nil { + return types.MsgExecuteScript_ScriptArg{}, fmt.Errorf("parsing argument %q of type %q: %w", value, argTypeName, err) + } + + return types.MsgExecuteScript_ScriptArg{ + Type: argTypeCode, + Value: types.Bech32ToLibra(addr), + }, nil +} + +// NewU8ScriptArg convert string to U8 ScriptTag. +func NewU8ScriptArg(value string) (types.MsgExecuteScript_ScriptArg, error) { + argTypeCode := dvmTypes.VMTypeTag_U8 + argTypeName := dvmTypes.VMTypeTag_name[int32(argTypeCode)] + + hashParsedValue, err := parseXxHashUint(value) + if err != nil { + return types.MsgExecuteScript_ScriptArg{}, fmt.Errorf("parsing argument %q of type %q: %w", value, argTypeName, err) + } + + uintValue, err := strconv.ParseUint(hashParsedValue, 10, 8) + if err != nil { + return types.MsgExecuteScript_ScriptArg{}, fmt.Errorf("parsing argument %q of type %q: %w", value, argTypeName, err) + } + + return types.MsgExecuteScript_ScriptArg{ + Type: argTypeCode, + Value: []byte{uint8(uintValue)}, + }, nil +} + +// NewU64ScriptArg convert string to U64 ScriptTag. +func NewU64ScriptArg(value string) (types.MsgExecuteScript_ScriptArg, error) { + argTypeCode := dvmTypes.VMTypeTag_U64 + argTypeName := dvmTypes.VMTypeTag_name[int32(argTypeCode)] + + hashParsedValue, err := parseXxHashUint(value) + if err != nil { + return types.MsgExecuteScript_ScriptArg{}, fmt.Errorf("parsing argument %q of type %q: %w", value, argTypeName, err) + } + + uintValue, err := strconv.ParseUint(hashParsedValue, 10, 64) + if err != nil { + return types.MsgExecuteScript_ScriptArg{}, fmt.Errorf("parsing argument %q of type %q: %w", value, argTypeName, err) + } + argValue := make([]byte, 8) + binary.LittleEndian.PutUint64(argValue, uintValue) + + return types.MsgExecuteScript_ScriptArg{ + Type: argTypeCode, + Value: argValue, + }, nil +} + +// NewU128ScriptArg convert string to U128 ScriptTag. +func NewU128ScriptArg(value string) (retTag types.MsgExecuteScript_ScriptArg, retErr error) { + argTypeCode := dvmTypes.VMTypeTag_U128 + argTypeName := dvmTypes.VMTypeTag_name[int32(argTypeCode)] + + defer func() { + if recover() != nil { + retErr = fmt.Errorf("parsing argument %q of type %q: failed", value, argTypeName) + } + }() + + hashParsedValue, err := parseXxHashUint(value) + if err != nil { + retErr = fmt.Errorf("parsing argument %q of type %q: %w", value, argTypeName, err) + return + } + + bigIntValue := sdk.NewUintFromString(hashParsedValue) + if bigIntValue.BigInt().BitLen() > 128 { + retErr = fmt.Errorf("parsing argument %q of type %q: invalid bitLen %d", value, argTypeName, bigIntValue.BigInt().BitLen()) + return + } + + // BigInt().Bytes() returns BigEndian format, reverse it + argValue := bigIntValue.BigInt().Bytes() + for left, right := 0, len(argValue)-1; left < right; left, right = left+1, right-1 { + argValue[left], argValue[right] = argValue[right], argValue[left] + } + + // Extend to 16 bytes + if len(argValue) < 16 { + zeros := make([]byte, 16-len(argValue)) + argValue = append(argValue, zeros...) + } + + retTag.Type, retTag.Value = argTypeCode, argValue + + return +} + +// NewVectorScriptArg convert string to Vector ScriptTag. +func NewVectorScriptArg(value string) (types.MsgExecuteScript_ScriptArg, error) { + argTypeCode := dvmTypes.VMTypeTag_Vector + argTypeName := dvmTypes.VMTypeTag_name[int32(argTypeCode)] + + if value == "" { + return types.MsgExecuteScript_ScriptArg{}, fmt.Errorf("parsing argument %q of type %q: empty", value, argTypeName) + } + + argValue, err := hex.DecodeString(strings.TrimPrefix(value, "0x")) + if err != nil { + return types.MsgExecuteScript_ScriptArg{}, fmt.Errorf("parsing argument %q of type %q: %w", value, argTypeName, err) + } + + return types.MsgExecuteScript_ScriptArg{ + Type: argTypeCode, + Value: argValue, + }, nil +} + +// NewBoolScriptArg convert string to Bool ScriptTag. +func NewBoolScriptArg(value string) (types.MsgExecuteScript_ScriptArg, error) { + argTypeCode := dvmTypes.VMTypeTag_Bool + argTypeName := dvmTypes.VMTypeTag_name[int32(argTypeCode)] + + valueBool, err := strconv.ParseBool(value) + if err != nil { + return types.MsgExecuteScript_ScriptArg{}, fmt.Errorf("parsing argument %q of type %q: %w", value, argTypeName, err) + } + + argValue := []byte{0} + if valueBool { + argValue[0] = 1 + } + + return types.MsgExecuteScript_ScriptArg{ + Type: argTypeCode, + Value: argValue, + }, nil +} + +// parseXxHashUint converts (or skips) xxHash integer format. +func parseXxHashUint(value string) (string, error) { + if value == "" { + return "", fmt.Errorf("xxHash parsing: empty") + } + + if value[0] == '#' { + seed := xxhash.NewS64(0) + if len(value) < 2 { + return "", fmt.Errorf("xxHash parsing: invalid length") + } + + if _, err := seed.WriteString(strings.ToLower(value[1:])); err != nil { + return "", fmt.Errorf("xxHash parsing: %w", err) + } + value = strconv.FormatUint(seed.Sum64(), 10) + } + + return value, nil +} + +// ConvertStringScriptArguments convert string client argument to ScriptArgs using compiler meta data (arg types). +func ConvertStringScriptArguments(argStrs []string, argTypes []dvmTypes.VMTypeTag) ([]types.MsgExecuteScript_ScriptArg, error) { + if len(argStrs) != len(argTypes) { + return nil, fmt.Errorf("strArgs / typedArgs length mismatch: %d / %d", len(argStrs), len(argTypes)) + } + + scriptArgs := make([]types.MsgExecuteScript_ScriptArg, len(argStrs)) + for argIdx, argStr := range argStrs { + argType := argTypes[argIdx] + var scriptArg types.MsgExecuteScript_ScriptArg + var err error + + switch argType { + case dvmTypes.VMTypeTag_Address: + scriptArg, err = NewAddressScriptArg(argStr) + case dvmTypes.VMTypeTag_U8: + scriptArg, err = NewU8ScriptArg(argStr) + case dvmTypes.VMTypeTag_U64: + scriptArg, err = NewU64ScriptArg(argStr) + case dvmTypes.VMTypeTag_U128: + scriptArg, err = NewU128ScriptArg(argStr) + case dvmTypes.VMTypeTag_Bool: + scriptArg, err = NewBoolScriptArg(argStr) + case dvmTypes.VMTypeTag_Vector: + scriptArg, err = NewVectorScriptArg(argStr) + default: + return nil, fmt.Errorf("argument[%d]: parsing argument %q: unsupported argType code: %v", argIdx, argStr, argType) + } + + if err != nil { + return nil, fmt.Errorf("argument[%d]: %w", argIdx, err) + } + scriptArgs[argIdx] = scriptArg + } + + return scriptArgs, nil +} diff --git a/x/vm/client/args_test.go b/x/vm/client/args_test.go new file mode 100644 index 0000000..ab81774 --- /dev/null +++ b/x/vm/client/args_test.go @@ -0,0 +1,227 @@ +package client + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/crypto/secp256k1" + + dvmTypes "github.com/dfinance/dstation/pkg/types/dvm" + "github.com/dfinance/dstation/x/vm/types" +) + +func TestVMClient_NewAddressScriptArg(t *testing.T) { + t.Parallel() + addr := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) + + // ok + { + tag, err := NewAddressScriptArg(addr.String()) + require.NoError(t, err) + require.Equal(t, dvmTypes.VMTypeTag_Address, tag.Type) + require.Equal(t, types.Bech32ToLibra(addr), tag.Value) + } + + // empty + { + _, err := NewAddressScriptArg("") + require.Error(t, err) + } + + // invalid + { + _, err := NewAddressScriptArg("invalid") + require.Error(t, err) + } +} + +func TestVMClient_NewU8ScriptArg(t *testing.T) { + t.Parallel() + + // ok + { + tag, err := NewU8ScriptArg("128") + require.NoError(t, err) + require.Equal(t, dvmTypes.VMTypeTag_U8, tag.Type) + require.Equal(t, []byte{0x80}, tag.Value) + } + + // empty + { + _, err := NewU8ScriptArg("") + require.Error(t, err) + } + + // invalid + { + _, err := NewU8ScriptArg("abc") + require.Error(t, err) + } + + // invalid: bitLen + { + _, err := NewU8ScriptArg("1000") + require.Error(t, err) + } +} + +func TestVMClient_NewU64ScriptArg(t *testing.T) { + t.Parallel() + + // ok + { + tag, err := NewU64ScriptArg("305441741") + require.NoError(t, err) + require.Equal(t, dvmTypes.VMTypeTag_U64, tag.Type) + require.Equal(t, []byte{0xCD, 0xAB, 0x34, 0x12, 0x00, 0x00, 0x00, 0x00}, tag.Value) + } + + // empty + { + _, err := NewU64ScriptArg("") + require.Error(t, err) + } + + // invalid + { + _, err := NewU64ScriptArg("abc") + require.Error(t, err) + } + + // invalid: bitLen + { + _, err := NewU64ScriptArg("100000000000000000000") + require.Error(t, err) + } +} + +func TestVMClient_NewU128ScriptArg(t *testing.T) { + t.Parallel() + + // ok + { + tag, err := NewU128ScriptArg("1339673755198158349044581307228491775") + require.NoError(t, err) + require.Equal(t, dvmTypes.VMTypeTag_U128, tag.Type) + require.Equal(t, []byte{0xFF, 0xF, 0xE, 0xD, 0xC, 0xB, 0xA, 0x9, 0x8, 0x7, 0x6, 0x5, 0x4, 0x3, 0x2, 0x1}, tag.Value) + } + + // ok: extending with zeros + { + tag, err := NewU128ScriptArg("18591708106338011145") + require.NoError(t, err) + require.Equal(t, dvmTypes.VMTypeTag_U128, tag.Type) + require.Equal(t, []byte{0x9, 0x8, 0x7, 0x6, 0x5, 0x4, 0x3, 0x2, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, tag.Value) + } + + // empty + { + _, err := NewU128ScriptArg("") + require.Error(t, err) + } + + // invalid + { + _, err := NewU128ScriptArg("abc") + require.Error(t, err) + } + + // invalid: bitLen + { + _, err := NewU128ScriptArg("87112285931760246646623899502532662132735") + require.Error(t, err) + } +} + +func TestVMClient_NewBoolScriptArg(t *testing.T) { + t.Parallel() + + // ok: true + { + { + tag, err := NewBoolScriptArg("true") + require.NoError(t, err) + require.Equal(t, dvmTypes.VMTypeTag_Bool, tag.Type) + require.Equal(t, []byte{1}, tag.Value) + } + { + tag, err := NewBoolScriptArg("True") + require.NoError(t, err) + require.Equal(t, dvmTypes.VMTypeTag_Bool, tag.Type) + require.Equal(t, []byte{1}, tag.Value) + } + { + tag, err := NewBoolScriptArg("TRUE") + require.NoError(t, err) + require.Equal(t, dvmTypes.VMTypeTag_Bool, tag.Type) + require.Equal(t, []byte{1}, tag.Value) + } + } + + // ok: false + { + { + tag, err := NewBoolScriptArg("false") + require.NoError(t, err) + require.Equal(t, dvmTypes.VMTypeTag_Bool, tag.Type) + require.Equal(t, []byte{0}, tag.Value) + } + { + tag, err := NewBoolScriptArg("False") + require.NoError(t, err) + require.Equal(t, dvmTypes.VMTypeTag_Bool, tag.Type) + require.Equal(t, []byte{0}, tag.Value) + } + { + tag, err := NewBoolScriptArg("FALSE") + require.NoError(t, err) + require.Equal(t, dvmTypes.VMTypeTag_Bool, tag.Type) + require.Equal(t, []byte{0}, tag.Value) + } + } + + // empty + { + _, err := NewBoolScriptArg("") + require.Error(t, err) + } + + // invalid + { + _, err := NewBoolScriptArg("abc") + require.Error(t, err) + } +} + +func TestVMClient_NewVectorScriptArg(t *testing.T) { + t.Parallel() + + // ok + { + tag, err := NewVectorScriptArg("01020304") + require.NoError(t, err) + require.Equal(t, dvmTypes.VMTypeTag_Vector, tag.Type) + require.Equal(t, []byte{0x1, 0x2, 0x3, 0x4}, tag.Value) + } + + // ok: prefixed + { + tag, err := NewVectorScriptArg("0xFFFEFD") + require.NoError(t, err) + require.Equal(t, dvmTypes.VMTypeTag_Vector, tag.Type) + require.Equal(t, []byte{0xFF, 0xFE, 0xFD}, tag.Value) + } + + // empty + { + _, err := NewVectorScriptArg("") + require.Error(t, err) + } + + // invalid + { + _, err := NewVectorScriptArg("zzxxcc") + require.Error(t, err) + } +} diff --git a/x/vm/client/cli/flags.go b/x/vm/client/cli/flags.go new file mode 100644 index 0000000..0bf399e --- /dev/null +++ b/x/vm/client/cli/flags.go @@ -0,0 +1,11 @@ +package cli + +import "github.com/spf13/cobra" + +const ( + FlagOutput = "to-file" +) + +func AddOutputFlagToCmd(cmd *cobra.Command) { + cmd.Flags().String(FlagOutput, "script.json", "Output file path") +} diff --git a/x/vm/client/cli/query.go b/x/vm/client/cli/query.go new file mode 100644 index 0000000..9b772c3 --- /dev/null +++ b/x/vm/client/cli/query.go @@ -0,0 +1,192 @@ +package cli + +import ( + "encoding/json" + "fmt" + "io/ioutil" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + authClient "github.com/cosmos/cosmos-sdk/x/auth/client" + "github.com/spf13/cobra" + "github.com/spf13/viper" + + "github.com/dfinance/dstation/x/vm/types" + + "github.com/dfinance/dstation/pkg" +) + +// GetQueryCmd returns the cli query commands for this module. +func GetQueryCmd() *cobra.Command { + queryCmd := &cobra.Command{ + Use: types.ModuleName, + Short: "Querying commands for the VM module", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + queryCmd.AddCommand( + GetCmdQueryData(), + GetCmdQueryTxVmStatus(), + GetCmdQueryCompile(), + ) + + return queryCmd +} + +// GetCmdQueryData returns query command that implement keeper querier. +func GetCmdQueryData() *cobra.Command { + cmd := &cobra.Command{ + Use: "data [address] [path]", + Short: "Get write set data from the VMStorage by address and path", + Example: "data wallet1jk4ld0uu6wdrj9t8u3gghm9jt583hxx7xp7he8 0019b01c2cf3c2160a43e4dcad70e3e5d18151cc38de7a1d1067c6031bfa0ae4d9", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + // Parse inputs + address, err := pkg.ParseSdkAddressParam("address", args[0], pkg.ParamTypeCliArg) + if err != nil { + return err + } + + _, path, err := pkg.ParseHexStringParam("path", args[1], pkg.ParamTypeCliArg) + if err != nil { + return err + } + + // Build and send request + res, err := queryClient.Data(cmd.Context(), &types.QueryDataRequest{ + Address: types.Bech32ToLibra(address), + Path: path, + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + pkg.BuildCmdHelp(cmd, []string{ + "VM address [Bech32 / HEX string]", + "VM path [HEX string]", + }) + + return cmd +} + +// GetCmdQueryTxVmStatus returns query command that implement keeper querier. +func GetCmdQueryTxVmStatus() *cobra.Command { + cmd := &cobra.Command{ + Use: "tx [hash]", + Short: "Get VM status for the Tx by hash", + Example: "tx 6D5A4D889BCDB4C71C6AE5836CD8BC1FD8E0703F1580B9812990431D1796CE34", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + // Get Tx + tx, err := authClient.QueryTx(clientCtx, args[0]) + if err != nil { + return err + } + if tx == nil || tx.Empty() { + return fmt.Errorf("transaction not found") + } + + // Build and send request + res, err := queryClient.TxVmStatus(cmd.Context(), &types.QueryTxVmStatusRequest{ + TxMeta: *tx, + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + pkg.BuildCmdHelp(cmd, []string{ + "transaction hash code [HEX string]", + }) + + return cmd +} + +// GetCmdQueryCompile returns query command that implement keeper querier. +func GetCmdQueryCompile() *cobra.Command { + cmd := &cobra.Command{ + Use: "compile [moveFile] [account]", + Short: "Compile script / module using source code from Move file", + Example: "compile script.move wallet196udj7s83uaw2u4safcrvgyqc0sc3flxuherp6 --to-file script.json", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + // Parse inputs + moveContent, err := pkg.ParseFilePath("moveFile", args[0], pkg.ParamTypeCliArg) + if err != nil { + return err + } + + address, err := pkg.ParseSdkAddressParam("account", args[1], pkg.ParamTypeCliArg) + if err != nil { + return err + } + + // Build and send request + res, err := queryClient.Compile(cmd.Context(), &types.QueryCompileRequest{ + Address: address, + Code: string(moveContent), + }) + if err != nil { + return err + } + + // Output + outputFilePath := viper.GetString(FlagOutput) + outputBz, err := json.MarshalIndent(res, "", " ") + if err != nil { + return fmt.Errorf("output: json marshal: %w", err) + } + + if outputFilePath == "" { + return clientCtx.PrintBytes(outputBz) + } + + if err := ioutil.WriteFile(outputFilePath, outputBz, 0644); err != nil { + return fmt.Errorf("output: file save: %w", err) + } + + return clientCtx.PrintString(fmt.Sprintf("Result saved to file: %s", outputFilePath)) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + AddOutputFlagToCmd(cmd) + + pkg.BuildCmdHelp(cmd, []string{ + "path to .move file", + "account address [Bech32 / HEX string]", + }) + + return cmd +} diff --git a/x/vm/client/cli/tx.go b/x/vm/client/cli/tx.go new file mode 100644 index 0000000..047f4df --- /dev/null +++ b/x/vm/client/cli/tx.go @@ -0,0 +1,245 @@ +package cli + +import ( + "encoding/json" + "fmt" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + govCli "github.com/cosmos/cosmos-sdk/x/gov/client/cli" + govTypes "github.com/cosmos/cosmos-sdk/x/gov/types" + "github.com/spf13/cobra" + + "github.com/dfinance/dstation/pkg" + vmClient "github.com/dfinance/dstation/x/vm/client" + "github.com/dfinance/dstation/x/vm/types" +) + +// GetTxCmd returns a root CLI command handler for all module transaction commands. +func GetTxCmd() *cobra.Command { + txCmd := &cobra.Command{ + Use: types.ModuleName, + Short: "VM transaction subcommands", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + txCmd.AddCommand( + GetCmdTxExecuteScript(), + GetCmdTxDeployContract(), + GetCmdTxSendUpdateStdlibProposal(), + ) + + return txCmd +} + +// GetCmdTxExecuteScript returns tx command that implement keeper handler. +func GetCmdTxExecuteScript() *cobra.Command { + cmd := &cobra.Command{ + Use: "execute [moveFile] [arg1,arg2,arg3,..]", + Short: "Execute Move script", + Example: "execute ./script.move.json wallet1jk4ld0uu6wdrj9t8u3gghm9jt583hxx7xp7he8 100 true \"my string\" \"68656c6c6f2c20776f726c6421\" #\"XFI_ETH\" --from my_account --fees 10000xfi --gas 500000", + Args: cobra.MinimumNArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + txf := tx.NewFactoryCLI(clientCtx, cmd.Flags()).WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever) + + // Parse inputs + fromAddr, err := pkg.ParseFromFlag(clientCtx) + if err != nil { + return err + } + + compItems, err := getCompiledItemFromFileArg("moveFile", args[0], true) + if err != nil { + return err + } + + // Extract script arguments meta + meta, err := queryClient.Metadata(cmd.Context(), &types.QueryMetadataRequest{Code: compItems.CompiledItems[0].ByteCode}) + if err != nil { + return fmt.Errorf("extracting script arguments meta: %w", err) + } + if meta.Metadata.GetScript() == nil { + return fmt.Errorf("extracting script arguments meta: requested byteCode is not a script") + } + typedArgs := meta.Metadata.GetScript().Arguments + + // Build msg + scriptArgs, err := vmClient.ConvertStringScriptArguments(args[1:], typedArgs) + if err != nil { + return fmt.Errorf("converting input args to typed args: %w", err) + } + msg := types.NewMsgExecuteScript(fromAddr, compItems.CompiledItems[0].ByteCode, scriptArgs...) + + return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, &msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + _ = cmd.MarkFlagRequired(flags.FlagFrom) + + pkg.BuildCmdHelp(cmd, []string{ + "path to compiled Move file containing byteCode (one script)", + "space separated VM script arguments (optional)", + }) + + return cmd +} + +// GetCmdTxDeployContract returns tx command that implement keeper handler. +func GetCmdTxDeployContract() *cobra.Command { + cmd := &cobra.Command{ + Use: "publish [moveFile]", + Short: "Publish Move module", + Example: "publish ./my_module.move.json --from my_account --fees 10000xfi --gas 500000", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + txf := tx.NewFactoryCLI(clientCtx, cmd.Flags()).WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever) + + // Parse inputs + fromAddr, err := pkg.ParseFromFlag(clientCtx) + if err != nil { + return err + } + + compItems, err := getCompiledItemFromFileArg("moveFile", args[0], true) + if err != nil { + return err + } + + // Build msg + contractsCode := make([][]byte, 0, len(compItems.CompiledItems)) + for _, item := range compItems.CompiledItems { + contractsCode = append(contractsCode, item.ByteCode) + } + msg := types.NewMsgDeployModule(fromAddr, contractsCode...) + + return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, &msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + _ = cmd.MarkFlagRequired(flags.FlagFrom) + + pkg.BuildCmdHelp(cmd, []string{ + "path to compiled Move file containing byteCode (one / several modules)", + }) + + return cmd +} + +// GetCmdTxSendUpdateStdlibProposal returns tx command that sends governance update stdlib VM module proposal. +func GetCmdTxSendUpdateStdlibProposal() *cobra.Command { + cmd := &cobra.Command{ + Use: "update-stdlib-proposal [moveFile] [plannedBlockHeight] [sourceUrl] [updateDescription]", + Short: "Submit a DVM stdlib update proposal", + Example: "update-stdlib-proposal ./update.move.json 1000 http://github.com/repo 'fix for Foo module' --deposit 10000xfi --from my_account --fees 10000xfi", + Args: cobra.ExactArgs(4), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + txf := tx.NewFactoryCLI(clientCtx, cmd.Flags()).WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever) + + // Parse inputs + fromAddr, err := pkg.ParseFromFlag(clientCtx) + if err != nil { + return err + } + + compItems, err := getCompiledItemFromFileArg("moveFile", args[0], false) + if err != nil { + return err + } + + plannedBlockHeight, err := pkg.ParseInt64Param("plannedBlockHeight", args[1], pkg.ParamTypeCliArg) + if err != nil { + return err + } + + sourceUrl, updateDesc := args[2], args[3] + + deposit, err := pkg.ParseDepositFlag(cmd.Flags()) + if err != nil { + return err + } + + // Build and validate PlannedProposal + code := make([][]byte, 0, len(compItems.CompiledItems)) + for _, compItem := range compItems.CompiledItems { + code = append(code, compItem.ByteCode) + } + + pProposal, err := types.NewPlannedProposal(plannedBlockHeight, types.NewStdLibUpdateProposal(sourceUrl, updateDesc, code...)) + if err != nil { + return fmt.Errorf("planned proposal: build: %w", err) + } + if err := pProposal.ValidateBasic(); err != nil { + return fmt.Errorf("planned proposal: validation: %w", err) + } + + // Build and validate Gov proposal message + msg, err := govTypes.NewMsgSubmitProposal(pProposal, deposit, fromAddr) + if err != nil { + return fmt.Errorf("gov proposal message: build: %w", err) + } + if err := msg.ValidateBasic(); err != nil { + return fmt.Errorf("gov proposal message: validation: %w", err) + } + + return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + cmd.Flags().String(govCli.FlagDeposit, "", "deposit of proposal") + _ = cmd.MarkFlagRequired(flags.FlagFrom) + _ = cmd.MarkFlagRequired(govCli.FlagDeposit) + + pkg.BuildCmdHelp(cmd, []string{ + "path to compiled Move file containing byteCode (one / several modules)", + "blockHeight at which update should occur [int]", + "URL containing proposal source code", + "proposal description (version, short changelist)", + }) + + return cmd +} + +// getCompiledItemFromFileArg reads .move file and performs basic code type checks. +func getCompiledItemFromFileArg(argName, argValue string, oneItem bool) (*types.QueryCompileResponse, error) { + jsonContent, err := pkg.ParseFilePath(argName, argValue, pkg.ParamTypeCliArg) + if err != nil { + return nil, err + } + + compItems := types.QueryCompileResponse{} + if err := json.Unmarshal(jsonContent, &compItems); err != nil { + return nil, pkg.BuildError(argName, argValue, pkg.ParamTypeCliArg, fmt.Sprintf("file json unmarshal: %v", err)) + } + + if len(compItems.CompiledItems) == 0 || (oneItem && len(compItems.CompiledItems) != 1) { + return nil, pkg.BuildError(argName, argValue, pkg.ParamTypeCliArg, fmt.Sprintf("file contains wrong number of items: %d", len(compItems.CompiledItems))) + } + + itemsCodeType := compItems.CompiledItems[0].CodeType + for _, item := range compItems.CompiledItems { + if itemsCodeType != item.CodeType { + return nil, pkg.BuildError(argName, argValue, pkg.ParamTypeCliArg, "file contains different code types (only similar types are allowed)") + } + } + + return &compItems, nil +} diff --git a/x/vm/common_test.go b/x/vm/common_test.go new file mode 100644 index 0000000..97494b2 --- /dev/null +++ b/x/vm/common_test.go @@ -0,0 +1,285 @@ +package vm_test + +import ( + "context" + "encoding/hex" + "fmt" + "os" + "path" + "path/filepath" + "strings" + "testing" + + "github.com/cosmos/cosmos-sdk/baseapp" + cryptoTypes "github.com/cosmos/cosmos-sdk/crypto/types" + "github.com/cosmos/cosmos-sdk/server" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/suite" + abci "github.com/tendermint/tendermint/abci/types" + + "github.com/dfinance/dstation/pkg" + "github.com/dfinance/dstation/pkg/tests" + "github.com/dfinance/dstation/x/vm/config" + "github.com/dfinance/dstation/x/vm/keeper" + "github.com/dfinance/dstation/x/vm/types" +) + +type ModuleDVVTestSuite struct { + suite.Suite + + app *tests.DSimApp + ctx sdk.Context + keeper keeper.Keeper + queryClient types.QueryClient + // + dvmStop func() error +} + +func (s *ModuleDVVTestSuite) SetupSuite() { + // Init DVM connections and config + _, dsPort, err := server.FreeTCPAddr() + if err != nil { + panic(fmt.Errorf("free TCP port request for DS server: %w", err)) + } + + _, vmPort, err := server.FreeTCPAddr() + if err != nil { + panic(fmt.Errorf("free TCP port request for VM connection: %w", err)) + } + + vmConfig := config.VMConfig{ + Address: fmt.Sprintf("tcp://127.0.0.1:%s", vmPort), + DataListen: fmt.Sprintf("tcp://127.0.0.1:%s", dsPort), + MaxAttempts: 0, + ReqTimeoutInMs: 0, + } + + // Start the DVM + // Debug helpers: + // - printLogs = true + // - extra args: "--log=debug" / "-vvv" + dvmStop, err := tests.LaunchDVMWithNetTransport(vmPort, dsPort, false) + if err != nil { + panic(fmt.Errorf("launch DVM: %w", err)) + } + s.dvmStop = dvmStop + + // Init the SimApp + s.app = tests.SetupDSimApp(tests.WithDVMConfig(vmConfig)) + s.ctx = s.app.GetContext(false) + s.keeper = s.app.DnApp.VmKeeper + + // Init the querier client + querier := keeper.Querier{Keeper: s.keeper} + queryHelper := baseapp.NewQueryServerTestHelper(s.ctx, s.app.DnApp.InterfaceRegistry()) + types.RegisterQueryServer(queryHelper, querier) + s.queryClient = types.NewQueryClient(queryHelper) +} + +func (s *ModuleDVVTestSuite) TearDownSuite() { + if err := s.dvmStop(); err != nil { + s.T().Logf("TearDownSuite: DVM: %v", err) + } + + s.app.TearDown() +} + +func (s *ModuleDVVTestSuite) SetupTest() { + s.ctx = s.ctx.WithEventManager(sdk.NewEventManager()) +} + +// GetProjectPath returns project root dir ("dfinance" base path). +func (s *ModuleDVVTestSuite) GetProjectPath() string { + workingDir, err := os.Getwd() + s.Require().NoError(err) + + projectDir := workingDir + for { + projectDir = filepath.Dir(projectDir) + if projectDir == "." { + s.Require().True(false, "dstation path not found within the current working dir: %s", workingDir) + } + + if filepath.Base(projectDir) == "dstation" { + break + } + } + + return projectDir +} + +// GetMoveFileContent reads Move file content withing "move" sub-directory. +func (s *ModuleDVVTestSuite) GetMoveFileContent(fileName string, templateValues ...string) []byte { + filePath := path.Join(s.GetProjectPath(), "x/vm/move", fileName) + fileContent, err := pkg.ParseFilePath("fileName", filePath, pkg.ParamTypeCliArg) + s.Require().NoError(err, "VM contract file: read failed") + + if len(templateValues) > 0 { + fmtArgs := make([]interface{}, 0, len(templateValues)) + for _, templateValue := range templateValues { + fmtArgs = append(fmtArgs, templateValue) + } + + fileContentStr := fmt.Sprintf(string(fileContent), fmtArgs...) + fileContent = []byte(fileContentStr) + } + + return fileContent +} + +// CompileMoveFile reads Move file and compiles it. +func (s *ModuleDVVTestSuite) CompileMoveFile(accAddr sdk.AccAddress, fileName string, templateValues ...string) [][]byte { + scriptSrc := s.GetMoveFileContent(fileName, templateValues...) + + resp, err := s.queryClient.Compile(context.Background(), &types.QueryCompileRequest{ + Address: types.Bech32ToLibra(accAddr), + Code: string(scriptSrc), + }) + s.Require().NoError(err, "VM contract compilation: failed") + s.Require().NotEmpty(resp.CompiledItems, "VM contract compilation: no compiled item found") + + byteCodes := make([][]byte, 0, len(resp.CompiledItems)) + for i, item := range resp.CompiledItems { + s.Require().NotEmpty(item, "VM contract compilation: compiled item [%d] is empty", i) + byteCodes = append(byteCodes, item.ByteCode) + } + + return byteCodes +} + +// DeployModule deploys VM module via Tx. +func (s *ModuleDVVTestSuite) DeployModule(accAddr sdk.AccAddress, accPrivKey cryptoTypes.PrivKey, fileName string, templateValues []string) (sdk.GasInfo, *sdk.Result, error) { + byteCodes := s.CompileMoveFile(accAddr, fileName, templateValues...) + + msg := types.NewMsgDeployModule(accAddr, byteCodes...) + + return s.app.DeliverTx(s.ctx, accAddr, accPrivKey, []sdk.Msg{&msg}) +} + +// ExecuteScript executes VM script via Tx. +func (s *ModuleDVVTestSuite) ExecuteScript(accAddr sdk.AccAddress, accPrivKey cryptoTypes.PrivKey, fileName string, templateValues []string, args ...types.MsgExecuteScript_ScriptArg) (sdk.GasInfo, *sdk.Result, error) { + byteCodes := s.CompileMoveFile(accAddr, fileName, templateValues...) + s.Require().Len(byteCodes, 1, "VM script execution: compiledUnits len mismatch") + + msg := types.NewMsgExecuteScript(accAddr, byteCodes[0], args...) + + return s.app.DeliverTx(s.ctx, accAddr, accPrivKey, []sdk.Msg{&msg}) +} + +// BuildScriptArg wraps x/vm/client arg builders and can be used with ExecuteScript func. +func (s *ModuleDVVTestSuite) BuildScriptArg(value string, builder func(string) (types.MsgExecuteScript_ScriptArg, error)) types.MsgExecuteScript_ScriptArg { + arg, err := builder(value) + s.Require().NoError(err) + + return arg +} + +// CheckContractExecuted checks that Tx result doesn't contain failed VM statues. +func (s *ModuleDVVTestSuite) CheckContractExecuted(gasInfo sdk.GasInfo, txRes *sdk.Result, txErr error) (sdk.GasInfo, []abci.Event) { + discardEvents := s.getDiscardContractEvents(txRes, txErr) + for _, event := range discardEvents { + s.T().Logf("Failed ABCI event:\n%s", s.StringifyABCIEvent(event)) + } + s.Require().Empty(discardEvents, "VM contract execution: failed") + + return gasInfo, txRes.Events +} + +// CheckContractFailed checks that Tx result contains failed VM statues. +func (s *ModuleDVVTestSuite) CheckContractFailed(gasInfo sdk.GasInfo, txRes *sdk.Result, txErr error) (sdk.GasInfo, []abci.Event) { + discardEvents := s.getDiscardContractEvents(txRes, txErr) + s.Require().NotEmpty(discardEvents, "VM contract execution: succeeded") + + return gasInfo, txRes.Events +} + +// CheckABCIEventsContain checks that eventsA contains all eventsB entries. +func (s *ModuleDVVTestSuite) CheckABCIEventsContain(eventsA []abci.Event, eventsB []sdk.Event) { + s.Require().GreaterOrEqual(len(eventsA), len(eventsB), "comparing ABCI/SDK events: length mismatch: %d / %d", len(eventsA), len(eventsB)) + + eventsBConv := make([]abci.Event, 0, len(eventsB)) + for _, event := range eventsB { + attrsConv := make([]abci.EventAttribute, 0, len(event.Attributes)) + for _, attr := range event.Attributes { + attrsConv = append(attrsConv, abci.EventAttribute{ + Key: attr.Key, + Value: attr.Value, + }) + } + + eventsBConv = append(eventsBConv, abci.Event{ + Type: event.Type, + Attributes: attrsConv, + }) + } + + for i, eventB := range eventsBConv { + s.Require().Contains(eventsA, eventB, "comparing ABCI/SDK events: ABCIs have no SDK [%d]", i) + } +} + +// StringifySdkEvent builds abci.Event string representation. +func (s *ModuleDVVTestSuite) StringifyABCIEvent(event abci.Event) string { + str := strings.Builder{} + + str.WriteString(fmt.Sprintf("- Event.Type: %s\n", event.Type)) + for _, attr := range event.Attributes { + str.WriteString(fmt.Sprintf(" * %s = %s\n", attr.Key, attr.Value)) + if string(attr.Key) == types.AttributeErrMajorStatus { + str.WriteString(fmt.Sprintf(" Description: %s\n", types.StringifyVMStatusMajorCode(string(attr.Value)))) + } + } + + return str.String() +} + +// PrintABCIEvents prints abci.Event list to test stdout. +func (s *ModuleDVVTestSuite) PrintABCIEvents(events []abci.Event) { + for i, event := range events { + s.T().Logf("Event [%d]:\n%s", i, s.StringifyABCIEvent(event)) + } +} + +// GetLibraAccAddressString converts sdk.AccAddress to Libra address HEX string (used as a templateValue for VM scripts). +// acc.GetAddress().String() works as well with DVM (this func is optional). +func (s *ModuleDVVTestSuite) GetLibraAccAddressString(accAddr sdk.AccAddress) string { + libraAddr := types.Bech32ToLibra(accAddr) + moveAddr := hex.EncodeToString(libraAddr) + + return "0x" + moveAddr +} + +// getDiscardContractEvents returns Discard abci.Event for Tx delivery result. +func (s *ModuleDVVTestSuite) getDiscardContractEvents(txRes *sdk.Result, txErr error) []abci.Event { + s.Require().NoError(txErr, "VM contract Tx delivery: failed") + s.Require().NotNil(txRes, "VM contract Tx delivery: result is nil") + + var discardEvents []abci.Event + for _, event := range txRes.Events { + if event.Type != types.EventTypeContractStatus { + continue + } + + for _, attr := range event.Attributes { + if string(attr.Key) != types.AttributeStatus { + continue + } + + if string(attr.Value) == types.AttributeValueStatusDiscard { + discardEvents = append(discardEvents, event) + break + } + } + } + + return discardEvents +} + +func TestVMModule_DVM(t *testing.T) { + if _, ok := os.LookupEnv(tests.EnvDvmIntegUse); !ok { + t.Skipf("Integration tests skipped as %q envVar not set (refer to pkg/tests/dvm.go)", tests.EnvDvmIntegUse) + } + + t.Parallel() + suite.Run(t, new(ModuleDVVTestSuite)) +} diff --git a/x/vm/config/vm_config.go b/x/vm/config/vm_config.go new file mode 100644 index 0000000..afbd425 --- /dev/null +++ b/x/vm/config/vm_config.go @@ -0,0 +1,79 @@ +package config + +import ( + "bytes" + "os" + "path/filepath" + + "github.com/spf13/viper" + tmOs "github.com/tendermint/tendermint/libs/os" +) + +const ( + VmConfigFile = "vm.toml" // Default VM config file name + DefaultConfigsDir = "config" + + // VM connection defaults + DefaultVMAddress = "tcp://127.0.0.1:50051" + DefaultDataListen = "tcp://127.0.0.1:50052" + + // VM request retry defaults + DefaultMaxAttempts = 0 + DefaultReqTimeout = 0 +) + +// VMConfig defines virtual machine connection config. +type VMConfig struct { + // Virtual machine address to connect from Cosmos SDK + Address string `mapstructure:"vm_address"` + // Node's data server address to listen for connections from VM + DataListen string `mapstructure:"vm_data_listen"` // node's data server listen address + + // Retry policy: maximum retry attempts (0 - infinity) + MaxAttempts uint `mapstructure:"vm_retry_max_attempts"` + // Retry policy: request timeout per attempt [ms] (0 - infinite, no timeout) + ReqTimeoutInMs uint `mapstructure:"vm_retry_req_timeout_ms"` +} + +// DefaultVMConfig returns VMConfig with defaults. +func DefaultVMConfig() VMConfig { + return VMConfig{ + Address: DefaultVMAddress, + DataListen: DefaultDataListen, + MaxAttempts: DefaultMaxAttempts, + ReqTimeoutInMs: DefaultReqTimeout, + } +} + +// WriteVMConfig writes VM config file in configuration directory. +func WriteVMConfig(configPath string, vmConfig VMConfig) { + var buffer bytes.Buffer + if err := configTemplate.Execute(&buffer, vmConfig); err != nil { + panic(err) + } + + tmOs.MustWriteFile(configPath, buffer.Bytes(), 0644) +} + +// ReadVMConfig reads VM config file from configuration directory. +func ReadVMConfig(homeDir string) VMConfig { + configFilePath := filepath.Join(homeDir, DefaultConfigsDir, VmConfigFile) + + if _, err := os.Stat(configFilePath); os.IsNotExist(err) { + defConfig := DefaultVMConfig() + WriteVMConfig(configFilePath, defConfig) + return defConfig + } + + viper.SetConfigFile(configFilePath) + if err := viper.ReadInConfig(); err != nil { + panic(err) + } + + config := VMConfig{} + if err := viper.Unmarshal(&config); err != nil { + panic(err) + } + + return config +} diff --git a/x/vm/config/vm_config_template.go b/x/vm/config/vm_config_template.go new file mode 100644 index 0000000..fe41f79 --- /dev/null +++ b/x/vm/config/vm_config_template.go @@ -0,0 +1,38 @@ +package config + +import ( + "text/template" +) + +const defaultConfigTemplate = `# This is a TOML config file to configurate connection to VM. +# For more information, see https://github.com/toml-lang/toml + +##### main base config options ##### + +# VM network address to connect. +vm_address = "{{ .Address }}" + +# VM data server listen address. +vm_data_listen = "{{ .DataListen }}" + +# VM retry settings. + +## Retry max attempts. +## Default is 0 - infinity attempts. +vm_retry_max_attempts = {{ .MaxAttempts }} + +## Request timeout per attempt in ms. +## Default is 0 - infinite (no timeout). +vm_retry_req_timeout_ms = {{ .ReqTimeoutInMs }} +` + +var configTemplate *template.Template + +func init() { + var err error + tmpl := template.New("vmConfigTemplate") + + if configTemplate, err = tmpl.Parse(defaultConfigTemplate); err != nil { + panic(err) + } +} diff --git a/x/vm/gov_test.go b/x/vm/gov_test.go new file mode 100644 index 0000000..0710f19 --- /dev/null +++ b/x/vm/gov_test.go @@ -0,0 +1,104 @@ +package vm_test + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + dnConfig "github.com/dfinance/dstation/cmd/dstation/config" + "github.com/dfinance/dstation/x/vm" + "github.com/dfinance/dstation/x/vm/client" + "github.com/dfinance/dstation/x/vm/types" +) + +func (s *ModuleDVVTestSuite) TestUpdateStdlibGovProposal() { + ctx, keeper := s.ctx, s.keeper + acc, accPrivKey := s.app.AddAccount(ctx, sdk.NewCoin(dnConfig.MainDenom, sdk.NewInt(1000))) + + // Deploy module v1 to the StdLib + { + // Compile + byteCode := s.CompileMoveFile(acc.GetAddress(), "gov/module_v1.move") + + // Build Gov proposal + curBlock, _ := s.app.GetCurrentBlockHeightTime() + updateProposal := types.NewStdLibUpdateProposal("http://github.com/myStdLib", "v1: initial version", byteCode[0]) + pProposal, err := types.NewPlannedProposal(curBlock+1, updateProposal) + s.Require().NoError(err) + s.Require().NoError(pProposal.ValidateBasic()) + + // Emulate Gov proposal approved and routed to the VM module + s.Require().NoError(vm.NewGovHandler(keeper)(ctx, pProposal)) + + // Skip block (planned proposal apply) + s.app.BeginBlock() + s.app.EndBlock() + } + + // Check module v1 deployed + { + _, scriptEvents := s.CheckContractExecuted( + s.ExecuteScript(acc.GetAddress(), accPrivKey, + "gov/script.move", nil, + s.BuildScriptArg("255", client.NewU64ScriptArg), + ), + ) + + s.CheckABCIEventsContain(scriptEvents, []sdk.Event{ + sdk.NewEvent( + types.EventTypeMoveEvent, + sdk.NewAttribute(types.AttributeVmEventSender, acc.GetAddress().String()), + sdk.NewAttribute(types.AttributeVmEventSource, types.AttributeValueSourceScript), + sdk.NewAttribute(types.AttributeVmEventType, "u64"), + sdk.NewAttribute(types.AttributeVmEventData, "ff00000000000000"), + ), + }) + } + + // Update module v1 to v2 + { + // Compile + byteCode := s.CompileMoveFile(acc.GetAddress(), "gov/module_v2.move") + + // Build Gov proposal + curBlock, _ := s.app.GetCurrentBlockHeightTime() + updateProposal := types.NewStdLibUpdateProposal("http://github.com/myStdLib", "v2: fix for inc() func", byteCode[0]) + pProposal, err := types.NewPlannedProposal(curBlock+1, updateProposal) + s.Require().NoError(err) + s.Require().NoError(pProposal.ValidateBasic()) + + // Emulate Gov proposal approved and routed to the VM module + s.Require().NoError(vm.NewGovHandler(keeper)(ctx, pProposal)) + + // Skip block (planned proposal apply) + s.app.BeginBlock() + s.app.EndBlock() + } + + // Check module was updated to v2 + { + _, scriptEvents := s.CheckContractExecuted( + s.ExecuteScript(acc.GetAddress(), accPrivKey, + "gov/script.move", nil, + s.BuildScriptArg("255", client.NewU64ScriptArg), + ), + ) + + s.CheckABCIEventsContain(scriptEvents, []sdk.Event{ + sdk.NewEvent( + types.EventTypeMoveEvent, + sdk.NewAttribute(types.AttributeVmEventSender, acc.GetAddress().String()), + sdk.NewAttribute(types.AttributeVmEventSource, types.AttributeValueSourceScript), + sdk.NewAttribute(types.AttributeVmEventType, "u64"), + sdk.NewAttribute(types.AttributeVmEventData, "0001000000000000"), + ), + }) + } + + // Check Gov proposal queue is empty + { + proposalsCount := 0 + keeper.IterateProposalsQueue(ctx, func(id uint64, pProposal *types.PlannedProposal) { + proposalsCount++ + }) + s.Require().Zero(proposalsCount) + } +} diff --git a/x/vm/handler.go b/x/vm/handler.go new file mode 100644 index 0000000..afe60a1 --- /dev/null +++ b/x/vm/handler.go @@ -0,0 +1,28 @@ +package vm + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkErrors "github.com/cosmos/cosmos-sdk/types/errors" + + "github.com/dfinance/dstation/x/vm/keeper" + "github.com/dfinance/dstation/x/vm/types" +) + +func NewHandler(k keeper.Keeper) sdk.Handler { + msgServer := keeper.NewMsgServerImpl(k) + + return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { + ctx = ctx.WithEventManager(sdk.NewEventManager()) + + switch msg := msg.(type) { + case *types.MsgDeployModule: + res, err := msgServer.DeployModule(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgExecuteScript: + res, err := msgServer.ExecuteScript(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + default: + return nil, sdkErrors.Wrapf(sdkErrors.ErrUnknownRequest, "unrecognized %s message type: %T", types.ModuleName, msg) + } + } +} diff --git a/x/vm/handler_gov.go b/x/vm/handler_gov.go new file mode 100644 index 0000000..1121a60 --- /dev/null +++ b/x/vm/handler_gov.go @@ -0,0 +1,66 @@ +package vm + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkErrors "github.com/cosmos/cosmos-sdk/types/errors" + govTypes "github.com/cosmos/cosmos-sdk/x/gov/types" + + "github.com/dfinance/dstation/x/vm/keeper" + "github.com/dfinance/dstation/x/vm/types" +) + +// NewGovHandler creates a governance handler to manage new proposal types. +func NewGovHandler(k keeper.Keeper) govTypes.Handler { + return func(ctx sdk.Context, content govTypes.Content) error { + if content.ProposalRoute() != types.RouterKey { + return fmt.Errorf("invalid proposal route %q for module %q", content.ProposalRoute(), types.ModuleName) + } + + switch c := content.(type) { + case *types.PlannedProposal: + return handlePlannedProposal(ctx, k, c) + default: + return sdkErrors.Wrapf(sdkErrors.ErrUnknownRequest, "unsupported proposal content type: %T", c) + } + } +} + +// handlePlannedProposal handles all types.PlannedProposal Gov proposals. +func handlePlannedProposal(ctx sdk.Context, k keeper.Keeper, pProposal *types.PlannedProposal) error { + c := pProposal.GetContent() + switch c.ProposalType() { + case types.ProposalTypeStdlibUpdate: + return handleStdlibUpdatePlannedProposal(ctx, k, pProposal) + default: + return sdkErrors.Wrapf(sdkErrors.ErrUnknownRequest, "unsupported proposal type for PlannedProposal: %s", c.ProposalType()) + } +} + +// handleStdlibUpdatePlannedProposal handles types.StdLibUpdateProposal Gov proposal. +func handleStdlibUpdatePlannedProposal(ctx sdk.Context, k keeper.Keeper, pProposal *types.PlannedProposal) error { + updateProposal, ok := pProposal.GetContent().(*types.StdLibUpdateProposal) + if !ok { + return fmt.Errorf("type assert to %s proposal for PlannedProposal failed: %T", types.ProposalTypeStdlibUpdate, pProposal.GetContent()) + } + + // DVM check (dry-run deploy) + msg := types.NewMsgDeployModule(types.StdLibAddress, updateProposal.Code...) + if err := msg.ValidateBasic(); err != nil { + return fmt.Errorf("module deploy (dry run): validation: %w", err) + } + + if err := k.DeployContractDryRun(ctx, msg); err != nil { + return fmt.Errorf("module deploy (dry run): %w", err) + } + + // Add proposal to the gov proposal queue + if err := k.ScheduleProposal(ctx, pProposal); err != nil { + return fmt.Errorf("proposal scheduling: %w", err) + } + + k.Logger(ctx).Info(fmt.Sprintf("Proposal scheduled:\n%s", pProposal.String())) + + return nil +} diff --git a/x/vm/integ_test.go b/x/vm/integ_test.go new file mode 100644 index 0000000..5718254 --- /dev/null +++ b/x/vm/integ_test.go @@ -0,0 +1,643 @@ +package vm_test + +import ( + "context" + "encoding/hex" + "fmt" + "strconv" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkErrors "github.com/cosmos/cosmos-sdk/types/errors" + + dnConfig "github.com/dfinance/dstation/cmd/dstation/config" + "github.com/dfinance/dstation/pkg/tests" + dvmTypes "github.com/dfinance/dstation/pkg/types/dvm" + "github.com/dfinance/dstation/x/vm/client" + "github.com/dfinance/dstation/x/vm/types" +) + +func (s *ModuleDVVTestSuite) TestScriptWithArgs() { + ctx := s.ctx + acc, accPrivKey := s.app.AddAccount(ctx, sdk.NewCoin(dnConfig.MainDenom, sdk.NewInt(1000))) + + s.CheckContractExecuted( + s.ExecuteScript(acc.GetAddress(), accPrivKey, + "scripts/arg_types.move", nil, + s.BuildScriptArg("128", client.NewU8ScriptArg), + s.BuildScriptArg("1000000", client.NewU64ScriptArg), + s.BuildScriptArg("100000000000000000000000000000", client.NewU128ScriptArg), + s.BuildScriptArg(acc.GetAddress().String(), client.NewAddressScriptArg), + s.BuildScriptArg("true", client.NewBoolScriptArg), + s.BuildScriptArg("false", client.NewBoolScriptArg), + s.BuildScriptArg("0x0001", client.NewVectorScriptArg), + ), + ) +} + +func (s *ModuleDVVTestSuite) TestScriptWithError() { + ctx := s.ctx + acc, accPrivKey := s.app.AddAccount(ctx, sdk.NewCoin(dnConfig.MainDenom, sdk.NewInt(1000))) + + s.CheckContractFailed( + s.ExecuteScript(acc.GetAddress(), accPrivKey, + "scripts/with_error.move", nil, + s.BuildScriptArg("1", client.NewU64ScriptArg), + ), + ) +} + +func (s *ModuleDVVTestSuite) TestEventTypeSerialization() { + ctx := s.ctx + acc, accPrivKey := s.app.AddAccount(ctx, sdk.NewCoin(dnConfig.MainDenom, sdk.NewInt(1000))) + + s.CheckContractExecuted( + s.DeployModule(acc.GetAddress(), accPrivKey, + "event_type_serialization/basic/module.move", nil, + ), + ) + + _, scriptEvents := s.CheckContractExecuted( + s.ExecuteScript(acc.GetAddress(), accPrivKey, + "event_type_serialization/basic/script.template.move", []string{ + s.GetLibraAccAddressString(acc.GetAddress()), + }, + ), + ) + + //s.PrintABCIEvents(scriptEvents) + s.CheckABCIEventsContain(scriptEvents, []sdk.Event{ + sdk.NewEvent( + types.EventTypeMoveEvent, + sdk.NewAttribute(types.AttributeVmEventSender, acc.GetAddress().String()), + sdk.NewAttribute(types.AttributeVmEventSource, types.AttributeValueSourceScript), + sdk.NewAttribute(types.AttributeVmEventType, "u8"), + sdk.NewAttribute(types.AttributeVmEventData, "80"), + ), + sdk.NewEvent( + types.EventTypeMoveEvent, + sdk.NewAttribute(types.AttributeVmEventSender, acc.GetAddress().String()), + sdk.NewAttribute(types.AttributeVmEventSource, types.AttributeValueSourceScript), + sdk.NewAttribute(types.AttributeVmEventType, "vector"), + sdk.NewAttribute(types.AttributeVmEventData, "020102"), + ), + sdk.NewEvent( + types.EventTypeMoveEvent, + sdk.NewAttribute(types.AttributeVmEventSender, acc.GetAddress().String()), + sdk.NewAttribute(types.AttributeVmEventSource, fmt.Sprintf("%s::Foo", acc.GetAddress())), + sdk.NewAttribute(types.AttributeVmEventType, "bool"), + sdk.NewAttribute(types.AttributeVmEventData, "01"), + ), + sdk.NewEvent( + types.EventTypeMoveEvent, + sdk.NewAttribute(types.AttributeVmEventSender, acc.GetAddress().String()), + sdk.NewAttribute(types.AttributeVmEventSource, types.AttributeValueSourceScript), + sdk.NewAttribute(types.AttributeVmEventType, fmt.Sprintf("%s::Foo::FooEvent>", acc.GetAddress())), + sdk.NewAttribute(types.AttributeVmEventData, "e803000000000000020102"), + ), + }) +} + +func (s *ModuleDVVTestSuite) TestEventTypeSerializationGasCalculation() { + ctx := s.ctx + acc, accPrivKey := s.app.AddAccount(ctx, sdk.NewCoin(dnConfig.MainDenom, sdk.NewInt(1000))) + + s.CheckContractExecuted( + s.DeployModule(acc.GetAddress(), accPrivKey, + "event_type_serialization/gas_calculation/module.move", nil, + ), + ) + + gasInfo, scriptEvents := s.CheckContractExecuted( + s.ExecuteScript(acc.GetAddress(), accPrivKey, + "event_type_serialization/gas_calculation/script.template.move", []string{ + s.GetLibraAccAddressString(acc.GetAddress()), + }, + ), + ) + + //s.PrintABCIEvents(scriptEvents) + s.CheckABCIEventsContain(scriptEvents, []sdk.Event{ + sdk.NewEvent( + types.EventTypeMoveEvent, + sdk.NewAttribute(types.AttributeVmEventSender, acc.GetAddress().String()), + sdk.NewAttribute(types.AttributeVmEventSource, fmt.Sprintf("%s::GasEvent", acc.GetAddress())), + sdk.NewAttribute(types.AttributeVmEventType, fmt.Sprintf("%s::GasEvent::D<%s::GasEvent::C<%s::GasEvent::B<%s::GasEvent::A>>>", acc.GetAddress(), acc.GetAddress(), acc.GetAddress(), acc.GetAddress())), + sdk.NewAttribute(types.AttributeVmEventData, "0a00000000000000"), + ), + }) + + expMinGasUsed := uint64(0) + for i := 1; i <= 4-types.EventTypeNoGasLevels; i++ { + expMinGasUsed += uint64(i) * types.EventTypeProcessingGas + } + + s.T().Logf("Consumed gas / expected min consumed gas: %d / %d", gasInfo.GasUsed, expMinGasUsed) + s.Require().GreaterOrEqual(gasInfo.GasUsed, expMinGasUsed) +} + +func (s *ModuleDVVTestSuite) TestEventTypeSerializationOutOfGas() { + ctx := s.ctx + acc, accPrivKey := s.app.AddAccount(ctx, sdk.NewCoin(dnConfig.MainDenom, sdk.NewInt(1000))) + + // Deploy module + s.CheckContractExecuted( + s.DeployModule(acc.GetAddress(), accPrivKey, + "event_type_serialization/gas_limit/module.move", nil, + ), + ) + + // Estimate event serialization gas usage + expMinGasUsed := uint64(0) + for i := 1; i <= 6-types.EventTypeNoGasLevels; i++ { + expMinGasUsed += uint64(i) * types.EventTypeProcessingGas + } + + // Compile, execute script + byteCodes := s.CompileMoveFile(acc.GetAddress(), "event_type_serialization/gas_limit/script.template.move", s.GetLibraAccAddressString(acc.GetAddress())) + s.Require().Len(byteCodes, 1) + msg := types.NewMsgExecuteScript(acc.GetAddress(), byteCodes[0]) + _, _, err := s.app.DeliverTx(ctx, acc.GetAddress(), accPrivKey, []sdk.Msg{&msg}, tests.TxWithGasLimit(expMinGasUsed)) + + s.Require().True(sdkErrors.ErrOutOfGas.Is(err)) +} + +func (s *ModuleDVVTestSuite) TestDeployModule() { + ctx := s.ctx + acc, accPrivKey := s.app.AddAccount(ctx, sdk.NewCoin(dnConfig.MainDenom, sdk.NewInt(1000))) + + s.CheckContractExecuted( + s.DeployModule(acc.GetAddress(), accPrivKey, + "math/module.move", nil, + ), + ) + + _, scriptEvents := s.CheckContractExecuted( + s.ExecuteScript(acc.GetAddress(), accPrivKey, + "math/script.template.move", []string{ + s.GetLibraAccAddressString(acc.GetAddress()), + }, + s.BuildScriptArg("10", client.NewU64ScriptArg), + s.BuildScriptArg("100", client.NewU64ScriptArg), + ), + ) + + // uint64 -> Little-endian bytes -> HEX string + expResult := uint64(110) + expResultVM, err := client.NewU64ScriptArg(strconv.FormatUint(expResult, 10)) + s.Require().NoError(err) + expResultVMEventAttr := hex.EncodeToString(expResultVM.Value) + + s.CheckABCIEventsContain(scriptEvents, []sdk.Event{ + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeySender, acc.GetAddress().String()), + ), + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyAction, types.TypeMsgExecuteScript), + ), + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), + ), + sdk.NewEvent( + types.EventTypeContractStatus, + sdk.NewAttribute(types.AttributeStatus, types.AttributeValueStatusKeep), + ), + sdk.NewEvent( + types.EventTypeMoveEvent, + sdk.NewAttribute(types.AttributeVmEventSender, acc.GetAddress().String()), + sdk.NewAttribute(types.AttributeVmEventSource, types.AttributeValueSourceScript), + sdk.NewAttribute(types.AttributeVmEventType, "u64"), + sdk.NewAttribute(types.AttributeVmEventData, expResultVMEventAttr), + ), + }) +} + +func (s *ModuleDVVTestSuite) TestCompileMetadata() { + ctx, queryClient := s.ctx, s.queryClient + acc, _ := s.app.AddAccount(ctx, sdk.NewCoin(dnConfig.MainDenom, sdk.NewInt(1000))) + + // Compile + byteCode := s.GetMoveFileContent("modules/with_resources.move") + resp, err := queryClient.Compile(context.Background(), &types.QueryCompileRequest{ + Address: types.Bech32ToLibra(acc.GetAddress()), + Code: string(byteCode), + }) + s.Require().NoError(err) + s.Require().NotNil(resp) + + // Check the compiled meta + s.Require().Len(resp.CompiledItems, 1) + s.Require().Equal(resp.CompiledItems[0].CodeType, types.CompiledItem_MODULE) + s.Require().Equal(resp.CompiledItems[0].Name, "Foo") + s.Require().NotEmpty(resp.CompiledItems[0].ByteCode) + s.Require().ElementsMatch(resp.CompiledItems[0].Methods, []*dvmTypes.Function{ + { + Name: "add", + IsPublic: true, + IsNative: false, + TypeParameters: nil, + Arguments: []string{"&signer", "u64", "u64"}, + Returns: []string{"u64"}, + }, + { + Name: "build_obj", + IsPublic: true, + IsNative: false, + TypeParameters: nil, + Arguments: []string{"&signer", "u64"}, + Returns: nil, + }, + }) + s.Require().ElementsMatch(resp.CompiledItems[0].Types, []*dvmTypes.Struct{ + { + Name: "Obj", + IsResource: true, + TypeParameters: nil, + Field: []*dvmTypes.Field{ + { + Name: "val", + Type: "u64", + }, + { + Name: "o", + Type: "U64", + }, + }, + }, + { + Name: "U64", + IsResource: true, + TypeParameters: nil, + Field: []*dvmTypes.Field{ + { + Name: "val", + Type: "u64", + }, + }, + }, + }) +} + +func (s *ModuleDVVTestSuite) TestNativeBalanceRes() { + ctx := s.ctx + acc, accPrivKey := s.app.AddAccount(ctx, sdk.NewCoin(dnConfig.MainDenom, sdk.NewInt(1000))) + + // Pass the account balance - 1xfi (fee) to the script for assert + s.CheckContractExecuted( + s.ExecuteScript(acc.GetAddress(), accPrivKey, + "scripts/native_balance.move", nil, + s.BuildScriptArg("999", client.NewU128ScriptArg), + ), + ) +} + +func (s *ModuleDVVTestSuite) TestNativeOracleRes() { + ctx := s.ctx + acc, accPrivKey := s.app.AddAccount(ctx, sdk.NewCoin(dnConfig.MainDenom, sdk.NewInt(1000))) + + // TODO: mock test without direct/reverse + s.CheckContractExecuted( + s.ExecuteScript(acc.GetAddress(), accPrivKey, + "scripts/oracle_price_direct.move", nil, + s.BuildScriptArg("100", client.NewU128ScriptArg), + ), + ) +} + +func (s *ModuleDVVTestSuite) TestCurrencyInfoRes() { + ctx := s.ctx + acc, accPrivKey := s.app.AddAccount(ctx, sdk.NewCoin(dnConfig.MainDenom, sdk.NewInt(1000))) + + s.CheckContractExecuted( + s.ExecuteScript(acc.GetAddress(), accPrivKey, + "scripts/currency_infos.move", nil, + s.BuildScriptArg("18", client.NewU8ScriptArg), // xfi + s.BuildScriptArg("18", client.NewU8ScriptArg), // eth + s.BuildScriptArg("8", client.NewU8ScriptArg), // btc + s.BuildScriptArg("6", client.NewU8ScriptArg), // usdt + ), + ) +} + +func (s *ModuleDVVTestSuite) TestBlockTimeTxMeta() { + ctx := s.ctx + acc, accPrivKey := s.app.AddAccount(ctx, sdk.NewCoin(dnConfig.MainDenom, sdk.NewInt(1000))) + + s.app.BeginBlock() + s.app.EndBlock() + blockHeight, blockTime := s.app.GetNextBlockHeightTime() // ExecuteScript starts a new block, so peek next values + + s.CheckContractExecuted( + s.ExecuteScript(acc.GetAddress(), accPrivKey, + "scripts/block_height_time.move", nil, + s.BuildScriptArg(strconv.FormatInt(blockHeight, 10), client.NewU64ScriptArg), + s.BuildScriptArg(strconv.FormatInt(blockTime.Unix(), 10), client.NewU64ScriptArg), + ), + ) +} + +func (s *ModuleDVVTestSuite) TestNativeDepositWithdraw() { + ctx, queryClient, bankKeeper := s.ctx, s.queryClient, s.app.DnApp.BankKeeper + acc, accPrivKey := s.app.AddAccount(ctx, sdk.NewCoin(dnConfig.MainDenom, sdk.NewInt(1000))) + + delCoin := sdk.NewInt64Coin(dnConfig.MainDenom, 500) + + // Query initial DecPool supply + getDecPoolSupply := func() sdk.Coins { + resp, err := queryClient.DelegatedPoolSupply(context.Background(), &types.QueryDelegatedPoolSupplyRequest{}) + s.Require().NoError(err) + s.Require().NotNil(resp) + return resp.Coins + } + prevDecPoolCoins := getDecPoolSupply() + + // Deposit + { + s.CheckContractExecuted( + s.ExecuteScript(acc.GetAddress(), accPrivKey, + "scripts/native_deposit.move", nil, + s.BuildScriptArg(delCoin.Amount.String(), client.NewU128ScriptArg), + ), + ) + + // Check bank balance (-1xfi for the fee) + accBalance := bankKeeper.GetBalance(ctx, acc.GetAddress(), dnConfig.MainDenom) + s.Require().EqualValues(delCoin.Amount.Int64()-1, accBalance.Amount.Int64()) + + // Check DelPool supply + curDecPoolCoins := getDecPoolSupply() + s.Require().True( + prevDecPoolCoins. + Add(delCoin). + IsEqual(curDecPoolCoins), + ) + prevDecPoolCoins = curDecPoolCoins + } + + // Withdraw + { + s.CheckContractExecuted( + s.ExecuteScript(acc.GetAddress(), accPrivKey, + "scripts/native_withdraw.move", nil, + s.BuildScriptArg("500", client.NewU128ScriptArg), + ), + ) + + // Check bank balance (-1xfi for the fee) + accBalance := bankKeeper.GetBalance(ctx, acc.GetAddress(), dnConfig.MainDenom) + s.Require().EqualValues(998, accBalance.Amount.Int64()) + + // Check DelPool supply + curDecPoolCoins := getDecPoolSupply() + s.Require().True( + prevDecPoolCoins. + Sub(sdk.NewCoins(delCoin)). + IsEqual(curDecPoolCoins), + ) + prevDecPoolCoins = curDecPoolCoins + } +} + +func (s *ModuleDVVTestSuite) TestTransferCoins() { + ctx, queryClient, bankKeeper := s.ctx, s.queryClient, s.app.DnApp.BankKeeper + + // Query initial DecPool supply + getDecPoolSupply := func() sdk.Coins { + resp, err := queryClient.DelegatedPoolSupply(context.Background(), &types.QueryDelegatedPoolSupplyRequest{}) + s.Require().NoError(err) + s.Require().NotNil(resp) + return resp.Coins + } + prevDecPoolCoins := getDecPoolSupply() + + // Define initial accounts balances, transfer amounts and expected final balances + acc1InitCoins := sdk.NewCoins( + sdk.NewCoin(dnConfig.MainDenom, sdk.NewInt(1000)), + sdk.NewCoin(dnConfig.EthDenom, sdk.NewInt(1000)), + sdk.NewCoin(dnConfig.BtcDenom, sdk.NewInt(1000)), + sdk.NewCoin(dnConfig.UsdtDenom, sdk.NewInt(1000)), + ) + acc2InitCoins := sdk.NewCoins( + sdk.NewCoin(dnConfig.MainDenom, sdk.NewInt(1)), + ) + + transferCoins := sdk.NewCoins( + sdk.NewInt64Coin(dnConfig.MainDenom, 500), + sdk.NewInt64Coin(dnConfig.EthDenom, 450), + sdk.NewInt64Coin(dnConfig.BtcDenom, 400), + sdk.NewInt64Coin(dnConfig.UsdtDenom, 350), + ) + + acc1ExpCoins := acc1InitCoins. + Sub(transferCoins). + Sub(sdk.NewCoins(sdk.NewInt64Coin(dnConfig.MainDenom, 1))) + acc2ExpCoins := transferCoins + + acc1, acc1PrivKey := s.app.AddAccount(ctx, acc1InitCoins...) + acc2, acc2PrivKey := s.app.AddAccount(ctx, acc2InitCoins...) + + // Account 1 -> Account 2: deposit and send via VM + { + s.CheckContractExecuted( + s.ExecuteScript(acc1.GetAddress(), acc1PrivKey, + "scripts/transfer_send.move", nil, + s.BuildScriptArg(acc2.GetAddress().String(), client.NewAddressScriptArg), + s.BuildScriptArg(transferCoins.AmountOf(dnConfig.MainDenom).String(), client.NewU128ScriptArg), + s.BuildScriptArg(transferCoins.AmountOf(dnConfig.EthDenom).String(), client.NewU128ScriptArg), + s.BuildScriptArg(transferCoins.AmountOf(dnConfig.BtcDenom).String(), client.NewU128ScriptArg), + s.BuildScriptArg(transferCoins.AmountOf(dnConfig.UsdtDenom).String(), client.NewU128ScriptArg), + ), + ) + + // Check bank balance + acc1CurCoins := bankKeeper.GetAllBalances(ctx, acc1.GetAddress()) + s.Require().True(acc1ExpCoins.IsEqual(acc1CurCoins)) + + acc2CurCoins := bankKeeper.GetAllBalances(ctx, acc2.GetAddress()) + s.Require().True(acc2InitCoins.IsEqual(acc2CurCoins)) + + // Check DelPool supply + curDecPoolCoins := getDecPoolSupply() + s.Require().True( + prevDecPoolCoins. + Add(transferCoins...). + IsEqual(curDecPoolCoins), + ) + prevDecPoolCoins = curDecPoolCoins + } + + // Account 2: withdraw + { + s.CheckContractExecuted( + s.ExecuteScript(acc2.GetAddress(), acc2PrivKey, + "scripts/transfer_receive.move", nil, + s.BuildScriptArg(transferCoins.AmountOf(dnConfig.MainDenom).String(), client.NewU128ScriptArg), + s.BuildScriptArg(transferCoins.AmountOf(dnConfig.EthDenom).String(), client.NewU128ScriptArg), + s.BuildScriptArg(transferCoins.AmountOf(dnConfig.BtcDenom).String(), client.NewU128ScriptArg), + s.BuildScriptArg(transferCoins.AmountOf(dnConfig.UsdtDenom).String(), client.NewU128ScriptArg), + ), + ) + + // Check bank balance + acc1CurCoins := bankKeeper.GetAllBalances(ctx, acc1.GetAddress()) + s.Require().True(acc1ExpCoins.IsEqual(acc1CurCoins)) + + acc2CurCoins := bankKeeper.GetAllBalances(ctx, acc2.GetAddress()) + s.Require().True(acc2ExpCoins.IsEqual(acc2CurCoins)) + + // Check DelPool supply + curDecPoolCoins := getDecPoolSupply() + s.Require().True( + prevDecPoolCoins. + Sub(transferCoins). + IsEqual(curDecPoolCoins), + ) + prevDecPoolCoins = curDecPoolCoins + } +} + +func (s *ModuleDVVTestSuite) TestDeployExecuteEdgeCases() { + ctx := s.ctx + + // Case 1: deploy the same module twice, execute script + // - Second deploy should fail + // - Script should execute (first module is deployed) + { + acc, accPrivKey := s.app.AddAccount(ctx, sdk.NewCoin(dnConfig.MainDenom, sdk.NewInt(1000))) + + s.CheckContractExecuted( + s.DeployModule(acc.GetAddress(), accPrivKey, + "math/module.move", nil, + ), + ) + + s.CheckContractFailed( + s.DeployModule(acc.GetAddress(), accPrivKey, + "math/module.move", nil, + ), + ) + + s.CheckContractExecuted( + s.ExecuteScript(acc.GetAddress(), accPrivKey, + "math/script.template.move", []string{ + s.GetLibraAccAddressString(acc.GetAddress()), + }, + s.BuildScriptArg("1", client.NewU64ScriptArg), + s.BuildScriptArg("2", client.NewU64ScriptArg), + ), + ) + } + + // Case 2: deploy module with address prefix (address 0x... { ... }) + // - Module with address prefix is OK (should deploy) + // - Second deploy should fail + // - Script should execute (first module is deployed) + { + acc, accPrivKey := s.app.AddAccount(ctx, sdk.NewCoin(dnConfig.MainDenom, sdk.NewInt(1000))) + + s.CheckContractExecuted( + s.DeployModule(acc.GetAddress(), accPrivKey, + "math/module_addr_wrapped.template.move", []string{ + s.GetLibraAccAddressString(acc.GetAddress()), + }, + ), + ) + + s.CheckContractFailed( + s.DeployModule(acc.GetAddress(), accPrivKey, + "math/module_addr_wrapped.template.move", []string{ + s.GetLibraAccAddressString(acc.GetAddress()), + }, + ), + ) + + s.CheckContractExecuted( + s.ExecuteScript(acc.GetAddress(), accPrivKey, + "math/script.template.move", []string{ + s.GetLibraAccAddressString(acc.GetAddress()), + }, + s.BuildScriptArg("1", client.NewU64ScriptArg), + s.BuildScriptArg("2", client.NewU64ScriptArg), + ), + ) + } + + // Case 3: deploy multiple modules sourced from one file, execute scripts from one file + // - Multi-module file should compile and deploy + // - Multi-script file should compile (two CompiledUnits) + // - Script execution only allowed for one script, but multiple Msgs might be included into one Tx + { + acc, accPrivKey := s.app.AddAccount(ctx, sdk.NewCoin(dnConfig.MainDenom, sdk.NewInt(1000))) + + // Deploy 4 modules + s.CheckContractExecuted( + s.DeployModule(acc.GetAddress(), accPrivKey, + "math/module_quad.move", nil, + ), + ) + + // Compile 2 scripts + scriptsCode := s.CompileMoveFile(acc.GetAddress(), + "math/script_double.template.move", + s.GetLibraAccAddressString(acc.GetAddress()), + s.GetLibraAccAddressString(acc.GetAddress()), + s.GetLibraAccAddressString(acc.GetAddress()), + s.GetLibraAccAddressString(acc.GetAddress()), + ) + s.Require().Len(scriptsCode, 2) + + // Execute scripts one by one (in one Tx) + script1Msg := types.NewMsgExecuteScript(acc.GetAddress(), scriptsCode[0], + s.BuildScriptArg("5", client.NewU64ScriptArg), + s.BuildScriptArg("5", client.NewU64ScriptArg), + s.BuildScriptArg("2", client.NewU64ScriptArg), + ) + + script2Msg := types.NewMsgExecuteScript(acc.GetAddress(), scriptsCode[1], + s.BuildScriptArg("5", client.NewU64ScriptArg), + s.BuildScriptArg("5", client.NewU64ScriptArg), + s.BuildScriptArg("2", client.NewU64ScriptArg), + ) + + _, scriptsEvents := s.CheckContractExecuted( + s.app.DeliverTx( + s.ctx, + acc.GetAddress(), + accPrivKey, + []sdk.Msg{&script1Msg, &script2Msg}, + ), + ) + + s.CheckABCIEventsContain(scriptsEvents, []sdk.Event{ + sdk.NewEvent( + types.EventTypeMoveEvent, + sdk.NewAttribute(types.AttributeVmEventSender, acc.GetAddress().String()), + sdk.NewAttribute(types.AttributeVmEventSource, types.AttributeValueSourceScript), + sdk.NewAttribute(types.AttributeVmEventType, "u64"), + sdk.NewAttribute(types.AttributeVmEventData, "0800000000000000"), + ), + sdk.NewEvent( + types.EventTypeMoveEvent, + sdk.NewAttribute(types.AttributeVmEventSender, acc.GetAddress().String()), + sdk.NewAttribute(types.AttributeVmEventSource, types.AttributeValueSourceScript), + sdk.NewAttribute(types.AttributeVmEventType, "u64"), + sdk.NewAttribute(types.AttributeVmEventData, "0200000000000000"), + ), + }) + } + + // Case 4: mixed module/script file + // - Mixed file should compile + // - Mixed module/script byteCode shouldn't be deployed + { + acc, accPrivKey := s.app.AddAccount(ctx, sdk.NewCoin(dnConfig.MainDenom, sdk.NewInt(1000))) + + s.CheckContractFailed( + s.DeployModule(acc.GetAddress(), accPrivKey, + "module_script.move", nil, + ), + ) + } +} diff --git a/x/vm/keeper/common_test.go b/x/vm/keeper/common_test.go new file mode 100644 index 0000000..2fdf502 --- /dev/null +++ b/x/vm/keeper/common_test.go @@ -0,0 +1,62 @@ +package keeper_test + +import ( + "context" + "testing" + "time" + + "github.com/cosmos/cosmos-sdk/baseapp" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/suite" + + "github.com/dfinance/dstation/pkg/mock" + "github.com/dfinance/dstation/pkg/tests" + dvmTypes "github.com/dfinance/dstation/pkg/types/dvm" + "github.com/dfinance/dstation/x/vm/keeper" + "github.com/dfinance/dstation/x/vm/types" +) + +type KeeperMockVmTestSuite struct { + suite.Suite + + app *tests.DSimApp + ctx sdk.Context + keeper keeper.Keeper + vmServer *mock.VMServer + queryClient types.QueryClient +} + +func (s *KeeperMockVmTestSuite) SetupSuite() { + // Init the SimApp + s.app = tests.SetupDSimApp(tests.WithMockVM()) + s.ctx = s.app.GetContext(false) + s.keeper = s.app.DnApp.VmKeeper + s.vmServer = s.app.MockVMServer + + // Init the querier client + querier := keeper.Querier{Keeper: s.keeper} + queryHelper := baseapp.NewQueryServerTestHelper(s.ctx, s.app.DnApp.InterfaceRegistry()) + types.RegisterQueryServer(queryHelper, querier) + s.queryClient = types.NewQueryClient(queryHelper) +} + +func (s *KeeperMockVmTestSuite) TearDownSuite() { + s.app.TearDown() +} + +func (s *KeeperMockVmTestSuite) SetupTest() { + s.ctx = s.ctx.WithEventManager(sdk.NewEventManager()) +} + +func (s *KeeperMockVmTestSuite) DoDSClientRequest(handler func(ctx context.Context, client dvmTypes.DSServiceClient)) { + client := dvmTypes.NewDSServiceClient(s.app.MockVMServer.GetDSClientConnection()) + ctx, ctxCancel := context.WithDeadline(context.Background(), time.Now().Add(100*time.Millisecond)) + defer ctxCancel() + + handler(ctx, client) +} + +func TestVMKeeper_MockVM(t *testing.T) { + t.Parallel() + suite.Run(t, new(KeeperMockVmTestSuite)) +} diff --git a/x/vm/keeper/genesis.go b/x/vm/keeper/genesis.go new file mode 100644 index 0000000..04942d2 --- /dev/null +++ b/x/vm/keeper/genesis.go @@ -0,0 +1,46 @@ +package keeper + +import ( + "encoding/hex" + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + + dvmTypes "github.com/dfinance/dstation/pkg/types/dvm" + "github.com/dfinance/dstation/x/vm/types" +) + +// InitGenesis inits module genesis state: creates currencies. +func (k Keeper) InitGenesis(ctx sdk.Context, state *types.GenesisState) { + // VM writeSets + for genWOIdx, genWriteOp := range state.WriteSet { + accessPath, value, err := genWriteOp.ToBytes() + if err != nil { + panic(fmt.Errorf("writeSet [%d]: %w", genWOIdx, err)) + } + + k.SetValue(ctx, accessPath, value) + } + + // Edge-case: set storage context for DS before the BeginBlock occurs + k.dsServer.SetContext(ctx) +} + +// ExportGenesis exports module genesis state using current params state. +func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { + state := types.GenesisState{} + + // VM writeSets + k.iterateVMStorageValues(ctx, func(accessPath *dvmTypes.VMAccessPath, value []byte) bool { + writeSetOp := types.GenesisState_WriteOp{ + Address: hex.EncodeToString(accessPath.Address), + Path: hex.EncodeToString(accessPath.Path), + Value: hex.EncodeToString(value), + } + state.WriteSet = append(state.WriteSet, writeSetOp) + + return false + }) + + return &state +} diff --git a/x/vm/keeper/genesis_test.go b/x/vm/keeper/genesis_test.go new file mode 100644 index 0000000..b187e21 --- /dev/null +++ b/x/vm/keeper/genesis_test.go @@ -0,0 +1,55 @@ +package keeper_test + +import ( + "encoding/hex" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/dfinance/dstation/pkg/mock" + "github.com/dfinance/dstation/pkg/tests" + "github.com/dfinance/dstation/x/vm/types" +) + +func TestVMKeeper_Genesis(t *testing.T) { + app := tests.SetupDSimApp() + defer app.TearDown() + + ctx, keeper := app.GetContext(false), app.DnApp.VmKeeper + + genStateExpected, genStateAppendix := types.DefaultGenesisState(), types.GenesisState{} + + // Add genesis data + { + // VM writeSets + for i := 0; i < 5; i++ { + vmPath, writeSetData := mock.GetRandomVMAccessPath(), mock.GetRandomBytes(20) + writeOp := types.GenesisState_WriteOp{ + Address: hex.EncodeToString(vmPath.Address), + Path: hex.EncodeToString(vmPath.Path), + Value: hex.EncodeToString(writeSetData), + } + + genStateAppendix.WriteSet = append(genStateAppendix.WriteSet, writeOp) + genStateExpected.WriteSet = append(genStateExpected.WriteSet, writeOp) + } + } + + + // ok: Init / Export check + { + keeper.InitGenesis(ctx, &genStateAppendix) + genStateExported := keeper.ExportGenesis(ctx) + + require.ElementsMatch(t, genStateExpected.WriteSet, genStateExported.WriteSet) + } + + // ok: DelPool module account check + { + delPoolAcc := app.DnApp.AccountKeeper.GetModuleAccount(ctx, types.DelPoolName) + require.NotNil(t, delPoolAcc) + + delPoolCoins := app.DnApp.BankKeeper.GetAllBalances(ctx, delPoolAcc.GetAddress()) + require.True(t, delPoolCoins.IsZero()) + } +} diff --git a/x/vm/keeper/grpc_ds_server.go b/x/vm/keeper/grpc_ds_server.go new file mode 100644 index 0000000..041e303 --- /dev/null +++ b/x/vm/keeper/grpc_ds_server.go @@ -0,0 +1,254 @@ +package keeper + +import ( + "context" + "encoding/hex" + "fmt" + "net" + "strings" + "sync" + "time" + + "google.golang.org/grpc" + + dvmTypes "github.com/dfinance/dstation/pkg/types/dvm" + "github.com/dfinance/dstation/x/vm/types" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/tendermint/tendermint/libs/log" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +var _ dvmTypes.DSServiceServer = &DSServer{} + +// DSServer is a DataSource server that catches VM client data requests. +type DSServer struct { + sync.Mutex + // Current storage context and implementation + ctx sdk.Context + storage types.VMStorage + ccInfoProvider types.CurrencyInfoResProvider + nBalanceProvider types.AccountBalanceResProvider + // Data middleware handlers + dataMiddlewares []types.DSDataMiddleware + // Started gRPC server instance + server *grpc.Server +} + +// Logger returns logger with DS server context. +func (srv *DSServer) Logger() log.Logger { + return srv.ctx.Logger().With("module", fmt.Sprintf("x/%s/dsserver", types.ModuleName)) +} + +// RegisterDataMiddleware registers new data middleware. +func (srv *DSServer) RegisterDataMiddleware(md types.DSDataMiddleware) { + srv.dataMiddlewares = append(srv.dataMiddlewares, md) +} + +// SetContext updates server storage context. +func (srv *DSServer) SetContext(ctx sdk.Context) { + srv.Lock() + defer srv.Unlock() + + srv.ctx = ctx +} + +// IsStarted checks if gRPC server has been started. +func (srv *DSServer) IsStarted() bool { + srv.Lock() + defer srv.Unlock() + + return srv.server != nil +} + +// Start starts gRPC DS server in the go routine. +func (srv *DSServer) Start(listener net.Listener) { + srv.Lock() + defer srv.Unlock() + + if srv.server != nil { + return + } + + srv.server = grpc.NewServer() + dvmTypes.RegisterDSServiceServer(srv.server, srv) + + go func() { + if err := srv.server.Serve(listener); err != nil { + panic(err) // should not happen + } + }() + time.Sleep(10 * time.Millisecond) // force context switch for server to start +} + +// Stop stops gRPC DS server. +func (srv *DSServer) Stop() { + srv.Lock() + defer srv.Unlock() + + if srv.server == nil { + return + } + + srv.server.Stop() +} + +// GetOraclePrice implements gRPC service handler: returns Oracle price for the specified currency pair. +func (srv *DSServer) GetOraclePrice(_ context.Context, req *dvmTypes.OraclePriceRequest) (*dvmTypes.OraclePriceResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + // Input check + denomLeft, denomRight := strings.ToLower(req.Currency_1), strings.ToLower(req.Currency_2) + if err := sdk.ValidateDenom(denomLeft); err != nil { + return &dvmTypes.OraclePriceResponse{ + ErrorCode: dvmTypes.ErrorCode_BAD_REQUEST, + ErrorMessage: fmt.Sprintf("currency_1: %v", err), + }, nil + } + if err := sdk.ValidateDenom(denomRight); err != nil { + return &dvmTypes.OraclePriceResponse{ + ErrorCode: dvmTypes.ErrorCode_BAD_REQUEST, + ErrorMessage: fmt.Sprintf("currency_2: %v", err), + }, nil + } + + // Mock response + exchangeRate := sdk.NewUint(100) + exchangeRateU128, err := types.SdkUintToVmU128(exchangeRate) + if err != nil { + panic(fmt.Errorf("converting exchangeRate (%s) to U128: %w", exchangeRate, err)) + } + + return &dvmTypes.OraclePriceResponse{Price: exchangeRateU128}, nil +} + +// GetNativeBalance implements gRPC service handler: returns account native balance resource. +func (srv *DSServer) GetNativeBalance(_ context.Context, req *dvmTypes.NativeBalanceRequest) (*dvmTypes.NativeBalanceResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + // Input check + accAddr, err := types.LibraToBech32(req.Address) + if err != nil { + return &dvmTypes.NativeBalanceResponse{ + ErrorCode: dvmTypes.ErrorCode_BAD_REQUEST, + ErrorMessage: fmt.Sprintf("address: %v", err), + }, nil + } + + denom := strings.ToLower(req.Ticker) + if err := sdk.ValidateDenom(denom); err != nil { + return &dvmTypes.NativeBalanceResponse{ + ErrorCode: dvmTypes.ErrorCode_BAD_REQUEST, + ErrorMessage: fmt.Sprintf("ticker: %v", err), + }, nil + } + + // Build response + balance := srv.nBalanceProvider.GetVmAccountBalance(srv.ctx, accAddr, denom) + + return &dvmTypes.NativeBalanceResponse{ + Balance: balance, + }, nil +} + +// GetCurrencyInfo implements gRPC service handler: returns CurrencyInfo resource. +func (srv *DSServer) GetCurrencyInfo(_ context.Context, req *dvmTypes.CurrencyInfoRequest) (*dvmTypes.CurrencyInfoResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + // Input check + denom := strings.ToLower(req.Ticker) + if err := sdk.ValidateDenom(denom); err != nil { + return &dvmTypes.CurrencyInfoResponse{ + ErrorCode: dvmTypes.ErrorCode_BAD_REQUEST, + ErrorMessage: fmt.Sprintf("ticker: %v", err), + }, nil + } + + // Build response + ccInfo := srv.ccInfoProvider.GetVmCurrencyInfo(srv.ctx, denom) + if ccInfo == nil { + return &dvmTypes.CurrencyInfoResponse{ + Info: nil, + ErrorCode: dvmTypes.ErrorCode_NO_DATA, + ErrorMessage: "denom not registered", + }, nil + } + + return &dvmTypes.CurrencyInfoResponse{Info: ccInfo}, nil +} + +// GetRaw implements gRPC service handler: returns value from the storage. +func (srv *DSServer) GetRaw(_ context.Context, req *dvmTypes.DSAccessPath) (*dvmTypes.DSRawResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + noDataErr := func(path *dvmTypes.DSAccessPath) *dvmTypes.DSRawResponse { + return &dvmTypes.DSRawResponse{ + ErrorCode: dvmTypes.ErrorCode_NO_DATA, + ErrorMessage: fmt.Sprintf("data not found for access path: %s", path.String()), + } + } + + path := &dvmTypes.VMAccessPath{ + Address: req.Address, + Path: req.Path, + } + srv.Logger().Info(fmt.Sprintf("Get path: %s", types.StringifyVMAccessPath(path))) + + // check middlewares + blob, err := srv.processMiddlewares(path) + if err != nil { + srv.Logger().Error(fmt.Sprintf("Error processing middlewares for path %s: %v", types.StringifyVMAccessPath(path), err)) + return noDataErr(req), nil + } + if blob != nil { + return &dvmTypes.DSRawResponse{Blob: blob}, nil + } + + // check storage + if !srv.storage.HasValue(srv.ctx, path) { + srv.Logger().Debug(fmt.Sprintf("Can't find path: %s", types.StringifyVMAccessPath(path))) + return noDataErr(req), nil + } + + srv.Logger().Debug(fmt.Sprintf("Get path: %s", types.StringifyVMAccessPath(path))) + blob = srv.storage.GetValue(srv.ctx, path) + srv.Logger().Debug(fmt.Sprintf("Return values: %s\n", hex.EncodeToString(blob))) + + return &dvmTypes.DSRawResponse{Blob: blob}, nil +} + +// MultiGetRaw implements gRPC service handler: returns multiple values from the storage. +func (srv *DSServer) MultiGetRaw(_ context.Context, req *dvmTypes.DSAccessPaths) (*dvmTypes.DSRawResponses, error) { + return nil, status.Errorf(codes.Unimplemented, "MultiGetRaw unimplemented") +} + +// processMiddlewares checks that accessPath can be processed by any registered middleware. +// Contract: if {data} != nil, middleware was found. +func (srv *DSServer) processMiddlewares(path *dvmTypes.VMAccessPath) (data []byte, err error) { + for _, f := range srv.dataMiddlewares { + data, err = f(srv.ctx, path) + if err != nil || data != nil { + return + } + } + + return +} + +// NewDSServer creates a new DS server. +func NewDSServer(storage types.VMStorage, ccInfoProvider types.CurrencyInfoResProvider, nBalanceProvider types.AccountBalanceResProvider) *DSServer { + return &DSServer{ + storage: storage, + ccInfoProvider: ccInfoProvider, + nBalanceProvider: nBalanceProvider, + } +} diff --git a/x/vm/keeper/grpc_ds_server_test.go b/x/vm/keeper/grpc_ds_server_test.go new file mode 100644 index 0000000..681942a --- /dev/null +++ b/x/vm/keeper/grpc_ds_server_test.go @@ -0,0 +1,186 @@ +package keeper_test + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + + dnConfig "github.com/dfinance/dstation/cmd/dstation/config" + "github.com/dfinance/dstation/pkg/mock" + "github.com/dfinance/dstation/pkg/tests" + dvmTypes "github.com/dfinance/dstation/pkg/types/dvm" + "github.com/dfinance/dstation/x/vm/types" +) + +func (s *KeeperMockVmTestSuite) TestDSServer_GetRaw() { + ctx, keeper := s.ctx, s.keeper + + // ok: non-existing + { + vmPath := mock.GetRandomVMAccessPath() + + s.DoDSClientRequest(func(ctx context.Context, client dvmTypes.DSServiceClient) { + resp, err := client.GetRaw(ctx, &dvmTypes.DSAccessPath{Address: vmPath.Address, Path: vmPath.Path}) + s.Require().NoError(err) + s.Require().NotNil(resp) + + s.Require().Equal(dvmTypes.ErrorCode_NO_DATA, resp.ErrorCode) + s.Require().NotEmpty(resp.ErrorMessage) + s.Require().Nil(resp.Blob) + }) + } + + // ok + { + vmPath, writeSetData := mock.GetRandomVMAccessPath(), mock.GetRandomBytes(8) + keeper.SetValue(ctx, vmPath, writeSetData) + + s.DoDSClientRequest(func(ctx context.Context, client dvmTypes.DSServiceClient) { + resp, err := client.GetRaw(ctx, &dvmTypes.DSAccessPath{Address: vmPath.Address, Path: vmPath.Path}) + s.Require().NoError(err) + s.Require().NotNil(resp) + + s.Require().Equal(dvmTypes.ErrorCode_NONE, resp.ErrorCode) + s.Require().Empty(resp.ErrorMessage) + s.Require().Equal(writeSetData, resp.Blob) + }) + } +} + +func (s *KeeperMockVmTestSuite) TestDSServer_GetCurrencyInfo() { + ctx, bankKeeper := s.ctx, s.app.DnApp.BankKeeper + + // fail: input + { + // denom + { + s.DoDSClientRequest(func(ctx context.Context, client dvmTypes.DSServiceClient) { + resp, err := client.GetCurrencyInfo(ctx, &dvmTypes.CurrencyInfoRequest{Ticker: ""}) + s.Require().NoError(err) + s.Require().NotNil(resp) + + s.Require().Equal(dvmTypes.ErrorCode_BAD_REQUEST, resp.ErrorCode) + s.Require().NotEmpty(resp.ErrorMessage) + }) + } + } + + // ok: non-existing + { + s.DoDSClientRequest(func(ctx context.Context, client dvmTypes.DSServiceClient) { + resp, err := client.GetCurrencyInfo(ctx, &dvmTypes.CurrencyInfoRequest{Ticker: "abc"}) + s.Require().NoError(err) + s.Require().NotNil(resp) + + s.Require().Equal(dvmTypes.ErrorCode_NO_DATA, resp.ErrorCode) + s.Require().NotEmpty(resp.ErrorMessage) + s.Require().Nil(resp.Info) + }) + } + + // ok: xfi + { + s.app.AddAccount(ctx, sdk.NewCoin(dnConfig.MainDenom, sdk.NewInt(1000))) + curTotalSupply := bankKeeper.GetSupply(ctx).GetTotal().AmountOf(dnConfig.MainDenom) + + curTotalSupplyU128, err := types.SdkIntToVmU128(curTotalSupply) + s.Require().NoError(err) + + s.DoDSClientRequest(func(ctx context.Context, client dvmTypes.DSServiceClient) { + resp, err := client.GetCurrencyInfo(ctx, &dvmTypes.CurrencyInfoRequest{Ticker: "xfi"}) + s.Require().NoError(err) + s.Require().NotNil(resp) + + s.Require().Equal(dvmTypes.ErrorCode_NONE, resp.ErrorCode) + s.Require().Empty(resp.ErrorMessage) + + s.Require().Equal([]byte("xfi"), resp.Info.Denom) + s.Require().EqualValues(18, resp.Info.Decimals) + s.Require().EqualValues(curTotalSupplyU128.Buf, resp.Info.TotalSupply.Buf) + }) + } +} + +func (s *KeeperMockVmTestSuite) TestDSServer_GetNativeBalance() { + ctx := s.ctx + + accXfiBalance := sdk.NewInt(500) + acc, _ := s.app.AddAccount(ctx, sdk.NewCoin(dnConfig.MainDenom, accXfiBalance)) + + // fail: input + { + // address + { + s.DoDSClientRequest(func(ctx context.Context, client dvmTypes.DSServiceClient) { + resp, err := client.GetNativeBalance(ctx, &dvmTypes.NativeBalanceRequest{Address: []byte{0x0}, Ticker: "xfi"}) + s.Require().NoError(err) + s.Require().NotNil(resp) + + s.Require().Equal(dvmTypes.ErrorCode_BAD_REQUEST, resp.ErrorCode) + s.Require().NotEmpty(resp.ErrorMessage) + }) + } + + // denom + { + s.DoDSClientRequest(func(ctx context.Context, client dvmTypes.DSServiceClient) { + resp, err := client.GetNativeBalance(ctx, &dvmTypes.NativeBalanceRequest{Address: types.Bech32ToLibra(acc.GetAddress()), Ticker: ""}) + s.Require().NoError(err) + s.Require().NotNil(resp) + + s.Require().Equal(dvmTypes.ErrorCode_BAD_REQUEST, resp.ErrorCode) + s.Require().NotEmpty(resp.ErrorMessage) + }) + } + } + + // ok: non-existing + { + accAddr, _, _ := tests.GenAccAddress() + + s.DoDSClientRequest(func(ctx context.Context, client dvmTypes.DSServiceClient) { + resp, err := client.GetNativeBalance(ctx, &dvmTypes.NativeBalanceRequest{Address: types.Bech32ToLibra(accAddr), Ticker: "mybtc"}) + s.Require().NoError(err) + s.Require().NotNil(resp) + + s.Require().Equal(dvmTypes.ErrorCode_NONE, resp.ErrorCode) + s.Require().Empty(resp.ErrorMessage) + s.checkVmU128Value(sdk.ZeroInt(), resp.Balance) + }) + } + + // ok: existing acc: existing denom + { + s.DoDSClientRequest(func(ctx context.Context, client dvmTypes.DSServiceClient) { + resp, err := client.GetNativeBalance(ctx, &dvmTypes.NativeBalanceRequest{Address: types.Bech32ToLibra(acc.GetAddress()), Ticker: dnConfig.MainDenom}) + s.Require().NoError(err) + s.Require().NotNil(resp) + + s.Require().Equal(dvmTypes.ErrorCode_NONE, resp.ErrorCode) + s.Require().Empty(resp.ErrorMessage) + s.checkVmU128Value(accXfiBalance, resp.Balance) + }) + } + + // ok: existing acc: non-existing denom + { + s.DoDSClientRequest(func(ctx context.Context, client dvmTypes.DSServiceClient) { + resp, err := client.GetNativeBalance(ctx, &dvmTypes.NativeBalanceRequest{Address: types.Bech32ToLibra(acc.GetAddress()), Ticker: "mybtc"}) + s.Require().NoError(err) + s.Require().NotNil(resp) + + s.Require().Equal(dvmTypes.ErrorCode_NONE, resp.ErrorCode) + s.Require().Empty(resp.ErrorMessage) + s.checkVmU128Value(sdk.ZeroInt(), resp.Balance) + }) + } +} + +func (s *KeeperMockVmTestSuite) checkVmU128Value(expected sdk.Int, received *dvmTypes.U128) { + s.Require().NotNil(received) + s.Require().Len(received.Buf, 16) + + expectedU128, err := types.SdkIntToVmU128(expected) + s.Require().NoError(err) + s.Require().ElementsMatch(expectedU128.Buf, received.Buf) +} diff --git a/x/vm/keeper/grpc_query.go b/x/vm/keeper/grpc_query.go new file mode 100644 index 0000000..55ef7bb --- /dev/null +++ b/x/vm/keeper/grpc_query.go @@ -0,0 +1,139 @@ +package keeper + +import ( + "context" + "strings" + + sdk "github.com/cosmos/cosmos-sdk/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + dvmTypes "github.com/dfinance/dstation/pkg/types/dvm" + "github.com/dfinance/dstation/x/vm/types" +) + +var _ types.QueryServer = Querier{} + +// Querier implements gRPC query RPCs. +type Querier struct { + Keeper +} + +// Data queries VMStorage value. +func (k Querier) Data(c context.Context, req *types.QueryDataRequest) (*types.QueryDataResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + // Validate and parse request + if len(req.Address) != types.VMAddressLength { + return nil, status.Errorf(codes.InvalidArgument, "address: invalid length (should be %d)", types.VMAddressLength) + } + if len(req.Path) == 0 { + return nil, status.Errorf(codes.InvalidArgument, "path: empty") + } + + ctx := sdk.UnwrapSDKContext(c) + value := k.GetValue(ctx, &dvmTypes.VMAccessPath{Address: req.Address, Path: req.Path}) + + return &types.QueryDataResponse{Value: value}, nil +} + +// TxVmStatus queries Tx VM status based on Tx ABCI logs. +func (k Querier) TxVmStatus(c context.Context, req *types.QueryTxVmStatusRequest) (*types.QueryTxVmStatusResponse, error) { + txVmStatus := types.NewVmStatusFromABCILogs(req.TxMeta) + return &types.QueryTxVmStatusResponse{VmStatus: txVmStatus}, nil +} + +// Compile queries Move code compilation. +func (k Querier) Compile(c context.Context, req *types.QueryCompileRequest) (*types.QueryCompileResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + // Validate and parse request + if len(req.Address) != types.VMAddressLength { + return nil, status.Errorf(codes.InvalidArgument, "address: invalid length (should be %d)", types.VMAddressLength) + } + if len(req.Code) == 0 { + return nil, status.Errorf(codes.InvalidArgument, "code: empty") + } + + // Build compile request + compReq := &dvmTypes.SourceFiles{ + Units: []*dvmTypes.CompilationUnit{ + { + Text: string(req.Code), + Name: "CompilationUnit", + }, + }, + Address: req.Address, + } + + // Compile request + compResp, err := k.vmClient.Compile(c, compReq) + if err != nil { + return nil, status.Errorf(codes.Unavailable, "compilation failed: VM connection (compilation): %v", err) + } + + // Check for compilation errors + if len(compResp.Errors) > 0 { + return nil, status.Errorf(codes.InvalidArgument, "compilation failed: compiler errors: [%s]", strings.Join(compResp.Errors, ", ")) + } + + // Build response + resp := make([]types.CompiledItem, 0, len(compResp.Units)) + for _, unit := range compResp.Units { + compItem := types.CompiledItem{ + ByteCode: unit.Bytecode, + Name: unit.Name, + } + + meta, err := k.vmClient.GetMetadata(c, &dvmTypes.Bytecode{Code: unit.Bytecode}) + if err != nil { + return nil, status.Errorf(codes.Unavailable, "compilation failed: VM connection (getting meta information): %v", err) + } + + if ok := meta.GetScript(); ok != nil { + compItem.CodeType = types.CompiledItem_SCRIPT + } + + if moduleMeta := meta.GetModule(); moduleMeta != nil { + compItem.CodeType = types.CompiledItem_MODULE + compItem.Types = moduleMeta.GetTypes() + compItem.Methods = moduleMeta.GetFunctions() + } + + resp = append(resp, compItem) + } + + return &types.QueryCompileResponse{CompiledItems: resp}, nil +} + +// Metadata queries VM for byteCode metadata. +func (k Querier) Metadata(c context.Context, req *types.QueryMetadataRequest) (*types.QueryMetadataResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + res, err := k.vmClient.GetMetadata(c, &dvmTypes.Bytecode{ + Code: req.Code, + }) + if err != nil { + return nil, status.Errorf(codes.Internal, "getting meta information: %v", err) + } + + return &types.QueryMetadataResponse{Metadata: res}, nil +} + +// DelegatedPoolSupply queries DelPool current supply. +func (k Querier) DelegatedPoolSupply(c context.Context, req *types.QueryDelegatedPoolSupplyRequest) (*types.QueryDelegatedPoolSupplyResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + ctx := sdk.UnwrapSDKContext(c) + coins := k.GetDelegatedPoolSupply(ctx) + + return &types.QueryDelegatedPoolSupplyResponse{Coins: coins}, nil +} diff --git a/x/vm/keeper/grpc_query_test.go b/x/vm/keeper/grpc_query_test.go new file mode 100644 index 0000000..51fd901 --- /dev/null +++ b/x/vm/keeper/grpc_query_test.go @@ -0,0 +1,57 @@ +package keeper_test + +import ( + "context" + + "github.com/dfinance/dstation/pkg/mock" + "github.com/dfinance/dstation/x/vm/types" +) + +func (s *KeeperMockVmTestSuite) TestQuerier() { + ctx, keeper, client := s.ctx, s.keeper, s.queryClient + vmPath, writeSetData := mock.GetRandomVMAccessPath(), mock.GetRandomBytes(12) + + // fail: invalid address + { + resp, err := client.Data(context.Background(), &types.QueryDataRequest{ + Address: []byte{0x1, 0x2}, + Path: vmPath.Path, + }) + s.Require().Error(err) + s.Require().Nil(resp) + } + + // fail: invalid path + { + resp, err := client.Data(context.Background(), &types.QueryDataRequest{ + Address: vmPath.Address, + Path: []byte{}, + }) + s.Require().Error(err) + s.Require().Nil(resp) + } + + // ok: non-existing + { + resp, err := client.Data(context.Background(), &types.QueryDataRequest{ + Address: vmPath.Address, + Path: vmPath.Path, + }) + s.Require().NoError(err) + s.Require().NotNil(resp) + s.Require().Empty(resp.Value) + } + + // ok: existing + { + keeper.SetValue(ctx, vmPath, writeSetData) + + resp, err := client.Data(context.Background(), &types.QueryDataRequest{ + Address: vmPath.Address, + Path: vmPath.Path, + }) + s.Require().NoError(err) + s.Require().NotNil(resp) + s.Require().Equal(writeSetData, resp.Value) + } +} diff --git a/x/vm/keeper/grpc_vm_client.go b/x/vm/keeper/grpc_vm_client.go new file mode 100644 index 0000000..f654c2f --- /dev/null +++ b/x/vm/keeper/grpc_vm_client.go @@ -0,0 +1,25 @@ +package keeper + +import ( + "google.golang.org/grpc" + + dvmTypes "github.com/dfinance/dstation/pkg/types/dvm" +) + +// VMClient is an aggregated gRPC VM services client. +type VMClient struct { + dvmTypes.DvmCompilerClient + dvmTypes.DVMBytecodeMetadataClient + dvmTypes.VMModulePublisherClient + dvmTypes.VMScriptExecutorClient +} + +// NewVMClient creates VMClient using gRPC connection. +func NewVMClient(conn *grpc.ClientConn) VMClient { + return VMClient{ + DvmCompilerClient: dvmTypes.NewDvmCompilerClient(conn), + DVMBytecodeMetadataClient: dvmTypes.NewDVMBytecodeMetadataClient(conn), + VMModulePublisherClient: dvmTypes.NewVMModulePublisherClient(conn), + VMScriptExecutorClient: dvmTypes.NewVMScriptExecutorClient(conn), + } +} diff --git a/x/vm/keeper/grpc_vm_retrier.go b/x/vm/keeper/grpc_vm_retrier.go new file mode 100644 index 0000000..b411a16 --- /dev/null +++ b/x/vm/keeper/grpc_vm_retrier.go @@ -0,0 +1,115 @@ +package keeper + +import ( + "context" + "fmt" + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" + + dvmTypes "github.com/dfinance/dstation/pkg/types/dvm" +) + +// VMExecRetryReq contains VM "execution" request meta (request details and retry settings). +type VMExecRetryReq struct { + // Request to retry (module publish). + RawModule *dvmTypes.VMPublishModule + // Request to retry (script execution) + RawScript *dvmTypes.VMExecuteScript + // Max number of request attempts (0 - infinite) + MaxAttempts uint + // Request timeout per attempt (0 - infinite) [ms] + ReqTimeoutInMs uint +} + +// sendExecuteReq sends request with retry mechanism. +func (k Keeper) sendExecuteReq(ctx sdk.Context, moduleReq *dvmTypes.VMPublishModule, scriptReq *dvmTypes.VMExecuteScript) (*dvmTypes.VMExecuteResponse, error) { + if moduleReq == nil && scriptReq == nil { + return nil, fmt.Errorf("request (module / script) not specified") + } + if moduleReq != nil && scriptReq != nil { + return nil, fmt.Errorf("only single request (module / script) is supported") + } + + retryReq := VMExecRetryReq{ + RawModule: moduleReq, + RawScript: scriptReq, + MaxAttempts: k.config.MaxAttempts, + ReqTimeoutInMs: k.config.ReqTimeoutInMs, + } + + return k.retryExecReq(ctx, retryReq) +} + +// retryExecReq sends request with retry mechanism and waits for connection and execution. +// Contract: either RawModule or RawScript must be specified for RetryExecReq. +func (k Keeper) retryExecReq(ctx sdk.Context, req VMExecRetryReq) (retResp *dvmTypes.VMExecuteResponse, retErr error) { + const failedRetryLogPeriod = 100 + + doneCh := make(chan bool) + curAttempt := uint(0) + reqTimeout := time.Duration(req.ReqTimeoutInMs) * time.Millisecond + reqStartedAt := time.Now() + + go func() { + defer func() { + close(doneCh) + }() + + for { + var connCtx context.Context + var connCancel context.CancelFunc + var resp *dvmTypes.VMExecuteResponse + var err error + + curAttempt++ + + connCtx = context.Background() + if reqTimeout > 0 { + connCtx, connCancel = context.WithTimeout(context.Background(), reqTimeout) + } + + curReqStartedAt := time.Now() + if req.RawModule != nil { + resp, err = k.vmClient.VMModulePublisherClient.PublishModule(connCtx, req.RawModule) + } else if req.RawScript != nil { + resp, err = k.vmClient.VMScriptExecutorClient.ExecuteScript(connCtx, req.RawScript) + } + if connCancel != nil { + connCancel() + } + curReqDur := time.Since(curReqStartedAt) + + if err == nil { + retResp, retErr = resp, nil + return + } + + if req.MaxAttempts != 0 && curAttempt == req.MaxAttempts { + retResp, retErr = nil, err + return + } + + if curReqDur < reqTimeout { + time.Sleep(reqTimeout - curReqDur) + } + + if curAttempt%failedRetryLogPeriod == 0 { + msg := fmt.Sprintf("Failing VM request: attempt %d / %d with %v timeout: %v", curAttempt, req.MaxAttempts, reqTimeout, time.Since(reqStartedAt)) + k.Logger(ctx).Info(msg) + } + } + }() + <-doneCh + + reqDur := time.Since(reqStartedAt) + msg := fmt.Sprintf("in %d attempt(s) with %v timeout (%v)", curAttempt, reqTimeout, reqDur) + if retErr == nil { + k.Logger(ctx).Info(fmt.Sprintf("Successfull VM request (%s)", msg)) + } else { + k.Logger(ctx).Error(fmt.Sprintf("Failed VM request (%s): %v", msg, retErr)) + retErr = fmt.Errorf("%s: %w", msg, retErr) + } + + return +} diff --git a/x/vm/keeper/grpc_vm_retrier_test.go b/x/vm/keeper/grpc_vm_retrier_test.go new file mode 100644 index 0000000..f18b83d --- /dev/null +++ b/x/vm/keeper/grpc_vm_retrier_test.go @@ -0,0 +1,160 @@ +package keeper_test + +import ( + "time" + + "github.com/dfinance/dstation/pkg/tests" + dvmTypes "github.com/dfinance/dstation/pkg/types/dvm" + "github.com/dfinance/dstation/x/vm/types" +) + +// nolint:errcheck +func (s *KeeperMockVmTestSuite) TestRetryMechanism() { + // Rollback to defaults + defer func() { + s.app.SetCustomVMRetryParams(0, 0) + s.vmServer.SetResponseDelay(0) + s.vmServer.SetFailCountdown(0) + }() + + accAddr, _, _ := tests.GenAccAddress() + ctx, keeper, vmServer := s.ctx, s.keeper, s.vmServer + + // ok + s.T().Log("OK: in one attempt (infinite settings)") + { + s.app.SetCustomVMRetryParams(0, 0) + + // Build msg + vmResp := &dvmTypes.VMExecuteResponse{GasUsed: 1, Status: &dvmTypes.VMStatus{}} + msg := types.NewMsgDeployModule(accAddr, []byte{0x1}) + + // Request + vmServer.SetResponseDelay(50 * time.Millisecond) + vmServer.SetFailCountdown(0) + vmServer.SetResponse(vmResp) + s.Require().NoError(keeper.DeployContract(ctx, msg)) + } + + // ok + s.T().Log("OK: in one attempt (settings with limit)") + { + s.app.SetCustomVMRetryParams(1, 5000) + + // Build msg + vmResp := &dvmTypes.VMExecuteResponse{GasUsed: 1, Status: &dvmTypes.VMStatus{}} + msg := types.NewMsgDeployModule(accAddr, []byte{0x1}) + + // Request + vmServer.SetResponseDelay(10 * time.Millisecond) + vmServer.SetFailCountdown(0) + vmServer.SetResponse(vmResp) + s.Require().NoError(keeper.DeployContract(ctx, msg)) + } + + // ok + s.T().Log("OK: in one attempt (without request timeout)") + { + s.app.SetCustomVMRetryParams(1, 0) + + // Build msg + vmResp := &dvmTypes.VMExecuteResponse{GasUsed: 1, Status: &dvmTypes.VMStatus{}} + msg := types.NewMsgDeployModule(accAddr, []byte{0x1}) + + // Request + vmServer.SetResponseDelay(500 * time.Millisecond) + vmServer.SetFailCountdown(0) + vmServer.SetResponse(vmResp) + s.Require().NoError(keeper.DeployContract(ctx, msg)) + } + + // ok + s.T().Log("OK: in multiple attempts (with request timeout)") + { + s.app.SetCustomVMRetryParams(10, 50) + + // Build msg + vmResp := &dvmTypes.VMExecuteResponse{GasUsed: 1, Status: &dvmTypes.VMStatus{}} + msg := types.NewMsgDeployModule(accAddr, []byte{0x1}) + + // Request + vmServer.SetResponseDelay(10 * time.Millisecond) + vmServer.SetFailCountdown(5) + vmServer.SetResponse(vmResp) + s.Require().NoError(keeper.DeployContract(ctx, msg)) + } + + // ok + s.T().Log("OK: in multiple attempts (without request timeout)") + { + s.app.SetCustomVMRetryParams(10, 0) + + // Build msg + vmResp := &dvmTypes.VMExecuteResponse{GasUsed: 1, Status: &dvmTypes.VMStatus{}} + msg := types.NewMsgDeployModule(accAddr, []byte{0x1}) + + // Request + vmServer.SetResponseDelay(100 * time.Millisecond) + vmServer.SetFailCountdown(5) + vmServer.SetResponse(vmResp) + s.Require().NoError(keeper.DeployContract(ctx, msg)) + } + + // ok + s.T().Log("OK: in one attempt with long response (without limits)") + { + s.app.SetCustomVMRetryParams(0, 0) + + // Build msg + vmResp := &dvmTypes.VMExecuteResponse{GasUsed: 1, Status: &dvmTypes.VMStatus{}} + msg := types.NewMsgDeployModule(accAddr, []byte{0x1}) + + // Request + vmServer.SetResponseDelay(3000 * time.Millisecond) + vmServer.SetFailCountdown(0) + vmServer.SetResponse(vmResp) + s.Require().NoError(keeper.DeployContract(ctx, msg)) + } + + // fail + s.T().Log("FAIL: by timeout (deadline)") + { + s.app.SetCustomVMRetryParams(5, 30) + + // Build msg + vmResp := &dvmTypes.VMExecuteResponse{GasUsed: 1, Status: &dvmTypes.VMStatus{}} + msg := types.NewMsgDeployModule(accAddr, []byte{0x1}) + + // Request + vmServer.SetResponseDelay(300 * time.Millisecond) + vmServer.SetFailCountdown(0) + vmServer.SetResponse(vmResp) + tests.CheckPanicErrorContains(s.T(), + func() { + keeper.DeployContract(ctx, msg) + }, + "context deadline exceeded", + ) + } + + // fail + s.T().Log("FAIL: by attempts") + { + s.app.SetCustomVMRetryParams(5, 0) + + // Build msg + vmResp := &dvmTypes.VMExecuteResponse{GasUsed: 1, Status: &dvmTypes.VMStatus{}} + msg := types.NewMsgDeployModule(accAddr, []byte{0x1}) + + // Request + vmServer.SetResponseDelay(50 * time.Millisecond) + vmServer.SetFailCountdown(10) + vmServer.SetResponse(vmResp) + tests.CheckPanicErrorContains(s.T(), + func() { + keeper.DeployContract(ctx, msg) + }, + "failing gRPC execution", + ) + } +} diff --git a/x/vm/keeper/keeper.go b/x/vm/keeper/keeper.go new file mode 100644 index 0000000..b693b29 --- /dev/null +++ b/x/vm/keeper/keeper.go @@ -0,0 +1,89 @@ +package keeper + +import ( + "fmt" + "net" + + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/tendermint/tendermint/libs/log" + "google.golang.org/grpc" + + dvmTypes "github.com/dfinance/dstation/pkg/types/dvm" + "github.com/dfinance/dstation/x/vm/config" + "github.com/dfinance/dstation/x/vm/types" +) + +var _ types.VMStorage = (*Keeper)(nil) +var _ types.CurrencyInfoResProvider = (*Keeper)(nil) +var _ types.AccountBalanceResProvider = (*Keeper)(nil) + +// Keeper is a module keeper object. +type Keeper struct { + storeKey sdk.StoreKey + cdc codec.BinaryMarshaler + config *config.VMConfig + // Dependency keepers + accKeeper types.AccountKeeper + bankKeeper types.BankKeeper + // VM connection + vmClient VMClient + vmConn *grpc.ClientConn + // DataSource server + dsServer *DSServer + dsListener net.Listener + // + cache *keeperCache +} + +// keeperCache keeps Keeper cache (Keeper is created by value, so cache should be defined as a pointer) +type keeperCache struct { + currencyInfo map[string]dvmTypes.CurrencyInfo // key: denom +} + +// Logger returns logger with keeper context. +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) +} + +// StartDSServer starts DataSource server. +func (k Keeper) StartDSServer() { + k.dsServer.Start(k.dsListener) +} + +// StopDSServer stops DataSource server. +func (k Keeper) StopDSServer() { + k.dsServer.Stop() +} + +// SetDSContext sets DataSource server context (storage context should be updated periodically to provide actual data). +func (k Keeper) SetDSContext(ctx sdk.Context) { + k.dsServer.SetContext(ctx.WithGasMeter(types.NewDumbGasMeter())) +} + +// NewKeeper create a new Keeper. +func NewKeeper( + cdc codec.BinaryMarshaler, storeKey sdk.StoreKey, + vmConn *grpc.ClientConn, dsListener net.Listener, + config *config.VMConfig, + accKeeper types.AccountKeeper, bankKeeper types.BankKeeper, +) Keeper { + + k := Keeper{ + cdc: cdc, + storeKey: storeKey, + accKeeper: accKeeper, + bankKeeper: bankKeeper, + vmConn: vmConn, + vmClient: NewVMClient(vmConn), + dsListener: dsListener, + config: config, + cache: &keeperCache{ + currencyInfo: make(map[string]dvmTypes.CurrencyInfo), + }, + } + + k.dsServer = NewDSServer(&k, &k, &k) + + return k +} diff --git a/x/vm/keeper/keeper_accbalance_provider.go b/x/vm/keeper/keeper_accbalance_provider.go new file mode 100644 index 0000000..816414f --- /dev/null +++ b/x/vm/keeper/keeper_accbalance_provider.go @@ -0,0 +1,22 @@ +package keeper + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + + dvmTypes "github.com/dfinance/dstation/pkg/types/dvm" + "github.com/dfinance/dstation/x/vm/types" +) + +// GetVmAccountBalance implements types.AccountBalanceResProvider interface. +func (k Keeper) GetVmAccountBalance(ctx sdk.Context, accAddress sdk.AccAddress, denom string) *dvmTypes.U128 { + coinBalance := k.bankKeeper.GetBalance(ctx, accAddress, denom) + + value, err := types.SdkIntToVmU128(coinBalance.Amount) + if err != nil { + panic(fmt.Errorf("converting balance (%s) for denom (%s) to VM U128 мфдгу: %w", coinBalance, denom, err)) + } + + return value +} diff --git a/x/vm/keeper/keeper_ccinfo_provider.go b/x/vm/keeper/keeper_ccinfo_provider.go new file mode 100644 index 0000000..2d3aaa5 --- /dev/null +++ b/x/vm/keeper/keeper_ccinfo_provider.go @@ -0,0 +1,71 @@ +package keeper + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + bankTypes "github.com/cosmos/cosmos-sdk/x/bank/types" + + dvmTypes "github.com/dfinance/dstation/pkg/types/dvm" + "github.com/dfinance/dstation/x/vm/types" +) + +// GetVmCurrencyInfo implements types.CurrencyInfoResProvider interface. +func (k Keeper) GetVmCurrencyInfo(ctx sdk.Context, denom string) *dvmTypes.CurrencyInfo { + // Check if cached + if ccInfo, found := k.cache.currencyInfo[denom]; found { + return k.enrichCurrencyInfoWithTotalSupply(ctx, ccInfo) + } + + // Request from the Bank and cache the value + _, denomUnit, found := k.getDenomMetadataFromBank(ctx, denom) + if !found { + return nil + } + + ccInfo := dvmTypes.CurrencyInfo{ + Denom: []byte(denomUnit.Denom), + Decimals: denomUnit.Exponent, + IsToken: false, + Address: types.StdLibAddress, + TotalSupply: nil, + } + k.cache.currencyInfo[denom] = ccInfo + + return k.enrichCurrencyInfoWithTotalSupply(ctx, ccInfo) +} + +// getDenomMetadataFromBank iterates over Bank denom metadata entries looking for specified denom-unit. +func (k Keeper) getDenomMetadataFromBank(ctx sdk.Context, denom string) (retMeta *bankTypes.Metadata, retUnit *bankTypes.DenomUnit, found bool) { + k.bankKeeper.IterateAllDenomMetaData(ctx, func(metadata bankTypes.Metadata) bool { + for _, unit := range metadata.DenomUnits { + if unit == nil || unit.Denom != denom { + continue + } + + if unit.Denom == denom { + retMeta, retUnit, found = &metadata, unit, true + } + + return true + } + + return false + }) + + return +} + +// enrichCurrencyInfoWithTotalSupply sets the TotalSupply field of dvmTypes.CurrencyInfo. +func (k Keeper) enrichCurrencyInfoWithTotalSupply(ctx sdk.Context, ccInfo dvmTypes.CurrencyInfo) *dvmTypes.CurrencyInfo { + denom := string(ccInfo.Denom) + supply := k.bankKeeper.GetSupply(ctx).GetTotal().AmountOf(denom) + + value, err := types.SdkIntToVmU128(supply) + if err != nil { + panic(fmt.Errorf("converting totalSupply (%s) for denom (%s) to VM U128 type: %w", supply.String(), denom, err)) + } + ccInfo.TotalSupply = value + + return &ccInfo +} diff --git a/x/vm/keeper/keeper_delpool_storage.go b/x/vm/keeper/keeper_delpool_storage.go new file mode 100644 index 0000000..2d8c1c9 --- /dev/null +++ b/x/vm/keeper/keeper_delpool_storage.go @@ -0,0 +1,47 @@ +package keeper + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkErrors "github.com/cosmos/cosmos-sdk/types/errors" + + "github.com/dfinance/dstation/x/vm/types" +) + +// DelegateCoinsToPool transfers coins from an account to the module account (DecPool). +func (k Keeper) DelegateCoinsToPool(ctx sdk.Context, accAddr sdk.AccAddress, coins sdk.Coins) error { + // Validate input + if err := coins.Validate(); err != nil { + return sdkErrors.Wrapf(sdkErrors.ErrInvalidCoins, "coins (%s): invalid: %v", coins, err) + } + + // Transfer + if err := k.bankKeeper.DelegateCoinsFromAccountToModule(ctx, accAddr, types.DelPoolName, coins); err != nil { + return fmt.Errorf("bank operation failed: %w", err) + } + + return nil +} + +// UndelegateCoinsFromPool transfers coins from the module account (DecPool) to an account. +func (k Keeper) UndelegateCoinsFromPool(ctx sdk.Context, accAddr sdk.AccAddress, coins sdk.Coins) error { + // Validate input + if err := coins.Validate(); err != nil { + return sdkErrors.Wrapf(sdkErrors.ErrInvalidCoins, "coins (%s): invalid: %v", coins, err) + } + + // Transfer + if err := k.bankKeeper.UndelegateCoinsFromModuleToAccount(ctx, types.DelPoolName, accAddr, coins); err != nil { + return fmt.Errorf("bank operation failed: %w", err) + } + + return nil +} + +// GetDelegatedPoolSupply returns module account (DecPool) current balance. +func (k Keeper) GetDelegatedPoolSupply(ctx sdk.Context) sdk.Coins { + moduleAcc := k.accKeeper.GetModuleAccount(ctx, types.DelPoolName) + + return k.bankKeeper.GetAllBalances(ctx, moduleAcc.GetAddress()) +} diff --git a/x/vm/keeper/keeper_delpool_storage_test.go b/x/vm/keeper/keeper_delpool_storage_test.go new file mode 100644 index 0000000..b00cb36 --- /dev/null +++ b/x/vm/keeper/keeper_delpool_storage_test.go @@ -0,0 +1,155 @@ +package keeper_test + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/dfinance/dstation/pkg/tests" + "github.com/dfinance/dstation/x/vm/types" +) + +func (s *KeeperMockVmTestSuite) TestDelPoolStorage() { + ctx, accKeeper, bankKeeper, keeper := s.ctx, s.app.DnApp.AccountKeeper, s.app.DnApp.BankKeeper, s.keeper + + accCoins := sdk.NewCoins( + sdk.NewCoin("testa", sdk.NewInt(1000)), + sdk.NewCoin("testb", sdk.NewInt(500)), + ) + acc, _ := s.app.AddAccount(ctx, accCoins...) + + delPoolAcc := accKeeper.GetModuleAccount(ctx, types.DelPoolName) + s.Require().NotNil(delPoolAcc) + delPoolCoins := keeper.GetDelegatedPoolSupply(ctx) + s.Require().True(delPoolCoins.Empty()) + + // fail: DelegateCoinsToPool: validation + { + s.Require().Error( + keeper.DelegateCoinsToPool(ctx, acc.GetAddress(), + sdk.Coins{ + sdk.Coin{ + Denom: "", + Amount: sdk.ZeroInt(), + }, + }, + ), + ) + s.Require().Error( + keeper.DelegateCoinsToPool(ctx, acc.GetAddress(), + sdk.Coins{ + sdk.Coin{ + Denom: "xfi", + Amount: sdk.NewInt(-1), + }, + }, + ), + ) + } + + // fail: DelegateCoinsToPool: insufficient funds + { + s.Require().Error( + keeper.DelegateCoinsToPool(ctx, acc.GetAddress(), + sdk.NewCoins( + sdk.Coin{Denom: accCoins[0].Denom, Amount: accCoins[0].Amount.MulRaw(2)}, + ), + ), + ) + } + + // fail: DelegateCoinsToPool: non-existing account + { + accAddr, _, _ := tests.GenAccAddress() + s.Require().Error(keeper.DelegateCoinsToPool(ctx, accAddr, sdk.NewCoins(sdk.NewCoin("xfi", sdk.NewInt(1))))) + } + + // ok: DelegateCoinsToPool (500testa, 500testb) + { + opCoins := sdk.NewCoins( + sdk.NewCoin(accCoins[0].Denom, accCoins[0].Amount.QuoRaw(2)), + accCoins[1], + ) + s.Require().NoError(keeper.DelegateCoinsToPool(ctx, acc.GetAddress(), opCoins)) + + curDelPoolCoins := bankKeeper.GetAllBalances(ctx, delPoolAcc.GetAddress()) + s.Require().True(delPoolCoins.Add(opCoins...).IsEqual(curDelPoolCoins)) + delPoolCoins = curDelPoolCoins + + curAccCoins := bankKeeper.GetAllBalances(ctx, acc.GetAddress()) + s.Require().True(accCoins.Sub(opCoins).IsEqual(curAccCoins)) + accCoins = curAccCoins + } + + // fail: UndelegateCoinsFromPool: validation + { + s.Require().Error( + keeper.UndelegateCoinsFromPool(ctx, acc.GetAddress(), + sdk.Coins{ + sdk.Coin{ + Denom: "", + Amount: sdk.ZeroInt(), + }, + }, + ), + ) + s.Require().Error( + keeper.UndelegateCoinsFromPool(ctx, acc.GetAddress(), + sdk.Coins{ + sdk.Coin{ + Denom: "xfi", + Amount: sdk.NewInt(-1), + }, + }, + ), + ) + } + + // fail: UndelegateCoinsFromPool: insufficient funds + { + s.Require().Error( + keeper.UndelegateCoinsFromPool(ctx, acc.GetAddress(), + sdk.NewCoins( + sdk.Coin{Denom: delPoolCoins[0].Denom, Amount: delPoolCoins[0].Amount.MulRaw(2)}, + ), + ), + ) + } + + // fail: UndelegateCoinsFromPool: non-existing account + { + accAddr, _, _ := tests.GenAccAddress() + s.Require().Error(keeper.UndelegateCoinsFromPool(ctx, accAddr, sdk.NewCoins(sdk.NewCoin("xfi", sdk.NewInt(1))))) + } + + // ok: UndelegateCoinsFromPool (500testa, 250testb) + { + opCoins := sdk.NewCoins( + delPoolCoins[0], + sdk.NewCoin(delPoolCoins[1].Denom, delPoolCoins[1].Amount.QuoRaw(2)), + ) + s.Require().NoError(keeper.UndelegateCoinsFromPool(ctx, acc.GetAddress(), opCoins)) + + curDelPoolCoins := bankKeeper.GetAllBalances(ctx, delPoolAcc.GetAddress()) + s.Require().True(delPoolCoins.Sub(opCoins).IsEqual(curDelPoolCoins)) + delPoolCoins = curDelPoolCoins + + curAccCoins := bankKeeper.GetAllBalances(ctx, acc.GetAddress()) + s.Require().True(accCoins.Add(opCoins...).IsEqual(curAccCoins)) + accCoins = curAccCoins + } + + // manual check + { + s.Require().True(delPoolCoins.IsEqual( + sdk.NewCoins( + sdk.NewCoin("testb", sdk.NewInt(250)), + ), + )) + + s.Require().True(accCoins.IsEqual( + sdk.NewCoins( + sdk.NewCoin("testa", sdk.NewInt(1000)), + sdk.NewCoin("testb", sdk.NewInt(250)), + ), + )) + } +} diff --git a/x/vm/keeper/keeper_gov_queue.go b/x/vm/keeper/keeper_gov_queue.go new file mode 100644 index 0000000..8e0ade4 --- /dev/null +++ b/x/vm/keeper/keeper_gov_queue.go @@ -0,0 +1,115 @@ +package keeper + +import ( + "fmt" + + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkErrors "github.com/cosmos/cosmos-sdk/types/errors" + + "github.com/dfinance/dstation/x/vm/types" +) + +// ScheduleProposal checks if types.PlannedProposal can be added to the gov proposal queue and adds it. +func (k Keeper) ScheduleProposal(ctx sdk.Context, pProposal *types.PlannedProposal) error { + if pProposal == nil { + return fmt.Errorf("pProposal: nil") + } + + if pProposal.Height <= ctx.BlockHeight() { + return sdkErrors.Wrapf( + sdkErrors.ErrInvalidRequest, + "schedule failed: planned blockHeight (%d) should be LT current (%d)", + pProposal.Height, ctx.BlockHeight()) + } + + k.addProposalToQueue(ctx, pProposal) + + return nil +} + +// RemoveProposalFromQueue removes types.PlannedProposal from the gov proposal queue. +func (k Keeper) RemoveProposalFromQueue(ctx sdk.Context, id uint64) { + store := ctx.KVStore(k.storeKey) + queueStore := prefix.NewStore(store, types.GovQueuePrefix) + key := types.GetGovQueueStorageKey(id) + + queueStore.Delete(key) +} + +// IterateProposalsQueue iterates over gov proposal queue. +func (k Keeper) IterateProposalsQueue(ctx sdk.Context, handler func(id uint64, pProposal *types.PlannedProposal)) { + store := ctx.KVStore(k.storeKey) + queueStore := prefix.NewStore(store, types.GovQueuePrefix) + + iterator := queueStore.Iterator(nil, nil) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + id := types.ParseGovQueueStorageKey(iterator.Key()) + + p, err := k.unmarshalPlannedProposal(iterator.Value()) + if err != nil { + panic(fmt.Errorf("unmarshalPlannedProposal: %w", err)) + } + + handler(id, p) + } +} + +// getNextProposalID returns next gov proposal queue ID. +func (k Keeper) getNextProposalID(ctx sdk.Context) uint64 { + store := ctx.KVStore(k.storeKey) + if !store.Has(types.GovQueueLastIdKey) { + return 0 + } + + bz := store.Get(types.GovQueueLastIdKey) + id := types.ParseGovQueueStorageKey(bz) + + return id + 1 +} + +// setProposalID updates gov proposal queue last ID. +func (k Keeper) setProposalID(ctx sdk.Context, id uint64) { + store := ctx.KVStore(k.storeKey) + + bz := types.GetGovQueueStorageKey(id) + store.Set(types.GovQueueLastIdKey, bz) +} + +// addProposalToQueue adds types.PlannedProposal to the gov proposal queue. +func (k Keeper) addProposalToQueue(ctx sdk.Context, pProposal *types.PlannedProposal) { + store := ctx.KVStore(k.storeKey) + queueStore := prefix.NewStore(store, types.GovQueuePrefix) + + id := k.getNextProposalID(ctx) + key := types.GetGovQueueStorageKey(id) + bz, err := k.marshalPlannedProposal(pProposal) + if err != nil { + panic(fmt.Errorf("marshalPlannedProposal: %w", err)) + } + + queueStore.Set(key, bz) + k.setProposalID(ctx, id) +} + +// marshalPlannedProposal returns binary serialization of types.PlannedProposal. +func (k Keeper) marshalPlannedProposal(pProposal *types.PlannedProposal) ([]byte, error) { + bz, err := k.cdc.MarshalBinaryLengthPrefixed(pProposal) + if err != nil { + return nil, err + } + + return bz, nil +} + +// unmarshalPlannedProposal return deserialized binary serialization of types.PlannedProposal. +func (k Keeper) unmarshalPlannedProposal(bz []byte) (*types.PlannedProposal, error) { + pProposal := &types.PlannedProposal{} + if err := k.cdc.UnmarshalBinaryLengthPrefixed(bz, pProposal); err != nil { + return nil, err + } + + return pProposal, nil +} diff --git a/x/vm/keeper/keeper_gov_queue_test.go b/x/vm/keeper/keeper_gov_queue_test.go new file mode 100644 index 0000000..0763e8c --- /dev/null +++ b/x/vm/keeper/keeper_gov_queue_test.go @@ -0,0 +1,111 @@ +package keeper_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "github.com/dfinance/dstation/x/vm/types" +) + +type proposalInput struct { + id uint64 + proposal *types.PlannedProposal +} + +func (i proposalInput) CheckEqual(t *testing.T, i2 proposalInput) { + require.Equal(t, i.id, i2.id, "input Ids") + require.Equal(t, i.proposal.Height, i2.proposal.Height, "proposal Heights") + require.Equal(t, i.proposal.Content.Value, i2.proposal.Content.Value, "proposal Contents") +} + +func (s *KeeperMockVmTestSuite) TestGovQueue() { + ctx, keeper := s.ctx, s.keeper + + // Skip block (to be sure current is not 0) + s.app.BeginBlock() + s.app.EndBlock() + startBlock, _ := s.app.GetCurrentBlockHeightTime() + + // Create mock proposals + proposalInputs := make([]proposalInput, 0) + { + { + proposal, err := types.NewPlannedProposal( + startBlock+10, + types.NewStdLibUpdateProposal("http://github.com/repo", "test_1", []byte{0x1}), + ) + s.Require().NoError(err) + proposalInputs = append(proposalInputs, proposalInput{ + id: 0, + proposal: proposal, + }) + } + { + proposal, err := types.NewPlannedProposal( + startBlock+10, + types.NewStdLibUpdateProposal("http://github.com/repo", "test_2", []byte{0x2}), + ) + s.Require().NoError(err) + proposalInputs = append(proposalInputs, proposalInput{ + id: 1, + proposal: proposal, + }) + } + { + proposal, err := types.NewPlannedProposal( + startBlock+10, + types.NewStdLibUpdateProposal("http://github.com/repo", "test_3", []byte{0x3}), + ) + s.Require().NoError(err) + proposalInputs = append(proposalInputs, proposalInput{ + id: 2, + proposal: proposal, + }) + } + } + + // fail: ScheduleProposal: proposal from the past + { + proposal, err := types.NewPlannedProposal( + startBlock-1, + types.NewStdLibUpdateProposal("http://github.com/repo", "test_1", []byte{0x1}), + ) + s.Require().NoError(err) + + s.Require().Error(keeper.ScheduleProposal(ctx, proposal)) + } + + // ok: ScheduleProposal + { + for _, input := range proposalInputs { + s.Require().NoError(keeper.ScheduleProposal(ctx, input.proposal)) + } + + proposalOutputs := make([]proposalInput, 0) + keeper.IterateProposalsQueue(ctx, func(id uint64, proposal *types.PlannedProposal) { + proposalOutputs = append(proposalOutputs, proposalInput{id: id, proposal: proposal}) + }) + + s.Require().Len(proposalOutputs, len(proposalInputs)) + for i := 0; i < len(proposalInputs); i++ { + proposalInputs[i].CheckEqual(s.T(), proposalOutputs[i]) + } + } + + // ok: RemoveProposalFromQueue + { + keeper.RemoveProposalFromQueue(ctx, 1) + + proposalInputs = append(proposalInputs[0:1], proposalInputs[2:]...) + proposalOutputs := make([]proposalInput, 0) + keeper.IterateProposalsQueue(ctx, func(id uint64, proposal *types.PlannedProposal) { + proposalOutputs = append(proposalOutputs, proposalInput{id: id, proposal: proposal}) + }) + + s.Require().Len(proposalOutputs, len(proposalInputs)) + for i := 0; i < len(proposalInputs); i++ { + proposalInputs[i].CheckEqual(s.T(), proposalOutputs[i]) + } + } +} diff --git a/x/vm/keeper/keeper_vm_execution.go b/x/vm/keeper/keeper_vm_execution.go new file mode 100644 index 0000000..a8a7a09 --- /dev/null +++ b/x/vm/keeper/keeper_vm_execution.go @@ -0,0 +1,143 @@ +package keeper + +import ( + "fmt" + "strings" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkErrors "github.com/cosmos/cosmos-sdk/types/errors" + + dnTypes "github.com/dfinance/dstation/pkg/types" + dvmTypes "github.com/dfinance/dstation/pkg/types/dvm" + "github.com/dfinance/dstation/x/vm/types" +) + +// ExecuteContract executes Move script and processes execution results (events, writeSets). +func (k Keeper) ExecuteContract(ctx sdk.Context, msg types.MsgExecuteScript) error { + req := types.NewVMExecuteScriptRequest(ctx, msg.Signer, msg.Script, msg.Args...) + + exec, err := k.sendExecuteReq(ctx, nil, req) + if err != nil { + sdkErr := sdkErrors.Wrapf(types.ErrVMCrashed, "grpc error: %v", err) + + k.Logger(ctx).Error(sdkErr.Error()) + panic(sdkErr) + } + + k.processVMExecution(ctx, exec) + + return nil +} + +// DeployContract deploys Move module (contract) and processes execution results (events, writeSets). +func (k Keeper) DeployContract(ctx sdk.Context, msg types.MsgDeployModule) error { + execList := make([]*dvmTypes.VMExecuteResponse, 0, len(msg.Modules)) + for i, code := range msg.Modules { + req := types.NewVMPublishModuleRequests(ctx, msg.Signer, code) + + exec, err := k.sendExecuteReq(ctx, req, nil) + if err != nil { + sdkErr := sdkErrors.Wrapf(types.ErrVMCrashed, "contract [%d]: grpc error: %v", i, err) + + k.Logger(ctx).Error(sdkErr.Error()) + panic(sdkErr) + } + execList = append(execList, exec) + } + + for _, exec := range execList { + k.processVMExecution(ctx, exec) + } + + return nil +} + +// DeployContractDryRun checks that contract can be deployed (returned writeSets are not persisted to store). +func (k Keeper) DeployContractDryRun(ctx sdk.Context, msg types.MsgDeployModule) error { + for i, code := range msg.Modules { + req := types.NewVMPublishModuleRequests(ctx, msg.Signer, code) + + exec, err := k.sendExecuteReq(ctx, req, nil) + if err != nil { + sdkErr := sdkErrors.Wrapf(types.ErrVMCrashed, "contract [%d]: grpc error: %v", i, err) + return sdkErr + } + + if exec.GetStatus().GetError() != nil { + statusMsg := types.StringifyVMStatus(exec.Status) + sdkErr := sdkErrors.Wrapf(types.ErrWrongExecutionResponse, "contract [%d]: %s", i, statusMsg) + return sdkErr + } + } + + return nil +} + +// processVMExecution processes VM execution result: emits events, converts VM events, updates writeSets. +func (k Keeper) processVMExecution(ctx sdk.Context, exec *dvmTypes.VMExecuteResponse) { + // Consume gas (if execution took too much gas - panic and mark transaction as out of gas) + ctx.GasMeter().ConsumeGas(exec.GasUsed, "vm script/module execution") + + // Emit execution events + ctx.EventManager().EmitEvent(dnTypes.NewModuleNameEvent(types.ModuleName)) + ctx.EventManager().EmitEvents(types.NewContractEvents(exec)) + + // Process success status + if exec.GetStatus().GetError() == nil { + k.processVMBalanceChangeSet(ctx, exec.BalanceChangeSet) + k.processVMWriteSet(ctx, exec.WriteSet) + + // Emit VM events (panic on "out of gas", emitted events stays in the EventManager) + for _, vmEvent := range exec.Events { + ctx.EventManager().EmitEvent(types.NewMoveEvent(ctx.GasMeter(), vmEvent)) + } + } +} + +// processVMBalanceChangeSet processes VM native balance changes (delegate / undelegate coins to / from VM). +func (k Keeper) processVMBalanceChangeSet(ctx sdk.Context, changeSet []*dvmTypes.VMBalanceChange) { + for _, value := range changeSet { + if value == nil { + panic(fmt.Errorf("processing account balance changes: nil value received")) + } + + accAddr, err := types.LibraToBech32(value.Address) + if err != nil { + panic(fmt.Errorf("processing account balance changes: converting Libra address (%v) to Bech32: %w", value.Address, err)) + } + denom := strings.ToLower(value.Ticker) + + switch op := value.Op.(type) { + case *dvmTypes.VMBalanceChange_Deposit: + coin := sdk.Coin{Denom: denom, Amount: types.VmU128ToSdkInt(op.Deposit)} + if err := k.DelegateCoinsToPool(ctx, accAddr, sdk.Coins{coin}); err != nil { + panic(fmt.Errorf("processing account balance changes: delegating coin (%s) to account (%s): %w", coin, accAddr, err)) + } + case *dvmTypes.VMBalanceChange_Withdraw: + coin := sdk.Coin{Denom: denom, Amount: types.VmU128ToSdkInt(op.Withdraw)} + if err := k.UndelegateCoinsFromPool(ctx, accAddr, sdk.Coins{coin}); err != nil { + panic(fmt.Errorf("processing account balance changes: undelegating coin (%s) to account (%s): %w", coin, accAddr, err)) + } + default: + panic(fmt.Errorf("processing account balance changes: unsupported change.Op: %T", value.Op)) + } + } +} + +// processVMWriteSet processes VM execution writeSets (set/delete). +func (k Keeper) processVMWriteSet(ctx sdk.Context, writeSet []*dvmTypes.VMValue) { + for _, value := range writeSet { + if value == nil { + panic(fmt.Errorf("processing writeSets: nil value received")) + } + + switch value.Type { + case dvmTypes.VmWriteOp_Value: + k.SetValue(ctx, value.Path, value.Value) + case dvmTypes.VmWriteOp_Deletion: + k.DelValue(ctx, value.Path) + default: + panic(fmt.Errorf("processing writeSets: unsupported writeOp.Type: %d", value.Type)) + } + } +} diff --git a/x/vm/keeper/keeper_vm_execution_test.go b/x/vm/keeper/keeper_vm_execution_test.go new file mode 100644 index 0000000..e24732d --- /dev/null +++ b/x/vm/keeper/keeper_vm_execution_test.go @@ -0,0 +1,403 @@ +package keeper_test + +import ( + "encoding/hex" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/dfinance/dstation/pkg/mock" + "github.com/dfinance/dstation/pkg/tests" + dnTypes "github.com/dfinance/dstation/pkg/types" + dvmTypes "github.com/dfinance/dstation/pkg/types/dvm" + "github.com/dfinance/dstation/x/vm/types" +) + +func (s *KeeperMockVmTestSuite) TestDeployContract() { + ctx, keeper, vmServer := s.ctx, s.keeper, s.vmServer + + // Build msg + accAddr, _, _ := tests.GenAccAddress() + vmResp := &dvmTypes.VMExecuteResponse{ + WriteSet: []*dvmTypes.VMValue{ + { + Type: dvmTypes.VmWriteOp_Value, + Path: &dvmTypes.VMAccessPath{ + Address: types.Bech32ToLibra(accAddr), + Path: mock.GetRandomBytes(mock.VMAddressLength), + }, + Value: mock.GetRandomBytes(512), + }, + }, + Events: nil, + GasUsed: 10000, + Status: &dvmTypes.VMStatus{}, + } + msg := types.NewMsgDeployModule(accAddr, []byte{0x1}) + + // Request + { + vmServer.SetResponse(vmResp) + s.Require().NoError(keeper.DeployContract(ctx, msg)) + } + + // Check events + { + events := ctx.EventManager().Events() + s.Require().Len(events, 2) + + s.Require().EqualValues(sdk.EventTypeMessage, events[0].Type) + s.Require().Len(events[0].Attributes, 1) + s.Require().EqualValues(sdk.AttributeKeyModule, events[0].Attributes[0].Key) + s.Require().EqualValues(types.ModuleName, events[0].Attributes[0].Value) + + s.Require().EqualValues(types.EventTypeContractStatus, events[1].Type) + s.Require().Len(events[1].Attributes, 1) + s.Require().EqualValues(types.AttributeStatus, events[1].Attributes[0].Key) + s.Require().EqualValues(types.AttributeValueStatusKeep, events[1].Attributes[0].Value) + } + + // Check writeSets + { + rcvValue := keeper.GetValue(ctx, vmResp.WriteSet[0].Path) + s.Require().EqualValues(vmResp.WriteSet[0].Value, rcvValue) + } +} + +func (s *KeeperMockVmTestSuite) TestExecuteContract() { + ctx, keeper, vmServer := s.ctx, s.keeper, s.vmServer + + // Build msg + accAddr, _, _ := tests.GenAccAddress() + vmResp := &dvmTypes.VMExecuteResponse{ + WriteSet: []*dvmTypes.VMValue{ + { + Type: dvmTypes.VmWriteOp_Value, + Path: &dvmTypes.VMAccessPath{ + Address: types.Bech32ToLibra(accAddr), + Path: mock.GetRandomBytes(mock.VMAddressLength), + }, + Value: mock.GetRandomBytes(512), + }, + { + Type: dvmTypes.VmWriteOp_Deletion, + Path: &dvmTypes.VMAccessPath{ + Address: types.Bech32ToLibra(accAddr), + Path: mock.GetRandomBytes(mock.VMAddressLength), + }, + Value: mock.GetRandomBytes(256), + }, + }, + Events: []*dvmTypes.VMEvent{ + { + SenderAddress: mock.VMStdLibAddress, + EventType: &dvmTypes.LcsTag{ + TypeTag: dvmTypes.LcsType_LcsU64, + }, + EventData: []byte{0x10}, + }, + }, + GasUsed: 10000, + Status: &dvmTypes.VMStatus{}, + } + msg := types.NewMsgExecuteScript(accAddr, []byte{0x1}) + + // Set writeSet for the next delete writeOp + { + keeper.SetValue(ctx, vmResp.WriteSet[1].Path, vmResp.WriteSet[1].Value) + s.Require().True(keeper.HasValue(ctx, vmResp.WriteSet[1].Path)) + } + + // Request + { + vmServer.SetResponse(vmResp) + s.Require().NoError(keeper.ExecuteContract(ctx, msg)) + } + + // Check events + { + events := ctx.EventManager().Events() + s.Require().Len(events, 3) + + // Module message + s.Require().EqualValues(sdk.EventTypeMessage, events[0].Type) + s.Require().Len(events[0].Attributes, 1) + s.Require().EqualValues(sdk.AttributeKeyModule, events[0].Attributes[0].Key) + s.Require().EqualValues(types.ModuleName, events[0].Attributes[0].Value) + + s.Require().EqualValues(types.EventTypeContractStatus, events[1].Type) + s.Require().Len(events[1].Attributes, 1) + s.Require().EqualValues(types.AttributeStatus, events[1].Attributes[0].Key) + s.Require().EqualValues(types.AttributeValueStatusKeep, events[1].Attributes[0].Value) + + s.Require().EqualValues(types.EventTypeMoveEvent, events[2].Type) + s.Require().Len(events[2].Attributes, 4) + + s.Require().EqualValues(types.AttributeVmEventSender, + events[2].Attributes[0].Key, + ) + s.Require().EqualValues(types.StdLibAddressShortStr, + events[2].Attributes[0].Value, + ) + + s.Require().EqualValues(types.AttributeVmEventSource, + events[2].Attributes[1].Key, + ) + s.Require().EqualValues(types.AttributeValueSourceScript, + events[2].Attributes[1].Value, + ) + + s.Require().EqualValues(types.AttributeVmEventType, + events[2].Attributes[2].Key, + ) + s.Require().EqualValues([]byte("u64"), + events[2].Attributes[2].Value, + ) + + s.Require().EqualValues(types.AttributeVmEventData, + events[2].Attributes[3].Key, + ) + s.Require().EqualValues(hex.EncodeToString(vmResp.Events[0].EventData), + events[2].Attributes[3].Value, + ) + } + + // Check writeSets + { + rcvValue := keeper.GetValue(ctx, vmResp.WriteSet[0].Path) + s.Require().EqualValues(vmResp.WriteSet[0].Value, rcvValue) + + s.Require().False(keeper.HasValue(ctx, vmResp.WriteSet[1].Path)) + } +} + +func (s *KeeperMockVmTestSuite) TestFailedExecution() { + ctx, keeper, vmServer := s.ctx, s.keeper, s.vmServer + + // Status: nil + { + // Build msg + accAddr, _, _ := tests.GenAccAddress() + vmResp := &dvmTypes.VMExecuteResponse{ + WriteSet: nil, + Events: nil, + GasUsed: 10000, + Status: &dvmTypes.VMStatus{}, + } + msg := types.NewMsgExecuteScript(accAddr, []byte{0x1}) + + // Request + ctx := ctx.WithEventManager(sdk.NewEventManager()) + vmServer.SetResponse(vmResp) + s.Require().NoError(keeper.ExecuteContract(ctx, msg)) + + // Check events + events := ctx.EventManager().Events() + s.Require().Len(events, 2) + + s.Require().Equal(dnTypes.NewModuleNameEvent(types.ModuleName), events[0]) + + s.Require().Equal(types.EventTypeContractStatus, events[1].Type) + s.Require().Len(events[1].Attributes, 1) + + s.Require().Equal( + []byte(types.AttributeStatus), + events[1].Attributes[0].Key, + ) + s.Require().Equal( + []byte(types.AttributeValueStatusKeep), + events[1].Attributes[0].Value, + ) + } + + // Status: failure + { + // Build msg + accAddr, _, _ := tests.GenAccAddress() + vmResp := &dvmTypes.VMExecuteResponse{ + WriteSet: nil, + Events: nil, + GasUsed: 10000, + Status: &dvmTypes.VMStatus{ + Error: &dvmTypes.VMStatus_ExecutionFailure{ + ExecutionFailure: &dvmTypes.Failure{ + StatusCode: 100, + }, + }, + Message: &dvmTypes.Message{ + Text: "something went wrong", + }, + }, + } + msg := types.NewMsgExecuteScript(accAddr, []byte{0x1}) + + // Request + ctx := ctx.WithEventManager(sdk.NewEventManager()) + vmServer.SetResponse(vmResp) + s.Require().NoError(keeper.ExecuteContract(ctx, msg)) + + // Check events + events := ctx.EventManager().Events() + s.Require().Len(events, 2) + + s.Require().Equal(dnTypes.NewModuleNameEvent(types.ModuleName), events[0]) + + s.Require().Equal(types.EventTypeContractStatus, events[1].Type) + s.Require().Len(events[1].Attributes, 4) + + s.Require().Equal( + []byte(types.AttributeStatus), + events[1].Attributes[0].Key, + ) + s.Require().Equal( + []byte(types.AttributeValueStatusDiscard), + events[1].Attributes[0].Value, + ) + + s.Require().Equal( + []byte(types.AttributeErrMajorStatus), + events[1].Attributes[1].Key, + ) + s.Require().Equal( + []byte("100"), + events[1].Attributes[1].Value, + ) + + s.Require().Equal( + []byte(types.AttributeErrSubStatus), + events[1].Attributes[2].Key, + ) + s.Require().Equal( + []byte("0"), + events[1].Attributes[2].Value, + ) + + s.Require().Equal( + []byte(types.AttributeErrMessage), + events[1].Attributes[3].Key, + ) + s.Require().Equal( + []byte(vmResp.Status.Message.Text), + events[1].Attributes[3].Value, + ) + } + + // Status: abort + { + // Build msg + accAddr, _, _ := tests.GenAccAddress() + vmResp := &dvmTypes.VMExecuteResponse{ + WriteSet: nil, + Events: nil, + GasUsed: 10000, + Status: &dvmTypes.VMStatus{ + Error: &dvmTypes.VMStatus_Abort{ + Abort: &dvmTypes.Abort{ + AbortCode: 100, + }, + }, + }, + } + msg := types.NewMsgExecuteScript(accAddr, []byte{0x1}) + + // Request + ctx := ctx.WithEventManager(sdk.NewEventManager()) + vmServer.SetResponse(vmResp) + s.Require().NoError(keeper.ExecuteContract(ctx, msg)) + + // Check events + events := ctx.EventManager().Events() + s.Require().Len(events, 2) + + s.Require().Equal(dnTypes.NewModuleNameEvent(types.ModuleName), events[0]) + + s.Require().Equal(types.EventTypeContractStatus, events[1].Type) + s.Require().Len(events[1].Attributes, 3) + + s.Require().Equal( + []byte(types.AttributeStatus), + events[1].Attributes[0].Key, + ) + s.Require().Equal( + []byte(types.AttributeValueStatusDiscard), + events[1].Attributes[0].Value, + ) + + s.Require().Equal( + []byte(types.AttributeErrMajorStatus), + events[1].Attributes[1].Key, + ) + s.Require().Equal( + []byte("4016"), + events[1].Attributes[1].Value, + ) + + s.Require().Equal( + []byte(types.AttributeErrSubStatus), + events[1].Attributes[2].Key, + ) + s.Require().Equal( + []byte("100"), + events[1].Attributes[2].Value, + ) + } + + // Status: move error + { + // Build msg + accAddr, _, _ := tests.GenAccAddress() + vmResp := &dvmTypes.VMExecuteResponse{ + WriteSet: nil, + Events: nil, + GasUsed: 10000, + Status: &dvmTypes.VMStatus{ + Error: &dvmTypes.VMStatus_MoveError{ + MoveError: &dvmTypes.MoveError{ + StatusCode: 100, + }, + }, + }, + } + msg := types.NewMsgExecuteScript(accAddr, []byte{0x1}) + + // Request + ctx := ctx.WithEventManager(sdk.NewEventManager()) + vmServer.SetResponse(vmResp) + s.Require().NoError(keeper.ExecuteContract(ctx, msg)) + + // Check events + events := ctx.EventManager().Events() + s.Require().Len(events, 2) + + s.Require().Equal(dnTypes.NewModuleNameEvent(types.ModuleName), events[0]) + + s.Require().Equal(types.EventTypeContractStatus, events[1].Type) + s.Require().Len(events[1].Attributes, 3) + + s.Require().Equal( + []byte(types.AttributeStatus), + events[1].Attributes[0].Key, + ) + s.Require().Equal( + []byte(types.AttributeValueStatusDiscard), + events[1].Attributes[0].Value, + ) + + s.Require().Equal( + []byte(types.AttributeErrMajorStatus), + events[1].Attributes[1].Key, + ) + s.Require().Equal( + []byte("100"), + events[1].Attributes[1].Value, + ) + + s.Require().Equal( + []byte(types.AttributeErrSubStatus), + events[1].Attributes[2].Key, + ) + s.Require().Equal( + []byte("0"), + events[1].Attributes[2].Value, + ) + } +} diff --git a/x/vm/keeper/keeper_vm_storage.go b/x/vm/keeper/keeper_vm_storage.go new file mode 100644 index 0000000..e93051f --- /dev/null +++ b/x/vm/keeper/keeper_vm_storage.go @@ -0,0 +1,63 @@ +package keeper + +import ( + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + + dvmTypes "github.com/dfinance/dstation/pkg/types/dvm" + "github.com/dfinance/dstation/x/vm/types" +) + +// HasValue implements types.VMStorage interface. +func (k Keeper) HasValue(ctx sdk.Context, accessPath *dvmTypes.VMAccessPath) bool { + store := ctx.KVStore(k.storeKey) + vmStore := prefix.NewStore(store, types.VMKeyPrefix) + key := types.GetVMStorageKey(accessPath) + + return vmStore.Has(key) +} + +// GetValue implements types.VMStorage interface. +func (k Keeper) GetValue(ctx sdk.Context, accessPath *dvmTypes.VMAccessPath) []byte { + store := ctx.KVStore(k.storeKey) + vmStore := prefix.NewStore(store, types.VMKeyPrefix) + key := types.GetVMStorageKey(accessPath) + + return vmStore.Get(key) +} + +// SetValue implements types.VMStorage interface. +func (k Keeper) SetValue(ctx sdk.Context, accessPath *dvmTypes.VMAccessPath, value []byte) { + store := ctx.KVStore(k.storeKey) + vmStore := prefix.NewStore(store, types.VMKeyPrefix) + key := types.GetVMStorageKey(accessPath) + + vmStore.Set(key, value) +} + +// DelValue implements types.VMStorage interface. +func (k Keeper) DelValue(ctx sdk.Context, accessPath *dvmTypes.VMAccessPath) { + store := ctx.KVStore(k.storeKey) + vmStore := prefix.NewStore(store, types.VMKeyPrefix) + key := types.GetVMStorageKey(accessPath) + + vmStore.Delete(key) +} + +// iterateVMStorageValues iterates over all VMStorage values and processes them with handler (stop when handler returns true). +func (k Keeper) iterateVMStorageValues(ctx sdk.Context, handler func(accessPath *dvmTypes.VMAccessPath, value []byte) bool) { + store := ctx.KVStore(k.storeKey) + vmStore := prefix.NewStore(store, types.VMKeyPrefix) + + iterator := vmStore.Iterator(nil, nil) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + accessPath := types.MustParseVMStorageKey(iterator.Key()) + value := iterator.Value() + + if handler(accessPath, value) { + break + } + } +} diff --git a/x/vm/keeper/keeper_vm_storage_test.go b/x/vm/keeper/keeper_vm_storage_test.go new file mode 100644 index 0000000..2caf767 --- /dev/null +++ b/x/vm/keeper/keeper_vm_storage_test.go @@ -0,0 +1,33 @@ +package keeper_test + +import ( + "github.com/dfinance/dstation/pkg/mock" +) + +func (s *KeeperMockVmTestSuite) TestVMStorage() { + ctx, keeper := s.ctx, s.keeper + vmPath, writeSetData := mock.GetRandomVMAccessPath(), mock.GetRandomBytes(12) + + // ok: HasValue, GetValue: non-existing + { + s.Require().False(keeper.HasValue(ctx, vmPath)) + s.Require().Nil(keeper.GetValue(ctx, vmPath)) + } + + // ok: SetValue + { + keeper.SetValue(ctx, vmPath, writeSetData) + + s.Require().True(keeper.HasValue(ctx, vmPath)) + s.Require().NotNil(keeper.GetValue(ctx, vmPath)) + s.Require().Equal(writeSetData, keeper.GetValue(ctx, vmPath)) + } + + // ok: DelValue + { + keeper.DelValue(ctx, vmPath) + + s.Require().False(keeper.HasValue(ctx, vmPath)) + s.Require().Nil(keeper.GetValue(ctx, vmPath)) + } +} diff --git a/x/vm/keeper/msg_server.go b/x/vm/keeper/msg_server.go new file mode 100644 index 0000000..9ded59d --- /dev/null +++ b/x/vm/keeper/msg_server.go @@ -0,0 +1,49 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + "github.com/dfinance/dstation/x/vm/types" +) + +var _ types.MsgServer = msgServer{} + +type msgServer struct { + Keeper +} + +// NewMsgServerImpl returns an implementation of the bank MsgServer interface +// for the provided Keeper. +func NewMsgServerImpl(keeper Keeper) types.MsgServer { + return &msgServer{Keeper: keeper} +} + +func (k msgServer) DeployModule(c context.Context, msg *types.MsgDeployModule) (*types.MsgDeployModuleResponse, error) { + if msg == nil { + return nil, status.Error(codes.InvalidArgument, "empty msg") + } + + ctx := sdk.UnwrapSDKContext(c) + if err := k.DeployContract(ctx, *msg); err != nil { + return nil, err + } + + return &types.MsgDeployModuleResponse{}, nil +} + +func (k msgServer) ExecuteScript(c context.Context, msg *types.MsgExecuteScript) (*types.MsgExecuteScriptResponse, error) { + if msg == nil { + return nil, status.Error(codes.InvalidArgument, "empty msg") + } + + ctx := sdk.UnwrapSDKContext(c) + if err := k.ExecuteContract(ctx, *msg); err != nil { + return nil, err + } + + return &types.MsgExecuteScriptResponse{}, nil +} diff --git a/x/vm/module.go b/x/vm/module.go new file mode 100644 index 0000000..2147da2 --- /dev/null +++ b/x/vm/module.go @@ -0,0 +1,164 @@ +// Module provides DVM integration with Move script/module execution/deployment. +// VMStorage is used for writeSets (VM execution results, Move resources) storage. +// DataSource server is a gRPC server for dnode-dvm async communication (DS context is updated during the BeginBlock). +// Module support DVM stdlib update proposal updates corresponding writeSets. +package vm + +import ( + "context" + "encoding/json" + "fmt" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + cdcTypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + "github.com/gorilla/mux" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + abci "github.com/tendermint/tendermint/abci/types" + + "github.com/dfinance/dstation/x/vm/client/cli" + "github.com/dfinance/dstation/x/vm/keeper" + "github.com/dfinance/dstation/x/vm/types" +) + +var _ module.AppModuleBasic = AppModuleBasic{} + +// AppModuleBasic defines the basic application module used by the VM module. +type AppModuleBasic struct { + cdc codec.Marshaler +} + +// Name returns the module's name. +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +// RegisterLegacyAminoCodec registers the staking module's types on the given LegacyAmino codec. +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterLegacyAminoCodec(cdc) +} + +// RegisterInterfaces registers the module's interface types +func (b AppModuleBasic) RegisterInterfaces(registry cdcTypes.InterfaceRegistry) { + types.RegisterInterfaces(registry) +} + +// DefaultGenesis returns default genesis state as raw bytes for the staking +// module. +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONMarshaler) json.RawMessage { + genState := types.DefaultGenesisState() + return cdc.MustMarshalJSON(&genState) +} + +// ValidateGenesis performs genesis state validation for the staking module. +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONMarshaler, config client.TxEncodingConfig, bz json.RawMessage) error { + var genState types.GenesisState + if err := cdc.UnmarshalJSON(bz, &genState); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + } + + return genState.Validate() +} + +// RegisterRESTRoutes registers the REST routes for the staking module. +func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) { + //rest.RegisterHandlers(clientCtx, rtr) +} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the staking module. +// nolint:errcheck +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) +} + +// GetTxCmd returns the root tx command for the staking module. +func (AppModuleBasic) GetTxCmd() *cobra.Command { + return cli.GetTxCmd() +} + +// GetQueryCmd returns no root query command for the staking module. +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd() +} + +// AppModule implements an application module for the staking module. +type AppModule struct { + AppModuleBasic + + keeper keeper.Keeper + accountKeeper types.AccountKeeper + bankKeeper types.BankKeeper +} + +// NewAppModule creates a new AppModule object +func NewAppModule(cdc codec.Marshaler, keeper keeper.Keeper, ak types.AccountKeeper, bk types.BankKeeper) AppModule { + return AppModule{ + AppModuleBasic: AppModuleBasic{cdc: cdc}, + keeper: keeper, + accountKeeper: ak, + bankKeeper: bk, + } +} + +// Name returns the staking module's name. +func (AppModule) Name() string { + return types.ModuleName +} + +// RegisterInvariants registers the staking module invariants. +func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {} + +// Route returns the message routing key for the staking module. +func (am AppModule) Route() sdk.Route { + return sdk.NewRoute(types.RouterKey, NewHandler(am.keeper)) +} + +// QuerierRoute returns the staking module's querier route name. +func (AppModule) QuerierRoute() string { + return types.QuerierRoute +} + +// LegacyQuerierHandler returns the staking module sdk.Querier. +func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { + return nil +} + +// RegisterServices registers module services. +func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) + querier := keeper.Querier{Keeper: am.keeper} + types.RegisterQueryServer(cfg.QueryServer(), querier) +} + +// InitGenesis performs genesis initialization for the staking module. It returns +// no validator updates. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONMarshaler, data json.RawMessage) []abci.ValidatorUpdate { + var genState types.GenesisState + cdc.MustUnmarshalJSON(data, &genState) + + am.keeper.InitGenesis(ctx, &genState) + + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the exported genesis state as raw bytes for the staking +// module. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONMarshaler) json.RawMessage { + genState := am.keeper.ExportGenesis(ctx) + + return cdc.MustMarshalJSON(genState) +} + +// BeginBlock returns the begin blocker for the staking module. +func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { + BeginBlocker(ctx, am.keeper) +} + +// EndBlock returns the end blocker for the staking module. It returns no validator +// updates. +func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + return []abci.ValidatorUpdate{} +} diff --git a/x/vm/move/event_type_serialization/basic/module.move b/x/vm/move/event_type_serialization/basic/module.move new file mode 100644 index 0000000..5cc21b7 --- /dev/null +++ b/x/vm/move/event_type_serialization/basic/module.move @@ -0,0 +1,18 @@ +// Module creates FooEvent which emits some event. +module Foo { + struct FooEvent { + field_T: T, + field_VT: VT + } + + public fun NewFooEvent(account: &signer, arg_T: T, arg_VT: VT): FooEvent { + let fooEvent = FooEvent { + field_T: arg_T, + field_VT: arg_VT + }; + + 0x1::Event::emit(account, true); + + fooEvent + } +} \ No newline at end of file diff --git a/x/vm/move/event_type_serialization/basic/script.template.move b/x/vm/move/event_type_serialization/basic/script.template.move new file mode 100644 index 0000000..927c4e2 --- /dev/null +++ b/x/vm/move/event_type_serialization/basic/script.template.move @@ -0,0 +1,18 @@ +// Script emits various events (including the one from the Foo module. +script { + use %s::Foo; + + fun main(account: &signer) { + // Event with single tag + 0x1::Event::emit(account, 128); + + // Event with single vector + 0x1::Event::emit>(account, x"0102"); + + // Two events: + // 1. Module: single tag + // 2. Script: generic struct with tag, vector + let fooEvent = Foo::NewFooEvent>(account, 1000, x"0102"); + 0x1::Event::emit>>(account, fooEvent); + } +} \ No newline at end of file diff --git a/x/vm/move/event_type_serialization/gas_calculation/module.move b/x/vm/move/event_type_serialization/gas_calculation/module.move new file mode 100644 index 0000000..6fc43b1 --- /dev/null +++ b/x/vm/move/event_type_serialization/gas_calculation/module.move @@ -0,0 +1,39 @@ +// Module emits complex events with 4-deep nested struct. +module GasEvent { + struct A { + value: u64 + } + + struct B { + value: T + } + + struct C { + value: T + } + + struct D { + value: T + } + + public fun test(account: &signer) { + let a = A { + value: 10 + }; + + let b = B { + value: a + }; + + let c = C> { + value: b + }; + + let d = D>> { + value: c + }; + + 0x1::Event::emit>>>(account, d); + } + +} \ No newline at end of file diff --git a/x/vm/move/event_type_serialization/gas_calculation/script.template.move b/x/vm/move/event_type_serialization/gas_calculation/script.template.move new file mode 100644 index 0000000..8a39d00 --- /dev/null +++ b/x/vm/move/event_type_serialization/gas_calculation/script.template.move @@ -0,0 +1,8 @@ +// Script triggers GasEvent module function. +script { + use %s::GasEvent; + + fun main(account: &signer) { + GasEvent::test(account); + } +} \ No newline at end of file diff --git a/x/vm/move/event_type_serialization/gas_limit/module.move b/x/vm/move/event_type_serialization/gas_limit/module.move new file mode 100644 index 0000000..47d3392 --- /dev/null +++ b/x/vm/move/event_type_serialization/gas_limit/module.move @@ -0,0 +1,55 @@ +// Module emits complex events with 6-deep nested struct and should fail with "out-of-gas". +module OutOfGasEvent { + struct A { + value: u64 + } + + struct B { + value: T + } + + struct C { + value: T + } + + struct Z { + value: T + } + + struct V { + value: T + } + + struct M { + value: T + } + + public fun test(account: &signer) { + let a = A { + value: 10 + }; + + let b = B { + value: a + }; + + let c = C> { + value: b + }; + + let z = Z>> { + value: c + }; + + let v = V>>> { + value: z + }; + + let m = M>>>> { + value: v + }; + + 0x1::Event::emit>>>>>(account, m); + } + +} \ No newline at end of file diff --git a/x/vm/move/event_type_serialization/gas_limit/script.template.move b/x/vm/move/event_type_serialization/gas_limit/script.template.move new file mode 100644 index 0000000..97673a7 --- /dev/null +++ b/x/vm/move/event_type_serialization/gas_limit/script.template.move @@ -0,0 +1,8 @@ +// Script triggers OutOfGasEvent module function. +script { + use %s::OutOfGasEvent; + + fun main(account: &signer) { + OutOfGasEvent::test(account); + } +} \ No newline at end of file diff --git a/x/vm/move/gov/module_v1.move b/x/vm/move/gov/module_v1.move new file mode 100644 index 0000000..d63b32c --- /dev/null +++ b/x/vm/move/gov/module_v1.move @@ -0,0 +1,8 @@ +// Generic StdLib Move module which contains an error. +address 0x1 { + module StdMath { + public fun inc(v: u64): u64 { + v + } + } +} \ No newline at end of file diff --git a/x/vm/move/gov/module_v2.move b/x/vm/move/gov/module_v2.move new file mode 100644 index 0000000..ddde09a --- /dev/null +++ b/x/vm/move/gov/module_v2.move @@ -0,0 +1,8 @@ +// Generic StdLib Move module with a fix. +address 0x1 { + module StdMath { + public fun inc(v: u64): u64 { + v + 1 + } + } +} \ No newline at end of file diff --git a/x/vm/move/gov/script.move b/x/vm/move/gov/script.move new file mode 100644 index 0000000..9295776 --- /dev/null +++ b/x/vm/move/gov/script.move @@ -0,0 +1,10 @@ +// Script triggers StdMath module inc function. +script { + use 0x1::StdMath; + + fun main(account: &signer, v: u64) { + let res = StdMath::inc(v); + + 0x1::Event::emit(account, res); + } +} \ No newline at end of file diff --git a/x/vm/move/math/module.move b/x/vm/move/math/module.move new file mode 100644 index 0000000..56bd46c --- /dev/null +++ b/x/vm/move/math/module.move @@ -0,0 +1,6 @@ +// Generic Move module. +module Math { + public fun add(a: u64, b: u64): u64 { + a + b + } +} \ No newline at end of file diff --git a/x/vm/move/math/module_addr_wrapped.template.move b/x/vm/move/math/module_addr_wrapped.template.move new file mode 100644 index 0000000..15b312f --- /dev/null +++ b/x/vm/move/math/module_addr_wrapped.template.move @@ -0,0 +1,8 @@ +// Generic Move module. +address %s { + module Math { + public fun add(a: u64, b: u64): u64 { + a + b + } + } +} \ No newline at end of file diff --git a/x/vm/move/math/module_quad.move b/x/vm/move/math/module_quad.move new file mode 100644 index 0000000..9d3f84c --- /dev/null +++ b/x/vm/move/math/module_quad.move @@ -0,0 +1,25 @@ +// File contains multiple Move modules (this is OK). + +module DblMathAdd { + public fun add(a: u64, b: u64): u64 { + a + b + } +} + +module DblMathSub { + public fun sub(a: u64, b: u64): u64 { + a - b + } +} + +module DblMathMul { + public fun sub(a: u64, b: u64): u64 { + a * b + } +} + +module DblMathQuo { + public fun sub(a: u64, b: u64): u64 { + a / b + } +} \ No newline at end of file diff --git a/x/vm/move/math/script.template.move b/x/vm/move/math/script.template.move new file mode 100644 index 0000000..085f4be --- /dev/null +++ b/x/vm/move/math/script.template.move @@ -0,0 +1,9 @@ +script { + use 0x1::Event; + use %s::Math; + + fun main(account: &signer, a: u64, b: u64) { + let c = Math::add(a, b); + Event::emit(account, c); + } +} \ No newline at end of file diff --git a/x/vm/move/math/script_double.template.move b/x/vm/move/math/script_double.template.move new file mode 100644 index 0000000..5fe706d --- /dev/null +++ b/x/vm/move/math/script_double.template.move @@ -0,0 +1,26 @@ +// File contains multiple scripts (this is OK). +// Execution should be performed one by one OR withing single Tx (separate Messages). + +script { + use 0x1::Event; + use %s::DblMathAdd; + use %s::DblMathSub; + + fun main(account: &signer, a: u64, b: u64, c: u64) { + let ab = DblMathAdd::add(a, b); + let res = DblMathSub::sub(ab, c); + Event::emit(account, res); + } +} + +script { + use 0x1::Event; + use %s::DblMathAdd; + use %s::DblMathSub; + + fun main(account: &signer, a: u64, b: u64, c: u64) { + let ab = DblMathSub::sub(a, b); + let res = DblMathAdd::add(ab, c); + Event::emit(account, res); + } +} \ No newline at end of file diff --git a/x/vm/move/module_script.move b/x/vm/move/module_script.move new file mode 100644 index 0000000..0d16465 --- /dev/null +++ b/x/vm/move/module_script.move @@ -0,0 +1,14 @@ +module MixedModule { + public fun add(a: u64, b: u64): u64 { + a + b + } +} + +script { + use 0x1::Event; + + fun main(account: &signer, a: u64, b: u64) { + let c = a + b; + Event::emit(account, c); + } +} \ No newline at end of file diff --git a/x/vm/move/modules/with_resources.move b/x/vm/move/modules/with_resources.move new file mode 100644 index 0000000..044a8ca --- /dev/null +++ b/x/vm/move/modules/with_resources.move @@ -0,0 +1,20 @@ +// Generic module with resources. +address 0x1 { + module Foo { + resource struct U64 {val: u64} + resource struct Obj {val: u64, o: U64} + + public fun add(sender: &signer, a: u64, b: u64): u64 { + let sum = a + b; + let value = U64 {val: sum}; + move_to(sender, value); + sum + } + + public fun build_obj(sender: &signer, a: u64) { + let u64val = U64 {val: a}; + let value = Obj {val: a, o: u64val}; + move_to(sender, value); + } + } +} \ No newline at end of file diff --git a/x/vm/move/scripts/arg_types.move b/x/vm/move/scripts/arg_types.move new file mode 100644 index 0000000..1c918c9 --- /dev/null +++ b/x/vm/move/scripts/arg_types.move @@ -0,0 +1,19 @@ +// Script excepts all arg types and asserts them. +script { + use 0x1::Vector; + + fun main(account: &signer, arg_u8: u8, arg_u64: u64, arg_u128: u128, arg_addr: address, arg_bool_true: bool, arg_bool_false: bool, arg_vector: vector) { + assert(arg_u8 == 128, 10); + assert(arg_u64 == 1000000, 11); + assert(arg_u128 == 100000000000000000000000000000, 12); + + assert(0x1::Signer::address_of(account) == arg_addr, 20); + + assert(arg_bool_true == true, 30); + assert(arg_bool_false == false, 31); + + assert(Vector::length(&mut arg_vector) == 2, 40); + assert(Vector::pop_back(&mut arg_vector) == 1, 41); + assert(Vector::pop_back(&mut arg_vector) == 0, 42); + } +} \ No newline at end of file diff --git a/x/vm/move/scripts/block_height_time.move b/x/vm/move/scripts/block_height_time.move new file mode 100644 index 0000000..7015795 --- /dev/null +++ b/x/vm/move/scripts/block_height_time.move @@ -0,0 +1,13 @@ +// Script receives current block time and height. +script { + use 0x1::Block; + use 0x1::Time; + + fun main(_account: &signer, sdk_block: u64, sdk_time: u64) { + let native_block = Block::get_current_block_height(); + let native_time = Time::now(); + + assert(native_block == sdk_block, 1); + assert(native_time == sdk_time, 2); + } +} \ No newline at end of file diff --git a/x/vm/move/scripts/currency_infos.move b/x/vm/move/scripts/currency_infos.move new file mode 100644 index 0000000..d86af8b --- /dev/null +++ b/x/vm/move/scripts/currency_infos.move @@ -0,0 +1,13 @@ +// Script requests multiple CurrencyInfo resources and asserts their decimals. +script { + use 0x1::Dfinance; + use 0x1::XFI; + use 0x1::Coins; + + fun main(_account: &signer, xfi_decimals: u8, eth_decimals: u8, btc_decimals: u8, usdt_decimals: u8) { + assert(Dfinance::decimals() == xfi_decimals, 1); + assert(Dfinance::decimals() == eth_decimals, 2); + assert(Dfinance::decimals() == btc_decimals, 3); + assert(Dfinance::decimals() == usdt_decimals, 4); + } +} \ No newline at end of file diff --git a/x/vm/move/scripts/native_balance.move b/x/vm/move/scripts/native_balance.move new file mode 100644 index 0000000..c10136c --- /dev/null +++ b/x/vm/move/scripts/native_balance.move @@ -0,0 +1,13 @@ +script { + use 0x1::Account; + use 0x1::XFI; + use 0x1::Event; + + fun main(account: &signer, sdk_balance: u128) { + let move_balance = Account::get_native_balance(account); + + Event::emit(account, move_balance); + Event::emit(account, sdk_balance); + assert(move_balance == sdk_balance, 1); + } +} \ No newline at end of file diff --git a/x/vm/move/scripts/native_deposit.move b/x/vm/move/scripts/native_deposit.move new file mode 100644 index 0000000..39e50ec --- /dev/null +++ b/x/vm/move/scripts/native_deposit.move @@ -0,0 +1,13 @@ +// Script performs the SDK->VM coin transfer and deposits it the VM resource. +script { + use 0x1::Account; + use 0x1::Dfinance; + use 0x1::XFI; + + fun main(account: &signer, amount: u128) { + let token = Account::deposit_native(account, amount); + assert(Dfinance::value(&token) == amount, 1); + + Account::deposit_to_sender(account, token); + } +} \ No newline at end of file diff --git a/x/vm/move/scripts/native_withdraw.move b/x/vm/move/scripts/native_withdraw.move new file mode 100644 index 0000000..5f47d51 --- /dev/null +++ b/x/vm/move/scripts/native_withdraw.move @@ -0,0 +1,13 @@ +// Script withdraws balance from the VM resource and performs the VM->SDK transfer. +script { + use 0x1::Account; + use 0x1::Dfinance; + use 0x1::XFI; + + fun main(account: &signer, amount: u128) { + let token = Account::withdraw_from_sender(account, amount); + assert(Dfinance::value(&token) == amount, 1); + + Account::withdraw_native(account, token); + } +} \ No newline at end of file diff --git a/x/vm/move/scripts/oracle_price_direct.move b/x/vm/move/scripts/oracle_price_direct.move new file mode 100644 index 0000000..7a8c382 --- /dev/null +++ b/x/vm/move/scripts/oracle_price_direct.move @@ -0,0 +1,8 @@ +script { + use 0x1::Coins; + + fun main(_account: &signer, sdk_price: u128) { + let native_price = Coins::get_price(); + assert(native_price == sdk_price, 1); + } +} \ No newline at end of file diff --git a/x/vm/move/scripts/transfer_receive.move b/x/vm/move/scripts/transfer_receive.move new file mode 100644 index 0000000..093de30 --- /dev/null +++ b/x/vm/move/scripts/transfer_receive.move @@ -0,0 +1,20 @@ +// Scripts withdraws signer coins from VM to SDK. +script { + use 0x1::Account; + use 0x1::XFI; + use 0x1::Coins; + + fun main(account: &signer, xfi_amount: u128, eth_amount: u128, btc_amount: u128, usdt_amount: u128) { + // Acquire tokens from resource + let xfi_token = Account::withdraw_from_sender(account, xfi_amount); + let eth_token = Account::withdraw_from_sender(account, eth_amount); + let btc_token = Account::withdraw_from_sender(account, btc_amount); + let usdt_token = Account::withdraw_from_sender(account, usdt_amount); + + // Witdraw signer coins + Account::withdraw_native(account, xfi_token); + Account::withdraw_native(account, eth_token); + Account::withdraw_native(account, btc_token); + Account::withdraw_native(account, usdt_token); + } +} \ No newline at end of file diff --git a/x/vm/move/scripts/transfer_send.move b/x/vm/move/scripts/transfer_send.move new file mode 100644 index 0000000..a337d19 --- /dev/null +++ b/x/vm/move/scripts/transfer_send.move @@ -0,0 +1,27 @@ +// Scripts deposits signer coins from SDK to VM and send them to the recepient. +script { + use 0x1::Account; + use 0x1::XFI; + use 0x1::Coins; + + fun main(account: &signer, recipient: address, xfi_amount: u128, eth_amount: u128, btc_amount: u128, usdt_amount: u128) { + // Deposit signer coins + let xfi_token = Account::deposit_native(account, xfi_amount); + Account::deposit_to_sender(account, xfi_token); + + let eth_token = Account::deposit_native(account, eth_amount); + Account::deposit_to_sender(account, eth_token); + + let btc_token = Account::deposit_native(account, btc_amount); + Account::deposit_to_sender(account, btc_token); + + let usdt_token = Account::deposit_native(account, usdt_amount); + Account::deposit_to_sender(account, usdt_token); + + // Transfer to recipient resource + Account::pay_from_sender(account, recipient, xfi_amount); + Account::pay_from_sender(account, recipient, eth_amount); + Account::pay_from_sender(account, recipient, btc_amount); + Account::pay_from_sender(account, recipient, usdt_amount); + } +} \ No newline at end of file diff --git a/x/vm/move/scripts/with_error.move b/x/vm/move/scripts/with_error.move new file mode 100644 index 0000000..71cce4c --- /dev/null +++ b/x/vm/move/scripts/with_error.move @@ -0,0 +1,6 @@ +// Script performs a simple assert. +script { + fun main(_account: &signer, value: u64) { + assert(value == 1000, 1); + } +} \ No newline at end of file diff --git a/x/vm/types/codec.go b/x/vm/types/codec.go new file mode 100644 index 0000000..31b4ae4 --- /dev/null +++ b/x/vm/types/codec.go @@ -0,0 +1,51 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/types" + cryptoCodec "github.com/cosmos/cosmos-sdk/crypto/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" + govTypes "github.com/cosmos/cosmos-sdk/x/gov/types" +) + +// RegisterLegacyAminoCodec registers the necessary x/staking interfaces and concrete types +// on the provided LegacyAmino codec. These types are used for Amino JSON serialization. +func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + cdc.RegisterConcrete(&MsgExecuteScript{}, ModuleName+"/MsgExecuteScript", nil) + cdc.RegisterConcrete(&MsgDeployModule{}, ModuleName+"/MsgDeployModule", nil) + cdc.RegisterConcrete(&PlannedProposal{}, ModuleName+"/PlannedProposal", nil) + cdc.RegisterConcrete(&StdLibUpdateProposal{}, ModuleName+"/StdLibUpdateProposal", nil) +} + +// RegisterInterfaces registers the x/staking interfaces types with the interface registry +func RegisterInterfaces(registry types.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgExecuteScript{}, + &MsgDeployModule{}, + ) + registry.RegisterImplementations((*govTypes.Content)(nil), + &PlannedProposal{}, + &StdLibUpdateProposal{}, + ) + + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} + +var ( + amino = codec.NewLegacyAmino() + + // ModuleCdc references the global x/staking module codec. Note, the codec should + // ONLY be used in certain instances of tests and for JSON encoding as Amino is + // still used for that purpose. + // + // The actual codec used for serialization should be provided to x/staking and + // defined at the application level. + ModuleCdc = codec.NewAminoCodec(amino) +) + +func init() { + RegisterLegacyAminoCodec(amino) + cryptoCodec.RegisterCrypto(amino) + amino.Seal() +} diff --git a/x/vm/types/dumbgasmeter.go b/x/vm/types/dumbgasmeter.go new file mode 100644 index 0000000..860134f --- /dev/null +++ b/x/vm/types/dumbgasmeter.go @@ -0,0 +1,39 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// DumbGasMeter is a sdk.GasMeter implementation that doesn't count amount of gas during usage. +type DumbGasMeter struct{} + +func (g DumbGasMeter) GasConsumed() sdk.Gas { + return 0 +} + +func (g DumbGasMeter) Limit() sdk.Gas { + return 0 +} + +func (g DumbGasMeter) GasConsumedToLimit() sdk.Gas { + return 0 +} + +func (g *DumbGasMeter) ConsumeGas(_ sdk.Gas, _ string) { +} + +func (g DumbGasMeter) IsPastLimit() bool { + return false +} + +func (g DumbGasMeter) IsOutOfGas() bool { + return false +} + +func (g DumbGasMeter) String() string { + return "DumbGasMeter" +} + +func NewDumbGasMeter() sdk.GasMeter { + return &DumbGasMeter{} +} diff --git a/x/vm/types/dumbgasmeter_test.go b/x/vm/types/dumbgasmeter_test.go new file mode 100644 index 0000000..ce9e671 --- /dev/null +++ b/x/vm/types/dumbgasmeter_test.go @@ -0,0 +1,24 @@ +package types + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +// Tests for dumb gas meter. +func TestVM_NewDumbGasMeter(t *testing.T) { + t.Parallel() + + gasMeter := NewDumbGasMeter() + require.Zero(t, gasMeter.Limit()) + require.Zero(t, gasMeter.GasConsumed()) + require.False(t, gasMeter.IsPastLimit()) + require.False(t, gasMeter.IsOutOfGas()) + require.Zero(t, gasMeter.GasConsumedToLimit()) + + gasMeter.ConsumeGas(100, "test") + require.Zero(t, gasMeter.GasConsumed()) + require.False(t, gasMeter.IsPastLimit()) + require.False(t, gasMeter.IsOutOfGas()) +} diff --git a/x/vm/types/errors.go b/x/vm/types/errors.go new file mode 100644 index 0000000..e4b5f84 --- /dev/null +++ b/x/vm/types/errors.go @@ -0,0 +1,18 @@ +package types + +import ( + sdkErrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +var ( + ErrInternal = sdkErrors.Register(ModuleName, 100, "internal") + ErrEmptyContract = sdkErrors.Register(ModuleName, 101, "contract code is empty") + ErrVMCrashed = sdkErrors.Register(ModuleName, 102, "VM has crashed / not reachable") // error breaks consensus + ErrNotFound = sdkErrors.Register(ModuleName, 103, "not found") + + ErrWrongArgTypeTag = sdkErrors.Register(ModuleName, 200, "invalid argument type") + ErrWrongArgValue = sdkErrors.Register(ModuleName, 201, "invalid argument value") + ErrWrongExecutionResponse = sdkErrors.Register(ModuleName, 202, "wrong execution response from VM") + + ErrGovInvalidProposal = sdkErrors.Register(ModuleName, 500, "invalid proposal") +) diff --git a/x/vm/types/events.go b/x/vm/types/events.go new file mode 100644 index 0000000..61caa40 --- /dev/null +++ b/x/vm/types/events.go @@ -0,0 +1,112 @@ +package types + +import ( + "encoding/hex" + "fmt" + "strconv" + + sdk "github.com/cosmos/cosmos-sdk/types" + + dvmTypes "github.com/dfinance/dstation/pkg/types/dvm" +) + +const ( + EventTypeContractStatus = ModuleName + ".contract_status" + EventTypeMoveEvent = ModuleName + ".contract_events" + // + AttributeStatus = "status" + AttributeErrMajorStatus = "major_status" + AttributeErrSubStatus = "sub_status" + AttributeErrMessage = "message" + AttributeErrLocationAddress = "location_address" + AttributeErrLocationModule = "location_module" + AttributeVmEventSender = "sender_address" + AttributeVmEventSource = "source" + AttributeVmEventType = "type" + AttributeVmEventData = "data" + // + AttributeValueStatusKeep = "keep" + AttributeValueStatusDiscard = "discard" + AttributeValueStatusError = "error" + AttributeValueSourceScript = "script" + AttributeValueSourceModuleFmt = "%s::%s" +) + +// NewContractEvents creates Events on successful / failed VM execution. +// "keep" status emits two events, "discard" status emits one event. +// panic if dvmTypes.VMExecuteResponse or dvmTypes.VMExecuteResponse.Status == nil +func NewContractEvents(exec *dvmTypes.VMExecuteResponse) sdk.Events { + if exec == nil { + panic(fmt.Errorf("building contract sdk.Events: exec is nil")) + } + + status := exec.GetStatus() + if status == nil { + panic(fmt.Errorf("building contract sdk.Events: exec.Status is nil")) + } + + if status.GetError() == nil { + return sdk.Events{ + sdk.NewEvent( + EventTypeContractStatus, + sdk.NewAttribute(AttributeStatus, AttributeValueStatusKeep), + ), + } + } + + // Allocate memory for 5 possible attributes: status, abort location 2 attributes, major and sub codes + attributes := make([]sdk.Attribute, 1, 5) + attributes[0] = sdk.NewAttribute(AttributeStatus, AttributeValueStatusDiscard) + + if sErr := status.GetError(); sErr != nil { + majorStatus, subStatus, abortLocation := GetStatusCodesFromVMStatus(status) + + if abortLocation != nil { + if abortLocation.GetAddress() != nil { + address := abortLocation.GetAddress() + attributes = append(attributes, sdk.NewAttribute(AttributeErrLocationAddress, string(address))) + } + + if abortLocation.GetModule() != "" { + attributes = append(attributes, sdk.NewAttribute(AttributeErrLocationModule, abortLocation.GetModule())) + } + } + + attributes = append( + attributes, + sdk.NewAttribute(AttributeErrMajorStatus, strconv.FormatUint(majorStatus, 10)), + sdk.NewAttribute(AttributeErrSubStatus, strconv.FormatUint(subStatus, 10)), + ) + + if status.GetMessage() != nil { + attributes = append(attributes, sdk.NewAttribute(AttributeErrMessage, status.GetMessage().GetText())) + } + } + + return sdk.Events{sdk.NewEvent(EventTypeContractStatus, attributes...)} +} + +// NewMoveEvent converts VM event to SDK event. +// GasMeter is used to prevent long parsing (lots of nested structs). +func NewMoveEvent(gasMeter sdk.GasMeter, vmEvent *dvmTypes.VMEvent) sdk.Event { + if vmEvent == nil { + panic(fmt.Errorf("building Move sdk.Event: event is nil")) + } + + // eventData: not parsed as it doesn't make sense + return sdk.NewEvent(EventTypeMoveEvent, + sdk.NewAttribute(AttributeVmEventSender, StringifySenderAddress(vmEvent.SenderAddress)), + sdk.NewAttribute(AttributeVmEventSource, GetEventSourceAttribute(vmEvent.SenderModule)), + sdk.NewAttribute(AttributeVmEventType, StringifyEventTypePanic(gasMeter, vmEvent.EventType)), + sdk.NewAttribute(AttributeVmEventData, hex.EncodeToString(vmEvent.EventData)), + ) +} + +// GetEventSourceAttribute returns SDK event attribute for VM event source (script / module) serialized to string. +func GetEventSourceAttribute(senderModule *dvmTypes.ModuleIdent) string { + if senderModule == nil { + return AttributeValueSourceScript + } + + return fmt.Sprintf(AttributeValueSourceModuleFmt, StringifySenderAddress(senderModule.Address), senderModule.Name) +} diff --git a/x/vm/types/events_test.go b/x/vm/types/events_test.go new file mode 100644 index 0000000..b3d8c91 --- /dev/null +++ b/x/vm/types/events_test.go @@ -0,0 +1,313 @@ +package types + +import ( + "encoding/binary" + "encoding/hex" + "strconv" + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/crypto/secp256k1" + + dvmTypes "github.com/dfinance/dstation/pkg/types/dvm" +) + +// Test event build when VM return status is "keep changes". +func TestVM_KeepEvent(t *testing.T) { + t.Parallel() + + // "keep" no error + { + exec := &dvmTypes.VMExecuteResponse{ + Status: &dvmTypes.VMStatus{}, + } + events := NewContractEvents(exec) + + require.Len(t, events, 1) + + event0 := events[0] + require.Equal(t, EventTypeContractStatus, event0.Type) + require.EqualValues(t, AttributeStatus, event0.Attributes[0].Key) + require.EqualValues(t, AttributeValueStatusKeep, event0.Attributes[0].Value) + } +} + +// Test event build when VM return status is "discard changes". +func TestVM_DiscardEvent(t *testing.T) { + t.Parallel() + + // "panic" with empty VMStatus_Abort + { + func() { + exec := &dvmTypes.VMExecuteResponse{ + Status: &dvmTypes.VMStatus{ + Error: &dvmTypes.VMStatus_Abort{}, + }, + } + + defer func() { + require.NotNil(t, recover()) + }() + + NewContractEvents(exec) + }() + } + + // "panic" with empty VMStatus_ExecutionFailure + { + func() { + exec := &dvmTypes.VMExecuteResponse{ + Status: &dvmTypes.VMStatus{ + Error: &dvmTypes.VMStatus_ExecutionFailure{}, + }, + } + + defer func() { + require.NotNil(t, recover()) + }() + + NewContractEvents(exec) + }() + } + + // "panic" with empty VMStatus_MoveError + { + func() { + exec := &dvmTypes.VMExecuteResponse{ + Status: &dvmTypes.VMStatus{ + Error: &dvmTypes.VMStatus_MoveError{}, + }, + } + + defer func() { + require.NotNil(t, recover()) + }() + + NewContractEvents(exec) + }() + } + + // "discard" with abort error and abort location + { + abortCode := uint64(500) + abortLocationModule := "AbortModule" + abortLocationAddress := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) + errMessage := "this is error!!111" + + exec := &dvmTypes.VMExecuteResponse{ + Status: &dvmTypes.VMStatus{ + Error: &dvmTypes.VMStatus_Abort{ + Abort: &dvmTypes.Abort{ + AbortCode: abortCode, + AbortLocation: &dvmTypes.AbortLocation{ + Module: abortLocationModule, + Address: abortLocationAddress.Bytes(), + }, + }, + }, + Message: &dvmTypes.Message{Text: errMessage}, + }, + } + events := NewContractEvents(exec) + + require.Len(t, events, 1) + + event0 := events[0] + require.Equal(t, EventTypeContractStatus, event0.Type) + + require.EqualValues(t, AttributeStatus, event0.Attributes[0].Key) + require.EqualValues(t, AttributeValueStatusDiscard, event0.Attributes[0].Value) + + require.EqualValues(t, AttributeErrLocationAddress, event0.Attributes[1].Key) + require.EqualValues(t, abortLocationAddress, event0.Attributes[1].Value) + + require.EqualValues(t, AttributeErrLocationModule, event0.Attributes[2].Key) + require.EqualValues(t, abortLocationModule, event0.Attributes[2].Value) + + require.EqualValues(t, AttributeErrMajorStatus, event0.Attributes[3].Key) + require.EqualValues(t, strconv.FormatUint(VMAbortedCode, 10), event0.Attributes[3].Value) + + require.EqualValues(t, AttributeErrSubStatus, event0.Attributes[4].Key) + require.EqualValues(t, strconv.FormatUint(abortCode, 10), event0.Attributes[4].Value) + + require.EqualValues(t, errMessage, event0.Attributes[5].Value) + } + + // "discard" with error without abort location + { + statusCode := uint64(500) + errMessage := "this is error!!111" + exec := &dvmTypes.VMExecuteResponse{ + Status: &dvmTypes.VMStatus{ + Error: &dvmTypes.VMStatus_ExecutionFailure{ + ExecutionFailure: &dvmTypes.Failure{ + StatusCode: statusCode, + }, + }, + Message: &dvmTypes.Message{ + Text: errMessage, + }, + }, + } + events := NewContractEvents(exec) + + require.Len(t, events, 1) + + event0 := events[0] + require.Equal(t, EventTypeContractStatus, event0.Type) + require.EqualValues(t, AttributeStatus, event0.Attributes[0].Key) + require.EqualValues(t, AttributeValueStatusDiscard, event0.Attributes[0].Value) + + require.EqualValues(t, AttributeErrMajorStatus, event0.Attributes[1].Key) + require.EqualValues(t, strconv.FormatUint(statusCode, 10), event0.Attributes[1].Value) + + require.EqualValues(t, AttributeErrSubStatus, event0.Attributes[2].Key) + require.EqualValues(t, "0", event0.Attributes[2].Value) + + require.EqualValues(t, AttributeErrMessage, event0.Attributes[3].Key) + require.EqualValues(t, errMessage, event0.Attributes[3].Value) + } +} + +// Test StringifySenderAddress. +func TestVM_StringifySenderAddress(t *testing.T) { + t.Parallel() + + address := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) + require.EqualValues(t, StdLibAddressShortStr, StringifySenderAddress(StdLibAddress)) + require.EqualValues(t, address.String(), StringifySenderAddress(address)) +} + +// Test event convertation from Move type to Cosmos. +func TestVM_NewEventFromVM(t *testing.T) { + t.Parallel() + + moduleAddr := make([]byte, VMAddressLength) + moduleAddr[VMAddressLength-1] = 2 + + value := uint64(18446744073709551615) + valBytes := make([]byte, 8) + + // seems Move using to_le_bytes + binary.LittleEndian.PutUint64(valBytes, value) + + vmEvent := dvmTypes.VMEvent{ + SenderAddress: StdLibAddress, + SenderModule: &dvmTypes.ModuleIdent{ + Name: "testModule", + Address: Bech32ToLibra(moduleAddr), + }, + EventType: &dvmTypes.LcsTag{ + TypeTag: dvmTypes.LcsType_LcsU64, + StructIdent: &dvmTypes.StructIdent{ + Address: []byte{1}, + Module: "Module_1", + Name: "Struct_1", + TypeParams: []*dvmTypes.LcsTag{ + { + TypeTag: dvmTypes.LcsType_LcsBool, + }, + { + TypeTag: dvmTypes.LcsType_LcsU128, + }, + }, + }, + }, + EventData: valBytes, + } + + sdkModuleEvent := NewMoveEvent(sdk.NewInfiniteGasMeter(), &vmEvent) + require.Equal(t, EventTypeMoveEvent, sdkModuleEvent.Type) + require.Len(t, sdkModuleEvent.Attributes, 4) + + // sender + { + attrId := 0 + require.EqualValues(t, AttributeVmEventSender, sdkModuleEvent.Attributes[attrId].Key) + require.EqualValues(t, StringifySenderAddress(vmEvent.SenderAddress), sdkModuleEvent.Attributes[attrId].Value) + } + // source + { + attrId := 1 + require.EqualValues(t, AttributeVmEventSource, sdkModuleEvent.Attributes[attrId].Key) + require.EqualValues(t, GetEventSourceAttribute(vmEvent.SenderModule), sdkModuleEvent.Attributes[attrId].Value) + } + // type + { + attrId := 2 + require.EqualValues(t, AttributeVmEventType, sdkModuleEvent.Attributes[attrId].Key) + require.EqualValues(t, StringifyEventTypePanic(sdk.NewInfiniteGasMeter(), vmEvent.EventType), sdkModuleEvent.Attributes[attrId].Value) + } + // data + { + attrId := 3 + require.EqualValues(t, AttributeVmEventData, sdkModuleEvent.Attributes[attrId].Key) + require.EqualValues(t, hex.EncodeToString(valBytes), sdkModuleEvent.Attributes[attrId].Value) + } + + // Modify vmEvent: from script + vmEvent.SenderModule = nil + sdkScriptEvent := NewMoveEvent(sdk.NewInfiniteGasMeter(), &vmEvent) + require.Equal(t, EventTypeMoveEvent, sdkScriptEvent.Type) + require.Len(t, sdkScriptEvent.Attributes, 4) + // source + { + attrId := 1 + require.EqualValues(t, AttributeVmEventSource, sdkScriptEvent.Attributes[attrId].Key) + require.EqualValues(t, AttributeValueSourceScript, sdkScriptEvent.Attributes[attrId].Value) + } +} + +// Processing event with out of gas. +func TestVM_OutOfGasProcessEvent(t *testing.T) { + t.Parallel() + + moduleAddr := make([]byte, VMAddressLength) + moduleAddr[VMAddressLength-1] = 2 + + value := uint64(18446744073709551615) + valBytes := make([]byte, 8) + + // seems Move using to_le_bytes + binary.LittleEndian.PutUint64(valBytes, value) + + vmEvent := dvmTypes.VMEvent{ + SenderAddress: StdLibAddress, + SenderModule: &dvmTypes.ModuleIdent{ + Name: "testModule", + Address: Bech32ToLibra(moduleAddr), + }, + EventType: &dvmTypes.LcsTag{ + TypeTag: dvmTypes.LcsType_LcsU64, + StructIdent: &dvmTypes.StructIdent{ + Address: []byte{1}, + Module: "Module_1", + Name: "Struct_1", + TypeParams: []*dvmTypes.LcsTag{ + { + TypeTag: dvmTypes.LcsType_LcsBool, + StructIdent: &dvmTypes.StructIdent{ + Address: []byte{2}, + Module: "Module_1", + Name: "Struct_2", + TypeParams: []*dvmTypes.LcsTag{ + { + TypeTag: dvmTypes.LcsType_LcsU8, + }, + }, + }, + }, + { + TypeTag: dvmTypes.LcsType_LcsU128, + }, + }, + }, + }, + EventData: valBytes, + } + + require.PanicsWithValue(t, sdk.ErrorOutOfGas{Descriptor: "event type processing"}, func() { + NewMoveEvent(sdk.NewGasMeter(1000), &vmEvent) + }) +} diff --git a/x/vm/types/expected_keepers.go b/x/vm/types/expected_keepers.go new file mode 100644 index 0000000..19947bf --- /dev/null +++ b/x/vm/types/expected_keepers.go @@ -0,0 +1,30 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + authTypes "github.com/cosmos/cosmos-sdk/x/auth/types" + bankExported "github.com/cosmos/cosmos-sdk/x/bank/exported" + bankTypes "github.com/cosmos/cosmos-sdk/x/bank/types" +) + +// AccountKeeper defines the expected account keeper. +type AccountKeeper interface { + GetModuleAccount(ctx sdk.Context, moduleName string) authTypes.ModuleAccountI + + SetModuleAccount(sdk.Context, authTypes.ModuleAccountI) +} + +// BankKeeper defines the expected interface needed to retrieve account balances. +type BankKeeper interface { + GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins + GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin + + SetBalances(ctx sdk.Context, addr sdk.AccAddress, balances sdk.Coins) error + + GetSupply(ctx sdk.Context) bankExported.SupplyI + + UndelegateCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error + DelegateCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error + + IterateAllDenomMetaData(ctx sdk.Context, cb func(bankTypes.Metadata) bool) +} diff --git a/x/vm/types/genesis.go b/x/vm/types/genesis.go new file mode 100644 index 0000000..739170c --- /dev/null +++ b/x/vm/types/genesis.go @@ -0,0 +1,62 @@ +package types + +import ( + "encoding/hex" + "fmt" + + dvmTypes "github.com/dfinance/dstation/pkg/types/dvm" +) + +func (m GenesisState_WriteOp) String() string { + return fmt.Sprintf("%s::%s", m.Address, m.Path) +} + +// ToBytes converts WriteOp to dvmTypes.VMAccessPath and []byte representation for value. +func (m GenesisState_WriteOp) ToBytes() (*dvmTypes.VMAccessPath, []byte, error) { + bzAddr, err := hex.DecodeString(m.Address) + if err != nil { + return nil, nil, fmt.Errorf("address: hex decode: %w", err) + } + if len(bzAddr) != VMAddressLength { + return nil, nil, fmt.Errorf("address: incorrect length (should be %d bytes)", VMAddressLength) + } + + bzPath, err := hex.DecodeString(m.Path) + if err != nil { + return nil, nil, fmt.Errorf("path: hex decode: %w", err) + } + + bzValue, err := hex.DecodeString(m.Value) + if err != nil { + return nil, nil, fmt.Errorf("value: hex decode: %w", err) + } + + return &dvmTypes.VMAccessPath{ + Address: bzAddr, + Path: bzPath, + }, bzValue, nil +} + +// Validate checks that genesis state is valid. +func (m GenesisState) Validate() error { + // VM writeSets + writeOpsSet := make(map[string]struct{}, len(m.WriteSet)) + for woIdx, writeOp := range m.WriteSet { + if _, _, err := writeOp.ToBytes(); err != nil { + return fmt.Errorf("writeSet [%d]: %w", woIdx, err) + } + + writeOpId := writeOp.String() + if _, ok := writeOpsSet[writeOpId]; ok { + return fmt.Errorf("writeSet [%d]: duplicated (%s)", woIdx, writeOpId) + } + writeOpsSet[writeOpId] = struct{}{} + } + + return nil +} + +// DefaultGenesisState returns default genesis state (validation is done on module init). +func DefaultGenesisState() GenesisState { + return defaultGenesisState +} diff --git a/x/vm/types/genesis.pb.go b/x/vm/types/genesis.pb.go new file mode 100644 index 0000000..f273e21 --- /dev/null +++ b/x/vm/types/genesis.pb.go @@ -0,0 +1,590 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: dfinance/vm/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/codec/types" + _ "github.com/cosmos/cosmos-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + _ "github.com/regen-network/cosmos-proto" + _ "google.golang.org/protobuf/types/known/timestamppb" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type GenesisState struct { + WriteSet []GenesisState_WriteOp `protobuf:"bytes,1,rep,name=write_set,json=writeSet,proto3" json:"write_set" yaml:"write_set"` +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_6fec33bf450a5340, []int{0} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.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) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +type GenesisState_WriteOp struct { + // Move address (HEX string) + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty" yaml:"address"` + // Move module path (HEX string) + Path string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty" yaml:"path"` + // Module code (HEX string) + Value string `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty" yaml:"value"` +} + +func (m *GenesisState_WriteOp) Reset() { *m = GenesisState_WriteOp{} } +func (*GenesisState_WriteOp) ProtoMessage() {} +func (*GenesisState_WriteOp) Descriptor() ([]byte, []int) { + return fileDescriptor_6fec33bf450a5340, []int{0, 0} +} +func (m *GenesisState_WriteOp) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState_WriteOp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState_WriteOp.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_WriteOp) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState_WriteOp.Merge(m, src) +} +func (m *GenesisState_WriteOp) XXX_Size() int { + return m.Size() +} +func (m *GenesisState_WriteOp) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState_WriteOp.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState_WriteOp proto.InternalMessageInfo + +func init() { + proto.RegisterType((*GenesisState)(nil), "dfinance.vm.v1beta1.GenesisState") + proto.RegisterType((*GenesisState_WriteOp)(nil), "dfinance.vm.v1beta1.GenesisState.WriteOp") +} + +func init() { proto.RegisterFile("dfinance/vm/genesis.proto", fileDescriptor_6fec33bf450a5340) } + +var fileDescriptor_6fec33bf450a5340 = []byte{ + // 380 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x91, 0x31, 0x6f, 0xe2, 0x30, + 0x14, 0xc7, 0x13, 0xb8, 0x3b, 0x20, 0xa0, 0x3b, 0x94, 0xeb, 0x10, 0x18, 0x62, 0x94, 0x4a, 0x2d, + 0x95, 0xaa, 0x58, 0xb4, 0x1b, 0x5b, 0x59, 0x3a, 0x56, 0x0a, 0x43, 0xa5, 0x2e, 0xd4, 0x49, 0x4c, + 0x88, 0x44, 0xe2, 0x08, 0x9b, 0xb4, 0x7c, 0x03, 0xb6, 0x56, 0x9d, 0x3a, 0xf2, 0x71, 0x18, 0x19, + 0x3b, 0x45, 0x15, 0x2c, 0x9d, 0xf3, 0x09, 0xaa, 0xd8, 0x06, 0x55, 0x55, 0xb7, 0xff, 0x7b, 0xbf, + 0xdf, 0x8b, 0x5e, 0xfc, 0xb4, 0x96, 0x3f, 0x0e, 0x63, 0x14, 0x7b, 0x18, 0xa6, 0x11, 0x0c, 0x70, + 0x8c, 0x69, 0x48, 0xed, 0x64, 0x46, 0x18, 0xd1, 0xff, 0xef, 0x91, 0x9d, 0x46, 0x76, 0xda, 0x73, + 0x31, 0x43, 0xbd, 0x76, 0x2b, 0x20, 0x24, 0x98, 0x62, 0xc8, 0x15, 0x77, 0x3e, 0x86, 0x28, 0x5e, + 0x08, 0xbf, 0x0d, 0xbe, 0x23, 0x16, 0x46, 0x98, 0x32, 0x14, 0x25, 0x52, 0x38, 0x0a, 0x48, 0x40, + 0x78, 0x84, 0x45, 0x92, 0xdd, 0x96, 0x47, 0x68, 0x44, 0xe8, 0x48, 0x00, 0x51, 0x48, 0x64, 0x8a, + 0x0a, 0xba, 0x88, 0x62, 0x28, 0x37, 0x80, 0x1e, 0x09, 0x63, 0xc1, 0xad, 0xa7, 0x92, 0xd6, 0xb8, + 0x16, 0x3b, 0x0f, 0x19, 0x62, 0x58, 0xbf, 0xd7, 0x6a, 0x0f, 0xb3, 0x90, 0xe1, 0x11, 0xc5, 0xcc, + 0x50, 0x3b, 0xe5, 0x6e, 0xfd, 0xe2, 0xcc, 0xfe, 0xe1, 0x37, 0xec, 0xaf, 0x53, 0xf6, 0x6d, 0x31, + 0x72, 0x93, 0x0c, 0x8c, 0x75, 0x06, 0x94, 0x3c, 0x03, 0xcd, 0x05, 0x8a, 0xa6, 0x7d, 0xeb, 0xf0, + 0x25, 0xcb, 0xa9, 0xf2, 0x3c, 0xc4, 0xac, 0xfd, 0xa2, 0x6a, 0x15, 0xe9, 0xeb, 0xe7, 0x5a, 0x05, + 0xf9, 0xfe, 0x0c, 0x53, 0x6a, 0xa8, 0x1d, 0xb5, 0x5b, 0x1b, 0xe8, 0x79, 0x06, 0xfe, 0x8a, 0x61, + 0x09, 0x2c, 0x67, 0xaf, 0xe8, 0xc7, 0xda, 0xaf, 0x04, 0xb1, 0x89, 0x51, 0xe2, 0xea, 0xbf, 0x3c, + 0x03, 0x75, 0xa1, 0x16, 0x5d, 0xcb, 0xe1, 0x50, 0x3f, 0xd1, 0x7e, 0xa7, 0x68, 0x3a, 0xc7, 0x46, + 0x99, 0x5b, 0xcd, 0x3c, 0x03, 0x0d, 0x61, 0xf1, 0xb6, 0xe5, 0x08, 0xdc, 0x6f, 0x2c, 0x57, 0x40, + 0x79, 0x5d, 0x01, 0xe5, 0x63, 0x05, 0x94, 0x7e, 0x75, 0x29, 0xd3, 0xe0, 0x6a, 0xbd, 0x35, 0xd5, + 0xcd, 0xd6, 0x54, 0xdf, 0xb7, 0xa6, 0xfa, 0xbc, 0x33, 0x95, 0xcd, 0xce, 0x54, 0xde, 0x76, 0xa6, + 0x72, 0x77, 0x1a, 0x84, 0x6c, 0x32, 0x77, 0x6d, 0x8f, 0x44, 0xf0, 0x70, 0x73, 0x9f, 0x32, 0xc4, + 0x42, 0x12, 0xc3, 0xc7, 0xe2, 0xfc, 0x6c, 0x91, 0x60, 0xea, 0xfe, 0xe1, 0x6f, 0x7b, 0xf9, 0x19, + 0x00, 0x00, 0xff, 0xff, 0x4a, 0xa8, 0x64, 0x6a, 0x1a, 0x02, 0x00, 0x00, +} + +func (m *GenesisState) 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) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.WriteSet) > 0 { + for iNdEx := len(m.WriteSet) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.WriteSet[iNdEx].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_WriteOp) 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_WriteOp) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState_WriteOp) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Value) > 0 { + i -= len(m.Value) + copy(dAtA[i:], m.Value) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Value))) + i-- + dAtA[i] = 0x1a + } + if len(m.Path) > 0 { + i -= len(m.Path) + copy(dAtA[i:], m.Path) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Path))) + i-- + dAtA[i] = 0x12 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.WriteSet) > 0 { + for _, e := range m.WriteSet { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + return n +} + +func (m *GenesisState_WriteOp) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + l = len(m.Path) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + l = len(m.Value) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GenesisState) 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: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field WriteSet", 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.WriteSet = append(m.WriteSet, GenesisState_WriteOp{}) + if err := m.WriteSet[len(m.WriteSet)-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) || (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_WriteOp) 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: WriteOp: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: WriteOp: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Path", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Path = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Value = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenesis(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/vm/types/genesis_test.go b/x/vm/types/genesis_test.go new file mode 100644 index 0000000..572fdb8 --- /dev/null +++ b/x/vm/types/genesis_test.go @@ -0,0 +1,130 @@ +package types + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestVM_Genesis_Validate(t *testing.T) { + t.Parallel() + + const ( + address1Ok = "010203040506070809A0A1A2A3A4A5A6A7A8A9AB" + address2Ok = "010203040506070809A0A1A2A3A4A5A6A7A8A9AC" + address3Ok = "010203040506070809A0A1A2A3A4A5A6A7A8A9AD" + addressWrongLen = "010203040506070809A0A1A2A3A4A5A6A7A8A9" + path1Ok = "B0B1B2B3B4B5B6B7B8C0" + path2Ok = "B0B1B2B3B4B5B6B7B8C1" + path3Ok = "B0B1B2B3B4B5B6B7B8C2" + valueOk = "112233445566778899AABBCCDDEEFF" + wrongHex = "xxyyzz" + ) + + // WriteSets + { + // fail: address wrong HEX + { + state := GenesisState{ + WriteSet: []GenesisState_WriteOp{ + { + Address: wrongHex, + Path: path1Ok, + Value: valueOk, + }, + }, + } + require.Error(t, state.Validate()) + } + + // fail: address wrong length + { + state := GenesisState{ + WriteSet: []GenesisState_WriteOp{ + { + Address: addressWrongLen, + Path: path1Ok, + Value: valueOk, + }, + }, + } + require.Error(t, state.Validate()) + } + + // fail: path wrong HEX + { + state := GenesisState{ + WriteSet: []GenesisState_WriteOp{ + { + Address: address1Ok, + Path: wrongHex, + Value: valueOk, + }, + }, + } + require.Error(t, state.Validate()) + } + + // fail: value wrong HEX + { + state := GenesisState{ + WriteSet: []GenesisState_WriteOp{ + { + Address: address1Ok, + Path: path1Ok, + Value: wrongHex, + }, + }, + } + require.Error(t, state.Validate()) + } + + // fail: duplicated writeOp + { + state := GenesisState{ + WriteSet: []GenesisState_WriteOp{ + { + Address: address1Ok, + Path: path1Ok, + Value: valueOk, + }, + { + Address: address2Ok, + Path: path2Ok, + Value: valueOk, + }, + { + Address: address1Ok, + Path: path1Ok, + Value: valueOk, + }, + }, + } + require.Error(t, state.Validate()) + } + + // ok + { + state := GenesisState{ + WriteSet: []GenesisState_WriteOp{ + { + Address: address1Ok, + Path: path1Ok, + Value: valueOk, + }, + { + Address: address2Ok, + Path: path2Ok, + Value: valueOk, + }, + { + Address: address3Ok, + Path: path3Ok, + Value: valueOk, + }, + }, + } + require.NoError(t, state.Validate()) + } + } +} diff --git a/x/vm/types/genesis_ws.go b/x/vm/types/genesis_ws.go new file mode 100644 index 0000000..48c2f6b --- /dev/null +++ b/x/vm/types/genesis_ws.go @@ -0,0 +1,114 @@ +package types + +import "encoding/json" + +const genesisDefaultWriteSets = ` +{ + "write_set": [ + { + "address": "0000000000000000000000000000000000000001", + "path": "000f10c361bbef3f3707af2bd2b1f5ccbcbc2d9477834ae1857a05119bf0cc19f3", + "value": "a11ceb0b010000000a010002020204030614051a09072344086714067b340aaf01050cb4015b0d8f020200000001010000020000000003010200000400000000050100000103000101030301030454696d651043757272656e7454696d657374616d7009646179735f66726f6d0a69735f67656e657369730c6d696e757465735f66726f6d036e6f77077365636f6e64730000000000000000000000000000000000000001030865000000000000000308805101000000000003083c0000000000000005140000000000000000000000000000000000000001000201060300010100031011030c010a010a00260c020b02030a0700270a010a001707011a02010100010407032900200202010100031011030c010a010a00260c020b02030a0700270a010a001707021a0203010100010507032b0010001402000000" + }, + { + "address": "0000000000000000000000000000000000000001", + "path": "00bece7868df537350b30aecfd94ecceac4ff0f4e589ab16605cc55e72a783856d", + "value": "a11ceb0b010000000601000203020a050c090715210836140c4a0e00000001000100000200020001060c010501060500065369676e65720a616464726573735f6f660e626f72726f775f61646472657373000000000000000000000000000000000000000100010003040b001101140201030000" + }, + { + "address": "0000000000000000000000000000000000000001", + "path": "001e71f6df00e48c8c254cd583d3dc45937e436997cfae0dbe3b8c2345b7159e09", + "value": "a11ceb0b0100000006010002030206050806070e0b0819140c2d03000000010001010202060c090000054576656e7404656d6974000000000000000000000000000000000000000100030000" + }, + { + "address": "0000000000000000000000000000000000000001", + "path": "00f291acfb65d0f093d26ad997ca99c2e14150a49953d95c8304a63701ca7de4f1", + "value": "a11ceb0b010000000d010008020816031e9d0104bb012005db01950107f002ef0308df061406f3060e0a8107280ba907020cab0797030dc20a020ec40a020000000100020003000401010100050200000602000007010001070101010308000100020902030102010a03040101010b05030101010c06070101010d08090101010e03090101000f0003010100100007010100110107010100120103000013010301010014010a00000b0b03010100150c09010100160d03010100170e03010100180e03010100190a0300001a00070101001b010f00001c010f0101001d10030101001e11030101001f1209010100200c09010100210d03010106130913041310130d1311130213011515130b1303130116171319130513181301060c010502060c090000010a0202070b040109000b0401090001060b04010900010402070b0401090004010b04010900010c03060c050b0401090002060c0402060c0b0401090004060c050b040109000a02010103060c050404060c05040a0202070b00010900040109000f040a02070b00010900010304050a020a02060c040a020a0205060c01080201080101070b00010900074163636f756e74084466696e616e6365054576656e74065369676e65720742616c616e63651452656365697665645061796d656e744576656e741053656e745061796d656e744576656e7401540a616464726573735f6f6604656d69740564656e6f6d076465706f7369740576616c7565087769746864726177047a65726f066163636570740762616c616e63650b62616c616e63655f666f720e6372656174655f6163636f756e740e6372656174655f62616c616e63650d6372656174655f7369676e65720e6465706f7369745f6e6174697665116465706f7369745f746f5f73656e646572156465706f7369745f776974685f6d65746164617461206465706f7369745f776974685f73656e6465725f616e645f6d657461646174610e64657374726f795f7369676e6572126765745f6e61746976655f62616c616e63650b6861735f6163636f756e740b6861735f62616c616e63650f7061795f66726f6d5f73656e6465721d7061795f66726f6d5f73656e6465725f776974685f6d657461646174611577697468647261775f66726f6d5f62616c616e63651477697468647261775f66726f6d5f73656e6465720f77697468647261775f6e617469766504636f696e06616d6f756e74057061796572086d657461646174610570617965650b64756d6d795f6669656c640000000000000000000000000000000000000001030807000000000000000a020100000201220b0401090001020423040a0a022405250a0202020423040a0a022605250a020302012701001307010003050b00380039003f00020801010003040b0011003801020901010003050a003d0037003802020a00000a0a0a00110c0c010e010912032d030b011112020b00000a0a0a00110c0c010e01380039003f000b011112020c02000d01010003060b000a010b0207013803020e03000f01010003060a000b0011000b013804021001010003060b000a010b020b033805021100010014480e0238020c040a043200000000000000000000000000000000240c070b07030d0b000107002738060c050a000c0d0a040c090a010c0a0a050c0b0a030c0c0b0d0b090b0b0b0a0b0c120238070a01380820032505270a0138090a01111420032c052e0a01110a0a013c000c060b0636000b02380a0a000c120a040c0e0b050c0f0b030c100b0011000c110b120b0e0b0f0b110b101201380b0212020013030014010003030a0029030215010003030a003b00021601010003060b000a010a020701380c021701010003080a000a010b000a02380d0b0338030218000003050b0036000a01380e021901010017080b0011003c000c020b020a01380f021a03000000001300" + }, + { + "address": "0000000000000000000000000000000000000001", + "path": "00d35c97ec98d9b737c66f0d5a6acf89644c8818196f1bb071e14971072c0d1427", + "value": "a11ceb0b010000000801000203025404561005665607bc01800108bc021406d0020a0cda02820300000001000101010002020301010003040501010004060701010005080101010006010801010007090701010008090a010100090b0c0101000a0d010101000b040c0101000c0b010101000d0e010101000e040c01010b0c060c080c090c040c070c010c0c0c02070a09000a09000002060a0900030106090002070a0900030107090002060a09000609000101010a090001060a0900010301070a090001090002070a0900090003070a09000303020303030303070a09000303030306566563746f7206617070656e6406626f72726f770a626f72726f775f6d757408636f6e7461696e730d64657374726f795f656d70747905656d7074790869735f656d707479066c656e67746808706f705f6261636b09707573685f6261636b0672656d6f7665077265766572736504737761700b737761705f72656d6f7665000000000000000000000000000000000000000103080a0000000000000000010001110d0138000e013801200307050c0a000d013802380305020b00010b013804020103000203000301000f220600000000000000000c020a0038050c030a020a0323030a051c0a000a0238060a0121031105170b00010b010108020a02060100000000000000160c0205050b00010b0101090204030005030006010001050b00380506000000000000000021020703000803000903000a010010260a002e38050c020a010a02260309050d0b00010700270a02060100000000000000170c020a010a0223031605230a000c040a010c030a01060100000000000000160c010b040b030a01380705110b003802020b010011270a002e38050c030a03060000000000000000210309050c0b0001020600000000000000000c020a03060100000000000000170c010a020a0123031705240a000a020a0138070a02060100000000000000160c020a01060100000000000000170c0105120b0001020c03000d01000a0d0a002e3805060100000000000000170c020a000a010a0238070b0038020200" + }, + { + "address": "0000000000000000000000000000000000000001", + "path": "007a0935e425ebfda3c9071fdebcda28ca0c712f89fc9d2a7cf454a1596710965b", + "value": "a11ceb0b010000000d01000602060d03133e04510205535707aa01bf0108e9021406fd021e0a9b031a0bb503020cb703ab030de206100ef2060800000001000200030100000401000000010102010500010002060203000007040501020008060701020009080200000a090a0102000b010700000c0b0c0102000d0d0c0102000e0c0a0102000f040e0102070a01060c010500010301060b020109000106090002060b020109000608010101010801010b0201090001090003060c090003020b02010900080102060c090003050303040103010305090001030103060503070800010303085365637572697479065369676e65720454696d6504496e666f0550726f6f660a616464726573735f6f66036e6f7706626f72726f770963616e5f70726f76651564657374726f795f657870697265645f70726f6f661864657374726f795f657870697265645f7365637572697479086861735f696e666f0569737375650d69737375655f666f72657665720570726f76650d726561645f736563757269747910736563757269746965735f636f756e740262790269640365787003666f7200000000000000000000000000000000000000010308660000000000000003086500000000000000030867000000000000000002011003010203110512031303020204140900110512031303020a02010002030b00370002030100071a0a003701140a0110021421030905120b003702140b01100414210c0205180b00010b0101090c020b02020401000f1a0e00100514060000000000000000220c010b01030a0700270e001005141101250c030b0303140700270b00130101010102050100101c0e00370314060000000000000000220c020b02030a0700270e003703141101250c040b0403140700270b003a000101010c010b010206010002030a0029000207010100113b0a02060000000000000000220305050f0a021101240c060b06030f0b00010702270a0011000c030a031106200317051e0b0006010000000000000012002d000601000000000000000c08052f0b00010a032a000c050a05100714060100000000000000160a050f07150b051007140c080b080c040b010a030a040a0239000a030a040a021201020801010002050b000b0106000000000000000038000209010010250e003702140e01100414210c030b03030c0701270e003701140e01100214210c050b0503180701270b003a000101010c020b0113010101010b02020a0100020a0a003702140a003701140b003703140202000202010102010100010202030000000a010a030a060a00" + }, + { + "address": "0000000000000000000000000000000000000001", + "path": "009934e51f2eb6b334a0111bc088588497e2a304aac277526593fd68f816c20417", + "value": "a11ceb0b010000000a010002020204030605050b03070e340842140656160a6c050c710e0d7f02000000010100000200010000010305426c6f636b0d426c6f636b4d65746164617461186765745f63757272656e745f626c6f636b5f68656967687406686569676874000000000000000000000000000000000000000105140000000000000000000000000000000000000001000201030300010100000507002b0010001402000000" + }, + { + "address": "0000000000000000000000000000000000000001", + "path": "0057b62e1468d1b54b24ec6aaa0fa1cf44ebe1cf82a6bed49ba858f02dac4bf6a3", + "value": "a11ceb0b010000000c01000802080a031229043b0605413507766508db01140aef010a0bf901020cfb013c0db702020eb902020000000100020003000401010201010101020205000100030602030101030704020101030805060101000900020102000a07020102000b0809010201090209030901060c010500010a090002070a0900090002070a09000301090002060c0b0101090002060c03010b010109000205070a0b010109000f536563757269747953746f72616765085365637572697479065369676e657206566563746f7201540a616464726573735f6f6605656d70747909707573685f6261636b0672656d6f766504696e697404707573680474616b650a7365637572697469657300000000000000000000000000000000000000010002010c0a0b01010900000604010002050b00380039003f00020501010002070b0011003c0036000b01380102060101000a0b0b0011000c020a023c0036000c030b030a013802020000000600" + }, + { + "address": "0000000000000000000000000000000000000001", + "path": "00386c247ee0ae4587fc3b7ad2364518bf679ff7681dbbbb0d8a165a0c6d7ec1d6", + "value": "a11ceb0b010000000c01000202021203140e05220a072c3f086b14067f160a9501140ba901020cab01180dc301020ec50102000000010200000202000003010201010004020000050001020101000600020201010001040101020900090105436f696e7303425443034554480550726963650455534454096765745f7072696365096861735f70726963650b64756d6d795f6669656c640576616c75650000000000000000000000000000000000000001051400000000000000000000000000000000000000010002010701010201070102020108040302010701020300010102000507003d0037001402010100000307003b00020200000300" + }, + { + "address": "0000000000000000000000000000000000000001", + "path": "0020b5dde2cb71801be4d554a2d7f1b1063f527aa8990f5fd08a097f3d8b9fd50b", + "value": "a11ceb0b01000000050100020202040706120818140a2c050000000102000358464901540b64756d6d795f6669656c640000000000000000000000000000000000000001000201020100" + }, + { + "address": "0000000000000000000000000000000000000001", + "path": "00dc548635f2b6e528d101e0832fb78622d940f8510d04cc16fc576f6139b4c84a", + "value": "a11ceb0b010000000801000202020403063205380e074649088f01140aa301060ca9011e000000000200000100010000020102000003010300000401040000050001000006020100000703010000080401000009000100000a00010002080008000108000104010301020455323536036164640761735f753132380661735f7536340561735f7538036469760966726f6d5f753132380866726f6d5f7536340766726f6d5f7538036d756c037375620376616c00000000000000000000000000000000000000010002010b0a0200030001030002030003030004030005030006030007030008030009030000" + }, + { + "address": "0000000000000000000000000000000000000001", + "path": "0041f3acd295ef0cbb729b138715119833fb8cc7f40d70ed6796b5737d4832f194", + "value": "a11ceb0b010000000601000203020b050d0507121e0830140c4406000000010001010100020101000106090000054465627567057072696e74117072696e745f737461636b5f7472616365000000000000000000000000000000000000000100030001030000" + }, + { + "address": "0000000000000000000000000000000000000001", + "path": "008696ee9de913cfa23cf7d81b8dc4f5b9c880a27d9989dd9553e53b861bdff8cf", + "value": "a11ceb0b0100000006010002030206050807070f0d081c140c3003000000010001010101060900010a02034c435308746f5f6279746573000000000000000000000000000000000000000100030000" + }, + { + "address": "0000000000000000000000000000000000000001", + "path": "009cb04857956873d52372bd369d73c8042b81cdf4913d838e55867ea219afb01c", + "value": "a11ceb0b010000000d010006020614031a74048e0108059601980107ae029d0208cb041406df044e0aad05240bd105080cd905e0030db9090c0ec5090c000000010002000301010100040101010005010102000602010102070001000108020301020009000300000a010400000b05060102000c03070101000d03080101000e09030101000f04030000100a0301010011030b010100120c0a010100130301010100140d03010100150e03010200160f0c01010017031001010018111001010019120a0101001a030a01010e1501160715121501060c010502060c090000010c04060c04020a02010b01010b020109000102010a0202070b010109000b01010900010b010109000101020b010109000b0101090003060c0a0202010b00010900020b0101090004010401060b0101090002070b0101090004020103100501030103010a02020504010504020a02060c010900010b03010900010b0201090003010304060a0202050401060c084466696e616e6365054576656e74065369676e657204496e666f015405546f6b656e11546f6b656e437265617465644576656e740a616464726573735f6f6604656d6974186173736572745f63616e5f72656769737465725f636f696e0d6372656174655f7369676e65720c6372656174655f746f6b656e08646563696d616c730564656e6f6d076465706f7369740e64657374726f795f7369676e65720c64657374726f795f7a65726f0869735f746f6b656e046a6f696e056f776e65720d72656769737465725f636f696e1372656769737465725f746f6b656e5f696e666f0573706c69740c746f74616c5f737570706c790576616c7565087769746864726177047a65726f0b64756d6d795f6669656c640763726561746f7200000000000000000000000000000000000000010201120201000308680000000000000003086700000000000000030865000000000000000308690000000000000003086600000000000000051400000000000000000000000000000000000000010002050d0a020c0211011305170401020118040202011b010302041c0517040d0a020c020015031501170115020000130a0b0011000707210c010b01030907042702030200040100144407073b00200c050b05030a0b00010706270a02070126030f05140a020700250c090516090c090b090c070b07031e0b00010703270a0011000c040a030c0a0a020c0b0a040c0c0a010c0d0b0a0b0b080b0c0b0d390038000b000c130a040c0f0a010c100a020c110b030c120b130b0f0b100b120b11390138010a0139020205010100030507073d003700140206010100030507073d0037011402070100100c0b013a030c020a003702140a02160b0036021502080200090100180c0b003a030c030a033200000000000000000000000000000000210c010b01030b070527020a010100030507073d00370314020b010003050d000b0138020b00020c010100030507073d00370414020d010019110a0011020b000c080b010c030a020c040b080b030b04090707320000000000000000000000000000000039003f00020e00000409070711030c010e010b003f000b011108020f01000a070d000a0138030c020b000b020210010100030507073d003705140211010003040b003702140212010013170a003702140a01260c020b02030c0b00010702270a003702140a01170b003602150a013903021301000303320000000000000000000000000000000039030200010000010000020003000400150115021503150415051500" + }, + { + "address": "0000000000000000000000000000000000000001", + "path": "0022c2d41e51b342483200ad4a9d288d116a1a8404138d4413248eff33c36d5927", + "value": "a11ceb0b0100000009010004020408030c4b05575907b0017108a1021406b5021f0ad402070cdb02b604000000010002020001010200010300010001040200000105010000010602000000070304000004030400000803050000090607000006030400000a080400000b040800000c090100000d070100000e0a0100000f03040001080101040208010801020800080001080001010202020102020402020302020800020702020204040404000a02020801040801080104040801040204040c0202020208010801040204040801080102010302020403020404044d6174680455323536034e756d0761735f75313238036469760966726f6d5f75313238036d756c0361646406657175616c73036d6178036e756d0a6e756d5f756e7061636b03706f7706706f775f3130117363616c655f746f5f646563696d616c73037375620576616c7565036465630000000000000000000000000000000000000001030891010000000000000201120410000064a7b3b6e00d0000000000000000000202100411020401000b200b00110a0c020c050b01110a0c030c070a020a0311070c040a050a040a0217110c180c060a070a040a0317110c180c080a060a08160a041109020501000d2c0b00110a0c020c050b01110a0c030c0907010a0217110c0c080a0511020a08110211030c060b060702110211030c0707010a0317110c0c0b0a0911020a0b110211030c0a0b070b0a11010c040b04110007011109020601000e0c0b003112110d0c020b013112110d0c030a020a032102070000070c0a000a0124030505080a000c02050a0a010c020b02020801000f3f0b00110a0c020c0a0b01110a0c030c0b0a0a11020a0b110211030c060a020a03160c090a090701230317052207010a09170c050b060a05110c110211030c0d05360a09070124032705320a090701170c040b060a04110c110211010c0c05340b060c0c0b0c0c0d0b0d0c070b0711000c080a080701110902090100100c0a010701250c020b0203080700270a000a011200020a010011070b0013000c010c020a020a01020b0100111532010000000000000000000000000000000c0331000c020a020a0123030905130a030a0035180c030a023101160c0205040a03020c01000c04060a000000000000000a00110b020d0100121a0b00110a0c020c040a020a0123030905110a040a010a0217110c180c0305180a040a020a0117110c1a0c030b03020e01000b200b00110a0c020c050b01110a0c030c070a020a0311070c040a050a040a0217110c180c060a070a040a0317110c180c080a060a08170a0411090200" + }, + { + "address": "0000000000000000000000000000000000000001", + "path": "001d38630b3873058ea4c0226b90ccd36a175559a7f8652bf4f9b2633d9afc756a", + "value": "a11ceb0b010000000601000203020a050c140720320852140c6606000000010001000002020300040a020a020a020a020103030a020a020a020101095369676e617475726518656432353531395f7468726573686f6c645f7665726966790e656432353531395f766572696679000000000000000000000000000000000000000100030001030000" + }, + { + "address": "0000000000000000000000000000000000000001", + "path": "00d6aa4796d52dcb4ad53952e57d14185c187f13ffbb3f0e402dc6da3c9c85b688", + "value": "a11ceb0b010000000701000403041b041f04052327074a3a088401140c9801e901000000010102000101010103020301010004040500000506050000060705000105000502060a0900030106090001060a0900010302060a02060a0201020203030202020502030302010007436f6d7061726506566563746f7206626f72726f77066c656e6774680d636d705f6c63735f627974657307636d705f75363406636d705f75380000000000000000000000000000000000000001020100083d0a0038000c030a0138000c040a030a0411030c050a0306000000000000000024030f05140a04060000000000000000240c060516090c060b06031905370a03060100000000000000170c030a04060100000000000000170c040a000a033801140a010a0438011411040c020a02310022033005360b01010b00010a0202050a0b01010b00010a050203000007160a000a01210305050831000c0305140a000a0123030d051031010c02051231020c020b020c030b030204000007160a000a01210305050831000c0305140a000a0123030d051031010c02051231020c020b020c030b030200" + }, + { + "address": "0000000000000000000000000000000000000001", + "path": "00322e5b50f94d3df7f68f08779d754435119f50ee6ec03f726051d408c6f1d8f6", + "value": "a11ceb0b010000000c01000402040503091d05261d07433e088101140695010a0a9f01080ba701020ca901610d8a02020e8c0202000000010002010101010300010000030101010100040203010100050104010100060506010101060c010503060c09000500010102060c050109000605090005010301054f66666572065369676e657201540a616464726573735f6f6606637265617465096578697374735f61740672656465656d076f66666572656403666f72000000000000000000000000000000000000000103080b00000000000000000202070900080500060101010003050a003d003700140202010003060b000b010a0239003f000203010003030a003b000204010100071c0a013e003a000c020c030b0011000c040a040a0221030d0510080c0705140a040a01210c070b070c050b05031a0700270b03020001000600" + }, + { + "address": "0000000000000000000000000000000000000001", + "path": "00645941518552d45ce5aa55b54db8723702ca0c0ecaa3fb36df0cedd4fc63d439", + "value": "a11ceb0b010000000a010002020204030619051f17073666089c011406b0010a0aba01050cbf01a5010de402020000000102000002000100000302010000040302000005010200000603020002030301080001030203080006040404010301000204040c4669786564506f696e7433320154146372656174655f66726f6d5f726174696f6e616c156372656174655f66726f6d5f7261775f76616c75650a6469766964655f7536340d6765745f7261775f76616c75650c6d756c7469706c795f7536340576616c7565000000000000000000000000000000000000000103081000000000000000000201070300010004240a003531402f0c040a013531202f0c030a040a031a0c020a0232000000000000000000000000000000002203130516080c07051a0a00060000000000000000210c070b070c050b0503200700270a023412000201010005030a00120002020100060f0a003531202f0c030a030e01100014351a0c020a02340203010005040e0010001402040100060f0a00350e0110001435180c030a033120300c020a023402000000" + } + ] +} +` + +var defaultGenesisState GenesisState + +func init() { + errorCodes = make(map[string]string) + if err := json.Unmarshal([]byte(genesisDefaultWriteSets), &defaultGenesisState); err != nil { + panic(err) + } +} diff --git a/x/vm/types/gov.pb.go b/x/vm/types/gov.pb.go new file mode 100644 index 0000000..0e7068a --- /dev/null +++ b/x/vm/types/gov.pb.go @@ -0,0 +1,621 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: dfinance/vm/gov.proto + +package types + +import ( + fmt "fmt" + types "github.com/cosmos/cosmos-sdk/codec/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + _ "github.com/regen-network/cosmos-proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// PlannedProposal defines VM Gov proposal with apply schedule and wrapped proposal content. +type PlannedProposal struct { + // Height is a block height proposal should be applied at + Height int64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty" yaml:"height"` + // Content is a Gov proposal content + Content *types.Any `protobuf:"bytes,2,opt,name=content,proto3" json:"content,omitempty" yaml:"content"` +} + +func (m *PlannedProposal) Reset() { *m = PlannedProposal{} } +func (*PlannedProposal) ProtoMessage() {} +func (*PlannedProposal) Descriptor() ([]byte, []int) { + return fileDescriptor_ebf6ed3fb4c5a03e, []int{0} +} +func (m *PlannedProposal) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PlannedProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PlannedProposal.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 *PlannedProposal) XXX_Merge(src proto.Message) { + xxx_messageInfo_PlannedProposal.Merge(m, src) +} +func (m *PlannedProposal) XXX_Size() int { + return m.Size() +} +func (m *PlannedProposal) XXX_DiscardUnknown() { + xxx_messageInfo_PlannedProposal.DiscardUnknown(m) +} + +var xxx_messageInfo_PlannedProposal proto.InternalMessageInfo + +type StdLibUpdateProposal struct { + // Url contains Stdlib update source code + Url string `protobuf:"bytes,2,opt,name=url,proto3" json:"url,omitempty" yaml:"url"` + // UpdateDescription contains some update description + UpdateDescription string `protobuf:"bytes,3,opt,name=update_description,json=updateDescription,proto3" json:"update_description,omitempty" yaml:"update_description"` + // Code is a DVM byteCode of updated modules + Code [][]byte `protobuf:"bytes,4,rep,name=code,proto3" json:"code,omitempty" yaml:"code"` +} + +func (m *StdLibUpdateProposal) Reset() { *m = StdLibUpdateProposal{} } +func (*StdLibUpdateProposal) ProtoMessage() {} +func (*StdLibUpdateProposal) Descriptor() ([]byte, []int) { + return fileDescriptor_ebf6ed3fb4c5a03e, []int{1} +} +func (m *StdLibUpdateProposal) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *StdLibUpdateProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_StdLibUpdateProposal.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 *StdLibUpdateProposal) XXX_Merge(src proto.Message) { + xxx_messageInfo_StdLibUpdateProposal.Merge(m, src) +} +func (m *StdLibUpdateProposal) XXX_Size() int { + return m.Size() +} +func (m *StdLibUpdateProposal) XXX_DiscardUnknown() { + xxx_messageInfo_StdLibUpdateProposal.DiscardUnknown(m) +} + +var xxx_messageInfo_StdLibUpdateProposal proto.InternalMessageInfo + +func init() { + proto.RegisterType((*PlannedProposal)(nil), "dfinance.vm.v1beta1.PlannedProposal") + proto.RegisterType((*StdLibUpdateProposal)(nil), "dfinance.vm.v1beta1.StdLibUpdateProposal") +} + +func init() { proto.RegisterFile("dfinance/vm/gov.proto", fileDescriptor_ebf6ed3fb4c5a03e) } + +var fileDescriptor_ebf6ed3fb4c5a03e = []byte{ + // 392 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x64, 0x51, 0xcd, 0xae, 0x93, 0x40, + 0x14, 0x66, 0xe4, 0xe6, 0x5e, 0x9d, 0xab, 0xb7, 0x29, 0xd6, 0x84, 0x36, 0x11, 0xc8, 0xb8, 0xb0, + 0x2e, 0x84, 0x54, 0x77, 0xdd, 0x15, 0x5d, 0xd6, 0xa4, 0xc1, 0xb8, 0x71, 0xd3, 0x0c, 0xcc, 0x94, + 0x92, 0xc0, 0x0c, 0x81, 0x81, 0xc8, 0x1b, 0xb8, 0x74, 0x63, 0xe2, 0xb2, 0x0f, 0xa1, 0xef, 0x60, + 0x5c, 0x75, 0xe9, 0x8a, 0x98, 0xf6, 0x0d, 0x78, 0x02, 0x03, 0x53, 0xda, 0xc5, 0xdd, 0x9d, 0xf3, + 0xfd, 0x9c, 0xf3, 0xcd, 0x1c, 0xf8, 0x8c, 0x6c, 0x22, 0x86, 0x59, 0x40, 0x9d, 0x32, 0x71, 0x42, + 0x5e, 0xda, 0x69, 0xc6, 0x05, 0xd7, 0x9e, 0xf6, 0xb0, 0x5d, 0x26, 0x76, 0x39, 0xf3, 0xa9, 0xc0, + 0xb3, 0xc9, 0x28, 0xe4, 0x21, 0xef, 0x78, 0xa7, 0xad, 0xa4, 0x74, 0x32, 0x0e, 0x39, 0x0f, 0x63, + 0xea, 0x74, 0x9d, 0x5f, 0x6c, 0x1c, 0xcc, 0xaa, 0x9e, 0x0a, 0x78, 0x9e, 0xf0, 0x7c, 0x2d, 0x3d, + 0xb2, 0x91, 0x14, 0xfa, 0x0e, 0xe0, 0x60, 0x15, 0x63, 0xc6, 0x28, 0x59, 0x65, 0x3c, 0xe5, 0x39, + 0x8e, 0xb5, 0x57, 0xf0, 0x7a, 0x4b, 0xa3, 0x70, 0x2b, 0x74, 0x60, 0x81, 0xa9, 0xea, 0x0e, 0x9b, + 0xda, 0x7c, 0x52, 0xe1, 0x24, 0x9e, 0x23, 0x89, 0x23, 0xef, 0x24, 0xd0, 0x3e, 0xc0, 0x9b, 0x80, + 0x33, 0x41, 0x99, 0xd0, 0x1f, 0x58, 0x60, 0x7a, 0xfb, 0x66, 0x64, 0xcb, 0x18, 0x76, 0x1f, 0xc3, + 0x5e, 0xb0, 0xca, 0x7d, 0xde, 0xd4, 0xe6, 0x9d, 0x9c, 0x70, 0x92, 0xa3, 0x3f, 0x3f, 0x5f, 0xdf, + 0xbc, 0x93, 0xb5, 0xd7, 0xcf, 0x98, 0x3f, 0xfc, 0xba, 0x33, 0x95, 0x1f, 0x3b, 0x53, 0x41, 0xbf, + 0x00, 0x1c, 0x7d, 0x14, 0x64, 0x19, 0xf9, 0x9f, 0x52, 0x82, 0x05, 0x3d, 0x87, 0xb3, 0xa0, 0x5a, + 0x64, 0x71, 0xb7, 0xed, 0x91, 0x7b, 0xd7, 0xd4, 0x26, 0x94, 0x73, 0x8b, 0x2c, 0x46, 0x5e, 0x4b, + 0x69, 0x4b, 0xa8, 0x15, 0x9d, 0x67, 0x4d, 0x68, 0x1e, 0x64, 0x51, 0x2a, 0x22, 0xce, 0x74, 0xb5, + 0x33, 0xb4, 0x41, 0xc6, 0x27, 0xc3, 0x3d, 0x0d, 0xf2, 0x86, 0x12, 0x7c, 0x7f, 0xc1, 0xb4, 0x17, + 0xf0, 0x2a, 0xe0, 0x84, 0xea, 0x57, 0x96, 0x3a, 0x7d, 0xec, 0x0e, 0x9a, 0xda, 0xbc, 0xed, 0x1f, + 0x42, 0x28, 0xf2, 0x3a, 0xf2, 0x92, 0xdb, 0x5d, 0xfc, 0x3e, 0x18, 0x60, 0x7f, 0x30, 0xc0, 0xbf, + 0x83, 0x01, 0xbe, 0x1d, 0x0d, 0x65, 0x7f, 0x34, 0x94, 0xbf, 0x47, 0x43, 0xf9, 0xfc, 0x32, 0x8c, + 0xc4, 0xb6, 0xf0, 0xed, 0x80, 0x27, 0xce, 0xf9, 0xd8, 0x24, 0x17, 0xb8, 0x5d, 0xe3, 0x7c, 0x69, + 0xef, 0x2e, 0xaa, 0x94, 0xe6, 0xfe, 0x75, 0xf7, 0x75, 0x6f, 0xff, 0x07, 0x00, 0x00, 0xff, 0xff, + 0x14, 0xbf, 0xf4, 0x48, 0x13, 0x02, 0x00, 0x00, +} + +func (m *PlannedProposal) 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 *PlannedProposal) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PlannedProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Content != nil { + { + size, err := m.Content.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGov(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.Height != 0 { + i = encodeVarintGov(dAtA, i, uint64(m.Height)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *StdLibUpdateProposal) 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 *StdLibUpdateProposal) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StdLibUpdateProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Code) > 0 { + for iNdEx := len(m.Code) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Code[iNdEx]) + copy(dAtA[i:], m.Code[iNdEx]) + i = encodeVarintGov(dAtA, i, uint64(len(m.Code[iNdEx]))) + i-- + dAtA[i] = 0x22 + } + } + if len(m.UpdateDescription) > 0 { + i -= len(m.UpdateDescription) + copy(dAtA[i:], m.UpdateDescription) + i = encodeVarintGov(dAtA, i, uint64(len(m.UpdateDescription))) + i-- + dAtA[i] = 0x1a + } + if len(m.Url) > 0 { + i -= len(m.Url) + copy(dAtA[i:], m.Url) + i = encodeVarintGov(dAtA, i, uint64(len(m.Url))) + i-- + dAtA[i] = 0x12 + } + return len(dAtA) - i, nil +} + +func encodeVarintGov(dAtA []byte, offset int, v uint64) int { + offset -= sovGov(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *PlannedProposal) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Height != 0 { + n += 1 + sovGov(uint64(m.Height)) + } + if m.Content != nil { + l = m.Content.Size() + n += 1 + l + sovGov(uint64(l)) + } + return n +} + +func (m *StdLibUpdateProposal) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Url) + if l > 0 { + n += 1 + l + sovGov(uint64(l)) + } + l = len(m.UpdateDescription) + if l > 0 { + n += 1 + l + sovGov(uint64(l)) + } + if len(m.Code) > 0 { + for _, b := range m.Code { + l = len(b) + n += 1 + l + sovGov(uint64(l)) + } + } + return n +} + +func sovGov(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGov(x uint64) (n int) { + return sovGov(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *PlannedProposal) 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 ErrIntOverflowGov + } + 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: PlannedProposal: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PlannedProposal: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + } + m.Height = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Height |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Content", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGov + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGov + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Content == nil { + m.Content = &types.Any{} + } + if err := m.Content.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGov(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGov + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *StdLibUpdateProposal) 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 ErrIntOverflowGov + } + 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: StdLibUpdateProposal: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StdLibUpdateProposal: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Url", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGov + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGov + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Url = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UpdateDescription", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGov + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGov + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.UpdateDescription = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Code", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthGov + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthGov + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Code = append(m.Code, make([]byte, postIndex-iNdEx)) + copy(m.Code[len(m.Code)-1], dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGov(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGov + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGov(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGov + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGov + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGov + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGov + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGov + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGov + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGov = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGov = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGov = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/vm/types/gov_planned_proposal.go b/x/vm/types/gov_planned_proposal.go new file mode 100644 index 0000000..d3b3f5e --- /dev/null +++ b/x/vm/types/gov_planned_proposal.go @@ -0,0 +1,122 @@ +package types + +import ( + "fmt" + "strings" + + "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + govTypes "github.com/cosmos/cosmos-sdk/x/gov/types" + "github.com/gogo/protobuf/proto" +) + +const ( + ProposalTypeVMPlanned = "VMPlannedProposal" +) + +var ( + _ govTypes.Content = (*PlannedProposal)(nil) +) + +// GetTitle implements govTypes.Content. +func (m PlannedProposal) GetTitle() string { + return "VM planned proposal: " + m.GetContent().GetTitle() +} + +// GetDescription implements govTypes.Content. +func (m PlannedProposal) GetDescription() string { + return m.GetContent().GetDescription() +} + +// ProposalRoute implements govTypes.Content. +func (m PlannedProposal) ProposalRoute() string { + return RouterKey +} + +// ProposalType implements govTypes.Content. +func (m PlannedProposal) ProposalType() string { + return ProposalTypeVMPlanned +} + +// ValidateBasic implements govTypes.Content. +func (m PlannedProposal) ValidateBasic() error { + if m.Height <= 0 { + return fmt.Errorf( "height: should be GT 0") + } + + if m.Content == nil { + return fmt.Errorf( "content: nil") + } + content, ok := m.Content.GetCachedValue().(govTypes.Content) + if !ok { + return fmt.Errorf( "content: %T does not implement govTypes.Content", m.Content) + } + + if err := content.ValidateBasic(); err != nil { + return fmt.Errorf( "content: invalid: %w", err) + } + + switch content.ProposalType() { + case ProposalTypeStdlibUpdate: + default: + return fmt.Errorf( "content: unknown ProposalType: %s", content.ProposalType()) + } + + return nil +} + +// String implements govTypes.Content. +func (m PlannedProposal) String() string { + b := strings.Builder{} + b.WriteString("PlannedProposal:\n") + b.WriteString(fmt.Sprintf(" BlockHeight: %d\n", m.Height)) + + if content := m.GetContent(); content != nil { + b.WriteString(fmt.Sprintf(" Content: %s", content.String())) + } else { + b.WriteString(" Content: nil") + } + + return b.String() +} + +// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces +func (m PlannedProposal) UnpackInterfaces(unpacker types.AnyUnpacker) error { + var content govTypes.Content + return unpacker.UnpackAny(m.Content, &content) +} + +// ShouldExecute checks if proposal should be executed now. +func (m PlannedProposal) ShouldExecute(ctx sdk.Context) bool { + return ctx.BlockHeight() >= m.Height +} + +// GetContent returns the proposal Content. +func (m PlannedProposal) GetContent() govTypes.Content { + content, ok := m.Content.GetCachedValue().(govTypes.Content) + if !ok { + return nil + } + + return content +} + +// NewPlannedProposal creates a new Plan object. +func NewPlannedProposal(blockHeight int64, content govTypes.Content) (*PlannedProposal, error) { + p := &PlannedProposal{ + Height: blockHeight, + } + + protoMsg, ok := content.(proto.Message) + if !ok { + return nil, fmt.Errorf("content: %T does not implement proto.Message", content) + } + + protoAny, err := types.NewAnyWithValue(protoMsg) + if err != nil { + return nil, fmt.Errorf("content: converting to ProtoAny: %w", err) + } + p.Content = protoAny + + return p, nil +} diff --git a/x/vm/types/gov_planned_proposal_test.go b/x/vm/types/gov_planned_proposal_test.go new file mode 100644 index 0000000..943cb06 --- /dev/null +++ b/x/vm/types/gov_planned_proposal_test.go @@ -0,0 +1,45 @@ +package types + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestVM_PlannedProposal(t *testing.T) { + // ok + { + content := NewStdLibUpdateProposal("http://github.com/repo", "test", []byte{1}) + p, err := NewPlannedProposal(1, content) + require.NoError(t, err) + require.NoError(t, p.ValidateBasic()) + } + + // fail: height: < 0 + { + content := NewStdLibUpdateProposal("http://github.com/repo", "test", []byte{1}) + p, err := NewPlannedProposal(-1, content) + require.NoError(t, err) + require.Error(t, p.ValidateBasic()) + } + + // fail: content: nil + { + _, err := NewPlannedProposal(1, nil) + require.Error(t, err) + } + + // fail: content: non-ProtoMessage + { + _, err := NewPlannedProposal(1, StdLibUpdateProposal{}) + require.Error(t, err) + } + + // fail: content: invalid + { + content := NewStdLibUpdateProposal("http://github.com/repo", "", []byte{1}) + p, err := NewPlannedProposal(1, content) + require.NoError(t, err) + require.Error(t, p.ValidateBasic()) + } +} diff --git a/x/vm/types/gov_stdlib_update.go b/x/vm/types/gov_stdlib_update.go new file mode 100644 index 0000000..7aea09f --- /dev/null +++ b/x/vm/types/gov_stdlib_update.go @@ -0,0 +1,75 @@ +package types + +import ( + "fmt" + "net/url" + "strings" + + sdkErrors "github.com/cosmos/cosmos-sdk/types/errors" + govTypes "github.com/cosmos/cosmos-sdk/x/gov/types" +) + +const ( + ProposalTypeStdlibUpdate = "StdlibUpdate" +) + +var ( + _ govTypes.Content = (*StdLibUpdateProposal)(nil) +) + +// GetTitle implements govTypes.Content (wrapped by PlannedProposal). +func (m StdLibUpdateProposal) GetTitle() string { return "DVM stdlib update" } + +// GetDescription implements govTypes.Content (wrapped by PlannedProposal). +func (m StdLibUpdateProposal) GetDescription() string { return "Updates DVM stdlib code" } + +// ProposalRoute implements govTypes.Content (wrapped by PlannedProposal). +func (m StdLibUpdateProposal) ProposalRoute() string { return RouterKey } + +// ProposalType implements govTypes.Content (wrapped by PlannedProposal). +func (m StdLibUpdateProposal) ProposalType() string { return ProposalTypeStdlibUpdate } + +// ValidateBasic implements govTypes.Content (wrapped by PlannedProposal). +func (m StdLibUpdateProposal) ValidateBasic() error { + if m.Url == "" { + return sdkErrors.Wrapf(ErrGovInvalidProposal, "url: empty") + } + if _, err := url.Parse(m.Url); err != nil { + return sdkErrors.Wrapf(ErrGovInvalidProposal, "url: %v", err) + } + if m.UpdateDescription == "" { + return sdkErrors.Wrapf(ErrGovInvalidProposal, "update_description: empty") + } + + if len(m.Code) == 0 { + return sdkErrors.Wrapf(ErrGovInvalidProposal, "code: empty") + } + for i, code := range m.Code { + if len(code) == 0 { + return sdkErrors.Wrapf(ErrGovInvalidProposal, "code [%d]: empty", i) + } + } + + return nil +} + +// String implements govTypes.Content (wrapped by PlannedProposal). +func (m StdLibUpdateProposal) String() string { + b := strings.Builder{} + b.WriteString("Proposal:\n") + b.WriteString(fmt.Sprintf(" Title: %s\n", m.GetTitle())) + b.WriteString(fmt.Sprintf(" Description: %s\n", m.GetDescription())) + b.WriteString(fmt.Sprintf(" Source URL: %s\n", m.Url)) + b.WriteString(fmt.Sprintf(" Update description: %s", m.UpdateDescription)) + + return b.String() +} + +// NewStdLibUpdateProposal creates a StdLibUpdateProposal object. +func NewStdLibUpdateProposal(url, updateDescription string, byteCode ...[]byte) govTypes.Content { + return &StdLibUpdateProposal{ + Url: url, + UpdateDescription: updateDescription, + Code: byteCode, + } +} diff --git a/x/vm/types/gov_stdlib_update_test.go b/x/vm/types/gov_stdlib_update_test.go new file mode 100644 index 0000000..935b1fb --- /dev/null +++ b/x/vm/types/gov_stdlib_update_test.go @@ -0,0 +1,45 @@ +package types + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestVM_StdLibUpdateProposal(t *testing.T) { + // ok + { + p := NewStdLibUpdateProposal("http://github.com/repo", "tst", []byte{1}) + require.NoError(t, p.ValidateBasic()) + } + + // fail: url: empty + { + p := NewStdLibUpdateProposal("", "tst", []byte{1}) + require.Error(t, p.ValidateBasic()) + } + + // fail: url: invalid + { + p := NewStdLibUpdateProposal("1://repo", "tst", []byte{1}) + require.Error(t, p.ValidateBasic()) + } + + // fail: description: empty + { + p := NewStdLibUpdateProposal("http://github.com/repo", "", []byte{1}) + require.Error(t, p.ValidateBasic()) + } + + // fail: byteCode: empty + { + p := NewStdLibUpdateProposal("http://github.com/repo", "tst", nil) + require.Error(t, p.ValidateBasic()) + } + + // fail: byteCode: empty + { + p := NewStdLibUpdateProposal("http://github.com/repo", "tst", []byte{1}, nil) + require.Error(t, p.ValidateBasic()) + } +} diff --git a/x/vm/types/grpc_utils_request.go b/x/vm/types/grpc_utils_request.go new file mode 100644 index 0000000..7bc23c7 --- /dev/null +++ b/x/vm/types/grpc_utils_request.go @@ -0,0 +1,49 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + dvmTypes "github.com/dfinance/dstation/pkg/types/dvm" +) + +// NewVMPublishModuleRequest builds a new dvmTypes.VMPublishModule VM request. +func NewVMPublishModuleRequests(ctx sdk.Context, signerAddrRaw string, code []byte) *dvmTypes.VMPublishModule { + return &dvmTypes.VMPublishModule{ + Sender: MustBech32ToLibra(signerAddrRaw), + MaxGasAmount: getVMLimitedGas(ctx), + GasUnitPrice: VmGasPrice, + Code: code, + } +} + +// NewVMExecuteScriptRequest builds a new dvmTypes.VMExecuteScript VM request. +func NewVMExecuteScriptRequest(ctx sdk.Context, signerAddrRaw string, code []byte, args ...MsgExecuteScript_ScriptArg) *dvmTypes.VMExecuteScript { + vmArgs := make([]*dvmTypes.VMArgs, 0, len(args)) + for _, arg := range args { + vmArgs = append(vmArgs, &dvmTypes.VMArgs{ + Type: arg.Type, + Value: arg.Value, + }) + } + + return &dvmTypes.VMExecuteScript{ + Senders: [][]byte{MustBech32ToLibra(signerAddrRaw)}, + MaxGasAmount: getVMLimitedGas(ctx), + GasUnitPrice: VmGasPrice, + Block: uint64(ctx.BlockHeight()), + Timestamp: uint64(ctx.BlockTime().Unix()), + Code: code, + TypeParams: nil, + Args: vmArgs, + } +} + +// getVMLimitedGas returns gas limit which is LTE VM max limit. +func getVMLimitedGas(ctx sdk.Context) sdk.Gas { + gas := ctx.GasMeter().Limit() - ctx.GasMeter().GasConsumed() + if gas > VmGasLimit { + return VmGasLimit + } + + return gas +} diff --git a/x/vm/types/grpc_utils_string.go b/x/vm/types/grpc_utils_string.go new file mode 100644 index 0000000..6e2b5ef --- /dev/null +++ b/x/vm/types/grpc_utils_string.go @@ -0,0 +1,410 @@ +package types + +import ( + "bytes" + "encoding/hex" + "fmt" + "strconv" + "strings" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/tendermint/tendermint/libs/log" + + dvmTypes "github.com/dfinance/dstation/pkg/types/dvm" +) + +const ( + // + VmGasPrice = 1 // gas unit price for VM execution + VmGasLimit = ^uint64(0)/1000 - 1 // gas limit for VM execution + + // VM Event to sdk.Event conversion params + EventTypeProcessingGas = 10000 // initial gas for processing event type. + EventTypeNoGasLevels = 2 // defines number of nesting levels that do not charge gas +) + +// StringifyVMAccessPath converts dvmTypes.VMAccessPath to HEX string. +func StringifyVMAccessPath(path *dvmTypes.VMAccessPath) string { + if path == nil { + return "nil" + } + + return fmt.Sprintf("Access path:\n"+ + " Address: %s\n"+ + " Path: %s\n"+ + " Key: %s", + hex.EncodeToString(path.Address), + hex.EncodeToString(path.Path), + hex.EncodeToString(GetVMStorageKey(path)), + ) +} + +// StringifyVMTypeTag convert dvmTypes.VMTypeTag to string representation. +func StringifyVMTypeTag(tag dvmTypes.VMTypeTag) (string, error) { + if val, ok := dvmTypes.VMTypeTag_name[int32(tag)]; !ok { + return "", fmt.Errorf("can't find string representation of VMTypeTag %d, check correctness of type value", tag) + } else { + return val, nil + } +} + +// StringifyVMTypeTagPanic wraps StringifyVMTypeTag and panics on error. +func StringifyVMTypeTagPanic(tag dvmTypes.VMTypeTag) string { + val, err := StringifyVMTypeTag(tag) + if err != nil { + panic(err) + } + + return val +} + +// StringifyVMLCSTag converts dvmTypes.LcsTag to string representation (recursive). +// defines number of prefixed indent string for each line. +func StringifyVMLCSTag(tag *dvmTypes.LcsTag, indentCount ...int) (string, error) { + const strIndent = " " + + curIndentCount := 0 + if len(indentCount) > 1 { + return "", fmt.Errorf("invalid indentCount length") + } + if len(indentCount) == 1 { + curIndentCount = indentCount[0] + } + if curIndentCount < 0 { + return "", fmt.Errorf("invalid indentCount") + } + + strBuilder := strings.Builder{} + + // Helper funcs + buildStrIndent := func() string { + str := "" + for i := 0; i < curIndentCount; i++ { + str += strIndent + } + return str + } + + buildErr := func(comment string, err error) error { + return fmt.Errorf("indent %d: %s: %w", curIndentCount, comment, err) + } + + buildLcsTypeStr := func(t dvmTypes.LcsType) (string, error) { + val, ok := dvmTypes.LcsType_name[int32(t)] + if !ok { + return "", fmt.Errorf("can't find string representation of LcsTag %d, check correctness of type value", t) + } + return val, nil + } + + // Print current tag with recursive func call for fields + if tag == nil { + strBuilder.WriteString("nil") + return strBuilder.String(), nil + } + + indentStr := buildStrIndent() + strBuilder.WriteString("LcsTag:\n") + + // Field: TypeTag + typeTagStr, err := buildLcsTypeStr(tag.TypeTag) + if err != nil { + return "", buildErr("TypeTag", err) + } + strBuilder.WriteString(fmt.Sprintf("%sTypeTag: %s\n", indentStr, typeTagStr)) + + // Field: VectorType + vectorTypeStr, err := StringifyVMLCSTag(tag.VectorType, curIndentCount+1) + if err != nil { + return "", buildErr("VectorType", err) + } + strBuilder.WriteString(fmt.Sprintf("%sVectorType: %s\n", indentStr, vectorTypeStr)) + + // Field: StructIdent + if tag.StructIdent != nil { + strBuilder.WriteString(fmt.Sprintf("%sStructIdent.Address: %s\n", indentStr, hex.EncodeToString(tag.StructIdent.Address))) + strBuilder.WriteString(fmt.Sprintf("%sStructIdent.Module: %s\n", indentStr, tag.StructIdent.Module)) + strBuilder.WriteString(fmt.Sprintf("%sStructIdent.Name: %s\n", indentStr, tag.StructIdent.Name)) + if len(tag.StructIdent.TypeParams) > 0 { + for structParamIdx, structParamTag := range tag.StructIdent.TypeParams { + structParamTagStr, err := StringifyVMLCSTag(structParamTag, curIndentCount+1) + if err != nil { + return "", buildErr(fmt.Sprintf("StructIdent.TypeParams[%d]", structParamIdx), err) + } + strBuilder.WriteString(fmt.Sprintf("%sStructIdent.TypeParams[%d]: %s", indentStr, structParamIdx, structParamTagStr)) + if structParamIdx < len(tag.StructIdent.TypeParams)-1 { + strBuilder.WriteString("\n") + } + } + } else { + strBuilder.WriteString(fmt.Sprintf("%sStructIdent.TypeParams: empty", indentStr)) + } + } else { + strBuilder.WriteString(fmt.Sprintf("%sStructIdent: nil", indentStr)) + } + + return strBuilder.String(), nil +} + +// StringifyVMLCSTagPanic wraps StringifyVMLCSTag and panics on error. +func StringifyVMLCSTagPanic(tag *dvmTypes.LcsTag, indentCount ...int) string { + val, err := StringifyVMLCSTag(tag, indentCount...) + if err != nil { + panic(err) + } + + return val +} + +// StringifyVMWriteOp converts dvmTypes.VmWriteOp to string representation. +func StringifyVMWriteOp(wOp dvmTypes.VmWriteOp) string { + switch wOp { + case dvmTypes.VmWriteOp_Value: + return "write" + case dvmTypes.VmWriteOp_Deletion: + return "del" + default: + return "unknown" + } +} + +// StringifyVMValue converts dvmTypes.VMValue (writeSet) to string representation. +func StringifyVMValue(value *dvmTypes.VMValue) string { + if value == nil { + return "nil" + } + + return fmt.Sprintf("\nWriteSet %q:\n"+ + " Address: %s\n"+ + " Path: %s\n"+ + " Value: %s", + StringifyVMWriteOp(value.Type), + hex.EncodeToString(value.Path.Address), + hex.EncodeToString(value.Path.Path), + hex.EncodeToString(value.Value), + ) +} + +// StringifyVMStatus converts dvmTypes.VMStatus (execution result) to string representation. +func StringifyVMStatus(status *dvmTypes.VMStatus) string { + strBuilder := strings.Builder{} + strBuilder.WriteString(fmt.Sprintf("Exec %q status:\n", status.String())) + + if status != nil { + majorStatus, subStatus, _ := GetStatusCodesFromVMStatus(status) + + strBuilder.WriteString(fmt.Sprintf(" Major code: %d\n", majorStatus)) + strBuilder.WriteString(fmt.Sprintf(" Major status: %s\n", StringifyVMStatusMajorCode(strconv.FormatUint(majorStatus, 10)))) + strBuilder.WriteString(fmt.Sprintf(" Sub code: %d\n", subStatus)) + strBuilder.WriteString(fmt.Sprintf(" Message: %s", status.GetMessage())) + } else { + strBuilder.WriteString(" VMStatus: nil") + } + + return strBuilder.String() +} + +// StringifyVMEvent converts dvmTypes.VMEvent to string representation. +func StringifyVMEvent(event *dvmTypes.VMEvent) string { + strBuilder := strings.Builder{} + + if event == nil { + strBuilder.WriteString("nil") + return strBuilder.String() + } + strBuilder.WriteString("\n") + + strBuilder.WriteString("Event:\n") + strBuilder.WriteString(fmt.Sprintf(" SenderAddress: %s\n", hex.EncodeToString(event.SenderAddress))) + if event.SenderModule != nil { + strBuilder.WriteString(fmt.Sprintf(" SenderModule.Address: %s\n", hex.EncodeToString(event.SenderModule.Address))) + strBuilder.WriteString(fmt.Sprintf(" SenderModule.Name: %s\n", event.SenderModule.Name)) + } else { + strBuilder.WriteString(" SenderModule: nil\n") + } + strBuilder.WriteString(fmt.Sprintf(" EventType: %s\n", StringifyVMLCSTagPanic(event.EventType, 2))) + strBuilder.WriteString(fmt.Sprintf(" EventData: %s", hex.EncodeToString(event.EventData))) + + return strBuilder.String() +} + +// StringifyEventType returns dvmTypes.LcsTag Move serialization. +// Func is similar to StringifyVMLCSTag, but result is one lined Move representation. +func StringifyEventType(gasMeter sdk.GasMeter, tag *dvmTypes.LcsTag) (string, error) { + // Start with initial gas for first event, and then go in progression based on depth. + return processEventType(gasMeter, tag, EventTypeProcessingGas, 1) +} + +// StringifyEventTypePanic wraps StringifyEventType and panic on error. +func StringifyEventTypePanic(gasMeter sdk.GasMeter, tag *dvmTypes.LcsTag) string { + eventType, eventTypeErr := StringifyEventType(gasMeter, tag) + if eventTypeErr != nil { + debugMsg := "" + if tagStr, tagErr := StringifyVMLCSTag(tag); tagErr != nil { + debugMsg = fmt.Sprintf("StringifyVMLCSTag failed: %v", tagErr) + } else { + debugMsg = tagStr + } + + panicErr := fmt.Sprintf("EventType serialization failed: %v\n%s", eventTypeErr, debugMsg) + panic(panicErr) + } + + return eventType +} + +// StringifySenderAddress converts VM address to string (0x1 for stdlib and wallet1... otherwise). +func StringifySenderAddress(addr []byte) string { + if bytes.Equal(addr, StdLibAddress) { + return StdLibAddressShortStr + } else { + return sdk.AccAddress(addr).String() + } +} + +// PrintVMStackTrace prints VM stack trace if contract is not executed successfully. +func PrintVMStackTrace(txId []byte, log log.Logger, exec *dvmTypes.VMExecuteResponse) { + strBuilder := strings.Builder{} + + strBuilder.WriteString(fmt.Sprintf("Stack trace %X:\n", txId)) + + // Print common status + if len(exec.Events) > 0 { + for eventIdx, event := range exec.Events { + strBuilder.WriteString(fmt.Sprintf("Events[%d]: %s\n", eventIdx, StringifyVMEvent(event))) + } + } else { + strBuilder.WriteString("Events: empty\n") + } + + // Print all writeSets + if len(exec.WriteSet) > 0 { + for wsIdx, ws := range exec.WriteSet { + strBuilder.WriteString(fmt.Sprintf("WriteSet[%d]: %s", wsIdx, StringifyVMValue(ws))) + } + } else { + strBuilder.WriteString("WriteSet: empty") + } + + log.Debug(strBuilder.String()) +} + +// GetVMTypeTagByString converts {typeTag} gRPC enum string representation to dvmTypes.VMTypeTag. +func GetVMTypeTagByString(typeTag string) (dvmTypes.VMTypeTag, error) { + if val, ok := dvmTypes.VMTypeTag_value[typeTag]; !ok { + return -1, fmt.Errorf("can't find tag VMTypeTag %s, check correctness of type value", typeTag) + } else { + return dvmTypes.VMTypeTag(val), nil + } +} + +// GetStatusCodesFromVMStatus extracts majorStatus, subStatus and abortLocation from dvmTypes.VMStatus +// panic if error exist but error object == nil +func GetStatusCodesFromVMStatus(status *dvmTypes.VMStatus) (majorStatus, subStatus uint64, location *dvmTypes.AbortLocation) { + switch sErr := status.GetError().(type) { + case *dvmTypes.VMStatus_Abort: + majorStatus = VMAbortedCode + if sErr.Abort == nil { + panic(fmt.Errorf("getting status codes: VMStatus_Abort.Abort is nil")) + } + subStatus = sErr.Abort.GetAbortCode() + if l := sErr.Abort.GetAbortLocation(); l != nil { + location = l + } + case *dvmTypes.VMStatus_ExecutionFailure: + if sErr.ExecutionFailure == nil { + panic(fmt.Errorf("getting status codes: VMStatus_ExecutionFailure.ExecutionFailure is nil")) + } + majorStatus = sErr.ExecutionFailure.GetStatusCode() + if l := sErr.ExecutionFailure.GetAbortLocation(); l != nil { + location = l + } + case *dvmTypes.VMStatus_MoveError: + if sErr.MoveError == nil { + panic(fmt.Errorf("getting status codes: VMStatus_MoveError.MoveError is nil")) + } + majorStatus = sErr.MoveError.GetStatusCode() + case nil: + majorStatus = VMExecutedCode + } + + return +} + +// processEventType recursively processes event type and returns result event type as a string. +// If {depth} < 0 we do not charge gas as some nesting levels might be "free". +func processEventType(gasMeter sdk.GasMeter, tag *dvmTypes.LcsTag, gas, depth uint64) (string, error) { + // We can't consume gas later (after recognizing the type), because it open doors for security holes. + // Let's say dev will create type with a lot of generics, so transaction will take much more time to process. + // In result it could be a situation when validator doesn't have enough time to process transaction. + // Charging gas amount is geometry increased from depth to depth. + + if depth > EventTypeNoGasLevels { + gas += EventTypeProcessingGas * (depth - EventTypeNoGasLevels - 1) + gasMeter.ConsumeGas(gas, "event type processing") + } + + if tag == nil { + return "", nil + } + + // Helper function: lcsTypeToString returns dvmTypes.LcsType Move representation + lcsTypeToString := func(lcsType dvmTypes.LcsType) string { + switch lcsType { + case dvmTypes.LcsType_LcsBool: + return "bool" + case dvmTypes.LcsType_LcsU8: + return "u8" + case dvmTypes.LcsType_LcsU64: + return "u64" + case dvmTypes.LcsType_LcsU128: + return "u128" + case dvmTypes.LcsType_LcsSigner: + return "signer" + case dvmTypes.LcsType_LcsVector: + return "vector" + case dvmTypes.LcsType_LcsStruct: + return "struct" + default: + return dvmTypes.LcsType_name[int32(lcsType)] + } + } + + // Check data consistency + if tag.TypeTag == dvmTypes.LcsType_LcsVector && tag.VectorType == nil { + return "", fmt.Errorf("TypeTag of type %q, but VectorType is nil", lcsTypeToString(tag.TypeTag)) + } + if tag.TypeTag == dvmTypes.LcsType_LcsStruct && tag.StructIdent == nil { + return "", fmt.Errorf("TypeTag of type %q, but StructIdent is nil", lcsTypeToString(tag.TypeTag)) + } + + // Vector tag + if tag.VectorType != nil { + vectorType, err := processEventType(gasMeter, tag.VectorType, gas, depth+1) + if err != nil { + return "", fmt.Errorf("VectorType serialization: %w", err) + } + return fmt.Sprintf("%s<%s>", lcsTypeToString(dvmTypes.LcsType_LcsVector), vectorType), nil + } + + // Struct tag + if tag.StructIdent != nil { + structType := fmt.Sprintf("%s::%s::%s", StringifySenderAddress(tag.StructIdent.Address), tag.StructIdent.Module, tag.StructIdent.Name) + if len(tag.StructIdent.TypeParams) == 0 { + return structType, nil + } + + structParams := make([]string, 0, len(tag.StructIdent.TypeParams)) + for paramIdx, paramTag := range tag.StructIdent.TypeParams { + structParam, err := processEventType(gasMeter, paramTag, gas, depth+1) + if err != nil { + return "", fmt.Errorf("StructIdent serialization: TypeParam[%d]: %w", paramIdx, err) + } + structParams = append(structParams, structParam) + } + return fmt.Sprintf("%s<%s>", structType, strings.Join(structParams, ", ")), nil + } + + // Single tag + return lcsTypeToString(tag.TypeTag), nil +} diff --git a/x/vm/types/grpc_utils_types.go b/x/vm/types/grpc_utils_types.go new file mode 100644 index 0000000..6cd7178 --- /dev/null +++ b/x/vm/types/grpc_utils_types.go @@ -0,0 +1,58 @@ +package types + +import ( + "fmt" + "math/big" + + sdk "github.com/cosmos/cosmos-sdk/types" + + dvmTypes "github.com/dfinance/dstation/pkg/types/dvm" +) + +// SdkIntToVmU128 converts sdk.Int to dvmTypes.U128. +func SdkIntToVmU128(value sdk.Int) (*dvmTypes.U128, error) { + if value.IsNegative() { + return nil, fmt.Errorf("sdk.Int is negative (not Uint): %s", value.String()) + } + + return SdkUintToVmU128(sdk.NewUintFromBigInt(value.BigInt())) +} + +// SdkUintToVmU128 converts sdk.Uint to dvmTypes.U128. +func SdkUintToVmU128(value sdk.Uint) (*dvmTypes.U128, error) { + if value.BigInt().BitLen() > 128 { + return nil, fmt.Errorf("invalid bitLen %d", value.BigInt().BitLen()) + } + + // BigInt().Bytes() returns BigEndian format, reverse it + valueBytes := value.BigInt().Bytes() + for left, right := 0, len(valueBytes)-1; left < right; left, right = left+1, right-1 { + valueBytes[left], valueBytes[right] = valueBytes[right], valueBytes[left] + } + + // Extend to 16 bytes + if len(valueBytes) < 16 { + zeros := make([]byte, 16-len(valueBytes)) + valueBytes = append(valueBytes, zeros...) + } + + return &dvmTypes.U128{Buf: valueBytes}, nil +} + +// VmU128ToSdkInt converts dvmTypes.U128 to sdk.Int. +func VmU128ToSdkInt(value *dvmTypes.U128) sdk.Int { + if value == nil || len(value.Buf) == 0 { + return sdk.ZeroInt() + } + + // BigInt is BigEndian, convert U128 Little to Big + for left, right := 0, len(value.Buf)-1; left < right; left, right = left+1, right-1 { + value.Buf[left], value.Buf[right] = value.Buf[right], value.Buf[left] + } + + // New big.Int + bigValue := big.NewInt(0) + bigValue.SetBytes(value.Buf) + + return sdk.NewIntFromBigInt(bigValue) +} diff --git a/x/vm/types/grpc_utils_types_test.go b/x/vm/types/grpc_utils_types_test.go new file mode 100644 index 0000000..8d7f129 --- /dev/null +++ b/x/vm/types/grpc_utils_types_test.go @@ -0,0 +1,125 @@ +package types + +import ( + "encoding/binary" + "encoding/hex" + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + + dvmTypes "github.com/dfinance/dstation/pkg/types/dvm" +) + +func TestVM_SdkIntToVmU128(t *testing.T) { + // ok: 0x0 + { + value := uint16(0x0) + res, err := SdkIntToVmU128(sdk.NewInt(int64(value))) + require.NoError(t, err) + checkU128(t, value, res) + } + + // ok: 0x1 + { + value := uint16(0x1) + res, err := SdkIntToVmU128(sdk.NewInt(int64(value))) + require.NoError(t, err) + checkU128(t, value, res) + } + + // fail: < 0 + { + _, err := SdkIntToVmU128(sdk.NewInt(-1)) + require.Error(t, err) + } +} + +func TestVM_SdkUintToVmU128(t *testing.T) { + // ok: 0x0 + { + value := uint16(0x0) + res, err := SdkUintToVmU128(sdk.NewUint(uint64(value))) + require.NoError(t, err) + checkU128(t, value, res) + } + + // ok: 0x1 + { + value := uint16(0x1) + res, err := SdkUintToVmU128(sdk.NewUint(uint64(value))) + require.NoError(t, err) + checkU128(t, value, res) + } + + // ok: 0xFFF + { + value := uint16(0xFFF) + res, err := SdkUintToVmU128(sdk.NewUint(uint64(value))) + require.NoError(t, err) + checkU128(t, value, res) + } + + // ok: 0x1FFF + { + value := uint16(0x1FFF) + res, err := SdkUintToVmU128(sdk.NewUint(uint64(value))) + require.NoError(t, err) + checkU128(t, value, res) + } + + // fail: > 16 bytes + { + value := sdk.NewUintFromString("12345678901234567890123456789012345678901234567890") + _, err := SdkUintToVmU128(value) + require.Error(t, err) + } +} + +func TestVM_VmU128ToSdkInt(t *testing.T) { + // nil + { + intValue := VmU128ToSdkInt(nil) + + require.EqualValues(t, 0, intValue.Int64()) + require.False(t, intValue.IsNegative()) + } + + // 1 byte + { + u128Value := &dvmTypes.U128{ + Buf: []byte{0xFF}, + } + intValue := VmU128ToSdkInt(u128Value) + + require.EqualValues(t, 255, intValue.Int64()) + require.False(t, intValue.IsNegative()) + } + + // 4293844428 [0xFF, 0xEE, 0xDD, 0xCC] + { + u128Value := &dvmTypes.U128{ + Buf: []byte{0xCC, 0xDD, 0xEE, 0xFF}, + } + intValue := VmU128ToSdkInt(u128Value) + + require.EqualValues(t, 4293844428, intValue.Int64()) + require.False(t, intValue.IsNegative()) + } +} + +func checkU128(t *testing.T, inValue uint16, outValue *dvmTypes.U128) { + require.NotNil(t, outValue) + require.Len(t, outValue.Buf, 16) + + inValueBytes := make([]byte, 2) + binary.LittleEndian.PutUint16(inValueBytes, inValue) + for i := 0; i < 16; i++ { + inValueByte := byte(0x0) + if i < len(inValueBytes) { + inValueByte = inValueBytes[i] + } + + require.Equal(t, inValueByte, outValue.Buf[i], "in / out at index [%d]: %s / %s", i, hex.EncodeToString(inValueBytes), hex.EncodeToString(outValue.Buf)) + } +} diff --git a/x/vm/types/grpc_utils_vm_status.go b/x/vm/types/grpc_utils_vm_status.go new file mode 100644 index 0000000..92b3125 --- /dev/null +++ b/x/vm/types/grpc_utils_vm_status.go @@ -0,0 +1,303 @@ +package types + +import ( + "encoding/json" + "fmt" + "strings" + + "github.com/cosmos/cosmos-sdk/types" +) + +const ( + // Error codes in JSON format + jsonErrorCodes = ` +{ + "14": "MAX_GAS_UNITS_BELOW_MIN_TRANSACTION_GAS_UNITS", + "3010": "DUPLICATE_TABLE", + "4001": "EXECUTED", + "4016": "ABORTED", + "1": "INVALID_SIGNATURE", + "3": "SEQUENCE_NUMBER_TOO_OLD", + "1072": "DUPLICATE_ACQUIRES_RESOURCE_ANNOTATION_ERROR", + "2017": "UNEXPECTED_VERIFIER_ERROR", + "1046": "CALL_BORROWED_MUTABLE_REFERENCE_ERROR", + "1006": "INVALID_RESOURCE_FIELD", + "2005": "PC_OVERFLOW", + "6": "TRANSACTION_EXPIRED", + "1058": "EQUALITY_OP_TYPE_MISMATCH_ERROR", + "3022": "VALUE_SERIALIZATION_ERROR", + "1023": "POP_RESOURCE_ERROR", + "1056": "INTEGER_OP_TYPE_MISMATCH_ERROR", + "15": "GAS_UNIT_PRICE_BELOW_MIN_BOUND", + "1017": "LOOKUP_FAILED", + "4008": "MISSING_DATA", + "2008": "STORAGE_ERROR", + "1063": "MOVEFROM_NO_RESOURCE_ERROR", + "2006": "VERIFICATION_ERROR", + "1089": "TOO_MANY_LOCALS", + "2009": "INTERNAL_TYPE_ERROR", + "1007": "INVALID_FALL_THROUGH", + "10": "EXCEEDED_MAX_TRANSACTION_SIZE", + "4020": "EXECUTION_STACK_OVERFLOW", + "5": "INSUFFICIENT_BALANCE_FOR_TRANSACTION_FEE", + "1043": "BORROWLOC_UNAVAILABLE_ERROR", + "3020": "BAD_U128", + "7": "SENDING_ACCOUNT_DOES_NOT_EXIST", + "1086": "INVALID_LOOP_BREAK", + "1065": "MOVETO_NO_RESOURCE_ERROR", + "1081": "LINKER_ERROR", + "1000": "UNKNOWN_VERIFICATION_ERROR", + "3002": "BAD_MAGIC", + "3007": "UNKNOWN_OPCODE", + "1045": "CALL_TYPE_MISMATCH_ERROR", + "3008": "BAD_HEADER_TABLE", + "1011": "INVALID_MAIN_FUNCTION_SIGNATURE", + "1048": "UNPACK_TYPE_MISMATCH_ERROR", + "1053": "WRITEREF_RESOURCE_ERROR", + "1030": "RET_TYPE_MISMATCH_ERROR", + "1040": "MOVELOC_UNAVAILABLE_ERROR", + "1005": "RECURSIVE_STRUCT_DEFINITION", + "2021": "TYPE_RESOLUTION_FAILURE", + "4017": "ARITHMETIC_ERROR", + "17": "INVALID_GAS_SPECIFIER", + "18446744073709551615": "UNKNOWN_STATUS", + "1041": "MOVELOC_EXISTS_BORROW_ERROR", + "1020": "TYPE_MISMATCH", + "12": "UNKNOWN_MODULE", + "16": "GAS_UNIT_PRICE_ABOVE_MAX_BOUND", + "1014": "UNIMPLEMENTED_HANDLE", + "11": "UNKNOWN_SCRIPT", + "1003": "INVALID_SIGNATURE_TOKEN", + "1035": "BORROWFIELD_BAD_FIELD_ERROR", + "1084": "EMPTY_CODE_UNIT", + "2018": "UNEXPECTED_DESERIALIZATION_ERROR", + "3000": "UNKNOWN_BINARY_ERROR", + "2019": "FAILED_TO_SERIALIZE_WRITE_SET_CHANGES", + "1026": "ABORT_TYPE_MISMATCH_ERROR", + "22": "NO_ACCOUNT_ROLE", + "1037": "COPYLOC_UNAVAILABLE_ERROR", + "2020": "FAILED_TO_DESERIALIZE_RESOURCE", + "3003": "UNKNOWN_VERSION", + "3014": "UNKNOWN_NATIVE_STRUCT_FLAG", + "4004": "RESOURCE_ALREADY_EXISTS", + "1044": "BORROWLOC_EXISTS_BORROW_ERROR", + "2012": "VM_STARTUP_FAILURE", + "1055": "WRITEREF_NO_MUTABLE_REFERENCE_ERROR", + "13": "MAX_GAS_UNITS_EXCEEDS_MAX_GAS_UNITS_BOUND", + "4002": "OUT_OF_GAS", + "4025": "VM_MAX_VALUE_DEPTH_REACHED", + "2010": "EVENT_KEY_MISMATCH", + "1047": "PACK_TYPE_MISMATCH_ERROR", + "1067": "MODULE_ADDRESS_DOES_NOT_MATCH_SENDER", + "1049": "READREF_TYPE_MISMATCH_ERROR", + "2015": "UNEXPECTED_ERROR_FROM_KNOWN_MOVE_FUNCTION", + "1074": "GLOBAL_REFERENCE_ERROR", + "1057": "BOOLEAN_OP_TYPE_MISMATCH_ERROR", + "19": "UNABLE_TO_DESERIALIZE_ACCOUNT", + "1069": "POSITIVE_STACK_SIZE_AT_BLOCK_END", + "1085": "INVALID_LOOP_SPLIT", + "1062": "MOVEFROM_TYPE_MISMATCH_ERROR", + "1075": "CONSTRAINT_KIND_MISMATCH", + "3019": "BAD_U64", + "1025": "BR_TYPE_MISMATCH_ERROR", + "1001": "INDEX_OUT_OF_BOUNDS", + "1091": "FUNCTION_RESOLUTION_FAILURE", + "3004": "UNKNOWN_TABLE_TYPE", + "1031": "RET_BORROWED_MUTABLE_REFERENCE_ERROR", + "1051": "READREF_EXISTS_MUTABLE_BORROW_ERROR", + "1064": "MOVETO_TYPE_MISMATCH_ERROR", + "1082": "INVALID_CONSTANT_TYPE", + "4003": "RESOURCE_DOES_NOT_EXIST", + "4024": "VM_MAX_TYPE_DEPTH_REACHED", + "1073": "INVALID_ACQUIRES_RESOURCE_ANNOTATION_ERROR", + "1032": "FREEZEREF_TYPE_MISMATCH_ERROR", + "1012": "DUPLICATE_ELEMENT", + "1068": "NO_MODULE_HANDLES", + "4009": "DATA_FORMAT_ERROR", + "1009": "NEGATIVE_STACK_SIZE_WITHIN_BLOCK", + "9": "INVALID_WRITE_SET", + "18": "SENDING_ACCOUNT_FROZEN", + "20": "CURRENCY_INFO_DOES_NOT_EXIST", + "1027": "STLOC_TYPE_MISMATCH_ERROR", + "3006": "UNKNOWN_SERIALIZED_TYPE", + "1021": "MISSING_DEPENDENCY", + "1038": "COPYLOC_RESOURCE_ERROR", + "23": "BAD_CHAIN_ID", + "1076": "NUMBER_OF_TYPE_ARGUMENTS_MISMATCH", + "1087": "INVALID_LOOP_CONTINUE", + "1095": "DUPLICATE_MODULE_NAME", + "1083": "MALFORMED_CONSTANT_DATA", + "3024": "CODE_DESERIALIZATION_ERROR", + "2003": "EMPTY_VALUE_STACK", + "2": "INVALID_AUTH_KEY", + "1039": "COPYLOC_EXISTS_BORROW_ERROR", + "3001": "MALFORMED", + "3023": "VALUE_DESERIALIZATION_ERROR", + "2011": "UNREACHABLE", + "0": "UNKNOWN_VALIDATION_STATUS", + "4": "SEQUENCE_NUMBER_TOO_NEW", + "1052": "WRITEREF_TYPE_MISMATCH_ERROR", + "1060": "BORROWGLOBAL_TYPE_MISMATCH_ERROR", + "2016": "VERIFIER_INVARIANT_VIOLATION", + "4021": "CALL_STACK_OVERFLOW", + "1090": "GENERIC_MEMBER_OPCODE_MISMATCH", + "2000": "UNKNOWN_INVARIANT_VIOLATION_ERROR", + "1042": "BORROWLOC_REFERENCE_ERROR", + "1028": "STLOC_UNSAFE_TO_DESTROY_ERROR", + "1071": "EXTRANEOUS_ACQUIRES_RESOURCE_ANNOTATION_ERROR", + "1094": "INVALID_OPERATION_IN_SCRIPT", + "3009": "UNEXPECTED_SIGNATURE_TYPE", + "1070": "MISSING_ACQUIRES_RESOURCE_ANNOTATION_ERROR", + "1013": "INVALID_MODULE_HANDLE", + "1061": "BORROWGLOBAL_NO_RESOURCE_ERROR", + "1033": "FREEZEREF_EXISTS_MUTABLE_BORROW_ERROR", + "1036": "BORROWFIELD_EXISTS_MUTABLE_BORROW_ERROR", + "1054": "WRITEREF_EXISTS_BORROW_ERROR", + "1059": "EXISTS_RESOURCE_TYPE_MISMATCH_ERROR", + "21": "INVALID_MODULE_PUBLISHER", + "1077": "LOOP_IN_INSTANTIATION_GRAPH", + "8": "REJECTED_WRITE_SET", + "1034": "BORROWFIELD_TYPE_MISMATCH_ERROR", + "1088": "UNSAFE_RET_UNUSED_RESOURCES", + "1080": "ZERO_SIZED_STRUCT", + "3005": "UNKNOWN_SIGNATURE_TYPE", + "3012": "UNKNOWN_NOMINAL_RESOURCE", + "3013": "UNKNOWN_KIND", + "1050": "READREF_RESOURCE_ERROR", + "4000": "UNKNOWN_RUNTIME_STATUS", + "1029": "UNSAFE_RET_LOCAL_OR_RESOURCE_STILL_BORROWED" +} +` + + VMErrUnknown = "unknown" + VMExecutedCode = 4001 + VMAbortedCode = 4016 +) + +var ( + // VM execution status majorCode to string error matching. + errorCodes map[string]string +) + +// StringifyVMStatusMajorCode returns dvm.VMStatus majorCode string representation. +func StringifyVMStatusMajorCode(majorCode string) string { + if v, ok := errorCodes[majorCode]; ok { + return v + } + + return VMErrUnknown +} + +func (m VmStatus) String() string { + return fmt.Sprintf("VM status:\n"+ + " Status: %s\n"+ + " Major code: %s\n"+ + " String code: %s\n"+ + " Sub code: %s\n"+ + " Message: %s", + m.Status, m.MajorCode, m.StrCode, m.SubCode, m.Message, + ) +} + +// StringifyVmStatuses build string representation of VmStatus list. +func StringifyVmStatuses(list []VmStatus) string { + strBuilder := strings.Builder{} + strBuilder.WriteString("VMStatuses:\n") + for i, status := range list { + strBuilder.WriteString(status.String()) + if i < len(list)-1 { + strBuilder.WriteString("\n") + } + } + + return strBuilder.String() +} + +// NewVmStatus creates a new VMStatus error. +func NewVmStatus(status, majorCode, subCode, message string) VmStatus { + strCode := "" + if status != AttributeValueStatusKeep { + strCode = StringifyVMStatusMajorCode(majorCode) + } + + return VmStatus{ + Status: status, + MajorCode: majorCode, + SubCode: subCode, + Message: message, + StrCode: strCode, + } +} + +func (m TxVmStatus) String() string { + return fmt.Sprintf("Tx:\n"+ + " Hash: %s\n"+ + " Statuses: %s", + m.Hash, StringifyVmStatuses(m.VmStatuses), + ) +} + +// NewTxVmStatus creates a new TxVMStatus object. +func NewTxVmStatus(hash string, statuses []VmStatus) TxVmStatus { + return TxVmStatus{ + Hash: hash, + VmStatuses: statuses, + } +} + +// NewVmStatusFromABCILogs converts SDK TxResponse log events to TxVMStatus. +func NewVmStatusFromABCILogs(tx types.TxResponse) TxVmStatus { + statuses := make([]VmStatus, 0) + + for _, log := range tx.Logs { + for _, event := range log.Events { + isFound := false + + if event.Type == EventTypeContractStatus { + status := "" + majorCode := "" + subCode := "" + message := "" + + for _, attr := range event.Attributes { + // find that it's event contains contract status. + if attr.Key == AttributeStatus { + status = attr.Value + + if status == AttributeValueStatusDiscard || status == AttributeValueStatusError { + isFound = true + break + } + } + } + + // event found. + if isFound { + for _, attr := range event.Attributes { + switch attr.Key { + case AttributeErrMajorStatus: + majorCode = attr.Value + + case AttributeErrSubStatus: + subCode = attr.Value + + case AttributeErrMessage: + message = attr.Value + } + } + } + + statuses = append(statuses, NewVmStatus(status, majorCode, subCode, message)) + } + } + } + + return NewTxVmStatus(tx.TxHash, statuses) +} + +func init() { + errorCodes = make(map[string]string) + if err := json.Unmarshal([]byte(jsonErrorCodes), &errorCodes); err != nil { + panic(err) + } +} diff --git a/x/vm/types/grpc_utils_vm_status_test.go b/x/vm/types/grpc_utils_vm_status_test.go new file mode 100644 index 0000000..add4e25 --- /dev/null +++ b/x/vm/types/grpc_utils_vm_status_test.go @@ -0,0 +1,134 @@ +package types + +import ( + "fmt" + "strconv" + "testing" + + "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + + dvmTypes "github.com/dfinance/dstation/pkg/types/dvm" +) + +const ( + ERR_GAS = "4002" + ERR_GAS_MSG = "OUT_OF_GAS" + ERR_ZERO_SUB = "0" + + ERR_SIG = "1" + ERR_U32 = "3018" + + ERR_U32_INT = 3018 + ERR_GAS_INT = 4002 +) + +// Test NewVmStatus. +func TestVM_NewVMStatus(t *testing.T) { + status := "error" + message := "out of gas" + + vmStatus := NewVmStatus(status, ERR_GAS, ERR_ZERO_SUB, message) + require.Equal(t, vmStatus.Status, status) + require.Equal(t, vmStatus.MajorCode, ERR_GAS) + require.Equal(t, vmStatus.SubCode, ERR_ZERO_SUB) + require.Equal(t, vmStatus.Message, message) + require.Equal(t, ERR_GAS_MSG, vmStatus.StrCode) + + vmStatus = NewVmStatus(AttributeValueStatusKeep, "", "", "") + require.Empty(t, vmStatus.StrCode) + require.Empty(t, vmStatus.Message) + require.Empty(t, vmStatus.MajorCode) + require.Empty(t, vmStatus.SubCode) +} + +// Test NewTxVMResponse. +func TestVM_NewTxVMStatus(t *testing.T) { + statuses := make([]VmStatus, 3) + + statuses[0] = NewVmStatus("error", ERR_GAS, "0", "") + statuses[1] = NewVmStatus("discard", ERR_SIG, "0", "invalid signature") + statuses[2] = NewVmStatus("error", ERR_U32, "0", "bad u32") + + txHash := "00" + txVMStatus := NewTxVmStatus(txHash, statuses) + + require.Equal(t, txHash, txVMStatus.Hash) + require.EqualValues(t, txVMStatus.VmStatuses, statuses) +} + +// New NewVmStatusFromABCILogs. +func TestVM_NewVMStatusFromABCILogs(t *testing.T) { + msgs := make([]string, 2) + msgs[0] = "out of gas" + msgs[1] = "bad u32" + + codes := make([]uint64, 2) + codes[0] = ERR_GAS_INT + codes[1] = ERR_U32_INT + + strCodes := make([]string, 2) + strCodes[0] = strconv.FormatUint(codes[0], 10) + strCodes[1] = strconv.FormatUint(codes[1], 10) + + hash := "01" + txResp := types.TxResponse{ + TxHash: hash, + Logs: types.ABCIMessageLogs{ + types.NewABCIMessageLog(0, "", + NewContractEvents(&dvmTypes.VMExecuteResponse{ + Status: &dvmTypes.VMStatus{ + Error: &dvmTypes.VMStatus_ExecutionFailure{ + ExecutionFailure: &dvmTypes.Failure{ + StatusCode: codes[0], + }, + }, + Message: &dvmTypes.Message{ + Text: msgs[0], + }, + }, + }), + ), + types.NewABCIMessageLog(1, "", + NewContractEvents(&dvmTypes.VMExecuteResponse{ + Status: &dvmTypes.VMStatus{ + Error: &dvmTypes.VMStatus_ExecutionFailure{ + ExecutionFailure: &dvmTypes.Failure{ + StatusCode: codes[1], + }, + }, + Message: &dvmTypes.Message{ + Text: msgs[1], + }, + }, + }), + ), + types.NewABCIMessageLog(2, "", + NewContractEvents(&dvmTypes.VMExecuteResponse{ + Status: &dvmTypes.VMStatus{}, + }), + ), + }, + } + + status := NewVmStatusFromABCILogs(txResp) + require.Equal(t, hash, status.Hash) + require.Len(t, status.VmStatuses, len(txResp.Logs)) + + for i, code := range strCodes { + isFound := false + + for _, status := range status.VmStatuses { + if status.MajorCode == code { + require.False(t, isFound) + + require.Equal(t, msgs[i], status.Message) + require.Equal(t, ERR_ZERO_SUB, status.SubCode) + + isFound = true + } + } + + require.True(t, isFound, fmt.Sprintf("not found code %s", code)) + } +} diff --git a/x/vm/types/keys.go b/x/vm/types/keys.go new file mode 100644 index 0000000..64d016b --- /dev/null +++ b/x/vm/types/keys.go @@ -0,0 +1,90 @@ +package types + +import ( + "bytes" + "encoding/binary" + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + + dvmTypes "github.com/dfinance/dstation/pkg/types/dvm" +) + +const ( + ModuleName = "vm" + StoreKey = ModuleName + RouterKey = ModuleName + QuerierRoute = ModuleName + // + DelPoolName = "vm_delegation_pool" +) + +var ( + // Storage keys + KeyDelimiter = []byte(":") // we should not rely on this delimiter for VMStorage (bytes.Split usage for instance) as VM accessPath.Path might include symbols like: [':', '@',..] + VMKeyPrefix = []byte("vm") // storage key prefix for VMStorage data + GovQueuePrefix = []byte("govQueue") // storage key prefix for GovQueue + GovQueueLastIdKey = []byte("gQueueLastId") // storage key used to store last GovQueue ID ("gQueue" prefix is used instead of "govQueue" as iterator would pick "LastId" that way) +) + +// GetVMStorageKey returns VMStorage key for dvmTypes.VMAccessPath. +func GetVMStorageKey(path *dvmTypes.VMAccessPath) []byte { + if path == nil { + return nil + } + + return bytes.Join( + [][]byte{ + path.Address, + path.Path, + }, + KeyDelimiter, + ) +} + +// MustParseVMStorageKey parses VMStorage key and panics on failure. +func MustParseVMStorageKey(key []byte) *dvmTypes.VMAccessPath { + // Key length is expected to be correct: {address_20bytes}:{path_at_least_1byte} + expectedMinLen := VMAddressLength + len(KeyDelimiter) + 1 + if len(key) < expectedMinLen { + panic(fmt.Errorf("VMKey (%s): invalid key length: expected / actual: %d / %d", string(key), expectedMinLen, len(key))) + } + + // Calc indices + addressStartIdx := 0 + addressEndIdx := addressStartIdx + VMAddressLength + delimiterStartIdx := addressEndIdx + delimiterEndIdx := delimiterStartIdx + len(KeyDelimiter) + pathStartIdx := delimiterEndIdx + + // Split key + addressValue := key[addressStartIdx:addressEndIdx] + delimiterValue := key[delimiterStartIdx:delimiterEndIdx] + pathValue := key[pathStartIdx:] + + // Validate + if !bytes.Equal(delimiterValue, KeyDelimiter) { + panic(fmt.Errorf("VMKey (%s): 1st delimiter value is invalid", string(key))) + } + if len(addressValue) < VMAddressLength { + panic(fmt.Errorf("VMKey (%s): address length is invalid: expected / actual: %d / %d", string(key), VMAddressLength, len(addressValue))) + } + if len(pathValue) == 0 { + panic(fmt.Errorf("VMKey (%s): path length is invalid: expected / actual: GT 1 / %d", string(key), len(pathValue))) + } + + return &dvmTypes.VMAccessPath{ + Address: addressValue, + Path: pathValue, + } +} + +// GetGovQueueStorageKey returns gov proposal queue storage key. +func GetGovQueueStorageKey(id uint64) []byte { + return sdk.Uint64ToBigEndian(id) +} + +// ParseGovQueueStorageKey parses GovQueue key. +func ParseGovQueueStorageKey(key []byte) uint64 { + return binary.BigEndian.Uint64(key) +} diff --git a/x/common/vm_storage/storage_test.go b/x/vm/types/keys_test.go similarity index 79% rename from x/common/vm_storage/storage_test.go rename to x/vm/types/keys_test.go index 7dc2a0b..ca8a604 100644 --- a/x/common/vm_storage/storage_test.go +++ b/x/vm/types/keys_test.go @@ -1,4 +1,4 @@ -package vm_storage +package types import ( "bytes" @@ -7,7 +7,7 @@ import ( "github.com/stretchr/testify/require" ) -func Test_MustParsePathKey(t *testing.T) { +func TestVM_MustParsePathKey(t *testing.T) { address := []byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19} path := []byte{1, 2, 4, 8, 16, 32, 64, 128, 255} @@ -15,12 +15,11 @@ func Test_MustParsePathKey(t *testing.T) { { key := bytes.Join( [][]byte{ - VMKey, address, path, }, KeyDelimiter) - accessPath := MustParsePathKey(key) + accessPath := MustParseVMStorageKey(key) require.EqualValues(t, address, accessPath.Address) require.EqualValues(t, path, accessPath.Path) } @@ -29,13 +28,12 @@ func Test_MustParsePathKey(t *testing.T) { { key := bytes.Join( [][]byte{ - VMKey, address[:len(address)-2], path, }, KeyDelimiter) require.Panics(t, func() { - MustParsePathKey(key) + MustParseVMStorageKey(key) }) } @@ -43,13 +41,12 @@ func Test_MustParsePathKey(t *testing.T) { { key := bytes.Join( [][]byte{ - VMKey, address, {}, }, KeyDelimiter) require.Panics(t, func() { - MustParsePathKey(key) + MustParseVMStorageKey(key) }) } @@ -57,13 +54,12 @@ func Test_MustParsePathKey(t *testing.T) { { key := bytes.Join( [][]byte{ - VMKey, address, {}, }, []byte("@")) require.Panics(t, func() { - MustParsePathKey(key) + MustParseVMStorageKey(key) }) } } diff --git a/x/vm/types/move.go b/x/vm/types/move.go new file mode 100644 index 0000000..f8bdaba --- /dev/null +++ b/x/vm/types/move.go @@ -0,0 +1,46 @@ +package types + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +const ( + // Default address length (Move address length) + VMAddressLength = 20 +) + +var ( + // Move stdlib addresses + StdLibAddress = make([]byte, VMAddressLength) + StdLibAddressShortStr = "0x1" +) + +// Bech32ToLibra converts Bech32 to Libra hex. +func Bech32ToLibra(addr sdk.AccAddress) []byte { + return addr.Bytes() +} + +// MustBech32ToLibra converts Bech32 address string to Libra hex and panics on failure. +func MustBech32ToLibra(addrRaw string) []byte { + addr, err := sdk.AccAddressFromBech32(addrRaw) + if err != nil { + panic(fmt.Errorf("raw bech32 string convert: %v", err)) + } + + return Bech32ToLibra(addr) +} + +// LibraToBech32 converts Libra bytes to sdk.AccAddress. +func LibraToBech32(addrRaw []byte) (sdk.AccAddress, error) { + if len(addrRaw) != VMAddressLength { + return sdk.AccAddress{}, fmt.Errorf("invalid length (must be %d)", VMAddressLength) + } + + return sdk.AccAddress(addrRaw), nil +} + +func init() { + StdLibAddress[VMAddressLength-1] = 1 +} diff --git a/x/vm/types/msg.go b/x/vm/types/msg.go new file mode 100644 index 0000000..c9a883c --- /dev/null +++ b/x/vm/types/msg.go @@ -0,0 +1,139 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkErrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +var ( + _ sdk.Msg = (*MsgExecuteScript)(nil) + _ sdk.Msg = (*MsgDeployModule)(nil) +) + +const ( + TypeMsgExecuteScript = "execute_script" + TypeMsgDeployModule = "deploy_module" +) + +// Route implements sdk.Msg interface. +func (MsgExecuteScript) Route() string { + return RouterKey +} + +// Type implements sdk.Msg interface. +func (MsgExecuteScript) Type() string { + return TypeMsgExecuteScript +} + +// ValidateBasic implements sdk.Msg interface. +func (m MsgExecuteScript) ValidateBasic() error { + signerAddr, err := sdk.AccAddressFromBech32(m.Signer) + if err != nil { + return sdkErrors.Wrapf(sdkErrors.ErrInvalidAddress, "signer address: invalid") + } + if signerAddr.Empty() { + return sdkErrors.Wrapf(sdkErrors.ErrInvalidAddress, "signer address: empty") + } + + if len(m.Script) == 0 { + return sdkErrors.Wrapf(ErrEmptyContract, "script: empty") + } + + for i, arg := range m.Args { + if _, err := StringifyVMTypeTag(arg.Type); err != nil { + return sdkErrors.Wrapf(ErrWrongArgTypeTag, "args [%d]: type: %v", i, err) + } + if len(arg.Value) == 0 { + return sdkErrors.Wrapf(ErrWrongArgTypeTag, "args [%d]: value: empty", i) + } + } + + return nil +} + +// GetSignBytes implements sdk.Msg interface. +func (m MsgExecuteScript) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(&m) + return sdk.MustSortJSON(bz) +} + +// GetSigners implements sdk.Msg interface. +func (m MsgExecuteScript) GetSigners() []sdk.AccAddress { + // signer pays fees + signerAddr, err := sdk.AccAddressFromBech32(m.Signer) + if err != nil { + panic(err) + } + + return []sdk.AccAddress{signerAddr} +} + +// NewMsgExecuteScript creates a new MsgExecuteScript message. +func NewMsgExecuteScript(signer sdk.AccAddress, script []byte, args ...MsgExecuteScript_ScriptArg) MsgExecuteScript { + if len(args) == 0 { + args = nil + } + + return MsgExecuteScript{ + Signer: signer.String(), + Script: script, + Args: args, + } +} + +// Route implements sdk.Msg interface. +func (MsgDeployModule) Route() string { + return RouterKey +} + +// Type implements sdk.Msg interface. +func (MsgDeployModule) Type() string { + return TypeMsgDeployModule +} + +// ValidateBasic implements sdk.Msg interface. +func (m MsgDeployModule) ValidateBasic() error { + signerAddr, err := sdk.AccAddressFromBech32(m.Signer) + if err != nil { + return sdkErrors.Wrapf(sdkErrors.ErrInvalidAddress, "signer address: invalid") + } + if signerAddr.Empty() { + return sdkErrors.Wrapf(sdkErrors.ErrInvalidAddress, "signer address: empty") + } + + if len(m.Modules) == 0 { + return sdkErrors.Wrapf(ErrEmptyContract, "modules: empty") + } + for i, module := range m.Modules { + if len(module) == 0 { + return sdkErrors.Wrapf(ErrEmptyContract, "modules [%d]: empty", i) + } + } + + return nil +} + +// GetSignBytes implements sdk.Msg interface. +func (m MsgDeployModule) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(&m) + return sdk.MustSortJSON(bz) +} + +// GetSigners implements sdk.Msg interface. +func (m MsgDeployModule) GetSigners() []sdk.AccAddress { + // signer pays fees + signerAddr, err := sdk.AccAddressFromBech32(m.Signer) + if err != nil { + panic(err) + } + + return []sdk.AccAddress{signerAddr} +} + +// NewMsgDeployModule creates a new MsgDeployModule message. +func NewMsgDeployModule(signer sdk.AccAddress, modules ...[]byte) MsgDeployModule { + return MsgDeployModule{ + Signer: signer.String(), + Modules: modules, + } +} diff --git a/x/vm/types/msg_test.go b/x/vm/types/msg_test.go new file mode 100644 index 0000000..33b4d8a --- /dev/null +++ b/x/vm/types/msg_test.go @@ -0,0 +1,99 @@ +package types + +import ( + "errors" + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkErrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/stretchr/testify/require" + + dvmTypes "github.com/dfinance/dstation/pkg/types/dvm" +) + +func TestVM_MsgDeployModule(t *testing.T) { + t.Parallel() + + acc, err := sdk.AccAddressFromBech32("cosmos18557aj0s0dxdd24elwmf6tgv4x6vas3h3vzg5u") + require.NoError(t, err) + code := make([]byte, 128) + + // ok + { + msg := NewMsgDeployModule(acc, code) + + require.Equal(t, acc.String(), msg.Signer) + require.Equal(t, code, msg.Modules[0]) + // + require.Equal(t, RouterKey, msg.Route()) + require.Equal(t, TypeMsgDeployModule, msg.Type()) + require.Equal(t, []sdk.AccAddress{acc}, msg.GetSigners()) + require.Equal(t, getMsgSignBytes(&msg), msg.GetSignBytes()) + + require.NoError(t, msg.ValidateBasic()) + } + + // fail + { + msg := NewMsgDeployModule([]byte{}, code) + require.True(t, errors.Is(msg.ValidateBasic(), sdkErrors.ErrInvalidAddress)) + } + + // fail + { + msg := NewMsgDeployModule(acc) + require.True(t, errors.Is(msg.ValidateBasic(), ErrEmptyContract)) + } +} + +func TestVM_MsgExecuteScript(t *testing.T) { + t.Parallel() + + acc, err := sdk.AccAddressFromBech32("cosmos18557aj0s0dxdd24elwmf6tgv4x6vas3h3vzg5u") + require.NoError(t, err) + code := make([]byte, 128) + + args := []MsgExecuteScript_ScriptArg{ + {Type: dvmTypes.VMTypeTag_U64, Value: []byte{0x1, 0x2, 0x3, 0x4}}, + {Type: dvmTypes.VMTypeTag_Vector, Value: []byte{0x0}}, + {Type: dvmTypes.VMTypeTag_Address, Value: Bech32ToLibra(acc)}, + } + + // ok + { + msg := NewMsgExecuteScript(acc, code, args...) + + require.Equal(t, acc.String(), msg.Signer) + require.Equal(t, code, msg.Script) + require.EqualValues(t, args, msg.Args) + + require.Equal(t, RouterKey, msg.Route()) + require.Equal(t, TypeMsgExecuteScript, msg.Type()) + require.Equal(t, []sdk.AccAddress{acc}, msg.GetSigners()) + require.Equal(t, getMsgSignBytes(&msg), msg.GetSignBytes()) + + require.NoError(t, msg.ValidateBasic()) + } + + // ok + { + msg := NewMsgExecuteScript(acc, code) + require.NoError(t, msg.ValidateBasic()) + } + + // fail + { + msg := NewMsgExecuteScript([]byte{}, code) + require.True(t, errors.Is(msg.ValidateBasic(), sdkErrors.ErrInvalidAddress)) + } + + // fail + { + msg := NewMsgExecuteScript(acc, nil) + require.True(t, errors.Is(msg.ValidateBasic(), ErrEmptyContract)) + } +} + +func getMsgSignBytes(msg sdk.Msg) []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(msg)) +} diff --git a/x/vm/types/query.pb.go b/x/vm/types/query.pb.go new file mode 100644 index 0000000..d567389 --- /dev/null +++ b/x/vm/types/query.pb.go @@ -0,0 +1,2235 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: dfinance/vm/query.proto + +package types + +import ( + context "context" + fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/types" + dvm "github.com/dfinance/dstation/pkg/types/dvm" + _ "github.com/gogo/protobuf/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// QueryDataRequest is request type for Query/Data RPC method. +type QueryDataRequest struct { + // VM address (Libra address) + Address []byte `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + // VM path + Path []byte `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"` +} + +func (m *QueryDataRequest) Reset() { *m = QueryDataRequest{} } +func (m *QueryDataRequest) String() string { return proto.CompactTextString(m) } +func (*QueryDataRequest) ProtoMessage() {} +func (*QueryDataRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_e48d74b547b7dcf2, []int{0} +} +func (m *QueryDataRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryDataRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryDataRequest.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 *QueryDataRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryDataRequest.Merge(m, src) +} +func (m *QueryDataRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryDataRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryDataRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryDataRequest proto.InternalMessageInfo + +func (m *QueryDataRequest) GetAddress() []byte { + if m != nil { + return m.Address + } + return nil +} + +func (m *QueryDataRequest) GetPath() []byte { + if m != nil { + return m.Path + } + return nil +} + +// QueryDataResponse is response type for Query/Data RPC method. +type QueryDataResponse struct { + // VMStorage value for address:path pair + Value []byte `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"` +} + +func (m *QueryDataResponse) Reset() { *m = QueryDataResponse{} } +func (m *QueryDataResponse) String() string { return proto.CompactTextString(m) } +func (*QueryDataResponse) ProtoMessage() {} +func (*QueryDataResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_e48d74b547b7dcf2, []int{1} +} +func (m *QueryDataResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryDataResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryDataResponse.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 *QueryDataResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryDataResponse.Merge(m, src) +} +func (m *QueryDataResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryDataResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryDataResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryDataResponse proto.InternalMessageInfo + +func (m *QueryDataResponse) GetValue() []byte { + if m != nil { + return m.Value + } + return nil +} + +// QueryTxVmStatusRequest is request type for Query/TxVmStatus RPC method. +type QueryTxVmStatusRequest struct { + // Tx meta received from /cosmos/tx/v1beta1/txs/{hash} + TxMeta types.TxResponse `protobuf:"bytes,1,opt,name=tx_meta,json=txMeta,proto3" json:"tx_meta"` +} + +func (m *QueryTxVmStatusRequest) Reset() { *m = QueryTxVmStatusRequest{} } +func (m *QueryTxVmStatusRequest) String() string { return proto.CompactTextString(m) } +func (*QueryTxVmStatusRequest) ProtoMessage() {} +func (*QueryTxVmStatusRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_e48d74b547b7dcf2, []int{2} +} +func (m *QueryTxVmStatusRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryTxVmStatusRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryTxVmStatusRequest.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 *QueryTxVmStatusRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryTxVmStatusRequest.Merge(m, src) +} +func (m *QueryTxVmStatusRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryTxVmStatusRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryTxVmStatusRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryTxVmStatusRequest proto.InternalMessageInfo + +func (m *QueryTxVmStatusRequest) GetTxMeta() types.TxResponse { + if m != nil { + return m.TxMeta + } + return types.TxResponse{} +} + +// QueryTxVmStatusResponse is response type for Query/TxVmStatus RPC method. +type QueryTxVmStatusResponse struct { + VmStatus TxVmStatus `protobuf:"bytes,1,opt,name=vm_status,json=vmStatus,proto3" json:"vm_status"` +} + +func (m *QueryTxVmStatusResponse) Reset() { *m = QueryTxVmStatusResponse{} } +func (m *QueryTxVmStatusResponse) String() string { return proto.CompactTextString(m) } +func (*QueryTxVmStatusResponse) ProtoMessage() {} +func (*QueryTxVmStatusResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_e48d74b547b7dcf2, []int{3} +} +func (m *QueryTxVmStatusResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryTxVmStatusResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryTxVmStatusResponse.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 *QueryTxVmStatusResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryTxVmStatusResponse.Merge(m, src) +} +func (m *QueryTxVmStatusResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryTxVmStatusResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryTxVmStatusResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryTxVmStatusResponse proto.InternalMessageInfo + +func (m *QueryTxVmStatusResponse) GetVmStatus() TxVmStatus { + if m != nil { + return m.VmStatus + } + return TxVmStatus{} +} + +// QueryCompileRequest is request type for Query/Compile RPC method. +type QueryCompileRequest struct { + // VM address (Libra address) + Address []byte `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + // Move code [Plain text] + Code string `protobuf:"bytes,2,opt,name=code,proto3" json:"code,omitempty"` +} + +func (m *QueryCompileRequest) Reset() { *m = QueryCompileRequest{} } +func (m *QueryCompileRequest) String() string { return proto.CompactTextString(m) } +func (*QueryCompileRequest) ProtoMessage() {} +func (*QueryCompileRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_e48d74b547b7dcf2, []int{4} +} +func (m *QueryCompileRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryCompileRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryCompileRequest.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 *QueryCompileRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryCompileRequest.Merge(m, src) +} +func (m *QueryCompileRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryCompileRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryCompileRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryCompileRequest proto.InternalMessageInfo + +func (m *QueryCompileRequest) GetAddress() []byte { + if m != nil { + return m.Address + } + return nil +} + +func (m *QueryCompileRequest) GetCode() string { + if m != nil { + return m.Code + } + return "" +} + +// QueryCompileResponse is response type for Query/Compile RPC method. +type QueryCompileResponse struct { + // Compiled items + CompiledItems []CompiledItem `protobuf:"bytes,1,rep,name=compiled_items,json=compiledItems,proto3" json:"compiled_items"` +} + +func (m *QueryCompileResponse) Reset() { *m = QueryCompileResponse{} } +func (m *QueryCompileResponse) String() string { return proto.CompactTextString(m) } +func (*QueryCompileResponse) ProtoMessage() {} +func (*QueryCompileResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_e48d74b547b7dcf2, []int{5} +} +func (m *QueryCompileResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryCompileResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryCompileResponse.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 *QueryCompileResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryCompileResponse.Merge(m, src) +} +func (m *QueryCompileResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryCompileResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryCompileResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryCompileResponse proto.InternalMessageInfo + +func (m *QueryCompileResponse) GetCompiledItems() []CompiledItem { + if m != nil { + return m.CompiledItems + } + return nil +} + +// QueryMetadataRequest is request type for Query/Metadata RPC method. +type QueryMetadataRequest struct { + Code []byte `protobuf:"bytes,1,opt,name=code,proto3" json:"code,omitempty"` +} + +func (m *QueryMetadataRequest) Reset() { *m = QueryMetadataRequest{} } +func (m *QueryMetadataRequest) String() string { return proto.CompactTextString(m) } +func (*QueryMetadataRequest) ProtoMessage() {} +func (*QueryMetadataRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_e48d74b547b7dcf2, []int{6} +} +func (m *QueryMetadataRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryMetadataRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryMetadataRequest.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 *QueryMetadataRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryMetadataRequest.Merge(m, src) +} +func (m *QueryMetadataRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryMetadataRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryMetadataRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryMetadataRequest proto.InternalMessageInfo + +func (m *QueryMetadataRequest) GetCode() []byte { + if m != nil { + return m.Code + } + return nil +} + +// QueryMetadataResponse is response type for Query/Metadata RPC method. +type QueryMetadataResponse struct { + Metadata *dvm.Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"` +} + +func (m *QueryMetadataResponse) Reset() { *m = QueryMetadataResponse{} } +func (m *QueryMetadataResponse) String() string { return proto.CompactTextString(m) } +func (*QueryMetadataResponse) ProtoMessage() {} +func (*QueryMetadataResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_e48d74b547b7dcf2, []int{7} +} +func (m *QueryMetadataResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryMetadataResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryMetadataResponse.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 *QueryMetadataResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryMetadataResponse.Merge(m, src) +} +func (m *QueryMetadataResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryMetadataResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryMetadataResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryMetadataResponse proto.InternalMessageInfo + +func (m *QueryMetadataResponse) GetMetadata() *dvm.Metadata { + if m != nil { + return m.Metadata + } + return nil +} + +// QueryDelegatedPoolSupplyRequest is request type for Query/DelegatedPoolSupply RPC method. +type QueryDelegatedPoolSupplyRequest struct { +} + +func (m *QueryDelegatedPoolSupplyRequest) Reset() { *m = QueryDelegatedPoolSupplyRequest{} } +func (m *QueryDelegatedPoolSupplyRequest) String() string { return proto.CompactTextString(m) } +func (*QueryDelegatedPoolSupplyRequest) ProtoMessage() {} +func (*QueryDelegatedPoolSupplyRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_e48d74b547b7dcf2, []int{8} +} +func (m *QueryDelegatedPoolSupplyRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryDelegatedPoolSupplyRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryDelegatedPoolSupplyRequest.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 *QueryDelegatedPoolSupplyRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryDelegatedPoolSupplyRequest.Merge(m, src) +} +func (m *QueryDelegatedPoolSupplyRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryDelegatedPoolSupplyRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryDelegatedPoolSupplyRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryDelegatedPoolSupplyRequest proto.InternalMessageInfo + +// QueryDelegatedPoolSupplyResponse is response type for Query/DelegatedPoolSupply RPC method. +type QueryDelegatedPoolSupplyResponse struct { + Coins github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=coins,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"coins"` +} + +func (m *QueryDelegatedPoolSupplyResponse) Reset() { *m = QueryDelegatedPoolSupplyResponse{} } +func (m *QueryDelegatedPoolSupplyResponse) String() string { return proto.CompactTextString(m) } +func (*QueryDelegatedPoolSupplyResponse) ProtoMessage() {} +func (*QueryDelegatedPoolSupplyResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_e48d74b547b7dcf2, []int{9} +} +func (m *QueryDelegatedPoolSupplyResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryDelegatedPoolSupplyResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryDelegatedPoolSupplyResponse.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 *QueryDelegatedPoolSupplyResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryDelegatedPoolSupplyResponse.Merge(m, src) +} +func (m *QueryDelegatedPoolSupplyResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryDelegatedPoolSupplyResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryDelegatedPoolSupplyResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryDelegatedPoolSupplyResponse proto.InternalMessageInfo + +func (m *QueryDelegatedPoolSupplyResponse) GetCoins() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.Coins + } + return nil +} + +func init() { + proto.RegisterType((*QueryDataRequest)(nil), "dfinance.vm.v1beta1.QueryDataRequest") + proto.RegisterType((*QueryDataResponse)(nil), "dfinance.vm.v1beta1.QueryDataResponse") + proto.RegisterType((*QueryTxVmStatusRequest)(nil), "dfinance.vm.v1beta1.QueryTxVmStatusRequest") + proto.RegisterType((*QueryTxVmStatusResponse)(nil), "dfinance.vm.v1beta1.QueryTxVmStatusResponse") + proto.RegisterType((*QueryCompileRequest)(nil), "dfinance.vm.v1beta1.QueryCompileRequest") + proto.RegisterType((*QueryCompileResponse)(nil), "dfinance.vm.v1beta1.QueryCompileResponse") + proto.RegisterType((*QueryMetadataRequest)(nil), "dfinance.vm.v1beta1.QueryMetadataRequest") + proto.RegisterType((*QueryMetadataResponse)(nil), "dfinance.vm.v1beta1.QueryMetadataResponse") + proto.RegisterType((*QueryDelegatedPoolSupplyRequest)(nil), "dfinance.vm.v1beta1.QueryDelegatedPoolSupplyRequest") + proto.RegisterType((*QueryDelegatedPoolSupplyResponse)(nil), "dfinance.vm.v1beta1.QueryDelegatedPoolSupplyResponse") +} + +func init() { proto.RegisterFile("dfinance/vm/query.proto", fileDescriptor_e48d74b547b7dcf2) } + +var fileDescriptor_e48d74b547b7dcf2 = []byte{ + // 698 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x55, 0x5d, 0x4f, 0x13, 0x4d, + 0x14, 0xee, 0xf2, 0x52, 0x3e, 0x86, 0xf7, 0x7d, 0xa3, 0x43, 0xe5, 0x63, 0x21, 0x5b, 0xba, 0xa0, + 0x16, 0xd4, 0x1d, 0xa9, 0x7a, 0xaf, 0xe0, 0x8d, 0x31, 0x18, 0x2d, 0xc4, 0x0b, 0x13, 0xd2, 0x4c, + 0x77, 0x87, 0xb2, 0xb1, 0xb3, 0xb3, 0x30, 0xd3, 0xcd, 0x72, 0x4b, 0xe4, 0xde, 0xe8, 0xbf, 0xf0, + 0x97, 0x70, 0x49, 0xe2, 0x8d, 0x57, 0x6a, 0xc0, 0x1f, 0x62, 0x76, 0xf6, 0x6c, 0x3f, 0xa0, 0xc5, + 0x7a, 0xd5, 0x9d, 0xf3, 0xf1, 0x9c, 0xe7, 0x9c, 0x79, 0xce, 0x14, 0xcd, 0x7a, 0x7b, 0x7e, 0x40, + 0x03, 0x97, 0x91, 0x88, 0x93, 0x83, 0x16, 0x3b, 0x3c, 0x72, 0xc2, 0x43, 0xa1, 0x04, 0x9e, 0xce, + 0x1c, 0x4e, 0xc4, 0x9d, 0x68, 0xbd, 0xce, 0x14, 0x5d, 0x37, 0x0b, 0x0d, 0xd1, 0x10, 0xda, 0x4f, + 0x92, 0xaf, 0x34, 0xd4, 0x5c, 0x6c, 0x08, 0xd1, 0x68, 0x32, 0x42, 0x43, 0x9f, 0xd0, 0x20, 0x10, + 0x8a, 0x2a, 0x5f, 0x04, 0x12, 0xbc, 0xcb, 0xae, 0x90, 0x5c, 0x48, 0x52, 0xa7, 0x92, 0x11, 0x5a, + 0x77, 0x7d, 0x02, 0x68, 0xfa, 0x00, 0x41, 0x56, 0x77, 0x50, 0xe6, 0x77, 0x85, 0x1f, 0x80, 0xbf, + 0xd0, 0x4d, 0x33, 0xe2, 0x60, 0x5d, 0x68, 0x5b, 0xbd, 0x88, 0x13, 0xce, 0x14, 0xf5, 0xa8, 0xa2, + 0xa9, 0xd3, 0x7e, 0x8a, 0x6e, 0xbc, 0x49, 0xfa, 0x79, 0x4e, 0x15, 0xad, 0xb2, 0x83, 0x16, 0x93, + 0x0a, 0xcf, 0xa1, 0x71, 0xea, 0x79, 0x87, 0x4c, 0xca, 0x39, 0x63, 0xc9, 0x28, 0xff, 0x5b, 0xcd, + 0x8e, 0x18, 0xa3, 0xd1, 0x90, 0xaa, 0xfd, 0xb9, 0x11, 0x6d, 0xd6, 0xdf, 0xf6, 0x2a, 0xba, 0xd9, + 0x85, 0x20, 0x43, 0x11, 0x48, 0x86, 0x0b, 0x28, 0x1f, 0xd1, 0x66, 0x8b, 0x01, 0x40, 0x7a, 0xb0, + 0x77, 0xd1, 0x8c, 0x0e, 0xdd, 0x89, 0xdf, 0xf2, 0x6d, 0x45, 0x55, 0x4b, 0x66, 0x25, 0x37, 0xd1, + 0xb8, 0x8a, 0x6b, 0x09, 0x37, 0x9d, 0x31, 0x55, 0x59, 0x71, 0xd2, 0x5e, 0x9d, 0xa4, 0x57, 0x47, + 0xcf, 0x00, 0x1a, 0x76, 0x76, 0xe2, 0xac, 0xcc, 0xc6, 0xe8, 0xe9, 0xf7, 0x62, 0xae, 0x3a, 0xa6, + 0xe2, 0x2d, 0xa6, 0xa8, 0xbd, 0x8b, 0x66, 0xaf, 0xc0, 0x03, 0x9f, 0x0d, 0x34, 0x19, 0xf1, 0x9a, + 0xd4, 0x46, 0xa8, 0x50, 0x74, 0xfa, 0xdc, 0x9d, 0xd3, 0xc9, 0x05, 0xf0, 0x89, 0x08, 0xce, 0xf6, + 0x26, 0x9a, 0xd6, 0xf0, 0x9b, 0x82, 0x87, 0x7e, 0x93, 0x0d, 0x35, 0x2d, 0x57, 0x78, 0x4c, 0x4f, + 0x6b, 0xb2, 0xaa, 0xbf, 0xed, 0x3d, 0x54, 0xe8, 0x05, 0x01, 0x82, 0xaf, 0xd0, 0xff, 0x6e, 0x6a, + 0xf2, 0x6a, 0xbe, 0x62, 0x3c, 0x01, 0xfb, 0xa7, 0x3c, 0x55, 0x29, 0xf5, 0x65, 0x09, 0xd9, 0xde, + 0x0b, 0xc5, 0x38, 0xf0, 0xfc, 0xcf, 0xed, 0xb2, 0x49, 0x7b, 0x0d, 0xea, 0x6c, 0xc1, 0x75, 0x67, + 0x6c, 0x33, 0x4e, 0x29, 0xd5, 0x94, 0xd3, 0x4b, 0x74, 0xeb, 0x52, 0x2c, 0x90, 0xaa, 0xa0, 0x89, + 0x4c, 0x2e, 0x30, 0xb4, 0x99, 0x0e, 0x1d, 0x2f, 0xe2, 0x4e, 0x3b, 0xa3, 0x1d, 0x67, 0x97, 0x50, + 0x31, 0x95, 0x03, 0x6b, 0xb2, 0x06, 0x55, 0xcc, 0x7b, 0x2d, 0x44, 0x73, 0xbb, 0x15, 0x86, 0xcd, + 0x23, 0xe0, 0x60, 0x9f, 0x18, 0x68, 0x69, 0x70, 0x0c, 0xd4, 0xa6, 0x28, 0x9f, 0x28, 0x3b, 0x9b, + 0xc3, 0x7c, 0x8f, 0x1e, 0x3a, 0x73, 0xf0, 0x83, 0x8d, 0x87, 0x49, 0xff, 0x5f, 0x7e, 0x14, 0xcb, + 0x0d, 0x5f, 0xed, 0xb7, 0xea, 0x8e, 0x2b, 0x38, 0x81, 0x45, 0x49, 0x7f, 0x1e, 0x48, 0xef, 0x3d, + 0x51, 0x47, 0x21, 0x93, 0x3a, 0x41, 0x56, 0x53, 0xe4, 0xca, 0x49, 0x1e, 0xe5, 0x35, 0x0f, 0x1c, + 0xa3, 0xd1, 0x44, 0xbe, 0xf8, 0x76, 0xdf, 0x69, 0x5f, 0x5e, 0x10, 0xf3, 0xce, 0x9f, 0xc2, 0xd2, + 0x1e, 0xec, 0xd2, 0xf1, 0xd7, 0x5f, 0x9f, 0x47, 0x16, 0xf0, 0x3c, 0xe9, 0x59, 0x4c, 0x58, 0xdc, + 0x64, 0x5c, 0xf8, 0x93, 0x81, 0x50, 0x47, 0x73, 0xf8, 0xde, 0x60, 0xe4, 0x2b, 0x4b, 0x63, 0xde, + 0x1f, 0x2e, 0x18, 0xc8, 0xac, 0x6a, 0x32, 0xcb, 0xb8, 0xd4, 0x97, 0x8c, 0x8a, 0x6b, 0xed, 0x05, + 0xc1, 0x1f, 0x0c, 0x34, 0x0e, 0x12, 0xc3, 0xe5, 0xc1, 0x45, 0x7a, 0x17, 0xc1, 0x5c, 0x1d, 0x22, + 0x12, 0xb8, 0xac, 0x68, 0x2e, 0x16, 0x5e, 0xec, 0xcb, 0x05, 0x94, 0x8c, 0x29, 0x9a, 0xc8, 0x04, + 0x86, 0xaf, 0x01, 0xbf, 0x24, 0x71, 0x73, 0x6d, 0x98, 0x50, 0x50, 0xd9, 0xb1, 0x81, 0xa6, 0xfb, + 0xa8, 0x10, 0x3f, 0xbe, 0xe6, 0x86, 0x07, 0x0a, 0xdb, 0x7c, 0xf2, 0x97, 0x59, 0xf0, 0x8a, 0x3d, + 0x3b, 0x3d, 0xb7, 0x8c, 0xb3, 0x73, 0xcb, 0xf8, 0x79, 0x6e, 0x19, 0x1f, 0x2f, 0xac, 0xdc, 0xd9, + 0x85, 0x95, 0xfb, 0x76, 0x61, 0xe5, 0xde, 0xdd, 0xed, 0x92, 0x74, 0xe7, 0x15, 0x97, 0xe9, 0x5f, + 0x07, 0x89, 0x93, 0xa1, 0x69, 0x5d, 0xd7, 0xc7, 0xf4, 0x6b, 0xfe, 0xe8, 0x77, 0x00, 0x00, 0x00, + 0xff, 0xff, 0x64, 0x97, 0x37, 0x5e, 0xa9, 0x06, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + // Data queries VMStorage value + Data(ctx context.Context, in *QueryDataRequest, opts ...grpc.CallOption) (*QueryDataResponse, error) + // TxVmStatus queries VM status for Tx + TxVmStatus(ctx context.Context, in *QueryTxVmStatusRequest, opts ...grpc.CallOption) (*QueryTxVmStatusResponse, error) + // Compile compiles provided Move code and returns byte code. + Compile(ctx context.Context, in *QueryCompileRequest, opts ...grpc.CallOption) (*QueryCompileResponse, error) + // Metadata queries VM for byteCode metadata (metadata.proto/GetMetadata RPC wrapper). + Metadata(ctx context.Context, in *QueryMetadataRequest, opts ...grpc.CallOption) (*QueryMetadataResponse, error) + // DelegatedPoolSupply queries Delegated pool module balance. + DelegatedPoolSupply(ctx context.Context, in *QueryDelegatedPoolSupplyRequest, opts ...grpc.CallOption) (*QueryDelegatedPoolSupplyResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Data(ctx context.Context, in *QueryDataRequest, opts ...grpc.CallOption) (*QueryDataResponse, error) { + out := new(QueryDataResponse) + err := c.cc.Invoke(ctx, "/dfinance.vm.v1beta1.Query/Data", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) TxVmStatus(ctx context.Context, in *QueryTxVmStatusRequest, opts ...grpc.CallOption) (*QueryTxVmStatusResponse, error) { + out := new(QueryTxVmStatusResponse) + err := c.cc.Invoke(ctx, "/dfinance.vm.v1beta1.Query/TxVmStatus", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) Compile(ctx context.Context, in *QueryCompileRequest, opts ...grpc.CallOption) (*QueryCompileResponse, error) { + out := new(QueryCompileResponse) + err := c.cc.Invoke(ctx, "/dfinance.vm.v1beta1.Query/Compile", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) Metadata(ctx context.Context, in *QueryMetadataRequest, opts ...grpc.CallOption) (*QueryMetadataResponse, error) { + out := new(QueryMetadataResponse) + err := c.cc.Invoke(ctx, "/dfinance.vm.v1beta1.Query/Metadata", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) DelegatedPoolSupply(ctx context.Context, in *QueryDelegatedPoolSupplyRequest, opts ...grpc.CallOption) (*QueryDelegatedPoolSupplyResponse, error) { + out := new(QueryDelegatedPoolSupplyResponse) + err := c.cc.Invoke(ctx, "/dfinance.vm.v1beta1.Query/DelegatedPoolSupply", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // Data queries VMStorage value + Data(context.Context, *QueryDataRequest) (*QueryDataResponse, error) + // TxVmStatus queries VM status for Tx + TxVmStatus(context.Context, *QueryTxVmStatusRequest) (*QueryTxVmStatusResponse, error) + // Compile compiles provided Move code and returns byte code. + Compile(context.Context, *QueryCompileRequest) (*QueryCompileResponse, error) + // Metadata queries VM for byteCode metadata (metadata.proto/GetMetadata RPC wrapper). + Metadata(context.Context, *QueryMetadataRequest) (*QueryMetadataResponse, error) + // DelegatedPoolSupply queries Delegated pool module balance. + DelegatedPoolSupply(context.Context, *QueryDelegatedPoolSupplyRequest) (*QueryDelegatedPoolSupplyResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) Data(ctx context.Context, req *QueryDataRequest) (*QueryDataResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Data not implemented") +} +func (*UnimplementedQueryServer) TxVmStatus(ctx context.Context, req *QueryTxVmStatusRequest) (*QueryTxVmStatusResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method TxVmStatus not implemented") +} +func (*UnimplementedQueryServer) Compile(ctx context.Context, req *QueryCompileRequest) (*QueryCompileResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Compile not implemented") +} +func (*UnimplementedQueryServer) Metadata(ctx context.Context, req *QueryMetadataRequest) (*QueryMetadataResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Metadata not implemented") +} +func (*UnimplementedQueryServer) DelegatedPoolSupply(ctx context.Context, req *QueryDelegatedPoolSupplyRequest) (*QueryDelegatedPoolSupplyResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DelegatedPoolSupply not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_Data_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryDataRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Data(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/dfinance.vm.v1beta1.Query/Data", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Data(ctx, req.(*QueryDataRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_TxVmStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryTxVmStatusRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).TxVmStatus(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/dfinance.vm.v1beta1.Query/TxVmStatus", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).TxVmStatus(ctx, req.(*QueryTxVmStatusRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_Compile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryCompileRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Compile(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/dfinance.vm.v1beta1.Query/Compile", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Compile(ctx, req.(*QueryCompileRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_Metadata_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryMetadataRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Metadata(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/dfinance.vm.v1beta1.Query/Metadata", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Metadata(ctx, req.(*QueryMetadataRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_DelegatedPoolSupply_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryDelegatedPoolSupplyRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).DelegatedPoolSupply(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/dfinance.vm.v1beta1.Query/DelegatedPoolSupply", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).DelegatedPoolSupply(ctx, req.(*QueryDelegatedPoolSupplyRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "dfinance.vm.v1beta1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Data", + Handler: _Query_Data_Handler, + }, + { + MethodName: "TxVmStatus", + Handler: _Query_TxVmStatus_Handler, + }, + { + MethodName: "Compile", + Handler: _Query_Compile_Handler, + }, + { + MethodName: "Metadata", + Handler: _Query_Metadata_Handler, + }, + { + MethodName: "DelegatedPoolSupply", + Handler: _Query_DelegatedPoolSupply_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "dfinance/vm/query.proto", +} + +func (m *QueryDataRequest) 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 *QueryDataRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryDataRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Path) > 0 { + i -= len(m.Path) + copy(dAtA[i:], m.Path) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Path))) + i-- + dAtA[i] = 0x12 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryDataResponse) 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 *QueryDataResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryDataResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Value) > 0 { + i -= len(m.Value) + copy(dAtA[i:], m.Value) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Value))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryTxVmStatusRequest) 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 *QueryTxVmStatusRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryTxVmStatusRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.TxMeta.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QueryTxVmStatusResponse) 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 *QueryTxVmStatusResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryTxVmStatusResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.VmStatus.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QueryCompileRequest) 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 *QueryCompileRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryCompileRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Code) > 0 { + i -= len(m.Code) + copy(dAtA[i:], m.Code) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Code))) + i-- + dAtA[i] = 0x12 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryCompileResponse) 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 *QueryCompileResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryCompileResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.CompiledItems) > 0 { + for iNdEx := len(m.CompiledItems) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.CompiledItems[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *QueryMetadataRequest) 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 *QueryMetadataRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryMetadataRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Code) > 0 { + i -= len(m.Code) + copy(dAtA[i:], m.Code) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Code))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryMetadataResponse) 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 *QueryMetadataResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryMetadataResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Metadata != nil { + { + size, err := m.Metadata.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryDelegatedPoolSupplyRequest) 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 *QueryDelegatedPoolSupplyRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryDelegatedPoolSupplyRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryDelegatedPoolSupplyResponse) 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 *QueryDelegatedPoolSupplyResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryDelegatedPoolSupplyResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Coins) > 0 { + for iNdEx := len(m.Coins) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Coins[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryDataRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.Path) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryDataResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Value) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryTxVmStatusRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.TxMeta.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryTxVmStatusResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.VmStatus.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryCompileRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.Code) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryCompileResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.CompiledItems) > 0 { + for _, e := range m.CompiledItems { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *QueryMetadataRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Code) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryMetadataResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Metadata != nil { + l = m.Metadata.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryDelegatedPoolSupplyRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryDelegatedPoolSupplyResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Coins) > 0 { + for _, e := range m.Coins { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryDataRequest) 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 ErrIntOverflowQuery + } + 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: QueryDataRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryDataRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = append(m.Address[:0], dAtA[iNdEx:postIndex]...) + if m.Address == nil { + m.Address = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Path", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Path = append(m.Path[:0], dAtA[iNdEx:postIndex]...) + if m.Path == nil { + m.Path = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryDataResponse) 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 ErrIntOverflowQuery + } + 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: QueryDataResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryDataResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Value = append(m.Value[:0], dAtA[iNdEx:postIndex]...) + if m.Value == nil { + m.Value = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryTxVmStatusRequest) 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 ErrIntOverflowQuery + } + 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: QueryTxVmStatusRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryTxVmStatusRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TxMeta", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TxMeta.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryTxVmStatusResponse) 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 ErrIntOverflowQuery + } + 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: QueryTxVmStatusResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryTxVmStatusResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field VmStatus", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.VmStatus.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryCompileRequest) 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 ErrIntOverflowQuery + } + 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: QueryCompileRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryCompileRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = append(m.Address[:0], dAtA[iNdEx:postIndex]...) + if m.Address == nil { + m.Address = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Code", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Code = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryCompileResponse) 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 ErrIntOverflowQuery + } + 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: QueryCompileResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryCompileResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CompiledItems", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CompiledItems = append(m.CompiledItems, CompiledItem{}) + if err := m.CompiledItems[len(m.CompiledItems)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryMetadataRequest) 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 ErrIntOverflowQuery + } + 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: QueryMetadataRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryMetadataRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Code", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Code = append(m.Code[:0], dAtA[iNdEx:postIndex]...) + if m.Code == nil { + m.Code = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryMetadataResponse) 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 ErrIntOverflowQuery + } + 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: QueryMetadataResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryMetadataResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Metadata == nil { + m.Metadata = &dvm.Metadata{} + } + if err := m.Metadata.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryDelegatedPoolSupplyRequest) 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 ErrIntOverflowQuery + } + 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: QueryDelegatedPoolSupplyRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryDelegatedPoolSupplyRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryDelegatedPoolSupplyResponse) 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 ErrIntOverflowQuery + } + 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: QueryDelegatedPoolSupplyResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryDelegatedPoolSupplyResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Coins", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Coins = append(m.Coins, types.Coin{}) + if err := m.Coins[len(m.Coins)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/vm/types/query.pb.gw.go b/x/vm/types/query.pb.gw.go new file mode 100644 index 0000000..f7518b2 --- /dev/null +++ b/x/vm/types/query.pb.gw.go @@ -0,0 +1,326 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: dfinance/vm/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage + +var ( + filter_Query_Data_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_Data_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryDataRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Data_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.Data(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Data_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryDataRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Data_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.Data(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_TxVmStatus_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_TxVmStatus_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryTxVmStatusRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_TxVmStatus_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.TxVmStatus(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_TxVmStatus_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryTxVmStatusRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_TxVmStatus_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.TxVmStatus(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_Compile_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_Compile_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryCompileRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Compile_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.Compile(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Compile_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryCompileRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Compile_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.Compile(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". +// UnaryRPC :call QueryServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_Data_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Data_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Data_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_TxVmStatus_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_TxVmStatus_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_TxVmStatus_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Compile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Compile_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Compile_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_Data_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Data_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Data_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_TxVmStatus_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_TxVmStatus_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_TxVmStatus_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Compile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Compile_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Compile_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_Data_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"dfinance", "vm", "v1beta1", "data"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_TxVmStatus_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"dfinance", "vm", "v1beta1", "tx_vm_status"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_Compile_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"dfinance", "vm", "v1beta1", "compile"}, "", runtime.AssumeColonVerbOpt(true))) +) + +var ( + forward_Query_Data_0 = runtime.ForwardResponseMessage + + forward_Query_TxVmStatus_0 = runtime.ForwardResponseMessage + + forward_Query_Compile_0 = runtime.ForwardResponseMessage +) diff --git a/x/vm/types/tx.pb.go b/x/vm/types/tx.pb.go new file mode 100644 index 0000000..b22fbc8 --- /dev/null +++ b/x/vm/types/tx.pb.go @@ -0,0 +1,518 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: dfinance/vm/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type MsgDeployModuleResponse struct { +} + +func (m *MsgDeployModuleResponse) Reset() { *m = MsgDeployModuleResponse{} } +func (m *MsgDeployModuleResponse) String() string { return proto.CompactTextString(m) } +func (*MsgDeployModuleResponse) ProtoMessage() {} +func (*MsgDeployModuleResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_34dee0a1e38a2d4b, []int{0} +} +func (m *MsgDeployModuleResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgDeployModuleResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgDeployModuleResponse.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 *MsgDeployModuleResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDeployModuleResponse.Merge(m, src) +} +func (m *MsgDeployModuleResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgDeployModuleResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDeployModuleResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgDeployModuleResponse proto.InternalMessageInfo + +type MsgExecuteScriptResponse struct { +} + +func (m *MsgExecuteScriptResponse) Reset() { *m = MsgExecuteScriptResponse{} } +func (m *MsgExecuteScriptResponse) String() string { return proto.CompactTextString(m) } +func (*MsgExecuteScriptResponse) ProtoMessage() {} +func (*MsgExecuteScriptResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_34dee0a1e38a2d4b, []int{1} +} +func (m *MsgExecuteScriptResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgExecuteScriptResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgExecuteScriptResponse.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 *MsgExecuteScriptResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgExecuteScriptResponse.Merge(m, src) +} +func (m *MsgExecuteScriptResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgExecuteScriptResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgExecuteScriptResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgExecuteScriptResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgDeployModuleResponse)(nil), "dfinance.vm.v1beta1.MsgDeployModuleResponse") + proto.RegisterType((*MsgExecuteScriptResponse)(nil), "dfinance.vm.v1beta1.MsgExecuteScriptResponse") +} + +func init() { proto.RegisterFile("dfinance/vm/tx.proto", fileDescriptor_34dee0a1e38a2d4b) } + +var fileDescriptor_34dee0a1e38a2d4b = []byte{ + // 283 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x91, 0x3f, 0x4e, 0xf4, 0x30, + 0x10, 0xc5, 0x37, 0xfa, 0xa4, 0xaf, 0xb0, 0xa0, 0x09, 0x2b, 0x01, 0x11, 0x72, 0xb1, 0x80, 0x68, + 0xc0, 0xd6, 0xc2, 0x09, 0x40, 0x50, 0xa6, 0x81, 0x8e, 0xce, 0xf6, 0x0e, 0xc6, 0x52, 0xe2, 0xb1, + 0xd6, 0x4e, 0x94, 0xbd, 0x05, 0xc7, 0xa2, 0x4c, 0x49, 0x89, 0x92, 0x8b, 0x20, 0xf2, 0x07, 0x11, + 0x04, 0xd2, 0x76, 0xf6, 0xbc, 0xdf, 0xf8, 0x8d, 0xe7, 0x91, 0xf9, 0xea, 0xc9, 0x58, 0x61, 0x15, + 0xf0, 0x32, 0xe7, 0xa1, 0x62, 0x6e, 0x8d, 0x01, 0xe3, 0xbd, 0xb1, 0xca, 0xca, 0x9c, 0x95, 0x4b, + 0x09, 0x41, 0x2c, 0x93, 0xb9, 0x46, 0x8d, 0x9d, 0xce, 0x3f, 0x4f, 0x3d, 0x9a, 0x1c, 0x69, 0x44, + 0x9d, 0x01, 0x17, 0xce, 0x70, 0x61, 0x2d, 0x06, 0x11, 0x0c, 0x5a, 0x3f, 0xa8, 0xc7, 0x0a, 0x7d, + 0x8e, 0x9e, 0x4b, 0xe1, 0x81, 0x0b, 0xa9, 0x0c, 0x1f, 0x5e, 0xeb, 0x2e, 0x03, 0x34, 0x99, 0xa1, + 0xcc, 0xfb, 0xea, 0xe2, 0x90, 0xec, 0xa7, 0x5e, 0xdf, 0x82, 0xcb, 0x70, 0x93, 0xe2, 0xaa, 0xc8, + 0xe0, 0x1e, 0xbc, 0x43, 0xeb, 0x61, 0x91, 0x90, 0x83, 0xd4, 0xeb, 0xbb, 0x0a, 0x54, 0x11, 0xe0, + 0x41, 0xad, 0x8d, 0x0b, 0xa3, 0x76, 0x59, 0x47, 0xe4, 0x5f, 0xea, 0x75, 0x2c, 0xc9, 0xce, 0xf7, + 0xde, 0xf8, 0x84, 0xfd, 0xf2, 0x27, 0xf6, 0xc3, 0x21, 0x39, 0xdf, 0x86, 0x1a, 0xbd, 0x62, 0x20, + 0xbb, 0x93, 0x21, 0xe2, 0xd3, 0xbf, 0xda, 0x27, 0x58, 0x72, 0xb1, 0x15, 0x36, 0xda, 0xdc, 0x5c, + 0xbf, 0x36, 0x34, 0xaa, 0x1b, 0x1a, 0xbd, 0x37, 0x34, 0x7a, 0x69, 0xe9, 0xac, 0x6e, 0xe9, 0xec, + 0xad, 0xa5, 0xb3, 0xc7, 0x33, 0x6d, 0xc2, 0x73, 0x21, 0x99, 0xc2, 0x9c, 0x7f, 0x2d, 0x71, 0xe5, + 0xfb, 0x0c, 0x78, 0xd5, 0x65, 0xba, 0x71, 0xe0, 0xe5, 0xff, 0x6e, 0xa7, 0x57, 0x1f, 0x01, 0x00, + 0x00, 0xff, 0xff, 0x5c, 0x91, 0x9c, 0x51, 0xef, 0x01, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { + // DeployModule deploys Move module/modules to VMStorage. + DeployModule(ctx context.Context, in *MsgDeployModule, opts ...grpc.CallOption) (*MsgDeployModuleResponse, error) + // ExecuteScript executes provided Move script. + ExecuteScript(ctx context.Context, in *MsgExecuteScript, opts ...grpc.CallOption) (*MsgExecuteScriptResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) DeployModule(ctx context.Context, in *MsgDeployModule, opts ...grpc.CallOption) (*MsgDeployModuleResponse, error) { + out := new(MsgDeployModuleResponse) + err := c.cc.Invoke(ctx, "/dfinance.vm.v1beta1.Msg/DeployModule", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) ExecuteScript(ctx context.Context, in *MsgExecuteScript, opts ...grpc.CallOption) (*MsgExecuteScriptResponse, error) { + out := new(MsgExecuteScriptResponse) + err := c.cc.Invoke(ctx, "/dfinance.vm.v1beta1.Msg/ExecuteScript", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + // DeployModule deploys Move module/modules to VMStorage. + DeployModule(context.Context, *MsgDeployModule) (*MsgDeployModuleResponse, error) + // ExecuteScript executes provided Move script. + ExecuteScript(context.Context, *MsgExecuteScript) (*MsgExecuteScriptResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) DeployModule(ctx context.Context, req *MsgDeployModule) (*MsgDeployModuleResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DeployModule not implemented") +} +func (*UnimplementedMsgServer) ExecuteScript(ctx context.Context, req *MsgExecuteScript) (*MsgExecuteScriptResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ExecuteScript not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_DeployModule_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgDeployModule) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).DeployModule(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/dfinance.vm.v1beta1.Msg/DeployModule", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).DeployModule(ctx, req.(*MsgDeployModule)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_ExecuteScript_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgExecuteScript) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).ExecuteScript(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/dfinance.vm.v1beta1.Msg/ExecuteScript", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).ExecuteScript(ctx, req.(*MsgExecuteScript)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "dfinance.vm.v1beta1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "DeployModule", + Handler: _Msg_DeployModule_Handler, + }, + { + MethodName: "ExecuteScript", + Handler: _Msg_ExecuteScript_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "dfinance/vm/tx.proto", +} + +func (m *MsgDeployModuleResponse) 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 *MsgDeployModuleResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgDeployModuleResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgExecuteScriptResponse) 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 *MsgExecuteScriptResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgExecuteScriptResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgDeployModuleResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgExecuteScriptResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgDeployModuleResponse) 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 ErrIntOverflowTx + } + 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: MsgDeployModuleResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgDeployModuleResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgExecuteScriptResponse) 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 ErrIntOverflowTx + } + 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: MsgExecuteScriptResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgExecuteScriptResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTx(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/vm/types/vm.pb.go b/x/vm/types/vm.pb.go new file mode 100644 index 0000000..deaa9f4 --- /dev/null +++ b/x/vm/types/vm.pb.go @@ -0,0 +1,1834 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: dfinance/vm/vm.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/codec/types" + dvm "github.com/dfinance/dstation/pkg/types/dvm" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + _ "github.com/regen-network/cosmos-proto" + _ "google.golang.org/protobuf/types/known/timestamppb" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type CompiledItem_CodeType int32 + +const ( + CompiledItem_MODULE CompiledItem_CodeType = 0 + CompiledItem_SCRIPT CompiledItem_CodeType = 1 +) + +var CompiledItem_CodeType_name = map[int32]string{ + 0: "MODULE", + 1: "SCRIPT", +} + +var CompiledItem_CodeType_value = map[string]int32{ + "MODULE": 0, + "SCRIPT": 1, +} + +func (x CompiledItem_CodeType) String() string { + return proto.EnumName(CompiledItem_CodeType_name, int32(x)) +} + +func (CompiledItem_CodeType) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_a1fbbb471026580b, []int{4, 0} +} + +// MsgExecuteScript defines a SDK message to execute a script with args to VM. +type MsgExecuteScript struct { + // Script sender address + Signer string `protobuf:"bytes,1,opt,name=signer,proto3" json:"signer,omitempty" yaml:"signer"` + // Script code + Script []byte `protobuf:"bytes,2,opt,name=script,proto3" json:"script,omitempty" yaml:"script"` + Args []MsgExecuteScript_ScriptArg `protobuf:"bytes,3,rep,name=args,proto3" json:"args" yaml:"args"` +} + +func (m *MsgExecuteScript) Reset() { *m = MsgExecuteScript{} } +func (m *MsgExecuteScript) String() string { return proto.CompactTextString(m) } +func (*MsgExecuteScript) ProtoMessage() {} +func (*MsgExecuteScript) Descriptor() ([]byte, []int) { + return fileDescriptor_a1fbbb471026580b, []int{0} +} +func (m *MsgExecuteScript) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgExecuteScript) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgExecuteScript.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 *MsgExecuteScript) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgExecuteScript.Merge(m, src) +} +func (m *MsgExecuteScript) XXX_Size() int { + return m.Size() +} +func (m *MsgExecuteScript) XXX_DiscardUnknown() { + xxx_messageInfo_MsgExecuteScript.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgExecuteScript proto.InternalMessageInfo + +type MsgExecuteScript_ScriptArg struct { + Type dvm.VMTypeTag `protobuf:"varint,1,opt,name=type,proto3,enum=dfinance.dvm.VMTypeTag" json:"type,omitempty" yaml:"type"` + Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty" yaml:"value"` +} + +func (m *MsgExecuteScript_ScriptArg) Reset() { *m = MsgExecuteScript_ScriptArg{} } +func (m *MsgExecuteScript_ScriptArg) String() string { return proto.CompactTextString(m) } +func (*MsgExecuteScript_ScriptArg) ProtoMessage() {} +func (*MsgExecuteScript_ScriptArg) Descriptor() ([]byte, []int) { + return fileDescriptor_a1fbbb471026580b, []int{0, 0} +} +func (m *MsgExecuteScript_ScriptArg) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgExecuteScript_ScriptArg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgExecuteScript_ScriptArg.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 *MsgExecuteScript_ScriptArg) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgExecuteScript_ScriptArg.Merge(m, src) +} +func (m *MsgExecuteScript_ScriptArg) XXX_Size() int { + return m.Size() +} +func (m *MsgExecuteScript_ScriptArg) XXX_DiscardUnknown() { + xxx_messageInfo_MsgExecuteScript_ScriptArg.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgExecuteScript_ScriptArg proto.InternalMessageInfo + +// MsgDeployModule defines a SDK message to deploy a module (contract) to VM. +type MsgDeployModule struct { + // Script sender address + Signer string `protobuf:"bytes,1,opt,name=signer,proto3" json:"signer,omitempty" yaml:"signer"` + // Module code + Modules [][]byte `protobuf:"bytes,2,rep,name=modules,proto3" json:"modules,omitempty" yaml:"modules"` +} + +func (m *MsgDeployModule) Reset() { *m = MsgDeployModule{} } +func (m *MsgDeployModule) String() string { return proto.CompactTextString(m) } +func (*MsgDeployModule) ProtoMessage() {} +func (*MsgDeployModule) Descriptor() ([]byte, []int) { + return fileDescriptor_a1fbbb471026580b, []int{1} +} +func (m *MsgDeployModule) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgDeployModule) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgDeployModule.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 *MsgDeployModule) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDeployModule.Merge(m, src) +} +func (m *MsgDeployModule) XXX_Size() int { + return m.Size() +} +func (m *MsgDeployModule) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDeployModule.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgDeployModule proto.InternalMessageInfo + +// TxVmStatus keeps VM statuses and errors for Tx. +type TxVmStatus struct { + // Tx hash [HEX string] + Hash string `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty" yaml:"hash"` + // VM statuses for the Tx + VmStatuses []VmStatus `protobuf:"bytes,2,rep,name=vm_statuses,json=vmStatuses,proto3" json:"vm_statuses" yaml:"vm_statuses"` +} + +func (m *TxVmStatus) Reset() { *m = TxVmStatus{} } +func (*TxVmStatus) ProtoMessage() {} +func (*TxVmStatus) Descriptor() ([]byte, []int) { + return fileDescriptor_a1fbbb471026580b, []int{2} +} +func (m *TxVmStatus) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TxVmStatus) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TxVmStatus.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 *TxVmStatus) XXX_Merge(src proto.Message) { + xxx_messageInfo_TxVmStatus.Merge(m, src) +} +func (m *TxVmStatus) XXX_Size() int { + return m.Size() +} +func (m *TxVmStatus) XXX_DiscardUnknown() { + xxx_messageInfo_TxVmStatus.DiscardUnknown(m) +} + +var xxx_messageInfo_TxVmStatus proto.InternalMessageInfo + +// VmStatus is a VM error response. +type VmStatus struct { + // Error Status: error / discard + Status string `protobuf:"bytes,1,opt,name=status,proto3" json:"status,omitempty" yaml:"status"` + // Major code + MajorCode string `protobuf:"bytes,2,opt,name=major_code,json=majorCode,proto3" json:"major_code,omitempty" yaml:"major_code"` + // Sub code + SubCode string `protobuf:"bytes,3,opt,name=sub_code,json=subCode,proto3" json:"sub_code,omitempty" yaml:"sub_code"` + // Detailed explanation of major code + StrCode string `protobuf:"bytes,4,opt,name=str_code,json=strCode,proto3" json:"str_code,omitempty" yaml:"str_code"` + // Error message + Message string `protobuf:"bytes,5,opt,name=message,proto3" json:"message,omitempty" yaml:"message"` +} + +func (m *VmStatus) Reset() { *m = VmStatus{} } +func (*VmStatus) ProtoMessage() {} +func (*VmStatus) Descriptor() ([]byte, []int) { + return fileDescriptor_a1fbbb471026580b, []int{3} +} +func (m *VmStatus) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *VmStatus) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_VmStatus.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 *VmStatus) XXX_Merge(src proto.Message) { + xxx_messageInfo_VmStatus.Merge(m, src) +} +func (m *VmStatus) XXX_Size() int { + return m.Size() +} +func (m *VmStatus) XXX_DiscardUnknown() { + xxx_messageInfo_VmStatus.DiscardUnknown(m) +} + +var xxx_messageInfo_VmStatus proto.InternalMessageInfo + +// CompiledItem contains VM compilation result. +type CompiledItem struct { + ByteCode []byte `protobuf:"bytes,1,opt,name=byte_code,json=byteCode,proto3" json:"byte_code,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Methods []*dvm.Function `protobuf:"bytes,3,rep,name=methods,proto3" json:"methods,omitempty"` + Types []*dvm.Struct `protobuf:"bytes,4,rep,name=types,proto3" json:"types,omitempty"` + CodeType CompiledItem_CodeType `protobuf:"varint,5,opt,name=code_type,json=codeType,proto3,enum=dfinance.vm.v1beta1.CompiledItem_CodeType" json:"code_type,omitempty"` +} + +func (m *CompiledItem) Reset() { *m = CompiledItem{} } +func (m *CompiledItem) String() string { return proto.CompactTextString(m) } +func (*CompiledItem) ProtoMessage() {} +func (*CompiledItem) Descriptor() ([]byte, []int) { + return fileDescriptor_a1fbbb471026580b, []int{4} +} +func (m *CompiledItem) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CompiledItem) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CompiledItem.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 *CompiledItem) XXX_Merge(src proto.Message) { + xxx_messageInfo_CompiledItem.Merge(m, src) +} +func (m *CompiledItem) XXX_Size() int { + return m.Size() +} +func (m *CompiledItem) XXX_DiscardUnknown() { + xxx_messageInfo_CompiledItem.DiscardUnknown(m) +} + +var xxx_messageInfo_CompiledItem proto.InternalMessageInfo + +func (m *CompiledItem) GetByteCode() []byte { + if m != nil { + return m.ByteCode + } + return nil +} + +func (m *CompiledItem) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *CompiledItem) GetMethods() []*dvm.Function { + if m != nil { + return m.Methods + } + return nil +} + +func (m *CompiledItem) GetTypes() []*dvm.Struct { + if m != nil { + return m.Types + } + return nil +} + +func (m *CompiledItem) GetCodeType() CompiledItem_CodeType { + if m != nil { + return m.CodeType + } + return CompiledItem_MODULE +} + +func init() { + proto.RegisterEnum("dfinance.vm.v1beta1.CompiledItem_CodeType", CompiledItem_CodeType_name, CompiledItem_CodeType_value) + proto.RegisterType((*MsgExecuteScript)(nil), "dfinance.vm.v1beta1.MsgExecuteScript") + proto.RegisterType((*MsgExecuteScript_ScriptArg)(nil), "dfinance.vm.v1beta1.MsgExecuteScript.ScriptArg") + proto.RegisterType((*MsgDeployModule)(nil), "dfinance.vm.v1beta1.MsgDeployModule") + proto.RegisterType((*TxVmStatus)(nil), "dfinance.vm.v1beta1.TxVmStatus") + proto.RegisterType((*VmStatus)(nil), "dfinance.vm.v1beta1.VmStatus") + proto.RegisterType((*CompiledItem)(nil), "dfinance.vm.v1beta1.CompiledItem") +} + +func init() { proto.RegisterFile("dfinance/vm/vm.proto", fileDescriptor_a1fbbb471026580b) } + +var fileDescriptor_a1fbbb471026580b = []byte{ + // 756 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0x4d, 0x4f, 0xe3, 0x46, + 0x18, 0xc7, 0xe3, 0xbc, 0x40, 0x32, 0x49, 0x21, 0x18, 0xda, 0x86, 0xa0, 0xc6, 0x91, 0x2b, 0xb5, + 0x29, 0x6a, 0xed, 0x42, 0x7b, 0x42, 0xbd, 0x10, 0xa0, 0x15, 0x52, 0xa3, 0x56, 0x4e, 0x8a, 0x2a, + 0x2e, 0xd1, 0xc4, 0x1e, 0x1c, 0x57, 0x19, 0x4f, 0xe4, 0x19, 0x5b, 0x44, 0xfd, 0x00, 0xad, 0xf6, + 0xb4, 0xc7, 0x95, 0xf6, 0xc2, 0xc7, 0x61, 0x6f, 0x1c, 0xf7, 0x14, 0xad, 0xe0, 0xb2, 0xe7, 0x7c, + 0x82, 0xd5, 0xbc, 0x38, 0x2f, 0x6c, 0x2e, 0x7b, 0xf2, 0xe3, 0xe7, 0xf9, 0x3d, 0x2f, 0xf3, 0x9f, + 0x17, 0xb0, 0xe7, 0xdd, 0x04, 0x21, 0x0c, 0x5d, 0x64, 0x27, 0xd8, 0x4e, 0xb0, 0x35, 0x8e, 0x08, + 0x23, 0xfa, 0x6e, 0xea, 0xb5, 0x12, 0x6c, 0x25, 0x47, 0x03, 0xc4, 0xe0, 0x51, 0x7d, 0xdf, 0x27, + 0xc4, 0x1f, 0x21, 0x5b, 0x20, 0x83, 0xf8, 0xc6, 0x86, 0xe1, 0x44, 0xf2, 0x75, 0xe3, 0x79, 0x88, + 0x05, 0x18, 0x51, 0x06, 0xf1, 0x58, 0x01, 0x7b, 0x3e, 0xf1, 0x89, 0x30, 0x6d, 0x6e, 0x29, 0xef, + 0xbe, 0x4b, 0x28, 0x26, 0xb4, 0x2f, 0x03, 0xf2, 0x27, 0xad, 0x38, 0x9f, 0xcb, 0x4b, 0xb0, 0xed, + 0x12, 0x8c, 0x49, 0xf8, 0x03, 0x9b, 0x8c, 0x51, 0x0a, 0x1c, 0xac, 0x00, 0x18, 0x31, 0xe8, 0x41, + 0x06, 0x65, 0xd0, 0x7c, 0x93, 0x05, 0xd5, 0x0e, 0xf5, 0x2f, 0x6e, 0x91, 0x1b, 0x33, 0xd4, 0x75, + 0xa3, 0x60, 0xcc, 0xf4, 0xef, 0xc0, 0x06, 0x0d, 0xfc, 0x10, 0x45, 0x35, 0xad, 0xa9, 0xb5, 0x4a, + 0xed, 0x9d, 0xd9, 0xd4, 0xf8, 0x6c, 0x02, 0xf1, 0xe8, 0xc4, 0x94, 0x7e, 0xd3, 0x51, 0x80, 0x40, + 0x45, 0x52, 0x2d, 0xdb, 0xd4, 0x5a, 0x95, 0x15, 0x54, 0xf8, 0x39, 0x2a, 0xab, 0xfe, 0x0d, 0xf2, + 0x30, 0xf2, 0x69, 0x2d, 0xd7, 0xcc, 0xb5, 0xca, 0xc7, 0xb6, 0xb5, 0x46, 0x39, 0xeb, 0xf9, 0x28, + 0x96, 0xfc, 0x9c, 0x46, 0x7e, 0x7b, 0xf7, 0x7e, 0x6a, 0x64, 0x66, 0x53, 0xa3, 0x2c, 0xab, 0xf3, + 0x52, 0xa6, 0x23, 0x2a, 0xd6, 0xff, 0x05, 0xa5, 0x39, 0xa7, 0xff, 0x02, 0xf2, 0x7c, 0xf5, 0x62, + 0xf4, 0xad, 0xe3, 0x2f, 0x17, 0x6d, 0xbc, 0x04, 0x5b, 0x57, 0x9d, 0xde, 0x64, 0x8c, 0x7a, 0xd0, + 0x6f, 0x6f, 0x2f, 0x4a, 0x71, 0xdc, 0x74, 0x44, 0x96, 0xfe, 0x0d, 0x28, 0x24, 0x70, 0x14, 0x23, + 0xb5, 0x9c, 0xea, 0x6c, 0x6a, 0x54, 0x24, 0x25, 0xdc, 0xa6, 0x23, 0xc3, 0x27, 0xc5, 0xff, 0xef, + 0x8c, 0xcc, 0xfb, 0x3b, 0x23, 0xb3, 0xb0, 0x4c, 0x06, 0xb6, 0x3b, 0xd4, 0x3f, 0x47, 0xe3, 0x11, + 0x99, 0x74, 0x88, 0x17, 0x8f, 0xd0, 0xa7, 0x28, 0xf9, 0x3d, 0xd8, 0xc4, 0x22, 0x89, 0xd6, 0xb2, + 0xcd, 0x5c, 0xab, 0xd2, 0xd6, 0x67, 0x53, 0x63, 0x4b, 0xb2, 0x2a, 0x60, 0x3a, 0x29, 0xb2, 0xd4, + 0xf5, 0xb5, 0x06, 0x40, 0xef, 0xf6, 0x0a, 0x77, 0x19, 0x64, 0x31, 0xd5, 0xbf, 0x06, 0xf9, 0x21, + 0xa4, 0x43, 0xd5, 0x6f, 0x69, 0x95, 0xdc, 0x6b, 0x3a, 0x22, 0xa8, 0x5f, 0x83, 0x72, 0x82, 0xfb, + 0x54, 0x64, 0xa8, 0x7e, 0xe5, 0xe3, 0xaf, 0xd6, 0xee, 0x48, 0x5a, 0xb8, 0x5d, 0x57, 0xfa, 0xeb, + 0x4a, 0x8e, 0x45, 0xbe, 0xe9, 0x80, 0x44, 0x51, 0x88, 0x9e, 0x54, 0xf8, 0x64, 0xaf, 0xd2, 0xe9, + 0xfe, 0xcb, 0x82, 0xe2, 0x7c, 0x36, 0xae, 0x86, 0xb0, 0xd6, 0xa8, 0x21, 0xfc, 0x5c, 0x0d, 0x89, + 0xfe, 0x0c, 0x00, 0x86, 0xff, 0x90, 0xa8, 0xef, 0x12, 0x4f, 0x6e, 0x46, 0xa9, 0xfd, 0xf9, 0x6c, + 0x6a, 0xec, 0x28, 0x41, 0xe6, 0x31, 0xd3, 0x29, 0x89, 0x9f, 0x33, 0xe2, 0x21, 0xdd, 0x02, 0x45, + 0x1a, 0x0f, 0x64, 0x4e, 0x4e, 0xe4, 0xec, 0xce, 0xa6, 0xc6, 0xb6, 0x6a, 0xa1, 0x22, 0xa6, 0xb3, + 0x49, 0xe3, 0xc1, 0x9c, 0x67, 0xaa, 0x47, 0xfe, 0x23, 0x9e, 0x45, 0x73, 0x9e, 0xc9, 0xfa, 0x7c, + 0x8f, 0x10, 0xa5, 0xd0, 0x47, 0xb5, 0x82, 0xc0, 0x97, 0xf7, 0x48, 0x06, 0xf8, 0x1e, 0x49, 0xeb, + 0x99, 0x12, 0x2f, 0xb2, 0xa0, 0x72, 0x46, 0xf0, 0x38, 0x18, 0x21, 0xef, 0x92, 0x21, 0xac, 0x1f, + 0x80, 0xd2, 0x60, 0xc2, 0x90, 0xec, 0xce, 0x05, 0xa9, 0x38, 0x45, 0xee, 0x10, 0x9d, 0x74, 0x90, + 0x0f, 0x21, 0x56, 0x2b, 0x77, 0x84, 0xad, 0xff, 0xc8, 0xbb, 0xb3, 0x21, 0xf1, 0xd2, 0x3b, 0xf4, + 0xc5, 0xea, 0xe1, 0xfe, 0x35, 0x0e, 0x5d, 0x16, 0x90, 0xd0, 0x49, 0x31, 0xfd, 0x10, 0x14, 0xc4, + 0x4b, 0x50, 0xcb, 0x0b, 0x7e, 0x6f, 0x95, 0xef, 0xb2, 0x28, 0x76, 0x99, 0x23, 0x11, 0xfd, 0x37, + 0x50, 0xe2, 0x93, 0xf4, 0xc5, 0xe5, 0x29, 0x88, 0xcb, 0x73, 0xb8, 0xf6, 0x44, 0x2c, 0x2f, 0xc2, + 0xe2, 0xc3, 0xf2, 0x2b, 0xe5, 0x14, 0x5d, 0x65, 0x99, 0x26, 0x28, 0xa6, 0x5e, 0x1d, 0x80, 0x8d, + 0xce, 0x1f, 0xe7, 0x7f, 0xfd, 0x7e, 0x51, 0xcd, 0x70, 0xbb, 0x7b, 0xe6, 0x5c, 0xfe, 0xd9, 0xab, + 0x6a, 0xed, 0xd3, 0xfb, 0xc7, 0x86, 0xf6, 0xf0, 0xd8, 0xd0, 0xde, 0x3d, 0x36, 0xb4, 0x97, 0x4f, + 0x8d, 0xcc, 0xc3, 0x53, 0x23, 0xf3, 0xf6, 0xa9, 0x91, 0xb9, 0xfe, 0xd6, 0x0f, 0xd8, 0x30, 0x1e, + 0x58, 0x2e, 0xc1, 0xf6, 0xe2, 0xe1, 0xe2, 0xa7, 0x22, 0x20, 0xa1, 0x7d, 0xcb, 0x1f, 0x5f, 0x31, + 0xef, 0x60, 0x43, 0x3c, 0x60, 0x3f, 0x7d, 0x08, 0x00, 0x00, 0xff, 0xff, 0xbb, 0x60, 0x04, 0x76, + 0x98, 0x05, 0x00, 0x00, +} + +func (m *MsgExecuteScript) 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 *MsgExecuteScript) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgExecuteScript) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Args) > 0 { + for iNdEx := len(m.Args) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Args[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintVm(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.Script) > 0 { + i -= len(m.Script) + copy(dAtA[i:], m.Script) + i = encodeVarintVm(dAtA, i, uint64(len(m.Script))) + i-- + dAtA[i] = 0x12 + } + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintVm(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgExecuteScript_ScriptArg) 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 *MsgExecuteScript_ScriptArg) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgExecuteScript_ScriptArg) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Value) > 0 { + i -= len(m.Value) + copy(dAtA[i:], m.Value) + i = encodeVarintVm(dAtA, i, uint64(len(m.Value))) + i-- + dAtA[i] = 0x12 + } + if m.Type != 0 { + i = encodeVarintVm(dAtA, i, uint64(m.Type)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *MsgDeployModule) 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 *MsgDeployModule) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgDeployModule) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Modules) > 0 { + for iNdEx := len(m.Modules) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Modules[iNdEx]) + copy(dAtA[i:], m.Modules[iNdEx]) + i = encodeVarintVm(dAtA, i, uint64(len(m.Modules[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintVm(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *TxVmStatus) 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 *TxVmStatus) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TxVmStatus) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.VmStatuses) > 0 { + for iNdEx := len(m.VmStatuses) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.VmStatuses[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintVm(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.Hash) > 0 { + i -= len(m.Hash) + copy(dAtA[i:], m.Hash) + i = encodeVarintVm(dAtA, i, uint64(len(m.Hash))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *VmStatus) 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 *VmStatus) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *VmStatus) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Message) > 0 { + i -= len(m.Message) + copy(dAtA[i:], m.Message) + i = encodeVarintVm(dAtA, i, uint64(len(m.Message))) + i-- + dAtA[i] = 0x2a + } + if len(m.StrCode) > 0 { + i -= len(m.StrCode) + copy(dAtA[i:], m.StrCode) + i = encodeVarintVm(dAtA, i, uint64(len(m.StrCode))) + i-- + dAtA[i] = 0x22 + } + if len(m.SubCode) > 0 { + i -= len(m.SubCode) + copy(dAtA[i:], m.SubCode) + i = encodeVarintVm(dAtA, i, uint64(len(m.SubCode))) + i-- + dAtA[i] = 0x1a + } + if len(m.MajorCode) > 0 { + i -= len(m.MajorCode) + copy(dAtA[i:], m.MajorCode) + i = encodeVarintVm(dAtA, i, uint64(len(m.MajorCode))) + i-- + dAtA[i] = 0x12 + } + if len(m.Status) > 0 { + i -= len(m.Status) + copy(dAtA[i:], m.Status) + i = encodeVarintVm(dAtA, i, uint64(len(m.Status))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *CompiledItem) 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 *CompiledItem) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CompiledItem) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.CodeType != 0 { + i = encodeVarintVm(dAtA, i, uint64(m.CodeType)) + i-- + dAtA[i] = 0x28 + } + if len(m.Types) > 0 { + for iNdEx := len(m.Types) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Types[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintVm(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + if len(m.Methods) > 0 { + for iNdEx := len(m.Methods) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Methods[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintVm(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintVm(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0x12 + } + if len(m.ByteCode) > 0 { + i -= len(m.ByteCode) + copy(dAtA[i:], m.ByteCode) + i = encodeVarintVm(dAtA, i, uint64(len(m.ByteCode))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintVm(dAtA []byte, offset int, v uint64) int { + offset -= sovVm(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgExecuteScript) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovVm(uint64(l)) + } + l = len(m.Script) + if l > 0 { + n += 1 + l + sovVm(uint64(l)) + } + if len(m.Args) > 0 { + for _, e := range m.Args { + l = e.Size() + n += 1 + l + sovVm(uint64(l)) + } + } + return n +} + +func (m *MsgExecuteScript_ScriptArg) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Type != 0 { + n += 1 + sovVm(uint64(m.Type)) + } + l = len(m.Value) + if l > 0 { + n += 1 + l + sovVm(uint64(l)) + } + return n +} + +func (m *MsgDeployModule) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovVm(uint64(l)) + } + if len(m.Modules) > 0 { + for _, b := range m.Modules { + l = len(b) + n += 1 + l + sovVm(uint64(l)) + } + } + return n +} + +func (m *TxVmStatus) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Hash) + if l > 0 { + n += 1 + l + sovVm(uint64(l)) + } + if len(m.VmStatuses) > 0 { + for _, e := range m.VmStatuses { + l = e.Size() + n += 1 + l + sovVm(uint64(l)) + } + } + return n +} + +func (m *VmStatus) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Status) + if l > 0 { + n += 1 + l + sovVm(uint64(l)) + } + l = len(m.MajorCode) + if l > 0 { + n += 1 + l + sovVm(uint64(l)) + } + l = len(m.SubCode) + if l > 0 { + n += 1 + l + sovVm(uint64(l)) + } + l = len(m.StrCode) + if l > 0 { + n += 1 + l + sovVm(uint64(l)) + } + l = len(m.Message) + if l > 0 { + n += 1 + l + sovVm(uint64(l)) + } + return n +} + +func (m *CompiledItem) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ByteCode) + if l > 0 { + n += 1 + l + sovVm(uint64(l)) + } + l = len(m.Name) + if l > 0 { + n += 1 + l + sovVm(uint64(l)) + } + if len(m.Methods) > 0 { + for _, e := range m.Methods { + l = e.Size() + n += 1 + l + sovVm(uint64(l)) + } + } + if len(m.Types) > 0 { + for _, e := range m.Types { + l = e.Size() + n += 1 + l + sovVm(uint64(l)) + } + } + if m.CodeType != 0 { + n += 1 + sovVm(uint64(m.CodeType)) + } + return n +} + +func sovVm(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozVm(x uint64) (n int) { + return sovVm(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgExecuteScript) 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 ErrIntOverflowVm + } + 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: MsgExecuteScript: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgExecuteScript: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Script", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Script = append(m.Script[:0], dAtA[iNdEx:postIndex]...) + if m.Script == nil { + m.Script = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Args", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Args = append(m.Args, MsgExecuteScript_ScriptArg{}) + if err := m.Args[len(m.Args)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipVm(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthVm + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgExecuteScript_ScriptArg) 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 ErrIntOverflowVm + } + 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: ScriptArg: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ScriptArg: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) + } + m.Type = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Type |= dvm.VMTypeTag(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Value = append(m.Value[:0], dAtA[iNdEx:postIndex]...) + if m.Value == nil { + m.Value = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipVm(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthVm + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgDeployModule) 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 ErrIntOverflowVm + } + 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: MsgDeployModule: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgDeployModule: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Modules", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Modules = append(m.Modules, make([]byte, postIndex-iNdEx)) + copy(m.Modules[len(m.Modules)-1], dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipVm(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthVm + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *TxVmStatus) 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 ErrIntOverflowVm + } + 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: TxVmStatus: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TxVmStatus: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Hash = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field VmStatuses", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.VmStatuses = append(m.VmStatuses, VmStatus{}) + if err := m.VmStatuses[len(m.VmStatuses)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipVm(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthVm + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *VmStatus) 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 ErrIntOverflowVm + } + 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: VmStatus: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: VmStatus: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Status = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MajorCode", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MajorCode = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SubCode", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SubCode = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StrCode", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.StrCode = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Message", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Message = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipVm(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthVm + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CompiledItem) 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 ErrIntOverflowVm + } + 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: CompiledItem: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CompiledItem: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ByteCode", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ByteCode = append(m.ByteCode[:0], dAtA[iNdEx:postIndex]...) + if m.ByteCode == nil { + m.ByteCode = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Methods", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Methods = append(m.Methods, &dvm.Function{}) + if err := m.Methods[len(m.Methods)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Types", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthVm + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthVm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Types = append(m.Types, &dvm.Struct{}) + if err := m.Types[len(m.Types)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CodeType", wireType) + } + m.CodeType = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CodeType |= CompiledItem_CodeType(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipVm(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthVm + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipVm(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowVm + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowVm + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowVm + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthVm + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupVm + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthVm + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthVm = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowVm = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupVm = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/vm/types/vm_ifaces.go b/x/vm/types/vm_ifaces.go new file mode 100644 index 0000000..25e9801 --- /dev/null +++ b/x/vm/types/vm_ifaces.go @@ -0,0 +1,35 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + dvmTypes "github.com/dfinance/dstation/pkg/types/dvm" +) + +// DSDataMiddleware defines prototype for DSServer middleware. +type DSDataMiddleware func(ctx sdk.Context, path *dvmTypes.VMAccessPath) ([]byte, error) + +// VMStorage interface defines VM storage IO operations: WriteSet ops. +type VMStorage interface { + // HasValue checks if VMStorage has a writeSet data by dvmTypes.VMAccessPath. + HasValue(ctx sdk.Context, accessPath *dvmTypes.VMAccessPath) bool + // GetValue returns a VMStorage writeSet data by dvmTypes.VMAccessPath. + GetValue(ctx sdk.Context, accessPath *dvmTypes.VMAccessPath) []byte + // SetValue sets the VMStorage writeSet data by dvmTypes.VMAccessPath. + SetValue(ctx sdk.Context, accessPath *dvmTypes.VMAccessPath, value []byte) + // DelValue removes the VMStorage writeSet data by dvmTypes.VMAccessPath. + DelValue(ctx sdk.Context, accessPath *dvmTypes.VMAccessPath) +} + +// CurrencyInfoResProvider interfaces defines DVM CurrencyInfo resource provider. +type CurrencyInfoResProvider interface { + // GetVmCurrencyInfo returns dvmTypes.CurrencyInfo resource if found. + GetVmCurrencyInfo(ctx sdk.Context, denom string) *dvmTypes.CurrencyInfo +} + +// AccountBalanceResProvider interface defines DVM native account balance resource provider. +type AccountBalanceResProvider interface { + // GetVmAccountBalance returns VM account native balance resource (SDK account balance). + // Contract: always returns non-nil value. + GetVmAccountBalance(ctx sdk.Context, accAddress sdk.AccAddress, denom string) *dvmTypes.U128 +}