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) + + + + +
+ +## 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. | + + + + + + + + + + + + + +## 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) | | | + + + + + + + + +## 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) | | | + + + + + + + + +## 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) | | | + + + + + + + + +## 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) | | | + + + + + + + + +## 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) | + + + + + + + + + + + + + + + + + + +## 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 | + + + + + + + + + + + + + + + + + + +## 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 | | + + + + + + + + + + + + + +## 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. | | + + + + + + + + +## 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