diff --git a/.dockerignore b/.dockerignore index 9e0f33074..8de3f1617 100644 --- a/.dockerignore +++ b/.dockerignore @@ -19,7 +19,6 @@ schema1.svg **/*.test **/debug **/node_modules -/docker-images /test /vendor coverage.txt diff --git a/.golangci.yml b/.golangci.yml index 87d809bf8..1dfcbd3ea 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -15,16 +15,6 @@ linters-settings: misspell: locale: US -issues: - exclude: - - "ineffective break statement. Did you mean to break out of the outer loop" - - exclude-rules: - - path: ext/xvalidator/validator.go - linters: - - golint - text: "exported var Translator should have its own declaration" - linters: disable-all: true enable: @@ -51,3 +41,5 @@ linters: - unused - varcheck - whitespace + - depguard + - goconst diff --git a/CHANGELOG.md b/CHANGELOG.md index 58e92db5e..43a5bc6c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,48 @@ # Changelog +## [v0.21.0](https://github.com/mesg-foundation/engine/releases/tag/v0.21.0) + +#### Breaking Changes + +- ([#1737](https://github.com/mesg-foundation/engine/pull/1737)) Add support for any type of data to filter. +- ([#1739](https://github.com/mesg-foundation/engine/pull/1739)) Add reference system to filter. +- ([#1774](https://github.com/mesg-foundation/engine/pull/1774)) Remove deprecated gRPC API. +- ([#1783](https://github.com/mesg-foundation/engine/pull/1783)) Calculate the instance env hash with only the customized env. + +#### Added + +- ([#1737](https://github.com/mesg-foundation/engine/pull/1737)) Add support for any type of data to filter. +- ([#1739](https://github.com/mesg-foundation/engine/pull/1739)) Add reference system to filter. +- ([#1749](https://github.com/mesg-foundation/engine/pull/1749)) Add more validation on resources. +- ([#1758](https://github.com/mesg-foundation/engine/pull/1758)) Introduce a simple LCD client. +- ([#1759](https://github.com/mesg-foundation/engine/pull/1759)) add 2 more linters and remove useless exclusion. +- ([#1767](https://github.com/mesg-foundation/engine/pull/1767)) New Runner gRPC API. +- ([#1768](https://github.com/mesg-foundation/engine/pull/1768)) Add lcd endpoints and commands exists to runner and process. +- ([#1771](https://github.com/mesg-foundation/engine/pull/1771)) Add Orchestrator gRPC API. +- ([#1780](https://github.com/mesg-foundation/engine/pull/1780)) Add info to cosmos version on build. + +#### Changed + +- ([#1751](https://github.com/mesg-foundation/engine/pull/1751)) Replace gRPC by LCD as much as possible from e2e tests. +- ([#1754](https://github.com/mesg-foundation/engine/pull/1754)) Update lcd service hash endpoint to use a dedicated request structure. +- ([#1755](https://github.com/mesg-foundation/engine/pull/1755)) Update lcd process hash endpoint to use a dedicated request structure. +- ([#1756](https://github.com/mesg-foundation/engine/pull/1756)) Change gogoproto's customtype to casttype. +- ([#1757](https://github.com/mesg-foundation/engine/pull/1757)) Replace runner gRPC by LCD in e2e tests. +- ([#1761](https://github.com/mesg-foundation/engine/pull/1761)) Remove module suffix from lot of places. +- ([#1769](https://github.com/mesg-foundation/engine/pull/1769)) Update cosmos events. +- ([#1773](https://github.com/mesg-foundation/engine/pull/1773)) Use new event API in e2e tests. +- ([#1775](https://github.com/mesg-foundation/engine/pull/1775)) Simplify container. +- ([#1781](https://github.com/mesg-foundation/engine/pull/1781)) Switch back to default staking coins of cosmos. + +#### Fixed + +- ([#1746](https://github.com/mesg-foundation/engine/pull/1746)) Add "dive" validation to all repeated message in the proto files. +- ([#1762](https://github.com/mesg-foundation/engine/pull/1762)) Fix account sequence desynchronisation when error. + +#### Dependencies + +- ([#1752](https://github.com/mesg-foundation/engine/pull/1752)) Update to cosmos-sdk v0.38.2 and tendermint v0.33.2. + ## [v0.20.0](https://github.com/mesg-foundation/engine/releases/tag/v0.20.0) #### Added diff --git a/app/app.go b/app/app.go index 826148d51..ebcb1faf9 100644 --- a/app/app.go +++ b/app/app.go @@ -25,7 +25,6 @@ import ( "github.com/cosmos/cosmos-sdk/x/slashing" "github.com/cosmos/cosmos-sdk/x/staking" "github.com/cosmos/cosmos-sdk/x/supply" - "github.com/mesg-foundation/engine/protobuf/api" "github.com/mesg-foundation/engine/protobuf/types" "github.com/mesg-foundation/engine/x/execution" "github.com/mesg-foundation/engine/x/instance" @@ -85,7 +84,6 @@ func MakeCodec() *codec.Codec { sdk.RegisterCodec(cdc) codec.RegisterCrypto(cdc) types.RegisterCodec(cdc) - api.RegisterCodec(cdc) return cdc.Seal() } diff --git a/cmd/mesg-cli/main.go b/cmd/mesg-cli/main.go index 84c888dee..698273735 100644 --- a/cmd/mesg-cli/main.go +++ b/cmd/mesg-cli/main.go @@ -17,7 +17,6 @@ import ( "github.com/cosmos/cosmos-sdk/x/bank" bankcmd "github.com/cosmos/cosmos-sdk/x/bank/client/cli" "github.com/mesg-foundation/engine/app" - "github.com/mesg-foundation/engine/config" "github.com/mesg-foundation/engine/cosmos" "github.com/spf13/cobra" "github.com/spf13/viper" @@ -32,22 +31,12 @@ func main() { // Instantiate the codec for the command line application cdc := app.MakeCodec() - // Read in the configuration file for the sdk - // TODO: change back when more refactor is done - // config := sdk.GetConfig() - // config.SetBech32PrefixForAccount(sdk.Bech32PrefixAccAddr, sdk.Bech32PrefixAccPub) - // config.SetBech32PrefixForValidator(sdk.Bech32PrefixValAddr, sdk.Bech32PrefixValPub) - // config.SetBech32PrefixForConsensusNode(sdk.Bech32PrefixConsAddr, sdk.Bech32PrefixConsPub) - // config.Seal() - cfg, err := config.New() - if err != nil { - panic(err) - } - cosmos.CustomizeConfig(cfg) + // init the config of cosmos + cosmos.InitConfig() rootCmd := &cobra.Command{ - Use: "mesg-cli", - Short: "Command line interface for interacting with appd", + Use: version.ClientName, + Short: "Command line interface for interacting with " + version.Name, } // Add --chain-id to persistent flags and mark it required @@ -66,6 +55,8 @@ func main() { lcd.ServeCommand(cdc, registerRoutes), flags.LineBreak, keys.Commands(), + signCommand(), + verifySignCommand(), flags.LineBreak, version.Cmd, flags.NewCompletionCmd(rootCmd, true), @@ -74,8 +65,7 @@ func main() { // Add flags and prefix all env exposed with MESG executor := cli.PrepareMainCmd(rootCmd, "MESG", app.DefaultCLIHome) - err = executor.Execute() - if err != nil { + if err := executor.Execute(); err != nil { fmt.Printf("Failed executing CLI command: %s, exiting...\n", err) os.Exit(1) } diff --git a/cmd/mesg-cli/sign.go b/cmd/mesg-cli/sign.go new file mode 100644 index 000000000..8396d336a --- /dev/null +++ b/cmd/mesg-cli/sign.go @@ -0,0 +1,76 @@ +package main + +import ( + "bufio" + "encoding/base64" + "fmt" + + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/crypto/keys" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/spf13/cobra" + "github.com/spf13/viper" +) + +func signCommand() *cobra.Command { + cmd := &cobra.Command{ + Use: "sign ", + Short: "Sign the given message", + Args: cobra.MinimumNArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + if len(args) != 2 { + return fmt.Errorf("must have exactly 2 args: name of the account to use and the message to sign") + } + buf := bufio.NewReader(cmd.InOrStdin()) + kb, err := keys.NewKeyring(sdk.KeyringServiceName(), viper.GetString(flags.FlagKeyringBackend), viper.GetString(flags.FlagHome), buf) + if err != nil { + return err + } + signature, _, err := kb.Sign(args[0], "", []byte(args[1])) + if err != nil { + return err + } + fmt.Println(base64.StdEncoding.EncodeToString(signature)) + return nil + }, + } + cmd.PersistentFlags().String(flags.FlagKeyringBackend, flags.DefaultKeyringBackend, "Select keyring's backend (os|file|test)") + viper.BindPFlag(flags.FlagKeyringBackend, cmd.Flags().Lookup(flags.FlagKeyringBackend)) + return cmd +} + +func verifySignCommand() *cobra.Command { + cmd := &cobra.Command{ + Use: "verifySign ", + Short: "Verify the signature of the given message", + Args: cobra.MinimumNArgs(3), + RunE: func(cmd *cobra.Command, args []string) error { + if len(args) != 3 { + return fmt.Errorf("must have exactly 2 args: name of the account to use and the message used to sign, and the signature") + } + buf := bufio.NewReader(cmd.InOrStdin()) + kb, err := keys.NewKeyring(sdk.KeyringServiceName(), viper.GetString(flags.FlagKeyringBackend), viper.GetString(flags.FlagHome), buf) + if err != nil { + return err + } + acc, err := kb.Get(args[0]) + if err != nil { + return err + } + signature, err := base64.StdEncoding.DecodeString(args[2]) + if err != nil { + return err + } + verify := acc.GetPubKey().VerifyBytes([]byte(args[1]), signature) + if verify { + fmt.Println("verification succeed") + } else { + fmt.Println("verification failed") + } + return nil + }, + } + cmd.PersistentFlags().String(flags.FlagKeyringBackend, flags.DefaultKeyringBackend, "Select keyring's backend (os|file|test)") + viper.BindPFlag(flags.FlagKeyringBackend, cmd.Flags().Lookup(flags.FlagKeyringBackend)) + return cmd +} diff --git a/cmd/mesg-daemon/main.go b/cmd/mesg-daemon/main.go index 85c722116..1904a3c91 100644 --- a/cmd/mesg-daemon/main.go +++ b/cmd/mesg-daemon/main.go @@ -10,11 +10,11 @@ import ( "github.com/cosmos/cosmos-sdk/server" "github.com/cosmos/cosmos-sdk/store" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/x/auth" genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli" "github.com/cosmos/cosmos-sdk/x/staking" "github.com/mesg-foundation/engine/app" - "github.com/mesg-foundation/engine/config" "github.com/mesg-foundation/engine/cosmos" "github.com/spf13/cobra" "github.com/spf13/viper" @@ -32,23 +32,14 @@ var invCheckPeriod uint func main() { cdc := app.MakeCodec() - // TODO: put back when more refactor is done - // config := sdk.GetConfig() - // config.SetBech32PrefixForAccount(sdk.Bech32PrefixAccAddr, sdk.Bech32PrefixAccPub) - // config.SetBech32PrefixForValidator(sdk.Bech32PrefixValAddr, sdk.Bech32PrefixValPub) - // config.SetBech32PrefixForConsensusNode(sdk.Bech32PrefixConsAddr, sdk.Bech32PrefixConsPub) - // config.Seal() - cfg, err := config.New() - if err != nil { - panic(err) - } - cosmos.CustomizeConfig(cfg) + // init the config of cosmos + cosmos.InitConfig() ctx := server.NewDefaultContext() cobra.EnableCommandSorting = false rootCmd := &cobra.Command{ - Use: "mesg-daemon", - Short: "app Daemon (server)", + Use: version.ServerName, + Short: "Engine Daemon (server)", PersistentPreRunE: server.PersistentPreRunEFn(ctx), } @@ -72,8 +63,7 @@ func main() { executor := cli.PrepareBaseCmd(rootCmd, "AU", app.DefaultNodeHome) rootCmd.PersistentFlags().UintVar(&invCheckPeriod, flagInvCheckPeriod, 0, "Assert registered invariants every N blocks") - err = executor.Execute() - if err != nil { + if err := executor.Execute(); err != nil { panic(err) } } diff --git a/config/config.go b/config/config.go index 9e1aed9b3..17b22735b 100644 --- a/config/config.go +++ b/config/config.go @@ -7,15 +7,24 @@ import ( "path/filepath" "time" - sdkcosmos "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/go-bip39" + "github.com/mesg-foundation/engine/ext/xvalidator" homedir "github.com/mitchellh/go-homedir" "github.com/sirupsen/logrus" tmconfig "github.com/tendermint/tendermint/config" - "gopkg.in/go-playground/validator.v9" "gopkg.in/yaml.v2" ) +const ( + // CosmosBech32MainPrefix defines the main Bech32 prefix. + CosmosBech32MainPrefix = "mesgtest" + + // CosmosCoinType is the mesg registered coin type from https://github.com/satoshilabs/slips/blob/master/slip-0044.md. + CosmosCoinType = uint32(470) + + // FullFundraiserPath is the parts of the BIP44 HD path that are fixed by what we used during the fundraiser. + FullFundraiserPath = "44'/470'/0'/0/0" +) + const ( defaultConfigFileName = "config.yml" envPathKey = "MESG_PATH" @@ -31,6 +40,9 @@ type Config struct { DefaultExecutionPrice string `validate:"required"` + // AuthorizedPubKeys are the bech32 public key of the accounts that are authorized to call the gRPC Admin API. + AuthorizedPubKeys []string `validate:"dive,required,bech32accpubkey" yaml:"authorized_pubkeys"` + Server struct { Address string `validate:"required"` } @@ -50,28 +62,12 @@ type Config struct { RelativePath string `validate:"required"` // Minimum gas prices for transactions. - MinGasPrices string `validate:"required"` - - // Token name to use in the staking module. - StakeTokenDenom string `validate:"required"` - - // Bech32MainPrefix defines the main Bech32 prefix. - Bech32MainPrefix string `validate:"required"` - - // CoinType is the mesg registered coin type from https://github.com/satoshilabs/slips/blob/master/slip-0044.md. - CoinType uint32 `validate:"required"` - - // BIP44Prefix is the parts of the BIP44 HD path that are fixed by what we used during the fundraiser. - FullFundraiserPath string `validate:"required"` - - // Power reduction between the staking token and the voting power on tendermint. - PowerReduction int64 `validate:"required"` + MinGasPrices string `validate:"required,deccoins"` } DevGenesis struct { - ChainID string `validate:"required"` - InitialBalances string `validate:"required"` - ValidatorDelegationCoin string `validate:"required"` + ChainID string `validate:"required"` + InitialBalances string `validate:"required,coins"` } Account struct { @@ -79,7 +75,7 @@ type Config struct { Password string `validate:"required"` Number uint32 Index uint32 - Mnemonic string + Mnemonic string `validate:"omitempty,mnemonic"` } } @@ -107,6 +103,7 @@ func defaultConfig() (*Config, error) { c.Tendermint.RelativePath = "tendermint" c.Tendermint.Config = tmconfig.DefaultConfig() c.Tendermint.Config.RPC.ListenAddress = "tcp://0.0.0.0:26657" + c.Tendermint.Config.RPC.MaxSubscriptionsPerClient = 100 c.Tendermint.Config.P2P.AddrBookStrict = false c.Tendermint.Config.P2P.AllowDuplicateIP = true c.Tendermint.Config.Consensus.TimeoutCommit = 5 * time.Second @@ -116,15 +113,9 @@ func defaultConfig() (*Config, error) { c.Cosmos.RelativePath = "cosmos" c.Cosmos.MinGasPrices = "1.0atto" - c.Cosmos.StakeTokenDenom = "atto" - c.Cosmos.Bech32MainPrefix = "mesgtest" - c.Cosmos.CoinType = 470 - c.Cosmos.FullFundraiserPath = "44'/470'/0'/0/0" // TODO: is it really useful? - c.Cosmos.PowerReduction = 18 c.DevGenesis.ChainID = "mesg-dev-chain" - c.DevGenesis.InitialBalances = "250000000000000000000000000atto" // 250 000 000 * 10^18 - c.DevGenesis.ValidatorDelegationCoin = "1000000000000000000000000atto" // 1 000 000 * 10^18 + c.DevGenesis.InitialBalances = "250000000000000000000000000atto,100000000stake" // 250 000 000 * 10^18 atto + 100,000,000 stake c.Account.Name = "engine" c.Account.Password = "pass" @@ -196,20 +187,8 @@ func (c *Config) validate() error { if _, err := logrus.ParseLevel(c.Log.Level); err != nil { return fmt.Errorf("config log.level error: %w", err) } - if c.Account.Mnemonic != "" && !bip39.IsMnemonicValid(c.Account.Mnemonic) { - return fmt.Errorf("config account.mnemonic error: mnemonic is not valid") - } if err := c.Tendermint.Config.ValidateBasic(); err != nil { return fmt.Errorf("config tendermint error: %w", err) } - if _, err := sdkcosmos.ParseDecCoins(c.Cosmos.MinGasPrices); err != nil { - return fmt.Errorf("config cosmos.mingasprices error: %w", err) - } - if _, err := sdkcosmos.ParseCoins(c.DevGenesis.InitialBalances); err != nil { - return fmt.Errorf("config devgenesis.initialbalances error: %w", err) - } - if _, err := sdkcosmos.ParseCoin(c.DevGenesis.ValidatorDelegationCoin); err != nil { - return fmt.Errorf("config devgenesis.validatordelegationcoin error: %w", err) - } - return validator.New().Struct(c) + return xvalidator.Struct(c) } diff --git a/container/container.go b/container/container.go index c2684a049..3f12b411f 100644 --- a/container/container.go +++ b/container/container.go @@ -1,28 +1,45 @@ package container import ( - "bytes" "context" - "encoding/json" + "encoding/base64" "errors" "fmt" - "io" "io/ioutil" + "net" + "net/http" + "os" + "strconv" "strings" "time" "github.com/docker/cli/cli/command/image/build" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" + "github.com/docker/docker/api/types/mount" + "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/client" "github.com/docker/docker/errdefs" "github.com/docker/docker/pkg/archive" + "github.com/docker/docker/pkg/idtools" + "github.com/mesg-foundation/engine/ext/xerrors" + "github.com/mesg-foundation/engine/ext/xnet" + "github.com/mesg-foundation/engine/ext/xos" + "github.com/mesg-foundation/engine/hash" + "github.com/mesg-foundation/engine/service" ) -// defaultStopGracePeriod is the timeout value between stopping a container and killing it. -const defaultStopGracePeriod = 10 * time.Second +const ( + // defaultStopGracePeriod is the timeout value between stopping a container and killing it. + defaultStopGracePeriod = 10 * time.Second + + defaultMaxAttempts = uint64(3) -var errSwarmNotInit = errors.New(`docker swarm is not initialized. run "docker swarm init" and try again`) + servicePrefix = "mesg_srv_" + imageTag = "mesg:" + + pollingTime = 500 * time.Millisecond +) // Status of the service. type Status uint @@ -35,7 +52,7 @@ const ( RUNNING ) -// statuses is a struct used to map service and contaienr statuses. +// statuses is a struct used to map service and container statuses. var statuses = []struct { container bool service bool @@ -47,63 +64,67 @@ var statuses = []struct { {service: false, container: false, status: STOPPED}, } -// buildResponse is the object that is returned by the docker build api. -type buildResponse struct { - Stream string `json:"stream"` - Error string `json:"error"` -} - -// Container describes the API of container package. -type Container interface { - Build(path string) (tag string, err error) - CreateNetwork(namespace string) (id string, err error) - DeleteNetwork(namespace string) error - SharedNetworkID() string - StartService(options ServiceOptions) (serviceID string, err error) - StopService(namespace string) (err error) - DeleteVolume(name string) error -} - -// DockerContainer provides high level interactions with Docker API for MESG. -type DockerContainer struct { +// Container starts and stops the MESG Service in Docker Container. +type Container struct { // client is a Docker client. client client.CommonAPIClient - // namespace prefix. - nsprefix string - - // sharedNetworkID is cache for an id network. - sharedNetworkID string + ipfsEndpoint string + engineEndpoint string + engineName string + engineNetwork string } -// New creates a new Container with given options. -func New(nsprefix string) (*DockerContainer, error) { +// New initializes the Container struct by connecting creating the Docker client. +func New(ipfsEndpoint, engineName, engineAddress, engineNetwork string) (*Container, error) { client, err := client.NewClientWithOpts(client.FromEnv) if err != nil { return nil, err } client.NegotiateAPIVersion(context.Background()) - c := &DockerContainer{ - client: client, - nsprefix: nsprefix, + _, port, err := xnet.SplitHostPort(engineAddress) + if err != nil { + return nil, err } - if err := c.isSwarmInit(); err != nil { - return nil, err + return &Container{ + client: client, + ipfsEndpoint: ipfsEndpoint, + engineEndpoint: net.JoinHostPort(engineName, strconv.Itoa(port)), + engineName: engineName, + engineNetwork: engineNetwork, + }, nil +} + +// Build the imge of the container +func (c *Container) Build(srv *service.Service) error { + // download and untar service context into path. + path, err := ioutil.TempDir("", "mesg") + if err != nil { + return err } + defer os.RemoveAll(path) - if err := c.createSharedNetwork(); err != nil { - return nil, err + resp, err := http.Get(c.ipfsEndpoint + srv.Source) + if err != nil { + return err + } + if resp.StatusCode != 200 { + return errors.New("service's source code is not reachable, status: " + resp.Status + ", url: " + c.ipfsEndpoint + srv.Source) + } + defer resp.Body.Close() + + if err := archive.Untar(resp.Body, path, &archive.TarOptions{ChownOpts: &idtools.Identity{ + UID: os.Geteuid(), + GID: os.Getegid()}, + }); err != nil { + return err } - return c, nil -} -// Build builds a docker image. -func (c *DockerContainer) Build(path string) (tag string, err error) { excludeFiles, err := build.ReadDockerignore(path) if err != nil { - return "", err + return err } tr, err := archive.TarWithOptions(path, &archive.TarOptions{ @@ -111,46 +132,302 @@ func (c *DockerContainer) Build(path string) (tag string, err error) { ExcludePatterns: excludeFiles, }) if err != nil { - return "", err + return err } defer tr.Close() - resp, err := c.client.ImageBuild(context.Background(), tr, types.ImageBuildOptions{ + if _, err := c.client.ImageBuild(context.Background(), tr, types.ImageBuildOptions{ Remove: true, ForceRemove: true, SuppressOutput: true, - }) + Tags: []string{imageTag + srv.Hash.String()}, + }); err != nil { + return err + } + + return nil +} + +// Start starts the service. +func (c *Container) Start(srv *service.Service, instanceHash, runnerHash, instanceEnvHash hash.Hash, instanceEnv []string, registerPayload []byte) (err error) { + runnerName := servicePrefix + runnerHash.String() + + networkID, err := c.createNetwork(runnerName) if err != nil { - return "", err + return err } - defer resp.Body.Close() - return tagFromResponse(resp.Body) + enginedNetworkID, err := c.enginedNetworkID() + if err != nil { + return err + } + + specs := make([]swarm.ServiceSpec, 0) + + // Create dependency container configs + for _, dep := range srv.Dependencies { + depName := runnerName + "_" + dep.Key + volumes := convertVolumes(srv, dep.Volumes, dep.Key) + volumesFrom, err := convertVolumesFrom(srv, dep.VolumesFrom) + if err != nil { + return err + } + stopGracePeriod := defaultStopGracePeriod + maxAttempts := defaultMaxAttempts + specs = append(specs, swarm.ServiceSpec{ + Annotations: swarm.Annotations{ + Name: depName, + Labels: map[string]string{ + "mesg.engine": c.engineName, + "mesg.service": srv.Hash.String(), + "mesg.instance": instanceHash.String(), + "mesg.runner": runnerHash.String(), + "mesg.dependency": dep.Key, + "com.docker.stack.namespace": depName, + }, + }, + TaskTemplate: swarm.TaskSpec{ + ContainerSpec: &swarm.ContainerSpec{ + Image: dep.Image, + Labels: map[string]string{ + "com.docker.stack.namespace": depName, + }, + Env: dep.Env, + Args: dep.Args, + Command: strings.Fields(dep.Command), + Mounts: append(volumes, volumesFrom...), + StopGracePeriod: &stopGracePeriod, + }, + Networks: []swarm.NetworkAttachmentConfig{ + { + Target: networkID, + Aliases: []string{dep.Key}, + }, + }, + RestartPolicy: &swarm.RestartPolicy{ + Condition: swarm.RestartPolicyConditionOnFailure, + MaxAttempts: &maxAttempts, + }, + }, + EndpointSpec: &swarm.EndpointSpec{ + Ports: convertPorts(dep.Ports), + }, + }) + } + + // Create configuration container config + volumes := convertVolumes(srv, srv.Configuration.Volumes, service.MainServiceKey) + volumesFrom, err := convertVolumesFrom(srv, srv.Configuration.VolumesFrom) + if err != nil { + return err + } + stopGracePeriod := defaultStopGracePeriod + maxAttempts := defaultMaxAttempts + specs = append(specs, swarm.ServiceSpec{ + Annotations: swarm.Annotations{ + Name: runnerName, + Labels: map[string]string{ + "mesg.engine": c.engineName, + "mesg.service": srv.Hash.String(), + "mesg.instance": instanceHash.String(), + "mesg.runner": runnerHash.String(), + "mesg.dependency": service.MainServiceKey, + "com.docker.stack.namespace": runnerName, + }, + }, + TaskTemplate: swarm.TaskSpec{ + ContainerSpec: &swarm.ContainerSpec{ + Image: imageTag + srv.Hash.String(), + Labels: map[string]string{ + "com.docker.stack.namespace": runnerName, + }, + Args: srv.Configuration.Args, + Command: strings.Fields(srv.Configuration.Command), + Env: xos.EnvMergeSlices(instanceEnv, []string{ + "MESG_SERVICE_HASH=" + srv.Hash.String(), + "MESG_INSTANCE_HASH=" + instanceHash.String(), + "MESG_RUNNER_HASH=" + runnerHash.String(), + "MESG_ENDPOINT=" + c.engineEndpoint, + "MESG_REGISTER_SIGNATURE=" + base64.StdEncoding.EncodeToString(registerPayload), + "MESG_ENV_HASH=" + instanceEnvHash.String(), + }), + Mounts: append(volumes, volumesFrom...), + StopGracePeriod: &stopGracePeriod, + }, + Networks: []swarm.NetworkAttachmentConfig{ + { + Target: networkID, + Aliases: []string{service.MainServiceKey}, + }, + { + Target: enginedNetworkID, + }, + }, + RestartPolicy: &swarm.RestartPolicy{ + Condition: swarm.RestartPolicyConditionOnFailure, + MaxAttempts: &maxAttempts, + }, + }, + EndpointSpec: &swarm.EndpointSpec{ + Ports: convertPorts(srv.Configuration.Ports), + }, + }) + + // Start + for _, spec := range specs { + if err := c.startService(spec); err != nil { + c.Stop(srv, runnerHash) + return err + } + } + + return nil } -// CreateNetwork creates a Docker Network with a namespace. Retruns network id and error. -func (c *DockerContainer) CreateNetwork(namespace string) (string, error) { - namespace = c.namespace(namespace) - network, err := c.client.NetworkInspect(context.Background(), namespace, types.NetworkInspectOptions{}) +// Stop stops an instance. +func (c *Container) Stop(srv *service.Service, runnerHash hash.Hash) error { + var ( + errs xerrors.SyncErrors + name = servicePrefix + runnerHash.String() + names = make([]string, 0) + ) + + for _, dep := range srv.Dependencies { + names = append(names, name+"_"+dep.Key) + } + names = append(names, name) + + for _, name := range names { + if err := c.stopService(name); err != nil { + errs.Append(err) + } + } + if err := errs.ErrorOrNil(); err != nil { + return err + } + + return c.deleteNetwork(name) +} + +// deleteData deletes the data volumes of instance and its dependencies. +// TODO: right now deleteData() is not compatible to work with multiple instances of same +// service since extractVolumes() accepts service, not instance. same applies in the start +// api as well. make it work with multiple instances. +// func deleteData(cont container.Container, s *service.Service) error { +// var ( +// wg sync.WaitGroup +// errs xerrors.SyncErrors +// volumes = make([]mount.Mount, 0) +// ) + +// for _, d := range s.Dependencies { +// volumes = append(volumes, convertVolumes(s, d.Volumes, d.Key)...) +// } +// volumes = append(volumes, convertVolumes(s, s.Configuration.Volumes, service.MainServiceKey)...) + +// for _, volume := range volumes { +// // TODO: is it actually necessary to remvoe in parallel? I worry that some volume will be deleted at the same time and create side effect +// wg.Add(1) +// go func(source string) { +// defer wg.Done() +// // if service is never started before, data volume won't be created and Docker Engine +// // will return with the not found error. therefore, we can safely ignore it. +// if err := cont.DeleteVolume(source); err != nil && !client.IsErrNotFound(err) { +// errs.Append(err) +// } +// }(volume.Source) +// } +// wg.Wait() +// return errs.ErrorOrNil() +// } + +func convertPorts(dPorts []string) []swarm.PortConfig { + ports := make([]swarm.PortConfig, len(dPorts)) + for i, p := range dPorts { + split := strings.Split(p, ":") + from, _ := strconv.ParseUint(split[0], 10, 64) + to := from + if len(split) > 1 { + to, _ = strconv.ParseUint(split[1], 10, 64) + } + ports[i] = swarm.PortConfig{ + Protocol: swarm.PortConfigProtocolTCP, + PublishMode: swarm.PortConfigPublishModeIngress, + TargetPort: uint32(to), + PublishedPort: uint32(from), + } + } + return ports +} + +func convertVolumes(s *service.Service, dVolumes []string, key string) []mount.Mount { + volumes := make([]mount.Mount, 0) + for _, volume := range dVolumes { + volumes = append(volumes, mount.Mount{ + Type: mount.TypeVolume, + Source: volumeKey(s, key, volume), + Target: volume, + }) + } + return volumes +} + +func convertVolumesFrom(s *service.Service, dVolumesFrom []string) ([]mount.Mount, error) { + volumesFrom := make([]mount.Mount, 0) + for _, depName := range dVolumesFrom { + var depVolumes []string + if depName == service.MainServiceKey { + depVolumes = s.Configuration.Volumes + } else { + dep, err := s.GetDependency(depName) + if err != nil { + return nil, err + } + depVolumes = dep.Volumes + } + for _, volume := range depVolumes { + volumesFrom = append(volumesFrom, mount.Mount{ + Type: mount.TypeVolume, + Source: volumeKey(s, depName, volume), + Target: volume, + }) + } + } + return volumesFrom, nil +} + +// volumeKey creates a key for service's volume based on the sid to make sure that the volume +// will stay the same for different versions of the service. +func volumeKey(s *service.Service, dependency, volume string) string { + return hash.Dump([]string{ + s.Hash.String(), + dependency, + volume, + }).String() +} + +// createNetwork creates a Docker Network with a name. Retruns network id and error. +func (c *Container) createNetwork(name string) (string, error) { + network, err := c.client.NetworkInspect(context.Background(), name, types.NetworkInspectOptions{}) if err != nil && !client.IsErrNotFound(err) { return "", err } if network.ID != "" { return network.ID, nil } - response, err := c.client.NetworkCreate(context.Background(), namespace, types.NetworkCreate{ + response, err := c.client.NetworkCreate(context.Background(), name, types.NetworkCreate{ CheckDuplicate: true, Driver: "overlay", Labels: map[string]string{ - "com.docker.stack.namespace": namespace, + "com.docker.stack.namespace": name, }, }) return response.ID, err } -// DeleteNetwork deletes a Docker Network associated with a namespace. -func (c *DockerContainer) DeleteNetwork(namespace string) error { +// deleteNetwork deletes a Docker Network. +func (c *Container) deleteNetwork(name string) error { for { - network, err := c.client.NetworkInspect(context.Background(), c.namespace(namespace), types.NetworkInspectOptions{}) + network, err := c.client.NetworkInspect(context.Background(), name, types.NetworkInspectOptions{}) if client.IsErrNotFound(err) { return nil } @@ -158,40 +435,38 @@ func (c *DockerContainer) DeleteNetwork(namespace string) error { return err } c.client.NetworkRemove(context.Background(), network.ID) - time.Sleep(100 * time.Millisecond) + time.Sleep(pollingTime) } } -// SharedNetworkID returns the ID of the shared network. -func (c *DockerContainer) SharedNetworkID() string { - return c.sharedNetworkID +// enginedNetworkID retrieve the docker network id of the engine network. +func (c *Container) enginedNetworkID() (string, error) { + network, err := c.client.NetworkInspect(context.Background(), c.engineNetwork, types.NetworkInspectOptions{}) + return network.ID, err } // StartService starts a docker service. -func (c *DockerContainer) StartService(options ServiceOptions) (string, error) { - if status, _ := c.serviceStatus(options.Namespace); status == RUNNING { - service, _, err := c.client.ServiceInspectWithRaw(context.Background(), c.namespace(options.Namespace), types.ServiceInspectOptions{}) - return service.ID, err +func (c *Container) startService(spec swarm.ServiceSpec) error { + if status, _ := c.serviceStatus(spec.Name); status == RUNNING { + _, _, err := c.client.ServiceInspectWithRaw(context.Background(), spec.Name, types.ServiceInspectOptions{}) + return err } - - service := options.toSwarmServiceSpec(c) - response, err := c.client.ServiceCreate(context.Background(), service, types.ServiceCreateOptions{}) - if err != nil { - return "", err + if _, err := c.client.ServiceCreate(context.Background(), spec, types.ServiceCreateOptions{}); err != nil { + return err } - return response.ID, c.waitForStatus(options.Namespace, RUNNING) + return c.waitForStatus(spec.Name, RUNNING) } // StopService stops a docker service. -func (c *DockerContainer) StopService(namespace string) error { - status, err := c.serviceStatus(namespace) +func (c *Container) stopService(name string) error { + status, err := c.serviceStatus(name) if err != nil { return err } if status == STOPPED { return nil } - service, _, err := c.client.ServiceInspectWithRaw(context.Background(), c.namespace(namespace), types.ServiceInspectOptions{}) + service, _, err := c.client.ServiceInspectWithRaw(context.Background(), name, types.ServiceInspectOptions{}) if err != nil && !client.IsErrNotFound(err) { return err } @@ -201,53 +476,22 @@ func (c *DockerContainer) StopService(namespace string) error { stopGracePeriod = *service.Spec.TaskTemplate.ContainerSpec.StopGracePeriod } - err = c.client.ServiceRemove(context.Background(), c.namespace(namespace)) + err = c.client.ServiceRemove(context.Background(), name) if err != nil && !client.IsErrNotFound(err) { return err } - if err := c.deletePendingContainer(namespace, time.Now().Add(stopGracePeriod)); err != nil { - return err - } - return c.waitForStatus(namespace, STOPPED) -} - -// DeleteVolume deletes a Docker Volume by name. -func (c *DockerContainer) DeleteVolume(name string) error { - return c.client.VolumeRemove(context.Background(), name, false) -} - -// Cleanup cleans all configuration like shared network of running services. -func (c *DockerContainer) Cleanup() error { - // remove shared network - if err := c.client.NetworkRemove(context.Background(), c.nsprefix); err != nil { - return err - } - return nil -} - -// namespace creates a new namespace with container prefix. -func (c *DockerContainer) namespace(s string) string { - return c.nsprefix + "-" + s -} - -// isSwarmInit returns true if docker is connected with any swarm. -func (c *DockerContainer) isSwarmInit() error { - info, err := c.client.Info(context.Background()) - if err != nil { + if err := c.deletePendingContainer(name, time.Now().Add(stopGracePeriod)); err != nil { return err } - if info.Swarm.NodeID == "" { - return errSwarmNotInit - } - return nil + return c.waitForStatus(name, STOPPED) } // findContainer returns a docker container. -func (c *DockerContainer) findContainer(namespace string) (string, error) { +func (c *Container) findContainer(name string) (string, error) { containers, err := c.client.ContainerList(context.Background(), types.ContainerListOptions{ Filters: filters.NewArgs(filters.KeyValuePair{ Key: "label", - Value: "com.docker.stack.namespace=" + c.namespace(namespace), + Value: "com.docker.stack.namespace=" + name, }), Limit: 1, }) @@ -255,7 +499,7 @@ func (c *DockerContainer) findContainer(namespace string) (string, error) { return "", err } if len(containers) == 0 { - return "", errdefs.NotFound(fmt.Errorf("container in namespace %s not found", namespace)) + return "", errdefs.NotFound(fmt.Errorf("container in namespace %s not found", name)) } return containers[0].ID, nil } @@ -266,13 +510,13 @@ func (c *DockerContainer) findContainer(namespace string) (string, error) { // - RUNNING: when the container is running in docker regardless of the status of the service. // - STARTING: when the service is running but the container is not yet started. // - STOPPED: when the container and the service is not running in docker. -func (c *DockerContainer) serviceStatus(namespace string) (Status, error) { - container, err := c.containerExists(namespace) +func (c *Container) serviceStatus(name string) (Status, error) { + container, err := c.containerExists(name) if err != nil { return UNKNOWN, err } - service, err := c.serviceExists(namespace) + service, err := c.serviceExists(name) if err != nil { return UNKNOWN, err } @@ -287,9 +531,9 @@ func (c *DockerContainer) serviceStatus(namespace string) (Status, error) { return UNKNOWN, nil } -// containerExists checks if container with namespace can be found. -func (c *DockerContainer) containerExists(namespace string) (bool, error) { - _, err := c.findContainer(namespace) +// containerExists checks if container with name can be found. +func (c *Container) containerExists(name string) (bool, error) { + _, err := c.findContainer(name) if err != nil && !client.IsErrNotFound(err) { return false, err } @@ -297,8 +541,8 @@ func (c *DockerContainer) containerExists(namespace string) (bool, error) { } // serviceExists checks if corresponding container for service namespace can be found. -func (c *DockerContainer) serviceExists(namespace string) (bool, error) { - _, _, err := c.client.ServiceInspectWithRaw(context.Background(), c.namespace(namespace), types.ServiceInspectOptions{}) +func (c *Container) serviceExists(name string) (bool, error) { + _, _, err := c.client.ServiceInspectWithRaw(context.Background(), name, types.ServiceInspectOptions{}) if err != nil && !client.IsErrNotFound(err) { return false, err } @@ -306,11 +550,11 @@ func (c *DockerContainer) serviceExists(namespace string) (bool, error) { } // tasksError returns the error of matching tasks. -func (c *DockerContainer) tasksError(namespace string) ([]string, error) { +func (c *Container) tasksError(name string) ([]string, error) { tasks, err := c.client.TaskList(context.Background(), types.TaskListOptions{ Filters: filters.NewArgs(filters.KeyValuePair{ Key: "label", - Value: "com.docker.stack.namespace=" + c.namespace(namespace), + Value: "com.docker.stack.namespace=" + name, }), }) if err != nil { @@ -327,16 +571,16 @@ func (c *DockerContainer) tasksError(namespace string) ([]string, error) { } // waitForStatus waits for the container to have the provided status. Returns error as soon as possible. -func (c *DockerContainer) waitForStatus(namespace string, status Status) error { - curstatus, err := c.serviceStatus(namespace) +func (c *Container) waitForStatus(name string, status Status) error { + curstatus, err := c.serviceStatus(name) if err != nil { return err } for curstatus != status { - time.Sleep(100 * time.Millisecond) + time.Sleep(pollingTime) - tasksErrors, err := c.tasksError(namespace) + tasksErrors, err := c.tasksError(name) if err != nil { return err } @@ -344,7 +588,7 @@ func (c *DockerContainer) waitForStatus(namespace string, status Status) error { return errors.New(strings.Join(tasksErrors, ", ")) } - curstatus, err = c.serviceStatus(namespace) + curstatus, err = c.serviceStatus(name) if err != nil { return err } @@ -353,40 +597,13 @@ func (c *DockerContainer) waitForStatus(namespace string, status Status) error { return nil } -func (c *DockerContainer) createSharedNetwork() error { - // check if already exists - network, err := c.client.NetworkInspect(context.Background(), c.nsprefix, types.NetworkInspectOptions{}) - if network.ID != "" { - c.sharedNetworkID = network.ID - return nil - } - if err != nil && !client.IsErrNotFound(err) { - return err - } - - // Create the new network needed to run containers. - resp, err := c.client.NetworkCreate(context.Background(), c.nsprefix, types.NetworkCreate{ - CheckDuplicate: true, - Driver: "overlay", - Labels: map[string]string{ - "com.docker.stack.namespace": c.nsprefix, - }, - }) - if err != nil { - return err - } - - c.sharedNetworkID = resp.ID - return nil -} - -func (c *DockerContainer) deletePendingContainer(namespace string, maxGraceTime time.Time) error { +func (c *Container) deletePendingContainer(name string, maxGraceTime time.Time) error { var ( id string err error ) - for start := time.Now(); start.Before(maxGraceTime); time.Sleep(100 * time.Millisecond) { - id, err = c.findContainer(namespace) + for start := time.Now(); start.Before(maxGraceTime); time.Sleep(pollingTime) { + id, err = c.findContainer(name) if client.IsErrNotFound(err) { return nil } @@ -402,37 +619,3 @@ func (c *DockerContainer) deletePendingContainer(namespace string, maxGraceTime c.client.ContainerRemove(context.Background(), id, types.ContainerRemoveOptions{Force: true}) return nil } - -// tagFromResponse retrives image build tag from client.Build response. -func tagFromResponse(r io.Reader) (string, error) { - last, err := lastResponseLine(r) - if err != nil { - return "", err - } - - var res buildResponse - if err := json.Unmarshal(last, &res); err != nil { - return "", fmt.Errorf("could not parse container build response: %s", err) - } - if res.Error != "" { - return "", fmt.Errorf("image build failed: %s", res.Error) - } - if !strings.HasPrefix(res.Stream, "sha256:") { - return "", fmt.Errorf("container: image build api dosen't return container id") - } - return strings.TrimSpace(res.Stream), nil -} - -// lastResponseLine returns the last log line from client.Build response. -func lastResponseLine(r io.Reader) ([]byte, error) { - b, err := ioutil.ReadAll(r) - if err != nil { - return nil, err - } - - lines := bytes.Split(bytes.TrimSpace(b), []byte{'\n'}) - if l := len(lines); l == 0 || len(lines[l-1]) == 0 { - return nil, errors.New("container: image build api return empty response") - } - return lines[len(lines)-1], nil -} diff --git a/container/container_test.go b/container/container_test.go deleted file mode 100644 index bd6327c20..000000000 --- a/container/container_test.go +++ /dev/null @@ -1,165 +0,0 @@ -package container - -import ( - "context" - "strings" - "testing" - - "github.com/docker/docker/api/types" - "github.com/stretchr/testify/require" -) - -const nstestprefix = "enginetest" - -func TestBuild(t *testing.T) { - c, err := New(nstestprefix) - require.NoError(t, err) - tag, err := c.Build("testdata/test-image") - require.NoError(t, err) - require.NotEmpty(t, tag) -} - -func TestNetwork(t *testing.T) { - const netname = "test-net" - - c, err := New(nstestprefix) - require.NoError(t, err) - defer c.Cleanup() - - t.Run("shared-network", func(t *testing.T) { - // check if is set after New - require.NotEmpty(t, c.SharedNetworkID()) - - // create 2nd time - 1st time is created with New - require.NoError(t, c.createSharedNetwork()) - }) - - t.Run("create", func(t *testing.T) { - nid, err := c.CreateNetwork(netname) - require.NoError(t, err) - require.NotEmpty(t, nid) - }) - - t.Run("delete", func(t *testing.T) { - require.NoError(t, c.DeleteNetwork(netname)) - _, err := c.client.NetworkInspect(context.Background(), c.namespace(netname), types.NetworkInspectOptions{}) - require.Error(t, err) - }) -} - -func TestService(t *testing.T) { - const servicename = "test-service" - - c, err := New(nstestprefix) - require.NoError(t, err) - defer c.Cleanup() - - t.Run("start", func(t *testing.T) { - id, err := c.StartService(ServiceOptions{ - Image: "busybox", - Namespace: servicename, - Ports: []Port{ - { - Target: 50053, - Published: 50053, - }, - { - Target: 50054, - Published: 50054, - }, - }, - Mounts: []Mount{ - { - Source: "testdata", - Target: "/testdata", - }, - }, - Env: []string{"foo=bar"}, - Args: []string{"hello"}, - Command: "echo", - Networks: []Network{ - { - ID: c.SharedNetworkID(), - Alias: "test-net", - }, - }, - Labels: map[string]string{"label": "test"}, - }) - require.NoError(t, err) - - resp, _, err := c.client.ServiceInspectWithRaw(context.Background(), id, types.ServiceInspectOptions{}) - require.NoError(t, err) - - require.Equal(t, "test", resp.Spec.Labels["label"]) - require.Equal(t, c.namespace(servicename), resp.Spec.Labels["com.docker.stack.namespace"]) - require.Equal(t, "busybox", resp.Spec.Labels["com.docker.stack.image"]) - require.Len(t, resp.Spec.EndpointSpec.Ports, 2) - require.Equal(t, resp.Spec.EndpointSpec.Ports[0].TargetPort, uint32(50053)) - require.Equal(t, resp.Spec.EndpointSpec.Ports[0].PublishedPort, uint32(50053)) - require.Equal(t, resp.Spec.EndpointSpec.Ports[1].TargetPort, uint32(50054)) - require.Equal(t, resp.Spec.EndpointSpec.Ports[1].PublishedPort, uint32(50054)) - require.Len(t, resp.Spec.TaskTemplate.Networks, 1) - require.Equal(t, resp.Spec.TaskTemplate.Networks[0].Aliases, []string{"test-net"}) - require.Len(t, resp.Spec.TaskTemplate.ContainerSpec.Mounts, 1) - require.Equal(t, resp.Spec.TaskTemplate.ContainerSpec.Mounts[0].Target, "/testdata") - require.Equal(t, resp.Spec.TaskTemplate.ContainerSpec.Mounts[0].Source, "testdata") - require.Equal(t, resp.Spec.TaskTemplate.ContainerSpec.Command, []string{"echo"}) - require.Equal(t, resp.Spec.TaskTemplate.ContainerSpec.Args, []string{"hello"}) - require.Equal(t, resp.Spec.TaskTemplate.ContainerSpec.Env, []string{"foo=bar"}) - }) - - t.Run("stop", func(t *testing.T) { - require.NoError(t, c.StopService(servicename)) - }) -} - -func TestNamespace(t *testing.T) { - c, _ := New("engine") - require.Equal(t, c.namespace("foo"), "engine-foo") -} - -func TestTagFromResponse(t *testing.T) { - var tests = []struct { - name string - resp string - tag string - err bool - }{ - { - "ok", - `{"stream":"sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"}`, - "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - false, - }, - { - "empty response", - "", - "", - true, - }, - { - "invalid json", - `-`, - "", - true, - }, - { - "no sha256 prefix", - `{"stream":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"}`, - "", - true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - tag, err := tagFromResponse(strings.NewReader(tt.resp)) - if tt.err && err == nil { - t.Errorf("want error") - } - if tt.tag != tag { - t.Errorf("invalid tag: want %s, got %s", tt.tag, tag) - } - }) - } -} diff --git a/container/service_options.go b/container/service_options.go deleted file mode 100644 index fd5e79de7..000000000 --- a/container/service_options.go +++ /dev/null @@ -1,134 +0,0 @@ -package container - -import ( - "strings" - "time" - - "github.com/docker/docker/api/types/mount" - "github.com/docker/docker/api/types/swarm" -) - -// ServiceOptions is a simplify version of swarm.ServiceSpec. -type ServiceOptions struct { - Image string - Namespace string - Ports []Port - Mounts []Mount - Env []string - Args []string - Command string - Networks []Network - Labels map[string]string - StopGracePeriod *time.Duration -} - -// Network keeps the network info for service. -type Network struct { - // ID of the docker network. - ID string - - // Alias is an optional attribute to name this service in the - // network and be able to access to it using this name. - Alias string -} - -// Port is a simplify version of swarm.PortConfig. -type Port struct { - Target uint32 - Published uint32 -} - -// Mount is a simplify version of mount.Mount. -type Mount struct { - Source string - Target string - Bind bool -} - -func (options *ServiceOptions) toSwarmServiceSpec(c *DockerContainer) swarm.ServiceSpec { - namespace := c.namespace(options.Namespace) - return swarm.ServiceSpec{ - Annotations: swarm.Annotations{ - Name: namespace, - Labels: mergeStringMaps(options.Labels, map[string]string{ - "com.docker.stack.namespace": namespace, - "com.docker.stack.image": options.Image, - }), - }, - TaskTemplate: swarm.TaskSpec{ - ContainerSpec: &swarm.ContainerSpec{ - Image: options.Image, - Labels: map[string]string{ - "com.docker.stack.namespace": namespace, - }, - Env: options.Env, - Args: options.Args, - Command: strings.Fields(options.Command), - Mounts: options.swarmMounts(), - StopGracePeriod: options.StopGracePeriod, - }, - Networks: options.swarmNetworks(), - }, - EndpointSpec: &swarm.EndpointSpec{ - Ports: options.swarmPorts(), - }, - } -} - -func (options *ServiceOptions) swarmPorts() []swarm.PortConfig { - ports := make([]swarm.PortConfig, len(options.Ports)) - for i, p := range options.Ports { - ports[i] = swarm.PortConfig{ - Protocol: swarm.PortConfigProtocolTCP, - PublishMode: swarm.PortConfigPublishModeIngress, - TargetPort: p.Target, - PublishedPort: p.Published, - } - } - return ports -} - -func (options *ServiceOptions) swarmMounts() []mount.Mount { - mounts := make([]mount.Mount, len(options.Mounts)) - for i, m := range options.Mounts { - mountType := mount.TypeVolume - if m.Bind { - mountType = mount.TypeBind - } - mounts[i] = mount.Mount{ - Source: m.Source, - Target: m.Target, - Type: mountType, - } - } - return mounts -} - -// swarmNetworks creates all necessary network attachment configurations for service. -// each network will be attached based on their networkID and an alias can be used to -// identify service in the network. -// aliases will make services accessible from other containers inside the same network. -func (options *ServiceOptions) swarmNetworks() []swarm.NetworkAttachmentConfig { - networks := make([]swarm.NetworkAttachmentConfig, len(options.Networks)) - for i, network := range options.Networks { - cfg := swarm.NetworkAttachmentConfig{ - Target: network.ID, - } - if network.Alias != "" { - cfg.Aliases = []string{network.Alias} - } - networks[i] = cfg - } - return networks -} - -func mergeStringMaps(m ...map[string]string) map[string]string { - out := make(map[string]string) - - for i := range m { - for k, v := range m[i] { - out[k] = v - } - } - return out -} diff --git a/container/testdata/.dockerignore b/container/testdata/.dockerignore deleted file mode 100644 index f4ee7b511..000000000 --- a/container/testdata/.dockerignore +++ /dev/null @@ -1 +0,0 @@ -ignoreme \ No newline at end of file diff --git a/container/testdata/test-image-with-ignore/.dockerignore b/container/testdata/test-image-with-ignore/.dockerignore deleted file mode 100644 index 01ff603e5..000000000 --- a/container/testdata/test-image-with-ignore/.dockerignore +++ /dev/null @@ -1,2 +0,0 @@ -# test file -file.txt diff --git a/container/testdata/test-image-with-ignore/Dockerfile b/container/testdata/test-image-with-ignore/Dockerfile deleted file mode 100644 index 86a44d3fe..000000000 --- a/container/testdata/test-image-with-ignore/Dockerfile +++ /dev/null @@ -1,2 +0,0 @@ -FROM busybox -CMD ["true"] diff --git a/container/testdata/test-image-with-ignore/file.txt b/container/testdata/test-image-with-ignore/file.txt deleted file mode 100644 index f4537d96f..000000000 --- a/container/testdata/test-image-with-ignore/file.txt +++ /dev/null @@ -1 +0,0 @@ -ignored by .dockerignore file diff --git a/container/testdata/test-image/Dockerfile b/container/testdata/test-image/Dockerfile deleted file mode 100644 index 86a44d3fe..000000000 --- a/container/testdata/test-image/Dockerfile +++ /dev/null @@ -1,2 +0,0 @@ -FROM busybox -CMD ["true"] diff --git a/core/main.go b/core/main.go index 97c2ab303..37c4319db 100644 --- a/core/main.go +++ b/core/main.go @@ -3,8 +3,6 @@ package main import ( "fmt" "path/filepath" - "strconv" - "sync" bam "github.com/cosmos/cosmos-sdk/baseapp" cosmosclient "github.com/cosmos/cosmos-sdk/client" @@ -15,18 +13,12 @@ import ( "github.com/gorilla/mux" "github.com/mesg-foundation/engine/app" "github.com/mesg-foundation/engine/config" - "github.com/mesg-foundation/engine/container" "github.com/mesg-foundation/engine/cosmos" "github.com/mesg-foundation/engine/event/publisher" - "github.com/mesg-foundation/engine/ext/xerrors" - "github.com/mesg-foundation/engine/ext/xnet" "github.com/mesg-foundation/engine/ext/xrand" "github.com/mesg-foundation/engine/ext/xsignal" - "github.com/mesg-foundation/engine/hash" "github.com/mesg-foundation/engine/logger" "github.com/mesg-foundation/engine/orchestrator" - "github.com/mesg-foundation/engine/protobuf/api" - "github.com/mesg-foundation/engine/runner/builder" "github.com/mesg-foundation/engine/server/grpc" "github.com/mesg-foundation/engine/version" "github.com/sirupsen/logrus" @@ -36,38 +28,6 @@ import ( db "github.com/tendermint/tm-db" ) -func stopRunningServices(mc *cosmos.ModuleClient, b *builder.Builder, owner string) error { - runners, err := mc.ListRunner(&cosmos.FilterRunner{Owner: owner}) - if err != nil { - return err - } - var ( - runnersLen = len(runners) - errC = make(chan error, runnersLen) - wg sync.WaitGroup - ) - wg.Add(runnersLen) - for _, instance := range runners { - go func(hash hash.Hash) { - defer wg.Done() - err := b.Delete(&api.DeleteRunnerRequest{ - Hash: hash, - DeleteData: false, - }) - if err != nil { - errC <- err - } - }(instance.Hash) - } - wg.Wait() - close(errC) - var errs xerrors.Errors - for err := range errC { - errs = append(errs, err) - } - return errs.ErrorOrNil() -} - func loadOrGenConfigAccount(kb *cosmos.Keybase, cfg *config.Config) (keys.Info, error) { if cfg.Account.Mnemonic != "" { logrus.WithField("module", "main").Warn("Config account mnemonic presents. Generating account with it...") @@ -114,18 +74,21 @@ func loadOrGenDevGenesis(cdc *codec.Codec, kb *cosmos.Keybase, cfg *config.Confi "nodeID": validator.NodeID, "peer": fmt.Sprintf("%s@%s:26656", validator.NodeID, validator.Name), }).Warnln("Validator") - return cosmos.GenGenesis(cdc, kb, app.NewDefaultGenesisState(), cfg.DevGenesis.ChainID, cfg.DevGenesis.InitialBalances, cfg.DevGenesis.ValidatorDelegationCoin, cfg.Tendermint.Config.GenesisFile(), []cosmos.GenesisValidator{validator}) + return cosmos.GenGenesis(cdc, kb, app.NewDefaultGenesisState(), cfg.DevGenesis.ChainID, cfg.DevGenesis.InitialBalances, cfg.Tendermint.Config.GenesisFile(), []cosmos.GenesisValidator{validator}) } //nolint:gocyclo func main() { xrand.SeedInit() + // init the config of cosmos + cosmos.InitConfig() + + // load engine config cfg, err := config.New() if err != nil { logrus.WithField("module", "main").Fatalln(err) } - cosmos.CustomizeConfig(cfg) // init logger. logger.Init(cfg.Log.Format, cfg.Log.Level, cfg.Log.ForceColors) @@ -133,14 +96,6 @@ func main() { // init tendermint logger tendermintLogger := logger.TendermintLogger() - // init container. - container, err := container.New(cfg.Name) - if err != nil { - logrus.WithField("module", "main").Fatalln(err) - } - - _, port, _ := xnet.SplitHostPort(cfg.Server.Address) - // init app factory db, err := db.NewGoLevelDB("app", filepath.Join(cfg.Path, cfg.Cosmos.RelativePath)) if err != nil { @@ -186,19 +141,14 @@ func main() { } }() - // create cosmos client - client, err := cosmos.NewClient(rpcclient.NewLocal(node), cdc, kb, genesis.ChainID, cfg.Account.Name, cfg.Account.Password, cfg.Cosmos.MinGasPrices) + // create rpc client + rpc, err := cosmos.NewRPC(rpcclient.NewLocal(node), cdc, kb, genesis.ChainID, cfg.Account.Name, cfg.Account.Password, cfg.Cosmos.MinGasPrices) if err != nil { logrus.WithField("module", "main").Fatalln(err) } - mc := cosmos.NewModuleClient(client) - - // init runner builder - b := builder.New(mc, container, cfg.Name, strconv.Itoa(port), cfg.IpfsEndpoint) - // init event publisher - ep := publisher.New(mc) + ep := publisher.New(rpc) // start tendermint node logrus.WithField("module", "main").WithField("seeds", cfg.Tendermint.Config.P2P.Seeds).Info("starting tendermint node") @@ -207,7 +157,7 @@ func main() { } // init gRPC server. - server := grpc.New(mc, ep, b, cfg.DefaultExecutionPrice) + server := grpc.New(rpc, ep, cfg.AuthorizedPubKeys) logrus.WithField("module", "main").Infof("starting MESG Engine version %s", version.Version) defer func() { logrus.WithField("module", "main").Info("stopping grpc server") @@ -221,7 +171,7 @@ func main() { }() logrus.WithField("module", "main").Info("starting process engine") - orch := orchestrator.New(mc, ep, cfg.DefaultExecutionPrice) + orch := orchestrator.New(rpc, ep, cfg.DefaultExecutionPrice) defer func() { logrus.WithField("module", "main").Info("stopping orchestrator") orch.Stop() @@ -252,7 +202,7 @@ func main() { cliCtx := context.NewCLIContext(). WithCodec(cdc). - WithClient(client). + WithClient(rpc). WithTrustNode(true) mux := mux.NewRouter() cosmosclient.RegisterRoutes(cliCtx, mux) @@ -265,14 +215,4 @@ func main() { }() <-xsignal.WaitForInterrupt() - - logrus.WithField("module", "main").Info("stopping running services") - if err := stopRunningServices(mc, b, acc.GetAddress().String()); err != nil { - logrus.WithField("module", "main").Errorln(err) - } - - logrus.WithField("module", "main").Info("cleanup container") - if err := container.Cleanup(); err != nil { - logrus.WithField("module", "main").Errorln(err) - } } diff --git a/cosmos/config.go b/cosmos/config.go index bf880feac..6f947ef6a 100644 --- a/cosmos/config.go +++ b/cosmos/config.go @@ -1,49 +1,33 @@ package cosmos import ( - "math/big" - sdktypes "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/staking" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/mesg-foundation/engine/config" ) -// CustomizeConfig customizes the cosmos application like addresses prefixes and coin type -func CustomizeConfig(engineCfg *config.Config) { +// InitConfig sets the bech32 prefix and HDPath to cosmos config. +func InitConfig() { // See github.com/cosmos/cosmos-sdk/types/address.go - var ( + const ( // Bech32PrefixAccAddr defines the Bech32 prefix of an account's address - Bech32PrefixAccAddr = engineCfg.Cosmos.Bech32MainPrefix + Bech32PrefixAccAddr = config.CosmosBech32MainPrefix // Bech32PrefixAccPub defines the Bech32 prefix of an account's public key - Bech32PrefixAccPub = engineCfg.Cosmos.Bech32MainPrefix + sdktypes.PrefixPublic + Bech32PrefixAccPub = config.CosmosBech32MainPrefix + sdktypes.PrefixPublic // Bech32PrefixValAddr defines the Bech32 prefix of a validator's operator address - Bech32PrefixValAddr = engineCfg.Cosmos.Bech32MainPrefix + sdktypes.PrefixValidator + sdktypes.PrefixOperator + Bech32PrefixValAddr = config.CosmosBech32MainPrefix + sdktypes.PrefixValidator + sdktypes.PrefixOperator // Bech32PrefixValPub defines the Bech32 prefix of a validator's operator public key - Bech32PrefixValPub = engineCfg.Cosmos.Bech32MainPrefix + sdktypes.PrefixValidator + sdktypes.PrefixOperator + sdktypes.PrefixPublic + Bech32PrefixValPub = config.CosmosBech32MainPrefix + sdktypes.PrefixValidator + sdktypes.PrefixOperator + sdktypes.PrefixPublic // Bech32PrefixConsAddr defines the Bech32 prefix of a consensus node address - Bech32PrefixConsAddr = engineCfg.Cosmos.Bech32MainPrefix + sdktypes.PrefixValidator + sdktypes.PrefixConsensus + Bech32PrefixConsAddr = config.CosmosBech32MainPrefix + sdktypes.PrefixValidator + sdktypes.PrefixConsensus // Bech32PrefixConsPub defines the Bech32 prefix of a consensus node public key - Bech32PrefixConsPub = engineCfg.Cosmos.Bech32MainPrefix + sdktypes.PrefixValidator + sdktypes.PrefixConsensus + sdktypes.PrefixPublic + Bech32PrefixConsPub = config.CosmosBech32MainPrefix + sdktypes.PrefixValidator + sdktypes.PrefixConsensus + sdktypes.PrefixPublic ) - config := sdktypes.GetConfig() - config.SetBech32PrefixForAccount(Bech32PrefixAccAddr, Bech32PrefixAccPub) - config.SetBech32PrefixForValidator(Bech32PrefixValAddr, Bech32PrefixValPub) - config.SetBech32PrefixForConsensusNode(Bech32PrefixConsAddr, Bech32PrefixConsPub) - config.SetFullFundraiserPath(engineCfg.Cosmos.FullFundraiserPath) - config.SetCoinType(engineCfg.Cosmos.CoinType) - config.Seal() - - // From github.com/cosmos/cosmos-sdk/types/staking.go - // Set the power reduction from token to voting power to 10^18 (number of decimal of the token). - sdktypes.PowerReduction = sdktypes.NewIntFromBigInt(new(big.Int).Exp(big.NewInt(10), big.NewInt(engineCfg.Cosmos.PowerReduction), nil)) - - // From github.com/cosmos/cosmos-sdk/x/staking/types/params.go - // Override default genesis state of staking module to set the bond denom - staking.DefaultGenesisState = func() staking.GenesisState { - state := stakingtypes.DefaultGenesisState() - state.Params.BondDenom = engineCfg.Cosmos.StakeTokenDenom - return state - } + cfg := sdktypes.GetConfig() + cfg.SetBech32PrefixForAccount(Bech32PrefixAccAddr, Bech32PrefixAccPub) + cfg.SetBech32PrefixForValidator(Bech32PrefixValAddr, Bech32PrefixValPub) + cfg.SetBech32PrefixForConsensusNode(Bech32PrefixConsAddr, Bech32PrefixConsPub) + cfg.SetFullFundraiserPath(config.FullFundraiserPath) + cfg.SetCoinType(config.CosmosCoinType) + cfg.Seal() } diff --git a/cosmos/genesis.go b/cosmos/genesis.go index 5cdc091f1..2b7b5b313 100644 --- a/cosmos/genesis.go +++ b/cosmos/genesis.go @@ -54,11 +54,7 @@ func LoadGenesis(genesisFile string) (*tmtypes.GenesisDoc, error) { } // GenGenesis generates a new genesis and save it. -func GenGenesis(cdc *codec.Codec, kb *Keybase, defaultGenesisŚtate map[string]json.RawMessage, chainID, initialBalances, validatorDelegationCoin, genesisFile string, validators []GenesisValidator) (*tmtypes.GenesisDoc, error) { - valDelCoin, err := sdktypes.ParseCoin(validatorDelegationCoin) - if err != nil { - return nil, err - } +func GenGenesis(cdc *codec.Codec, kb *Keybase, defaultGenesisŚtate map[string]json.RawMessage, chainID, initialBalances, genesisFile string, validators []GenesisValidator) (*tmtypes.GenesisDoc, error) { msgs := []sdktypes.Msg{} for _, validator := range validators { // get account @@ -67,7 +63,7 @@ func GenGenesis(cdc *codec.Codec, kb *Keybase, defaultGenesisŚtate map[string]j return nil, err } // generate msg to add this validator - msgs = append(msgs, genCreateValidatorMsg(acc.GetAddress(), validator.Name, valDelCoin, validator.ValPubKey)) + msgs = append(msgs, genCreateValidatorMsg(acc.GetAddress(), validator.Name, validator.ValPubKey)) } // generate genesis transaction accNumber := uint64(0) @@ -147,11 +143,11 @@ func genGenesisAppState(cdc *codec.Codec, defaultGenesisŚtate map[string]json.R return genutil.SetGenTxsInAppGenesisState(cdc, defaultGenesisŚtate, []authtypes.StdTx{signedStdTx}) } -func genCreateValidatorMsg(accAddress sdktypes.AccAddress, accName string, validatorDelegationCoin sdktypes.Coin, valPubKey crypto.PubKey) stakingtypes.MsgCreateValidator { +func genCreateValidatorMsg(accAddress sdktypes.AccAddress, accName string, valPubKey crypto.PubKey) stakingtypes.MsgCreateValidator { return stakingtypes.NewMsgCreateValidator( sdktypes.ValAddress(accAddress), valPubKey, - validatorDelegationCoin, + sdktypes.NewCoin(sdktypes.DefaultBondDenom, sdktypes.TokensFromConsensusPower(100)), stakingtypes.Description{ Moniker: accName, Details: "init-validator", diff --git a/cosmos/genesis_test.go b/cosmos/genesis_test.go index c1f4afb36..3c331af7e 100644 --- a/cosmos/genesis_test.go +++ b/cosmos/genesis_test.go @@ -31,17 +31,16 @@ func TestGenesis(t *testing.T) { require.NoError(t, err) // variables var ( - chainID = "test-chainID" - initialBalances = "100amesg" - validatorDelegationCoin = "1amesg" - name = "name" - password = "pass" - privValidatorKeyFile = filepath.Join(path, "privValidatorKeyFile.json") - privValidatorStateFile = filepath.Join(path, "privValidatorStateFile.json") - nodeKeyFile = filepath.Join(path, "nodeKeyFile.json") - genesisPath = filepath.Join(path, "genesis.json") - validators = []GenesisValidator{} - defaultGenesisState = map[string]json.RawMessage{} + chainID = "test-chainID" + initialBalances = "100amesg" + name = "name" + password = "pass" + privValidatorKeyFile = filepath.Join(path, "privValidatorKeyFile.json") + privValidatorStateFile = filepath.Join(path, "privValidatorStateFile.json") + nodeKeyFile = filepath.Join(path, "nodeKeyFile.json") + genesisPath = filepath.Join(path, "genesis.json") + validators = []GenesisValidator{} + defaultGenesisState = map[string]json.RawMessage{} ) // init account mnemonic, _ := kb.NewMnemonic() @@ -63,7 +62,7 @@ func TestGenesis(t *testing.T) { require.False(t, GenesisExist(genesisPath)) }) t.Run("generate genesis", func(t *testing.T) { - genesis, err := GenGenesis(cdc, kb, defaultGenesisState, chainID, initialBalances, validatorDelegationCoin, genesisPath, validators) + genesis, err := GenGenesis(cdc, kb, defaultGenesisState, chainID, initialBalances, genesisPath, validators) require.NoError(t, err) require.NotEmpty(t, genesis) }) diff --git a/cosmos/lcd.go b/cosmos/lcd.go new file mode 100644 index 000000000..a1359b090 --- /dev/null +++ b/cosmos/lcd.go @@ -0,0 +1,236 @@ +package cosmos + +import ( + "bytes" + "encoding/hex" + "fmt" + "io/ioutil" + "net/http" + "sync" + + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/crypto/keys" + sdk "github.com/cosmos/cosmos-sdk/types" + sdktypes "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/rest" + "github.com/cosmos/cosmos-sdk/x/auth" + authrest "github.com/cosmos/cosmos-sdk/x/auth/client/rest" + authutils "github.com/cosmos/cosmos-sdk/x/auth/client/utils" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + abci "github.com/tendermint/tendermint/abci/types" +) + +// LCD is a simple cosmos LCD client. +type LCD struct { + endpoint string + cdc *codec.Codec + kb keys.Keybase + chainID string + accName string + accPassword string + minGasPrices sdktypes.DecCoins + gasLimit uint64 + + // local state + acc *auth.BaseAccount + accountMutex sync.Mutex + broadcastMutex sync.Mutex +} + +// NewLCD initializes a cosmos LCD client. +func NewLCD(endpoint string, cdc *codec.Codec, kb keys.Keybase, chainID, accName, accPassword, minGasPrices string, gasLimit uint64) (*LCD, error) { + minGasPricesDecoded, err := sdktypes.ParseDecCoins(minGasPrices) + if err != nil { + return nil, err + } + return &LCD{ + endpoint: endpoint, + cdc: cdc, + kb: kb, + chainID: chainID, + accName: accName, + accPassword: accPassword, + minGasPrices: minGasPricesDecoded, + gasLimit: gasLimit, + }, nil +} + +// Get executes a get request on the LCD. +func (lcd *LCD) Get(path string, ptr interface{}) error { + resp, err := http.Get(lcd.endpoint + path) + if err != nil { + return err + } + defer resp.Body.Close() + if resp.StatusCode < 200 || resp.StatusCode >= 300 { + return fmt.Errorf("request status code is not 2XX, got %d", resp.StatusCode) + } + body, err := ioutil.ReadAll(resp.Body) + if err != nil { + return err + } + cosResp := rest.ResponseWithHeight{} + if err := lcd.cdc.UnmarshalJSON(body, &cosResp); err != nil { + return err + } + if len(cosResp.Result) > 0 { + if err := lcd.cdc.UnmarshalJSON(cosResp.Result, ptr); err != nil { + return err + } + } + return nil +} + +// Post executes a post request on the LCD. +// The response is expected to be a ResponseWithHeight that contains the expected result. +func (lcd *LCD) Post(path string, req interface{}, ptr interface{}) error { + cosResp := rest.ResponseWithHeight{} + if err := lcd.PostBare(path, req, &cosResp); err != nil { + return err + } + if len(cosResp.Result) > 0 { + if err := lcd.cdc.UnmarshalJSON(cosResp.Result, ptr); err != nil { + return err + } + } + return nil +} + +// PostBare executes a post request on the LCD. +// There is no expectation on the type of response. +func (lcd *LCD) PostBare(path string, req interface{}, ptr interface{}) error { + reqBody, err := lcd.cdc.MarshalJSON(req) + if err != nil { + return err + } + resp, err := http.Post(lcd.endpoint+path, "application/json", bytes.NewReader(reqBody)) + if err != nil { + return err + } + defer resp.Body.Close() + if resp.StatusCode < 200 || resp.StatusCode >= 300 { + return fmt.Errorf("request status code is not 2XX, got %d", resp.StatusCode) + } + body, err := ioutil.ReadAll(resp.Body) + if err != nil { + return err + } + if err := lcd.cdc.UnmarshalJSON(body, ptr); err != nil { + return err + } + return nil +} + +//BroadcastMsg sign and broadcast a transaction from a message. +func (lcd *LCD) BroadcastMsg(msg sdk.Msg) ([]byte, error) { + return lcd.BroadcastMsgs([]sdk.Msg{msg}) +} + +//BroadcastMsgs sign and broadcast a transaction from multiple messages. +func (lcd *LCD) BroadcastMsgs(msgs []sdk.Msg) ([]byte, error) { + // Lock the getAccount + create and sign tx + broadcast + lcd.broadcastMutex.Lock() + defer lcd.broadcastMutex.Unlock() + + acc, err := lcd.getAccount() + if err != nil { + return nil, err + } + + // create and sign the tx + tx, err := lcd.createAndSignTx(msgs, acc) + if err != nil { + return nil, err + } + + // broadcast the tx + req := authrest.BroadcastReq{ + Tx: tx, + Mode: "block", // TODO: should be changed to "sync" and wait for the tx event + } + var res sdk.TxResponse + if err := lcd.PostBare("txs", req, &res); err != nil { + return nil, err + } + if abci.CodeTypeOK != res.Code { + return nil, fmt.Errorf("transaction returned with invalid code %d: %s", res.Code, res.RawLog) + } + + // only increase sequence if no error during broadcast of tx + if err := lcd.setAccountSequence(acc.GetSequence() + 1); err != nil { + return nil, err + } + + // decode result + result, err := hex.DecodeString(res.Data) + if err != nil { + return nil, err + } + return result, nil +} + +// getAccount returns the local account. +func (lcd *LCD) getAccount() (*auth.BaseAccount, error) { + lcd.accountMutex.Lock() + defer lcd.accountMutex.Unlock() + if lcd.acc == nil { + accKb, err := lcd.kb.Get(lcd.accName) + if err != nil { + return nil, err + } + lcd.acc = auth.NewBaseAccount(accKb.GetAddress(), nil, accKb.GetPubKey(), 0, 0) + } + localSeq := lcd.acc.GetSequence() + if err := lcd.Get("auth/accounts/"+lcd.acc.GetAddress().String(), &lcd.acc); err != nil { + return nil, err + } + // replace seq if sup + if localSeq > lcd.acc.GetSequence() { + lcd.acc.SetSequence(localSeq) + } + return lcd.acc, nil +} + +// setAccountSequence sets the sequence on the local account. +func (lcd *LCD) setAccountSequence(seq uint64) error { + lcd.accountMutex.Lock() + defer lcd.accountMutex.Unlock() + if lcd.acc == nil { + return fmt.Errorf("lcd.acc should not be nil. use getAccount first") + } + return lcd.acc.SetSequence(seq) +} + +func (lcd *LCD) createAndSignTx(msgs []sdk.Msg, acc *auth.BaseAccount) (authtypes.StdTx, error) { + // Create TxBuilder + txBuilder := authtypes.NewTxBuilder( + authutils.GetTxEncoder(lcd.cdc), + acc.GetAccountNumber(), + acc.GetSequence(), + lcd.gasLimit, + flags.DefaultGasAdjustment, + true, + lcd.chainID, + "", + nil, + lcd.minGasPrices, + ).WithKeybase(lcd.kb) + + // create StdSignMsg + stdSignMsg, err := txBuilder.BuildSignMsg(msgs) + if err != nil { + return authtypes.StdTx{}, err + } + + // create StdTx + stdTx := authtypes.NewStdTx(stdSignMsg.Msgs, stdSignMsg.Fee, nil, stdSignMsg.Memo) + + // sign StdTx + signedTx, err := txBuilder.SignStdTx(lcd.accName, lcd.accPassword, stdTx, false) + if err != nil { + return authtypes.StdTx{}, err + } + + return signedTx, nil +} diff --git a/cosmos/module_client.go b/cosmos/module_client.go deleted file mode 100644 index a027f2192..000000000 --- a/cosmos/module_client.go +++ /dev/null @@ -1,286 +0,0 @@ -package cosmos - -import ( - "context" - "fmt" - - executionpb "github.com/mesg-foundation/engine/execution" - "github.com/mesg-foundation/engine/ext/xos" - "github.com/mesg-foundation/engine/hash" - instancepb "github.com/mesg-foundation/engine/instance" - ownershippb "github.com/mesg-foundation/engine/ownership" - processpb "github.com/mesg-foundation/engine/process" - "github.com/mesg-foundation/engine/protobuf/api" - runnerpb "github.com/mesg-foundation/engine/runner" - servicepb "github.com/mesg-foundation/engine/service" - "github.com/mesg-foundation/engine/x/execution" - "github.com/mesg-foundation/engine/x/instance" - "github.com/mesg-foundation/engine/x/ownership" - "github.com/mesg-foundation/engine/x/process" - "github.com/mesg-foundation/engine/x/runner" - "github.com/mesg-foundation/engine/x/service" -) - -// ModuleClient handles all communication with every module. -type ModuleClient struct { - *Client -} - -// NewModuleClient creates new module client. -func NewModuleClient(c *Client) *ModuleClient { - return &ModuleClient{Client: c} -} - -func sroutef(format string, args ...interface{}) string { - return fmt.Sprintf("custom/"+format, args...) -} - -// CreateService creates a new service from definition. -func (mc *ModuleClient) CreateService(req *api.CreateServiceRequest) (*servicepb.Service, error) { - acc, err := mc.GetAccount() - if err != nil { - return nil, err - } - msg := service.NewMsgCreateService(acc.GetAddress(), req) - tx, err := mc.BuildAndBroadcastMsg(msg) - if err != nil { - return nil, err - } - return mc.GetService(tx.Data) -} - -// GetService returns the service that matches given hash. -func (mc *ModuleClient) GetService(hash hash.Hash) (*servicepb.Service, error) { - var out *servicepb.Service - route := sroutef("%s/%s/%s", service.QuerierRoute, service.QueryGetService, hash) - return out, mc.QueryJSON(route, nil, &out) -} - -// ListService returns all services. -func (mc *ModuleClient) ListService() ([]*servicepb.Service, error) { - var out []*servicepb.Service - route := sroutef("%s/%s", service.QuerierRoute, service.QueryListService) - return out, mc.QueryJSON(route, nil, &out) -} - -// ExistService returns if a service already exists. -func (mc *ModuleClient) ExistService(hash hash.Hash) (bool, error) { - var out bool - route := sroutef("%s/%s/%s", service.QuerierRoute, service.QueryExistService, hash) - return out, mc.QueryJSON(route, nil, &out) -} - -// HashService returns the calculate hash of a service. -func (mc *ModuleClient) HashService(req *api.CreateServiceRequest) (hash.Hash, error) { - var out hash.Hash - route := sroutef("%s/%s", service.QuerierRoute, service.QueryHashService) - return out, mc.QueryJSON(route, req, &out) -} - -// CreateProcess creates a new process. -func (mc *ModuleClient) CreateProcess(req *api.CreateProcessRequest) (*processpb.Process, error) { - acc, err := mc.GetAccount() - if err != nil { - return nil, err - } - msg := process.NewMsgCreateProcess(acc.GetAddress(), req) - tx, err := mc.BuildAndBroadcastMsg(msg) - if err != nil { - return nil, err - } - return mc.GetProcess(tx.Data) -} - -// GetInstance returns the instance that matches given hash. -func (mc *ModuleClient) GetInstance(hash hash.Hash) (*instancepb.Instance, error) { - var out *instancepb.Instance - route := sroutef("%s/%s/%s", instance.QuerierRoute, instance.QueryGetInstance, hash) - return out, mc.QueryJSON(route, nil, &out) -} - -// ListInstance returns all instances. -func (mc *ModuleClient) ListInstance(req *api.ListInstanceRequest) ([]*instancepb.Instance, error) { - var out []*instancepb.Instance - route := sroutef("%s/%s", instance.QuerierRoute, instance.QueryListInstances) - return out, mc.QueryJSON(route, req, &out) -} - -// ListOwnership returns all ownerships. -func (mc *ModuleClient) ListOwnership() ([]*ownershippb.Ownership, error) { - var out []*ownershippb.Ownership - route := sroutef("%s/%s", ownership.QuerierRoute, ownership.QueryListOwnerships) - return out, mc.QueryJSON(route, nil, &out) -} - -// DeleteProcess deletes the process by hash. -func (mc *ModuleClient) DeleteProcess(req *api.DeleteProcessRequest) error { - acc, err := mc.GetAccount() - if err != nil { - return err - } - msg := process.NewMsgDeleteProcess(acc.GetAddress(), req) - _, err = mc.BuildAndBroadcastMsg(msg) - return err -} - -// GetProcess returns the process that matches given hash. -func (mc *ModuleClient) GetProcess(hash hash.Hash) (*processpb.Process, error) { - var out *processpb.Process - route := sroutef("%s/%s/%s", process.QuerierRoute, process.QueryGetProcess, hash.String()) - return out, mc.QueryJSON(route, nil, &out) -} - -// ListProcess returns all processes. -func (mc *ModuleClient) ListProcess() ([]*processpb.Process, error) { - var out []*processpb.Process - route := sroutef("%s/%s", process.QuerierRoute, process.QueryListProcesses) - return out, mc.QueryJSON(route, nil, &out) -} - -// CreateExecution creates a new execution. -func (mc *ModuleClient) CreateExecution(req *api.CreateExecutionRequest) (*executionpb.Execution, error) { - acc, err := mc.GetAccount() - if err != nil { - return nil, err - } - msg := execution.NewMsgCreateExecution(req, acc.GetAddress()) - tx, err := mc.BuildAndBroadcastMsg(msg) - if err != nil { - return nil, err - } - return mc.GetExecution(tx.Data) -} - -// UpdateExecution updates a execution. -func (mc *ModuleClient) UpdateExecution(req *api.UpdateExecutionRequest) (*executionpb.Execution, error) { - acc, err := mc.GetAccount() - if err != nil { - return nil, err - } - msg := execution.NewMsgUpdateExecution(req, acc.GetAddress()) - tx, err := mc.BuildAndBroadcastMsg(msg) - if err != nil { - return nil, err - } - return mc.GetExecution(tx.Data) -} - -// GetExecution returns the execution that matches given hash. -func (mc *ModuleClient) GetExecution(hash hash.Hash) (*executionpb.Execution, error) { - var out *executionpb.Execution - route := sroutef("%s/%s/%s", execution.QuerierRoute, execution.QueryGetExecution, hash) - return out, mc.QueryJSON(route, nil, &out) -} - -// ListExecution returns all executions. -func (mc *ModuleClient) ListExecution() ([]*executionpb.Execution, error) { - var out []*executionpb.Execution - route := sroutef("%s/%s", execution.QuerierRoute, execution.QueryListExecution) - return out, mc.QueryJSON(route, nil, &out) -} - -// StreamExecution returns execution that matches given hash. -func (mc *ModuleClient) StreamExecution(ctx context.Context, req *api.StreamExecutionRequest) (chan *executionpb.Execution, chan error, error) { - if err := req.Filter.Validate(); err != nil { - return nil, nil, err - } - - stream, serrC, err := mc.Stream(ctx, EventModuleQuery(execution.ModuleName)) - if err != nil { - return nil, nil, err - } - - execC := make(chan *executionpb.Execution) - errC := make(chan error) - go func() { - loop: - for { - select { - case hash := <-stream: - exec, err := mc.GetExecution(hash) - if err != nil { - errC <- err - break - } - if req.Filter.Match(exec) { - execC <- exec - } - case err := <-serrC: - errC <- err - case <-ctx.Done(): - break loop - } - } - close(errC) - close(execC) - }() - return execC, errC, nil -} - -// CreateRunner creates a new runner. -func (mc *ModuleClient) CreateRunner(req *api.CreateRunnerRequest) (*runnerpb.Runner, error) { - s, err := mc.GetService(req.ServiceHash) - if err != nil { - return nil, err - } - envHash := hash.Dump(xos.EnvMergeSlices(s.Configuration.Env, req.Env)) - acc, err := mc.GetAccount() - if err != nil { - return nil, err - } - - msg := runner.NewMsgCreateRunner(acc.GetAddress(), req.ServiceHash, envHash) - tx, err := mc.BuildAndBroadcastMsg(msg) - if err != nil { - return nil, err - } - return mc.GetRunner(tx.Data) -} - -// DeleteRunner deletes an existing runner. -func (mc *ModuleClient) DeleteRunner(req *api.DeleteRunnerRequest) error { - acc, err := mc.GetAccount() - if err != nil { - return err - } - msg := runner.NewMsgDeleteRunner(acc.GetAddress(), req.Hash) - _, err = mc.BuildAndBroadcastMsg(msg) - return err -} - -// GetRunner returns the runner that matches given hash. -func (mc *ModuleClient) GetRunner(hash hash.Hash) (*runnerpb.Runner, error) { - var out *runnerpb.Runner - route := sroutef("%s/%s/%s", runner.QuerierRoute, runner.QueryGetRunner, hash) - return out, mc.QueryJSON(route, nil, &out) -} - -// FilterRunner to apply while listing runners. -type FilterRunner struct { - Owner string - InstanceHash hash.Hash -} - -// ListRunner returns all runners. -func (mc *ModuleClient) ListRunner(f *FilterRunner) ([]*runnerpb.Runner, error) { - var rs []*runnerpb.Runner - route := sroutef("%s/%s", runner.QuerierRoute, runner.QueryListRunners) - if err := mc.QueryJSON(route, nil, &rs); err != nil { - return nil, err - } - - // no filter, returns - if f == nil { - return rs, nil - } - - // filter results - out := make([]*runnerpb.Runner, 0) - for _, r := range rs { - if (f.Owner == "" || r.Owner == f.Owner) && - (f.InstanceHash.IsZero() || r.InstanceHash.Equal(f.InstanceHash)) { - out = append(out, r) - } - } - return out, nil -} diff --git a/cosmos/client.go b/cosmos/rpc.go similarity index 64% rename from cosmos/client.go rename to cosmos/rpc.go index bc73276dd..9e25ebd2c 100644 --- a/cosmos/client.go +++ b/cosmos/rpc.go @@ -16,15 +16,13 @@ import ( authExported "github.com/cosmos/cosmos-sdk/x/auth/exported" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/mesg-foundation/engine/ext/xreflect" - "github.com/mesg-foundation/engine/ext/xstrings" - "github.com/mesg-foundation/engine/hash" abci "github.com/tendermint/tendermint/abci/types" rpcclient "github.com/tendermint/tendermint/rpc/client" tenderminttypes "github.com/tendermint/tendermint/types" ) -// Client is a tendermint client with helper functions. -type Client struct { +// RPC is a tendermint rpc client with helper functions. +type RPC struct { rpcclient.Client cdc *codec.Codec kb keys.Keybase @@ -34,18 +32,18 @@ type Client struct { minGasPrices sdktypes.DecCoins // Local state - acc authExported.Account - getAccountMutex sync.Mutex - broadcastMutex sync.Mutex + acc authExported.Account + accountMutex sync.Mutex + broadcastMutex sync.Mutex } -// NewClient returns a rpc tendermint client. -func NewClient(client rpcclient.Client, cdc *codec.Codec, kb keys.Keybase, chainID, accName, accPassword, minGasPrices string) (*Client, error) { +// NewRPC returns a rpc tendermint client. +func NewRPC(client rpcclient.Client, cdc *codec.Codec, kb keys.Keybase, chainID, accName, accPassword, minGasPrices string) (*RPC, error) { minGasPricesDecoded, err := sdktypes.ParseDecCoins(minGasPrices) if err != nil { return nil, err } - return &Client{ + return &RPC{ Client: client, cdc: cdc, kb: kb, @@ -56,8 +54,13 @@ func NewClient(client rpcclient.Client, cdc *codec.Codec, kb keys.Keybase, chain }, nil } +// Codec returns the codec used by RPC. +func (c *RPC) Codec() *codec.Codec { + return c.cdc +} + // QueryJSON is abci.query wrapper with errors check and decode data. -func (c *Client) QueryJSON(path string, qdata, ptr interface{}) error { +func (c *RPC) QueryJSON(path string, qdata, ptr interface{}) error { var data []byte if !xreflect.IsNil(qdata) { b, err := c.cdc.MarshalJSON(qdata) @@ -77,7 +80,7 @@ func (c *Client) QueryJSON(path string, qdata, ptr interface{}) error { // QueryWithData performs a query to a Tendermint node with the provided path // and a data payload. It returns the result and height of the query upon success // or an error if the query fails. -func (c *Client) QueryWithData(path string, data []byte) ([]byte, int64, error) { +func (c *RPC) QueryWithData(path string, data []byte) ([]byte, int64, error) { result, err := c.ABCIQuery(path, data) if err != nil { return nil, 0, err @@ -90,24 +93,46 @@ func (c *Client) QueryWithData(path string, data []byte) ([]byte, int64, error) } // BuildAndBroadcastMsg builds and signs message and broadcast it to node. -func (c *Client) BuildAndBroadcastMsg(msg sdktypes.Msg) (*abci.ResponseDeliverTx, error) { - c.broadcastMutex.Lock() // Lock the whole signature + broadcast of the transaction - signedTx, err := c.CreateAndSignTx([]sdktypes.Msg{msg}) +func (c *RPC) BuildAndBroadcastMsg(msg sdktypes.Msg) (*abci.ResponseDeliverTx, error) { + signedTx, err := c.buildAndBroadcastMsgNoResult(msg) if err != nil { - c.broadcastMutex.Unlock() return nil, err } + return c.waitForTxResult(signedTx) +} - txres, err := c.BroadcastTxSync(signedTx) - c.broadcastMutex.Unlock() +func (c *RPC) buildAndBroadcastMsgNoResult(msg sdktypes.Msg) (tenderminttypes.Tx, error) { + // Lock the getAccount + create and sign tx + broadcast + c.broadcastMutex.Lock() + defer c.broadcastMutex.Unlock() + + acc, err := c.GetAccount() if err != nil { return nil, err } + // create and sign the tx + signedTx, err := c.createAndSignTx([]sdktypes.Msg{msg}, acc) + if err != nil { + return nil, err + } + txres, err := c.BroadcastTxSync(signedTx) + if err != nil { + return nil, err + } if txres.Code != abci.CodeTypeOK { return nil, fmt.Errorf("transaction returned with invalid code %d: %s", txres.Code, txres.Log) } + // only increase sequence if no error during broadcast of tx + if err := c.setAccountSequence(acc.GetSequence() + 1); err != nil { + return nil, err + } + + return signedTx, nil +} + +func (c *RPC) waitForTxResult(signedTx tenderminttypes.Tx) (*abci.ResponseDeliverTx, error) { // TODO: 20*time.Second should not be hardcoded here ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second) defer cancel() @@ -131,52 +156,14 @@ func (c *Client) BuildAndBroadcastMsg(msg sdktypes.Msg) (*abci.ResponseDeliverTx } return &data.TxResult.Result, nil case <-ctx.Done(): - return nil, errors.New("reach timeout for listening for transaction result") - } -} - -// Stream subscribes to the provided query and returns the hash of the matching ressources. -func (c *Client) Stream(ctx context.Context, query string) (chan hash.Hash, chan error, error) { - subscriber := xstrings.RandASCIILetters(8) - eventStream, err := c.Subscribe(ctx, subscriber, query, 0) - if err != nil { - return nil, nil, err + return nil, fmt.Errorf("reach timeout for listening for transaction result: %w", ctx.Err()) } - hashC := make(chan hash.Hash) - errC := make(chan error) - go func() { - loop: - for { - select { - case event := <-eventStream: - attrs := event.Events[EventHashType] - // The following error might be too much as MAYBE if one transaction contains many messages, the events will be merged across the whole transaction - if len(attrs) != 1 { - errC <- fmt.Errorf("event %s has %d tag(s), but only 1 is expected", EventHashType, len(attrs)) - } - for _, attr := range attrs { - hash, err := hash.Decode(attr) - if err != nil { - errC <- err - } else { - hashC <- hash - } - } - case <-ctx.Done(): - break loop - } - } - close(errC) - close(hashC) - c.Unsubscribe(context.Background(), subscriber, query) - }() - return hashC, errC, nil } // GetAccount returns the local account. -func (c *Client) GetAccount() (authExported.Account, error) { - c.getAccountMutex.Lock() - defer c.getAccountMutex.Unlock() +func (c *RPC) GetAccount() (authExported.Account, error) { + c.accountMutex.Lock() + defer c.accountMutex.Unlock() if c.acc == nil { accKb, err := c.kb.Get(c.accName) if err != nil { @@ -190,11 +177,11 @@ func (c *Client) GetAccount() (authExported.Account, error) { 0, ) } - localSeq := c.acc.GetSequence() accR, err := auth.NewAccountRetriever(c).GetAccount(c.acc.GetAddress()) if err != nil { return nil, err } + localSeq := c.acc.GetSequence() c.acc = accR // replace seq if sup if localSeq > c.acc.GetSequence() { @@ -203,21 +190,23 @@ func (c *Client) GetAccount() (authExported.Account, error) { return c.acc, nil } -// CreateAndSignTx build and sign a msg with client account. -func (c *Client) CreateAndSignTx(msgs []sdktypes.Msg) (tenderminttypes.Tx, error) { - // retrieve account - accR, err := c.GetAccount() - if err != nil { - return nil, err +// setAccountSequence sets the sequence on the local account. +func (c *RPC) setAccountSequence(seq uint64) error { + c.accountMutex.Lock() + defer c.accountMutex.Unlock() + if c.acc == nil { + return fmt.Errorf("c.acc should not be nil. use GetAccount first") } - sequence := accR.GetSequence() - accR.SetSequence(accR.GetSequence() + 1) + return c.acc.SetSequence(seq) +} +// createAndSignTx build and sign a msg with client account. +func (c *RPC) createAndSignTx(msgs []sdktypes.Msg, acc authExported.Account) (tenderminttypes.Tx, error) { // Create TxBuilder txBuilder := authtypes.NewTxBuilder( authutils.GetTxEncoder(c.cdc), - accR.GetAccountNumber(), - sequence, + acc.GetAccountNumber(), + acc.GetSequence(), flags.DefaultGasLimit, flags.DefaultGasAdjustment, true, diff --git a/cosmos/type.go b/cosmos/type.go deleted file mode 100644 index 864fd008d..000000000 --- a/cosmos/type.go +++ /dev/null @@ -1,25 +0,0 @@ -package cosmos - -import ( - "fmt" - - sdktypes "github.com/cosmos/cosmos-sdk/types" -) - -// common attribute keys. -const ( - AttributeKeyHash = "hash" -) - -// EventHashType is a message with resource hash -var EventHashType = sdktypes.EventTypeMessage + "." + AttributeKeyHash - -// EventActionQuery returns tendermint query which matches given message type. -func EventActionQuery(msgType string) string { - return fmt.Sprintf("%s.%s='%s'", sdktypes.EventTypeMessage, sdktypes.AttributeKeyAction, msgType) -} - -// EventModuleQuery returns tendermint query which matches given module. -func EventModuleQuery(module string) string { - return fmt.Sprintf("%s.%s='%s'", sdktypes.EventTypeMessage, sdktypes.AttributeKeyModule, module) -} diff --git a/docker-images/http-server/Dockerfile b/docker-images/http-server/Dockerfile deleted file mode 100644 index 86ae486a3..000000000 --- a/docker-images/http-server/Dockerfile +++ /dev/null @@ -1,7 +0,0 @@ -FROM busybox - -COPY httpd.sh . - -EXPOSE 80 - -CMD ["./httpd.sh"] diff --git a/docker-images/http-server/httpd.sh b/docker-images/http-server/httpd.sh deleted file mode 100755 index 77b034e89..000000000 --- a/docker-images/http-server/httpd.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -while true -do - echo -ne "HTTP/1.1 200 OK\r\n\r\nok\r\n" | nc -l -p 80 -w 0 -done diff --git a/docker-images/sleep/Dockerfile b/docker-images/sleep/Dockerfile deleted file mode 100644 index 4b1f6458c..000000000 --- a/docker-images/sleep/Dockerfile +++ /dev/null @@ -1,8 +0,0 @@ -FROM alpine:latest AS build -COPY sleep.s . -RUN apk add binutils nasm -RUN nasm -f elf64 sleep.s && ld sleep.o -o sleep - -FROM scratch -COPY --from=build sleep . -CMD ["./sleep"] diff --git a/docker-images/sleep/sleep.s b/docker-images/sleep/sleep.s deleted file mode 100644 index 99f4aef9b..000000000 --- a/docker-images/sleep/sleep.s +++ /dev/null @@ -1,15 +0,0 @@ -global _start - -section .data - timespec: - tv_sec dq 65535 - tv_nsec dq 0 - -section .text - _start: -.loop: - mov rax, 35 - mov rdi, timespec - xor rsi, rsi - syscall - jmp .loop diff --git a/e2e/account_sequence_test.go b/e2e/account_sequence_test.go new file mode 100644 index 000000000..11b78cff0 --- /dev/null +++ b/e2e/account_sequence_test.go @@ -0,0 +1,34 @@ +package main + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/bank" + "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/crypto" +) + +func testAccountSequence(t *testing.T) { + var ( + randomAddress = sdk.AccAddress(crypto.AddressHash([]byte("hello"))) + err error + ) + t.Run("wrong msg", func(t *testing.T) { + _, err = lcd.BroadcastMsg(bank.NewMsgSend( + cliAddress, + randomAddress, + sdk.NewCoins(sdk.NewInt64Coin("wrong", 1000)), + )) + require.Error(t, err) + require.Contains(t, err.Error(), "transaction returned with invalid code") + }) + t.Run("good msg", func(t *testing.T) { + _, err = lcd.BroadcastMsg(bank.NewMsgSend( + cliAddress, + randomAddress, + sdk.NewCoins(sdk.NewInt64Coin("atto", 1000)), + )) + require.NoError(t, err) + }) +} diff --git a/e2e/api_test.go b/e2e/api_test.go index 7f09746da..c3b77dd5c 100644 --- a/e2e/api_test.go +++ b/e2e/api_test.go @@ -1,91 +1,73 @@ package main import ( - "bytes" "context" - "io/ioutil" - "net/http" + "encoding/base64" + "fmt" "os" "path/filepath" "testing" + "time" + "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/crypto/keys" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/rest" + "github.com/cosmos/cosmos-sdk/x/bank" "github.com/mesg-foundation/engine/app" "github.com/mesg-foundation/engine/config" + "github.com/mesg-foundation/engine/container" "github.com/mesg-foundation/engine/cosmos" - pb "github.com/mesg-foundation/engine/protobuf/api" + "github.com/mesg-foundation/engine/execution" + "github.com/mesg-foundation/engine/hash" + "github.com/mesg-foundation/engine/server/grpc/orchestrator" "github.com/stretchr/testify/require" - rpcclient "github.com/tendermint/tendermint/rpc/client" "google.golang.org/grpc" ) type apiclient struct { - pb.ServiceClient - pb.EventClient - pb.ExecutionClient - pb.ProcessClient - pb.InstanceClient - pb.OwnershipClient - pb.RunnerClient + EventClient orchestrator.EventClient + ExecutionClient orchestrator.ExecutionClient + RunnerClient orchestrator.RunnerClient } var ( minExecutionPrice sdk.Coins - client apiclient - cclient *cosmos.Client + client *apiclient cdc = app.MakeCodec() processInitialBalance = sdk.NewCoins(sdk.NewInt64Coin("atto", 10000000)) + kb *cosmos.Keybase + cfg *config.Config + engineAddress sdk.AccAddress + cont *container.Container + lcd *cosmos.LCD + lcdEngine *cosmos.LCD + cliAddress sdk.AccAddress + cliInitialBalance, _ = sdk.ParseCoins("100000000000000000000000000atto") ) const ( lcdEndpoint = "http://127.0.0.1:1317/" - lcdPostContentType = "application/json" + pollingInterval = 500 * time.Millisecond // half a block + pollingTimeout = 10 * time.Second // 10 blocks + gasLimit = flags.DefaultGasLimit * 10 // x10 so the biggest txs have enough gas + cliAccountMnemonic = "large fork soccer lab answer enlist robust vacant narrow please inmate primary father must add hub shy couch rail video tool marine pill give" + cliAccountName = "cli" + cliAccountPassword = "pass" ) -func lcdGet(t *testing.T, path string, ptr interface{}) { - resp, err := http.Get(lcdEndpoint + path) - require.NoError(t, err) - defer resp.Body.Close() - body, err := ioutil.ReadAll(resp.Body) - require.NoError(t, err) - cosResp := rest.ResponseWithHeight{} - require.NoError(t, cdc.UnmarshalJSON(body, &cosResp)) - if len(cosResp.Result) > 0 { - require.NoError(t, cdc.UnmarshalJSON(cosResp.Result, ptr)) - } -} - -func lcdPost(t *testing.T, path string, req interface{}, ptr interface{}) { - reqBody, err := cdc.MarshalJSON(req) - require.NoError(t, err) - resp, err := http.Post(lcdEndpoint+path, lcdPostContentType, bytes.NewReader(reqBody)) - require.NoError(t, err) - defer resp.Body.Close() - body, err := ioutil.ReadAll(resp.Body) - require.NoError(t, err) - cosResp := rest.ResponseWithHeight{} - require.NoError(t, cdc.UnmarshalJSON(body, &cosResp)) - if len(cosResp.Result) > 0 { - require.NoError(t, cdc.UnmarshalJSON(cosResp.Result, ptr)) - } -} - func TestAPI(t *testing.T) { if testing.Short() { t.Skip() } - cfg, err := config.New() - require.NoError(t, err) + // init the config of cosmos + cosmos.InitConfig() - minExecutionPrice, err = sdk.ParseCoins(cfg.DefaultExecutionPrice) + // init config + var err error + cfg, err = config.New() require.NoError(t, err) - - cosmos.CustomizeConfig(cfg) - - conn, err := grpc.DialContext(context.Background(), "localhost:50052", grpc.WithInsecure()) + minExecutionPrice, err = sdk.ParseCoins(cfg.DefaultExecutionPrice) require.NoError(t, err) // change and recreate cosmos relative path because CI dir permissions @@ -93,35 +75,45 @@ func TestAPI(t *testing.T) { err = os.MkdirAll(filepath.Join(cfg.Path, cfg.Cosmos.RelativePath), os.FileMode(0755)) require.NoError(t, err) - kb, err := cosmos.NewKeybase(filepath.Join(cfg.Path, cfg.Cosmos.RelativePath)) + // init keybase with engine account and cli account + kb, err = cosmos.NewKeybase(filepath.Join(cfg.Path, cfg.Cosmos.RelativePath)) + require.NoError(t, err) + // init engine account + engineAcc, err := kb.CreateAccount(cfg.Account.Name, cfg.Account.Mnemonic, "", cfg.Account.Password, keys.CreateHDPath(cfg.Account.Number, cfg.Account.Index).String(), cosmos.DefaultAlgo) + require.NoError(t, err) + engineAddress = engineAcc.GetAddress() + + // init cli account + cliAcc, err := kb.CreateAccount(cliAccountName, cliAccountMnemonic, "", cliAccountPassword, keys.CreateHDPath(cfg.Account.Number, cfg.Account.Index).String(), cosmos.DefaultAlgo) + require.NoError(t, err) + cliAddress = cliAcc.GetAddress() + + // init LCD with engine account and make a transfer to cli account + lcdEngine, err = cosmos.NewLCD(lcdEndpoint, cdc, kb, cfg.DevGenesis.ChainID, cfg.Account.Name, cfg.Account.Password, cfg.Cosmos.MinGasPrices, gasLimit) + require.NoError(t, err) + _, err = lcdEngine.BroadcastMsg(bank.NewMsgSend(engineAddress, cliAddress, cliInitialBalance)) require.NoError(t, err) - if cfg.Account.Mnemonic != "" { - _, err = kb.CreateAccount(cfg.Account.Name, cfg.Account.Mnemonic, "", cfg.Account.Password, keys.CreateHDPath(cfg.Account.Number, cfg.Account.Index).String(), cosmos.DefaultAlgo) - require.NoError(t, err) - } - httpclient, err := rpcclient.NewHTTP("http://localhost:26657", "/websocket") + // init container + cont, err = container.New(cfg.IpfsEndpoint, cfg.Name, cfg.Server.Address, cfg.Name) require.NoError(t, err) - require.NoError(t, httpclient.Start()) - defer httpclient.Stop() - cclient, err = cosmos.NewClient(httpclient, cdc, kb, cfg.DevGenesis.ChainID, cfg.Account.Name, cfg.Account.Password, cfg.Cosmos.MinGasPrices) + + // init gRPC client + conn, err := grpc.DialContext(context.Background(), "localhost:50052", grpc.WithInsecure()) require.NoError(t, err) - client = apiclient{ - pb.NewServiceClient(conn), - pb.NewEventClient(conn), - pb.NewExecutionClient(conn), - pb.NewProcessClient(conn), - pb.NewInstanceClient(conn), - pb.NewOwnershipClient(conn), - pb.NewRunnerClient(conn), + client = &apiclient{ + EventClient: orchestrator.NewEventClient(conn), + ExecutionClient: orchestrator.NewExecutionClient(conn), + RunnerClient: orchestrator.NewRunnerClient(conn), } - // ping server to test connection - _, err = client.ServiceClient.List(context.Background(), &pb.ListServiceRequest{}) + // init LCD + lcd, err = cosmos.NewLCD(lcdEndpoint, cdc, kb, cfg.DevGenesis.ChainID, cliAccountName, cliAccountPassword, cfg.Cosmos.MinGasPrices, gasLimit) require.NoError(t, err) - // basic tests + // run tests + t.Run("account-sequence", testAccountSequence) t.Run("service", testService) t.Run("runner", testRunner) t.Run("process", testProcess) @@ -132,3 +124,80 @@ func TestAPI(t *testing.T) { t.Run("runner/delete", testDeleteRunner) t.Run("complex-service", testComplexService) } + +func pollExecution(executionHash hash.Hash, status execution.Status) (*execution.Execution, error) { + timeout := time.After(pollingTimeout) + for { + var exec *execution.Execution + if err := lcd.Get("execution/get/"+executionHash.String(), &exec); err != nil { + return nil, err + } + if exec.Status == status { + return exec, nil + } + select { + case <-time.After(pollingInterval): + continue + case <-timeout: + return nil, fmt.Errorf("pollExecution timeout with execution hash %q", executionHash) + } + } +} + +func pollExecutionOfProcess(processHash hash.Hash, status execution.Status, nodeKey string) (*execution.Execution, error) { + timeout := time.After(pollingTimeout) + for { + var execs []*execution.Execution + if err := lcd.Get("execution/list", &execs); err != nil { + return nil, err + } + for _, exec := range execs { + if exec.ProcessHash.Equal(processHash) && exec.Status == status && exec.NodeKey == nodeKey { + return exec, nil + } + } + select { + case <-time.After(pollingInterval): + continue + case <-timeout: + return nil, fmt.Errorf("pollExecutionOfProcess timeout with process hash %q and status %q and nodeKey %q", processHash, status, nodeKey) + } + } +} + +func signPayload(payload interface{}) ([]byte, error) { + encodedValue, err := cdc.MarshalJSON(payload) + if err != nil { + return nil, err + } + encodedValueSorted, err := sdk.SortJSON(encodedValue) + if err != nil { + return nil, err + } + signature, _, err := kb.Sign(cliAccountName, cliAccountPassword, encodedValueSorted) + if err != nil { + return nil, err + } + return signature, nil +} + +// signCred is a structure that manage a token. +type signCred struct { + request interface{} +} + +// GetRequestMetadata returns the metadata for the request. +func (c *signCred) GetRequestMetadata(context.Context, ...string) (map[string]string, error) { + signature, err := signPayload(c.request) + if err != nil { + return nil, err + } + return map[string]string{ + orchestrator.RequestSignature: base64.StdEncoding.EncodeToString(signature), + }, nil +} + +// RequireTransportSecurity tells if the transport should be secured. +func (c *signCred) RequireTransportSecurity() bool { + return false +} diff --git a/e2e/complex_service_test.go b/e2e/complex_service_test.go index 472e2ce69..a038feda9 100644 --- a/e2e/complex_service_test.go +++ b/e2e/complex_service_test.go @@ -4,57 +4,90 @@ import ( "context" "testing" + "github.com/mesg-foundation/engine/ext/xos" "github.com/mesg-foundation/engine/hash" "github.com/mesg-foundation/engine/protobuf/acknowledgement" - pb "github.com/mesg-foundation/engine/protobuf/api" + "github.com/mesg-foundation/engine/server/grpc/orchestrator" + grpcorchestrator "github.com/mesg-foundation/engine/server/grpc/orchestrator" + "github.com/mesg-foundation/engine/service" + runnerrest "github.com/mesg-foundation/engine/x/runner/client/rest" "github.com/stretchr/testify/require" + "google.golang.org/grpc" ) func testComplexService(t *testing.T) { var ( - testServiceHash hash.Hash - testRunnerHashC hash.Hash - testInstanceHash hash.Hash + testServiceComplexHash hash.Hash + testRunnerComplexHash hash.Hash + testInstanceComplexHash hash.Hash + testInstanceComplexEnvHash hash.Hash + testServiceComplexStruct *service.Service + testInstanceComplexEnv []string + registerPayloadSignature []byte + err error ) - req := newTestComplexCreateServiceRequest() - - t.Run("create", func(t *testing.T) { - resp, err := client.ServiceClient.Create(context.Background(), req) + t.Run("create service", func(t *testing.T) { + testComplexCreateServiceMsg.Owner = cliAddress + testServiceComplexHash, err = lcd.BroadcastMsg(testComplexCreateServiceMsg) require.NoError(t, err) - testServiceHash = resp.Hash }) - stream, err := client.EventClient.Stream(context.Background(), &pb.StreamEventRequest{}) - require.NoError(t, err) - acknowledgement.WaitForStreamToBeReady(stream) + t.Run("get", func(t *testing.T) { + require.NoError(t, lcd.Get("service/get/"+testServiceComplexHash.String(), &testServiceComplexStruct)) + require.Equal(t, testServiceComplexHash, testServiceComplexStruct.Hash) + }) + testInstanceComplexEnv = xos.EnvMergeSlices(testServiceComplexStruct.Configuration.Env, []string{"ENVB=is_override"}) - t.Run("run", func(t *testing.T) { - resp, err := client.RunnerClient.Create(context.Background(), &pb.CreateRunnerRequest{ - ServiceHash: testServiceHash, - Env: []string{"ENVB=is_override"}, - }) + t.Run("get runner hashes", func(t *testing.T) { + var res runnerrest.HashResponse + err := lcd.Post("runner/hash", &runnerrest.HashRequest{ + ServiceHash: testServiceComplexHash, + Address: engineAddress.String(), + Env: testInstanceComplexEnv, + }, &res) require.NoError(t, err) - testRunnerHashC = resp.Hash + testRunnerComplexHash = res.RunnerHash + testInstanceComplexHash = res.InstanceHash + testInstanceComplexEnvHash = res.EnvHash + }) + + t.Run("build service image", func(t *testing.T) { + require.NoError(t, cont.Build(testServiceComplexStruct)) + }) + + t.Run("create msg, sign it and inject into env", func(t *testing.T) { + value := grpcorchestrator.RunnerRegisterRequest{ + ServiceHash: testServiceComplexHash, + EnvHash: testInstanceComplexEnvHash, + } - resp1, err := client.RunnerClient.Get(context.Background(), &pb.GetRunnerRequest{Hash: testRunnerHashC}) + registerPayloadSignature, err = signPayload(value) require.NoError(t, err) - testInstanceHash = resp1.InstanceHash }) + t.Run("start runner", func(t *testing.T) { + require.NoError(t, cont.Start(testServiceComplexStruct, testInstanceComplexHash, testRunnerComplexHash, testInstanceComplexEnvHash, testInstanceComplexEnv, registerPayloadSignature)) + }) + + req := orchestrator.EventStreamRequest{} + stream, err := client.EventClient.Stream(context.Background(), &req, grpc.PerRPCCredentials(&signCred{req})) + require.NoError(t, err) + acknowledgement.WaitForStreamToBeReady(stream) + t.Run("check events", func(t *testing.T) { okEventsNo := 6 for i := 0; i < okEventsNo; { ev, err := stream.Recv() require.NoError(t, err) - if !ev.InstanceHash.Equal(testInstanceHash) { + if !ev.InstanceHash.Equal(testInstanceComplexHash) { continue } i++ switch ev.Key { - case "test_service_ready", "read_env_ok", "read_env_override_ok", "access_volumes_ok", "access_volumes_from_ok", "resolve_dependence_ok": + case "service_ready", "read_env_ok", "read_env_override_ok", "access_volumes_ok", "access_volumes_from_ok", "resolve_dependence_ok": t.Logf("received event %s ", ev.Key) default: t.Fatalf("failed on event %s", ev.Key) @@ -63,8 +96,12 @@ func testComplexService(t *testing.T) { }) t.Run("delete", func(t *testing.T) { - t.Skip("FIXME: this call never get trough. some issue with the service's dependency") - _, err := client.RunnerClient.Delete(context.Background(), &pb.DeleteRunnerRequest{Hash: testRunnerHashC}) + req := orchestrator.RunnerDeleteRequest{ + RunnerHash: testRunnerComplexHash, + } + _, err := client.RunnerClient.Delete(context.Background(), &req, grpc.PerRPCCredentials(&signCred{req})) require.NoError(t, err) + + require.NoError(t, cont.Stop(testServiceComplexStruct, testRunnerComplexHash)) }) } diff --git a/e2e/definition_test.go b/e2e/definition_test.go index 7d9ffe991..637abc452 100644 --- a/e2e/definition_test.go +++ b/e2e/definition_test.go @@ -1,192 +1,236 @@ package main import ( - "github.com/mesg-foundation/engine/protobuf/api" - pb "github.com/mesg-foundation/engine/protobuf/api" "github.com/mesg-foundation/engine/service" + servicemodule "github.com/mesg-foundation/engine/x/service" ) -func newTestComplexCreateServiceRequest() *pb.CreateServiceRequest { - return &api.CreateServiceRequest{ - Sid: "test-complex-service", - Name: "test-complex-service", - Dependencies: []*service.Service_Dependency{ - { - Key: "nginx", - Image: "nginx", - Volumes: []string{"/etc/nginx"}, - }, - }, - Configuration: service.Service_Configuration{ - Env: []string{ - "ENVA=do_not_override", - "ENVB=override", - }, - Volumes: []string{"/volume/test/"}, - VolumesFrom: []string{"nginx"}, +var testComplexCreateServiceMsg = &servicemodule.MsgCreate{ + Sid: "test-complex-service", + Name: "test-complex-service", + Dependencies: []*service.Service_Dependency{ + { + Key: "nginx", + Image: "nginx", + Volumes: []string{"/etc/nginx"}, }, - Events: []*service.Service_Event{ - {Key: "test_service_ready"}, - {Key: "read_env_ok"}, - {Key: "read_env_error"}, - {Key: "read_env_override_ok"}, - {Key: "read_env_override_error"}, - {Key: "access_volumes_ok"}, - {Key: "access_volumes_error"}, - {Key: "access_volumes_from_ok"}, - {Key: "access_volumes_from_error"}, - {Key: "resolve_dependence_ok"}, - {Key: "resolve_dependence_error"}, + }, + Configuration: service.Service_Configuration{ + Env: []string{ + "ENVA=do_not_override", + "ENVB=override", }, - Source: "QmSuVcdic2dhS5QKQGWp66SJQUkDRqAqCHpU6Sx9uXJcdc", - } + Volumes: []string{"/volume/test/"}, + VolumesFrom: []string{"nginx"}, + }, + Events: []*service.Service_Event{ + {Key: "service_ready"}, + {Key: "read_env_ok"}, + {Key: "read_env_error"}, + {Key: "read_env_override_ok"}, + {Key: "read_env_override_error"}, + {Key: "access_volumes_ok"}, + {Key: "access_volumes_error"}, + {Key: "access_volumes_from_ok"}, + {Key: "access_volumes_from_error"}, + {Key: "resolve_dependence_ok"}, + {Key: "resolve_dependence_error"}, + }, + Source: "QmQbobdv3tg1UdPiHBGaqbQF2mjGHPBBNAK4M9hoFA3NVU", } -func newTestCreateServiceRequest() *pb.CreateServiceRequest { - return &api.CreateServiceRequest{ - Sid: "test-service", - Name: "test-service", - Configuration: service.Service_Configuration{ - Env: []string{"FOO=1", "BAR=2", "REQUIRED"}, +var testCreateServiceMsg = &servicemodule.MsgCreate{ + Sid: "test-service", + Name: "test-service", + Configuration: service.Service_Configuration{ + Env: []string{"FOO=1", "BAR=2", "REQUIRED"}, + }, + Tasks: []*service.Service_Task{ + { + Key: "task_trigger", + Inputs: []*service.Service_Parameter{ + { + Key: "msg", + Type: "String", + }, + }, + Outputs: []*service.Service_Parameter{ + { + Key: "msg", + Type: "String", + }, + { + Key: "timestamp", + Type: "Number", + }, + }, }, - Tasks: []*service.Service_Task{ - { - Key: "task1", - Inputs: []*service.Service_Parameter{ - { - Key: "msg", - Type: "String", - }, + { + Key: "task1", + Inputs: []*service.Service_Parameter{ + { + Key: "msg", + Type: "String", }, - Outputs: []*service.Service_Parameter{ - { - Key: "msg", - Type: "String", - }, - { - Key: "timestamp", - Type: "Number", - }, + }, + Outputs: []*service.Service_Parameter{ + { + Key: "msg", + Type: "String", + }, + { + Key: "timestamp", + Type: "Number", }, }, - { - Key: "task2", - Inputs: []*service.Service_Parameter{ - { - Key: "msg", - Type: "String", - }, + }, + { + Key: "task2", + Inputs: []*service.Service_Parameter{ + { + Key: "msg", + Type: "String", }, - Outputs: []*service.Service_Parameter{ - { - Key: "msg", - Type: "String", - }, - { - Key: "timestamp", - Type: "Number", - }, + }, + Outputs: []*service.Service_Parameter{ + { + Key: "msg", + Type: "String", + }, + { + Key: "timestamp", + Type: "Number", }, }, - { - Key: "task_complex", - Inputs: []*service.Service_Parameter{ - { - Key: "msg", - Type: "Object", - Object: []*service.Service_Parameter{ - { - Key: "msg", - Type: "String", - }, - { - Key: "array", - Type: "String", - Repeated: true, - Optional: true, - }, + }, + { + Key: "task_complex", + Inputs: []*service.Service_Parameter{ + { + Key: "msg", + Type: "Object", + Object: []*service.Service_Parameter{ + { + Key: "msg", + Type: "String", + }, + { + Key: "array", + Type: "String", + Repeated: true, + Optional: true, }, }, }, - Outputs: []*service.Service_Parameter{ - { - Key: "msg", - Type: "Object", - Object: []*service.Service_Parameter{ - { - Key: "msg", - Type: "String", - }, - { - Key: "timestamp", - Type: "Number", - }, - { - Key: "array", - Type: "String", - Repeated: true, - Optional: true, - }, + }, + Outputs: []*service.Service_Parameter{ + { + Key: "msg", + Type: "Object", + Object: []*service.Service_Parameter{ + { + Key: "msg", + Type: "String", + }, + { + Key: "timestamp", + Type: "Number", + }, + { + Key: "array", + Type: "String", + Repeated: true, + Optional: true, }, }, }, }, }, - Events: []*service.Service_Event{ - { - Key: "test_service_ready", - }, - { - Key: "test_event", - Data: []*service.Service_Parameter{ - { - Key: "msg", - Type: "String", - }, - { - Key: "timestamp", - Type: "Number", + { + Key: "task_complex_trigger", + Inputs: []*service.Service_Parameter{ + { + Key: "msg", + Type: "Object", + Object: []*service.Service_Parameter{ + { + Key: "msg", + Type: "String", + }, + { + Key: "array", + Type: "String", + Repeated: true, + Optional: true, + }, }, }, }, - { - Key: "test_event_complex", - Data: []*service.Service_Parameter{ - { - Key: "msg", - Type: "Object", - Object: []*service.Service_Parameter{ - { - Key: "msg", - Type: "String", - }, - { - Key: "timestamp", - Type: "Number", - }, - { - Key: "array", - Type: "String", - Repeated: true, - }, + Outputs: []*service.Service_Parameter{ + { + Key: "msg", + Type: "Object", + Object: []*service.Service_Parameter{ + { + Key: "msg", + Type: "String", + }, + { + Key: "timestamp", + Type: "Number", + }, + { + Key: "array", + Type: "String", + Repeated: true, + Optional: true, }, }, }, }, - { - Key: "event_after_task", - Data: []*service.Service_Parameter{ - { - Key: "task_key", - Type: "String", - }, - { - Key: "timestamp", - Type: "Number", + }, + }, + Events: []*service.Service_Event{ + { + Key: "service_ready", + }, + { + Key: "event_trigger", + Data: []*service.Service_Parameter{ + { + Key: "msg", + Type: "String", + }, + { + Key: "timestamp", + Type: "Number", + }, + }, + }, + { + Key: "event_complex_trigger", + Data: []*service.Service_Parameter{ + { + Key: "msg", + Type: "Object", + Object: []*service.Service_Parameter{ + { + Key: "msg", + Type: "String", + }, + { + Key: "timestamp", + Type: "Number", + }, + { + Key: "array", + Type: "String", + Repeated: true, + }, }, }, }, }, - Source: "QmXcPDajWN55n1UPV5VNJDEKE96xJFJMe3X7GwN3qx8p7r", - } + }, + Source: "QmXiBMy2rguhPn5hCmHh8rw1jjpq6YcekiUcvh91htVndM", } diff --git a/e2e/event_test.go b/e2e/event_test.go index fe9df51ca..7a14ad347 100644 --- a/e2e/event_test.go +++ b/e2e/event_test.go @@ -1,112 +1,106 @@ package main import ( - "context" "testing" - "time" - - "github.com/mesg-foundation/engine/hash" - "github.com/mesg-foundation/engine/protobuf/acknowledgement" - pb "github.com/mesg-foundation/engine/protobuf/api" - "github.com/mesg-foundation/engine/protobuf/types" - "github.com/stretchr/testify/require" ) func testEvent(t *testing.T) { - stream, err := client.EventClient.Stream(context.Background(), &pb.StreamEventRequest{ - Filter: &pb.StreamEventRequest_Filter{}, - }) - require.NoError(t, err) - acknowledgement.WaitForStreamToBeReady(stream) + t.SkipNow() + // TODO: cannot create an event so this test is not functional + // stream, err := client.EventClient.Stream(context.Background(), &orchestrator.EventStreamRequest{ + // Filter: &orchestrator.EventStreamRequest_Filter{}, + // }, grpc.PerRPCCredentials(&signCred{req})) + // require.NoError(t, err) + // acknowledgement.WaitForStreamToBeReady(stream) - t.Run("simple event", func(t *testing.T) { - var ( - eventHash hash.Hash - data = &types.Struct{ - Fields: map[string]*types.Value{ - "msg": { - Kind: &types.Value_StringValue{ - StringValue: "foo", - }, - }, - "timestamp": { - Kind: &types.Value_NumberValue{ - NumberValue: float64(time.Now().Unix()), - }, - }, - }, - } - ) - t.Run("create", func(t *testing.T) { - resp, err := client.EventClient.Create(context.Background(), &pb.CreateEventRequest{ - InstanceHash: testInstanceHash, - Key: "test_event", - Data: data, - }) - require.NoError(t, err) - eventHash = resp.Hash - }) - t.Run("receive", func(t *testing.T) { - event, err := stream.Recv() - require.NoError(t, err) - require.Equal(t, eventHash, event.Hash) - require.Equal(t, testInstanceHash, event.InstanceHash) - require.Equal(t, "test_event", event.Key) - require.True(t, data.Equal(event.Data)) - }) - }) + // t.Run("simple event", func(t *testing.T) { + // var ( + // eventHash hash.Hash + // data = &types.Struct{ + // Fields: map[string]*types.Value{ + // "msg": { + // Kind: &types.Value_StringValue{ + // StringValue: "foo", + // }, + // }, + // "timestamp": { + // Kind: &types.Value_NumberValue{ + // NumberValue: float64(time.Now().Unix()), + // }, + // }, + // }, + // } + // ) + // t.Run("create", func(t *testing.T) { + // resp, err := client.EventClient.Create(context.Background(), &pb.CreateEventRequest{ + // InstanceHash: testInstanceHash, + // Key: "event_trigger", + // Data: data, + // }) + // require.NoError(t, err) + // eventHash = resp.Hash + // }) + // t.Run("receive", func(t *testing.T) { + // event, err := stream.Recv() + // require.NoError(t, err) + // require.Equal(t, eventHash, event.Hash) + // require.Equal(t, testInstanceHash, event.InstanceHash) + // require.Equal(t, "event_trigger", event.Key) + // require.True(t, data.Equal(event.Data)) + // }) + // }) - t.Run("complex event", func(t *testing.T) { - var ( - eventHash hash.Hash - data = &types.Struct{ - Fields: map[string]*types.Value{ - "msg": { - Kind: &types.Value_StructValue{ - StructValue: &types.Struct{ - Fields: map[string]*types.Value{ - "msg": { - Kind: &types.Value_StringValue{ - StringValue: "complex", - }, - }, - "timestamp": { - Kind: &types.Value_NumberValue{ - NumberValue: float64(time.Now().Unix()), - }, - }, - "array": { - Kind: &types.Value_ListValue{ - ListValue: &types.ListValue{Values: []*types.Value{ - {Kind: &types.Value_StringValue{StringValue: "first"}}, - {Kind: &types.Value_StringValue{StringValue: "second"}}, - {Kind: &types.Value_StringValue{StringValue: "third"}}, - }}, - }, - }, - }, - }, - }, - }, - }, - } - ) - t.Run("create", func(t *testing.T) { - resp, err := client.EventClient.Create(context.Background(), &pb.CreateEventRequest{ - InstanceHash: testInstanceHash, - Key: "test_event_complex", - Data: data, - }) - require.NoError(t, err) - eventHash = resp.Hash - }) - t.Run("receive", func(t *testing.T) { - event, err := stream.Recv() - require.NoError(t, err) - require.Equal(t, eventHash, event.Hash) - require.Equal(t, testInstanceHash, event.InstanceHash) - require.Equal(t, "test_event_complex", event.Key) - require.True(t, data.Equal(event.Data)) - }) - }) + // t.Run("complex event", func(t *testing.T) { + // var ( + // eventHash hash.Hash + // data = &types.Struct{ + // Fields: map[string]*types.Value{ + // "msg": { + // Kind: &types.Value_StructValue{ + // StructValue: &types.Struct{ + // Fields: map[string]*types.Value{ + // "msg": { + // Kind: &types.Value_StringValue{ + // StringValue: "complex", + // }, + // }, + // "timestamp": { + // Kind: &types.Value_NumberValue{ + // NumberValue: float64(time.Now().Unix()), + // }, + // }, + // "array": { + // Kind: &types.Value_ListValue{ + // ListValue: &types.ListValue{Values: []*types.Value{ + // {Kind: &types.Value_StringValue{StringValue: "first"}}, + // {Kind: &types.Value_StringValue{StringValue: "second"}}, + // {Kind: &types.Value_StringValue{StringValue: "third"}}, + // }}, + // }, + // }, + // }, + // }, + // }, + // }, + // }, + // } + // ) + // t.Run("create", func(t *testing.T) { + // resp, err := client.EventClient.Create(context.Background(), &pb.CreateEventRequest{ + // InstanceHash: testInstanceHash, + // Key: "event_complex_trigger", + // Data: data, + // }) + // require.NoError(t, err) + // eventHash = resp.Hash + // }) + // t.Run("receive", func(t *testing.T) { + // event, err := stream.Recv() + // require.NoError(t, err) + // require.Equal(t, eventHash, event.Hash) + // require.Equal(t, testInstanceHash, event.InstanceHash) + // require.Equal(t, "event_complex_trigger", event.Key) + // require.True(t, data.Equal(event.Data)) + // }) + // }) } diff --git a/e2e/execution_test.go b/e2e/execution_test.go index 62185031f..ca0e5ea3d 100644 --- a/e2e/execution_test.go +++ b/e2e/execution_test.go @@ -6,55 +6,29 @@ import ( "testing" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/bank" "github.com/mesg-foundation/engine/execution" "github.com/mesg-foundation/engine/hash" - "github.com/mesg-foundation/engine/protobuf/acknowledgement" - pb "github.com/mesg-foundation/engine/protobuf/api" "github.com/mesg-foundation/engine/protobuf/types" + "github.com/mesg-foundation/engine/server/grpc/orchestrator" "github.com/mesg-foundation/engine/x/ownership" "github.com/stretchr/testify/require" + "google.golang.org/grpc" ) func testExecution(t *testing.T) { var ( - streamInProgress pb.Execution_StreamClient - streamCompleted pb.Execution_StreamClient - err error - executorHash = testRunnerHash - executorAddress = testRunnerAddress + executorHash = testRunnerHash + executorAddress = testRunnerAddress + err error ) - t.Run("create stream nil filter", func(t *testing.T) { - _, err := client.ExecutionClient.Stream(context.Background(), &pb.StreamExecutionRequest{}) - require.NoError(t, err) - }) - - t.Run("create stream", func(t *testing.T) { - streamInProgress, err = client.ExecutionClient.Stream(context.Background(), &pb.StreamExecutionRequest{ - Filter: &pb.StreamExecutionRequest_Filter{ - ExecutorHash: executorHash, - Statuses: []execution.Status{execution.Status_InProgress}, - }, - }) - require.NoError(t, err) - streamCompleted, err = client.ExecutionClient.Stream(context.Background(), &pb.StreamExecutionRequest{ - Filter: &pb.StreamExecutionRequest_Filter{ - ExecutorHash: executorHash, - Statuses: []execution.Status{execution.Status_Completed}, - }, - }) - require.NoError(t, err) - acknowledgement.WaitForStreamToBeReady(streamInProgress) - acknowledgement.WaitForStreamToBeReady(streamCompleted) - }) - - t.Run("simple execution", func(t *testing.T) { + t.Run("simple execution with price and withdraw", func(t *testing.T) { var ( executionHash hash.Hash + execAddress sdk.AccAddress exec *execution.Execution taskKey = "task1" - eventHash = hash.Int(1) + price = sdk.NewCoins(sdk.NewInt64Coin("atto", 50000)) inputs = &types.Struct{ Fields: map[string]*types.Value{ "msg": { @@ -64,33 +38,52 @@ func testExecution(t *testing.T) { }, }, } + expectedCoinsForExecutor = sdk.NewCoins(sdk.NewInt64Coin("atto", 40000)) // 80% + expectedCoinsForService = sdk.NewCoins(sdk.NewInt64Coin("atto", 5000)) // 10% + expectedCoinsForEmitter = sdk.NewCoins(sdk.NewInt64Coin("atto", 5000)) // 10% + executorBalance sdk.Coins + serviceBalance sdk.Coins ) + + require.NoError(t, lcd.Get("bank/balances/"+executorAddress.String(), &executorBalance)) + require.NoError(t, lcd.Get("bank/balances/"+testServiceAddress.String(), &serviceBalance)) + t.Run("create", func(t *testing.T) { - resp, err := client.ExecutionClient.Create(context.Background(), &pb.CreateExecutionRequest{ + req := orchestrator.ExecutionCreateRequest{ TaskKey: taskKey, - EventHash: eventHash, ExecutorHash: executorHash, Inputs: inputs, - }) + Price: price.String(), + } + resp, err := client.ExecutionClient.Create(context.Background(), &req, grpc.PerRPCCredentials(&signCred{req})) require.NoError(t, err) executionHash = resp.Hash }) + t.Run("get execution address", func(t *testing.T) { + var exec *execution.Execution + require.NoError(t, lcd.Get("execution/get/"+executionHash.String(), &exec)) + require.Equal(t, exec.Hash, executionHash) + execAddress = exec.Address + }) + t.Run("execution balance before completed", func(t *testing.T) { + coins := sdk.Coins{} + require.NoError(t, lcd.Get("bank/balances/"+execAddress.String(), &coins)) + require.True(t, coins.IsEqual(price), price, coins) + }) t.Run("in progress", func(t *testing.T) { - execInProgress, err := streamInProgress.Recv() + execInProgress, err := pollExecution(executionHash, execution.Status_InProgress) require.NoError(t, err) require.Equal(t, executionHash, execInProgress.Hash) require.Equal(t, taskKey, execInProgress.TaskKey) - require.Equal(t, eventHash, execInProgress.EventHash) require.Equal(t, executorHash, execInProgress.ExecutorHash) require.Equal(t, execution.Status_InProgress, execInProgress.Status) require.True(t, inputs.Equal(execInProgress.Inputs)) }) t.Run("completed", func(t *testing.T) { - exec, err = streamCompleted.Recv() + exec, err = pollExecution(executionHash, execution.Status_Completed) require.NoError(t, err) require.Equal(t, executionHash, exec.Hash) require.Equal(t, taskKey, exec.TaskKey) - require.Equal(t, eventHash, exec.EventHash) require.Equal(t, executorHash, exec.ExecutorHash) require.Equal(t, execution.Status_Completed, exec.Status) require.True(t, inputs.Equal(exec.Inputs)) @@ -98,9 +91,54 @@ func testExecution(t *testing.T) { require.NotEmpty(t, exec.Outputs.Fields["timestamp"].GetNumberValue()) }) t.Run("get", func(t *testing.T) { - exec, err := client.ExecutionClient.Get(context.Background(), &pb.GetExecutionRequest{Hash: executionHash}) + var execR *execution.Execution + require.NoError(t, lcd.Get("execution/get/"+executionHash.String(), &execR)) + require.True(t, exec.Equal(execR), exec, execR) + }) + t.Run("executor + emitter balance", func(t *testing.T) { + var coins sdk.Coins + require.NoError(t, lcd.Get("bank/balances/"+executorAddress.String(), &coins)) + expectedCoins := expectedCoinsForExecutor.Add(expectedCoinsForEmitter...).Add(executorBalance...) + require.True(t, expectedCoins.IsEqual(coins), expectedCoins, coins) + }) + t.Run("service balance", func(t *testing.T) { + var coins sdk.Coins + require.NoError(t, lcd.Get("bank/balances/"+testServiceAddress.String(), &coins)) + expectedCoins := expectedCoinsForService.Add(serviceBalance...) + require.True(t, expectedCoins.IsEqual(coins), expectedCoins, coins) + }) + t.Run("execution balance", func(t *testing.T) { + var coins sdk.Coins + require.NoError(t, lcd.Get("bank/balances/"+execAddress.String(), &coins)) + require.True(t, coins.IsZero(), coins) + }) + t.Run("withdraw from service", func(t *testing.T) { + msg := ownership.MsgWithdraw{ + Owner: cliAddress, + Amount: expectedCoinsForService.String(), + ResourceHash: testServiceHash, + } + _, err := lcd.BroadcastMsg(msg) require.NoError(t, err) - require.True(t, exec.Equal(exec)) + + // check balance + var coins sdk.Coins + require.NoError(t, lcd.Get("bank/balances/"+testServiceAddress.String(), &coins)) + require.True(t, serviceBalance.IsEqual(coins), serviceBalance, coins) + }) + t.Run("withdraw from runner", func(t *testing.T) { + msg := ownership.MsgWithdraw{ + Owner: engineAddress, + Amount: expectedCoinsForExecutor.Add(expectedCoinsForEmitter...).String(), + ResourceHash: testRunnerHash, + } + _, err := lcdEngine.BroadcastMsg(msg) + require.NoError(t, err) + + // check balance + var coins sdk.Coins + require.NoError(t, lcd.Get("bank/balances/"+testRunnerAddress.String(), &coins)) + require.True(t, executorBalance.IsEqual(coins), executorBalance, coins) }) }) @@ -109,7 +147,7 @@ func testExecution(t *testing.T) { executionHash hash.Hash exec *execution.Execution taskKey = "task_complex" - eventHash = hash.Int(2) + price = "10000atto" inputs = &types.Struct{ Fields: map[string]*types.Value{ "msg": { @@ -138,31 +176,30 @@ func testExecution(t *testing.T) { } ) t.Run("create", func(t *testing.T) { - resp, err := client.ExecutionClient.Create(context.Background(), &pb.CreateExecutionRequest{ + req := orchestrator.ExecutionCreateRequest{ TaskKey: taskKey, - EventHash: eventHash, ExecutorHash: executorHash, Inputs: inputs, - }) + Price: price, + } + resp, err := client.ExecutionClient.Create(context.Background(), &req, grpc.PerRPCCredentials(&signCred{req})) require.NoError(t, err) executionHash = resp.Hash }) t.Run("in progress", func(t *testing.T) { - execInProgress, err := streamInProgress.Recv() + execInProgress, err := pollExecution(executionHash, execution.Status_InProgress) require.NoError(t, err) require.Equal(t, executionHash, execInProgress.Hash) require.Equal(t, taskKey, execInProgress.TaskKey) - require.Equal(t, eventHash, execInProgress.EventHash) require.Equal(t, executorHash, execInProgress.ExecutorHash) require.Equal(t, execution.Status_InProgress, execInProgress.Status) require.True(t, inputs.Equal(execInProgress.Inputs)) }) t.Run("completed", func(t *testing.T) { - exec, err = streamCompleted.Recv() + exec, err = pollExecution(executionHash, execution.Status_Completed) require.NoError(t, err) require.Equal(t, executionHash, exec.Hash) require.Equal(t, taskKey, exec.TaskKey) - require.Equal(t, eventHash, exec.EventHash) require.Equal(t, executorHash, exec.ExecutorHash) require.Equal(t, execution.Status_Completed, exec.Status) require.True(t, inputs.Equal(exec.Inputs)) @@ -174,121 +211,16 @@ func testExecution(t *testing.T) { require.NotEmpty(t, exec.Outputs.Fields["msg"].GetStructValue().Fields["timestamp"].GetNumberValue()) }) t.Run("get", func(t *testing.T) { - exec, err := client.ExecutionClient.Get(context.Background(), &pb.GetExecutionRequest{Hash: executionHash}) - require.NoError(t, err) - require.True(t, exec.Equal(exec)) + var execR *execution.Execution + require.NoError(t, lcd.Get("execution/get/"+executionHash.String(), &execR)) + require.True(t, exec.Equal(execR)) }) }) t.Run("list", func(t *testing.T) { - t.Run("grpc", func(t *testing.T) { - resp, err := client.ExecutionClient.List(context.Background(), &pb.ListExecutionRequest{}) - require.NoError(t, err) - require.Len(t, resp.Executions, 2) - }) - t.Run("lcd", func(t *testing.T) { - execs := make([]*execution.Execution, 0) - lcdGet(t, "execution/list", &execs) - require.Len(t, execs, 2) - }) - }) - - t.Run("execution with price", func(t *testing.T) { - var ( - inputs = &types.Struct{ - Fields: map[string]*types.Value{ - "msg": { - Kind: &types.Value_StringValue{ - StringValue: "test", - }, - }, - }, - } - ) - resp, err := client.ExecutionClient.Create(context.Background(), &pb.CreateExecutionRequest{ - TaskKey: "task1", - EventHash: hash.Int(1), - ExecutorHash: executorHash, - Price: "50000atto", - Inputs: inputs, - }) - require.NoError(t, err) - - var execAddress sdk.AccAddress - t.Run("get execution address", func(t *testing.T) { - var exec *execution.Execution - lcdGet(t, "execution/get/"+resp.Hash.String(), &exec) - require.Equal(t, exec.Hash, resp.Hash) - execAddress = exec.Address - }) - - // check balance of execution before completed - t.Run("execution balance before completed", func(t *testing.T) { - coins := sdk.Coins{} - lcdGet(t, "bank/balances/"+execAddress.String(), &coins) - require.True(t, coins.AmountOf("atto").Equal(sdk.NewInt(50000)), coins) - }) - - expectedCoinsForExecutor := sdk.NewInt(40000) - expectedCoinsForService := sdk.NewInt(5000) - expectedCoinsForEmitter := sdk.NewInt(5000) - - var executorBalance sdk.Coins - var serviceBalance sdk.Coins - lcdGet(t, "bank/balances/"+executorAddress.String(), &executorBalance) - lcdGet(t, "bank/balances/"+testServiceAddress.String(), &serviceBalance) - - _, err = streamInProgress.Recv() - require.NoError(t, err) - - exec, err := streamCompleted.Recv() - require.NoError(t, err) - require.Equal(t, resp.Hash, exec.Hash) - - // check balance of executor - t.Run("executor + emitter balance", func(t *testing.T) { - coins := sdk.Coins{} - lcdGet(t, "bank/balances/"+executorAddress.String(), &coins) - require.True(t, coins.AmountOf("atto").Equal(expectedCoinsForExecutor.Add(expectedCoinsForEmitter).Add(executorBalance.AmountOf("atto"))), coins) - }) - // check balance of service - t.Run("service balance", func(t *testing.T) { - coins := sdk.Coins{} - lcdGet(t, "bank/balances/"+testServiceAddress.String(), &coins) - require.True(t, coins.AmountOf("atto").Equal(expectedCoinsForService.Add(serviceBalance.AmountOf("atto"))), coins) - }) - // check balance of execution - t.Run("execution balance", func(t *testing.T) { - coins := sdk.Coins{} - lcdGet(t, "bank/balances/"+execAddress.String(), &coins) - require.True(t, coins.AmountOf("atto").Equal(sdk.NewInt(0)), coins) - }) - - t.Run("withdraw from service", func(t *testing.T) { - acc, err := cclient.GetAccount() - require.NoError(t, err) - coins := sdk.NewCoins(sdk.NewCoin("atto", expectedCoinsForService)) - msg := ownership.NewMsgWithdrawCoins(testServiceHash, coins, acc.GetAddress()) - _, err = cclient.BuildAndBroadcastMsg(msg) - require.NoError(t, err) - - param := bank.NewQueryBalanceParams(testServiceAddress) - require.NoError(t, cclient.QueryJSON("custom/bank/balances", param, &coins)) - require.True(t, coins.AmountOf("atto").Equal(serviceBalance.AmountOf("atto")), coins) - }) - - t.Run("withdraw from runner", func(t *testing.T) { - acc, err := cclient.GetAccount() - require.NoError(t, err) - coins := sdk.NewCoins(sdk.NewCoin("atto", expectedCoinsForExecutor.Add(expectedCoinsForEmitter))) - msg := ownership.NewMsgWithdrawCoins(testRunnerHash, coins, acc.GetAddress()) - _, err = cclient.BuildAndBroadcastMsg(msg) - require.NoError(t, err) - - param := bank.NewQueryBalanceParams(testRunnerAddress) - require.NoError(t, cclient.QueryJSON("custom/bank/balances", param, &coins)) - require.True(t, coins.AmountOf("atto").Equal(executorBalance.AmountOf("atto")), coins) - }) + execs := make([]*execution.Execution, 0) + require.NoError(t, lcd.Get("execution/list", &execs)) + require.Len(t, execs, 2) }) t.Run("many executions in parallel", func(t *testing.T) { @@ -296,6 +228,7 @@ func testExecution(t *testing.T) { n = 10 executions = make([]hash.Hash, 0) taskKey = "task1" + price = "10000atto" inputs = &types.Struct{ Fields: map[string]*types.Value{ "msg": { @@ -310,17 +243,16 @@ func testExecution(t *testing.T) { wg := sync.WaitGroup{} var mutex sync.Mutex wg.Add(n) - for i := 1; i <= n; i++ { + for i := 0; i < n; i++ { go func() { defer wg.Done() - hash, err := hash.Random() - require.Nil(t, err) - resp, err := client.ExecutionClient.Create(context.Background(), &pb.CreateExecutionRequest{ + req := orchestrator.ExecutionCreateRequest{ TaskKey: taskKey, - EventHash: hash, ExecutorHash: executorHash, Inputs: inputs, - }) + Price: price, + } + resp, err := client.ExecutionClient.Create(context.Background(), &req, grpc.PerRPCCredentials(&signCred{req})) require.NoError(t, err) mutex.Lock() defer mutex.Unlock() @@ -333,24 +265,42 @@ func testExecution(t *testing.T) { }) t.Run("check in progress", func(t *testing.T) { execs := make([]hash.Hash, 0) - for i := 1; i <= n; i++ { - exec, err := streamInProgress.Recv() - require.NoError(t, err) - require.Contains(t, executions, exec.Hash) - require.NotContains(t, execs, exec.Hash) - execs = append(execs, exec.Hash) + wg := sync.WaitGroup{} + var mutex sync.Mutex + wg.Add(n) + for i := 0; i < n; i++ { + go func(i int) { + defer wg.Done() + exec, err := pollExecution(executions[i], execution.Status_InProgress) + require.NoError(t, err) + mutex.Lock() + defer mutex.Unlock() + require.Contains(t, executions, exec.Hash) + require.NotContains(t, execs, exec.Hash) + execs = append(execs, exec.Hash) + }(i) } + wg.Wait() require.Len(t, execs, n) }) t.Run("check completed", func(t *testing.T) { execs := make([]hash.Hash, 0) - for i := 1; i <= n; i++ { - exec, err := streamCompleted.Recv() - require.NoError(t, err) - require.Contains(t, executions, exec.Hash) - require.NotContains(t, execs, exec.Hash) - execs = append(execs, exec.Hash) + wg := sync.WaitGroup{} + var mutex sync.Mutex + wg.Add(n) + for i := 0; i < n; i++ { + go func(i int) { + defer wg.Done() + exec, err := pollExecution(executions[i], execution.Status_Completed) + require.NoError(t, err) + mutex.Lock() + defer mutex.Unlock() + require.Contains(t, executions, exec.Hash) + require.NotContains(t, execs, exec.Hash) + execs = append(execs, exec.Hash) + }(i) } + wg.Wait() require.Len(t, execs, n) }) }) diff --git a/e2e/instance_test.go b/e2e/instance_test.go index 3917f5da9..d114f742b 100644 --- a/e2e/instance_test.go +++ b/e2e/instance_test.go @@ -1,12 +1,10 @@ package main import ( - "context" "testing" "github.com/mesg-foundation/engine/hash" "github.com/mesg-foundation/engine/instance" - pb "github.com/mesg-foundation/engine/protobuf/api" "github.com/stretchr/testify/require" ) @@ -14,54 +12,16 @@ var testInstanceHash hash.Hash func testInstance(t *testing.T) { t.Run("get", func(t *testing.T) { - t.Run("grpc", func(t *testing.T) { - resp, err := client.InstanceClient.Get(context.Background(), &pb.GetInstanceRequest{Hash: testInstanceHash}) - require.NoError(t, err) - require.Equal(t, testInstanceHash, resp.Hash) - require.Equal(t, testServiceHash, resp.ServiceHash) - require.Equal(t, hash.Dump([]string{"BAR=3", "FOO=1", "REQUIRED=4"}), resp.EnvHash) - }) - t.Run("lcd", func(t *testing.T) { - var inst *instance.Instance - lcdGet(t, "instance/get/"+testInstanceHash.String(), &inst) - require.Equal(t, testInstanceHash, inst.Hash) - require.Equal(t, testServiceHash, inst.ServiceHash) - require.Equal(t, hash.Dump([]string{"BAR=3", "FOO=1", "REQUIRED=4"}), inst.EnvHash) - }) + var inst *instance.Instance + require.NoError(t, lcd.Get("instance/get/"+testInstanceHash.String(), &inst)) + require.Equal(t, testInstanceHash, inst.Hash) + require.Equal(t, testServiceHash, inst.ServiceHash) + require.Equal(t, hash.Dump([]string{"BAR=3", "FOO=1", "REQUIRED=4"}), inst.EnvHash) }) t.Run("list", func(t *testing.T) { - t.Run("with nil filter", func(t *testing.T) { - t.Run("grpc", func(t *testing.T) { - resp, err := client.InstanceClient.List(context.Background(), &pb.ListInstanceRequest{}) - require.NoError(t, err) - require.Len(t, resp.Instances, 1) - }) - t.Run("lcd", func(t *testing.T) { - insts := make([]*instance.Instance, 0) - lcdGet(t, "instance/list", &insts) - require.Len(t, insts, 1) - }) - }) - t.Run("do not match service", func(t *testing.T) { - resp, err := client.InstanceClient.List(context.Background(), &pb.ListInstanceRequest{ - Filter: &pb.ListInstanceRequest_Filter{ - ServiceHash: hash.Int(1), - }, - }) - require.NoError(t, err) - require.Len(t, resp.Instances, 0) - }) - t.Run("match service", func(t *testing.T) { - resp, err := client.InstanceClient.List(context.Background(), &pb.ListInstanceRequest{ - Filter: &pb.ListInstanceRequest_Filter{ - ServiceHash: testServiceHash, - }, - }) - require.NoError(t, err) - require.Len(t, resp.Instances, 1) - require.Equal(t, testServiceHash, resp.Instances[0].ServiceHash) - require.Equal(t, testInstanceHash, resp.Instances[0].Hash) - }) + insts := make([]*instance.Instance, 0) + require.NoError(t, lcd.Get("instance/list", &insts)) + require.Len(t, insts, 1) }) } diff --git a/e2e/orchestrator_balance_withdraw_test.go b/e2e/orchestrator_balance_withdraw_test.go index e134918ec..9278ece38 100644 --- a/e2e/orchestrator_balance_withdraw_test.go +++ b/e2e/orchestrator_balance_withdraw_test.go @@ -6,32 +6,36 @@ import ( "time" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/bank" "github.com/mesg-foundation/engine/execution" "github.com/mesg-foundation/engine/hash" "github.com/mesg-foundation/engine/process" - pb "github.com/mesg-foundation/engine/protobuf/api" "github.com/mesg-foundation/engine/protobuf/types" + "github.com/mesg-foundation/engine/server/grpc/orchestrator" + "github.com/mesg-foundation/engine/x/ownership" + processmodule "github.com/mesg-foundation/engine/x/process" "github.com/stretchr/testify/require" + "google.golang.org/grpc" ) -func testOrchestratorProcessBalanceWithdraw(executionStream pb.Execution_StreamClient, instanceHash hash.Hash) func(t *testing.T) { +func testOrchestratorProcessBalanceWithdraw(runnerHash, instanceHash hash.Hash) func(t *testing.T) { return func(t *testing.T) { var ( processHash hash.Hash procAddress sdk.AccAddress + err error ) t.Run("create process", func(t *testing.T) { - respProc, err := client.ProcessClient.Create(context.Background(), &pb.CreateProcessRequest{ - Name: "event-task-process", + msg := processmodule.MsgCreate{ + Owner: cliAddress, + Name: "balance-withdraw-process", Nodes: []*process.Process_Node{ { Key: "n0", Type: &process.Process_Node_Event_{ Event: &process.Process_Node_Event{ InstanceHash: instanceHash, - EventKey: "test_event", + EventKey: "event_trigger", }, }, }, @@ -48,27 +52,27 @@ func testOrchestratorProcessBalanceWithdraw(executionStream pb.Execution_StreamC Edges: []*process.Process_Edge{ {Src: "n0", Dst: "n1"}, }, - }) + } + processHash, err = lcd.BroadcastMsg(msg) require.NoError(t, err) - processHash = respProc.Hash }) t.Run("get process address", func(t *testing.T) { var proc *process.Process - lcdGet(t, "process/get/"+processHash.String(), &proc) + require.NoError(t, lcd.Get("process/get/"+processHash.String(), &proc)) require.Equal(t, proc.Hash, processHash) procAddress = proc.Address }) t.Run("check coins on process", func(t *testing.T) { var coins sdk.Coins - param := bank.NewQueryBalanceParams(procAddress) - require.NoError(t, cclient.QueryJSON("custom/bank/balances", param, &coins)) + require.NoError(t, lcd.Get("bank/balances/"+procAddress.String(), &coins)) require.True(t, coins.IsEqual(processInitialBalance), coins) }) t.Run("trigger process", func(t *testing.T) { - _, err := client.EventClient.Create(context.Background(), &pb.CreateEventRequest{ - InstanceHash: instanceHash, - Key: "test_event", - Data: &types.Struct{ + req := orchestrator.ExecutionCreateRequest{ + Price: "10000atto", + TaskKey: "task_trigger", + ExecutorHash: runnerHash, + Inputs: &types.Struct{ Fields: map[string]*types.Value{ "msg": { Kind: &types.Value_StringValue{ @@ -82,35 +86,57 @@ func testOrchestratorProcessBalanceWithdraw(executionStream pb.Execution_StreamC }, }, }, - }) + } + _, err := client.ExecutionClient.Create(context.Background(), &req, grpc.PerRPCCredentials(&signCred{req})) require.NoError(t, err) }) t.Run("check in progress execution", func(t *testing.T) { - exec, err := executionStream.Recv() + exec, err := pollExecutionOfProcess(processHash, execution.Status_InProgress, "n1") require.NoError(t, err) require.True(t, processHash.Equal(exec.ProcessHash)) require.Equal(t, execution.Status_InProgress, exec.Status) + require.Equal(t, "task1", exec.TaskKey) + require.Equal(t, "n1", exec.NodeKey) + require.Equal(t, "foo_1", exec.Inputs.Fields["msg"].GetStringValue()) }) t.Run("check completed execution", func(t *testing.T) { - exec, err := executionStream.Recv() + exec, err := pollExecutionOfProcess(processHash, execution.Status_Completed, "n1") require.NoError(t, err) require.True(t, processHash.Equal(exec.ProcessHash)) require.Equal(t, execution.Status_Completed, exec.Status) + require.Equal(t, "task1", exec.TaskKey) + require.Equal(t, "n1", exec.NodeKey) + require.Equal(t, "foo_1", exec.Outputs.Fields["msg"].GetStringValue()) + require.NotEmpty(t, exec.Outputs.Fields["timestamp"].GetNumberValue()) }) t.Run("check coins on process after 1 execution", func(t *testing.T) { var coins sdk.Coins - param := bank.NewQueryBalanceParams(procAddress) - require.NoError(t, cclient.QueryJSON("custom/bank/balances", param, &coins)) + require.NoError(t, lcd.Get("bank/balances/"+procAddress.String(), &coins)) require.True(t, coins.IsEqual(processInitialBalance.Sub(minExecutionPrice)), coins) }) + t.Run("withdraw from process", func(t *testing.T) { + coins := minExecutionPrice + msg := ownership.MsgWithdraw{ + Owner: cliAddress, + Amount: coins.String(), + ResourceHash: processHash, + } + _, err := lcd.BroadcastMsg(msg) + require.NoError(t, err) + + require.NoError(t, lcd.Get("bank/balances/"+procAddress.String(), &coins)) + require.True(t, coins.IsEqual(processInitialBalance.Sub(minExecutionPrice).Sub(minExecutionPrice)), coins) + }) t.Run("delete process", func(t *testing.T) { - _, err := client.ProcessClient.Delete(context.Background(), &pb.DeleteProcessRequest{Hash: processHash}) + _, err := lcd.BroadcastMsg(processmodule.MsgDelete{ + Owner: cliAddress, + Hash: processHash, + }) require.NoError(t, err) }) t.Run("check coins on process after deletion", func(t *testing.T) { var coins sdk.Coins - param := bank.NewQueryBalanceParams(procAddress) - require.NoError(t, cclient.QueryJSON("custom/bank/balances", param, &coins)) + require.NoError(t, lcd.Get("bank/balances/"+procAddress.String(), &coins)) require.True(t, coins.IsZero(), coins) }) } diff --git a/e2e/orchestrator_event_task_test.go b/e2e/orchestrator_event_task_test.go index 2b5246004..4f2d4b4e9 100644 --- a/e2e/orchestrator_event_task_test.go +++ b/e2e/orchestrator_event_task_test.go @@ -8,25 +8,31 @@ import ( "github.com/mesg-foundation/engine/execution" "github.com/mesg-foundation/engine/hash" "github.com/mesg-foundation/engine/process" - pb "github.com/mesg-foundation/engine/protobuf/api" "github.com/mesg-foundation/engine/protobuf/types" + "github.com/mesg-foundation/engine/server/grpc/orchestrator" + processmodule "github.com/mesg-foundation/engine/x/process" "github.com/stretchr/testify/require" + "google.golang.org/grpc" ) -func testOrchestratorEventTask(executionStream pb.Execution_StreamClient, instanceHash hash.Hash) func(t *testing.T) { +func testOrchestratorEventTask(runnerHash hash.Hash, instanceHash hash.Hash) func(t *testing.T) { return func(t *testing.T) { - var processHash hash.Hash + var ( + processHash hash.Hash + err error + ) t.Run("create process", func(t *testing.T) { - respProc, err := client.ProcessClient.Create(context.Background(), &pb.CreateProcessRequest{ - Name: "event-task-process", + msg := processmodule.MsgCreate{ + Owner: cliAddress, + Name: "event-task-process", Nodes: []*process.Process_Node{ { Key: "n0", Type: &process.Process_Node_Event_{ Event: &process.Process_Node_Event{ InstanceHash: instanceHash, - EventKey: "test_event", + EventKey: "event_trigger", }, }, }, @@ -43,15 +49,16 @@ func testOrchestratorEventTask(executionStream pb.Execution_StreamClient, instan Edges: []*process.Process_Edge{ {Src: "n0", Dst: "n1"}, }, - }) + } + processHash, err = lcd.BroadcastMsg(msg) require.NoError(t, err) - processHash = respProc.Hash }) t.Run("trigger process", func(t *testing.T) { - _, err := client.EventClient.Create(context.Background(), &pb.CreateEventRequest{ - InstanceHash: instanceHash, - Key: "test_event", - Data: &types.Struct{ + req := orchestrator.ExecutionCreateRequest{ + Price: "10000atto", + TaskKey: "task_trigger", + ExecutorHash: runnerHash, + Inputs: &types.Struct{ Fields: map[string]*types.Value{ "msg": { Kind: &types.Value_StringValue{ @@ -65,11 +72,12 @@ func testOrchestratorEventTask(executionStream pb.Execution_StreamClient, instan }, }, }, - }) + } + _, err := client.ExecutionClient.Create(context.Background(), &req, grpc.PerRPCCredentials(&signCred{req})) require.NoError(t, err) }) t.Run("check in progress execution", func(t *testing.T) { - exec, err := executionStream.Recv() + exec, err := pollExecutionOfProcess(processHash, execution.Status_InProgress, "n1") require.NoError(t, err) require.Equal(t, "task1", exec.TaskKey) require.Equal(t, "n1", exec.NodeKey) @@ -78,7 +86,7 @@ func testOrchestratorEventTask(executionStream pb.Execution_StreamClient, instan require.Equal(t, "foo_1", exec.Inputs.Fields["msg"].GetStringValue()) }) t.Run("check completed execution", func(t *testing.T) { - exec, err := executionStream.Recv() + exec, err := pollExecutionOfProcess(processHash, execution.Status_Completed, "n1") require.NoError(t, err) require.Equal(t, "task1", exec.TaskKey) require.Equal(t, "n1", exec.NodeKey) @@ -88,7 +96,10 @@ func testOrchestratorEventTask(executionStream pb.Execution_StreamClient, instan require.NotEmpty(t, exec.Outputs.Fields["timestamp"].GetNumberValue()) }) t.Run("delete process", func(t *testing.T) { - _, err := client.ProcessClient.Delete(context.Background(), &pb.DeleteProcessRequest{Hash: processHash}) + _, err := lcd.BroadcastMsg(processmodule.MsgDelete{ + Owner: cliAddress, + Hash: processHash, + }) require.NoError(t, err) }) } diff --git a/e2e/orchestrator_filter_path_nested_test.go b/e2e/orchestrator_filter_path_nested_test.go new file mode 100644 index 000000000..befe3b35b --- /dev/null +++ b/e2e/orchestrator_filter_path_nested_test.go @@ -0,0 +1,276 @@ +package main + +import ( + "context" + "fmt" + "testing" + "time" + + "github.com/mesg-foundation/engine/execution" + "github.com/mesg-foundation/engine/hash" + "github.com/mesg-foundation/engine/process" + "github.com/mesg-foundation/engine/protobuf/types" + "github.com/mesg-foundation/engine/server/grpc/orchestrator" + processmodule "github.com/mesg-foundation/engine/x/process" + "github.com/stretchr/testify/require" + "google.golang.org/grpc" +) + +func testOrchestratorFilterPathNested(runnerHash, instanceHash hash.Hash) func(t *testing.T) { + return func(t *testing.T) { + var ( + processHash hash.Hash + err error + ) + + t.Run("create process", func(t *testing.T) { + msg := processmodule.MsgCreate{ + Owner: cliAddress, + Name: "filter", + Nodes: []*process.Process_Node{ + { + Key: "n0", + Type: &process.Process_Node_Event_{ + Event: &process.Process_Node_Event{ + InstanceHash: instanceHash, + EventKey: "event_complex_trigger", + }, + }, + }, + { + Key: "n1", + Type: &process.Process_Node_Filter_{ + Filter: &process.Process_Node_Filter{ + Conditions: []process.Process_Node_Filter_Condition{ + { + Ref: &process.Process_Node_Reference{ + NodeKey: "n0", + Path: &process.Process_Node_Reference_Path{ + Selector: &process.Process_Node_Reference_Path_Key{ + Key: "msg", + }, + Path: &process.Process_Node_Reference_Path{ + Selector: &process.Process_Node_Reference_Path_Key{ + Key: "msg", + }, + }, + }, + }, + Predicate: process.Process_Node_Filter_Condition_EQ, + Value: &types.Value{ + Kind: &types.Value_StringValue{ + StringValue: "shouldMatch", + }, + }, + }, + { + Ref: &process.Process_Node_Reference{ + NodeKey: "n0", + Path: &process.Process_Node_Reference_Path{ + Selector: &process.Process_Node_Reference_Path_Key{ + Key: "msg", + }, + Path: &process.Process_Node_Reference_Path{ + Selector: &process.Process_Node_Reference_Path_Key{ + Key: "timestamp", + }, + }, + }, + }, + Predicate: process.Process_Node_Filter_Condition_GT, + Value: &types.Value{ + Kind: &types.Value_NumberValue{ + NumberValue: 10, + }, + }, + }, + { + Ref: &process.Process_Node_Reference{ + NodeKey: "n0", + Path: &process.Process_Node_Reference_Path{ + Selector: &process.Process_Node_Reference_Path_Key{ + Key: "msg", + }, + Path: &process.Process_Node_Reference_Path{ + Selector: &process.Process_Node_Reference_Path_Key{ + Key: "array", + }, + }, + }, + }, + Predicate: process.Process_Node_Filter_Condition_EQ, + Value: &types.Value{ + Kind: &types.Value_ListValue{ + ListValue: &types.ListValue{ + Values: []*types.Value{ + { + Kind: &types.Value_StringValue{ + StringValue: "one", + }, + }, + { + Kind: &types.Value_StringValue{ + StringValue: "two", + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + { + Key: "n2", + Type: &process.Process_Node_Task_{ + Task: &process.Process_Node_Task{ + InstanceHash: instanceHash, + TaskKey: "task_complex", + }, + }, + }, + }, + Edges: []*process.Process_Edge{ + {Src: "n0", Dst: "n1"}, + {Src: "n1", Dst: "n2"}, + }, + } + processHash, err = lcd.BroadcastMsg(msg) + require.NoError(t, err) + }) + t.Run("pass filter", func(t *testing.T) { + t.Run("trigger process", func(t *testing.T) { + req := orchestrator.ExecutionCreateRequest{ + Price: "10000atto", + TaskKey: "task_complex_trigger", + ExecutorHash: runnerHash, + Inputs: &types.Struct{ + Fields: map[string]*types.Value{ + "msg": { + Kind: &types.Value_StructValue{ + StructValue: &types.Struct{ + Fields: map[string]*types.Value{ + "msg": { + Kind: &types.Value_StringValue{ + StringValue: "shouldMatch", + }, + }, + "timestamp": { + Kind: &types.Value_NumberValue{ + NumberValue: float64(time.Now().Unix()), + }, + }, + "array": { + Kind: &types.Value_ListValue{ + ListValue: &types.ListValue{ + Values: []*types.Value{ + { + Kind: &types.Value_StringValue{ + StringValue: "one", + }, + }, + { + Kind: &types.Value_StringValue{ + StringValue: "two", + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + } + _, err := client.ExecutionClient.Create(context.Background(), &req, grpc.PerRPCCredentials(&signCred{req})) + require.NoError(t, err) + }) + t.Run("check in progress execution", func(t *testing.T) { + exec, err := pollExecutionOfProcess(processHash, execution.Status_InProgress, "n2") + require.NoError(t, err) + require.Equal(t, "task_complex", exec.TaskKey) + require.Equal(t, "n2", exec.NodeKey) + require.True(t, processHash.Equal(exec.ProcessHash)) + require.Equal(t, execution.Status_InProgress, exec.Status) + require.Equal(t, "shouldMatch", exec.Inputs.Fields["msg"].GetStructValue().Fields["msg"].GetStringValue()) + }) + t.Run("check completed execution", func(t *testing.T) { + exec, err := pollExecutionOfProcess(processHash, execution.Status_Completed, "n2") + require.NoError(t, err) + require.Equal(t, "task_complex", exec.TaskKey) + require.Equal(t, "n2", exec.NodeKey) + require.True(t, processHash.Equal(exec.ProcessHash)) + require.Equal(t, execution.Status_Completed, exec.Status) + require.Equal(t, "shouldMatch", exec.Outputs.Fields["msg"].GetStructValue().Fields["msg"].GetStringValue()) + require.NotEmpty(t, exec.Outputs.Fields["msg"].GetStructValue().Fields["timestamp"].GetNumberValue()) + }) + }) + t.Run("stop at filter", func(t *testing.T) { + t.Run("trigger process", func(t *testing.T) { + req := orchestrator.ExecutionCreateRequest{ + Price: "10000atto", + TaskKey: "task_complex_trigger", + ExecutorHash: runnerHash, + Inputs: &types.Struct{ + Fields: map[string]*types.Value{ + "msg": { + Kind: &types.Value_StructValue{ + StructValue: &types.Struct{ + Fields: map[string]*types.Value{ + "msg": { + Kind: &types.Value_StringValue{ + StringValue: "shouldNotMatch", + }, + }, + "timestamp": { + Kind: &types.Value_NumberValue{ + NumberValue: float64(time.Now().Unix()), + }, + }, + "array": { + Kind: &types.Value_ListValue{ + ListValue: &types.ListValue{ + Values: []*types.Value{ + { + Kind: &types.Value_StringValue{ + StringValue: "one", + }, + }, + { + Kind: &types.Value_StringValue{ + StringValue: "two", + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + } + _, err := client.ExecutionClient.Create(context.Background(), &req, grpc.PerRPCCredentials(&signCred{req})) + require.NoError(t, err) + }) + t.Run("wait timeout to check execution is not created", func(t *testing.T) { + _, err := pollExecutionOfProcess(processHash, execution.Status_InProgress, "n2") + require.EqualError(t, err, fmt.Sprintf("pollExecutionOfProcess timeout with process hash %q and status %q and nodeKey %q", processHash, execution.Status_InProgress, "n2")) + }) + }) + t.Run("delete process", func(t *testing.T) { + _, err := lcd.BroadcastMsg(processmodule.MsgDelete{ + Owner: cliAddress, + Hash: processHash, + }) + require.NoError(t, err) + }) + } +} diff --git a/e2e/orchestrator_filter_test.go b/e2e/orchestrator_filter_test.go index f89b2dc07..1c61a7253 100644 --- a/e2e/orchestrator_filter_test.go +++ b/e2e/orchestrator_filter_test.go @@ -9,25 +9,31 @@ import ( "github.com/mesg-foundation/engine/execution" "github.com/mesg-foundation/engine/hash" "github.com/mesg-foundation/engine/process" - pb "github.com/mesg-foundation/engine/protobuf/api" "github.com/mesg-foundation/engine/protobuf/types" + "github.com/mesg-foundation/engine/server/grpc/orchestrator" + processmodule "github.com/mesg-foundation/engine/x/process" "github.com/stretchr/testify/require" + "google.golang.org/grpc" ) -func testOrchestratorFilter(executionStream pb.Execution_StreamClient, instanceHash hash.Hash) func(t *testing.T) { +func testOrchestratorFilter(runnerHash, instanceHash hash.Hash) func(t *testing.T) { return func(t *testing.T) { - var processHash hash.Hash + var ( + processHash hash.Hash + err error + ) t.Run("create process", func(t *testing.T) { - respProc, err := client.ProcessClient.Create(context.Background(), &pb.CreateProcessRequest{ - Name: "filter", + msg := processmodule.MsgCreate{ + Owner: cliAddress, + Name: "filter", Nodes: []*process.Process_Node{ { Key: "n0", Type: &process.Process_Node_Event_{ Event: &process.Process_Node_Event{ InstanceHash: instanceHash, - EventKey: "test_event", + EventKey: "event_trigger", }, }, }, @@ -37,9 +43,36 @@ func testOrchestratorFilter(executionStream pb.Execution_StreamClient, instanceH Filter: &process.Process_Node_Filter{ Conditions: []process.Process_Node_Filter_Condition{ { - Key: "msg", + Ref: &process.Process_Node_Reference{ + NodeKey: "n0", + Path: &process.Process_Node_Reference_Path{ + Selector: &process.Process_Node_Reference_Path_Key{ + Key: "msg", + }, + }, + }, Predicate: process.Process_Node_Filter_Condition_EQ, - Value: "shouldMatch", + Value: &types.Value{ + Kind: &types.Value_StringValue{ + StringValue: "shouldMatch", + }, + }, + }, + { + Ref: &process.Process_Node_Reference{ + NodeKey: "n0", + Path: &process.Process_Node_Reference_Path{ + Selector: &process.Process_Node_Reference_Path_Key{ + Key: "timestamp", + }, + }, + }, + Predicate: process.Process_Node_Filter_Condition_GT, + Value: &types.Value{ + Kind: &types.Value_NumberValue{ + NumberValue: 10, + }, + }, }, }, }, @@ -59,16 +92,17 @@ func testOrchestratorFilter(executionStream pb.Execution_StreamClient, instanceH {Src: "n0", Dst: "n1"}, {Src: "n1", Dst: "n2"}, }, - }) + } + processHash, err = lcd.BroadcastMsg(msg) require.NoError(t, err) - processHash = respProc.Hash }) t.Run("pass filter", func(t *testing.T) { t.Run("trigger process", func(t *testing.T) { - _, err := client.EventClient.Create(context.Background(), &pb.CreateEventRequest{ - InstanceHash: instanceHash, - Key: "test_event", - Data: &types.Struct{ + req := orchestrator.ExecutionCreateRequest{ + Price: "10000atto", + TaskKey: "task_trigger", + ExecutorHash: runnerHash, + Inputs: &types.Struct{ Fields: map[string]*types.Value{ "msg": { Kind: &types.Value_StringValue{ @@ -82,11 +116,12 @@ func testOrchestratorFilter(executionStream pb.Execution_StreamClient, instanceH }, }, }, - }) + } + _, err := client.ExecutionClient.Create(context.Background(), &req, grpc.PerRPCCredentials(&signCred{req})) require.NoError(t, err) }) t.Run("check in progress execution", func(t *testing.T) { - exec, err := executionStream.Recv() + exec, err := pollExecutionOfProcess(processHash, execution.Status_InProgress, "n2") require.NoError(t, err) require.Equal(t, "task1", exec.TaskKey) require.Equal(t, "n2", exec.NodeKey) @@ -95,7 +130,7 @@ func testOrchestratorFilter(executionStream pb.Execution_StreamClient, instanceH require.Equal(t, "shouldMatch", exec.Inputs.Fields["msg"].GetStringValue()) }) t.Run("check completed execution", func(t *testing.T) { - exec, err := executionStream.Recv() + exec, err := pollExecutionOfProcess(processHash, execution.Status_Completed, "n2") require.NoError(t, err) require.Equal(t, "task1", exec.TaskKey) require.Equal(t, "n2", exec.NodeKey) @@ -107,14 +142,15 @@ func testOrchestratorFilter(executionStream pb.Execution_StreamClient, instanceH }) t.Run("stop at filter", func(t *testing.T) { t.Run("trigger process", func(t *testing.T) { - _, err := client.EventClient.Create(context.Background(), &pb.CreateEventRequest{ - InstanceHash: instanceHash, - Key: "test_event", - Data: &types.Struct{ + req := orchestrator.ExecutionCreateRequest{ + Price: "10000atto", + TaskKey: "task_trigger", + ExecutorHash: runnerHash, + Inputs: &types.Struct{ Fields: map[string]*types.Value{ "msg": { Kind: &types.Value_StringValue{ - StringValue: "shouldNOTMatch", + StringValue: "shouldNotMatch", }, }, "timestamp": { @@ -124,28 +160,20 @@ func testOrchestratorFilter(executionStream pb.Execution_StreamClient, instanceH }, }, }, - }) + } + _, err := client.ExecutionClient.Create(context.Background(), &req, grpc.PerRPCCredentials(&signCred{req})) require.NoError(t, err) }) - t.Run("wait 2 sec to check execution is not created", func(t *testing.T) { - recvC := make(chan error) - go func() { - // FIXME: this go routine is never garbage and the Recv may cause side effect if the stream is use later - exec, err := executionStream.Recv() - fmt.Println("received execution but should not", exec) - recvC <- err - }() - select { - case <-time.After(2 * time.Second): - return - case err := <-recvC: - require.NoError(t, err) - t.Fatal("should not received any execution") - } + t.Run("wait timeout to check execution is not created", func(t *testing.T) { + _, err := pollExecutionOfProcess(processHash, execution.Status_InProgress, "n2") + require.EqualError(t, err, fmt.Sprintf("pollExecutionOfProcess timeout with process hash %q and status %q and nodeKey %q", processHash, execution.Status_InProgress, "n2")) }) }) t.Run("delete process", func(t *testing.T) { - _, err := client.ProcessClient.Delete(context.Background(), &pb.DeleteProcessRequest{Hash: processHash}) + _, err := lcd.BroadcastMsg(processmodule.MsgDelete{ + Owner: cliAddress, + Hash: processHash, + }) require.NoError(t, err) }) } diff --git a/e2e/orchestrator_map_const_test.go b/e2e/orchestrator_map_const_test.go index cf9c73ebc..0f6b432e0 100644 --- a/e2e/orchestrator_map_const_test.go +++ b/e2e/orchestrator_map_const_test.go @@ -8,25 +8,31 @@ import ( "github.com/mesg-foundation/engine/execution" "github.com/mesg-foundation/engine/hash" "github.com/mesg-foundation/engine/process" - pb "github.com/mesg-foundation/engine/protobuf/api" "github.com/mesg-foundation/engine/protobuf/types" + "github.com/mesg-foundation/engine/server/grpc/orchestrator" + processmodule "github.com/mesg-foundation/engine/x/process" "github.com/stretchr/testify/require" + "google.golang.org/grpc" ) -func testOrchestratorMapConst(executionStream pb.Execution_StreamClient, instanceHash hash.Hash) func(t *testing.T) { +func testOrchestratorMapConst(runnerHash, instanceHash hash.Hash) func(t *testing.T) { return func(t *testing.T) { - var processHash hash.Hash + var ( + processHash hash.Hash + err error + ) t.Run("create process", func(t *testing.T) { - respProc, err := client.ProcessClient.Create(context.Background(), &pb.CreateProcessRequest{ - Name: "map-const", + msg := processmodule.MsgCreate{ + Owner: cliAddress, + Name: "map-const", Nodes: []*process.Process_Node{ { Key: "n0", Type: &process.Process_Node_Event_{ Event: &process.Process_Node_Event{ InstanceHash: instanceHash, - EventKey: "test_event", + EventKey: "event_trigger", }, }, }, @@ -58,15 +64,16 @@ func testOrchestratorMapConst(executionStream pb.Execution_StreamClient, instanc {Src: "n0", Dst: "n1"}, {Src: "n1", Dst: "n2"}, }, - }) + } + processHash, err = lcd.BroadcastMsg(msg) require.NoError(t, err) - processHash = respProc.Hash }) t.Run("trigger process", func(t *testing.T) { - _, err := client.EventClient.Create(context.Background(), &pb.CreateEventRequest{ - InstanceHash: instanceHash, - Key: "test_event", - Data: &types.Struct{ + req := orchestrator.ExecutionCreateRequest{ + Price: "10000atto", + TaskKey: "task_trigger", + ExecutorHash: runnerHash, + Inputs: &types.Struct{ Fields: map[string]*types.Value{ "msg": { Kind: &types.Value_StringValue{ @@ -80,11 +87,12 @@ func testOrchestratorMapConst(executionStream pb.Execution_StreamClient, instanc }, }, }, - }) + } + _, err := client.ExecutionClient.Create(context.Background(), &req, grpc.PerRPCCredentials(&signCred{req})) require.NoError(t, err) }) t.Run("check in progress execution", func(t *testing.T) { - exec, err := executionStream.Recv() + exec, err := pollExecutionOfProcess(processHash, execution.Status_InProgress, "n2") require.NoError(t, err) require.Equal(t, "task1", exec.TaskKey) require.Equal(t, "n2", exec.NodeKey) @@ -93,7 +101,7 @@ func testOrchestratorMapConst(executionStream pb.Execution_StreamClient, instanc require.Equal(t, "itsAConstant", exec.Inputs.Fields["msg"].GetStringValue()) }) t.Run("check completed execution", func(t *testing.T) { - exec, err := executionStream.Recv() + exec, err := pollExecutionOfProcess(processHash, execution.Status_Completed, "n2") require.NoError(t, err) require.Equal(t, "task1", exec.TaskKey) require.Equal(t, "n2", exec.NodeKey) @@ -103,7 +111,10 @@ func testOrchestratorMapConst(executionStream pb.Execution_StreamClient, instanc require.NotEmpty(t, exec.Outputs.Fields["timestamp"].GetNumberValue()) }) t.Run("delete process", func(t *testing.T) { - _, err := client.ProcessClient.Delete(context.Background(), &pb.DeleteProcessRequest{Hash: processHash}) + _, err := lcd.BroadcastMsg(processmodule.MsgDelete{ + Owner: cliAddress, + Hash: processHash, + }) require.NoError(t, err) }) } diff --git a/e2e/orchestrator_nested_data_test.go b/e2e/orchestrator_nested_data_test.go index 062a86d6d..365a170b8 100644 --- a/e2e/orchestrator_nested_data_test.go +++ b/e2e/orchestrator_nested_data_test.go @@ -8,25 +8,31 @@ import ( "github.com/mesg-foundation/engine/execution" "github.com/mesg-foundation/engine/hash" "github.com/mesg-foundation/engine/process" - pb "github.com/mesg-foundation/engine/protobuf/api" "github.com/mesg-foundation/engine/protobuf/types" + "github.com/mesg-foundation/engine/server/grpc/orchestrator" + processmodule "github.com/mesg-foundation/engine/x/process" "github.com/stretchr/testify/require" + "google.golang.org/grpc" ) -func testOrchestratorNestedData(executionStream pb.Execution_StreamClient, instanceHash hash.Hash) func(t *testing.T) { +func testOrchestratorNestedData(runnerHash, instanceHash hash.Hash) func(t *testing.T) { return func(t *testing.T) { - var processHash hash.Hash + var ( + processHash hash.Hash + err error + ) t.Run("create process", func(t *testing.T) { - respProc, err := client.ProcessClient.Create(context.Background(), &pb.CreateProcessRequest{ - Name: "nested-data", + msg := processmodule.MsgCreate{ + Owner: cliAddress, + Name: "nested-data", Nodes: []*process.Process_Node{ { Key: "n0", Type: &process.Process_Node_Event_{ Event: &process.Process_Node_Event{ InstanceHash: instanceHash, - EventKey: "test_event_complex", + EventKey: "event_complex_trigger", }, }, }, @@ -43,66 +49,78 @@ func testOrchestratorNestedData(executionStream pb.Execution_StreamClient, insta Edges: []*process.Process_Edge{ {Src: "n0", Dst: "n1"}, }, - }) + } + processHash, err = lcd.BroadcastMsg(msg) require.NoError(t, err) - processHash = respProc.Hash }) - data := &types.Struct{ - Fields: map[string]*types.Value{ - "msg": { - Kind: &types.Value_StructValue{ - StructValue: &types.Struct{ - Fields: map[string]*types.Value{ - "msg": { - Kind: &types.Value_StringValue{ - StringValue: "complex", - }, - }, - "timestamp": { - Kind: &types.Value_NumberValue{ - NumberValue: float64(time.Now().Unix()), - }, - }, - "array": { - Kind: &types.Value_ListValue{ - ListValue: &types.ListValue{Values: []*types.Value{ - {Kind: &types.Value_StringValue{StringValue: "first"}}, - {Kind: &types.Value_StringValue{StringValue: "second"}}, - {Kind: &types.Value_StringValue{StringValue: "third"}}, - }}, + t.Run("trigger process", func(t *testing.T) { + req := orchestrator.ExecutionCreateRequest{ + Price: "10000atto", + TaskKey: "task_complex_trigger", + ExecutorHash: runnerHash, + Inputs: &types.Struct{ + Fields: map[string]*types.Value{ + "msg": { + Kind: &types.Value_StructValue{ + StructValue: &types.Struct{ + Fields: map[string]*types.Value{ + "msg": { + Kind: &types.Value_StringValue{ + StringValue: "complex", + }, + }, + "timestamp": { + Kind: &types.Value_NumberValue{ + NumberValue: float64(time.Now().Unix()), + }, + }, + "array": { + Kind: &types.Value_ListValue{ + ListValue: &types.ListValue{Values: []*types.Value{ + {Kind: &types.Value_StringValue{StringValue: "first"}}, + {Kind: &types.Value_StringValue{StringValue: "second"}}, + {Kind: &types.Value_StringValue{StringValue: "third"}}, + }}, + }, + }, }, }, }, }, }, }, - }, - } - t.Run("trigger process", func(t *testing.T) { - _, err := client.EventClient.Create(context.Background(), &pb.CreateEventRequest{ - InstanceHash: instanceHash, - Key: "test_event_complex", - Data: data, - }) + } + _, err := client.ExecutionClient.Create(context.Background(), &req, grpc.PerRPCCredentials(&signCred{req})) require.NoError(t, err) }) t.Run("check in progress execution", func(t *testing.T) { - exec, err := executionStream.Recv() + exec, err := pollExecutionOfProcess(processHash, execution.Status_InProgress, "n1") require.NoError(t, err) require.Equal(t, "task_complex", exec.TaskKey) require.Equal(t, "n1", exec.NodeKey) require.True(t, processHash.Equal(exec.ProcessHash)) require.Equal(t, execution.Status_InProgress, exec.Status) - require.True(t, data.Equal(exec.Inputs)) + + require.Equal(t, "complex", exec.Inputs.Fields["msg"].GetStructValue().Fields["msg"].GetStringValue()) + require.Len(t, exec.Inputs.Fields["msg"].GetStructValue().Fields["array"].GetListValue().Values, 3) + require.Equal(t, "first", exec.Inputs.Fields["msg"].GetStructValue().Fields["array"].GetListValue().Values[0].GetStringValue()) + require.Equal(t, "second", exec.Inputs.Fields["msg"].GetStructValue().Fields["array"].GetListValue().Values[1].GetStringValue()) + require.Equal(t, "third", exec.Inputs.Fields["msg"].GetStructValue().Fields["array"].GetListValue().Values[2].GetStringValue()) }) t.Run("check completed execution", func(t *testing.T) { - exec, err := executionStream.Recv() + exec, err := pollExecutionOfProcess(processHash, execution.Status_Completed, "n1") require.NoError(t, err) require.Equal(t, "task_complex", exec.TaskKey) require.Equal(t, "n1", exec.NodeKey) require.True(t, processHash.Equal(exec.ProcessHash)) require.Equal(t, execution.Status_Completed, exec.Status) - require.True(t, data.Equal(exec.Inputs)) + + require.Equal(t, "complex", exec.Inputs.Fields["msg"].GetStructValue().Fields["msg"].GetStringValue()) + require.Len(t, exec.Inputs.Fields["msg"].GetStructValue().Fields["array"].GetListValue().Values, 3) + require.Equal(t, "first", exec.Inputs.Fields["msg"].GetStructValue().Fields["array"].GetListValue().Values[0].GetStringValue()) + require.Equal(t, "second", exec.Inputs.Fields["msg"].GetStructValue().Fields["array"].GetListValue().Values[1].GetStringValue()) + require.Equal(t, "third", exec.Inputs.Fields["msg"].GetStructValue().Fields["array"].GetListValue().Values[2].GetStringValue()) + require.Equal(t, "complex", exec.Outputs.Fields["msg"].GetStructValue().Fields["msg"].GetStringValue()) require.Len(t, exec.Outputs.Fields["msg"].GetStructValue().Fields["array"].GetListValue().Values, 3) require.Equal(t, "first", exec.Outputs.Fields["msg"].GetStructValue().Fields["array"].GetListValue().Values[0].GetStringValue()) @@ -111,7 +129,10 @@ func testOrchestratorNestedData(executionStream pb.Execution_StreamClient, insta require.NotEmpty(t, exec.Outputs.Fields["msg"].GetStructValue().Fields["timestamp"].GetNumberValue()) }) t.Run("delete process", func(t *testing.T) { - _, err := client.ProcessClient.Delete(context.Background(), &pb.DeleteProcessRequest{Hash: processHash}) + _, err := lcd.BroadcastMsg(processmodule.MsgDelete{ + Owner: cliAddress, + Hash: processHash, + }) require.NoError(t, err) }) } diff --git a/e2e/orchestrator_nested_map_test.go b/e2e/orchestrator_nested_map_test.go index 34239c3fe..f3582b210 100644 --- a/e2e/orchestrator_nested_map_test.go +++ b/e2e/orchestrator_nested_map_test.go @@ -7,57 +7,30 @@ import ( "github.com/mesg-foundation/engine/execution" "github.com/mesg-foundation/engine/hash" "github.com/mesg-foundation/engine/process" - pb "github.com/mesg-foundation/engine/protobuf/api" "github.com/mesg-foundation/engine/protobuf/types" + "github.com/mesg-foundation/engine/server/grpc/orchestrator" + processmodule "github.com/mesg-foundation/engine/x/process" "github.com/stretchr/testify/require" + "google.golang.org/grpc" ) -func testOrchestratorNestedMap(executionStream pb.Execution_StreamClient, instanceHash hash.Hash) func(t *testing.T) { +func testOrchestratorNestedMap(runnerHash, instanceHash hash.Hash) func(t *testing.T) { return func(t *testing.T) { var ( + err error processHash hash.Hash - dataEvent = &types.Struct{ - Fields: map[string]*types.Value{ - "msg": { - Kind: &types.Value_StructValue{ - StructValue: &types.Struct{ - Fields: map[string]*types.Value{ - "msg": { - Kind: &types.Value_StringValue{ - StringValue: "complex", - }, - }, - "timestamp": { - Kind: &types.Value_NumberValue{ - NumberValue: 101, - }, - }, - "array": { - Kind: &types.Value_ListValue{ - ListValue: &types.ListValue{Values: []*types.Value{ - {Kind: &types.Value_StringValue{StringValue: "first"}}, - {Kind: &types.Value_StringValue{StringValue: "second"}}, - {Kind: &types.Value_StringValue{StringValue: "third"}}, - }}, - }, - }, - }, - }, - }, - }, - }, - } ) t.Run("create process", func(t *testing.T) { - respProc, err := client.ProcessClient.Create(context.Background(), &pb.CreateProcessRequest{ - Name: "nested-map", + msg := processmodule.MsgCreate{ + Owner: cliAddress, + Name: "nested-map", Nodes: []*process.Process_Node{ { Key: "n0", Type: &process.Process_Node_Event_{ Event: &process.Process_Node_Event{ InstanceHash: instanceHash, - EventKey: "test_event_complex", + EventKey: "event_complex_trigger", }, }, }, @@ -101,21 +74,53 @@ func testOrchestratorNestedMap(executionStream pb.Execution_StreamClient, instan {Src: "n0", Dst: "n1"}, {Src: "n1", Dst: "n2"}, }, - }) + } + processHash, err = lcd.BroadcastMsg(msg) require.NoError(t, err) - processHash = respProc.Hash }) t.Run("trigger process", func(t *testing.T) { - _, err := client.EventClient.Create(context.Background(), &pb.CreateEventRequest{ - InstanceHash: instanceHash, - Key: "test_event_complex", - Data: dataEvent, - }) + req := orchestrator.ExecutionCreateRequest{ + Price: "10000atto", + TaskKey: "task_complex_trigger", + ExecutorHash: runnerHash, + Inputs: &types.Struct{ + Fields: map[string]*types.Value{ + "msg": { + Kind: &types.Value_StructValue{ + StructValue: &types.Struct{ + Fields: map[string]*types.Value{ + "msg": { + Kind: &types.Value_StringValue{ + StringValue: "complex", + }, + }, + "timestamp": { + Kind: &types.Value_NumberValue{ + NumberValue: 101, + }, + }, + "array": { + Kind: &types.Value_ListValue{ + ListValue: &types.ListValue{Values: []*types.Value{ + {Kind: &types.Value_StringValue{StringValue: "first"}}, + {Kind: &types.Value_StringValue{StringValue: "second"}}, + {Kind: &types.Value_StringValue{StringValue: "third"}}, + }}, + }, + }, + }, + }, + }, + }, + }, + }, + } + _, err := client.ExecutionClient.Create(context.Background(), &req, grpc.PerRPCCredentials(&signCred{req})) require.NoError(t, err) }) t.Run("first task", func(t *testing.T) { t.Run("check in progress execution", func(t *testing.T) { - exec, err := executionStream.Recv() + exec, err := pollExecutionOfProcess(processHash, execution.Status_InProgress, "n2") require.NoError(t, err) require.Equal(t, "task_complex", exec.TaskKey) require.Equal(t, "n2", exec.NodeKey) @@ -129,7 +134,7 @@ func testOrchestratorNestedMap(executionStream pb.Execution_StreamClient, instan require.Equal(t, "fourth-constant", exec.Inputs.Fields["msg"].GetStructValue().Fields["array"].GetListValue().Values[3].GetStringValue()) }) t.Run("check completed execution", func(t *testing.T) { - exec, err := executionStream.Recv() + exec, err := pollExecutionOfProcess(processHash, execution.Status_Completed, "n2") require.NoError(t, err) require.Equal(t, "task_complex", exec.TaskKey) require.Equal(t, "n2", exec.NodeKey) @@ -145,7 +150,10 @@ func testOrchestratorNestedMap(executionStream pb.Execution_StreamClient, instan }) }) t.Run("delete process", func(t *testing.T) { - _, err := client.ProcessClient.Delete(context.Background(), &pb.DeleteProcessRequest{Hash: processHash}) + _, err := lcd.BroadcastMsg(processmodule.MsgDelete{ + Owner: cliAddress, + Hash: processHash, + }) require.NoError(t, err) }) } diff --git a/e2e/orchestrator_ref_grand_parent_task_test.go b/e2e/orchestrator_ref_grand_parent_task_test.go index 861f0af05..4d79b25ee 100644 --- a/e2e/orchestrator_ref_grand_parent_task_test.go +++ b/e2e/orchestrator_ref_grand_parent_task_test.go @@ -8,24 +8,30 @@ import ( "github.com/mesg-foundation/engine/execution" "github.com/mesg-foundation/engine/hash" "github.com/mesg-foundation/engine/process" - pb "github.com/mesg-foundation/engine/protobuf/api" "github.com/mesg-foundation/engine/protobuf/types" + "github.com/mesg-foundation/engine/server/grpc/orchestrator" + processmodule "github.com/mesg-foundation/engine/x/process" "github.com/stretchr/testify/require" + "google.golang.org/grpc" ) -func testOrchestratorRefGrandParentTask(executionStream pb.Execution_StreamClient, instanceHash hash.Hash) func(t *testing.T) { +func testOrchestratorRefGrandParentTask(runnerHash, instanceHash hash.Hash) func(t *testing.T) { return func(t *testing.T) { - var processHash hash.Hash + var ( + processHash hash.Hash + err error + ) t.Run("create process", func(t *testing.T) { - respProc, err := client.ProcessClient.Create(context.Background(), &pb.CreateProcessRequest{ - Name: "ref-grand-parent-task", + msg := processmodule.MsgCreate{ + Owner: cliAddress, + Name: "ref-grand-parent-task", Nodes: []*process.Process_Node{ { Key: "n0", Type: &process.Process_Node_Event_{ Event: &process.Process_Node_Event{ InstanceHash: instanceHash, - EventKey: "test_event", + EventKey: "event_trigger", }, }, }, @@ -68,10 +74,10 @@ func testOrchestratorRefGrandParentTask(executionStream pb.Execution_StreamClien Outputs: map[string]*process.Process_Node_Map_Output{ "msg": { Value: &process.Process_Node_Map_Output_Ref{ - Ref: &process.Process_Node_Map_Output_Reference{ + Ref: &process.Process_Node_Reference{ NodeKey: "n1", - Path: &process.Process_Node_Map_Output_Reference_Path{ - Selector: &process.Process_Node_Map_Output_Reference_Path_Key{ + Path: &process.Process_Node_Reference_Path{ + Selector: &process.Process_Node_Reference_Path_Key{ Key: "msg", }, }, @@ -99,15 +105,16 @@ func testOrchestratorRefGrandParentTask(executionStream pb.Execution_StreamClien {Src: "n3", Dst: "n4"}, {Src: "n4", Dst: "n5"}, }, - }) + } + processHash, err = lcd.BroadcastMsg(msg) require.NoError(t, err) - processHash = respProc.Hash }) t.Run("trigger process", func(t *testing.T) { - _, err := client.EventClient.Create(context.Background(), &pb.CreateEventRequest{ - InstanceHash: instanceHash, - Key: "test_event", - Data: &types.Struct{ + req := orchestrator.ExecutionCreateRequest{ + Price: "10000atto", + TaskKey: "task_trigger", + ExecutorHash: runnerHash, + Inputs: &types.Struct{ Fields: map[string]*types.Value{ "msg": { Kind: &types.Value_StringValue{ @@ -121,12 +128,13 @@ func testOrchestratorRefGrandParentTask(executionStream pb.Execution_StreamClien }, }, }, - }) + } + _, err := client.ExecutionClient.Create(context.Background(), &req, grpc.PerRPCCredentials(&signCred{req})) require.NoError(t, err) }) t.Run("check first task", func(t *testing.T) { t.Run("check in progress execution", func(t *testing.T) { - exec, err := executionStream.Recv() + exec, err := pollExecutionOfProcess(processHash, execution.Status_InProgress, "n1") require.NoError(t, err) require.Equal(t, "n1", exec.NodeKey) require.Equal(t, "task1", exec.TaskKey) @@ -135,7 +143,7 @@ func testOrchestratorRefGrandParentTask(executionStream pb.Execution_StreamClien require.Equal(t, "foo_event", exec.Inputs.Fields["msg"].GetStringValue()) }) t.Run("check completed execution", func(t *testing.T) { - exec, err := executionStream.Recv() + exec, err := pollExecutionOfProcess(processHash, execution.Status_Completed, "n1") require.NoError(t, err) require.Equal(t, "n1", exec.NodeKey) require.Equal(t, "task1", exec.TaskKey) @@ -147,7 +155,7 @@ func testOrchestratorRefGrandParentTask(executionStream pb.Execution_StreamClien }) t.Run("check second task", func(t *testing.T) { t.Run("check in progress execution", func(t *testing.T) { - exec, err := executionStream.Recv() + exec, err := pollExecutionOfProcess(processHash, execution.Status_InProgress, "n3") require.NoError(t, err) require.Equal(t, "n3", exec.NodeKey) require.Equal(t, "task1", exec.TaskKey) @@ -156,7 +164,7 @@ func testOrchestratorRefGrandParentTask(executionStream pb.Execution_StreamClien require.Equal(t, "itsAConstant", exec.Inputs.Fields["msg"].GetStringValue()) }) t.Run("check completed execution", func(t *testing.T) { - exec, err := executionStream.Recv() + exec, err := pollExecutionOfProcess(processHash, execution.Status_Completed, "n3") require.NoError(t, err) require.Equal(t, "n3", exec.NodeKey) require.Equal(t, "task1", exec.TaskKey) @@ -168,7 +176,7 @@ func testOrchestratorRefGrandParentTask(executionStream pb.Execution_StreamClien }) t.Run("check third task", func(t *testing.T) { t.Run("check in progress execution", func(t *testing.T) { - exec, err := executionStream.Recv() + exec, err := pollExecutionOfProcess(processHash, execution.Status_InProgress, "n5") require.NoError(t, err) require.Equal(t, "n5", exec.NodeKey) require.Equal(t, "task1", exec.TaskKey) @@ -177,7 +185,7 @@ func testOrchestratorRefGrandParentTask(executionStream pb.Execution_StreamClien require.Equal(t, "foo_event", exec.Inputs.Fields["msg"].GetStringValue()) }) t.Run("check completed execution", func(t *testing.T) { - exec, err := executionStream.Recv() + exec, err := pollExecutionOfProcess(processHash, execution.Status_Completed, "n5") require.NoError(t, err) require.Equal(t, "n5", exec.NodeKey) require.Equal(t, "task1", exec.TaskKey) @@ -188,7 +196,10 @@ func testOrchestratorRefGrandParentTask(executionStream pb.Execution_StreamClien }) }) t.Run("delete process", func(t *testing.T) { - _, err := client.ProcessClient.Delete(context.Background(), &pb.DeleteProcessRequest{Hash: processHash}) + _, err := lcd.BroadcastMsg(processmodule.MsgDelete{ + Owner: cliAddress, + Hash: processHash, + }) require.NoError(t, err) }) } diff --git a/e2e/orchestrator_ref_path_nested_test.go b/e2e/orchestrator_ref_path_nested_test.go index 1b5d8bad9..ab05bdf47 100644 --- a/e2e/orchestrator_ref_path_nested_test.go +++ b/e2e/orchestrator_ref_path_nested_test.go @@ -8,25 +8,31 @@ import ( "github.com/mesg-foundation/engine/execution" "github.com/mesg-foundation/engine/hash" "github.com/mesg-foundation/engine/process" - pb "github.com/mesg-foundation/engine/protobuf/api" "github.com/mesg-foundation/engine/protobuf/types" + "github.com/mesg-foundation/engine/server/grpc/orchestrator" + processmodule "github.com/mesg-foundation/engine/x/process" "github.com/stretchr/testify/require" + "google.golang.org/grpc" ) -func testOrchestratorRefPathNested(executionStream pb.Execution_StreamClient, instanceHash hash.Hash) func(t *testing.T) { +func testOrchestratorRefPathNested(runnerHash, instanceHash hash.Hash) func(t *testing.T) { return func(t *testing.T) { - var processHash hash.Hash + var ( + processHash hash.Hash + err error + ) t.Run("create process", func(t *testing.T) { - respProc, err := client.ProcessClient.Create(context.Background(), &pb.CreateProcessRequest{ - Name: "nested-path-data", + msg := processmodule.MsgCreate{ + Owner: cliAddress, + Name: "nested-path-data", Nodes: []*process.Process_Node{ { Key: "n0", Type: &process.Process_Node_Event_{ Event: &process.Process_Node_Event{ InstanceHash: instanceHash, - EventKey: "test_event_complex", + EventKey: "event_complex_trigger", }, }, }, @@ -41,14 +47,14 @@ func testOrchestratorRefPathNested(executionStream pb.Execution_StreamClient, in Outputs: map[string]*process.Process_Node_Map_Output{ "msg": { Value: &process.Process_Node_Map_Output_Ref{ - Ref: &process.Process_Node_Map_Output_Reference{ + Ref: &process.Process_Node_Reference{ NodeKey: "n0", - Path: &process.Process_Node_Map_Output_Reference_Path{ - Selector: &process.Process_Node_Map_Output_Reference_Path_Key{ + Path: &process.Process_Node_Reference_Path{ + Selector: &process.Process_Node_Reference_Path_Key{ Key: "msg", }, - Path: &process.Process_Node_Map_Output_Reference_Path{ - Selector: &process.Process_Node_Map_Output_Reference_Path_Key{ + Path: &process.Process_Node_Reference_Path{ + Selector: &process.Process_Node_Reference_Path_Key{ Key: "msg", }, }, @@ -62,18 +68,18 @@ func testOrchestratorRefPathNested(executionStream pb.Execution_StreamClient, in Outputs: []*process.Process_Node_Map_Output{ { Value: &process.Process_Node_Map_Output_Ref{ - Ref: &process.Process_Node_Map_Output_Reference{ + Ref: &process.Process_Node_Reference{ NodeKey: "n0", - Path: &process.Process_Node_Map_Output_Reference_Path{ - Selector: &process.Process_Node_Map_Output_Reference_Path_Key{ + Path: &process.Process_Node_Reference_Path{ + Selector: &process.Process_Node_Reference_Path_Key{ Key: "msg", }, - Path: &process.Process_Node_Map_Output_Reference_Path{ - Selector: &process.Process_Node_Map_Output_Reference_Path_Key{ + Path: &process.Process_Node_Reference_Path{ + Selector: &process.Process_Node_Reference_Path_Key{ Key: "array", }, - Path: &process.Process_Node_Map_Output_Reference_Path{ - Selector: &process.Process_Node_Map_Output_Reference_Path_Index{ + Path: &process.Process_Node_Reference_Path{ + Selector: &process.Process_Node_Reference_Path_Index{ Index: 2, }, }, @@ -84,18 +90,18 @@ func testOrchestratorRefPathNested(executionStream pb.Execution_StreamClient, in }, { Value: &process.Process_Node_Map_Output_Ref{ - Ref: &process.Process_Node_Map_Output_Reference{ + Ref: &process.Process_Node_Reference{ NodeKey: "n0", - Path: &process.Process_Node_Map_Output_Reference_Path{ - Selector: &process.Process_Node_Map_Output_Reference_Path_Key{ + Path: &process.Process_Node_Reference_Path{ + Selector: &process.Process_Node_Reference_Path_Key{ Key: "msg", }, - Path: &process.Process_Node_Map_Output_Reference_Path{ - Selector: &process.Process_Node_Map_Output_Reference_Path_Key{ + Path: &process.Process_Node_Reference_Path{ + Selector: &process.Process_Node_Reference_Path_Key{ Key: "array", }, - Path: &process.Process_Node_Map_Output_Reference_Path{ - Selector: &process.Process_Node_Map_Output_Reference_Path_Index{ + Path: &process.Process_Node_Reference_Path{ + Selector: &process.Process_Node_Reference_Path_Index{ Index: 1, }, }, @@ -106,18 +112,18 @@ func testOrchestratorRefPathNested(executionStream pb.Execution_StreamClient, in }, { Value: &process.Process_Node_Map_Output_Ref{ - Ref: &process.Process_Node_Map_Output_Reference{ + Ref: &process.Process_Node_Reference{ NodeKey: "n0", - Path: &process.Process_Node_Map_Output_Reference_Path{ - Selector: &process.Process_Node_Map_Output_Reference_Path_Key{ + Path: &process.Process_Node_Reference_Path{ + Selector: &process.Process_Node_Reference_Path_Key{ Key: "msg", }, - Path: &process.Process_Node_Map_Output_Reference_Path{ - Selector: &process.Process_Node_Map_Output_Reference_Path_Key{ + Path: &process.Process_Node_Reference_Path{ + Selector: &process.Process_Node_Reference_Path_Key{ Key: "array", }, - Path: &process.Process_Node_Map_Output_Reference_Path{ - Selector: &process.Process_Node_Map_Output_Reference_Path_Index{ + Path: &process.Process_Node_Reference_Path{ + Selector: &process.Process_Node_Reference_Path_Index{ Index: 0, }, }, @@ -154,14 +160,14 @@ func testOrchestratorRefPathNested(executionStream pb.Execution_StreamClient, in Outputs: map[string]*process.Process_Node_Map_Output{ "msg": { Value: &process.Process_Node_Map_Output_Ref{ - Ref: &process.Process_Node_Map_Output_Reference{ + Ref: &process.Process_Node_Reference{ NodeKey: "n2", - Path: &process.Process_Node_Map_Output_Reference_Path{ - Selector: &process.Process_Node_Map_Output_Reference_Path_Key{ + Path: &process.Process_Node_Reference_Path{ + Selector: &process.Process_Node_Reference_Path_Key{ Key: "msg", }, - Path: &process.Process_Node_Map_Output_Reference_Path{ - Selector: &process.Process_Node_Map_Output_Reference_Path_Key{ + Path: &process.Process_Node_Reference_Path{ + Selector: &process.Process_Node_Reference_Path_Key{ Key: "msg", }, }, @@ -189,52 +195,53 @@ func testOrchestratorRefPathNested(executionStream pb.Execution_StreamClient, in {Src: "n2", Dst: "n3"}, {Src: "n3", Dst: "n4"}, }, - }) + } + processHash, err = lcd.BroadcastMsg(msg) require.NoError(t, err) - processHash = respProc.Hash }) - data := &types.Struct{ - Fields: map[string]*types.Value{ - "msg": { - Kind: &types.Value_StructValue{ - StructValue: &types.Struct{ - Fields: map[string]*types.Value{ - "msg": { - Kind: &types.Value_StringValue{ - StringValue: "complex", - }, - }, - "timestamp": { - Kind: &types.Value_NumberValue{ - NumberValue: float64(time.Now().Unix()), - }, - }, - "array": { - Kind: &types.Value_ListValue{ - ListValue: &types.ListValue{Values: []*types.Value{ - {Kind: &types.Value_StringValue{StringValue: "first"}}, - {Kind: &types.Value_StringValue{StringValue: "second"}}, - {Kind: &types.Value_StringValue{StringValue: "third"}}, - }}, + t.Run("trigger process", func(t *testing.T) { + req := orchestrator.ExecutionCreateRequest{ + Price: "10000atto", + TaskKey: "task_complex_trigger", + ExecutorHash: runnerHash, + Inputs: &types.Struct{ + Fields: map[string]*types.Value{ + "msg": { + Kind: &types.Value_StructValue{ + StructValue: &types.Struct{ + Fields: map[string]*types.Value{ + "msg": { + Kind: &types.Value_StringValue{ + StringValue: "complex", + }, + }, + "timestamp": { + Kind: &types.Value_NumberValue{ + NumberValue: float64(time.Now().Unix()), + }, + }, + "array": { + Kind: &types.Value_ListValue{ + ListValue: &types.ListValue{Values: []*types.Value{ + {Kind: &types.Value_StringValue{StringValue: "first"}}, + {Kind: &types.Value_StringValue{StringValue: "second"}}, + {Kind: &types.Value_StringValue{StringValue: "third"}}, + }}, + }, + }, }, }, }, }, }, }, - }, - } - t.Run("trigger process", func(t *testing.T) { - _, err := client.EventClient.Create(context.Background(), &pb.CreateEventRequest{ - InstanceHash: instanceHash, - Key: "test_event_complex", - Data: data, - }) + } + _, err := client.ExecutionClient.Create(context.Background(), &req, grpc.PerRPCCredentials(&signCred{req})) require.NoError(t, err) }) t.Run("first ref", func(t *testing.T) { t.Run("check in progress execution", func(t *testing.T) { - exec, err := executionStream.Recv() + exec, err := pollExecutionOfProcess(processHash, execution.Status_InProgress, "n2") require.NoError(t, err) require.Equal(t, "task_complex", exec.TaskKey) require.Equal(t, "n2", exec.NodeKey) @@ -247,7 +254,7 @@ func testOrchestratorRefPathNested(executionStream pb.Execution_StreamClient, in require.Equal(t, "first", exec.Inputs.Fields["msg"].GetStructValue().Fields["array"].GetListValue().Values[2].GetStringValue()) }) t.Run("check completed execution", func(t *testing.T) { - exec, err := executionStream.Recv() + exec, err := pollExecutionOfProcess(processHash, execution.Status_Completed, "n2") require.NoError(t, err) require.Equal(t, "task_complex", exec.TaskKey) require.Equal(t, "n2", exec.NodeKey) @@ -263,7 +270,7 @@ func testOrchestratorRefPathNested(executionStream pb.Execution_StreamClient, in }) t.Run("second ref", func(t *testing.T) { t.Run("check in progress execution", func(t *testing.T) { - exec, err := executionStream.Recv() + exec, err := pollExecutionOfProcess(processHash, execution.Status_InProgress, "n4") require.NoError(t, err) require.Equal(t, "task1", exec.TaskKey) require.Equal(t, "n4", exec.NodeKey) @@ -272,7 +279,7 @@ func testOrchestratorRefPathNested(executionStream pb.Execution_StreamClient, in require.Equal(t, "complex", exec.Inputs.Fields["msg"].GetStringValue()) }) t.Run("check completed execution", func(t *testing.T) { - exec, err := executionStream.Recv() + exec, err := pollExecutionOfProcess(processHash, execution.Status_Completed, "n4") require.NoError(t, err) require.Equal(t, "task1", exec.TaskKey) require.Equal(t, "n4", exec.NodeKey) @@ -283,7 +290,10 @@ func testOrchestratorRefPathNested(executionStream pb.Execution_StreamClient, in }) }) t.Run("delete process", func(t *testing.T) { - _, err := client.ProcessClient.Delete(context.Background(), &pb.DeleteProcessRequest{Hash: processHash}) + _, err := lcd.BroadcastMsg(processmodule.MsgDelete{ + Owner: cliAddress, + Hash: processHash, + }) require.NoError(t, err) }) } diff --git a/e2e/orchestrator_result_task_test.go b/e2e/orchestrator_result_task_test.go index 65eb4b06c..798f40b4d 100644 --- a/e2e/orchestrator_result_task_test.go +++ b/e2e/orchestrator_result_task_test.go @@ -7,18 +7,25 @@ import ( "github.com/mesg-foundation/engine/execution" "github.com/mesg-foundation/engine/hash" "github.com/mesg-foundation/engine/process" - pb "github.com/mesg-foundation/engine/protobuf/api" "github.com/mesg-foundation/engine/protobuf/types" + "github.com/mesg-foundation/engine/server/grpc/orchestrator" + processmodule "github.com/mesg-foundation/engine/x/process" "github.com/stretchr/testify/require" + "google.golang.org/grpc" ) -func testOrchestratorResultTask(executionStream pb.Execution_StreamClient, runnerHash hash.Hash, instanceHash hash.Hash) func(t *testing.T) { +func testOrchestratorResultTask(runnerHash hash.Hash, instanceHash hash.Hash) func(t *testing.T) { return func(t *testing.T) { - var processHash hash.Hash + var ( + processHash hash.Hash + triggerExecHash hash.Hash + err error + ) t.Run("create process", func(t *testing.T) { - respProc, err := client.ProcessClient.Create(context.Background(), &pb.CreateProcessRequest{ - Name: "result-task-process", + msg := processmodule.MsgCreate{ + Owner: cliAddress, + Name: "result-task-process", Nodes: []*process.Process_Node{ { Key: "n0", @@ -42,14 +49,14 @@ func testOrchestratorResultTask(executionStream pb.Execution_StreamClient, runne Edges: []*process.Process_Edge{ {Src: "n0", Dst: "n1"}, }, - }) + } + processHash, err = lcd.BroadcastMsg(msg) require.NoError(t, err) - processHash = respProc.Hash }) t.Run("trigger process", func(t *testing.T) { - _, err := client.ExecutionClient.Create(context.Background(), &pb.CreateExecutionRequest{ + req := orchestrator.ExecutionCreateRequest{ + Price: "10000atto", TaskKey: "task1", - EventHash: hash.Int(11010101011), ExecutorHash: runnerHash, Inputs: &types.Struct{ Fields: map[string]*types.Value{ @@ -60,16 +67,18 @@ func testOrchestratorResultTask(executionStream pb.Execution_StreamClient, runne }, }, }, - }) + } + resp, err := client.ExecutionClient.Create(context.Background(), &req, grpc.PerRPCCredentials(&signCred{req})) require.NoError(t, err) + triggerExecHash = resp.Hash }) t.Run("check trigger process execution", func(t *testing.T) { t.Run("in progress", func(t *testing.T) { - exec, err := executionStream.Recv() + exec, err := pollExecution(triggerExecHash, execution.Status_InProgress) require.NoError(t, err) + require.Equal(t, triggerExecHash, exec.Hash) require.Equal(t, "task1", exec.TaskKey) require.Equal(t, "", exec.NodeKey) - require.True(t, hash.Int(11010101011).Equal(exec.EventHash)) require.Equal(t, execution.Status_InProgress, exec.Status) require.True(t, exec.Inputs.Equal(&types.Struct{ Fields: map[string]*types.Value{ @@ -82,18 +91,18 @@ func testOrchestratorResultTask(executionStream pb.Execution_StreamClient, runne })) }) t.Run("completed", func(t *testing.T) { - exec, err := executionStream.Recv() + exec, err := pollExecution(triggerExecHash, execution.Status_Completed) require.NoError(t, err) + require.Equal(t, triggerExecHash, exec.Hash) require.Equal(t, "task1", exec.TaskKey) require.Equal(t, "", exec.NodeKey) - require.True(t, hash.Int(11010101011).Equal(exec.EventHash)) require.Equal(t, execution.Status_Completed, exec.Status) require.Equal(t, "foo_2", exec.Outputs.Fields["msg"].GetStringValue()) require.NotEmpty(t, exec.Outputs.Fields["timestamp"].GetNumberValue()) }) }) t.Run("check in progress execution", func(t *testing.T) { - exec, err := executionStream.Recv() + exec, err := pollExecutionOfProcess(processHash, execution.Status_InProgress, "n1") require.NoError(t, err) require.Equal(t, "task2", exec.TaskKey) require.Equal(t, "n1", exec.NodeKey) @@ -102,7 +111,7 @@ func testOrchestratorResultTask(executionStream pb.Execution_StreamClient, runne require.Equal(t, "foo_2", exec.Inputs.Fields["msg"].GetStringValue()) }) t.Run("check completed execution", func(t *testing.T) { - exec, err := executionStream.Recv() + exec, err := pollExecutionOfProcess(processHash, execution.Status_Completed, "n1") require.NoError(t, err) require.Equal(t, "task2", exec.TaskKey) require.Equal(t, "n1", exec.NodeKey) @@ -112,7 +121,10 @@ func testOrchestratorResultTask(executionStream pb.Execution_StreamClient, runne require.NotEmpty(t, exec.Outputs.Fields["timestamp"].GetNumberValue()) }) t.Run("delete process", func(t *testing.T) { - _, err := client.ProcessClient.Delete(context.Background(), &pb.DeleteProcessRequest{Hash: processHash}) + _, err := lcd.BroadcastMsg(processmodule.MsgDelete{ + Owner: cliAddress, + Hash: processHash, + }) require.NoError(t, err) }) } diff --git a/e2e/orchestrator_test.go b/e2e/orchestrator_test.go index 10fc00b16..5658d38b6 100644 --- a/e2e/orchestrator_test.go +++ b/e2e/orchestrator_test.go @@ -1,29 +1,19 @@ package main import ( - "context" "testing" - - "github.com/mesg-foundation/engine/protobuf/acknowledgement" - pb "github.com/mesg-foundation/engine/protobuf/api" - "github.com/stretchr/testify/require" ) func testOrchestrator(t *testing.T) { - executionStream, err := client.ExecutionClient.Stream(context.Background(), &pb.StreamExecutionRequest{}) - require.NoError(t, err) - acknowledgement.WaitForStreamToBeReady(executionStream) - // running orchestrator tests - t.Run("process balance and withdraw", testOrchestratorProcessBalanceWithdraw(executionStream, testInstanceHash)) - t.Run("event task", testOrchestratorEventTask(executionStream, testInstanceHash)) - t.Run("result task", testOrchestratorResultTask(executionStream, testRunnerHash, testInstanceHash)) - t.Run("map const", testOrchestratorMapConst(executionStream, testInstanceHash)) - t.Run("ref grand parent task", testOrchestratorRefGrandParentTask(executionStream, testInstanceHash)) - t.Run("nested data", testOrchestratorNestedData(executionStream, testInstanceHash)) - t.Run("nested map", testOrchestratorNestedMap(executionStream, testInstanceHash)) - t.Run("ref path nested", testOrchestratorRefPathNested(executionStream, testInstanceHash)) - - // to execute last because of go routine leak. See fixme in following function - t.Run("filter", testOrchestratorFilter(executionStream, testInstanceHash)) + t.Run("process balance and withdraw", testOrchestratorProcessBalanceWithdraw(testRunnerHash, testInstanceHash)) + t.Run("event task", testOrchestratorEventTask(testRunnerHash, testInstanceHash)) + t.Run("result task", testOrchestratorResultTask(testRunnerHash, testInstanceHash)) + t.Run("map const", testOrchestratorMapConst(testRunnerHash, testInstanceHash)) + t.Run("ref grand parent task", testOrchestratorRefGrandParentTask(testRunnerHash, testInstanceHash)) + t.Run("nested data", testOrchestratorNestedData(testRunnerHash, testInstanceHash)) + t.Run("nested map", testOrchestratorNestedMap(testRunnerHash, testInstanceHash)) + t.Run("ref path nested", testOrchestratorRefPathNested(testRunnerHash, testInstanceHash)) + t.Run("filter", testOrchestratorFilter(testRunnerHash, testInstanceHash)) + t.Run("filter path nested", testOrchestratorFilterPathNested(testRunnerHash, testInstanceHash)) } diff --git a/e2e/process_test.go b/e2e/process_test.go index 09cd72219..1d04c4655 100644 --- a/e2e/process_test.go +++ b/e2e/process_test.go @@ -1,31 +1,32 @@ package main import ( - "context" "testing" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/bank" "github.com/mesg-foundation/engine/hash" "github.com/mesg-foundation/engine/ownership" "github.com/mesg-foundation/engine/process" - pb "github.com/mesg-foundation/engine/protobuf/api" + processmodule "github.com/mesg-foundation/engine/x/process" + processrest "github.com/mesg-foundation/engine/x/process/client/rest" "github.com/stretchr/testify/require" ) func testProcess(t *testing.T) { var ( + err error processHash hash.Hash processAddress sdk.AccAddress - req = &pb.CreateProcessRequest{ - Name: "test-process", + msg = &processmodule.MsgCreate{ + Owner: cliAddress, + Name: "test-process", Nodes: []*process.Process_Node{ { Key: "n0", Type: &process.Process_Node_Event_{ Event: &process.Process_Node_Event{ InstanceHash: testInstanceHash, - EventKey: "test_service_ready", + EventKey: "service_ready", }, }, }, @@ -34,7 +35,7 @@ func testProcess(t *testing.T) { Type: &process.Process_Node_Task_{ Task: &process.Process_Node_Task{ InstanceHash: testInstanceHash, - TaskKey: "test_service_ready", + TaskKey: "service_ready", }, }, }, @@ -49,104 +50,75 @@ func testProcess(t *testing.T) { ) t.Run("create", func(t *testing.T) { - resp, err := client.ProcessClient.Create(context.Background(), req) + processHash, err = lcd.BroadcastMsg(msg) require.NoError(t, err) - processHash = resp.Hash }) t.Run("get", func(t *testing.T) { - t.Run("grpc", func(t *testing.T) { - p, err := client.ProcessClient.Get(context.Background(), &pb.GetProcessRequest{Hash: processHash}) - require.NoError(t, err) - require.True(t, p.Equal(&process.Process{ - Hash: p.Hash, - Address: p.Address, - Name: req.Name, - Nodes: req.Nodes, - Edges: req.Edges, - })) - }) - t.Run("lcd", func(t *testing.T) { - var p *process.Process - lcdGet(t, "process/get/"+processHash.String(), &p) - require.True(t, p.Equal(&process.Process{ - Hash: p.Hash, - Address: p.Address, - Name: req.Name, - Nodes: req.Nodes, - Edges: req.Edges, - })) - processAddress = p.Address - }) + var p *process.Process + require.NoError(t, lcd.Get("process/get/"+processHash.String(), &p)) + require.True(t, p.Equal(&process.Process{ + Hash: p.Hash, + Address: p.Address, + Name: msg.Name, + Nodes: msg.Nodes, + Edges: msg.Edges, + })) + processAddress = p.Address }) t.Run("check ownership creation", func(t *testing.T) { - t.Run("lcd", func(t *testing.T) { - ownerships := make([]*ownership.Ownership, 0) - lcdGet(t, "ownership/list", &ownerships) - owners := make([]*ownership.Ownership, 0) - for _, o := range ownerships { - if o.ResourceHash.Equal(processHash) && o.Resource == ownership.Ownership_Process && o.Owner != "" { - owners = append(owners, o) - } - } - require.Len(t, owners, 1) - }) - t.Run("grpc", func(t *testing.T) { - ownerships, err := client.OwnershipClient.List(context.Background(), &pb.ListOwnershipRequest{}) - require.NoError(t, err) - owners := make([]*ownership.Ownership, 0) - for _, o := range ownerships.Ownerships { - if o.ResourceHash.Equal(processHash) && o.Resource == ownership.Ownership_Process && o.Owner != "" { - owners = append(owners, o) - } + ownerships := make([]*ownership.Ownership, 0) + require.NoError(t, lcd.Get("ownership/list", &ownerships)) + owners := make([]*ownership.Ownership, 0) + for _, o := range ownerships { + if o.ResourceHash.Equal(processHash) && o.Resource == ownership.Ownership_Process && o.Owner != "" { + owners = append(owners, o) } - require.Len(t, owners, 1) - }) + } + require.Len(t, owners, 1) }) t.Run("check coins on process", func(t *testing.T) { var coins sdk.Coins - param := bank.NewQueryBalanceParams(processAddress) - require.NoError(t, cclient.QueryJSON("custom/bank/balances", param, &coins)) + require.NoError(t, lcd.Get("bank/balances/"+processAddress.String(), &coins)) require.True(t, coins.IsEqual(processInitialBalance), coins) }) t.Run("list", func(t *testing.T) { - t.Run("grpc", func(t *testing.T) { - ps, err := client.ProcessClient.List(context.Background(), &pb.ListProcessRequest{}) - require.NoError(t, err) - require.Len(t, ps.Processes, 1) - }) - t.Run("lcd", func(t *testing.T) { - ps := make([]*process.Process, 0) - lcdGet(t, "process/list", &ps) - require.Len(t, ps, 1) - }) + ps := make([]*process.Process, 0) + require.NoError(t, lcd.Get("process/list", &ps)) + require.Len(t, ps, 1) + }) + + t.Run("hash", func(t *testing.T) { + msg := processrest.HashRequest{ + Name: msg.Name, + Nodes: msg.Nodes, + Edges: msg.Edges, + } + var hash hash.Hash + require.NoError(t, lcd.Post("process/hash", msg, &hash)) + require.Equal(t, processHash, hash) }) t.Run("delete", func(t *testing.T) { - _, err := client.ProcessClient.Delete(context.Background(), &pb.DeleteProcessRequest{Hash: processHash}) + _, err := lcd.BroadcastMsg(processmodule.MsgDelete{ + Owner: cliAddress, + Hash: processHash, + }) require.NoError(t, err) }) t.Run("check ownership deletion", func(t *testing.T) { - t.Run("lcd", func(t *testing.T) { - ownerships := make([]*ownership.Ownership, 0) - lcdGet(t, "ownership/list", &ownerships) - require.Len(t, ownerships, 2) - }) - t.Run("grpc", func(t *testing.T) { - ownerships, err := client.OwnershipClient.List(context.Background(), &pb.ListOwnershipRequest{}) - require.NoError(t, err) - require.Len(t, ownerships.Ownerships, 2) - }) + ownerships := make([]*ownership.Ownership, 0) + require.NoError(t, lcd.Get("ownership/list", &ownerships)) + require.Len(t, ownerships, 2) }) t.Run("check coins on process", func(t *testing.T) { var coins sdk.Coins - param := bank.NewQueryBalanceParams(processAddress) - require.NoError(t, cclient.QueryJSON("custom/bank/balances", param, &coins)) + require.NoError(t, lcd.Get("bank/balances/"+processAddress.String(), &coins)) require.True(t, coins.IsZero(), coins) }) } diff --git a/e2e/runner_test.go b/e2e/runner_test.go index b5df362d2..f71fe9ec3 100644 --- a/e2e/runner_test.go +++ b/e2e/runner_test.go @@ -5,102 +5,109 @@ import ( "testing" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/bank" + "github.com/mesg-foundation/engine/ext/xos" "github.com/mesg-foundation/engine/hash" "github.com/mesg-foundation/engine/protobuf/acknowledgement" - pb "github.com/mesg-foundation/engine/protobuf/api" "github.com/mesg-foundation/engine/runner" + "github.com/mesg-foundation/engine/server/grpc/orchestrator" + grpcorchestrator "github.com/mesg-foundation/engine/server/grpc/orchestrator" + runnerrest "github.com/mesg-foundation/engine/x/runner/client/rest" "github.com/stretchr/testify/require" + "google.golang.org/grpc" ) -var testRunnerHash hash.Hash -var testRunnerAddress sdk.AccAddress +var ( + testRunnerHash hash.Hash + testInstanceEnvHash hash.Hash + testRunnerAddress sdk.AccAddress +) func testRunner(t *testing.T) { - t.Run("create", func(t *testing.T) { - stream, err := client.EventClient.Stream(context.Background(), &pb.StreamEventRequest{ - Filter: &pb.StreamEventRequest_Filter{ - Key: "test_service_ready", - }, - }) + var ( + testInstanceEnv = xos.EnvMergeSlices(testServiceStruct.Configuration.Env, []string{"BAR=3", "REQUIRED=4"}) + registerPayloadSignature []byte + ) + t.Run("hash", func(t *testing.T) { + var res runnerrest.HashResponse + err := lcd.Post("runner/hash", &runnerrest.HashRequest{ + ServiceHash: testServiceHash, + Address: engineAddress.String(), + Env: testInstanceEnv, + }, &res) require.NoError(t, err) - acknowledgement.WaitForStreamToBeReady(stream) + testRunnerHash = res.RunnerHash + testInstanceHash = res.InstanceHash + testInstanceEnvHash = res.EnvHash + }) + + t.Run("build service image", func(t *testing.T) { + require.NoError(t, cont.Build(testServiceStruct)) + }) - resp, err := client.RunnerClient.Create(context.Background(), &pb.CreateRunnerRequest{ + t.Run("create msg, sign it and inject into env", func(t *testing.T) { + value := grpcorchestrator.RunnerRegisterRequest{ ServiceHash: testServiceHash, - Env: []string{"BAR=3", "REQUIRED=4"}, - }) - require.NoError(t, err) - testRunnerHash = resp.Hash + EnvHash: testInstanceEnvHash, + } - // wait for service to be ready - _, err = stream.Recv() + var err error + registerPayloadSignature, err = signPayload(value) require.NoError(t, err) }) - t.Run("recreate", func(t *testing.T) { - _, err := client.RunnerClient.Delete(context.Background(), &pb.DeleteRunnerRequest{Hash: testRunnerHash}) + t.Run("wait for service to be ready", func(t *testing.T) { + req := orchestrator.EventStreamRequest{ + Filter: &orchestrator.EventStreamRequest_Filter{ + Key: "service_ready", + }, + } + stream, err := client.EventClient.Stream(context.Background(), &req, grpc.PerRPCCredentials(&signCred{req})) require.NoError(t, err) - resp, err := client.RunnerClient.Create(context.Background(), &pb.CreateRunnerRequest{ - ServiceHash: testServiceHash, - Env: []string{"BAR=3", "REQUIRED=4"}, + acknowledgement.WaitForStreamToBeReady(stream) + + t.Run("start", func(t *testing.T) { + require.NoError(t, cont.Start(testServiceStruct, testInstanceHash, testRunnerHash, testInstanceEnvHash, testInstanceEnv, registerPayloadSignature)) }) + + // wait for service to be ready + _, err = stream.Recv() require.NoError(t, err) - testRunnerHash = resp.Hash }) t.Run("get", func(t *testing.T) { - t.Run("grpc", func(t *testing.T) { - resp, err := client.RunnerClient.Get(context.Background(), &pb.GetRunnerRequest{Hash: testRunnerHash}) - require.NoError(t, err) - require.Equal(t, testRunnerHash, resp.Hash) - testInstanceHash = resp.InstanceHash - }) - t.Run("lcd", func(t *testing.T) { - var r *runner.Runner - lcdGet(t, "runner/get/"+testRunnerHash.String(), &r) - require.Equal(t, testRunnerHash, r.Hash) - testRunnerAddress = r.Address - }) + var run *runner.Runner + require.NoError(t, lcd.Get("runner/get/"+testRunnerHash.String(), &run)) + require.Equal(t, testRunnerHash, run.Hash) + testRunnerAddress = run.Address }) - // TODO: need to test the filters t.Run("list", func(t *testing.T) { - t.Run("grpc", func(t *testing.T) { - resp, err := client.RunnerClient.List(context.Background(), &pb.ListRunnerRequest{}) - require.NoError(t, err) - require.Len(t, resp.Runners, 1) - require.Equal(t, testInstanceHash, resp.Runners[0].InstanceHash) - require.Equal(t, testRunnerHash, resp.Runners[0].Hash) - }) - t.Run("lcd", func(t *testing.T) { - rs := make([]*runner.Runner, 0) - lcdGet(t, "runner/list", &rs) - require.Len(t, rs, 1) - require.Equal(t, testInstanceHash, rs[0].InstanceHash) - require.Equal(t, testRunnerHash, rs[0].Hash) - }) + rs := make([]*runner.Runner, 0) + require.NoError(t, lcd.Get("runner/list", &rs)) + require.Len(t, rs, 1) + require.Equal(t, testInstanceHash, rs[0].InstanceHash) + require.Equal(t, testRunnerHash, rs[0].Hash) }) } func testDeleteRunner(t *testing.T) { - _, err := client.RunnerClient.Delete(context.Background(), &pb.DeleteRunnerRequest{Hash: testRunnerHash}) + req := orchestrator.RunnerDeleteRequest{ + RunnerHash: testRunnerHash, + } + _, err := client.RunnerClient.Delete(context.Background(), &req, grpc.PerRPCCredentials(&signCred{req})) require.NoError(t, err) - t.Run("grpc", func(t *testing.T) { - resp, err := client.RunnerClient.List(context.Background(), &pb.ListRunnerRequest{}) - require.NoError(t, err) - require.Len(t, resp.Runners, 0) - }) - t.Run("lcd", func(t *testing.T) { + require.NoError(t, cont.Stop(testServiceStruct, testRunnerHash)) + + t.Run("check deletion", func(t *testing.T) { rs := make([]*runner.Runner, 0) - lcdGet(t, "runner/list", &rs) + require.NoError(t, lcd.Get("runner/list", &rs)) require.Len(t, rs, 0) }) + t.Run("check coins on runner", func(t *testing.T) { var coins sdk.Coins - param := bank.NewQueryBalanceParams(testRunnerAddress) - require.NoError(t, cclient.QueryJSON("custom/bank/balances", param, &coins)) + require.NoError(t, lcd.Get("bank/balances/"+testRunnerAddress.String(), &coins)) require.True(t, coins.IsZero(), coins) }) } diff --git a/e2e/service_test.go b/e2e/service_test.go index 26413a5b7..8951cd1a2 100644 --- a/e2e/service_test.go +++ b/e2e/service_test.go @@ -1,106 +1,73 @@ package main import ( - "context" "testing" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/mesg-foundation/engine/hash" "github.com/mesg-foundation/engine/ownership" - pb "github.com/mesg-foundation/engine/protobuf/api" "github.com/mesg-foundation/engine/service" + servicerest "github.com/mesg-foundation/engine/x/service/client/rest" "github.com/stretchr/testify/require" ) var ( testServiceHash hash.Hash testServiceAddress sdk.AccAddress + testServiceStruct *service.Service + err error ) func testService(t *testing.T) { - req := newTestCreateServiceRequest() - t.Run("create", func(t *testing.T) { - resp, err := client.ServiceClient.Create(context.Background(), req) + testCreateServiceMsg.Owner = cliAddress + testServiceHash, err = lcd.BroadcastMsg(testCreateServiceMsg) require.NoError(t, err) - testServiceHash = resp.Hash }) t.Run("get", func(t *testing.T) { - t.Run("grpc", func(t *testing.T) { - service, err := client.ServiceClient.Get(context.Background(), &pb.GetServiceRequest{Hash: testServiceHash}) - require.NoError(t, err) - require.Equal(t, testServiceHash, service.Hash) - }) - t.Run("lcd", func(t *testing.T) { - var s *service.Service - lcdGet(t, "service/get/"+testServiceHash.String(), &s) - require.Equal(t, testServiceHash, s.Hash) - testServiceAddress = s.Address - }) + require.NoError(t, lcd.Get("service/get/"+testServiceHash.String(), &testServiceStruct)) + require.Equal(t, testServiceHash, testServiceStruct.Hash) + testServiceAddress = testServiceStruct.Address }) t.Run("list", func(t *testing.T) { - t.Run("grpc", func(t *testing.T) { - resp, err := client.ServiceClient.List(context.Background(), &pb.ListServiceRequest{}) - require.NoError(t, err) - require.Len(t, resp.Services, 1) - }) - t.Run("lcd", func(t *testing.T) { - ss := make([]*service.Service, 0) - lcdGet(t, "service/list", &ss) - require.Len(t, ss, 1) - }) + ss := make([]*service.Service, 0) + require.NoError(t, lcd.Get("service/list", &ss)) + require.Len(t, ss, 1) }) t.Run("exists", func(t *testing.T) { - t.Run("grpc", func(t *testing.T) { - resp, err := client.ServiceClient.Exists(context.Background(), &pb.ExistsServiceRequest{Hash: testServiceHash}) - require.NoError(t, err) - require.True(t, resp.Exists) - - resp, err = client.ServiceClient.Exists(context.Background(), &pb.ExistsServiceRequest{Hash: hash.Int(1)}) - require.NoError(t, err) - require.False(t, resp.Exists) - }) - t.Run("lcd", func(t *testing.T) { - var exist bool - lcdGet(t, "service/exist/"+testServiceHash.String(), &exist) - require.True(t, exist) - lcdGet(t, "service/exist/"+hash.Int(1).String(), &exist) - require.False(t, exist) - }) + var exist bool + require.NoError(t, lcd.Get("service/exist/"+testServiceHash.String(), &exist)) + require.True(t, exist) + require.NoError(t, lcd.Get("service/exist/"+hash.Int(1).String(), &exist)) + require.False(t, exist) }) t.Run("hash", func(t *testing.T) { - t.Run("grpc", func(t *testing.T) { - resp, err := client.ServiceClient.Hash(context.Background(), req) - require.NoError(t, err) - require.Equal(t, testServiceHash, resp.Hash) - }) - t.Run("lcd", func(t *testing.T) { - var hash hash.Hash - lcdPost(t, "service/hash", req, &hash) - require.Equal(t, testServiceHash, hash) - }) + msg := servicerest.HashRequest{ + Sid: testCreateServiceMsg.Sid, + Name: testCreateServiceMsg.Name, + Description: testCreateServiceMsg.Description, + Configuration: testCreateServiceMsg.Configuration, + Tasks: testCreateServiceMsg.Tasks, + Events: testCreateServiceMsg.Events, + Dependencies: testCreateServiceMsg.Dependencies, + Repository: testCreateServiceMsg.Repository, + Source: testCreateServiceMsg.Source, + } + var hash hash.Hash + require.NoError(t, lcd.Post("service/hash", msg, &hash)) + require.Equal(t, testServiceHash, hash) }) t.Run("check ownership creation", func(t *testing.T) { - t.Run("grpc", func(t *testing.T) { - ownerships, err := client.OwnershipClient.List(context.Background(), &pb.ListOwnershipRequest{}) - require.NoError(t, err) - require.Len(t, ownerships.Ownerships, 1) - require.NotEmpty(t, ownerships.Ownerships[0].Owner) - require.Equal(t, ownership.Ownership_Service, ownerships.Ownerships[0].Resource) - require.Equal(t, testServiceHash, ownerships.Ownerships[0].ResourceHash) - }) - t.Run("lcd", func(t *testing.T) { - ownerships := make([]*ownership.Ownership, 0) - lcdGet(t, "ownership/list", &ownerships) - require.Len(t, ownerships, 1) - require.NotEmpty(t, ownerships[0].Owner) - require.Equal(t, ownership.Ownership_Service, ownerships[0].Resource) - require.Equal(t, testServiceHash, ownerships[0].ResourceHash) - }) + ownerships := make([]*ownership.Ownership, 0) + require.NoError(t, lcd.Get("ownership/list", &ownerships)) + require.Len(t, ownerships, 1) + require.NotEmpty(t, ownerships[0].Owner) + require.Equal(t, ownership.Ownership_Service, ownerships[0].Resource) + require.Equal(t, testServiceHash, ownerships[0].ResourceHash) }) } diff --git a/e2e/testdata/e2e.config.yml b/e2e/testdata/e2e.config.yml index feda05243..02adde02e 100644 --- a/e2e/testdata/e2e.config.yml +++ b/e2e/testdata/e2e.config.yml @@ -1,6 +1,8 @@ +authorized_pubkeys: + - mesgtestpub1addwnpepqg0ujk8vcwq86z8466rznfvfz5rk992wsy0qtczfedgsy3x90mrzk476x05 account: mnemonic: glimpse upon body vast economy give taxi yellow rabbit come click ranch chronic hammer sport near rotate charge lumber chicken cloud base thing forum tendermint: config: consensus: - timeoutcommit: 1s \ No newline at end of file + timeoutcommit: 1s diff --git a/e2e/testdata/test-complex-service/go.mod b/e2e/testdata/test-complex-service/go.mod index 96e3c2526..25d66f1a8 100644 --- a/e2e/testdata/test-complex-service/go.mod +++ b/e2e/testdata/test-complex-service/go.mod @@ -3,6 +3,6 @@ module main go 1.13 require ( - github.com/mesg-foundation/engine v0.15.0 - google.golang.org/grpc v1.24.0 + github.com/mesg-foundation/engine v0.18.4-0.20200406120519-06c3e44902e9 + google.golang.org/grpc v1.28.0 ) diff --git a/e2e/testdata/test-complex-service/go.sum b/e2e/testdata/test-complex-service/go.sum index 5ad77df53..32fc92ae6 100644 --- a/e2e/testdata/test-complex-service/go.sum +++ b/e2e/testdata/test-complex-service/go.sum @@ -1,330 +1,672 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/99designs/keyring v1.1.3 h1:mEV3iyZWjkxQ7R8ia8GcG97vCX5zQQ7n4o8R2BylwQY= +github.com/99designs/keyring v1.1.3/go.mod h1:657DQuMrBZRtuL/voxVyiyb6zpMehlm5vLB9Qwrv904= 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/ChainSafe/go-schnorrkel v0.0.0-20200102211924-4bcbc698314f h1:4O1om+UVU+Hfcihr1timk8YNXHxzZWgCo7ofnrZRApw= +github.com/ChainSafe/go-schnorrkel v0.0.0-20200102211924-4bcbc698314f/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4= +github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= github.com/Masterminds/semver v1.4.2/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= +github.com/Masterminds/sprig v2.15.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o= github.com/Masterminds/sprig v2.20.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o= github.com/Microsoft/go-winio v0.4.12/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA= -github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk= +github.com/Microsoft/hcsshim v0.8.6/go.mod h1:Op3hHsoHPAvb6lceZHDtd9OkTew38wNoXnJs8iY7rUg= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= +github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= +github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= +github.com/Songmu/retry v0.1.0/go.mod h1:7sXIW7eseB9fq0FUvigRcQMVLR9tuHI0Scok+rkpAuA= +github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrdtl/UvroE= github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= +github.com/Workiva/go-datastructures v1.0.52/go.mod h1:Z+F2Rca0qCsVYDS8z7bAGm8f3UkzuWYS/oBZz5a7VVA= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= +github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/aokoli/goutils v1.0.1/go.mod h1:SijmP0QR8LtwsmDs8Yii5Z/S4trXFGFC2oO5g9DP+DQ= +github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= +github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= +github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= +github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= +github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A= +github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU= +github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= +github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= +github.com/bartekn/go-bip39 v0.0.0-20171116152956-a05967ea095d h1:1aAija9gr0Hyv4KfQcRcwlmFIrhkDmIj2dz5bkg/s/8= github.com/bartekn/go-bip39 v0.0.0-20171116152956-a05967ea095d/go.mod h1:icNx/6QdFblhsEjZehARqbNumymUT/ydwlLojFdv7Sk= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= +github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/btcsuite/btcd v0.0.0-20190115013929-ed77733ec07d/go.mod h1:d3C0AkH6BRcvO8T0UEPu53cnw4IbV63x1bEjildYhO0= +github.com/btcsuite/btcd v0.0.0-20190807005414-4063feeff79a h1:We35J+0yvVFrEXbtViYUW8H/wNOhqjIF3PsrW4yYmGw= github.com/btcsuite/btcd v0.0.0-20190807005414-4063feeff79a/go.mod h1:3J08xEfcugPacsc34/LKRU2yO7YmuT8yt28J8k2+rrI= github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= github.com/btcsuite/btcutil v0.0.0-20180706230648-ab6388e0c60a/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= +github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d h1:yJzD/yFppdVCf6ApMkVy8cUxV0XrxdP9rVf6D87/Mng= github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg= github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVaaLLH7j4eDXPRvw78tMflu7Ie2bzYOH4Y8rRKBY= github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= +github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ= +github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +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/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= +github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= +github.com/containerd/containerd v1.3.0/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA= github.com/containerd/continuity v0.0.0-20190426062206-aaeac12a7ffc/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y= 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/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.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/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.37.0/go.mod h1:3b/k/Zd+YDuttSmEJdNkxga1H5EIiDUhSYeErAHQN7A= -github.com/cosmos/go-bip39 v0.0.0-20180618194314-52158e4697b8/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= +github.com/cosmos/cosmos-sdk v0.38.2 h1:IeDZxxTgTMGJRZsV4s482O2gxjhLzToX5Zy1uwyasDs= +github.com/cosmos/cosmos-sdk v0.38.2/go.mod h1:p27t20Rw7qRZ0Dj7kq2a+rIwBtbk3k05/tF1sHPPw5I= +github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d h1:49RLWk1j44Xu4fjHb6JFYmeUnDORVwHNkDxaQ0ctCVU= github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= -github.com/cosmos/ledger-cosmos-go v0.10.3/go.mod h1:J8//BsAGTo3OC/vDLjMRFLW6q0WAaXvHnVc7ZmE8iUY= +github.com/cosmos/ledger-cosmos-go v0.11.1 h1:9JIYsGnXP613pb2vPjFeMMjBI5lEDsEaF6oYorTy6J4= +github.com/cosmos/ledger-cosmos-go v0.11.1/go.mod h1:J8//BsAGTo3OC/vDLjMRFLW6q0WAaXvHnVc7ZmE8iUY= +github.com/cosmos/ledger-go v0.9.2 h1:Nnao/dLwaVTk1Q5U9THldpUMMXU94BOTWPddSmVB6pI= github.com/cosmos/ledger-go v0.9.2/go.mod h1:oZJ2hHAZROdlHiwTg4t7kP+GKIIkBT+o6c9QWFanOyI= -github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= +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/cskr/pubsub v1.0.2 h1:vlOzMhl6PFn60gRlTQQsIfVwaPB/B/8MziK8FhEPt/0= github.com/cskr/pubsub v1.0.2/go.mod h1:/8MzYXk/NJAz782G8RPkFzXTZVu63VotefPnR9TIRis= +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-20161028175848-04cdfd42973b/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 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/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= +github.com/docker/cli v0.0.0-20191011045415-5d85cdacd257/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/docker/docker v0.0.0-20180803200506-eeea12db7a65/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v1.4.2-0.20191006173954-0abbb9e4ebf1/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= -github.com/etcd-io/bbolt v1.3.2/go.mod h1:ZF2nL25h33cCyBtcyWeZ2/I3HQOfTP+0PIEvHjkjCrw= +github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/dvsekhvalnov/jose2go v0.0.0-20180829124132-7f401d37b68a h1:mq+R6XEM6lJX5VlLyZIrUSP8tSuJp82xTK89hvBwJbU= +github.com/dvsekhvalnov/jose2go v0.0.0-20180829124132-7f401d37b68a/go.mod h1:7BvyPhdbLxMXIYTFPLsyJRFMsKmOZnQmzh6Gb+uquuM= +github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= +github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= +github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= +github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= +github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/protoc-gen-validate v0.0.14/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/etcd-io/bbolt v1.3.3 h1:gSJmxrs37LgTqR/oyJBWok6k6SvXEUerFTbltIhXkBM= github.com/etcd-io/bbolt v1.3.3/go.mod h1:ZF2nL25h33cCyBtcyWeZ2/I3HQOfTP+0PIEvHjkjCrw= -github.com/fortytw2/leaktest v1.2.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= +github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51 h1:0JZ+dUmQeA8IIVUMzysrX4/AKuQwWhV2dYQuPZdvdSQ= +github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51/go.mod h1:Yg+htXGokKKdzcwhuNDwVvN+uBxDGXJ7G/VN1d8fa64= +github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 h1:JWuenKqqX8nojtoVVWjGfOF9635RETekkoH6Cc9SX0A= +github.com/facebookgo/stack v0.0.0-20160209184415-751773369052/go.mod h1:UbMTZqLaRiH3MsBH8va0n7s1pQYcu3uTb8G4tygF4Zg= +github.com/facebookgo/subset v0.0.0-20150612182917-8dac2c3c4870 h1:E2s37DuLxFhQDg5gKsWoLBOB0n+ZW8s599zru8FJ2/Y= +github.com/facebookgo/subset v0.0.0-20150612182917-8dac2c3c4870/go.mod h1:5tD+neXqOorC30/tWg0LCSkrqj/AR6gu8yY8/fpw1q0= +github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= +github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4= +github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20= +github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-bindata/go-bindata v0.0.0-20181025070752-41975c0ccc30/go.mod h1:xK8Dsgwmeed+BBsSy2XTopBn/8uK2HWuGSnA11C3Joo= -github.com/go-kit/kit v0.6.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-kit/kit v0.10.0 h1:dXFJfIHVvUcpSgDOV+Ne6t7jXri8Tfv2uOLHUZ2XNuo= +github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= -github.com/go-playground/locales v0.12.1 h1:2FITxuFt/xuCNP1Acdhv62OzaCiviiE4kotfhkmOqEc= -github.com/go-playground/locales v0.12.1/go.mod h1:IUMDtCfWo/w/mtMfIE/IG2K+Ey3ygWanZIBtBW0W2TM= -github.com/go-playground/universal-translator v0.16.0 h1:X++omBR/4cE2MNg91AoC3rmGrCjJ8eAeUP/K/EKx4DM= -github.com/go-playground/universal-translator v0.16.0/go.mod h1:1AnU7NaIRDWWzGEKwgtJRd2xk99HeFyHw3yid4rvQIY= +github.com/go-logfmt/logfmt v0.5.0 h1:TrB8swr/68K7m9CcGut2g3UOihhbcbiMAYiuTXdEih4= +github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= +github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= +github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= +github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= +github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= +github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= +github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= +github.com/go-playground/validator/v10 v10.2.0 h1:KgJ0snyC2R9VXYN2rneOtQcw5aHQB1Vv0sFl1UcHBOY= +github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI= +github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= +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/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= -github.com/gogo/protobuf v1.3.0 h1:G8O7TerXerS4F6sx9OV7/nRfJdnXgHZu/S/7F2SN+UE= -github.com/gogo/protobuf v1.3.0/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= +github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls= +github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= 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/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.3.1-0.20190508161146-9fa652df1129/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= +github.com/golang/mock v1.3.1 h1:qGJ6qTW+x6xX/my+8YUVl4WNpX9B7+/l2tRsHGZ7f2s= github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= +github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= 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 h1:87PNWwrRvUSnqS4dlcBU/ftvOIBep4sYuBLlh6rX2wk= +github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ= +github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= 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= +github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/google/uuid v0.0.0-20161128191214-064e2069ce9c/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/gorilla/mux v1.7.0/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= +github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= +github.com/gorilla/mux v1.7.3 h1:gnP5JzjVOuiZD07fKKToCAOjS0yOpj/qPETTXCCS6hw= github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= -github.com/gorilla/websocket v1.2.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM= +github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= +github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= +github.com/grpc-ecosystem/go-grpc-middleware v1.2.0/go.mod h1:mJzapYve32yjrKlk9GbyCZHuPgZsrbyIbyKhSzOpg6s= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= +github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= +github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c h1:6rhixN/i8ZofjG1Y75iExal34USq5p+wiN1tpie8IrU= +github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NMPJylDgVpX0MLRlPy15sqSwOFv/U1GZ2m21JhFfek0= +github.com/gtank/merlin v0.1.1-0.20191105220539-8318aed1a79f h1:8N8XWLZelZNibkhM1FuF+3Ad3YIbgirjdMiVA0eUkaM= +github.com/gtank/merlin v0.1.1-0.20191105220539-8318aed1a79f/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s= +github.com/gtank/ristretto255 v0.1.2 h1:JEqUCPA1NvLq5DwYtuzigd7ss8fwbYay9fi4/5uMzcc= +github.com/gtank/ristretto255 v0.1.2/go.mod h1:Ph5OpO6c7xKUGROZfWVLiJf9icMDwUeIvY4OmlYW69o= +github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE= +github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= +github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= +github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= +github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= +github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= +github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= +github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= +github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= +github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc= +github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= +github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= +github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= +github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= +github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= +github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= +github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/huandu/xstrings v1.0.0/go.mod h1:4qWG/gcEcfX4z/mBDHJ++3ReCw9ibxbsNJbcucJdbSo= github.com/huandu/xstrings v1.2.0/go.mod h1:DvyZB1rfVYsBIigL8HwpZgxHwXozlTgGqn63UyNX5k4= +github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= +github.com/imdario/mergo v0.3.4/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= github.com/imdario/mergo v0.3.7/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= +github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= +github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= +github.com/jmhodges/levigo v1.0.0 h1:q5EC36kV79HWeTBWsod3mG11EgStG3qArTKcvlksN1U= github.com/jmhodges/levigo v1.0.0/go.mod h1:Q6Qx+uH3RAqyK4rFQroq9RL7mdkABMcfhEI+nNuzMJQ= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= +github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= -github.com/kelseyhightower/envconfig v1.3.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg= +github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d h1:Z+RDyXzjKE0i2sTjZ/b1uxiGtPhFy34Ou/Tk0qwN0kM= +github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d/go.mod h1:JJNrCn9otv/2QP4D7SMJBgaleKpOf66PnW6F5WGNRIc= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= 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 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s= github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/leodido/go-urn v1.1.0 h1:Sm1gr51B1kKyfD2BlRcLSiEkffoG96g6TPv6eRoEiB8= -github.com/leodido/go-urn v1.1.0/go.mod h1:+cyI34gQWZcE1eQU7NVgKkkzdXDQHr1dBMtdAPozLkw= -github.com/libp2p/go-buffer-pool v0.0.1/go.mod h1:xtyIz9PMobb13WaxR6Zo1Pd1zXJKYg0a8KiIvDp3TzQ= +github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= +github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= +github.com/libp2p/go-buffer-pool v0.0.2 h1:QNK2iAFa8gjAe1SPz6mHSMuCcjs+X1wlHzeOSqcmlfs= github.com/libp2p/go-buffer-pool v0.0.2/go.mod h1:MvaB6xw5vOrDl8rYZGLFdKAuk/hRoRZd1Vi32+RXyFM= -github.com/lyft/protoc-gen-validate v0.1.0/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= +github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= +github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= +github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= +github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4= github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= -github.com/mattn/go-isatty v0.0.6/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= +github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= +github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= +github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= +github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/mesg-foundation/engine v0.15.0 h1:EbZbYrDafGd0wkazQvRjM2qZ4BYRVH+Oun9OFLmol+s= -github.com/mesg-foundation/engine v0.15.0/go.mod h1:YMr8ecDOi7kxUKweWMUqBG4/5HzMQxBO8675ccNgAo8= +github.com/mesg-foundation/engine v0.18.4-0.20200402055258-ff1bb6a08721 h1:phDRjfATdCfyvreTyk45L5TiXFLbG0W9TzYkgrOyWuM= +github.com/mesg-foundation/engine v0.18.4-0.20200402055258-ff1bb6a08721/go.mod h1:TjchQ1Y4OqVkOA3nJ3pJ8Pagxl360dmqzH+PhyR8NLE= +github.com/mesg-foundation/engine v0.18.4-0.20200406080522-ff6a40ead454 h1:GVwuKVMa3SdPn67i7R8ZI8KQB0w3wd4b6z1rB5eOtwc= +github.com/mesg-foundation/engine v0.18.4-0.20200406080522-ff6a40ead454/go.mod h1:TjchQ1Y4OqVkOA3nJ3pJ8Pagxl360dmqzH+PhyR8NLE= +github.com/mesg-foundation/engine v0.18.4-0.20200406094054-953626b372e7 h1:IJcitSp6L2bUJ4dQ54GyB3whPXQ+AC9PKfEGum9nHcU= +github.com/mesg-foundation/engine v0.18.4-0.20200406094054-953626b372e7/go.mod h1:TjchQ1Y4OqVkOA3nJ3pJ8Pagxl360dmqzH+PhyR8NLE= +github.com/mesg-foundation/engine v0.18.4-0.20200406120519-06c3e44902e9 h1:LXD6PywTNfGZsDytVDGfHcDbqEWCh3RhQztGqaJyxnA= +github.com/mesg-foundation/engine v0.18.4-0.20200406120519-06c3e44902e9/go.mod h1:TjchQ1Y4OqVkOA3nJ3pJ8Pagxl360dmqzH+PhyR8NLE= +github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= +github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643 h1:hLDRPB66XQT/8+wG9WsDpiCvZf1yKO7sz7scAjSlBa0= +github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643/go.mod h1:43+3pMjjKimDBf5Kr4ZFNGbLql1zKkbImw+fZbw3geM= +github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= +github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db/go.mod h1:l0dey0ia/Uv7NcFFVbCLtqEBQbrT4OCwCSKTEv6enCw= +github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= +github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= +github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= +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/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/mr-tron/base58 v1.1.1 h1:OJIdWOWYe2l5PQNgimGtuwHY8nDskvJ5vvs//YnzRLs= -github.com/mr-tron/base58 v1.1.1/go.mod h1:xcD2VGqlgYjBdcBLw+TuYLr8afG+Hj8g2eTVqeSzSU8= +github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= +github.com/mr-tron/base58 v1.1.3 h1:v+sk57XuaCKGXpWtVBX8YJzO7hMGx4Aajh4TQbdEFdc= +github.com/mr-tron/base58 v1.1.3/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/mwitkow/go-proto-validators v0.0.0-20180403085117-0950a7990007/go.mod h1:m2XC9Qq0AlmmVksL6FktJCdTYyLk7V3fKyp0sl1yWQo= github.com/mwitkow/go-proto-validators v0.0.0-20190212092829-1f388280e944/go.mod h1:m2XC9Qq0AlmmVksL6FktJCdTYyLk7V3fKyp0sl1yWQo= +github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg= +github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL6eU= +github.com/nats-io/nats-server/v2 v2.1.2/go.mod h1:Afk+wRZqkMQs/p45uXdrVLuab3gwv3Z8C4HTBu8GD/k= +github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzEE/Zbp4w= +github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= +github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= +github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= +github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= +github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= +github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.8.0 h1:VkHVNpR4iVnU8XQR6DBm8BqYjN7CRzw+xKUbVVbbW9w= github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/onsi/gomega v1.5.0 h1:izbySO9zDPmjJ8rDjLvkA2zJHIo+HkYXHnf7eN7SSyo= github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= github.com/opencontainers/runc v0.1.1/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U= +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= +github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= +github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5/go.mod h1:/wsWhb9smxSfWAKL3wpBW7V8scJMt8N8gnaMCS9E/cA= +github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw= +github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= +github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= +github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM= +github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= -github.com/pelletier/go-toml v1.4.0/go.mod h1:PN7xzY2wHTK0K9p34ErDQMlFxa51Fk0OUruD3k1mMwo= +github.com/pelletier/go-toml v1.6.0 h1:aetoXYr0Tv7xRU/V4B4IZJ2QcbtMUFoNb3ORp7TzIK4= +github.com/pelletier/go-toml v1.6.0/go.mod h1:5N711Q9dKgbdkxHL+MEfF31hpT7l0S0s/t2kKREewys= +github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= +github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= +github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA= +github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= -github.com/prometheus/client_golang v0.9.2/go.mod h1:OsXs2jCmiKlQ1lTBmv21f2mNfw4xf/QclQDMrYNZzcM= +github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs= github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= -github.com/prometheus/client_golang v1.1.0/go.mod h1:I1FGZT9+L76gKKOs5djB6ezCbFQP1xR9D75/vuwEF3g= +github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= +github.com/prometheus/client_golang v1.5.0 h1:Ctq0iGpCmr3jeP77kbF2UxgvRwzWWz+4Bh9/vJTyg1A= +github.com/prometheus/client_golang v1.5.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/common v0.0.0-20181020173914-7e9e6cabbd39/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= +github.com/prometheus/client_model v0.1.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M= +github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= -github.com/prometheus/common v0.0.0-20181126121408-4724e9255275/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -github.com/prometheus/common v0.6.0/go.mod h1:eBmuwkDJBwy6iBfxCBob6t6dR6ENT/y+J+Zk0j9GMYc= +github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA= +github.com/prometheus/common v0.9.1 h1:KOMtN28tlbam3/7ZKEYKHhKoJZYYj3gMH4uc62x7X7U= +github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.0-20190227231451-bbced9601137/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +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= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/procfs v0.0.3/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ= +github.com/prometheus/procfs v0.0.8 h1:+fpWZdT24pJBiqJdAwYBjPSk+5YmQzYNPYzQsdzLkt8= +github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= -github.com/pseudomuto/protoc-gen-doc v1.3.0/go.mod h1:fwtQAY9erXp3mC92O8OTECnDlJT2r0Ff4KSEKbGEmy0= +github.com/pseudomuto/protoc-gen-doc v1.3.1/go.mod h1:y5+P6n3iGrbKG+9O04V5ld71in3v/bX88wUwgt+U8EA= github.com/pseudomuto/protokit v0.2.0/go.mod h1:2PdH30hxVHsup8KpBTOXTBeMVhJZVio3Q8ViKSAXT0Q= -github.com/rakyll/statik v0.1.5/go.mod h1:OEi9wJV/fMUAGx1eNjq75DKDsJVuEv1U0oYdX6GX8Zs= github.com/rakyll/statik v0.1.6/go.mod h1:OEi9wJV/fMUAGx1eNjq75DKDsJVuEv1U0oYdX6GX8Zs= -github.com/rcrowley/go-metrics v0.0.0-20180503174638-e2704e165165/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= +github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= +github.com/rcrowley/go-metrics v0.0.0-20190706150252-9beb055b7962 h1:eUm8ma4+yPknhXtkYlWh3tMkE6gBjXZToDned9s2gbQ= github.com/rcrowley/go-metrics v0.0.0-20190706150252-9beb055b7962/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= -github.com/rs/cors v1.6.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik= github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= -github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= +github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= +github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= +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.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +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= +github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/snikch/goodman v0.0.0-20171125024755-10e37e294daa/go.mod h1:oJyF+mSPHbB5mVY2iO9KV3pTt/QbIkGaO8gQ2WrDbP4= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= +github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/afero v1.2.1/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= +github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= +github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cobra v0.0.1/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= -github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= +github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= +github.com/spf13/cobra v0.0.6 h1:breEStsVwemnKh2/s6gMvSdMEkwW0sK8vGStnlVBMCs= +github.com/spf13/cobra v0.0.6/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= 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/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/spf13/viper v1.0.0/go.mod h1:A8kyI5cUJhb8N+3pkfONlcEcZbueH6nhAm0Fq7SrnBM= -github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= +github.com/spf13/viper v1.6.2 h1:7aKfF+e8/k68gda3LOjo5RxiUqddoFxVq4BKBPrxk5E= +github.com/spf13/viper v1.6.2/go.mod h1:t3iDnF5Jlj76alVNuyFBk5oUMCvsrkbvZK0WQdfDi5k= +github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= +github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= +github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= +github.com/stretchr/testify v0.0.0-20170130113145-4d4bfba8f1d1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= 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 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/syndtr/goleveldb v1.0.1-0.20190318030020-c3a204f8e965/go.mod h1:9OrXJhf154huy1nPWmuSrkgjPUtUNhA+Zmy+6AESzuA= +github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= +github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= +github.com/syndtr/goleveldb v1.0.1-0.20190923125748-758128399b1d h1:gZZadD8H+fF+n9CmNhYL1Y0dJB+kLOmKd7FbPJLeGHs= +github.com/syndtr/goleveldb v1.0.1-0.20190923125748-758128399b1d/go.mod h1:9OrXJhf154huy1nPWmuSrkgjPUtUNhA+Zmy+6AESzuA= +github.com/tcnksm/ghr v0.13.0/go.mod h1:tcp6tzbRYE0LqFSG7ykXP/BVG1/2BkX6aIn9FFV1mIQ= +github.com/tcnksm/go-gitconfig v0.1.2/go.mod h1:/8EhP4H7oJZdIPyT+/UIsG87kTzrzM4UsLGSItWYCpE= +github.com/tcnksm/go-latest v0.0.0-20170313132115-e3007ae9052e/go.mod h1:d7u6HkTYKSv5m6MCKkOQlHwaShTMl3HjqSGW3XtVhXM= +github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c h1:g+WoO5jjkqGAzHWCjJB1zZfXPIAaDpzXIEJ0eS6B5Ok= +github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c/go.mod h1:ahpPrc7HpcfEWDQRZEmnXMzHY03mLDYMCxeDzy46i+8= +github.com/tendermint/btcd v0.1.1 h1:0VcxPfflS2zZ3RiOAHkBiFUcPvbtRj5O7zHmcJWHV7s= github.com/tendermint/btcd v0.1.1/go.mod h1:DC6/m53jtQzr/NFmMNEu0rxf18/ktVoVtMrnDD5pN+U= -github.com/tendermint/crypto v0.0.0-20180820045704-3764759f34a5/go.mod h1:z4YtwM70uOnk8h0pjJYlj3zdYwi9l03By6iAIF5j/Pk= +github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 h1:hqAk8riJvK4RMWx1aInLzndwxKalgi5rTqgfXxOxbEI= +github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15/go.mod h1:z4YtwM70uOnk8h0pjJYlj3zdYwi9l03By6iAIF5j/Pk= github.com/tendermint/go-amino v0.14.1/go.mod h1:i/UKE5Uocn+argJJBb12qTZsCDBcAYMbR92AaJVmKso= -github.com/tendermint/go-amino v0.15.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= -github.com/tendermint/iavl v0.12.4/go.mod h1:8LHakzt8/0G3/I8FUU0ReNx98S/EP6eyPJkAUvEXT/o= -github.com/tendermint/tendermint v0.32.1/go.mod h1:jmPDAKuNkev9793/ivn/fTBnfpA9mGBww8MPRNPNxnU= -github.com/tendermint/tendermint v0.32.2/go.mod h1:NwMyx58S8VJ7tEpFKqRVlVWKO9N9zjTHu+Dx96VsnOE= -github.com/tendermint/tendermint v0.32.3/go.mod h1:ZK2c29jl1QRYznIRyRWRDsmm1yvtPzBRT00x4t1JToY= -github.com/tendermint/tm-db v0.1.1/go.mod h1:0cPKWu2Mou3IlxecH+MEUSYc1Ch537alLe6CpFrKzgw= +github.com/tendermint/go-amino v0.15.1 h1:D2uk35eT4iTsvJd9jWIetzthE5C0/k2QmMFkCN+4JgQ= +github.com/tendermint/go-amino v0.15.1/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= +github.com/tendermint/iavl v0.13.2 h1:O1m08/Ciy53l9IYmf75uIRVvrNsfjEbre8u/yCu/oqk= +github.com/tendermint/iavl v0.13.2/go.mod h1:vE1u0XAGXYjHykd4BLp8p/yivrw2PF1TuoljBcsQoGA= +github.com/tendermint/tendermint v0.33.2 h1:NzvRMTuXJxqSsFed2J7uHmMU5N1CVzSpfi3nCc882KY= +github.com/tendermint/tendermint v0.33.2/go.mod h1:25DqB7YvV1tN3tHsjWoc2vFtlwICfrub9XO6UBO+4xk= +github.com/tendermint/tm-db v0.4.1/go.mod h1:JsJ6qzYkCGiGwm5GHl/H5GLI9XLb6qZX7PRe425dHAY= +github.com/tendermint/tm-db v0.5.0 h1:qtM5UTr1dlRnHtDY6y7MZO5Di8XAE2j3lc/pCnKJ5hQ= +github.com/tendermint/tm-db v0.5.0/go.mod h1:lSq7q5WRR/njf1LnhiZ/lIJHk2S8Y1Zyq5oP/3o9C2U= +github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= -github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= -github.com/vektra/mockery v0.0.0-20181123154057-e78b021dcbb5/go.mod h1:ppEjwdhyy7Y31EnHRDm1JkChoC7LXIJ7Ex0VYLWtZtQ= +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/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/zondax/hid v0.9.0 h1:eiT3P6vNxAEVxXMw66eZUAAnU2zD33JBkfG/EnfAKl8= github.com/zondax/hid v0.9.0/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= +go.etcd.io/bbolt v1.3.3 h1:MUGmc65QhB3pIlaQ5bB4LwqSj6GIonVJXpZiaKNyaKk= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= +go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= +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.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= +go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= +go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= +go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20180501155221-613d6eafa307/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20190228161510-8dd112bcdc25/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 h1:HuIa8hRrWRSrqYzx1qI49NNxhdi2PrY7gxVSq1JjLDc= golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413 h1:ULYEB3JvPRE/IfO+9uO7vKV/xzVTO7XPAwm8xbf4w2g= +golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7 h1:fHDIZ2oxGnUZRN6WgWFCbYBjH9uqVPRCUVUDhs0wnbA= golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200301022130-244492dfa37a h1:GuSPYbZzB5/dcLNCwLQLsg3obCJtX9IJhpXkvY7kzk0= +golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190412183630-56d357773e84/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/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190801041406-cbf593c0f2f3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a h1:aYOabOQFp6Vj6W1F80affTUvO9UxmJRx8K0gsfABByQ= -golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190712062909-fae7ac547cb7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +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-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527 h1:uYVVQ9WP/Ds2ROhcaGPeIdVq0RIXVLwsHlnvJ+cT1So= +golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20181112210238-4b1f3b6b1646/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190813142322-97f12d73768f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20181029155118-b69ba1387ce2/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64 h1:iKtrH9Y8mcbADOP0YFaEMth7OfuHY9xHOwNj4znpM1A= -google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/grpc v1.13.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= +google.golang.org/genproto v0.0.0-20181107211654-5fc9ac540362/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190530194941-fb225487d101/go.mod h1:z3L6/3dTEVtUr6QSP8miRzeRqwQOioJ9I66odjN4I7s= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55 h1:gSJIx1SDwno+2ElGhA4+qG2zF97qiUzTM+rQ0klBOcE= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM= +google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= -google.golang.org/grpc v1.22.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.22.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.24.0 h1:vb/1TCsVn3DcJlQ0Gs1yB1pKI6Do2/QNwxdKqmc/b0s= -google.golang.org/grpc v1.24.0/go.mod h1:XDChyiUovWa60DnaeDeZmSW86xtLtjtZbwvSiRnRtcA= +google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.28.0 h1:bO/TA4OxCOummhSf10siHuG7vJOiwh7SpRpFZDkOgl4= +google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= -gopkg.in/go-playground/validator.v9 v9.29.1 h1:SvGtYmN60a5CVKTOzMSyfzWDeZRxRuGvRQyEAKbw1xc= -gopkg.in/go-playground/validator.v9 v9.29.1/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ= +gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= +gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno= +gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= +honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= +sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= +sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= diff --git a/e2e/testdata/test-complex-service/main.go b/e2e/testdata/test-complex-service/main.go index 8b56e5c6e..74de23745 100644 --- a/e2e/testdata/test-complex-service/main.go +++ b/e2e/testdata/test-complex-service/main.go @@ -11,66 +11,82 @@ import ( "github.com/mesg-foundation/engine/ext/xsignal" "github.com/mesg-foundation/engine/hash" - pb "github.com/mesg-foundation/engine/protobuf/api" + "github.com/mesg-foundation/engine/server/grpc/orchestrator" + "github.com/mesg-foundation/engine/server/grpc/runner" "google.golang.org/grpc" "google.golang.org/grpc/keepalive" ) const ( // env variables for configure mesg client. - envMesgEndpoint = "MESG_ENDPOINT" - envMesgInstanceHash = "MESG_INSTANCE_HASH" + envMesgEndpoint = "MESG_ENDPOINT" + envMesgServiceHash = "MESG_SERVICE_HASH" + envMesgEnvHash = "MESG_ENV_HASH" + envMesgRegisterSignature = "MESG_REGISTER_SIGNATURE" ) -// Client is a client to connect to all mesg exposed API. -type Client struct { - // all clients registered by mesg server. - pb.EventClient - pb.ExecutionClient - - // instance hash that could be used in api calls. - InstanceHash hash.Hash -} - -// New creates a new client from env variables supplied by mesg engine. -func New() (*Client, error) { +// register +func register() (string, error) { endpoint := os.Getenv(envMesgEndpoint) if endpoint == "" { - return nil, fmt.Errorf("client: mesg server address env(%s) is empty", envMesgEndpoint) + return "", fmt.Errorf("env %q is empty", envMesgEndpoint) + } + + conn, err := grpc.DialContext(context.Background(), endpoint, grpc.WithInsecure()) + if err != nil { + return "", err + } + client := orchestrator.NewRunnerClient(conn) + + serviceHash, err := hash.Decode(os.Getenv(envMesgServiceHash)) + if err != nil { + return "", err } + envHash, err := hash.Decode(os.Getenv(envMesgEnvHash)) + if err != nil { + return "", err + } + signature := os.Getenv(envMesgRegisterSignature) - instanceHash, err := hash.Decode(os.Getenv(envMesgInstanceHash)) + resp, err := client.Register(context.Background(), &orchestrator.RunnerRegisterRequest{ + ServiceHash: serviceHash, + EnvHash: envHash, + }, grpc.PerRPCCredentials(&signCred{signature})) if err != nil { - return nil, fmt.Errorf("client: error with mesg's instance hash env(%s): %s", envMesgInstanceHash, err.Error()) + return "", err } + return resp.Token, nil +} +func newClient(token string) (runner.RunnerClient, error) { + endpoint := os.Getenv(envMesgEndpoint) + if endpoint == "" { + return nil, fmt.Errorf("env %q is empty", envMesgEndpoint) + } + + // runner client dialoptions := []grpc.DialOption{ // Keep alive prevents Docker network to drop TCP idle connections after 15 minutes. // See: https://forum.mesg.com/t/solution-summary-for-docker-dropping-connections-after-15-min/246 grpc.WithKeepaliveParams(keepalive.ClientParameters{ Time: 5 * time.Minute, // 5 minutes is the minimun time of gRPC enforcement policy. }), - grpc.WithTimeout(10 * time.Second), grpc.WithInsecure(), + grpc.WithPerRPCCredentials(&tokenCred{token}), } - conn, err := grpc.DialContext(context.Background(), endpoint, dialoptions...) if err != nil { - return nil, fmt.Errorf("client: connection error: %s", err) + return nil, fmt.Errorf("connection error: %s", err) } - return &Client{ - ExecutionClient: pb.NewExecutionClient(conn), - EventClient: pb.NewEventClient(conn), - InstanceHash: instanceHash, - }, nil + return runner.NewRunnerClient(conn), nil } -// SendEvent creates a new event. -func (c *Client) SendEvent(key string) { - if _, err := c.EventClient.Create(context.Background(), &pb.CreateEventRequest{ - InstanceHash: c.InstanceHash, - Key: key, +// sendEvent creates a new event. +func sendEvent(client runner.RunnerClient, token string, key string) { + log.Println("sending event:", key) + if _, err := client.Event(context.Background(), &runner.EventRequest{ + Key: key, }); err != nil { log.Fatal(err) } @@ -79,7 +95,13 @@ func (c *Client) SendEvent(key string) { func main() { log.SetFlags(log.LstdFlags | log.Lshortfile) - client, err := New() + token, err := register() + if err != nil { + log.Fatal(err) + } + log.Printf("registered with token %s\n", token) + + client, err := newClient(token) if err != nil { log.Fatal(err) } @@ -88,39 +110,73 @@ func main() { // give some time to nginx to start time.Sleep(10 * time.Second) - client.SendEvent("test_service_ready") + sendEvent(client, token, "service_ready") // check env default value if os.Getenv("ENVA") == "do_not_override" { - client.SendEvent("read_env_ok") + sendEvent(client, token, "read_env_ok") } else { - client.SendEvent("read_env_error") + sendEvent(client, token, "read_env_error") } // check env override value if os.Getenv("ENVB") == "is_override" { - client.SendEvent("read_env_override_ok") + sendEvent(client, token, "read_env_override_ok") } else { - client.SendEvent("read_env_override_error") + sendEvent(client, token, "read_env_override_error") } if err := ioutil.WriteFile("/volume/test/test.txt", []byte("foo"), 0644); err == nil { - client.SendEvent("access_volumes_ok") + sendEvent(client, token, "access_volumes_ok") } else { - client.SendEvent("access_volumes_error") + sendEvent(client, token, "access_volumes_error") } if _, err := http.Get("http://nginx:80/"); err == nil { - client.SendEvent("resolve_dependence_ok") + sendEvent(client, token, "resolve_dependence_ok") } else { - client.SendEvent("resolve_dependence_error") + sendEvent(client, token, "resolve_dependence_error") } if content, err := ioutil.ReadFile("/etc/nginx/nginx.conf"); len(content) > 0 && err == nil { - client.SendEvent("access_volumes_from_ok") + sendEvent(client, token, "access_volumes_from_ok") } else { - client.SendEvent("access_volumes_from_error") + sendEvent(client, token, "access_volumes_from_error") } <-xsignal.WaitForInterrupt() } + +// tokenCred is a structure that manage a token. +type tokenCred struct { + token string +} + +// GetRequestMetadata returns the metadata for the request. +func (c *tokenCred) GetRequestMetadata(context.Context, ...string) (map[string]string, error) { + return map[string]string{ + runner.CredentialToken: c.token, + }, nil +} + +// RequireTransportSecurity tells if the transport should be secured. +func (c *tokenCred) RequireTransportSecurity() bool { + return false +} + +// signCred is a structure that manage a token. +type signCred struct { + signature string +} + +// GetRequestMetadata returns the metadata for the request. +func (c *signCred) GetRequestMetadata(context.Context, ...string) (map[string]string, error) { + return map[string]string{ + orchestrator.RequestSignature: c.signature, + }, nil +} + +// RequireTransportSecurity tells if the transport should be secured. +func (c *signCred) RequireTransportSecurity() bool { + return false +} diff --git a/e2e/testdata/test-complex-service/mesg.yml b/e2e/testdata/test-complex-service/mesg.yml index f66e5687f..b6dcea98e 100644 --- a/e2e/testdata/test-complex-service/mesg.yml +++ b/e2e/testdata/test-complex-service/mesg.yml @@ -17,7 +17,7 @@ dependencies: - /etc/nginx events: - test_service_ready: + service_ready: read_env_ok: read_env_error: diff --git a/e2e/testdata/test-service/go.mod b/e2e/testdata/test-service/go.mod index be8630d87..25d66f1a8 100644 --- a/e2e/testdata/test-service/go.mod +++ b/e2e/testdata/test-service/go.mod @@ -3,6 +3,6 @@ module main go 1.13 require ( - github.com/mesg-foundation/engine v0.15.1-0.20191119102502-3216db2fdeb9 - google.golang.org/grpc v1.24.0 + github.com/mesg-foundation/engine v0.18.4-0.20200406120519-06c3e44902e9 + google.golang.org/grpc v1.28.0 ) diff --git a/e2e/testdata/test-service/go.sum b/e2e/testdata/test-service/go.sum index c67b2de47..c05c54f7c 100644 --- a/e2e/testdata/test-service/go.sum +++ b/e2e/testdata/test-service/go.sum @@ -1,133 +1,293 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/99designs/keyring v1.1.3 h1:mEV3iyZWjkxQ7R8ia8GcG97vCX5zQQ7n4o8R2BylwQY= +github.com/99designs/keyring v1.1.3/go.mod h1:657DQuMrBZRtuL/voxVyiyb6zpMehlm5vLB9Qwrv904= +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/ChainSafe/go-schnorrkel v0.0.0-20200102211924-4bcbc698314f h1:4O1om+UVU+Hfcihr1timk8YNXHxzZWgCo7ofnrZRApw= +github.com/ChainSafe/go-schnorrkel v0.0.0-20200102211924-4bcbc698314f/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4= +github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= github.com/Masterminds/semver v1.4.2/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= +github.com/Masterminds/sprig v2.15.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o= github.com/Masterminds/sprig v2.20.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o= +github.com/Microsoft/go-winio v0.4.12 h1:xAfWHN1IrQ0NJ9TBC0KBZoqLjzDTr1ML+4MywiUOryc= github.com/Microsoft/go-winio v0.4.12/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA= +github.com/Microsoft/hcsshim v0.8.6 h1:ZfF0+zZeYdzMIVMZHKtDKJvLHj76XCuVae/jNkjj0IA= github.com/Microsoft/hcsshim v0.8.6/go.mod h1:Op3hHsoHPAvb6lceZHDtd9OkTew38wNoXnJs8iY7rUg= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= +github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= +github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= +github.com/Songmu/retry v0.1.0/go.mod h1:7sXIW7eseB9fq0FUvigRcQMVLR9tuHI0Scok+rkpAuA= +github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrdtl/UvroE= github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= -github.com/Workiva/go-datastructures v1.0.50/go.mod h1:Z+F2Rca0qCsVYDS8z7bAGm8f3UkzuWYS/oBZz5a7VVA= +github.com/Workiva/go-datastructures v1.0.52/go.mod h1:Z+F2Rca0qCsVYDS8z7bAGm8f3UkzuWYS/oBZz5a7VVA= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= +github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/aokoli/goutils v1.0.1/go.mod h1:SijmP0QR8LtwsmDs8Yii5Z/S4trXFGFC2oO5g9DP+DQ= +github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= +github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= +github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= +github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= +github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A= +github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU= +github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= +github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= +github.com/bartekn/go-bip39 v0.0.0-20171116152956-a05967ea095d h1:1aAija9gr0Hyv4KfQcRcwlmFIrhkDmIj2dz5bkg/s/8= github.com/bartekn/go-bip39 v0.0.0-20171116152956-a05967ea095d/go.mod h1:icNx/6QdFblhsEjZehARqbNumymUT/ydwlLojFdv7Sk= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= +github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/btcsuite/btcd v0.0.0-20190115013929-ed77733ec07d/go.mod h1:d3C0AkH6BRcvO8T0UEPu53cnw4IbV63x1bEjildYhO0= +github.com/btcsuite/btcd v0.0.0-20190807005414-4063feeff79a h1:We35J+0yvVFrEXbtViYUW8H/wNOhqjIF3PsrW4yYmGw= github.com/btcsuite/btcd v0.0.0-20190807005414-4063feeff79a/go.mod h1:3J08xEfcugPacsc34/LKRU2yO7YmuT8yt28J8k2+rrI= github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= github.com/btcsuite/btcutil v0.0.0-20180706230648-ab6388e0c60a/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= +github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d h1:yJzD/yFppdVCf6ApMkVy8cUxV0XrxdP9rVf6D87/Mng= github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg= github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVaaLLH7j4eDXPRvw78tMflu7Ie2bzYOH4Y8rRKBY= github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= +github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ= +github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +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/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= +github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= +github.com/containerd/containerd v1.3.0 h1:xjvXQWABwS2uiv3TWgQt5Uth60Gu86LTGZXMJkjc7rY= github.com/containerd/containerd v1.3.0/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA= +github.com/containerd/continuity v0.0.0-20190426062206-aaeac12a7ffc h1:TP+534wVlf61smEIq1nwLLAjQVEK2EADoW3CX9AuT+8= github.com/containerd/continuity v0.0.0-20190426062206-aaeac12a7ffc/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y= 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/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.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/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.37.3/go.mod h1:dAwYeOJ5ybRZg/OdRfiDy8q/cZq/GXQp9ZHAtz0E74I= -github.com/cosmos/go-bip39 v0.0.0-20180618194314-52158e4697b8/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= +github.com/cosmos/cosmos-sdk v0.38.2 h1:IeDZxxTgTMGJRZsV4s482O2gxjhLzToX5Zy1uwyasDs= +github.com/cosmos/cosmos-sdk v0.38.2/go.mod h1:p27t20Rw7qRZ0Dj7kq2a+rIwBtbk3k05/tF1sHPPw5I= +github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d h1:49RLWk1j44Xu4fjHb6JFYmeUnDORVwHNkDxaQ0ctCVU= github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= -github.com/cosmos/ledger-cosmos-go v0.10.3/go.mod h1:J8//BsAGTo3OC/vDLjMRFLW6q0WAaXvHnVc7ZmE8iUY= +github.com/cosmos/ledger-cosmos-go v0.11.1 h1:9JIYsGnXP613pb2vPjFeMMjBI5lEDsEaF6oYorTy6J4= +github.com/cosmos/ledger-cosmos-go v0.11.1/go.mod h1:J8//BsAGTo3OC/vDLjMRFLW6q0WAaXvHnVc7ZmE8iUY= +github.com/cosmos/ledger-go v0.9.2 h1:Nnao/dLwaVTk1Q5U9THldpUMMXU94BOTWPddSmVB6pI= github.com/cosmos/ledger-go v0.9.2/go.mod h1:oZJ2hHAZROdlHiwTg4t7kP+GKIIkBT+o6c9QWFanOyI= -github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= +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/cskr/pubsub v1.0.2 h1:vlOzMhl6PFn60gRlTQQsIfVwaPB/B/8MziK8FhEPt/0= github.com/cskr/pubsub v1.0.2/go.mod h1:/8MzYXk/NJAz782G8RPkFzXTZVu63VotefPnR9TIRis= +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-20161028175848-04cdfd42973b/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 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/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= +github.com/docker/cli v0.0.0-20191011045415-5d85cdacd257 h1:CtCb3w4JnCpPuhlQ1sot/7HsKo/Y+emcB8PW4FxV22s= github.com/docker/cli v0.0.0-20191011045415-5d85cdacd257/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= +github.com/docker/distribution v2.7.1+incompatible h1:a5mlkVzth6W5A4fOsS3D2EO5BUmsJpcB+cRlLU7cSug= github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= +github.com/docker/docker v1.4.2-0.20191006173954-0abbb9e4ebf1 h1:FlyqqgbnhlpvsNPqXTdzxngEz/O0JxdMdb0AkfSQiOc= github.com/docker/docker v1.4.2-0.20191006173954-0abbb9e4ebf1/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/etcd-io/bbolt v1.3.2/go.mod h1:ZF2nL25h33cCyBtcyWeZ2/I3HQOfTP+0PIEvHjkjCrw= +github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/dvsekhvalnov/jose2go v0.0.0-20180829124132-7f401d37b68a h1:mq+R6XEM6lJX5VlLyZIrUSP8tSuJp82xTK89hvBwJbU= +github.com/dvsekhvalnov/jose2go v0.0.0-20180829124132-7f401d37b68a/go.mod h1:7BvyPhdbLxMXIYTFPLsyJRFMsKmOZnQmzh6Gb+uquuM= +github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= +github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= +github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= +github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= +github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/protoc-gen-validate v0.0.14/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/etcd-io/bbolt v1.3.3 h1:gSJmxrs37LgTqR/oyJBWok6k6SvXEUerFTbltIhXkBM= github.com/etcd-io/bbolt v1.3.3/go.mod h1:ZF2nL25h33cCyBtcyWeZ2/I3HQOfTP+0PIEvHjkjCrw= +github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51 h1:0JZ+dUmQeA8IIVUMzysrX4/AKuQwWhV2dYQuPZdvdSQ= github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51/go.mod h1:Yg+htXGokKKdzcwhuNDwVvN+uBxDGXJ7G/VN1d8fa64= +github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 h1:JWuenKqqX8nojtoVVWjGfOF9635RETekkoH6Cc9SX0A= github.com/facebookgo/stack v0.0.0-20160209184415-751773369052/go.mod h1:UbMTZqLaRiH3MsBH8va0n7s1pQYcu3uTb8G4tygF4Zg= +github.com/facebookgo/subset v0.0.0-20150612182917-8dac2c3c4870 h1:E2s37DuLxFhQDg5gKsWoLBOB0n+ZW8s599zru8FJ2/Y= github.com/facebookgo/subset v0.0.0-20150612182917-8dac2c3c4870/go.mod h1:5tD+neXqOorC30/tWg0LCSkrqj/AR6gu8yY8/fpw1q0= -github.com/fortytw2/leaktest v1.2.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= +github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= +github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4= +github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20= +github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-bindata/go-bindata v0.0.0-20181025070752-41975c0ccc30/go.mod h1:xK8Dsgwmeed+BBsSy2XTopBn/8uK2HWuGSnA11C3Joo= -github.com/go-kit/kit v0.6.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-kit/kit v0.10.0 h1:dXFJfIHVvUcpSgDOV+Ne6t7jXri8Tfv2uOLHUZ2XNuo= +github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= +github.com/go-logfmt/logfmt v0.5.0 h1:TrB8swr/68K7m9CcGut2g3UOihhbcbiMAYiuTXdEih4= +github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= +github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= +github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= -github.com/go-playground/universal-translator v0.16.0 h1:X++omBR/4cE2MNg91AoC3rmGrCjJ8eAeUP/K/EKx4DM= -github.com/go-playground/universal-translator v0.16.0/go.mod h1:1AnU7NaIRDWWzGEKwgtJRd2xk99HeFyHw3yid4rvQIY= +github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= +github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= +github.com/go-playground/validator/v10 v10.2.0 h1:KgJ0snyC2R9VXYN2rneOtQcw5aHQB1Vv0sFl1UcHBOY= +github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI= +github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= +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/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= -github.com/gogo/protobuf v1.3.0 h1:G8O7TerXerS4F6sx9OV7/nRfJdnXgHZu/S/7F2SN+UE= -github.com/gogo/protobuf v1.3.0/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls= github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= 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/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.3.1-0.20190508161146-9fa652df1129/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= +github.com/golang/mock v1.3.1 h1:qGJ6qTW+x6xX/my+8YUVl4WNpX9B7+/l2tRsHGZ7f2s= github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= +github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= 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 h1:87PNWwrRvUSnqS4dlcBU/ftvOIBep4sYuBLlh6rX2wk= +github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ= +github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= 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= +github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/google/uuid v0.0.0-20161128191214-064e2069ce9c/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/gorilla/mux v1.7.0/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= +github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= +github.com/gorilla/mux v1.7.3 h1:gnP5JzjVOuiZD07fKKToCAOjS0yOpj/qPETTXCCS6hw= github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= -github.com/gorilla/websocket v1.2.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM= github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= -github.com/grpc-ecosystem/go-grpc-middleware v1.1.0/go.mod h1:f5nM7jw/oeRSadq3xCzHAvxcr8HZnzsqU6ILg/0NiiE= +github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= +github.com/grpc-ecosystem/go-grpc-middleware v1.2.0/go.mod h1:mJzapYve32yjrKlk9GbyCZHuPgZsrbyIbyKhSzOpg6s= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= +github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= +github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c h1:6rhixN/i8ZofjG1Y75iExal34USq5p+wiN1tpie8IrU= +github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NMPJylDgVpX0MLRlPy15sqSwOFv/U1GZ2m21JhFfek0= +github.com/gtank/merlin v0.1.1-0.20191105220539-8318aed1a79f h1:8N8XWLZelZNibkhM1FuF+3Ad3YIbgirjdMiVA0eUkaM= +github.com/gtank/merlin v0.1.1-0.20191105220539-8318aed1a79f/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s= +github.com/gtank/ristretto255 v0.1.2 h1:JEqUCPA1NvLq5DwYtuzigd7ss8fwbYay9fi4/5uMzcc= +github.com/gtank/ristretto255 v0.1.2/go.mod h1:Ph5OpO6c7xKUGROZfWVLiJf9icMDwUeIvY4OmlYW69o= +github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE= +github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= +github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= +github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= +github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= +github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= +github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= +github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= +github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= +github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc= +github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= +github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= +github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= +github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= +github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= +github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= +github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/huandu/xstrings v1.0.0/go.mod h1:4qWG/gcEcfX4z/mBDHJ++3ReCw9ibxbsNJbcucJdbSo= github.com/huandu/xstrings v1.2.0/go.mod h1:DvyZB1rfVYsBIigL8HwpZgxHwXozlTgGqn63UyNX5k4= +github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= +github.com/imdario/mergo v0.3.4/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= github.com/imdario/mergo v0.3.7/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= +github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= +github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= +github.com/jmhodges/levigo v1.0.0 h1:q5EC36kV79HWeTBWsod3mG11EgStG3qArTKcvlksN1U= github.com/jmhodges/levigo v1.0.0/go.mod h1:Q6Qx+uH3RAqyK4rFQroq9RL7mdkABMcfhEI+nNuzMJQ= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= +github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d h1:Z+RDyXzjKE0i2sTjZ/b1uxiGtPhFy34Ou/Tk0qwN0kM= +github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d/go.mod h1:JJNrCn9otv/2QP4D7SMJBgaleKpOf66PnW6F5WGNRIc= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= 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 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s= github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= @@ -135,210 +295,398 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/leodido/go-urn v1.1.0 h1:Sm1gr51B1kKyfD2BlRcLSiEkffoG96g6TPv6eRoEiB8= -github.com/leodido/go-urn v1.1.0/go.mod h1:+cyI34gQWZcE1eQU7NVgKkkzdXDQHr1dBMtdAPozLkw= +github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= +github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= +github.com/libp2p/go-buffer-pool v0.0.2 h1:QNK2iAFa8gjAe1SPz6mHSMuCcjs+X1wlHzeOSqcmlfs= github.com/libp2p/go-buffer-pool v0.0.2/go.mod h1:MvaB6xw5vOrDl8rYZGLFdKAuk/hRoRZd1Vi32+RXyFM= -github.com/lyft/protoc-gen-validate v0.1.0/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= +github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= +github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= +github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= +github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4= github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= -github.com/mattn/go-isatty v0.0.6/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= +github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= +github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= +github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= +github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/mesg-foundation/engine v0.15.1-0.20191119102502-3216db2fdeb9 h1:zXN9B47xm1gDoKokv1Ml7HG1bsLHUyHV5ouIQyPCsf8= -github.com/mesg-foundation/engine v0.15.1-0.20191119102502-3216db2fdeb9/go.mod h1:PKdZsf3GqJrgX5+E4/+DII3fVu/SrQDOaJmESl4jfWQ= +github.com/mesg-foundation/engine v0.18.4-0.20200402055258-ff1bb6a08721 h1:phDRjfATdCfyvreTyk45L5TiXFLbG0W9TzYkgrOyWuM= +github.com/mesg-foundation/engine v0.18.4-0.20200402055258-ff1bb6a08721/go.mod h1:TjchQ1Y4OqVkOA3nJ3pJ8Pagxl360dmqzH+PhyR8NLE= +github.com/mesg-foundation/engine v0.18.4-0.20200406080522-ff6a40ead454 h1:GVwuKVMa3SdPn67i7R8ZI8KQB0w3wd4b6z1rB5eOtwc= +github.com/mesg-foundation/engine v0.18.4-0.20200406080522-ff6a40ead454/go.mod h1:TjchQ1Y4OqVkOA3nJ3pJ8Pagxl360dmqzH+PhyR8NLE= +github.com/mesg-foundation/engine v0.18.4-0.20200406094054-953626b372e7 h1:IJcitSp6L2bUJ4dQ54GyB3whPXQ+AC9PKfEGum9nHcU= +github.com/mesg-foundation/engine v0.18.4-0.20200406094054-953626b372e7/go.mod h1:TjchQ1Y4OqVkOA3nJ3pJ8Pagxl360dmqzH+PhyR8NLE= +github.com/mesg-foundation/engine v0.18.4-0.20200406120519-06c3e44902e9 h1:LXD6PywTNfGZsDytVDGfHcDbqEWCh3RhQztGqaJyxnA= +github.com/mesg-foundation/engine v0.18.4-0.20200406120519-06c3e44902e9/go.mod h1:TjchQ1Y4OqVkOA3nJ3pJ8Pagxl360dmqzH+PhyR8NLE= +github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= +github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643 h1:hLDRPB66XQT/8+wG9WsDpiCvZf1yKO7sz7scAjSlBa0= +github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643/go.mod h1:43+3pMjjKimDBf5Kr4ZFNGbLql1zKkbImw+fZbw3geM= +github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= +github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db/go.mod h1:l0dey0ia/Uv7NcFFVbCLtqEBQbrT4OCwCSKTEv6enCw= +github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= +github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= +github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= +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/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/mr-tron/base58 v1.1.1 h1:OJIdWOWYe2l5PQNgimGtuwHY8nDskvJ5vvs//YnzRLs= -github.com/mr-tron/base58 v1.1.1/go.mod h1:xcD2VGqlgYjBdcBLw+TuYLr8afG+Hj8g2eTVqeSzSU8= +github.com/mr-tron/base58 v1.1.3 h1:v+sk57XuaCKGXpWtVBX8YJzO7hMGx4Aajh4TQbdEFdc= +github.com/mr-tron/base58 v1.1.3/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/mwitkow/go-proto-validators v0.0.0-20180403085117-0950a7990007/go.mod h1:m2XC9Qq0AlmmVksL6FktJCdTYyLk7V3fKyp0sl1yWQo= github.com/mwitkow/go-proto-validators v0.0.0-20190212092829-1f388280e944/go.mod h1:m2XC9Qq0AlmmVksL6FktJCdTYyLk7V3fKyp0sl1yWQo= +github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg= +github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL6eU= +github.com/nats-io/nats-server/v2 v2.1.2/go.mod h1:Afk+wRZqkMQs/p45uXdrVLuab3gwv3Z8C4HTBu8GD/k= +github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzEE/Zbp4w= +github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= +github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= +github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= +github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= +github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= +github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.8.0 h1:VkHVNpR4iVnU8XQR6DBm8BqYjN7CRzw+xKUbVVbbW9w= github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/onsi/gomega v1.5.0 h1:izbySO9zDPmjJ8rDjLvkA2zJHIo+HkYXHnf7eN7SSyo= github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= +github.com/opencontainers/go-digest v1.0.0-rc1 h1:WzifXhOVOEOuFYOJAW6aQqW0TooG2iki3E3Ii+WN7gQ= github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= +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.1.1 h1:GlxAyO6x8rfZYN9Tt0Kti5a/cP41iuiO2yYT0IJGY8Y= github.com/opencontainers/runc v0.1.1/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U= +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= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= +github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5/go.mod h1:/wsWhb9smxSfWAKL3wpBW7V8scJMt8N8gnaMCS9E/cA= +github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw= +github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= +github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= +github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM= +github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= -github.com/pelletier/go-toml v1.4.0/go.mod h1:PN7xzY2wHTK0K9p34ErDQMlFxa51Fk0OUruD3k1mMwo= +github.com/pelletier/go-toml v1.6.0 h1:aetoXYr0Tv7xRU/V4B4IZJ2QcbtMUFoNb3ORp7TzIK4= +github.com/pelletier/go-toml v1.6.0/go.mod h1:5N711Q9dKgbdkxHL+MEfF31hpT7l0S0s/t2kKREewys= +github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= +github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= +github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA= +github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs= github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= -github.com/prometheus/client_golang v1.1.0/go.mod h1:I1FGZT9+L76gKKOs5djB6ezCbFQP1xR9D75/vuwEF3g= +github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= +github.com/prometheus/client_golang v1.5.0 h1:Ctq0iGpCmr3jeP77kbF2UxgvRwzWWz+4Bh9/vJTyg1A= +github.com/prometheus/client_golang v1.5.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/common v0.0.0-20181020173914-7e9e6cabbd39/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= +github.com/prometheus/client_model v0.1.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M= +github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= +github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -github.com/prometheus/common v0.6.0/go.mod h1:eBmuwkDJBwy6iBfxCBob6t6dR6ENT/y+J+Zk0j9GMYc= +github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA= +github.com/prometheus/common v0.9.1 h1:KOMtN28tlbam3/7ZKEYKHhKoJZYYj3gMH4uc62x7X7U= +github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= 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= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/procfs v0.0.3/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ= +github.com/prometheus/procfs v0.0.8 h1:+fpWZdT24pJBiqJdAwYBjPSk+5YmQzYNPYzQsdzLkt8= +github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= -github.com/pseudomuto/protoc-gen-doc v1.3.0/go.mod h1:fwtQAY9erXp3mC92O8OTECnDlJT2r0Ff4KSEKbGEmy0= +github.com/pseudomuto/protoc-gen-doc v1.3.1/go.mod h1:y5+P6n3iGrbKG+9O04V5ld71in3v/bX88wUwgt+U8EA= github.com/pseudomuto/protokit v0.2.0/go.mod h1:2PdH30hxVHsup8KpBTOXTBeMVhJZVio3Q8ViKSAXT0Q= -github.com/rakyll/statik v0.1.5/go.mod h1:OEi9wJV/fMUAGx1eNjq75DKDsJVuEv1U0oYdX6GX8Zs= github.com/rakyll/statik v0.1.6/go.mod h1:OEi9wJV/fMUAGx1eNjq75DKDsJVuEv1U0oYdX6GX8Zs= -github.com/rcrowley/go-metrics v0.0.0-20180503174638-e2704e165165/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= +github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= +github.com/rcrowley/go-metrics v0.0.0-20190706150252-9beb055b7962 h1:eUm8ma4+yPknhXtkYlWh3tMkE6gBjXZToDned9s2gbQ= github.com/rcrowley/go-metrics v0.0.0-20190706150252-9beb055b7962/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= -github.com/rs/cors v1.6.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik= github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= -github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= +github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= +github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= +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.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +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= +github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/snikch/goodman v0.0.0-20171125024755-10e37e294daa/go.mod h1:oJyF+mSPHbB5mVY2iO9KV3pTt/QbIkGaO8gQ2WrDbP4= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= +github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/afero v1.2.1/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= +github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= +github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cobra v0.0.1/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= -github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= +github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= +github.com/spf13/cobra v0.0.6 h1:breEStsVwemnKh2/s6gMvSdMEkwW0sK8vGStnlVBMCs= +github.com/spf13/cobra v0.0.6/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= 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/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/spf13/viper v1.0.0/go.mod h1:A8kyI5cUJhb8N+3pkfONlcEcZbueH6nhAm0Fq7SrnBM= -github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= +github.com/spf13/viper v1.6.2 h1:7aKfF+e8/k68gda3LOjo5RxiUqddoFxVq4BKBPrxk5E= +github.com/spf13/viper v1.6.2/go.mod h1:t3iDnF5Jlj76alVNuyFBk5oUMCvsrkbvZK0WQdfDi5k= +github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= +github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= +github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= +github.com/stretchr/testify v0.0.0-20170130113145-4d4bfba8f1d1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= 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 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stumble/gorocksdb v0.0.3/go.mod h1:v6IHdFBXk5DJ1K4FZ0xi+eY737quiiBxYtSWXadLybY= -github.com/syndtr/goleveldb v1.0.1-0.20190318030020-c3a204f8e965/go.mod h1:9OrXJhf154huy1nPWmuSrkgjPUtUNhA+Zmy+6AESzuA= +github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= +github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= +github.com/syndtr/goleveldb v1.0.1-0.20190923125748-758128399b1d h1:gZZadD8H+fF+n9CmNhYL1Y0dJB+kLOmKd7FbPJLeGHs= +github.com/syndtr/goleveldb v1.0.1-0.20190923125748-758128399b1d/go.mod h1:9OrXJhf154huy1nPWmuSrkgjPUtUNhA+Zmy+6AESzuA= +github.com/tcnksm/ghr v0.13.0/go.mod h1:tcp6tzbRYE0LqFSG7ykXP/BVG1/2BkX6aIn9FFV1mIQ= +github.com/tcnksm/go-gitconfig v0.1.2/go.mod h1:/8EhP4H7oJZdIPyT+/UIsG87kTzrzM4UsLGSItWYCpE= +github.com/tcnksm/go-latest v0.0.0-20170313132115-e3007ae9052e/go.mod h1:d7u6HkTYKSv5m6MCKkOQlHwaShTMl3HjqSGW3XtVhXM= +github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c h1:g+WoO5jjkqGAzHWCjJB1zZfXPIAaDpzXIEJ0eS6B5Ok= +github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c/go.mod h1:ahpPrc7HpcfEWDQRZEmnXMzHY03mLDYMCxeDzy46i+8= +github.com/tendermint/btcd v0.1.1 h1:0VcxPfflS2zZ3RiOAHkBiFUcPvbtRj5O7zHmcJWHV7s= github.com/tendermint/btcd v0.1.1/go.mod h1:DC6/m53jtQzr/NFmMNEu0rxf18/ktVoVtMrnDD5pN+U= -github.com/tendermint/crypto v0.0.0-20180820045704-3764759f34a5/go.mod h1:z4YtwM70uOnk8h0pjJYlj3zdYwi9l03By6iAIF5j/Pk= +github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 h1:hqAk8riJvK4RMWx1aInLzndwxKalgi5rTqgfXxOxbEI= +github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15/go.mod h1:z4YtwM70uOnk8h0pjJYlj3zdYwi9l03By6iAIF5j/Pk= github.com/tendermint/go-amino v0.14.1/go.mod h1:i/UKE5Uocn+argJJBb12qTZsCDBcAYMbR92AaJVmKso= -github.com/tendermint/go-amino v0.15.0 h1:TC4e66P59W7ML9+bxio17CPKnxW3nKIRAYskntMAoRk= -github.com/tendermint/go-amino v0.15.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= -github.com/tendermint/iavl v0.12.4/go.mod h1:8LHakzt8/0G3/I8FUU0ReNx98S/EP6eyPJkAUvEXT/o= -github.com/tendermint/tendermint v0.32.1/go.mod h1:jmPDAKuNkev9793/ivn/fTBnfpA9mGBww8MPRNPNxnU= -github.com/tendermint/tendermint v0.32.6/go.mod h1:D2+A3pNjY+Po72X0mTfaXorFhiVI8dh/Zg640FGyGtE= -github.com/tendermint/tm-db v0.1.1/go.mod h1:0cPKWu2Mou3IlxecH+MEUSYc1Ch537alLe6CpFrKzgw= -github.com/tendermint/tm-db v0.2.0/go.mod h1:0cPKWu2Mou3IlxecH+MEUSYc1Ch537alLe6CpFrKzgw= +github.com/tendermint/go-amino v0.15.1 h1:D2uk35eT4iTsvJd9jWIetzthE5C0/k2QmMFkCN+4JgQ= +github.com/tendermint/go-amino v0.15.1/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= +github.com/tendermint/iavl v0.13.2 h1:O1m08/Ciy53l9IYmf75uIRVvrNsfjEbre8u/yCu/oqk= +github.com/tendermint/iavl v0.13.2/go.mod h1:vE1u0XAGXYjHykd4BLp8p/yivrw2PF1TuoljBcsQoGA= +github.com/tendermint/tendermint v0.33.2 h1:NzvRMTuXJxqSsFed2J7uHmMU5N1CVzSpfi3nCc882KY= +github.com/tendermint/tendermint v0.33.2/go.mod h1:25DqB7YvV1tN3tHsjWoc2vFtlwICfrub9XO6UBO+4xk= +github.com/tendermint/tm-db v0.4.1/go.mod h1:JsJ6qzYkCGiGwm5GHl/H5GLI9XLb6qZX7PRe425dHAY= +github.com/tendermint/tm-db v0.5.0 h1:qtM5UTr1dlRnHtDY6y7MZO5Di8XAE2j3lc/pCnKJ5hQ= +github.com/tendermint/tm-db v0.5.0/go.mod h1:lSq7q5WRR/njf1LnhiZ/lIJHk2S8Y1Zyq5oP/3o9C2U= +github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= -github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= -github.com/vektra/mockery v0.0.0-20181123154057-e78b021dcbb5/go.mod h1:ppEjwdhyy7Y31EnHRDm1JkChoC7LXIJ7Ex0VYLWtZtQ= +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/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/zondax/hid v0.9.0 h1:eiT3P6vNxAEVxXMw66eZUAAnU2zD33JBkfG/EnfAKl8= github.com/zondax/hid v0.9.0/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= +go.etcd.io/bbolt v1.3.3 h1:MUGmc65QhB3pIlaQ5bB4LwqSj6GIonVJXpZiaKNyaKk= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= +go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= +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.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= +go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= +go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= +go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20180501155221-613d6eafa307/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20190228161510-8dd112bcdc25/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 h1:HuIa8hRrWRSrqYzx1qI49NNxhdi2PrY7gxVSq1JjLDc= golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413 h1:ULYEB3JvPRE/IfO+9uO7vKV/xzVTO7XPAwm8xbf4w2g= +golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7 h1:fHDIZ2oxGnUZRN6WgWFCbYBjH9uqVPRCUVUDhs0wnbA= golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200301022130-244492dfa37a h1:GuSPYbZzB5/dcLNCwLQLsg3obCJtX9IJhpXkvY7kzk0= +golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190412183630-56d357773e84/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 h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/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-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190801041406-cbf593c0f2f3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a h1:aYOabOQFp6Vj6W1F80affTUvO9UxmJRx8K0gsfABByQ= -golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190712062909-fae7ac547cb7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +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-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527 h1:uYVVQ9WP/Ds2ROhcaGPeIdVq0RIXVLwsHlnvJ+cT1So= +golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20191024005414-555d28b269f0 h1:/5xXl8Y5W96D+TtHSlonuFqGHIWVuyCkGJLwGh9JJFs= +golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20181112210238-4b1f3b6b1646/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190813142322-97f12d73768f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20181029155118-b69ba1387ce2/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20181107211654-5fc9ac540362/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190530194941-fb225487d101/go.mod h1:z3L6/3dTEVtUr6QSP8miRzeRqwQOioJ9I66odjN4I7s= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55 h1:gSJIx1SDwno+2ElGhA4+qG2zF97qiUzTM+rQ0klBOcE= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/grpc v1.13.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= +google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM= +google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= -google.golang.org/grpc v1.22.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.22.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.24.0 h1:vb/1TCsVn3DcJlQ0Gs1yB1pKI6Do2/QNwxdKqmc/b0s= -google.golang.org/grpc v1.24.0/go.mod h1:XDChyiUovWa60DnaeDeZmSW86xtLtjtZbwvSiRnRtcA= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.28.0 h1:bO/TA4OxCOummhSf10siHuG7vJOiwh7SpRpFZDkOgl4= +google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/go-playground/assert.v1 v1.2.1 h1:xoYuJVE7KT85PYWrN730RguIQO0ePzVRfFMXadIrXTM= -gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= -gopkg.in/go-playground/validator.v9 v9.30.0 h1:Wk0Z37oBmKj9/n+tPyBHZmeL19LaCoK3Qq48VwYENss= -gopkg.in/go-playground/validator.v9 v9.30.0/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ= +gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= +gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno= +gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= +honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= +sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= +sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= diff --git a/e2e/testdata/test-service/main.go b/e2e/testdata/test-service/main.go index 45eafd705..e42836a9e 100644 --- a/e2e/testdata/test-service/main.go +++ b/e2e/testdata/test-service/main.go @@ -9,99 +9,105 @@ import ( "github.com/mesg-foundation/engine/execution" "github.com/mesg-foundation/engine/hash" - pb "github.com/mesg-foundation/engine/protobuf/api" types "github.com/mesg-foundation/engine/protobuf/types" + "github.com/mesg-foundation/engine/server/grpc/orchestrator" + "github.com/mesg-foundation/engine/server/grpc/runner" "google.golang.org/grpc" "google.golang.org/grpc/keepalive" ) const ( // env variables for configure mesg client. - envMesgEndpoint = "MESG_ENDPOINT" - envMesgInstanceHash = "MESG_INSTANCE_HASH" - envMesgRunnerHash = "MESG_RUNNER_HASH" + envMesgEndpoint = "MESG_ENDPOINT" + envMesgServiceHash = "MESG_SERVICE_HASH" + envMesgEnvHash = "MESG_ENV_HASH" + envMesgRegisterSignature = "MESG_REGISTER_SIGNATURE" ) -// Client is a client to connect to all mesg exposed API. -type Client struct { - // all clients registered by mesg server. - pb.EventClient - pb.ExecutionClient - - // instance hash that could be used in api calls. - InstanceHash hash.Hash - - // runner hash that could be used in api calls. - RunnerHash hash.Hash -} - -// New creates a new client from env variables supplied by mesg engine. -func New() (*Client, error) { +// register +func register() (string, error) { endpoint := os.Getenv(envMesgEndpoint) if endpoint == "" { - return nil, fmt.Errorf("client: mesg server address env(%s) is empty", envMesgEndpoint) + return "", fmt.Errorf("env %q is empty", envMesgEndpoint) } - instanceHash, err := hash.Decode(os.Getenv(envMesgInstanceHash)) + conn, err := grpc.DialContext(context.Background(), endpoint, grpc.WithInsecure()) if err != nil { - return nil, fmt.Errorf("client: error with mesg's instance hash env(%s): %s", envMesgInstanceHash, err.Error()) + return "", err } + client := orchestrator.NewRunnerClient(conn) - runnerHash, err := hash.Decode(os.Getenv(envMesgRunnerHash)) + serviceHash, err := hash.Decode(os.Getenv(envMesgServiceHash)) if err != nil { - return nil, fmt.Errorf("client: error with mesg's runner hash env(%s): %s", envMesgRunnerHash, err.Error()) + return "", err } + envHash, err := hash.Decode(os.Getenv(envMesgEnvHash)) + if err != nil { + return "", err + } + signature := os.Getenv(envMesgRegisterSignature) + resp, err := client.Register(context.Background(), &orchestrator.RunnerRegisterRequest{ + ServiceHash: serviceHash, + EnvHash: envHash, + }, grpc.PerRPCCredentials(&signCred{signature})) + if err != nil { + return "", err + } + return resp.Token, nil +} + +func newClient(token string) (runner.RunnerClient, error) { + endpoint := os.Getenv(envMesgEndpoint) + if endpoint == "" { + return nil, fmt.Errorf("env %q is empty", envMesgEndpoint) + } + + // runner client dialoptions := []grpc.DialOption{ // Keep alive prevents Docker network to drop TCP idle connections after 15 minutes. // See: https://forum.mesg.com/t/solution-summary-for-docker-dropping-connections-after-15-min/246 grpc.WithKeepaliveParams(keepalive.ClientParameters{ Time: 5 * time.Minute, // 5 minutes is the minimun time of gRPC enforcement policy. }), - grpc.WithTimeout(10 * time.Second), grpc.WithInsecure(), + grpc.WithPerRPCCredentials(&tokenCred{token}), } - conn, err := grpc.DialContext(context.Background(), endpoint, dialoptions...) if err != nil { - return nil, fmt.Errorf("client: connection error: %s", err) + return nil, fmt.Errorf("connection error: %s", err) } - return &Client{ - ExecutionClient: pb.NewExecutionClient(conn), - EventClient: pb.NewEventClient(conn), - InstanceHash: instanceHash, - RunnerHash: runnerHash, - }, nil + return runner.NewRunnerClient(conn), nil } func main() { log.SetFlags(log.LstdFlags | log.Lshortfile) - client, err := New() + token, err := register() + if err != nil { + log.Fatal(err) + } + log.Printf("registered with token %s\n", token) + + client, err := newClient(token) if err != nil { log.Fatal(err) } log.Printf("connected to %s\n", os.Getenv(envMesgEndpoint)) - stream, err := client.ExecutionClient.Stream(context.Background(), &pb.StreamExecutionRequest{ - Filter: &pb.StreamExecutionRequest_Filter{ - Statuses: []execution.Status{execution.Status_InProgress}, - ExecutorHash: client.RunnerHash, - }, - }) + stream, err := client.Execution(context.Background(), &runner.ExecutionRequest{}) if err != nil { log.Fatal(err) } log.Printf("created execution stream\n") - if _, err := client.EventClient.Create(context.Background(), &pb.CreateEventRequest{ - InstanceHash: client.InstanceHash, - Key: "test_service_ready", + if _, err := client.Event(context.Background(), &runner.EventRequest{ + Key: "service_ready", }); err != nil { log.Fatal(err) } - log.Printf("emitted test_service_ready event\n") + log.Printf("emitted service_ready event\n") for { exec, err := stream.Recv() @@ -110,33 +116,28 @@ func main() { } log.Printf("received execution %s %s\n", exec.TaskKey, exec.Hash) - go processExec(client, exec) + go processExec(client, token, exec) } } -func processExec(client *Client, exec *execution.Execution) { - req := &pb.UpdateExecutionRequest{ - Hash: exec.Hash, - } - - if exec.TaskKey == "task1" || exec.TaskKey == "task2" { - req.Result = &pb.UpdateExecutionRequest_Outputs{ - Outputs: &types.Struct{ - Fields: map[string]*types.Value{ - "msg": { - Kind: &types.Value_StringValue{ - StringValue: exec.Inputs.Fields["msg"].GetStringValue(), - }, +func processExec(client runner.RunnerClient, token string, exec *execution.Execution) { + var outputs *types.Struct + if exec.TaskKey == "task_trigger" || exec.TaskKey == "task1" || exec.TaskKey == "task2" { + outputs = &types.Struct{ + Fields: map[string]*types.Value{ + "msg": { + Kind: &types.Value_StringValue{ + StringValue: exec.Inputs.Fields["msg"].GetStringValue(), }, - "timestamp": { - Kind: &types.Value_NumberValue{ - NumberValue: float64(time.Now().Unix()), - }, + }, + "timestamp": { + Kind: &types.Value_NumberValue{ + NumberValue: float64(time.Now().Unix()), }, }, }, } - } else if exec.TaskKey == "task_complex" { + } else if exec.TaskKey == "task_complex_trigger" || exec.TaskKey == "task_complex" { var fields = map[string]*types.Value{ "msg": { Kind: &types.Value_StringValue{ @@ -156,14 +157,12 @@ func processExec(client *Client, exec *execution.Execution) { }, } } - req.Result = &pb.UpdateExecutionRequest_Outputs{ - Outputs: &types.Struct{ - Fields: map[string]*types.Value{ - "msg": { - Kind: &types.Value_StructValue{ - StructValue: &types.Struct{ - Fields: fields, - }, + outputs = &types.Struct{ + Fields: map[string]*types.Value{ + "msg": { + Kind: &types.Value_StructValue{ + StructValue: &types.Struct{ + Fields: fields, }, }, }, @@ -173,30 +172,66 @@ func processExec(client *Client, exec *execution.Execution) { log.Fatalf("Taskkey %q not implemented", exec.TaskKey) } - if _, err := client.ExecutionClient.Update(context.Background(), req); err != nil { + if _, err := client.Result(context.Background(), &runner.ResultRequest{ + ExecutionHash: exec.Hash, + Result: &runner.ResultRequest_Outputs{ + Outputs: outputs, + }, + }); err != nil { log.Fatal(err) } log.Printf("execution result submitted\n") - if _, err := client.EventClient.Create(context.Background(), &pb.CreateEventRequest{ - InstanceHash: client.InstanceHash, - Key: "event_after_task", - Data: &types.Struct{ - Fields: map[string]*types.Value{ - "task_key": { - Kind: &types.Value_StringValue{ - StringValue: exec.TaskKey, - }, - }, - "timestamp": { - Kind: &types.Value_NumberValue{ - NumberValue: float64(time.Now().Unix()), - }, - }, - }, - }, - }); err != nil { - log.Fatal(err) + if exec.TaskKey == "task_trigger" { + if _, err := client.Event(context.Background(), &runner.EventRequest{ + Key: "event_trigger", + Data: outputs, + }); err != nil { + log.Fatal(err) + } + log.Printf("emitted event_trigger event\n") } - log.Printf("emitted event_after_task event\n") + if exec.TaskKey == "task_complex_trigger" { + if _, err := client.Event(context.Background(), &runner.EventRequest{ + Key: "event_complex_trigger", + Data: outputs, + }); err != nil { + log.Fatal(err) + } + log.Printf("emitted event_complex_trigger event\n") + } +} + +// tokenCred is a structure that manage a token. +type tokenCred struct { + token string +} + +// GetRequestMetadata returns the metadata for the request. +func (c *tokenCred) GetRequestMetadata(context.Context, ...string) (map[string]string, error) { + return map[string]string{ + runner.CredentialToken: c.token, + }, nil +} + +// RequireTransportSecurity tells if the transport should be secured. +func (c *tokenCred) RequireTransportSecurity() bool { + return false +} + +// signCred is a structure that manage a token. +type signCred struct { + signature string +} + +// GetRequestMetadata returns the metadata for the request. +func (c *signCred) GetRequestMetadata(context.Context, ...string) (map[string]string, error) { + return map[string]string{ + orchestrator.RequestSignature: c.signature, + }, nil +} + +// RequireTransportSecurity tells if the transport should be secured. +func (c *signCred) RequireTransportSecurity() bool { + return false } diff --git a/e2e/testdata/test-service/mesg.yml b/e2e/testdata/test-service/mesg.yml index a7670c931..7042ffc1f 100644 --- a/e2e/testdata/test-service/mesg.yml +++ b/e2e/testdata/test-service/mesg.yml @@ -6,26 +6,23 @@ configuration: - BAR=2 - REQUIRED tasks: - task1: - inputs: + task_trigger: + inputs: &simpleInputs msg: type: String - outputs: + outputs: &simpleOutputs msg: type: String timestamp: type: Number + task1: + inputs: *simpleInputs + outputs: *simpleOutputs task2: - inputs: - msg: - type: String - outputs: - msg: - type: String - timestamp: - type: Number + inputs: *simpleInputs + outputs: *simpleOutputs task_complex: - inputs: + inputs: &complexInputs msg: type: Object object: @@ -35,7 +32,7 @@ tasks: type: String repeated: true optional: true - outputs: + outputs: &complexOutputs msg: type: Object object: @@ -47,29 +44,12 @@ tasks: type: String repeated: true optional: true + task_complex_trigger: + inputs: *complexInputs + outputs: *complexOutputs events: - test_service_ready: - test_event: - data: - msg: - type: String - timestamp: - type: Number - test_event_complex: - data: - msg: - type: Object - object: - msg: - type: String - timestamp: - type: Number - array: - type: String - repeated: true - event_after_task: - data: - task_key: - type: String - timestamp: - type: Number \ No newline at end of file + service_ready: + event_trigger: + data: *simpleOutputs + event_complex_trigger: + data: *complexOutputs diff --git a/event/event.pb.go b/event/event.pb.go index 0611fe17e..f45cf2667 100644 --- a/event/event.pb.go +++ b/event/event.pb.go @@ -26,9 +26,9 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Event represents a single event run in engine. type Event struct { // Hash is a unique hash to identify event. - Hash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=hash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"hash" hash:"-"` + Hash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=hash,proto3,casttype=github.com/mesg-foundation/engine/hash.Hash" json:"hash,omitempty" hash:"-" validate:"required,hash"` // instanceHash is hash of instance that can proceed an execution. - InstanceHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,2,opt,name=instanceHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"instanceHash" hash:"name:2" validate:"required,hash"` + InstanceHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,2,opt,name=instanceHash,proto3,casttype=github.com/mesg-foundation/engine/hash.Hash" json:"instanceHash,omitempty" hash:"name:2" validate:"required,hash"` // key is the key of the event. Key string `protobuf:"bytes,3,opt,name=key,proto3" json:"key,omitempty" hash:"name:3" validate:"required,printascii"` // data is the data for the event. @@ -69,25 +69,25 @@ func init() { func init() { proto.RegisterFile("event.proto", fileDescriptor_2d17a9d3f0ddf27e) } var fileDescriptor_2d17a9d3f0ddf27e = []byte{ - // 320 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x91, 0x41, 0x4b, 0xfb, 0x30, - 0x18, 0xc6, 0xd7, 0x6d, 0xff, 0x3f, 0x9a, 0xcd, 0x83, 0x05, 0xa1, 0x4c, 0xb0, 0x25, 0x07, 0x1d, - 0xb8, 0x25, 0xb2, 0x79, 0x1a, 0x82, 0x50, 0x10, 0x3c, 0x77, 0x37, 0xc1, 0x43, 0xd6, 0xbe, 0x6b, - 0x83, 0x36, 0xa9, 0x4d, 0x3a, 0xd8, 0xd1, 0x6f, 0xb7, 0xcf, 0xe0, 0xa1, 0xa0, 0x1f, 0xa1, 0x9f, - 0x40, 0x92, 0xa9, 0x4c, 0x10, 0x04, 0x6f, 0x79, 0x92, 0xe7, 0xf9, 0xbd, 0xe4, 0x7d, 0x50, 0x0f, - 0x56, 0x20, 0x34, 0x29, 0x4a, 0xa9, 0xa5, 0x8b, 0x72, 0x50, 0x29, 0xd1, 0xeb, 0x02, 0xd4, 0x00, - 0xa7, 0x32, 0x95, 0xd4, 0xde, 0x2f, 0xaa, 0x25, 0x35, 0xca, 0x0a, 0x7b, 0xda, 0xfa, 0x07, 0xc7, - 0x5f, 0xcf, 0x36, 0x43, 0x95, 0x2e, 0xab, 0xf8, 0x03, 0x86, 0xdf, 0xda, 0xe8, 0xdf, 0x8d, 0x81, - 0xbb, 0x73, 0xd4, 0xcd, 0x98, 0xca, 0x3c, 0x27, 0x70, 0x86, 0xfd, 0xf0, 0x7a, 0x53, 0xfb, 0xad, - 0x97, 0xda, 0x3f, 0x4f, 0xb9, 0xce, 0xaa, 0x05, 0x89, 0x65, 0x4e, 0xcd, 0xdc, 0xf1, 0x52, 0x56, - 0x22, 0x61, 0x9a, 0x4b, 0x41, 0x41, 0xa4, 0x5c, 0x00, 0x35, 0x29, 0x72, 0xcb, 0x54, 0xd6, 0xd4, - 0xfe, 0x9e, 0x11, 0x33, 0x3c, 0xc6, 0x91, 0x85, 0xb9, 0xcf, 0x0e, 0xea, 0x73, 0xa1, 0x34, 0x13, - 0x31, 0x18, 0x8b, 0xd7, 0xb6, 0xf4, 0xfb, 0xbf, 0xd1, 0x4f, 0xb7, 0x74, 0xc1, 0x72, 0x98, 0x4d, - 0x70, 0xb0, 0x62, 0x8f, 0x3c, 0x61, 0x1a, 0x66, 0xb8, 0x84, 0xa7, 0x8a, 0x97, 0x90, 0x8c, 0x8c, - 0x01, 0x47, 0xdf, 0x46, 0xba, 0x21, 0xea, 0x3c, 0xc0, 0xda, 0xeb, 0x04, 0xce, 0x70, 0x3f, 0xbc, - 0x68, 0x6a, 0x7f, 0xb4, 0x83, 0x99, 0xfe, 0x88, 0x29, 0x4a, 0x2e, 0x34, 0x53, 0x31, 0xe7, 0x38, - 0x32, 0x61, 0xf7, 0x0a, 0x75, 0x13, 0xa6, 0x99, 0xd7, 0x0d, 0x9c, 0x61, 0x6f, 0x72, 0x44, 0x6c, - 0x05, 0x9f, 0x7b, 0x25, 0x73, 0xbb, 0xd1, 0xf0, 0xb0, 0xa9, 0xfd, 0x83, 0x1d, 0xf6, 0x25, 0x8e, - 0x6c, 0x2a, 0x1c, 0x6f, 0x5e, 0x4f, 0x5a, 0x77, 0x67, 0xbf, 0x7f, 0xd6, 0xd6, 0xbc, 0xf8, 0x6f, - 0xc1, 0xd3, 0xf7, 0x00, 0x00, 0x00, 0xff, 0xff, 0x32, 0x9b, 0xad, 0xff, 0xf6, 0x01, 0x00, 0x00, + // 316 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x91, 0xc1, 0x4a, 0xfb, 0x40, + 0x10, 0xc6, 0xff, 0x69, 0xfb, 0x17, 0xdc, 0xd6, 0x83, 0x01, 0x21, 0x54, 0x30, 0x71, 0x0f, 0x5a, + 0xb0, 0xdd, 0x95, 0xd6, 0x53, 0xf0, 0x14, 0x10, 0x3c, 0x47, 0x2f, 0x7a, 0xdb, 0x24, 0xd3, 0x64, + 0xd1, 0xec, 0xc6, 0xec, 0xa6, 0xd0, 0x83, 0xef, 0xe7, 0x53, 0x04, 0x7c, 0x85, 0x1c, 0x3d, 0xc9, + 0x6e, 0x55, 0x2a, 0x08, 0x5e, 0xbc, 0xe5, 0x9b, 0x99, 0xef, 0xfb, 0x65, 0x67, 0xd0, 0x10, 0x56, + 0x20, 0x34, 0xa9, 0x6a, 0xa9, 0xa5, 0x8b, 0x4a, 0x50, 0x39, 0xd1, 0xeb, 0x0a, 0xd4, 0x18, 0xe7, + 0x32, 0x97, 0xd4, 0xd6, 0x93, 0x66, 0x49, 0x8d, 0xb2, 0xc2, 0x7e, 0x6d, 0xe6, 0xc7, 0x87, 0x5f, + 0x6d, 0xeb, 0xa1, 0x4a, 0xd7, 0x4d, 0xfa, 0x11, 0x86, 0xbb, 0x1e, 0xfa, 0x7f, 0x65, 0xc2, 0xdd, + 0x02, 0x0d, 0x0a, 0xa6, 0x0a, 0xcf, 0x09, 0x9c, 0xc9, 0x28, 0xba, 0xed, 0x5a, 0xff, 0xd8, 0xe8, + 0x10, 0xcf, 0x70, 0xb0, 0x62, 0x8f, 0x3c, 0x63, 0x1a, 0x42, 0x5c, 0xc3, 0x53, 0xc3, 0x6b, 0xc8, + 0xa6, 0xa6, 0x87, 0xdf, 0x5a, 0xff, 0x2c, 0xe7, 0xba, 0x68, 0x12, 0x92, 0xca, 0x92, 0x9a, 0x1f, + 0x9b, 0x2d, 0x65, 0x23, 0x32, 0xa6, 0xb9, 0x14, 0x14, 0x44, 0xce, 0x05, 0x50, 0x33, 0x4a, 0xae, + 0x99, 0x2a, 0x62, 0x4b, 0x70, 0x9f, 0xd1, 0x88, 0x0b, 0xa5, 0x99, 0x48, 0xc1, 0x54, 0xbd, 0x9e, + 0x25, 0xde, 0x75, 0xad, 0x7f, 0xb2, 0x21, 0x0a, 0x56, 0x42, 0x38, 0xff, 0x3b, 0xec, 0x37, 0x9c, + 0x1b, 0xa1, 0xfe, 0x03, 0xac, 0xbd, 0x7e, 0xe0, 0x4c, 0x76, 0xa3, 0xf3, 0xae, 0xf5, 0xa7, 0x5b, + 0xd4, 0xc5, 0x8f, 0xd4, 0xaa, 0xe6, 0x42, 0x33, 0x95, 0x72, 0x8e, 0x63, 0x63, 0x76, 0x2f, 0xd1, + 0x20, 0x63, 0x9a, 0x79, 0x83, 0xc0, 0x99, 0x0c, 0xe7, 0x07, 0xc4, 0x9e, 0xe4, 0x73, 0xcf, 0xe4, + 0xc6, 0x6e, 0x38, 0xda, 0xef, 0x5a, 0x7f, 0x6f, 0x2b, 0xfb, 0x02, 0xc7, 0xd6, 0x15, 0xcd, 0x5e, + 0x5e, 0x8f, 0xfe, 0xdd, 0x9f, 0xfe, 0xfe, 0x04, 0x7b, 0xf6, 0x64, 0xc7, 0x06, 0x2f, 0xde, 0x03, + 0x00, 0x00, 0xff, 0xff, 0x48, 0xc8, 0x52, 0x5d, 0x06, 0x02, 0x00, 0x00, } diff --git a/event/publisher/publisher.go b/event/publisher/publisher.go index e8631a2f0..d32eae446 100644 --- a/event/publisher/publisher.go +++ b/event/publisher/publisher.go @@ -1,11 +1,17 @@ package publisher import ( + "fmt" + "github.com/cskr/pubsub" "github.com/mesg-foundation/engine/cosmos" "github.com/mesg-foundation/engine/event" "github.com/mesg-foundation/engine/hash" + "github.com/mesg-foundation/engine/instance" "github.com/mesg-foundation/engine/protobuf/types" + "github.com/mesg-foundation/engine/service" + instancemodule "github.com/mesg-foundation/engine/x/instance" + servicemodule "github.com/mesg-foundation/engine/x/service" ) const ( @@ -15,27 +21,29 @@ const ( // EventPublisher exposes event APIs of MESG. type EventPublisher struct { - ps *pubsub.PubSub - mc *cosmos.ModuleClient + ps *pubsub.PubSub + rpc *cosmos.RPC } // New creates a new Event SDK with given options. -func New(mc *cosmos.ModuleClient) *EventPublisher { +func New(rpc *cosmos.RPC) *EventPublisher { return &EventPublisher{ - ps: pubsub.New(0), - mc: mc, + ps: pubsub.New(0), + rpc: rpc, } } // Publish a MESG event eventKey with eventData for service token. func (ep *EventPublisher) Publish(instanceHash hash.Hash, eventKey string, eventData *types.Struct) (*event.Event, error) { - i, err := ep.mc.GetInstance(instanceHash) - if err != nil { + var i *instance.Instance + route := fmt.Sprintf("custom/%s/%s/%s", instancemodule.QuerierRoute, instancemodule.QueryGet, instanceHash) + if err := ep.rpc.QueryJSON(route, nil, &i); err != nil { return nil, err } - s, err := ep.mc.GetService(i.ServiceHash) - if err != nil { + var s *service.Service + route = fmt.Sprintf("custom/%s/%s/%s", servicemodule.QuerierRoute, servicemodule.QueryGet, i.ServiceHash) + if err := ep.rpc.QueryJSON(route, nil, &s); err != nil { return nil, err } diff --git a/execution/execution.go b/execution/execution.go index 64f0c6fe6..6b9716f07 100644 --- a/execution/execution.go +++ b/execution/execution.go @@ -2,13 +2,14 @@ package execution import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/mesg-foundation/engine/ext/xvalidator" "github.com/mesg-foundation/engine/hash" "github.com/mesg-foundation/engine/protobuf/types" "github.com/tendermint/tendermint/crypto" ) // New returns a new execution. -func New(processHash, instanceHash, parentHash, eventHash hash.Hash, nodeKey, taskKey, price string, inputs *types.Struct, tags []string, executorHash hash.Hash) *Execution { +func New(processHash, instanceHash, parentHash, eventHash hash.Hash, nodeKey, taskKey, price string, inputs *types.Struct, tags []string, executorHash hash.Hash) (*Execution, error) { exec := &Execution{ ProcessHash: processHash, EventHash: eventHash, @@ -24,7 +25,7 @@ func New(processHash, instanceHash, parentHash, eventHash hash.Hash, nodeKey, ta } exec.Hash = hash.Dump(exec) exec.Address = sdk.AccAddress(crypto.AddressHash(exec.Hash)) - return exec + return exec, xvalidator.Struct(exec) } // Execute changes executions status to in progres. diff --git a/execution/execution.pb.go b/execution/execution.pb.go index 5447c8f54..3249c744f 100644 --- a/execution/execution.pb.go +++ b/execution/execution.pb.go @@ -71,19 +71,19 @@ func (Status) EnumDescriptor() ([]byte, []int) { // Execution represents a single execution run in engine. type Execution struct { // Hash is a unique hash to identify execution. - Hash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=hash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"hash" hash:"-"` + Hash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=hash,proto3,casttype=github.com/mesg-foundation/engine/hash.Hash" json:"hash,omitempty" hash:"-" validate:"required,hash"` // parentHash is the unique hash of parent execution. // if execution is triggered by another one, // dependency execution considered as the parent. - ParentHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,2,opt,name=parentHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"parentHash" hash:"name:2"` + ParentHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,2,opt,name=parentHash,proto3,casttype=github.com/mesg-foundation/engine/hash.Hash" json:"parentHash,omitempty" hash:"name:2" validate:"required_without=EventHash,omitempty,hash"` // eventHash is unique event hash. - EventHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,3,opt,name=eventHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"eventHash" hash:"name:3"` + EventHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,3,opt,name=eventHash,proto3,casttype=github.com/mesg-foundation/engine/hash.Hash" json:"eventHash,omitempty" hash:"name:3" validate:"required_without=ParentHash,omitempty,hash"` // Status is the current status of execution. - Status Status `protobuf:"varint,4,opt,name=status,proto3,enum=mesg.types.Status" json:"status,omitempty" hash:"-"` + Status Status `protobuf:"varint,4,opt,name=status,proto3,enum=mesg.types.Status" json:"status,omitempty" hash:"-" validate:"required"` // instanceHash is hash of the instance that can proceed an execution - InstanceHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,5,opt,name=instanceHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"instanceHash" hash:"name:5"` + InstanceHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,5,opt,name=instanceHash,proto3,casttype=github.com/mesg-foundation/engine/hash.Hash" json:"instanceHash,omitempty" hash:"name:5" validate:"required,hash"` // taskKey is the key of the task of this execution. - TaskKey string `protobuf:"bytes,6,opt,name=taskKey,proto3" json:"taskKey,omitempty" hash:"name:6"` + TaskKey string `protobuf:"bytes,6,opt,name=taskKey,proto3" json:"taskKey,omitempty" hash:"name:6" validate:"required,printascii"` // inputs data of the execution. Inputs *types.Struct `protobuf:"bytes,7,opt,name=inputs,proto3" json:"inputs,omitempty" hash:"name:7"` // outputs are the returned data of successful execution. @@ -93,19 +93,19 @@ type Execution struct { // tags are optionally associated with execution by the user. Tags []string `protobuf:"bytes,10,rep,name=tags,proto3" json:"tags,omitempty" hash:"name:10" validate:"dive,printascii"` // processHash is the unique hash of the process associated to this execution. - ProcessHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,11,opt,name=processHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"processHash" hash:"name:11"` + ProcessHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,11,opt,name=processHash,proto3,casttype=github.com/mesg-foundation/engine/hash.Hash" json:"processHash,omitempty" hash:"name:11" validate:"omitempty,hash"` // node key of the process. NodeKey string `protobuf:"bytes,12,opt,name=nodeKey,proto3" json:"nodeKey,omitempty" hash:"name:12"` // runner that should execute this execution. - ExecutorHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,13,opt,name=executorHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"executorHash" hash:"name:13"` + ExecutorHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,13,opt,name=executorHash,proto3,casttype=github.com/mesg-foundation/engine/hash.Hash" json:"executorHash,omitempty" hash:"name:13" validate:"required,hash"` // price of running the exeuction. - Price string `protobuf:"bytes,14,opt,name=price,proto3" json:"price,omitempty" hash:"name:14" validate:"coins"` + Price string `protobuf:"bytes,14,opt,name=price,proto3" json:"price,omitempty" hash:"name:14" validate:"required,coinsPositiveZero"` // blockHeight where the execution was included into blockchain. BlockHeight int64 `protobuf:"varint,15,opt,name=blockHeight,proto3" json:"blockHeight,omitempty" hash:"-"` // list of emitters of this execution. - Emitters []*Execution_Emitter `protobuf:"bytes,16,rep,name=emitters,proto3" json:"emitters,omitempty" hash:"-"` + Emitters []*Execution_Emitter `protobuf:"bytes,16,rep,name=emitters,proto3" json:"emitters,omitempty" hash:"-" validate:"dive"` // The address of the execution. - Address github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,17,opt,name=address,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"address,omitempty" hash:"-" validate:"accaddress"` + Address github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,17,opt,name=address,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"address,omitempty" hash:"-" validate:"required,accaddress"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -138,9 +138,9 @@ var xxx_messageInfo_Execution proto.InternalMessageInfo // Emitter is a runner that proposed an execution. type Execution_Emitter struct { // Emitter's hash. - RunnerHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=runnerHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"runnerHash" hash:"-" validate:"hash"` + RunnerHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=runnerHash,proto3,casttype=github.com/mesg-foundation/engine/hash.Hash" json:"runnerHash,omitempty" hash:"-" validate:"required,hash"` // Block height when this emitter proposed the execution. - BlockHeight int64 `protobuf:"varint,2,opt,name=blockHeight,proto3" json:"blockHeight,omitempty" hash:"-"` + BlockHeight int64 `protobuf:"varint,2,opt,name=blockHeight,proto3" json:"blockHeight,omitempty" hash:"-" validate:"required"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -179,52 +179,59 @@ func init() { func init() { proto.RegisterFile("execution.proto", fileDescriptor_776e2c5022e94aef) } var fileDescriptor_776e2c5022e94aef = []byte{ - // 720 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0xdd, 0x6e, 0xd3, 0x48, - 0x18, 0xad, 0x9b, 0x34, 0x3f, 0x5f, 0xd2, 0x34, 0x1d, 0x69, 0x25, 0xab, 0xab, 0xad, 0xad, 0xd9, - 0x9b, 0xec, 0xb6, 0x71, 0xb6, 0xe9, 0x76, 0x7f, 0x2a, 0x21, 0x68, 0xa0, 0x50, 0x84, 0x04, 0x95, - 0x23, 0x6e, 0xb8, 0x73, 0xec, 0xa9, 0x33, 0x4a, 0x32, 0x63, 0xcd, 0x8c, 0x0b, 0x7d, 0x23, 0xc4, - 0x3d, 0xef, 0xd0, 0x67, 0xe0, 0x22, 0x12, 0x3c, 0x42, 0x2e, 0xb9, 0x42, 0x1e, 0xc7, 0xa9, 0x13, - 0x10, 0xa0, 0xaa, 0x57, 0xc9, 0xf8, 0x3b, 0xe7, 0x7c, 0x67, 0xce, 0x78, 0x3e, 0xc3, 0x16, 0x79, - 0x43, 0xfc, 0x58, 0x51, 0xce, 0x9c, 0x48, 0x70, 0xc5, 0x11, 0x4c, 0x88, 0x0c, 0x1d, 0x75, 0x15, - 0x11, 0xb9, 0x83, 0x43, 0x1e, 0xf2, 0x8e, 0x7e, 0x3e, 0x88, 0x2f, 0x3a, 0xc9, 0x4a, 0x2f, 0xf4, - 0xbf, 0x14, 0xbf, 0xf3, 0xeb, 0xa2, 0xac, 0x39, 0x1d, 0xa9, 0x44, 0xec, 0xab, 0xb4, 0x88, 0xdf, - 0xd7, 0xa0, 0x7a, 0x9a, 0x35, 0x40, 0x7d, 0x28, 0x0e, 0x3d, 0x39, 0x34, 0x0d, 0xdb, 0x68, 0xd5, - 0x7b, 0xf7, 0xaf, 0xa7, 0xd6, 0xda, 0x87, 0xa9, 0xb5, 0x17, 0x52, 0x35, 0x8c, 0x07, 0x8e, 0xcf, - 0x27, 0x9d, 0xa4, 0x77, 0xfb, 0x82, 0xc7, 0x2c, 0xf0, 0x12, 0x46, 0x87, 0xb0, 0x90, 0x32, 0xd2, - 0x49, 0x58, 0xce, 0x99, 0x27, 0x87, 0xb3, 0xa9, 0x55, 0x49, 0x16, 0xc7, 0xb8, 0x8d, 0x5d, 0x2d, - 0x86, 0x02, 0x80, 0xc8, 0x13, 0x84, 0xa9, 0xa4, 0x6e, 0xae, 0x6b, 0xe9, 0x47, 0xb7, 0x93, 0xde, - 0x4c, 0xa5, 0x99, 0x37, 0x21, 0xc7, 0x5d, 0xec, 0xe6, 0x74, 0xd1, 0x00, 0xaa, 0xe4, 0x32, 0x6b, - 0x52, 0xb8, 0xab, 0x26, 0x87, 0xd8, 0xbd, 0x91, 0x45, 0xff, 0x41, 0x49, 0x2a, 0x4f, 0xc5, 0xd2, - 0x2c, 0xda, 0x46, 0xab, 0xd1, 0x45, 0xce, 0xcd, 0x51, 0x38, 0x7d, 0x5d, 0xe9, 0xd5, 0x97, 0x12, - 0x98, 0xe3, 0xd1, 0x10, 0xea, 0x94, 0x49, 0xe5, 0x31, 0x9f, 0x68, 0x83, 0x1b, 0x77, 0x65, 0xf0, - 0x08, 0xbb, 0x4b, 0xca, 0x68, 0x0f, 0xca, 0xca, 0x93, 0xa3, 0x67, 0xe4, 0xca, 0x2c, 0xd9, 0x46, - 0xab, 0xda, 0xdb, 0x5e, 0x61, 0xfc, 0x83, 0xdd, 0x0c, 0x81, 0x1e, 0x40, 0x89, 0xb2, 0x28, 0x56, - 0xd2, 0x2c, 0xdb, 0x46, 0xab, 0xd6, 0xfd, 0x25, 0xdd, 0x50, 0xf6, 0xc2, 0x38, 0x7d, 0xfd, 0xaa, - 0x7c, 0x25, 0xf1, 0x2f, 0x76, 0xe7, 0x3c, 0x74, 0x0f, 0xca, 0x3c, 0x56, 0x5a, 0xa2, 0xf2, 0x3d, - 0x89, 0xe5, 0x58, 0x32, 0x0e, 0xc2, 0xb0, 0x41, 0x84, 0xe0, 0xc2, 0xac, 0x6a, 0xaf, 0xcb, 0xa8, - 0xb4, 0x84, 0x4e, 0xa0, 0xa8, 0xbc, 0x50, 0x9a, 0x60, 0x17, 0x5a, 0xd5, 0x5e, 0x7b, 0x36, 0xb5, - 0xfe, 0xc8, 0x79, 0x39, 0xf8, 0x0b, 0xdb, 0x97, 0xde, 0x98, 0x06, 0x9e, 0x22, 0xc7, 0x38, 0xa0, - 0x97, 0x64, 0x3f, 0x12, 0x94, 0x29, 0x4f, 0xfa, 0x94, 0x62, 0x57, 0x53, 0x51, 0x08, 0xb5, 0x48, - 0x70, 0x9f, 0x48, 0xa9, 0xd3, 0xaf, 0xe9, 0xf4, 0x4f, 0x6f, 0x97, 0x7e, 0x23, 0xdf, 0xfc, 0x00, - 0xbb, 0x79, 0x65, 0xb4, 0x0f, 0x65, 0xc6, 0x03, 0x92, 0xa4, 0x5f, 0xd7, 0x3b, 0x42, 0xab, 0x8c, - 0x2e, 0x76, 0x33, 0x08, 0xa2, 0x50, 0x4f, 0x2f, 0x37, 0x17, 0xda, 0xd7, 0xe6, 0x9d, 0xf9, 0x3a, - 0xc4, 0xee, 0x92, 0x34, 0xfa, 0x1f, 0x36, 0x22, 0x41, 0x7d, 0x62, 0x36, 0xb4, 0xad, 0xdf, 0x67, - 0x53, 0xcb, 0xca, 0x13, 0xfe, 0xce, 0xa7, 0xe8, 0x73, 0xca, 0x24, 0x76, 0x53, 0x06, 0x72, 0xa0, - 0x36, 0x18, 0x73, 0x7f, 0x74, 0x46, 0x68, 0x38, 0x54, 0xe6, 0x96, 0x6d, 0xb4, 0x0a, 0x2b, 0x27, - 0x95, 0x07, 0xa0, 0x27, 0x50, 0x21, 0x13, 0xaa, 0x14, 0x11, 0xd2, 0x6c, 0xda, 0x85, 0x56, 0xad, - 0xfb, 0x5b, 0xfe, 0x9e, 0x2c, 0xa6, 0x8d, 0x73, 0x9a, 0xa2, 0x56, 0xb4, 0x16, 0x64, 0x34, 0x81, - 0xb2, 0x17, 0x04, 0x82, 0x48, 0x69, 0x6e, 0xeb, 0x64, 0xfa, 0xb3, 0xa9, 0xb5, 0x9b, 0x01, 0x73, - 0x7e, 0x3d, 0xdf, 0x9f, 0x03, 0xf1, 0xe7, 0xa9, 0xd5, 0xce, 0xe5, 0xe6, 0x73, 0x39, 0xe1, 0x72, - 0xfe, 0xd3, 0x96, 0xc1, 0x28, 0x9d, 0x81, 0xce, 0x89, 0xef, 0x9f, 0xa4, 0x0c, 0x37, 0xeb, 0xb1, - 0xf3, 0xce, 0x80, 0xf2, 0xdc, 0x12, 0xe2, 0x00, 0x22, 0x66, 0x8c, 0xa4, 0xe7, 0x92, 0x8e, 0xc3, - 0x17, 0xb7, 0x3b, 0x17, 0xf3, 0x1b, 0x86, 0x93, 0x47, 0xd8, 0xcd, 0xb5, 0x58, 0x0d, 0x79, 0xfd, - 0x07, 0x21, 0xff, 0xf9, 0x1c, 0x4a, 0xe9, 0xc0, 0x41, 0x35, 0x28, 0xbf, 0x64, 0x23, 0xc6, 0x5f, - 0xb3, 0xe6, 0x1a, 0xaa, 0x43, 0xe5, 0x5c, 0xf0, 0x88, 0x4b, 0x12, 0x34, 0x0d, 0xd4, 0x00, 0x78, - 0xca, 0xce, 0x05, 0x0f, 0x93, 0xfd, 0x35, 0xd7, 0xd1, 0x26, 0x54, 0x1f, 0xf2, 0x49, 0x34, 0x26, - 0x8a, 0x04, 0xcd, 0x02, 0x02, 0x28, 0x3d, 0xf6, 0xe8, 0x98, 0x04, 0xcd, 0x62, 0xef, 0xe8, 0xfa, - 0xe3, 0xee, 0xda, 0xdb, 0x4f, 0xbb, 0xc6, 0xab, 0x9f, 0xd8, 0xde, 0xe2, 0x8b, 0x34, 0x28, 0xe9, - 0x7b, 0x7e, 0xf8, 0x25, 0x00, 0x00, 0xff, 0xff, 0x5e, 0x15, 0xca, 0x14, 0xa5, 0x06, 0x00, 0x00, + // 826 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0xdd, 0x8e, 0xdb, 0x44, + 0x14, 0xae, 0x37, 0xbb, 0xc9, 0xe6, 0x24, 0xbb, 0x4d, 0x47, 0x42, 0xb2, 0x96, 0x52, 0x1b, 0x5f, + 0x80, 0x81, 0x8d, 0xd3, 0x66, 0x5b, 0x40, 0x2b, 0x55, 0x62, 0x5d, 0x2d, 0x2a, 0x3f, 0xaa, 0x56, + 0x2e, 0x08, 0xb1, 0x20, 0x21, 0xc7, 0x9e, 0x3a, 0xa3, 0xc4, 0x33, 0x66, 0x66, 0x9c, 0xb2, 0x17, + 0xe5, 0x29, 0xe0, 0x1d, 0x78, 0x0f, 0x6e, 0x78, 0x0a, 0x4b, 0x70, 0xc7, 0xad, 0x2f, 0xb9, 0x42, + 0x1e, 0xc7, 0xd9, 0x09, 0x8a, 0x16, 0x44, 0xb7, 0x57, 0xc9, 0xf8, 0x9c, 0xf3, 0x7d, 0xdf, 0xf9, + 0x99, 0x33, 0x70, 0x13, 0xff, 0x80, 0xa3, 0x5c, 0x12, 0x46, 0xbd, 0x8c, 0x33, 0xc9, 0x10, 0xa4, + 0x58, 0x24, 0x9e, 0xbc, 0xc8, 0xb0, 0x38, 0x70, 0x12, 0x96, 0xb0, 0x91, 0xfa, 0x3e, 0xc9, 0x9f, + 0x8d, 0xaa, 0x93, 0x3a, 0xa8, 0x7f, 0xb5, 0xff, 0xc1, 0xeb, 0x2b, 0xb3, 0x8a, 0x19, 0x09, 0xc9, + 0xf3, 0x48, 0xd6, 0x46, 0xe7, 0xcf, 0x3d, 0xe8, 0x9e, 0x36, 0x04, 0x68, 0x0a, 0xdb, 0xd3, 0x50, + 0x4c, 0x4d, 0xc3, 0x36, 0xdc, 0xbe, 0xff, 0x45, 0x59, 0x58, 0x6f, 0x56, 0xe7, 0x63, 0x67, 0xe8, + 0xd8, 0x8b, 0x70, 0x4e, 0xe2, 0x50, 0xe2, 0x63, 0x87, 0xe3, 0xef, 0x73, 0xc2, 0x71, 0x7c, 0x58, + 0xd9, 0x9c, 0xbf, 0x0a, 0xeb, 0xbd, 0x84, 0xc8, 0x69, 0x3e, 0xf1, 0x22, 0x96, 0x8e, 0x2a, 0x71, + 0xc3, 0x67, 0x2c, 0xa7, 0x71, 0x58, 0x41, 0x8e, 0x30, 0x4d, 0x08, 0xc5, 0xa3, 0xca, 0xd5, 0x7b, + 0x1c, 0x8a, 0x69, 0xa0, 0x18, 0xd0, 0xcf, 0x06, 0x40, 0x16, 0x72, 0x4c, 0x65, 0xf5, 0xd1, 0xdc, + 0x52, 0x84, 0x79, 0x59, 0x58, 0x7e, 0x4d, 0x48, 0xc3, 0x14, 0x1f, 0x8f, 0x37, 0xb1, 0x7e, 0xf7, + 0x9c, 0xc8, 0x29, 0xcb, 0xe5, 0xc3, 0xd3, 0xc5, 0x32, 0xfa, 0x90, 0xa5, 0x44, 0xe2, 0x34, 0x93, + 0x17, 0xff, 0x4f, 0x91, 0x26, 0x04, 0xfd, 0x64, 0x40, 0x17, 0x37, 0xc0, 0x66, 0x4b, 0xc9, 0x5a, + 0x94, 0x85, 0xf5, 0x48, 0x93, 0x75, 0x74, 0xa5, 0xac, 0xb3, 0x15, 0xd8, 0xcb, 0xea, 0xba, 0x14, + 0x82, 0x3e, 0x87, 0xb6, 0x90, 0xa1, 0xcc, 0x85, 0xb9, 0x6d, 0x1b, 0xee, 0xfe, 0x18, 0x79, 0x97, + 0x43, 0xe0, 0x3d, 0x55, 0x16, 0xdf, 0x2e, 0x0b, 0xeb, 0xf6, 0x15, 0xed, 0x72, 0x82, 0x25, 0x06, + 0x7a, 0x01, 0x7d, 0x42, 0x85, 0x0c, 0x69, 0x84, 0x55, 0x9a, 0x3b, 0x2a, 0xcd, 0xaf, 0xcb, 0xc2, + 0x7a, 0x4b, 0x4b, 0xf3, 0xc1, 0xf5, 0xf5, 0x7c, 0x8d, 0x0e, 0x7d, 0x0a, 0x1d, 0x19, 0x8a, 0xd9, + 0x67, 0xf8, 0xc2, 0x6c, 0xdb, 0x86, 0xdb, 0xf5, 0xef, 0x96, 0x85, 0x75, 0xa8, 0x31, 0xbf, 0xbf, + 0x91, 0x39, 0xe3, 0x84, 0xca, 0x50, 0x44, 0x84, 0x38, 0x41, 0x03, 0x80, 0x3e, 0x82, 0x36, 0xa1, + 0x59, 0x2e, 0x85, 0xd9, 0xb1, 0x0d, 0xb7, 0x37, 0x7e, 0xad, 0x2e, 0x4c, 0x33, 0xf2, 0xde, 0x53, + 0x35, 0xec, 0xfe, 0xad, 0xb2, 0xb0, 0xf6, 0x34, 0x86, 0x0f, 0x9c, 0x60, 0x19, 0x87, 0x1e, 0x42, + 0x87, 0xe5, 0x52, 0x41, 0xec, 0x5e, 0x05, 0xd1, 0x2f, 0x0b, 0x6b, 0xb7, 0x29, 0x6f, 0xd0, 0xc4, + 0x20, 0x07, 0x76, 0x30, 0xe7, 0x8c, 0x9b, 0x5d, 0x95, 0xca, 0xba, 0x57, 0x6d, 0x42, 0x27, 0xb0, + 0x2d, 0xc3, 0x44, 0x98, 0x60, 0xb7, 0xdc, 0xae, 0x3f, 0x2c, 0x0b, 0xeb, 0x1d, 0x4d, 0xcb, 0xbd, + 0xbb, 0x7a, 0xba, 0x31, 0x59, 0xe0, 0xb5, 0x54, 0x55, 0x28, 0x7a, 0x01, 0xbd, 0x8c, 0xb3, 0x08, + 0x0b, 0xa1, 0x3a, 0xd6, 0x53, 0x1d, 0xfb, 0xa6, 0x2c, 0x2c, 0x57, 0x47, 0xba, 0xa7, 0x23, 0xbd, + 0xe4, 0xf4, 0xe9, 0x7c, 0xe8, 0x10, 0x3a, 0x94, 0xc5, 0xb8, 0x6a, 0x59, 0x5f, 0xe5, 0x89, 0xca, + 0xc2, 0xda, 0xd7, 0xa9, 0xc7, 0x4e, 0xd0, 0xb8, 0xa0, 0x1f, 0xa1, 0x5f, 0x2f, 0x2d, 0xc6, 0x95, + 0xda, 0x3d, 0xa5, 0xf6, 0xbc, 0x2c, 0xac, 0xb7, 0xf5, 0x90, 0xa3, 0x6b, 0x1c, 0x30, 0x9d, 0x0f, + 0x3d, 0x81, 0x9d, 0x8c, 0x93, 0x08, 0x9b, 0xfb, 0x4a, 0xeb, 0x87, 0x65, 0x61, 0xdd, 0xd7, 0x89, + 0xef, 0x6f, 0x24, 0x8e, 0x18, 0xa1, 0xe2, 0x8c, 0x09, 0x22, 0xc9, 0x02, 0x9f, 0x63, 0xce, 0x9c, + 0xa0, 0x86, 0x41, 0x1e, 0xf4, 0x26, 0x73, 0x16, 0xcd, 0x1e, 0x63, 0x92, 0x4c, 0xa5, 0x79, 0xd3, + 0x36, 0xdc, 0xd6, 0x3f, 0x3a, 0xad, 0x3b, 0xa0, 0xaf, 0x60, 0x17, 0xa7, 0x44, 0x4a, 0xcc, 0x85, + 0x39, 0xb0, 0x5b, 0x6e, 0x6f, 0xfc, 0x86, 0x7e, 0x5f, 0x57, 0xfb, 0xd6, 0x3b, 0xad, 0xbd, 0xfc, + 0xdb, 0x65, 0x61, 0x99, 0x1b, 0xae, 0x6e, 0x35, 0x0c, 0x4e, 0xb0, 0x02, 0x43, 0x0b, 0xe8, 0x84, + 0x71, 0xcc, 0xb1, 0x10, 0xe6, 0x2d, 0x55, 0xd3, 0x6f, 0x2f, 0x6b, 0xba, 0x79, 0x45, 0x87, 0x51, + 0xb4, 0x8c, 0xa8, 0x6a, 0x3a, 0xd4, 0x6a, 0x1a, 0x31, 0x91, 0x32, 0xb1, 0xfc, 0x19, 0x8a, 0x78, + 0x56, 0x3f, 0x0f, 0xde, 0x49, 0x14, 0x9d, 0xd4, 0x11, 0x41, 0x43, 0x76, 0xf0, 0xab, 0x01, 0x9d, + 0xa5, 0x56, 0x24, 0x01, 0x78, 0x4e, 0x29, 0xae, 0x5b, 0xfb, 0x2a, 0x5f, 0x0a, 0x8d, 0x07, 0xf9, + 0xeb, 0x2d, 0xd8, 0x52, 0x2d, 0xf8, 0xf7, 0x8d, 0xa7, 0x07, 0xbd, 0xfb, 0x04, 0xda, 0xf5, 0xaa, + 0x44, 0x3d, 0xe8, 0x7c, 0x49, 0x67, 0x94, 0x3d, 0xa7, 0x83, 0x1b, 0xa8, 0x0f, 0xbb, 0x67, 0x9c, + 0x65, 0x4c, 0xe0, 0x78, 0x60, 0xa0, 0x7d, 0x80, 0x4f, 0xe8, 0x19, 0x67, 0x49, 0x95, 0xf8, 0x60, + 0x0b, 0xed, 0x41, 0xf7, 0x11, 0x4b, 0xb3, 0x39, 0x96, 0x38, 0x1e, 0xb4, 0x10, 0x40, 0xfb, 0xe3, + 0x90, 0xcc, 0x71, 0x3c, 0xd8, 0xf6, 0x1f, 0xfc, 0xf6, 0xfb, 0x9d, 0x1b, 0xbf, 0xfc, 0x71, 0xc7, + 0x38, 0xff, 0x0f, 0x69, 0xad, 0x5e, 0xf1, 0x49, 0x5b, 0x6d, 0x96, 0xa3, 0xbf, 0x03, 0x00, 0x00, + 0xff, 0xff, 0x4d, 0xc0, 0x65, 0x90, 0xd9, 0x07, 0x00, 0x00, } func (this *Execution) Equal(that interface{}) bool { @@ -246,19 +253,19 @@ func (this *Execution) Equal(that interface{}) bool { } else if this == nil { return false } - if !this.Hash.Equal(that1.Hash) { + if !bytes.Equal(this.Hash, that1.Hash) { return false } - if !this.ParentHash.Equal(that1.ParentHash) { + if !bytes.Equal(this.ParentHash, that1.ParentHash) { return false } - if !this.EventHash.Equal(that1.EventHash) { + if !bytes.Equal(this.EventHash, that1.EventHash) { return false } if this.Status != that1.Status { return false } - if !this.InstanceHash.Equal(that1.InstanceHash) { + if !bytes.Equal(this.InstanceHash, that1.InstanceHash) { return false } if this.TaskKey != that1.TaskKey { @@ -281,13 +288,13 @@ func (this *Execution) Equal(that interface{}) bool { return false } } - if !this.ProcessHash.Equal(that1.ProcessHash) { + if !bytes.Equal(this.ProcessHash, that1.ProcessHash) { return false } if this.NodeKey != that1.NodeKey { return false } - if !this.ExecutorHash.Equal(that1.ExecutorHash) { + if !bytes.Equal(this.ExecutorHash, that1.ExecutorHash) { return false } if this.Price != that1.Price { @@ -331,7 +338,7 @@ func (this *Execution_Emitter) Equal(that interface{}) bool { } else if this == nil { return false } - if !this.RunnerHash.Equal(that1.RunnerHash) { + if !bytes.Equal(this.RunnerHash, that1.RunnerHash) { return false } if this.BlockHeight != that1.BlockHeight { diff --git a/execution/execution_test.go b/execution/execution_test.go index f32b2b598..a0d4e9c76 100644 --- a/execution/execution_test.go +++ b/execution/execution_test.go @@ -19,7 +19,7 @@ func TestNewFromService(t *testing.T) { tags = []string{"tag"} ) - execution := New(nil, hash, parentHash, eventHash, "", taskKey, "", nil, tags, nil) + execution, _ := New(nil, hash, parentHash, eventHash, "", taskKey, "", nil, tags, nil) require.NotNil(t, execution) require.Equal(t, hash, execution.InstanceHash) require.Equal(t, parentHash, execution.ParentHash) @@ -31,7 +31,7 @@ func TestNewFromService(t *testing.T) { } func TestExecute(t *testing.T) { - e := New(nil, nil, nil, nil, "", "", "", nil, nil, nil) + e, _ := New(nil, nil, nil, nil, "", "", "", nil, nil, nil) require.NoError(t, e.Execute()) require.Equal(t, Status_InProgress, e.Status) require.Error(t, e.Execute()) @@ -39,7 +39,7 @@ func TestExecute(t *testing.T) { func TestComplete(t *testing.T) { var output types.Struct - e := New(nil, nil, nil, nil, "", "", "", nil, nil, nil) + e, _ := New(nil, nil, nil, nil, "", "", "", nil, nil, nil) e.Execute() require.NoError(t, e.Complete(&output)) require.Equal(t, Status_Completed, e.Status) @@ -49,7 +49,7 @@ func TestComplete(t *testing.T) { func TestFailed(t *testing.T) { err := errors.New("test") - e := New(nil, nil, nil, nil, "", "", "", nil, nil, nil) + e, _ := New(nil, nil, nil, nil, "", "", "", nil, nil, nil) e.Execute() require.NoError(t, e.Fail(err)) require.Equal(t, Status_Failed, e.Status) @@ -61,7 +61,7 @@ func TestExecutionHash(t *testing.T) { ids := make(map[string]bool) f := func(instanceHash, parentHash, eventID []byte, taskKey string, tags []string) bool { - e := New(nil, instanceHash, parentHash, eventID, "", taskKey, "", nil, tags, nil) + e, _ := New(nil, instanceHash, parentHash, eventID, "", taskKey, "", nil, tags, nil) if ids[string(e.Hash)] { return false } diff --git a/ext/xerrors/errors.go b/ext/xerrors/errors.go index f911bba1c..ad9b67a12 100644 --- a/ext/xerrors/errors.go +++ b/ext/xerrors/errors.go @@ -23,8 +23,7 @@ func (e Errors) Error() string { s = append(s, err.Error()) } } - - return strings.Join(s, "\n") + return strings.Join(s, ". ") } // SyncErrors is an error for tracing multiple errors safe to use in multiple goroutines. diff --git a/ext/xerrors/errors_test.go b/ext/xerrors/errors_test.go index bd2ca6b12..068e8e1c7 100644 --- a/ext/xerrors/errors_test.go +++ b/ext/xerrors/errors_test.go @@ -22,7 +22,7 @@ func TestError(t *testing.T) { errs = append(errs, errors.New("a")) errs = append(errs, errors.New("b")) - if errs.Error() != "a\nb" { + if errs.Error() != "a. b" { t.Fatalf("invalid error message - got: %q, want: %q", errs.Error(), "a\nb") } } diff --git a/ext/xvalidator/validator.go b/ext/xvalidator/validator.go index 7fd2e187e..8230bd128 100644 --- a/ext/xvalidator/validator.go +++ b/ext/xvalidator/validator.go @@ -1,18 +1,21 @@ package xvalidator import ( + "fmt" "reflect" "regexp" "strconv" "strings" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/go-bip39" "github.com/go-playground/locales/en" ut "github.com/go-playground/universal-translator" + validator "github.com/go-playground/validator/v10" + en_translations "github.com/go-playground/validator/v10/translations/en" + "github.com/mesg-foundation/engine/ext/xerrors" "github.com/mesg-foundation/engine/ext/xnet" "github.com/mesg-foundation/engine/hash" - validator "gopkg.in/go-playground/validator.v9" - en_translations "gopkg.in/go-playground/validator.v9/translations/en" ) const ( @@ -23,11 +26,20 @@ const ( envSeparator = "=" ) -// Default global value to used from package level. -var Validate, Translator = New() +// Struct validates a structure using go-playground/validator and more validation fields. +func Struct(s interface{}) error { + var errs xerrors.Errors + val, trans := New("") + if err := val.Struct(s); err != nil { + for _, e := range err.(validator.ValidationErrors) { + errs = append(errs, fmt.Errorf("%s", e.Translate(trans))) + } + } + return errs.ErrorOrNil() +} -// NewWithPrefix returns a new instance of 'validate' with more validation fields prefixed with 'prefix'. -func NewWithPrefix(prefix string) (*validator.Validate, ut.Translator) { +// New returns a new instance of 'validate' with more validation fields prefixed with 'prefix'. +func New(prefix string) (*validator.Validate, ut.Translator) { en := en.New() uni := ut.New(en, en) trans, _ := uni.GetTranslator("en") @@ -43,7 +55,7 @@ func NewWithPrefix(prefix string) (*validator.Validate, ut.Translator) { validate.RegisterValidation("portmap", IsPortMapping) validate.RegisterTranslation("portmap", trans, func(ut ut.Translator) error { - return ut.Add("portmap", "{0} must be a valid port mapping. eg: 80 or 80:80", false) + return ut.Add("portmap", "{0} must be a valid port mapping (eg: 80 or 80:80)", false) }, func(ut ut.Translator, fe validator.FieldError) string { t, _ := ut.T(fe.Tag(), fe.Field(), prefix) return t @@ -51,15 +63,15 @@ func NewWithPrefix(prefix string) (*validator.Validate, ut.Translator) { validate.RegisterValidation("domain", IsDomainName) validate.RegisterTranslation("domain", trans, func(ut ut.Translator) error { - return ut.Add("domain", "{0} must respect domain-style notation. eg: author.name", false) + return ut.Add("domain", "{0} must respect domain-style notation (eg: author.name)", false) }, func(ut ut.Translator, fe validator.FieldError) string { - t, _ := ut.T(fe.Tag(), fe.Field()) + t, _ := ut.T(fe.Tag(), fe.Field(), prefix) return t }) validate.RegisterValidation("hash", IsHash) validate.RegisterTranslation("hash", trans, func(ut ut.Translator) error { - return ut.Add("hash", "{0} must be a valid hash in hex format", false) + return ut.Add("hash", "{0} must be a valid hash", false) }, func(ut ut.Translator, fe validator.FieldError) string { t, _ := ut.T(fe.Tag(), fe.Field(), prefix) return t @@ -67,7 +79,7 @@ func NewWithPrefix(prefix string) (*validator.Validate, ut.Translator) { validate.RegisterValidation("accaddress", IsAccAddress) validate.RegisterTranslation("accaddress", trans, func(ut ut.Translator) error { - return ut.Add("address", "{0} must be a valid address", false) + return ut.Add("accaddress", "{0} must be a valid address", false) }, func(ut ut.Translator, fe validator.FieldError) string { t, _ := ut.T(fe.Tag(), fe.Field(), prefix) return t @@ -81,15 +93,50 @@ func NewWithPrefix(prefix string) (*validator.Validate, ut.Translator) { return t }) + validate.RegisterValidation("coin", IsCoin) + validate.RegisterTranslation("coin", trans, func(ut ut.Translator) error { + return ut.Add("coin", "{0} must be a valid coin", false) + }, func(ut ut.Translator, fe validator.FieldError) string { + t, _ := ut.T(fe.Tag(), fe.Field(), prefix) + return t + }) + + validate.RegisterValidation("coinsPositiveZero", IsCoinsPositiveOrZero) + validate.RegisterTranslation("coinsPositiveZero", trans, func(ut ut.Translator) error { + return ut.Add("coinsPositiveZero", "{0} must be positive or zero coins", false) + }, func(ut ut.Translator, fe validator.FieldError) string { + t, _ := ut.T(fe.Tag(), fe.Field(), prefix) + return t + }) + + validate.RegisterValidation("deccoins", IsDecCoins) + validate.RegisterTranslation("deccoins", trans, func(ut ut.Translator) error { + return ut.Add("deccoins", "{0} must be a valid deccoins", false) + }, func(ut ut.Translator, fe validator.FieldError) string { + t, _ := ut.T(fe.Tag(), fe.Field(), prefix) + return t + }) + + validate.RegisterValidation("mnemonic", IsMnemonic) + validate.RegisterTranslation("mnemonic", trans, func(ut ut.Translator) error { + return ut.Add("mnemonic", "{0} must be a valid mnemonic", false) + }, func(ut ut.Translator, fe validator.FieldError) string { + t, _ := ut.T(fe.Tag(), fe.Field(), prefix) + return t + }) + + validate.RegisterValidation("bech32accpubkey", IsBech32AccPubKey) + validate.RegisterTranslation("bech32accpubkey", trans, func(ut ut.Translator) error { + return ut.Add("bech32accpubkey", "{0} must be a valid bech32accpubkey", false) + }, func(ut ut.Translator, fe validator.FieldError) string { + t, _ := ut.T(fe.Tag(), fe.Field(), prefix) + return t + }) + en_translations.RegisterDefaultTranslations(validate, trans) return validate, trans } -// New returns a new instance of 'validate' with more validation fields. -func New() (*validator.Validate, ut.Translator) { - return NewWithPrefix("") -} - // IsHash validates if given field is valid hash. // It checks both string and slice of bytes. func IsHash(fl validator.FieldLevel) bool { @@ -112,7 +159,7 @@ func IsHash(fl validator.FieldLevel) bool { func IsAccAddress(fl validator.FieldLevel) bool { switch v := fl.Field(); v.Kind() { case reflect.String: - _, err := sdk.AccAddressFromBech32(fl.Field().String()) + _, err := sdk.AccAddressFromBech32(v.String()) return err == nil case reflect.Slice: if v.Type().Elem().Kind() != reflect.Uint8 { @@ -130,6 +177,38 @@ func IsCoins(fl validator.FieldLevel) bool { return err == nil } +// IsCoin validates if given field is valid cosmos coins. +func IsCoin(fl validator.FieldLevel) bool { + _, err := sdk.ParseCoin(fl.Field().String()) + return err == nil +} + +// IsDecCoins validates if given field is valid cosmos coins. +func IsDecCoins(fl validator.FieldLevel) bool { + _, err := sdk.ParseDecCoins(fl.Field().String()) + return err == nil +} + +// IsMnemonic validates if given field is valid cosmos coins. +func IsMnemonic(fl validator.FieldLevel) bool { + return bip39.IsMnemonicValid(fl.Field().String()) +} + +// IsBech32AccPubKey validates if given field is valid cosmos coins. +func IsBech32AccPubKey(fl validator.FieldLevel) bool { + _, err := sdk.GetPubKeyFromBech32(sdk.Bech32PubKeyTypeAccPub, fl.Field().String()) + return err == nil +} + +// IsCoinsPositiveOrZero validates if given field is valid cosmos positive or zero coins. +func IsCoinsPositiveOrZero(fl validator.FieldLevel) bool { + coins, err := sdk.ParseCoins(fl.Field().String()) + if err != nil { + return false + } + return coins.IsAllPositive() || coins.IsZero() +} + // IsDomainName validates if given field is valid domain name. func IsDomainName(fl validator.FieldLevel) bool { return xnet.IsDomainName(fl.Field().String()) diff --git a/go.mod b/go.mod index 1cc532dcf..71b16e0a3 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/btcsuite/btcd v0.0.0-20190807005414-4063feeff79a // indirect github.com/containerd/containerd v1.3.0 // indirect github.com/containerd/continuity v0.0.0-20190426062206-aaeac12a7ffc // indirect - github.com/cosmos/cosmos-sdk v0.38.1 + github.com/cosmos/cosmos-sdk v0.38.3 github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d github.com/cskr/pubsub v1.0.2 github.com/docker/cli v0.0.0-20191011045415-5d85cdacd257 @@ -21,6 +21,7 @@ require ( github.com/go-kit/kit v0.10.0 github.com/go-playground/locales v0.13.0 github.com/go-playground/universal-translator v0.17.0 + github.com/go-playground/validator/v10 v10.2.0 github.com/gogo/protobuf v1.3.1 github.com/golang/mock v1.3.1 // indirect github.com/golang/protobuf v1.3.4 @@ -31,7 +32,6 @@ require ( github.com/huandu/xstrings v1.2.0 // indirect github.com/imdario/mergo v0.3.7 // indirect github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect - github.com/leodido/go-urn v1.1.0 // indirect github.com/mitchellh/go-homedir v1.1.0 github.com/morikuni/aec v1.0.0 // indirect github.com/mr-tron/base58 v1.1.3 @@ -50,14 +50,12 @@ require ( github.com/stretchr/testify v1.5.1 github.com/tcnksm/ghr v0.13.0 github.com/tendermint/go-amino v0.15.1 - github.com/tendermint/tendermint v0.33.0 - github.com/tendermint/tm-db v0.4.0 + github.com/tendermint/tendermint v0.33.3 + github.com/tendermint/tm-db v0.5.0 golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413 golang.org/x/net v0.0.0-20200301022130-244492dfa37a // indirect golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527 // indirect - google.golang.org/grpc v1.27.1 - gopkg.in/go-playground/assert.v1 v1.2.1 // indirect - gopkg.in/go-playground/validator.v9 v9.31.0 + google.golang.org/grpc v1.28.0 gopkg.in/yaml.v2 v2.2.8 gotest.tools v2.2.0+incompatible // indirect ) diff --git a/go.sum b/go.sum index a159642ea..fa146c71e 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,5 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0 h1:eOI3/cP2VTU6uZLDYAoic+eyzzB9YyGmJ7eIjl8rOPg= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/99designs/keyring v1.1.3 h1:mEV3iyZWjkxQ7R8ia8GcG97vCX5zQQ7n4o8R2BylwQY= github.com/99designs/keyring v1.1.3/go.mod h1:657DQuMrBZRtuL/voxVyiyb6zpMehlm5vLB9Qwrv904= @@ -27,8 +28,7 @@ github.com/Songmu/retry v0.1.0 h1:hPA5xybQsksLR/ry/+t/7cFajPW+dqjmjhzZhioBILA= github.com/Songmu/retry v0.1.0/go.mod h1:7sXIW7eseB9fq0FUvigRcQMVLR9tuHI0Scok+rkpAuA= github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrdtl/UvroE= github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= -github.com/Workiva/go-datastructures v1.0.50 h1:slDmfW6KCHcC7U+LP3DDBbm4fqTwZGn1beOFPfGaLvo= -github.com/Workiva/go-datastructures v1.0.50/go.mod h1:Z+F2Rca0qCsVYDS8z7bAGm8f3UkzuWYS/oBZz5a7VVA= +github.com/Workiva/go-datastructures v1.0.52/go.mod h1:Z+F2Rca0qCsVYDS8z7bAGm8f3UkzuWYS/oBZz5a7VVA= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= @@ -79,6 +79,7 @@ github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+ github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= github.com/containerd/containerd v1.3.0 h1:xjvXQWABwS2uiv3TWgQt5Uth60Gu86LTGZXMJkjc7rY= @@ -86,22 +87,21 @@ github.com/containerd/containerd v1.3.0/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMX github.com/containerd/continuity v0.0.0-20190426062206-aaeac12a7ffc h1:TP+534wVlf61smEIq1nwLLAjQVEK2EADoW3CX9AuT+8= github.com/containerd/continuity v0.0.0-20190426062206-aaeac12a7ffc/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= +github.com/coreos/etcd v3.3.10+incompatible h1:jFneRYjIvLMLhDLCzuTuU4rSJUjRplcJQ7pD7MnhC04= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= -github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.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/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.38.1 h1:DTuxIJeMpB//ydq+ObAjQgsaiwYBZ8T7NDzXjyiL1Kg= -github.com/cosmos/cosmos-sdk v0.38.1/go.mod h1:9ZZex0GKpyNCvilvVAPBoB+0n3A/aO1+/UhPVEaiCy4= +github.com/cosmos/cosmos-sdk v0.38.3 h1:qIBTiw+2T9POaSUJ5rvbBbXeq8C8btBlJxnSegPBd3Y= +github.com/cosmos/cosmos-sdk v0.38.3/go.mod h1:rzWOofbKfRt3wxiylmYWEFHnxxGj0coyqgWl2I9obAw= github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d h1:49RLWk1j44Xu4fjHb6JFYmeUnDORVwHNkDxaQ0ctCVU= github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= github.com/cosmos/ledger-cosmos-go v0.11.1 h1:9JIYsGnXP613pb2vPjFeMMjBI5lEDsEaF6oYorTy6J4= github.com/cosmos/ledger-cosmos-go v0.11.1/go.mod h1:J8//BsAGTo3OC/vDLjMRFLW6q0WAaXvHnVc7ZmE8iUY= github.com/cosmos/ledger-go v0.9.2 h1:Nnao/dLwaVTk1Q5U9THldpUMMXU94BOTWPddSmVB6pI= github.com/cosmos/ledger-go v0.9.2/go.mod h1:oZJ2hHAZROdlHiwTg4t7kP+GKIIkBT+o6c9QWFanOyI= -github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= 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= @@ -135,7 +135,9 @@ github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1 github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.0.14/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/envoyproxy/protoc-gen-validate v0.1.0 h1:EQciDnbrYxy13PgWoY8AqoxGiPrpgBZ1R8UNe3ddc+A= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= @@ -168,10 +170,14 @@ github.com/go-logfmt/logfmt v0.4.0 h1:MP4Eh7ZCb31lleYCFuwm0oe4/YGak+5l1vA2NOE80n github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logfmt/logfmt v0.5.0 h1:TrB8swr/68K7m9CcGut2g3UOihhbcbiMAYiuTXdEih4= github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= +github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= +github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= +github.com/go-playground/validator/v10 v10.2.0 h1:KgJ0snyC2R9VXYN2rneOtQcw5aHQB1Vv0sFl1UcHBOY= +github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI= github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= 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= @@ -201,12 +207,14 @@ github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= 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 h1:87PNWwrRvUSnqS4dlcBU/ftvOIBep4sYuBLlh6rX2wk= github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= @@ -293,6 +301,7 @@ github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jmhodges/levigo v1.0.0 h1:q5EC36kV79HWeTBWsod3mG11EgStG3qArTKcvlksN1U= github.com/jmhodges/levigo v1.0.0/go.mod h1:Q6Qx+uH3RAqyK4rFQroq9RL7mdkABMcfhEI+nNuzMJQ= +github.com/jonboulle/clockwork v0.1.0 h1:VKV+ZcuP6l3yW9doeqz6ziZGgcynBVQO+obU0+0hcPo= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= @@ -318,8 +327,8 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/leodido/go-urn v1.1.0 h1:Sm1gr51B1kKyfD2BlRcLSiEkffoG96g6TPv6eRoEiB8= -github.com/leodido/go-urn v1.1.0/go.mod h1:+cyI34gQWZcE1eQU7NVgKkkzdXDQHr1dBMtdAPozLkw= +github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= +github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/libp2p/go-buffer-pool v0.0.2 h1:QNK2iAFa8gjAe1SPz6mHSMuCcjs+X1wlHzeOSqcmlfs= github.com/libp2p/go-buffer-pool v0.0.2/go.mod h1:MvaB6xw5vOrDl8rYZGLFdKAuk/hRoRZd1Vi32+RXyFM= github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= @@ -459,8 +468,6 @@ github.com/pseudomuto/protokit v0.2.0 h1:hlnBDcy3YEDXH7kc9gV+NLaN0cDzhDvD1s7Y6FZ github.com/pseudomuto/protokit v0.2.0/go.mod h1:2PdH30hxVHsup8KpBTOXTBeMVhJZVio3Q8ViKSAXT0Q= github.com/rakyll/statik v0.1.6 h1:uICcfUXpgqtw2VopbIncslhAmE5hwc4g20TEyEENBNs= github.com/rakyll/statik v0.1.6/go.mod h1:OEi9wJV/fMUAGx1eNjq75DKDsJVuEv1U0oYdX6GX8Zs= -github.com/rcrowley/go-metrics v0.0.0-20180503174638-e2704e165165 h1:nkcn14uNmFEuGCb2mBZbBb24RdNRL08b/wb+xBOYpuk= -github.com/rcrowley/go-metrics v0.0.0-20180503174638-e2704e165165/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rcrowley/go-metrics v0.0.0-20190706150252-9beb055b7962 h1:eUm8ma4+yPknhXtkYlWh3tMkE6gBjXZToDned9s2gbQ= github.com/rcrowley/go-metrics v0.0.0-20190706150252-9beb055b7962/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= @@ -468,7 +475,6 @@ github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6So github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik= github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= -github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= @@ -493,10 +499,7 @@ github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cobra v0.0.1/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= -github.com/spf13/cobra v0.0.5 h1:f0B+LkLX6DtmRH1isoNA9VTtNUK9K8xYd28JNNfOv/s= -github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= github.com/spf13/cobra v0.0.6 h1:breEStsVwemnKh2/s6gMvSdMEkwW0sK8vGStnlVBMCs= github.com/spf13/cobra v0.0.6/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= @@ -507,11 +510,7 @@ github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= 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= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/spf13/viper v1.3.2 h1:VUFqw5KcqRf7i70GOzW7N+Q7+gxVBkSSqiXB12+JQ4M= -github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= -github.com/spf13/viper v1.6.1 h1:VPZzIkznI1YhVMRi6vNFLHSwhnhReBfgTxIPccpfdZk= -github.com/spf13/viper v1.6.1/go.mod h1:t3iDnF5Jlj76alVNuyFBk5oUMCvsrkbvZK0WQdfDi5k= github.com/spf13/viper v1.6.2 h1:7aKfF+e8/k68gda3LOjo5RxiUqddoFxVq4BKBPrxk5E= github.com/spf13/viper v1.6.2/go.mod h1:t3iDnF5Jlj76alVNuyFBk5oUMCvsrkbvZK0WQdfDi5k= github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= @@ -541,22 +540,24 @@ github.com/tcnksm/go-gitconfig v0.1.2 h1:iiDhRitByXAEyjgBqsKi9QU4o2TNtv9kPP3RgPg github.com/tcnksm/go-gitconfig v0.1.2/go.mod h1:/8EhP4H7oJZdIPyT+/UIsG87kTzrzM4UsLGSItWYCpE= github.com/tcnksm/go-latest v0.0.0-20170313132115-e3007ae9052e h1:IWllFTiDjjLIf2oeKxpIUmtiDV5sn71VgeQgg6vcE7k= github.com/tcnksm/go-latest v0.0.0-20170313132115-e3007ae9052e/go.mod h1:d7u6HkTYKSv5m6MCKkOQlHwaShTMl3HjqSGW3XtVhXM= -github.com/tecbot/gorocksdb v0.0.0-20191017175515-d217d93fd4c5 h1:gVwAW5OwaZlDB5/CfqcGFM9p9C+KxvQKyNOltQ8orj0= -github.com/tecbot/gorocksdb v0.0.0-20191017175515-d217d93fd4c5/go.mod h1:ahpPrc7HpcfEWDQRZEmnXMzHY03mLDYMCxeDzy46i+8= +github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c h1:g+WoO5jjkqGAzHWCjJB1zZfXPIAaDpzXIEJ0eS6B5Ok= +github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c/go.mod h1:ahpPrc7HpcfEWDQRZEmnXMzHY03mLDYMCxeDzy46i+8= github.com/tendermint/btcd v0.1.1 h1:0VcxPfflS2zZ3RiOAHkBiFUcPvbtRj5O7zHmcJWHV7s= github.com/tendermint/btcd v0.1.1/go.mod h1:DC6/m53jtQzr/NFmMNEu0rxf18/ktVoVtMrnDD5pN+U= github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 h1:hqAk8riJvK4RMWx1aInLzndwxKalgi5rTqgfXxOxbEI= github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15/go.mod h1:z4YtwM70uOnk8h0pjJYlj3zdYwi9l03By6iAIF5j/Pk= -github.com/tendermint/iavl v0.13.0 h1:r2sINvNFlJsLlLhGoqlqPlREWYkuK26BvMfkBt+XQnA= -github.com/tendermint/iavl v0.13.0/go.mod h1:7nSUPdrsHEZ2nNZa+9gaIrcJciWd1jCQZXtcyARU82k= -github.com/tendermint/tendermint v0.33.0 h1:TW1g9sQs3YSqKM8o1+opL3/VmBy4Ke/VKV9MxYpqNbI= -github.com/tendermint/tendermint v0.33.0/go.mod h1:s5UoymnPIY+GcA3mMte4P9gpMP8vS7UH7HBXikT1pHI= -github.com/tendermint/tm-db v0.4.0 h1:iPbCcLbf4nwDFhS39Zo1lpdS1X/cT9CkTlUx17FHQgA= -github.com/tendermint/tm-db v0.4.0/go.mod h1:+Cwhgowrf7NBGXmsqFMbwEtbo80XmyrlY5Jsk95JubQ= +github.com/tendermint/iavl v0.13.2 h1:O1m08/Ciy53l9IYmf75uIRVvrNsfjEbre8u/yCu/oqk= +github.com/tendermint/iavl v0.13.2/go.mod h1:vE1u0XAGXYjHykd4BLp8p/yivrw2PF1TuoljBcsQoGA= +github.com/tendermint/tendermint v0.33.2 h1:NzvRMTuXJxqSsFed2J7uHmMU5N1CVzSpfi3nCc882KY= +github.com/tendermint/tendermint v0.33.2/go.mod h1:25DqB7YvV1tN3tHsjWoc2vFtlwICfrub9XO6UBO+4xk= +github.com/tendermint/tendermint v0.33.3 h1:6lMqjEoCGejCzAghbvfQgmw87snGSqEhDTo/jw+W8CI= +github.com/tendermint/tendermint v0.33.3/go.mod h1:25DqB7YvV1tN3tHsjWoc2vFtlwICfrub9XO6UBO+4xk= +github.com/tendermint/tm-db v0.4.1/go.mod h1:JsJ6qzYkCGiGwm5GHl/H5GLI9XLb6qZX7PRe425dHAY= +github.com/tendermint/tm-db v0.5.0 h1:qtM5UTr1dlRnHtDY6y7MZO5Di8XAE2j3lc/pCnKJ5hQ= +github.com/tendermint/tm-db v0.5.0/go.mod h1:lSq7q5WRR/njf1LnhiZ/lIJHk2S8Y1Zyq5oP/3o9C2U= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= -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/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= @@ -582,7 +583,6 @@ golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnf golang.org/x/crypto v0.0.0-20180501155221-613d6eafa307/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 h1:HuIa8hRrWRSrqYzx1qI49NNxhdi2PrY7gxVSq1JjLDc= @@ -643,7 +643,6 @@ golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -651,10 +650,6 @@ golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190712062909-fae7ac547cb7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a h1:aYOabOQFp6Vj6W1F80affTUvO9UxmJRx8K0gsfABByQ= -golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a h1:aYOabOQFp6Vj6W1F80affTUvO9UxmJRx8K0gsfABByQ= -golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42 h1:vEOn+mP2zCOVzKckCZy6YsCtDblrpj/w7B9nxGNELpg= @@ -714,9 +709,12 @@ google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ij google.golang.org/grpc v1.22.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.27.1 h1:zvIju4sqAGvwKspUQOhwnpcqSbzi7/H6QomNNjTL4sk= google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.28.0 h1:bO/TA4OxCOummhSf10siHuG7vJOiwh7SpRpFZDkOgl4= +google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -729,10 +727,6 @@ gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= -gopkg.in/go-playground/assert.v1 v1.2.1 h1:xoYuJVE7KT85PYWrN730RguIQO0ePzVRfFMXadIrXTM= -gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= -gopkg.in/go-playground/validator.v9 v9.31.0 h1:bmXmP2RSNtFES+bn4uYuHT7iJFJv7Vj+an+ZQdDaD1M= -gopkg.in/go-playground/validator.v9 v9.31.0/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ= gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno= gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= diff --git a/hash/hash.go b/hash/hash.go index cf85e8f81..fbe6a6642 100644 --- a/hash/hash.go +++ b/hash/hash.go @@ -113,37 +113,6 @@ func (h Hash) Equal(h1 Hash) bool { return bytes.Equal(h, h1) } -// Marshal marshals hash into slice of bytes. It's used by protobuf. -func (h Hash) Marshal() ([]byte, error) { - if len(h) != size { - return nil, errInvalidLen - } - return h, nil -} - -// MarshalTo marshals hash into slice of bytes. It's used by protobuf. -func (h Hash) MarshalTo(data []byte) (int, error) { - if len(h) != size { - return 0, errInvalidLen - } - return copy(data, h), nil -} - -// Unmarshal unmarshals slice of bytes into hash. It's used by protobuf. -func (h *Hash) Unmarshal(data []byte) error { - if len(data) != size { - return errInvalidLen - } - *h = make([]byte, len(data)) - copy(*h, data) - return nil -} - -// Size retruns size of hash. It's used by protobuf. -func (h Hash) Size() int { - return len(h) -} - // Valid checks if service hash length is valid. // It treats empty hash as valid one. func (h Hash) Valid() bool { diff --git a/hash/hash_test.go b/hash/hash_test.go index 6607d9237..4faf9d003 100644 --- a/hash/hash_test.go +++ b/hash/hash_test.go @@ -76,12 +76,6 @@ func TestEqual(t *testing.T) { assert.False(t, zero.Equal(one)) } -func TestSize(t *testing.T) { - assert.Equal(t, 0, Hash(nil).Size()) - assert.Equal(t, size, zero.Size()) - assert.Equal(t, 5, Hash([]byte("hello")).Size()) -} - func TestMarshalJSON(t *testing.T) { b, err := json.Marshal(Int(1)) assert.NoError(t, err) @@ -93,28 +87,3 @@ func TestUnmarshalJSON(t *testing.T) { assert.NoError(t, json.Unmarshal([]byte("\"4uQeVj5tqViQh7yWWGStvkEG1Zmhx6uasJtWCJziofM\""), &h)) assert.Equal(t, Int(1), h) } - -func TestUnmarshal(t *testing.T) { - var hash Hash - data := []byte(Int(1)) - hash.Unmarshal(data) - // check if unmarshal copy the data - // test if two slises do not share the same address - assert.True(t, &hash[cap(hash)-1] != &data[cap(data)-1]) -} - -func TestWrongLength(t *testing.T) { - var h Hash - wrongLenByte := []byte("hello") - t.Run("Marshal", func(t *testing.T) { - _, err := Hash(wrongLenByte).Marshal() - require.EqualError(t, err, "hash: invalid length") - }) - t.Run("MarshalTo", func(t *testing.T) { - _, err := h.MarshalTo(wrongLenByte) - require.EqualError(t, err, "hash: invalid length") - }) - t.Run("Unmarshal", func(t *testing.T) { - require.EqualError(t, h.Unmarshal(wrongLenByte), "hash: invalid length") - }) -} diff --git a/instance/instance.go b/instance/instance.go new file mode 100644 index 000000000..d07bcaff2 --- /dev/null +++ b/instance/instance.go @@ -0,0 +1,16 @@ +package instance + +import ( + "github.com/mesg-foundation/engine/ext/xvalidator" + "github.com/mesg-foundation/engine/hash" +) + +// New returns a new Instance and validate it. +func New(serviceHash hash.Hash, envHash hash.Hash) (*Instance, error) { + inst := &Instance{ + ServiceHash: serviceHash, + EnvHash: envHash, + } + inst.Hash = hash.Dump(inst) + return inst, xvalidator.Struct(inst) +} diff --git a/instance/instance.pb.go b/instance/instance.pb.go index c32cd0924..d391fb778 100644 --- a/instance/instance.pb.go +++ b/instance/instance.pb.go @@ -25,9 +25,9 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Instance represents service's instance. type Instance struct { - Hash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=hash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"hash"` - ServiceHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,2,opt,name=serviceHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"serviceHash" hash:"name:2"` - EnvHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,3,opt,name=envHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"envHash" hash:"name:3"` + Hash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=hash,proto3,casttype=github.com/mesg-foundation/engine/hash.Hash" json:"hash,omitempty" hash:"-" validate:"required,hash"` + ServiceHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,2,opt,name=serviceHash,proto3,casttype=github.com/mesg-foundation/engine/hash.Hash" json:"serviceHash,omitempty" hash:"name:2" validate:"required,hash"` + EnvHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,3,opt,name=envHash,proto3,casttype=github.com/mesg-foundation/engine/hash.Hash" json:"envHash,omitempty" hash:"name:3" validate:"required,hash"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -64,22 +64,23 @@ func init() { func init() { proto.RegisterFile("instance.proto", fileDescriptor_fd22322185b2070b) } var fileDescriptor_fd22322185b2070b = []byte{ - // 226 bytes of a gzipped FileDescriptorProto + // 252 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0xcb, 0xcc, 0x2b, 0x2e, 0x49, 0xcc, 0x4b, 0x4e, 0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0xca, 0x4d, 0x2d, 0x4e, 0xd7, 0x2b, 0xa9, 0x2c, 0x48, 0x2d, 0x96, 0x52, 0x4a, 0xcf, 0x4f, 0xcf, 0xd7, 0x07, 0x8b, 0x27, - 0x95, 0xa6, 0xe9, 0x83, 0x78, 0x60, 0x0e, 0x98, 0x05, 0x51, 0xaf, 0x34, 0x9b, 0x89, 0x8b, 0xc3, - 0x13, 0x6a, 0x84, 0x90, 0x3b, 0x17, 0x4b, 0x46, 0x62, 0x71, 0x86, 0x04, 0xa3, 0x02, 0xa3, 0x06, - 0x8f, 0x93, 0xf1, 0x89, 0x7b, 0xf2, 0x0c, 0xb7, 0xee, 0xc9, 0x6b, 0xa7, 0x67, 0x96, 0x64, 0x94, - 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x83, 0x4c, 0xd7, 0x4d, 0xcb, 0x2f, 0xcd, 0x4b, 0x49, 0x2c, - 0xc9, 0xcc, 0xcf, 0xd3, 0x4f, 0xcd, 0x4b, 0xcf, 0xcc, 0x4b, 0xd5, 0x07, 0xe9, 0xd2, 0xf3, 0x48, - 0x2c, 0xce, 0x08, 0x02, 0x1b, 0x20, 0x94, 0xc6, 0xc5, 0x5d, 0x9c, 0x5a, 0x54, 0x96, 0x99, 0x9c, - 0x0a, 0x12, 0x94, 0x60, 0x02, 0x9b, 0xe7, 0x42, 0x86, 0x79, 0x9f, 0xee, 0xc9, 0xf3, 0x82, 0x38, - 0x56, 0x4a, 0x79, 0x89, 0xb9, 0xa9, 0x56, 0x46, 0x4a, 0x41, 0xc8, 0x06, 0x0b, 0xc5, 0x71, 0xb1, - 0xa7, 0xe6, 0x95, 0x81, 0xed, 0x60, 0xa6, 0x96, 0x1d, 0xc6, 0x4a, 0x41, 0x30, 0x43, 0x9d, 0x4c, - 0x4e, 0x3c, 0x94, 0x63, 0x58, 0xf1, 0x48, 0x8e, 0x31, 0x4a, 0x8b, 0xb0, 0x81, 0xb0, 0x98, 0x48, - 0x62, 0x03, 0x07, 0xad, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x82, 0x71, 0x79, 0x6a, 0x9c, 0x01, - 0x00, 0x00, + 0x95, 0xa6, 0xe9, 0x83, 0x78, 0x60, 0x0e, 0x98, 0x05, 0x51, 0xaf, 0xf4, 0x8c, 0x89, 0x8b, 0xc3, + 0x13, 0x6a, 0x84, 0x50, 0x06, 0x17, 0x4b, 0x46, 0x62, 0x71, 0x86, 0x04, 0xa3, 0x02, 0xa3, 0x06, + 0x8f, 0x53, 0xc8, 0xa7, 0x7b, 0xf2, 0x8a, 0x20, 0xbe, 0x95, 0x92, 0xae, 0x92, 0x42, 0x59, 0x62, + 0x4e, 0x66, 0x4a, 0x62, 0x49, 0xaa, 0x95, 0x52, 0x51, 0x6a, 0x61, 0x69, 0x66, 0x51, 0x6a, 0x8a, + 0x0e, 0x48, 0x4e, 0xe9, 0xd7, 0x3d, 0x79, 0xed, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, + 0xfc, 0x5c, 0x7d, 0x90, 0xf5, 0xba, 0x69, 0xf9, 0xa5, 0x79, 0x29, 0x89, 0x25, 0x99, 0xf9, 0x79, + 0xfa, 0xa9, 0x79, 0xe9, 0x99, 0x79, 0xa9, 0xfa, 0x20, 0xa5, 0x7a, 0x1e, 0x89, 0xc5, 0x19, 0x41, + 0x60, 0x1b, 0x84, 0xaa, 0xb9, 0xb8, 0x8b, 0x53, 0x8b, 0xca, 0x32, 0x93, 0x53, 0x41, 0x82, 0x12, + 0x4c, 0x60, 0x0b, 0x23, 0x3f, 0xdd, 0x93, 0x57, 0x83, 0x58, 0x98, 0x97, 0x98, 0x9b, 0x6a, 0x65, + 0x44, 0x3d, 0x5b, 0x91, 0x6d, 0x13, 0x2a, 0xe6, 0x62, 0x4f, 0xcd, 0x2b, 0x03, 0x5b, 0xcc, 0x8c, + 0xd5, 0x62, 0x63, 0xea, 0x59, 0x0c, 0xb3, 0xc9, 0xc9, 0xe4, 0xc4, 0x43, 0x39, 0x86, 0x15, 0x8f, + 0xe4, 0x18, 0xa3, 0xb4, 0x08, 0xeb, 0x87, 0x45, 0x6a, 0x12, 0x1b, 0x38, 0x96, 0x8c, 0x01, 0x01, + 0x00, 0x00, 0xff, 0xff, 0xc8, 0xf9, 0x30, 0x37, 0xe7, 0x01, 0x00, 0x00, } func (this *Instance) Equal(that interface{}) bool { @@ -101,13 +102,13 @@ func (this *Instance) Equal(that interface{}) bool { } else if this == nil { return false } - if !this.Hash.Equal(that1.Hash) { + if !bytes.Equal(this.Hash, that1.Hash) { return false } - if !this.ServiceHash.Equal(that1.ServiceHash) { + if !bytes.Equal(this.ServiceHash, that1.ServiceHash) { return false } - if !this.EnvHash.Equal(that1.EnvHash) { + if !bytes.Equal(this.EnvHash, that1.EnvHash) { return false } if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { diff --git a/internal/mocks/mocks.go b/internal/mocks/mocks.go deleted file mode 100644 index 5d4c41bc7..000000000 --- a/internal/mocks/mocks.go +++ /dev/null @@ -1,11 +0,0 @@ -package mocks - -import "github.com/docker/docker/client" - -// CommonAPIClient is the common methods between stable and experimental versions of APIClient. -type CommonAPIClient interface { - client.CommonAPIClient -} - -// disble no-used linter -var _ = CommonAPIClient(nil) diff --git a/orchestrator/orchestrator.go b/orchestrator/orchestrator.go index e5d196c98..a9f12b0d9 100644 --- a/orchestrator/orchestrator.go +++ b/orchestrator/orchestrator.go @@ -6,21 +6,26 @@ import ( "fmt" "math/rand" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/mesg-foundation/engine/cosmos" "github.com/mesg-foundation/engine/event" "github.com/mesg-foundation/engine/event/publisher" "github.com/mesg-foundation/engine/execution" + "github.com/mesg-foundation/engine/ext/xstrings" "github.com/mesg-foundation/engine/hash" "github.com/mesg-foundation/engine/process" - "github.com/mesg-foundation/engine/protobuf/api" "github.com/mesg-foundation/engine/protobuf/types" + "github.com/mesg-foundation/engine/runner" + executionmodule "github.com/mesg-foundation/engine/x/execution" + processmodule "github.com/mesg-foundation/engine/x/process" + runnermodule "github.com/mesg-foundation/engine/x/runner" "github.com/sirupsen/logrus" ) // New creates a new Process instance -func New(mc *cosmos.ModuleClient, ep *publisher.EventPublisher, execPrice string) *Orchestrator { +func New(rpc *cosmos.RPC, ep *publisher.EventPublisher, execPrice string) *Orchestrator { return &Orchestrator{ - mc: mc, + rpc: rpc, ep: ep, ErrC: make(chan error), stopC: make(chan bool), @@ -38,16 +43,10 @@ func (s *Orchestrator) Start() error { ctx, cancel := context.WithCancel(context.Background()) defer cancel() - - executionStream, errC, err := s.mc.StreamExecution(ctx, &api.StreamExecutionRequest{ - Filter: &api.StreamExecutionRequest_Filter{ - Statuses: []execution.Status{execution.Status_Completed}, - }, - }) - if err != nil { + if err := s.startExecutionStream(ctx); err != nil { return err } - s.executionStream = executionStream + for { select { case event := <-s.eventStream.C: @@ -55,8 +54,6 @@ func (s *Orchestrator) Start() error { case execution := <-s.executionStream: go s.execute(s.resultFilter(execution), execution, nil, execution.Outputs) go s.execute(s.dependencyFilter(execution), execution, nil, execution.Outputs) - case err := <-errC: - s.ErrC <- err case <-s.stopC: return nil } @@ -66,6 +63,7 @@ func (s *Orchestrator) Start() error { // Stop stops the orchestrator engine func (s *Orchestrator) Stop() { s.stopC <- true + s.eventStream.Close() } func (s *Orchestrator) eventFilter(event *event.Event) func(wf *process.Process, node *process.Process_Node) (bool, error) { @@ -113,8 +111,9 @@ func (s *Orchestrator) findNodes(wf *process.Process, filter func(wf *process.Pr } func (s *Orchestrator) execute(filter func(wf *process.Process, node *process.Process_Node) (bool, error), exec *execution.Execution, event *event.Event, data *types.Struct) { - processes, err := s.mc.ListProcess() - if err != nil { + var processes []*process.Process + route := fmt.Sprintf("custom/%s/%s", processmodule.QuerierRoute, processmodule.QueryList) + if err := s.rpc.QueryJSON(route, nil, &processes); err != nil { s.ErrC <- err return } @@ -142,7 +141,7 @@ func (s *Orchestrator) executeNode(wf *process.Process, n *process.Process_Node, return err } } else if filter := n.GetFilter(); filter != nil { - if !filter.Match(data) { + if !s.filterMatch(filter, wf, n.Key, exec, data) { return nil } } @@ -161,6 +160,26 @@ func (s *Orchestrator) executeNode(wf *process.Process, n *process.Process_Node, return nil } +// filterMatch returns true if the data match the current list of filters. +func (s *Orchestrator) filterMatch(f *process.Process_Node_Filter, wf *process.Process, nodeKey string, exec *execution.Execution, data *types.Struct) bool { + for _, condition := range f.Conditions { + resolvedData, err := s.resolveRef(wf, exec, nodeKey, data, condition.Ref) + if err != nil { + s.ErrC <- err + return false + } + match, err := condition.Match(resolvedData) + if err != nil { + s.ErrC <- err + } + if !match { + return false + } + } + return true +} + +// processMap constructs the Struct that the map indicates how to construct. func (s *Orchestrator) processMap(nodeKey string, outputs map[string]*process.Process_Node_Map_Output, wf *process.Process, exec *execution.Execution, data *types.Struct) (*types.Struct, error) { result := &types.Struct{ Fields: make(map[string]*types.Value), @@ -175,6 +194,7 @@ func (s *Orchestrator) processMap(nodeKey string, outputs map[string]*process.Pr return result, nil } +// outputToValue returns a specific value from an output. func (s *Orchestrator) outputToValue(nodeKey string, output *process.Process_Node_Map_Output, wf *process.Process, exec *execution.Execution, data *types.Struct) (*types.Value, error) { switch v := output.GetValue().(type) { case *process.Process_Node_Map_Output_Null_: @@ -209,45 +229,58 @@ func (s *Orchestrator) outputToValue(nodeKey string, output *process.Process_Nod }, }, nil case *process.Process_Node_Map_Output_Ref: - node, err := wf.FindNode(v.Ref.NodeKey) - if err != nil { - return nil, err - } - if node.GetTask() != nil { - return s.resolveInput(wf.Hash, exec, v.Ref.NodeKey, v.Ref.Path) - } - // check that the parent nodeKey == ref.NodeKey - // this ensures that we can use directly the data of the previous node - refToParent := false - for _, parent := range wf.ParentKeys(nodeKey) { - if parent == v.Ref.NodeKey { - refToParent = true - break - } - } - if !refToParent { - return nil, fmt.Errorf("ref can only reference a parent node for non task nodes") - } - return resolveRef(data, v.Ref.Path) + return s.resolveRef(wf, exec, nodeKey, data, v.Ref) default: return nil, errors.New("unknown output") } } -func (s *Orchestrator) resolveInput(wfHash hash.Hash, exec *execution.Execution, nodeKey string, path *process.Process_Node_Map_Output_Reference_Path) (*types.Value, error) { +// resolveRef returns a specific value from a reference. +func (s *Orchestrator) resolveRef(wf *process.Process, exec *execution.Execution, nodeKey string, data *types.Struct, ref *process.Process_Node_Reference) (*types.Value, error) { + refNode, err := wf.FindNode(ref.NodeKey) + if err != nil { + return nil, err + } + // if referenced node is a task, get its output + if refNode.GetTask() != nil { + return s.resolveInput(wf.Hash, exec, ref.NodeKey, ref.Path) + } + // check that the parent nodeKey == ref.NodeKey + // this ensures that we can use directly the data of the previous node + refToParent := false + for _, parent := range wf.ParentKeys(nodeKey) { + if parent == ref.NodeKey { + refToParent = true + break + } + } + if !refToParent { + return nil, fmt.Errorf("ref can only reference a parent node for non task nodes") + } + return ref.Path.Resolve(data) +} + +// resolveInput returns a specific value from a reference path. +func (s *Orchestrator) resolveInput(wfHash hash.Hash, exec *execution.Execution, refNodeKey string, path *process.Process_Node_Reference_Path) (*types.Value, error) { + // the wfHash condition only works for Task node, not for Result if !wfHash.Equal(exec.ProcessHash) { return nil, fmt.Errorf("reference's nodeKey not found") } - if exec.NodeKey != nodeKey { - parent, err := s.mc.GetExecution(exec.ParentHash) - if err != nil { - return nil, err - } - return s.resolveInput(wfHash, parent, nodeKey, path) + // we reach the right execution, return it + // but only works for Task as the execution related to the Result is not created by this process + if exec.NodeKey == refNodeKey { + return path.Resolve(exec.Outputs) + } + // get parentExec and do a recursive call + var parentExec *execution.Execution + route := fmt.Sprintf("custom/%s/%s/%s", executionmodule.QuerierRoute, executionmodule.QueryGet, exec.ParentHash) + if err := s.rpc.QueryJSON(route, nil, &parentExec); err != nil { + return nil, err } - return resolveRef(exec.Outputs, path) + return s.resolveInput(wfHash, parentExec, refNodeKey, path) } +// processTask create the request to execute the task. func (s *Orchestrator) processTask(nodeKey string, task *process.Process_Node_Task, wf *process.Process, exec *execution.Execution, event *event.Event, data *types.Struct) error { var eventHash, execHash hash.Hash if event != nil { @@ -256,17 +289,29 @@ func (s *Orchestrator) processTask(nodeKey string, task *process.Process_Node_Ta if exec != nil { execHash = exec.Hash } - executors, err := s.mc.ListRunner(&cosmos.FilterRunner{ - InstanceHash: task.InstanceHash, - }) - if err != nil { + var runners []*runner.Runner + route := fmt.Sprintf("custom/%s/%s", runnermodule.QuerierRoute, runnermodule.QueryList) + if err := s.rpc.QueryJSON(route, nil, &runners); err != nil { return err } + executors := make([]*runner.Runner, 0) + for _, run := range runners { + if run.InstanceHash.Equal(task.InstanceHash) { + executors = append(executors, run) + } + } if len(executors) == 0 { return fmt.Errorf("no runner is running instance %q", task.InstanceHash) } executor := executors[rand.Intn(len(executors))] - _, err = s.mc.CreateExecution(&api.CreateExecutionRequest{ + + // create execution + acc, err := s.rpc.GetAccount() + if err != nil { + return err + } + msg := executionmodule.MsgCreate{ + Signer: acc.GetAddress(), ProcessHash: wf.Hash, EventHash: eventHash, ParentHash: execHash, @@ -276,54 +321,63 @@ func (s *Orchestrator) processTask(nodeKey string, task *process.Process_Node_Ta ExecutorHash: executor.Hash, Price: s.execPrice, Tags: nil, - }) - return err -} - -func resolveRef(data *types.Struct, path *process.Process_Node_Map_Output_Reference_Path) (*types.Value, error) { - if path == nil { - return &types.Value{Kind: &types.Value_StructValue{StructValue: data}}, nil } - - var v *types.Value - key, ok := path.Selector.(*process.Process_Node_Map_Output_Reference_Path_Key) - if !ok { - return nil, fmt.Errorf("orchestrator: first selector in the path must be a key") + if _, err := s.rpc.BuildAndBroadcastMsg(msg); err != nil { + return err } + return nil +} - v, ok = data.Fields[key.Key] - if !ok { - return nil, fmt.Errorf("orchestrator: key %s not found", key.Key) +// startExecutionStream returns execution that matches given hash. +func (s *Orchestrator) startExecutionStream(ctx context.Context) error { + subscriber := xstrings.RandASCIILetters(8) + query := fmt.Sprintf("%s.%s EXISTS AND %s.%s='%s'", + executionmodule.EventType, executionmodule.AttributeKeyHash, + executionmodule.EventType, sdk.AttributeKeyAction, executionmodule.AttributeActionCompleted, + ) + eventStream, err := s.rpc.Subscribe(ctx, subscriber, query, 0) + if err != nil { + return err } - for p := path.Path; p != nil; p = p.Path { - switch s := p.Selector.(type) { - case *process.Process_Node_Map_Output_Reference_Path_Key: - str, ok := v.GetKind().(*types.Value_StructValue) - if !ok { - return nil, fmt.Errorf("orchestrator: can't get key from non-struct value") - } - if str.StructValue.GetFields() == nil { - return nil, fmt.Errorf("orchestrator: can't get key from nil-struct") - } - v, ok = str.StructValue.Fields[s.Key] - if !ok { - return nil, fmt.Errorf("orchestrator: key %s not found", s.Key) - } - case *process.Process_Node_Map_Output_Reference_Path_Index: - list, ok := v.GetKind().(*types.Value_ListValue) - if !ok { - return nil, fmt.Errorf("orchestrator: can't get index from non-list value") + s.executionStream = make(chan *execution.Execution) + go func() { + loop: + for { + select { + case event := <-eventStream: + // get the index of the action=completed attributes + attrKeyActionCreated := fmt.Sprintf("%s.%s", executionmodule.EventType, sdk.AttributeKeyAction) + attrIndexes := make([]int, 0) + for index, attr := range event.Events[attrKeyActionCreated] { + if attr == executionmodule.AttributeActionCompleted { + attrIndexes = append(attrIndexes, index) + } + } + // iterate only on the index of attribute hash where action=completed + attrKeyHash := fmt.Sprintf("%s.%s", executionmodule.EventType, executionmodule.AttributeKeyHash) + for _, index := range attrIndexes { + attr := event.Events[attrKeyHash][index] + hash, err := hash.Decode(attr) + if err != nil { + s.ErrC <- err + continue + } + var exec *execution.Execution + route := fmt.Sprintf("custom/%s/%s/%s", executionmodule.QuerierRoute, executionmodule.QueryGet, hash) + if err := s.rpc.QueryJSON(route, nil, &exec); err != nil { + s.ErrC <- err + continue + } + s.executionStream <- exec + } + case <-ctx.Done(): + break loop } - - if len(list.ListValue.GetValues()) <= int(s.Index) { - return nil, fmt.Errorf("orchestrator: index %d out of range", s.Index) - } - v = list.ListValue.Values[s.Index] - default: - return nil, fmt.Errorf("orchestrator: unknown selector type %T", v) } - } - - return v, nil + if err := s.rpc.Unsubscribe(context.Background(), subscriber, query); err != nil { + s.ErrC <- err + } + }() + return nil } diff --git a/orchestrator/orchestrator_test.go b/orchestrator/orchestrator_test.go index e3649bd49..f260cc3a8 100644 --- a/orchestrator/orchestrator_test.go +++ b/orchestrator/orchestrator_test.go @@ -199,15 +199,15 @@ package orchestrator // }, // } // // Different processes -// _, err := o.resolveInput(hash.Int(1), exec, "2", &process.Process_Node_Map_Output_Reference_Path{Selector: &process.Process_Node_Map_Output_Reference_Path_Key{Key: "xxx"}}) +// _, err := o.resolveInput(hash.Int(1), exec, "2", &process.Process_Node_Reference_Path{Selector: &process.Process_Node_Reference_Path_Key{Key: "xxx"}}) // require.Error(t, err) // // Different steps, should return the value of the data -// val, err := o.resolveInput(hash.Int(2), exec, "2", &process.Process_Node_Map_Output_Reference_Path{Selector: &process.Process_Node_Map_Output_Reference_Path_Key{Key: "xxx"}}) +// val, err := o.resolveInput(hash.Int(2), exec, "2", &process.Process_Node_Reference_Path{Selector: &process.Process_Node_Reference_Path_Key{Key: "xxx"}}) // require.NoError(t, err) // require.Equal(t, val, exec.Outputs.Fields["xxx"]) // // Invalid execution parent hash // e.On("Get", mock.Anything).Once().Return(nil, fmt.Errorf("err")) -// _, err = o.resolveInput(hash.Int(2), exec, "-", &process.Process_Node_Map_Output_Reference_Path{Selector: &process.Process_Node_Map_Output_Reference_Path_Key{Key: "xxx"}}) +// _, err = o.resolveInput(hash.Int(2), exec, "-", &process.Process_Node_Reference_Path{Selector: &process.Process_Node_Reference_Path_Key{Key: "xxx"}}) // require.Error(t, err) // // Output from a previous exec // execMock := &execution.Execution{ @@ -222,7 +222,7 @@ package orchestrator // }, // } // e.On("Get", mock.Anything).Once().Return(execMock, nil) -// val, err = o.resolveInput(hash.Int(2), exec, "3", &process.Process_Node_Map_Output_Reference_Path{Selector: &process.Process_Node_Map_Output_Reference_Path_Key{Key: "yyy"}}) +// val, err = o.resolveInput(hash.Int(2), exec, "3", &process.Process_Node_Reference_Path{Selector: &process.Process_Node_Reference_Path_Key{Key: "yyy"}}) // require.NoError(t, err) // require.Equal(t, val, execMock.Outputs.Fields["yyy"]) // } diff --git a/orchestrator/type.go b/orchestrator/type.go index b7f007beb..b2034209a 100644 --- a/orchestrator/type.go +++ b/orchestrator/type.go @@ -9,14 +9,14 @@ import ( // Orchestrator manages the executions based on the definition of the processes type Orchestrator struct { - mc *cosmos.ModuleClient - ep *publisher.EventPublisher + rpc *cosmos.RPC + ep *publisher.EventPublisher - eventStream *event.Listener - executionStream <-chan *execution.Execution + eventStream *event.Listener - ErrC chan error - stopC chan bool + executionStream chan *execution.Execution + ErrC chan error + stopC chan bool execPrice string } diff --git a/ownership/ownership.go b/ownership/ownership.go new file mode 100644 index 000000000..713636653 --- /dev/null +++ b/ownership/ownership.go @@ -0,0 +1,19 @@ +package ownership + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/mesg-foundation/engine/ext/xvalidator" + "github.com/mesg-foundation/engine/hash" +) + +// New returns a new ownership and validate it. +func New(owner string, resource Ownership_Resource, resourceHash hash.Hash, resourceAddress sdk.AccAddress) (*Ownership, error) { + own := &Ownership{ + Owner: owner, + Resource: resource, + ResourceHash: resourceHash, + ResourceAddress: resourceAddress, + } + own.Hash = hash.Dump(own) + return own, xvalidator.Struct(own) +} diff --git a/ownership/ownership.pb.go b/ownership/ownership.pb.go index 295f8e8f8..c16530526 100644 --- a/ownership/ownership.pb.go +++ b/ownership/ownership.pb.go @@ -58,15 +58,16 @@ func (Ownership_Resource) EnumDescriptor() ([]byte, []int) { // Ownership is a ownership relation between one owner and a resource. type Ownership struct { // Service's hash. - Hash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=hash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"hash" hash:"-" validate:"required"` + Hash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=hash,proto3,casttype=github.com/mesg-foundation/engine/hash.Hash" json:"hash,omitempty" hash:"-" validate:"required,hash"` // The owner of the resource. + // TODO: to transform to accAddress Owner string `protobuf:"bytes,2,opt,name=owner,proto3" json:"owner,omitempty" hash:"name:2" validate:"required"` // Resource's hash. - ResourceHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,3,opt,name=resourceHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"resourceHash" hash:"name:3"` + ResourceHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,3,opt,name=resourceHash,proto3,casttype=github.com/mesg-foundation/engine/hash.Hash" json:"resourceHash,omitempty" hash:"name:3" validate:"required,hash"` // Resource's type. - Resource Ownership_Resource `protobuf:"varint,4,opt,name=resource,proto3,enum=mesg.types.Ownership_Resource" json:"resource,omitempty"` + Resource Ownership_Resource `protobuf:"varint,4,opt,name=resource,proto3,enum=mesg.types.Ownership_Resource" json:"resource,omitempty" validate:"required"` // The address of the resource. - ResourceAddress github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,5,opt,name=resourceAddress,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"resourceAddress,omitempty" hash:"-" validate:"accaddress"` + ResourceAddress github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,5,opt,name=resourceAddress,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"resourceAddress,omitempty" hash:"-" validate:"required,accaddress"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -104,32 +105,32 @@ func init() { func init() { proto.RegisterFile("ownership.proto", fileDescriptor_21ae26e0dccf9d04) } var fileDescriptor_21ae26e0dccf9d04 = []byte{ - // 390 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x52, 0xcf, 0x8e, 0x93, 0x40, - 0x1c, 0x2e, 0x2d, 0xad, 0xed, 0x58, 0x2d, 0x99, 0x13, 0x31, 0x06, 0x70, 0x12, 0x93, 0x26, 0x06, - 0x48, 0xda, 0x78, 0xc1, 0x53, 0x1b, 0x0f, 0x9e, 0xd4, 0xd0, 0x9b, 0xb7, 0xe9, 0xf0, 0x2b, 0x10, - 0x65, 0xa6, 0xce, 0x40, 0x8d, 0x07, 0x5f, 0xc2, 0xa7, 0xf0, 0x51, 0xfa, 0x0c, 0x1e, 0x48, 0x76, - 0x1f, 0xa1, 0xc7, 0x3d, 0x6d, 0x80, 0xd2, 0xed, 0x6e, 0x7a, 0xd8, 0xec, 0x89, 0xf9, 0xc8, 0xf7, - 0x6f, 0xbe, 0x0c, 0x9a, 0x88, 0x5f, 0x1c, 0xa4, 0x4a, 0xd2, 0xad, 0xb7, 0x95, 0x22, 0x17, 0x18, - 0x65, 0xa0, 0x62, 0x2f, 0xff, 0xbd, 0x05, 0xf5, 0x8a, 0xc4, 0x22, 0x16, 0x7e, 0xfd, 0x7f, 0x5d, - 0x6c, 0xfc, 0x0a, 0xd5, 0xa0, 0x3e, 0x35, 0x7c, 0xf2, 0x57, 0x47, 0xa3, 0x2f, 0xad, 0x07, 0x8e, - 0x91, 0x9e, 0x50, 0x95, 0x98, 0x9a, 0xa3, 0x4d, 0xc7, 0xcb, 0xd5, 0xbe, 0xb4, 0x3b, 0xff, 0x4b, - 0xfb, 0x5d, 0x9c, 0xe6, 0x49, 0xb1, 0xf6, 0x98, 0xc8, 0xfc, 0xca, 0xde, 0xdd, 0x88, 0x82, 0x47, - 0x34, 0x4f, 0x05, 0xf7, 0x81, 0xc7, 0x29, 0x07, 0xbf, 0x52, 0x79, 0x9f, 0xa8, 0x4a, 0x0e, 0xa5, - 0xfd, 0xba, 0x02, 0x01, 0x71, 0x89, 0xb3, 0xa3, 0x3f, 0xd2, 0x88, 0xe6, 0x10, 0x10, 0x09, 0x3f, - 0x8b, 0x54, 0x42, 0x44, 0xc2, 0x3a, 0x00, 0x7f, 0x40, 0xfd, 0xba, 0xb9, 0xd9, 0x75, 0xb4, 0xe9, - 0x68, 0xf9, 0xf6, 0x50, 0xda, 0x6f, 0x1a, 0x19, 0xa7, 0x19, 0x04, 0xb3, 0xcb, 0xda, 0x46, 0x83, - 0x13, 0x34, 0x96, 0xa0, 0x44, 0x21, 0x19, 0x54, 0x91, 0x66, 0xaf, 0x6e, 0xfb, 0xf1, 0x69, 0x6d, - 0x5f, 0x9c, 0xc5, 0xce, 0x49, 0x78, 0xcf, 0x19, 0x07, 0x68, 0xd8, 0x62, 0x53, 0x77, 0xb4, 0xe9, - 0xcb, 0x99, 0xe5, 0xdd, 0x0d, 0xec, 0x9d, 0x86, 0xf3, 0xc2, 0x23, 0x2b, 0x3c, 0xf1, 0xf1, 0x1f, - 0x34, 0x69, 0xcf, 0x8b, 0x28, 0x92, 0xa0, 0x94, 0xd9, 0x6f, 0x66, 0x3d, 0x94, 0xb6, 0x75, 0x61, - 0x23, 0xca, 0x18, 0x6d, 0x88, 0xe4, 0xa6, 0xb4, 0xdd, 0xb3, 0x6b, 0x30, 0xa1, 0x32, 0xa1, 0x8e, - 0x1f, 0x57, 0x45, 0xdf, 0xfd, 0x26, 0x7f, 0xc1, 0xd8, 0xd1, 0x3a, 0x7c, 0x98, 0x45, 0x02, 0x34, - 0x6c, 0x4b, 0xe1, 0x21, 0xd2, 0x3f, 0x0b, 0x0e, 0x46, 0x07, 0x3f, 0x47, 0xcf, 0x56, 0x20, 0x77, - 0x29, 0x03, 0x43, 0xab, 0xc0, 0x57, 0x29, 0x18, 0x28, 0x65, 0x74, 0x31, 0x42, 0x83, 0xb0, 0xe0, - 0x1c, 0xa4, 0xd1, 0x5b, 0xbe, 0xdf, 0x5f, 0x59, 0x9d, 0x7f, 0xd7, 0x96, 0xf6, 0xed, 0x11, 0x63, - 0x9e, 0x5e, 0xe0, 0x7a, 0x50, 0x3f, 0xa9, 0xf9, 0x6d, 0x00, 0x00, 0x00, 0xff, 0xff, 0xf0, 0x62, - 0x80, 0xe0, 0x95, 0x02, 0x00, 0x00, + // 400 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x52, 0x3f, 0x8f, 0xd3, 0x30, + 0x14, 0xbf, 0xdc, 0xe5, 0x8e, 0x9e, 0x39, 0x71, 0x91, 0x19, 0x88, 0x18, 0x9a, 0x60, 0x09, 0xa8, + 0x04, 0x49, 0xa4, 0xab, 0x58, 0xc2, 0xd4, 0x4c, 0x4c, 0x80, 0x52, 0x16, 0x10, 0x8b, 0xeb, 0xbc, + 0x26, 0x11, 0xc4, 0x2e, 0x76, 0x52, 0xc4, 0xc0, 0xca, 0x67, 0xe1, 0xa3, 0x20, 0xf1, 0x1d, 0x22, + 0xc1, 0x47, 0xc8, 0xc8, 0x84, 0xec, 0x34, 0x6d, 0x41, 0x15, 0x62, 0xb8, 0x29, 0xf9, 0xd9, 0xef, + 0xfd, 0xfe, 0x3c, 0x3f, 0x74, 0x29, 0x3e, 0x72, 0x90, 0xaa, 0x28, 0x57, 0xe1, 0x4a, 0x8a, 0x5a, + 0x60, 0x54, 0x81, 0xca, 0xc3, 0xfa, 0xd3, 0x0a, 0xd4, 0x5d, 0x92, 0x8b, 0x5c, 0x44, 0xe6, 0x7c, + 0xd1, 0x2c, 0x23, 0x8d, 0x0c, 0x30, 0x7f, 0x7d, 0x3d, 0xf9, 0x6e, 0xa3, 0xf3, 0x17, 0x03, 0x07, + 0x2e, 0x90, 0x5d, 0x50, 0x55, 0xb8, 0x96, 0x6f, 0x4d, 0x2e, 0x92, 0x57, 0x5d, 0xeb, 0xdd, 0xd3, + 0x38, 0x26, 0x01, 0xf1, 0xd7, 0xf4, 0x7d, 0x99, 0xd1, 0x1a, 0x62, 0x22, 0xe1, 0x43, 0x53, 0x4a, + 0xc8, 0x1e, 0xeb, 0x3b, 0xf2, 0xab, 0xf5, 0x1e, 0xe5, 0x65, 0x5d, 0x34, 0x8b, 0x90, 0x89, 0x2a, + 0xd2, 0xfa, 0xc1, 0x52, 0x34, 0x3c, 0xa3, 0x75, 0x29, 0x78, 0x04, 0x3c, 0x2f, 0x39, 0x44, 0xba, + 0x34, 0x7c, 0x46, 0x55, 0x91, 0x1a, 0x05, 0xfc, 0x14, 0x9d, 0x1a, 0xeb, 0xee, 0xb1, 0x6f, 0x4d, + 0xce, 0x93, 0xfb, 0x3b, 0x29, 0x4e, 0x2b, 0x88, 0xaf, 0x0e, 0xe9, 0x91, 0xb4, 0xef, 0xc1, 0x9f, + 0xd1, 0x85, 0x04, 0x25, 0x1a, 0xc9, 0x40, 0x53, 0xba, 0x27, 0xc6, 0xee, 0xeb, 0xae, 0xf5, 0x1e, + 0xec, 0x71, 0x4c, 0xaf, 0xcf, 0xf3, 0x1f, 0x72, 0x78, 0x8e, 0x46, 0x03, 0x76, 0x6d, 0xdf, 0x9a, + 0xdc, 0xba, 0x1a, 0x87, 0xbb, 0xb1, 0x87, 0xdb, 0x71, 0x86, 0xe9, 0xa6, 0x2a, 0xb9, 0xd3, 0xb5, + 0xde, 0xed, 0x43, 0x81, 0xb6, 0x44, 0xf8, 0x8b, 0x85, 0x2e, 0x07, 0x30, 0xcb, 0x32, 0x09, 0x4a, + 0xb9, 0xa7, 0x26, 0xd7, 0xdb, 0xae, 0xf5, 0x1e, 0xfe, 0xeb, 0x19, 0x28, 0x63, 0xb4, 0xef, 0xd0, + 0xc1, 0x82, 0xbd, 0x60, 0x4c, 0xa8, 0x4a, 0xa8, 0xcd, 0x27, 0x50, 0xd9, 0xbb, 0xa8, 0xb7, 0x38, + 0x63, 0x6c, 0xa3, 0x91, 0xfe, 0x2d, 0x4a, 0x62, 0x34, 0x1a, 0x7c, 0xe3, 0x11, 0xb2, 0x9f, 0x0b, + 0x0e, 0xce, 0x11, 0xbe, 0x89, 0x6e, 0xcc, 0x41, 0xae, 0x4b, 0x06, 0x8e, 0xa5, 0xc1, 0x4b, 0x29, + 0x18, 0x28, 0xe5, 0x1c, 0x63, 0x84, 0xce, 0xd2, 0x86, 0x73, 0x90, 0xce, 0x49, 0xf2, 0xe4, 0xdb, + 0x8f, 0xf1, 0xd1, 0xd7, 0x9f, 0x63, 0xeb, 0xcd, 0x7f, 0x8c, 0x77, 0xbb, 0xba, 0x8b, 0x33, 0xb3, + 0x8b, 0xd3, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x54, 0xea, 0xef, 0x74, 0xce, 0x02, 0x00, 0x00, } func (this *Ownership) Equal(that interface{}) bool { @@ -151,13 +152,13 @@ func (this *Ownership) Equal(that interface{}) bool { } else if this == nil { return false } - if !this.Hash.Equal(that1.Hash) { + if !bytes.Equal(this.Hash, that1.Hash) { return false } if this.Owner != that1.Owner { return false } - if !this.ResourceHash.Equal(that1.ResourceHash) { + if !bytes.Equal(this.ResourceHash, that1.ResourceHash) { return false } if this.Resource != that1.Resource { diff --git a/process/codec.go b/process/codec.go index 39f345304..33da5d5d7 100644 --- a/process/codec.go +++ b/process/codec.go @@ -9,7 +9,7 @@ import ( func RegisterCodec(cdc *codec.Codec) { cdc.RegisterInterface((*isProcess_Node_Map_Output_Value)(nil), nil) cdc.RegisterConcrete(&Process_Node_Map_Output_Ref{}, "mesg.types.Process_Node_Map_Output_Ref", nil) - cdc.RegisterConcrete(&Process_Node_Map_Output_Reference{}, "mesg.types.Process_Node_Map_Output_Reference", nil) + cdc.RegisterConcrete(&Process_Node_Reference{}, "mesg.types.Process_Node_Reference", nil) cdc.RegisterConcrete(&Process_Node_Map_Output_Null_{}, "mesg.types.Process_Node_Map_Output_Null_", nil) cdc.RegisterConcrete(&Process_Node_Map_Output_StringConst{}, "mesg.types.Process_Node_Map_Output_StringConst", nil) cdc.RegisterConcrete(&Process_Node_Map_Output_DoubleConst{}, "mesg.types.Process_Node_Map_Output_DoubleConst", nil) @@ -29,9 +29,9 @@ func RegisterCodec(cdc *codec.Codec) { cdc.RegisterConcrete(&Process_Node_Map{}, "mesg.types.Process_Node_Map", nil) cdc.RegisterConcrete(&Process_Node_Filter_{}, "mesg.types.Process_Node_Filter_", nil) cdc.RegisterConcrete(&Process_Node_Filter{}, "mesg.types.Process_Node_Filter", nil) - cdc.RegisterInterface((*isProcess_Node_Map_Output_Reference_Path_Selector)(nil), nil) - cdc.RegisterConcrete(&Process_Node_Map_Output_Reference_Path_Key{}, "mesg.types.Process_Node_Map_Output_Reference_Path_Key", nil) - cdc.RegisterConcrete(&Process_Node_Map_Output_Reference_Path_Index{}, "mesg.types.Process_Node_Map_Output_Reference_Path_Index", nil) + cdc.RegisterInterface((*isProcess_Node_Reference_Path_Selector)(nil), nil) + cdc.RegisterConcrete(&Process_Node_Reference_Path_Key{}, "mesg.types.Process_Node_Reference_Path_Key", nil) + cdc.RegisterConcrete(&Process_Node_Reference_Path_Index{}, "mesg.types.Process_Node_Reference_Path_Index", nil) } // KeyOutput is a simple key/value representation of one output of a Process_Node_Map. diff --git a/process/filter.go b/process/filter.go index 2fa5a0b4b..730b68b10 100644 --- a/process/filter.go +++ b/process/filter.go @@ -1,20 +1,54 @@ package process -import "github.com/mesg-foundation/engine/protobuf/types" +import ( + "errors" + "strings" -// Match returns true if the data match the current list of filters -func (f Process_Node_Filter) Match(data *types.Struct) bool { - for _, condition := range f.Conditions { - if !condition.Match(data) { - return false - } - } - - return true -} + "github.com/mesg-foundation/engine/protobuf/types" +) // Match returns true the current filter matches the given data -func (f Process_Node_Filter_Condition) Match(data *types.Struct) bool { - return f.Predicate == Process_Node_Filter_Condition_EQ && - data.Fields[f.Key].GetStringValue() == f.Value +func (f *Process_Node_Filter_Condition) Match(data *types.Value) (bool, error) { + switch f.Predicate { + case Process_Node_Filter_Condition_EQ: + return data.Equal(f.Value), nil + case Process_Node_Filter_Condition_GT, + Process_Node_Filter_Condition_GTE, + Process_Node_Filter_Condition_LT, + Process_Node_Filter_Condition_LTE: + n1, ok1 := data.Kind.(*types.Value_NumberValue) + n2, ok2 := f.Value.Kind.(*types.Value_NumberValue) + if !ok1 || !ok2 { + return false, errors.New("predicates GT, GTE, LT, and LTE are only compatible with type Number") + } + switch f.Predicate { + case Process_Node_Filter_Condition_GT: + return n1.NumberValue > n2.NumberValue, nil + case Process_Node_Filter_Condition_GTE: + return n1.NumberValue >= n2.NumberValue, nil + case Process_Node_Filter_Condition_LT: + return n1.NumberValue < n2.NumberValue, nil + case Process_Node_Filter_Condition_LTE: + return n1.NumberValue <= n2.NumberValue, nil + } + case Process_Node_Filter_Condition_CONTAINS: + switch dataTyped := data.Kind.(type) { + case *types.Value_ListValue: + for _, value := range dataTyped.ListValue.Values { + if value.Equal(f.Value) { + return true, nil + } + } + return false, nil + case *types.Value_StringValue: + filter, ok := f.Value.Kind.(*types.Value_StringValue) + if !ok { + return false, errors.New("predicates CONTAINS on data of type String is only compatible with value of type String") + } + return strings.Contains(dataTyped.StringValue, filter.StringValue), nil + default: + return false, errors.New("predicate CONTAINS is only compatible on data of type List or String") + } + } + return false, errors.New("predicates type is unknown") } diff --git a/process/filter_test.go b/process/filter_test.go index e42eaadeb..645ad6e99 100644 --- a/process/filter_test.go +++ b/process/filter_test.go @@ -9,113 +9,304 @@ import ( func TestMatch(t *testing.T) { var tests = []struct { - name string - filter Process_Node_Filter - data *types.Struct - match bool + name string + condition *Process_Node_Filter_Condition + data *types.Value + match bool + err string }{ { name: "not matching filter", - filter: Process_Node_Filter{ - Conditions: []Process_Node_Filter_Condition{ - { - Key: "foo", - Predicate: Process_Node_Filter_Condition_EQ, - Value: "xx", + condition: &Process_Node_Filter_Condition{ + Predicate: Process_Node_Filter_Condition_EQ, + Value: &types.Value{ + Kind: &types.Value_StringValue{ + StringValue: "xx", }, }, }, - data: &types.Struct{ - Fields: map[string]*types.Value{ - "foo": { - Kind: &types.Value_StringValue{ - StringValue: "bar", - }, + data: &types.Value{ + Kind: &types.Value_StringValue{ + StringValue: "bar", + }, + }, + match: false, + }, + { + name: "matching GT", + condition: &Process_Node_Filter_Condition{ + Predicate: Process_Node_Filter_Condition_GT, + Value: &types.Value{ + Kind: &types.Value_NumberValue{ + NumberValue: 1, }, }, }, + data: &types.Value{ + Kind: &types.Value_NumberValue{ + NumberValue: 2, + }, + }, + match: true, + }, + { + name: "non matching GT", + condition: &Process_Node_Filter_Condition{ + Predicate: Process_Node_Filter_Condition_GT, + Value: &types.Value{ + Kind: &types.Value_NumberValue{ + NumberValue: 2, + }, + }, + }, + data: &types.Value{ + Kind: &types.Value_NumberValue{ + NumberValue: 1, + }, + }, match: false, }, { - name: "matching multiple conditions", - filter: Process_Node_Filter{ - Conditions: []Process_Node_Filter_Condition{ - { - Key: "foo", - Predicate: Process_Node_Filter_Condition_EQ, - Value: "bar", + name: "GT wrong type", + condition: &Process_Node_Filter_Condition{ + Predicate: Process_Node_Filter_Condition_LTE, + Value: &types.Value{ + Kind: &types.Value_NumberValue{ + NumberValue: 1, }, - { - Key: "xxx", - Predicate: Process_Node_Filter_Condition_EQ, - Value: "yyy", + }, + }, + data: &types.Value{ + Kind: &types.Value_StringValue{ + StringValue: "foo", + }, + }, + match: false, + err: "predicates GT, GTE, LT, and LTE are only compatible with type Number", + }, + { + name: "matching GTE", + condition: &Process_Node_Filter_Condition{ + Predicate: Process_Node_Filter_Condition_GTE, + Value: &types.Value{ + Kind: &types.Value_NumberValue{ + NumberValue: 1, }, }, }, - data: &types.Struct{ - Fields: map[string]*types.Value{ - "foo": { - Kind: &types.Value_StringValue{ - StringValue: "bar", - }, + data: &types.Value{ + Kind: &types.Value_NumberValue{ + NumberValue: 1, + }, + }, + match: true, + }, + { + name: "non matching GTE", + condition: &Process_Node_Filter_Condition{ + Predicate: Process_Node_Filter_Condition_GTE, + Value: &types.Value{ + Kind: &types.Value_NumberValue{ + NumberValue: 2, }, - "xxx": { - Kind: &types.Value_StringValue{ - StringValue: "yyy", - }, + }, + }, + data: &types.Value{ + Kind: &types.Value_NumberValue{ + NumberValue: 1, + }, + }, + match: false, + }, + { + name: "matching LT", + condition: &Process_Node_Filter_Condition{ + Predicate: Process_Node_Filter_Condition_LT, + Value: &types.Value{ + Kind: &types.Value_NumberValue{ + NumberValue: 2, }, - "aaa": { - Kind: &types.Value_StringValue{ - StringValue: "bbb", - }, + }, + }, + data: &types.Value{ + Kind: &types.Value_NumberValue{ + NumberValue: 1, + }, + }, + match: true, + }, + { + name: "non matching LT", + condition: &Process_Node_Filter_Condition{ + Predicate: Process_Node_Filter_Condition_LT, + Value: &types.Value{ + Kind: &types.Value_NumberValue{ + NumberValue: 1, + }, + }, + }, + data: &types.Value{ + Kind: &types.Value_NumberValue{ + NumberValue: 2, + }, + }, + match: false, + }, + { + name: "matching LTE", + condition: &Process_Node_Filter_Condition{ + Predicate: Process_Node_Filter_Condition_LTE, + Value: &types.Value{ + Kind: &types.Value_NumberValue{ + NumberValue: 1, }, }, }, + data: &types.Value{ + Kind: &types.Value_NumberValue{ + NumberValue: 1, + }, + }, match: true, }, { - name: "non matching multiple conditions", - filter: Process_Node_Filter{ - Conditions: []Process_Node_Filter_Condition{ - { - Key: "foo", - Predicate: Process_Node_Filter_Condition_EQ, - Value: "bar", + name: "non matching LTE", + condition: &Process_Node_Filter_Condition{ + Predicate: Process_Node_Filter_Condition_LTE, + Value: &types.Value{ + Kind: &types.Value_NumberValue{ + NumberValue: 1, }, - { - Key: "xxx", - Predicate: Process_Node_Filter_Condition_EQ, - Value: "aaa", + }, + }, + data: &types.Value{ + Kind: &types.Value_NumberValue{ + NumberValue: 2, + }, + }, + match: false, + }, + { + name: "matching contains", + condition: &Process_Node_Filter_Condition{ + Predicate: Process_Node_Filter_Condition_CONTAINS, + Value: &types.Value{ + Kind: &types.Value_StringValue{ + StringValue: "foo", }, }, }, - data: &types.Struct{ - Fields: map[string]*types.Value{ - "foo": { - Kind: &types.Value_StringValue{ - StringValue: "bar", + data: &types.Value{ + Kind: &types.Value_ListValue{ + ListValue: &types.ListValue{ + Values: []*types.Value{ + { + Kind: &types.Value_StringValue{ + StringValue: "foo", + }, + }, }, }, - "xxx": { - Kind: &types.Value_StringValue{ - StringValue: "yyy", - }, + }, + }, + match: true, + }, + { + name: "non matching contains", + condition: &Process_Node_Filter_Condition{ + Predicate: Process_Node_Filter_Condition_CONTAINS, + Value: &types.Value{ + Kind: &types.Value_StringValue{ + StringValue: "foo", }, - "aaa": { - Kind: &types.Value_StringValue{ - StringValue: "bbb", + }, + }, + data: &types.Value{ + Kind: &types.Value_ListValue{ + ListValue: &types.ListValue{ + Values: []*types.Value{ + { + Kind: &types.Value_StringValue{ + StringValue: "bar", + }, + }, }, }, }, }, match: false, }, + { + name: "wrong type contains", + condition: &Process_Node_Filter_Condition{ + Predicate: Process_Node_Filter_Condition_CONTAINS, + Value: &types.Value{ + Kind: &types.Value_StringValue{ + StringValue: "foo", + }, + }, + }, + data: &types.Value{ + Kind: &types.Value_NumberValue{ + NumberValue: 10, + }, + }, + match: false, + err: "predicate CONTAINS is only compatible on data of type List or String", + }, + { + name: "wrong type contains string", + condition: &Process_Node_Filter_Condition{ + Predicate: Process_Node_Filter_Condition_CONTAINS, + Value: &types.Value{ + Kind: &types.Value_NumberValue{ + NumberValue: 10, + }, + }, + }, + data: &types.Value{ + Kind: &types.Value_StringValue{ + StringValue: "foo", + }, + }, + match: false, + err: "predicates CONTAINS on data of type String is only compatible with value of type String", + }, + { + name: "string contain", + condition: &Process_Node_Filter_Condition{ + Predicate: Process_Node_Filter_Condition_CONTAINS, + Value: &types.Value{ + Kind: &types.Value_StringValue{ + StringValue: "world", + }, + }, + }, + data: &types.Value{ + Kind: &types.Value_StringValue{ + StringValue: "hello world", + }, + }, + match: true, + }, + { + name: "unknown predicate", + condition: &Process_Node_Filter_Condition{ + Predicate: Process_Node_Filter_Condition_Unknown, + }, + match: false, + err: "predicates type is unknown", + }, } for _, tt := range tests { tt := tt t.Run(tt.name, func(t *testing.T) { - require.Equal(t, tt.match, tt.filter.Match(tt.data)) + match, err := tt.condition.Match(tt.data) + require.Equal(t, tt.match, match) + if len(tt.err) > 0 || err != nil { + require.EqualError(t, err, tt.err) + } }) } } diff --git a/process/process.go b/process/process.go index db7b15b4e..837822ea7 100644 --- a/process/process.go +++ b/process/process.go @@ -4,13 +4,14 @@ import ( "fmt" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/mesg-foundation/engine/ext/xvalidator" "github.com/mesg-foundation/engine/hash" + "github.com/mesg-foundation/engine/protobuf/types" "github.com/tendermint/tendermint/crypto" - validator "gopkg.in/go-playground/validator.v9" ) // New returns a new process and validate it. -func New(name string, nodes []*Process_Node, edges []*Process_Edge) *Process { +func New(name string, nodes []*Process_Node, edges []*Process_Edge) (*Process, error) { p := &Process{ Name: name, Nodes: nodes, @@ -18,12 +19,12 @@ func New(name string, nodes []*Process_Node, edges []*Process_Edge) *Process { } p.Hash = hash.Dump(p) p.Address = sdk.AccAddress(crypto.AddressHash(p.Hash)) - return p + return p, p.Validate() } // Validate returns an error if the process is invalid for whatever reason func (w *Process) Validate() error { - if err := validator.New().Struct(w); err != nil { + if err := xvalidator.Struct(w); err != nil { return err } if err := w.validate(); err != nil { @@ -33,15 +34,30 @@ func (w *Process) Validate() error { return err } for _, node := range w.Nodes { - mapNode := node.GetMap() - if mapNode != nil { - for _, output := range mapNode.Outputs { + switch n := node.GetType().(type) { + case *Process_Node_Map_: + for _, output := range n.Map.Outputs { if ref := output.GetRef(); ref != nil { if _, err := w.FindNode(ref.NodeKey); err != nil { return err } } } + case *Process_Node_Filter_: + for _, condition := range n.Filter.Conditions { + switch condition.Predicate { + case Process_Node_Filter_Condition_GT, + Process_Node_Filter_Condition_GTE, + Process_Node_Filter_Condition_LT, + Process_Node_Filter_Condition_LTE: + if _, ok := condition.Value.Kind.(*types.Value_NumberValue); !ok { + return fmt.Errorf("filter with condition GT, GTE, LT or LTE only works with value of type Number") + } + } + if _, err := w.FindNode(condition.Ref.NodeKey); err != nil { + return err + } + } } } if err := w.shouldBeDirectedTree(); err != nil { diff --git a/process/process.pb.go b/process/process.pb.go index 60238201d..b1b68ad68 100644 --- a/process/process.pb.go +++ b/process/process.pb.go @@ -10,6 +10,7 @@ import ( _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" github_com_mesg_foundation_engine_hash "github.com/mesg-foundation/engine/hash" + types "github.com/mesg-foundation/engine/protobuf/types" math "math" ) @@ -54,16 +55,36 @@ const ( Process_Node_Filter_Condition_Unknown Process_Node_Filter_Condition_Predicate = 0 // Equal Process_Node_Filter_Condition_EQ Process_Node_Filter_Condition_Predicate = 1 + // Greater than + Process_Node_Filter_Condition_GT Process_Node_Filter_Condition_Predicate = 2 + // Greater or equal than + Process_Node_Filter_Condition_GTE Process_Node_Filter_Condition_Predicate = 3 + // Lesser than + Process_Node_Filter_Condition_LT Process_Node_Filter_Condition_Predicate = 4 + // Lesser or equal than + Process_Node_Filter_Condition_LTE Process_Node_Filter_Condition_Predicate = 5 + // CONTAINS + Process_Node_Filter_Condition_CONTAINS Process_Node_Filter_Condition_Predicate = 6 ) var Process_Node_Filter_Condition_Predicate_name = map[int32]string{ 0: "Unknown", 1: "EQ", + 2: "GT", + 3: "GTE", + 4: "LT", + 5: "LTE", + 6: "CONTAINS", } var Process_Node_Filter_Condition_Predicate_value = map[string]int32{ - "Unknown": 0, - "EQ": 1, + "Unknown": 0, + "EQ": 1, + "GT": 2, + "GTE": 3, + "LT": 4, + "LTE": 5, + "CONTAINS": 6, } func (x Process_Node_Filter_Condition_Predicate) String() string { @@ -77,15 +98,15 @@ func (Process_Node_Filter_Condition_Predicate) EnumDescriptor() ([]byte, []int) // A process is a configuration to trigger a specific task when certains conditions of a trigger are valid. type Process struct { // Process's hash - Hash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=hash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"hash" hash:"-" validate:"required"` + Hash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=hash,proto3,casttype=github.com/mesg-foundation/engine/hash.Hash" json:"hash,omitempty" hash:"-" validate:"required,hash"` // Process's name - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty" hash:"name:2" validate:"required"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty" hash:"name:2" validate:"required,printascii"` // Nodes with information related to the execution to trigger. Nodes []*Process_Node `protobuf:"bytes,4,rep,name=nodes,proto3" json:"nodes,omitempty" hash:"name:4" validate:"dive,required"` // Edges to create the link between the nodes. Edges []*Process_Edge `protobuf:"bytes,5,rep,name=edges,proto3" json:"edges,omitempty" hash:"name:5" validate:"dive,required"` // The address of the process. - Address github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,6,opt,name=address,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"address,omitempty" hash:"-"` + Address github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,6,opt,name=address,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"address,omitempty" hash:"-" validate:"required,accaddress"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -237,7 +258,7 @@ func (*Process_Node) XXX_OneofWrappers() []interface{} { type Process_Node_Result struct { // Hash of the instance that triggers the process. - InstanceHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,2,opt,name=instanceHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"instanceHash" hash:"name:2" validate:"required"` + InstanceHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,2,opt,name=instanceHash,proto3,casttype=github.com/mesg-foundation/engine/hash.Hash" json:"instanceHash,omitempty" hash:"name:2" validate:"required,hash"` // Key of the task that triggers the process. TaskKey string `protobuf:"bytes,3,opt,name=taskKey,proto3" json:"taskKey,omitempty" hash:"name:3" validate:"printascii,required"` XXX_NoUnkeyedLiteral struct{} `json:"-"` @@ -271,7 +292,7 @@ var xxx_messageInfo_Process_Node_Result proto.InternalMessageInfo type Process_Node_Event struct { // Hash of the instance that triggers the process. - InstanceHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,2,opt,name=instanceHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"instanceHash" hash:"name:2" validate:"required"` + InstanceHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,2,opt,name=instanceHash,proto3,casttype=github.com/mesg-foundation/engine/hash.Hash" json:"instanceHash,omitempty" hash:"name:2" validate:"required,hash"` // Key of the event that triggers the process. EventKey string `protobuf:"bytes,3,opt,name=eventKey,proto3" json:"eventKey,omitempty" hash:"name:3" validate:"printascii,required"` XXX_NoUnkeyedLiteral struct{} `json:"-"` @@ -305,7 +326,7 @@ var xxx_messageInfo_Process_Node_Event proto.InternalMessageInfo type Process_Node_Task struct { // Hash of the instance to execute. - InstanceHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,2,opt,name=instanceHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"instanceHash" hash:"name:2" validate:"required"` + InstanceHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,2,opt,name=instanceHash,proto3,casttype=github.com/mesg-foundation/engine/hash.Hash" json:"instanceHash,omitempty" hash:"name:2" validate:"required,hash"` // Task of the instance to execute. TaskKey string `protobuf:"bytes,3,opt,name=taskKey,proto3" json:"taskKey,omitempty" hash:"name:3" validate:"printascii,required"` XXX_NoUnkeyedLiteral struct{} `json:"-"` @@ -426,7 +447,7 @@ type Process_Node_Map_Output_BoolConst struct { BoolConst bool `protobuf:"varint,4,opt,name=bool_const,json=boolConst,proto3,oneof" json:"bool_const,omitempty" hash:"name:4"` } type Process_Node_Map_Output_Ref struct { - Ref *Process_Node_Map_Output_Reference `protobuf:"bytes,5,opt,name=ref,proto3,oneof" json:"ref,omitempty" hash:"name:5"` + Ref *Process_Node_Reference `protobuf:"bytes,5,opt,name=ref,proto3,oneof" json:"ref,omitempty" hash:"name:5"` } type Process_Node_Map_Output_List_ struct { List *Process_Node_Map_Output_List `protobuf:"bytes,6,opt,name=list,proto3,oneof" json:"list,omitempty" hash:"name:6"` @@ -478,7 +499,7 @@ func (m *Process_Node_Map_Output) GetBoolConst() bool { return false } -func (m *Process_Node_Map_Output) GetRef() *Process_Node_Map_Output_Reference { +func (m *Process_Node_Map_Output) GetRef() *Process_Node_Reference { if x, ok := m.GetValue().(*Process_Node_Map_Output_Ref); ok { return x.Ref } @@ -576,125 +597,9 @@ func (m *Process_Node_Map_Output_Map) XXX_DiscardUnknown() { var xxx_messageInfo_Process_Node_Map_Output_Map proto.InternalMessageInfo -type Process_Node_Map_Output_Reference struct { - NodeKey string `protobuf:"bytes,1,opt,name=nodeKey,proto3" json:"nodeKey,omitempty" hash:"name:1" validate:"required"` - Path *Process_Node_Map_Output_Reference_Path `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty" hash:"name:2"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Process_Node_Map_Output_Reference) Reset() { *m = Process_Node_Map_Output_Reference{} } -func (m *Process_Node_Map_Output_Reference) String() string { return proto.CompactTextString(m) } -func (*Process_Node_Map_Output_Reference) ProtoMessage() {} -func (*Process_Node_Map_Output_Reference) Descriptor() ([]byte, []int) { - return fileDescriptor_54c4d0e8c0aaf5c3, []int{0, 0, 3, 0, 2} -} -func (m *Process_Node_Map_Output_Reference) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Process_Node_Map_Output_Reference.Unmarshal(m, b) -} -func (m *Process_Node_Map_Output_Reference) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Process_Node_Map_Output_Reference.Marshal(b, m, deterministic) -} -func (m *Process_Node_Map_Output_Reference) XXX_Merge(src proto.Message) { - xxx_messageInfo_Process_Node_Map_Output_Reference.Merge(m, src) -} -func (m *Process_Node_Map_Output_Reference) XXX_Size() int { - return xxx_messageInfo_Process_Node_Map_Output_Reference.Size(m) -} -func (m *Process_Node_Map_Output_Reference) XXX_DiscardUnknown() { - xxx_messageInfo_Process_Node_Map_Output_Reference.DiscardUnknown(m) -} - -var xxx_messageInfo_Process_Node_Map_Output_Reference proto.InternalMessageInfo - -type Process_Node_Map_Output_Reference_Path struct { - // Types that are valid to be assigned to Selector: - // *Process_Node_Map_Output_Reference_Path_Key - // *Process_Node_Map_Output_Reference_Path_Index - Selector isProcess_Node_Map_Output_Reference_Path_Selector `protobuf_oneof:"selector"` - // Path can be nil if on the leaf - Path *Process_Node_Map_Output_Reference_Path `protobuf:"bytes,3,opt,name=path,proto3" json:"path,omitempty" hash:"name:3"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Process_Node_Map_Output_Reference_Path) Reset() { - *m = Process_Node_Map_Output_Reference_Path{} -} -func (m *Process_Node_Map_Output_Reference_Path) String() string { return proto.CompactTextString(m) } -func (*Process_Node_Map_Output_Reference_Path) ProtoMessage() {} -func (*Process_Node_Map_Output_Reference_Path) Descriptor() ([]byte, []int) { - return fileDescriptor_54c4d0e8c0aaf5c3, []int{0, 0, 3, 0, 2, 0} -} -func (m *Process_Node_Map_Output_Reference_Path) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Process_Node_Map_Output_Reference_Path.Unmarshal(m, b) -} -func (m *Process_Node_Map_Output_Reference_Path) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Process_Node_Map_Output_Reference_Path.Marshal(b, m, deterministic) -} -func (m *Process_Node_Map_Output_Reference_Path) XXX_Merge(src proto.Message) { - xxx_messageInfo_Process_Node_Map_Output_Reference_Path.Merge(m, src) -} -func (m *Process_Node_Map_Output_Reference_Path) XXX_Size() int { - return xxx_messageInfo_Process_Node_Map_Output_Reference_Path.Size(m) -} -func (m *Process_Node_Map_Output_Reference_Path) XXX_DiscardUnknown() { - xxx_messageInfo_Process_Node_Map_Output_Reference_Path.DiscardUnknown(m) -} - -var xxx_messageInfo_Process_Node_Map_Output_Reference_Path proto.InternalMessageInfo - -type isProcess_Node_Map_Output_Reference_Path_Selector interface { - isProcess_Node_Map_Output_Reference_Path_Selector() - Equal(interface{}) bool -} - -type Process_Node_Map_Output_Reference_Path_Key struct { - Key string `protobuf:"bytes,1,opt,name=key,proto3,oneof" json:"key,omitempty" hash:"name:1" validate:"printascii"` -} -type Process_Node_Map_Output_Reference_Path_Index struct { - Index uint64 `protobuf:"varint,2,opt,name=index,proto3,oneof" json:"index,omitempty" hash:"name:2"` -} - -func (*Process_Node_Map_Output_Reference_Path_Key) isProcess_Node_Map_Output_Reference_Path_Selector() { -} -func (*Process_Node_Map_Output_Reference_Path_Index) isProcess_Node_Map_Output_Reference_Path_Selector() { -} - -func (m *Process_Node_Map_Output_Reference_Path) GetSelector() isProcess_Node_Map_Output_Reference_Path_Selector { - if m != nil { - return m.Selector - } - return nil -} - -func (m *Process_Node_Map_Output_Reference_Path) GetKey() string { - if x, ok := m.GetSelector().(*Process_Node_Map_Output_Reference_Path_Key); ok { - return x.Key - } - return "" -} - -func (m *Process_Node_Map_Output_Reference_Path) GetIndex() uint64 { - if x, ok := m.GetSelector().(*Process_Node_Map_Output_Reference_Path_Index); ok { - return x.Index - } - return 0 -} - -// XXX_OneofWrappers is for the internal use of the proto package. -func (*Process_Node_Map_Output_Reference_Path) XXX_OneofWrappers() []interface{} { - return []interface{}{ - (*Process_Node_Map_Output_Reference_Path_Key)(nil), - (*Process_Node_Map_Output_Reference_Path_Index)(nil), - } -} - type Process_Node_Filter struct { // List of condition to apply for this filter - Conditions []Process_Node_Filter_Condition `protobuf:"bytes,2,rep,name=conditions,proto3" json:"conditions" hash:"name:2"` + Conditions []Process_Node_Filter_Condition `protobuf:"bytes,2,rep,name=conditions,proto3" json:"conditions" hash:"name:2" validate:"dive"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -725,15 +630,15 @@ func (m *Process_Node_Filter) XXX_DiscardUnknown() { var xxx_messageInfo_Process_Node_Filter proto.InternalMessageInfo type Process_Node_Filter_Condition struct { - // Key to check. - Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty" hash:"name:1" validate:"required,printascii"` // Type of condition to apply. Predicate Process_Node_Filter_Condition_Predicate `protobuf:"varint,2,opt,name=predicate,proto3,enum=mesg.types.Process_Node_Filter_Condition_Predicate" json:"predicate,omitempty" hash:"name:2" validate:"required"` // Value of the filter. - Value string `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty" hash:"name:3"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + Value *types.Value `protobuf:"bytes,4,opt,name=value,proto3" json:"value,omitempty" hash:"name:4" validate:"required"` + // Input defined as reference. + Ref *Process_Node_Reference `protobuf:"bytes,5,opt,name=ref,proto3" json:"ref,omitempty" hash:"name:5" validate:"required"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *Process_Node_Filter_Condition) Reset() { *m = Process_Node_Filter_Condition{} } @@ -760,6 +665,119 @@ func (m *Process_Node_Filter_Condition) XXX_DiscardUnknown() { var xxx_messageInfo_Process_Node_Filter_Condition proto.InternalMessageInfo +type Process_Node_Reference struct { + NodeKey string `protobuf:"bytes,1,opt,name=nodeKey,proto3" json:"nodeKey,omitempty" hash:"name:1" validate:"required"` + // Path can be nil if referencing the whole node's output + Path *Process_Node_Reference_Path `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty" hash:"name:2"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Process_Node_Reference) Reset() { *m = Process_Node_Reference{} } +func (m *Process_Node_Reference) String() string { return proto.CompactTextString(m) } +func (*Process_Node_Reference) ProtoMessage() {} +func (*Process_Node_Reference) Descriptor() ([]byte, []int) { + return fileDescriptor_54c4d0e8c0aaf5c3, []int{0, 0, 5} +} +func (m *Process_Node_Reference) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Process_Node_Reference.Unmarshal(m, b) +} +func (m *Process_Node_Reference) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Process_Node_Reference.Marshal(b, m, deterministic) +} +func (m *Process_Node_Reference) XXX_Merge(src proto.Message) { + xxx_messageInfo_Process_Node_Reference.Merge(m, src) +} +func (m *Process_Node_Reference) XXX_Size() int { + return xxx_messageInfo_Process_Node_Reference.Size(m) +} +func (m *Process_Node_Reference) XXX_DiscardUnknown() { + xxx_messageInfo_Process_Node_Reference.DiscardUnknown(m) +} + +var xxx_messageInfo_Process_Node_Reference proto.InternalMessageInfo + +type Process_Node_Reference_Path struct { + // Types that are valid to be assigned to Selector: + // *Process_Node_Reference_Path_Key + // *Process_Node_Reference_Path_Index + Selector isProcess_Node_Reference_Path_Selector `protobuf_oneof:"selector"` + // Path can be nil if on the leaf + Path *Process_Node_Reference_Path `protobuf:"bytes,3,opt,name=path,proto3" json:"path,omitempty" hash:"name:3"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Process_Node_Reference_Path) Reset() { *m = Process_Node_Reference_Path{} } +func (m *Process_Node_Reference_Path) String() string { return proto.CompactTextString(m) } +func (*Process_Node_Reference_Path) ProtoMessage() {} +func (*Process_Node_Reference_Path) Descriptor() ([]byte, []int) { + return fileDescriptor_54c4d0e8c0aaf5c3, []int{0, 0, 5, 0} +} +func (m *Process_Node_Reference_Path) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Process_Node_Reference_Path.Unmarshal(m, b) +} +func (m *Process_Node_Reference_Path) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Process_Node_Reference_Path.Marshal(b, m, deterministic) +} +func (m *Process_Node_Reference_Path) XXX_Merge(src proto.Message) { + xxx_messageInfo_Process_Node_Reference_Path.Merge(m, src) +} +func (m *Process_Node_Reference_Path) XXX_Size() int { + return xxx_messageInfo_Process_Node_Reference_Path.Size(m) +} +func (m *Process_Node_Reference_Path) XXX_DiscardUnknown() { + xxx_messageInfo_Process_Node_Reference_Path.DiscardUnknown(m) +} + +var xxx_messageInfo_Process_Node_Reference_Path proto.InternalMessageInfo + +type isProcess_Node_Reference_Path_Selector interface { + isProcess_Node_Reference_Path_Selector() + Equal(interface{}) bool +} + +type Process_Node_Reference_Path_Key struct { + Key string `protobuf:"bytes,1,opt,name=key,proto3,oneof" json:"key,omitempty" hash:"name:1" validate:"printascii"` +} +type Process_Node_Reference_Path_Index struct { + Index uint64 `protobuf:"varint,2,opt,name=index,proto3,oneof" json:"index,omitempty" hash:"name:2"` +} + +func (*Process_Node_Reference_Path_Key) isProcess_Node_Reference_Path_Selector() {} +func (*Process_Node_Reference_Path_Index) isProcess_Node_Reference_Path_Selector() {} + +func (m *Process_Node_Reference_Path) GetSelector() isProcess_Node_Reference_Path_Selector { + if m != nil { + return m.Selector + } + return nil +} + +func (m *Process_Node_Reference_Path) GetKey() string { + if x, ok := m.GetSelector().(*Process_Node_Reference_Path_Key); ok { + return x.Key + } + return "" +} + +func (m *Process_Node_Reference_Path) GetIndex() uint64 { + if x, ok := m.GetSelector().(*Process_Node_Reference_Path_Index); ok { + return x.Index + } + return 0 +} + +// XXX_OneofWrappers is for the internal use of the proto package. +func (*Process_Node_Reference_Path) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*Process_Node_Reference_Path_Key)(nil), + (*Process_Node_Reference_Path_Index)(nil), + } +} + type Process_Edge struct { // Source of the edge. Src string `protobuf:"bytes,1,opt,name=src,proto3" json:"src,omitempty" hash:"name:1" validate:"required"` @@ -808,88 +826,94 @@ func init() { proto.RegisterType((*Process_Node_Map_Output_List)(nil), "mesg.types.Process.Node.Map.Output.List") proto.RegisterType((*Process_Node_Map_Output_Map)(nil), "mesg.types.Process.Node.Map.Output.Map") proto.RegisterMapType((map[string]*Process_Node_Map_Output)(nil), "mesg.types.Process.Node.Map.Output.Map.OutputsEntry") - proto.RegisterType((*Process_Node_Map_Output_Reference)(nil), "mesg.types.Process.Node.Map.Output.Reference") - proto.RegisterType((*Process_Node_Map_Output_Reference_Path)(nil), "mesg.types.Process.Node.Map.Output.Reference.Path") proto.RegisterType((*Process_Node_Filter)(nil), "mesg.types.Process.Node.Filter") proto.RegisterType((*Process_Node_Filter_Condition)(nil), "mesg.types.Process.Node.Filter.Condition") + proto.RegisterType((*Process_Node_Reference)(nil), "mesg.types.Process.Node.Reference") + proto.RegisterType((*Process_Node_Reference_Path)(nil), "mesg.types.Process.Node.Reference.Path") proto.RegisterType((*Process_Edge)(nil), "mesg.types.Process.Edge") } func init() { proto.RegisterFile("process.proto", fileDescriptor_54c4d0e8c0aaf5c3) } var fileDescriptor_54c4d0e8c0aaf5c3 = []byte{ - // 1135 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x97, 0xdd, 0x6e, 0x1b, 0x45, - 0x14, 0xc7, 0xb3, 0xf6, 0xda, 0x8e, 0x4f, 0xdc, 0x28, 0x8c, 0x04, 0x58, 0xa6, 0xc4, 0xc6, 0x15, - 0x24, 0x81, 0x64, 0x4d, 0xec, 0xb4, 0xa5, 0x41, 0x08, 0x65, 0x23, 0x57, 0x85, 0xba, 0x21, 0x35, - 0x0d, 0x1f, 0xbd, 0x09, 0x9b, 0xdd, 0xb1, 0xbd, 0xca, 0x7a, 0xc6, 0xdd, 0x99, 0x0d, 0x09, 0xe2, - 0x06, 0x9e, 0x81, 0x4b, 0x1e, 0x80, 0x47, 0xe9, 0x25, 0x02, 0x21, 0x24, 0x84, 0x2c, 0xd1, 0x47, - 0xf0, 0x25, 0x37, 0xa0, 0x99, 0x59, 0x3b, 0x9b, 0xd8, 0x4e, 0x37, 0xa5, 0x08, 0x89, 0xab, 0x64, - 0xd7, 0xe7, 0xfc, 0x66, 0xce, 0xff, 0x9c, 0x39, 0x67, 0x16, 0xae, 0xf4, 0x7c, 0x6a, 0x63, 0xc6, - 0x8c, 0x9e, 0x4f, 0x39, 0x45, 0xd0, 0xc5, 0xac, 0x6d, 0xf0, 0x93, 0x1e, 0x66, 0x85, 0x72, 0x9b, - 0xb6, 0x69, 0x45, 0xbe, 0x3f, 0x08, 0x5a, 0x15, 0xf1, 0x24, 0x1f, 0xe4, 0x7f, 0xca, 0xbe, 0xfc, - 0xeb, 0x2b, 0x90, 0xd9, 0x55, 0x04, 0xd4, 0x06, 0xbd, 0x63, 0xb1, 0x4e, 0x5e, 0x2b, 0x69, 0xcb, - 0x39, 0xf3, 0xe3, 0xc7, 0xfd, 0xe2, 0xcc, 0x6f, 0xfd, 0xe2, 0x5b, 0x6d, 0x97, 0x77, 0x82, 0x03, - 0xc3, 0xa6, 0xdd, 0x8a, 0x80, 0xaf, 0xb5, 0x68, 0x40, 0x1c, 0x8b, 0xbb, 0x94, 0x54, 0x30, 0x69, - 0xbb, 0x04, 0x57, 0x84, 0x97, 0x71, 0xc7, 0x62, 0x9d, 0x41, 0xbf, 0x78, 0x55, 0x3c, 0x6c, 0x96, - 0xd7, 0xca, 0xa5, 0x23, 0xcb, 0x73, 0x1d, 0x8b, 0xe3, 0xcd, 0xb2, 0x8f, 0x1f, 0x05, 0xae, 0x8f, - 0x9d, 0x72, 0x53, 0x2e, 0x80, 0x6e, 0x81, 0x4e, 0xac, 0x2e, 0xce, 0x27, 0x4a, 0xda, 0x72, 0xd6, - 0x7c, 0x7d, 0xd0, 0x2f, 0xbe, 0xa6, 0xbc, 0xc4, 0xdb, 0xcd, 0xea, 0x14, 0x57, 0xf1, 0x23, 0x7a, - 0x08, 0x29, 0x42, 0x1d, 0xcc, 0xf2, 0x7a, 0x29, 0xb9, 0x3c, 0x57, 0xcd, 0x1b, 0xa7, 0xf1, 0x1a, - 0x61, 0x1c, 0xc6, 0x0e, 0x75, 0xb0, 0xf9, 0xe6, 0xa0, 0x5f, 0x7c, 0x23, 0x42, 0xdd, 0x88, 0x52, - 0x1d, 0xf7, 0x08, 0xaf, 0x9e, 0xa2, 0x15, 0x52, 0xb0, 0xb1, 0xd3, 0xc6, 0x2c, 0x9f, 0x9a, 0xce, - 0xae, 0x3b, 0xed, 0x71, 0xf6, 0xf5, 0x8b, 0xd8, 0x12, 0x89, 0x3e, 0x85, 0x8c, 0xe5, 0x38, 0x3e, - 0x66, 0x2c, 0x9f, 0x96, 0xf2, 0xbe, 0x37, 0xe8, 0x17, 0x67, 0x87, 0x5a, 0xfd, 0xd9, 0x2f, 0xae, - 0x45, 0x64, 0xb6, 0x29, 0xeb, 0x52, 0x16, 0xfe, 0x59, 0x63, 0xce, 0x61, 0x45, 0x6d, 0x62, 0xcb, - 0xb6, 0xb7, 0x14, 0xa4, 0x39, 0xa4, 0x15, 0xbe, 0x7f, 0x19, 0x74, 0x11, 0x30, 0xba, 0x09, 0xc9, - 0x43, 0x7c, 0x22, 0x93, 0x37, 0xae, 0xe9, 0xfa, 0x64, 0x4d, 0x85, 0x07, 0x6a, 0x40, 0xda, 0xc7, - 0x2c, 0xf0, 0xb8, 0xcc, 0xc7, 0x5c, 0xb5, 0x38, 0x4d, 0x53, 0xa3, 0x29, 0xcd, 0xcc, 0x17, 0x06, - 0xfd, 0xe2, 0x95, 0x33, 0x09, 0xbb, 0x33, 0xd3, 0x0c, 0x19, 0xe8, 0x03, 0x48, 0xe1, 0x23, 0x4c, - 0x78, 0x3e, 0x29, 0x61, 0x8b, 0x53, 0x61, 0x75, 0x61, 0x35, 0xc6, 0xaa, 0x09, 0x96, 0x22, 0xa0, - 0xdb, 0xa0, 0x73, 0x8b, 0x1d, 0xe6, 0x75, 0x49, 0x7a, 0x75, 0x2a, 0xe9, 0x81, 0xc5, 0x0e, 0xc7, - 0x40, 0x1b, 0x02, 0x24, 0xfd, 0xd1, 0x36, 0x24, 0xbb, 0x56, 0x2f, 0x9f, 0x92, 0x98, 0xab, 0x53, - 0x31, 0xf7, 0xac, 0xde, 0x18, 0xe5, 0xba, 0xa0, 0x08, 0x6f, 0xa1, 0x52, 0xcb, 0xf5, 0x38, 0xf6, - 0x65, 0xfe, 0x2e, 0x52, 0xe9, 0xb6, 0x34, 0x1b, 0x43, 0xdd, 0x90, 0x2a, 0x29, 0x46, 0xe1, 0x27, - 0x0d, 0xd2, 0x4a, 0x4d, 0xf4, 0x35, 0xe4, 0x5c, 0xc2, 0xb8, 0x45, 0x6c, 0x2c, 0x8e, 0x90, 0x4c, - 0x42, 0xce, 0xfc, 0xec, 0xd9, 0x4e, 0x5f, 0x8c, 0x73, 0x74, 0x66, 0x35, 0xf4, 0x21, 0x64, 0x84, - 0x46, 0x77, 0xf1, 0x89, 0x4c, 0x58, 0xd6, 0x7c, 0x7b, 0xd0, 0x2f, 0xae, 0x9e, 0x49, 0x48, 0x84, - 0xd2, 0xf3, 0x5d, 0xc2, 0x2d, 0x66, 0xbb, 0x6e, 0xa4, 0xc2, 0x87, 0x80, 0xc2, 0xcf, 0x1a, 0xa4, - 0x64, 0x56, 0xff, 0xe3, 0x98, 0x1a, 0x30, 0x2b, 0x0b, 0xe8, 0x9f, 0x04, 0x35, 0x22, 0x14, 0x7e, - 0xd4, 0x40, 0x17, 0x15, 0xf6, 0x3f, 0x4a, 0xd4, 0xef, 0x73, 0x90, 0xbc, 0x67, 0xf5, 0x10, 0x85, - 0x0c, 0x0d, 0x78, 0x2f, 0xe0, 0x2c, 0xaf, 0xc9, 0x96, 0xb7, 0x72, 0xd1, 0xe1, 0x30, 0x3e, 0x52, - 0xb6, 0x75, 0xc2, 0xfd, 0x93, 0xb1, 0x1e, 0xb8, 0x7e, 0x41, 0x0f, 0x1c, 0xae, 0x52, 0xf8, 0x16, - 0x20, 0xad, 0x28, 0xe8, 0x3e, 0xe8, 0x24, 0xf0, 0x3c, 0xd9, 0xaf, 0xe6, 0xab, 0xcb, 0x31, 0x16, - 0x36, 0x76, 0x02, 0xcf, 0x1b, 0x3b, 0x56, 0xeb, 0xf2, 0x9c, 0x0b, 0x14, 0xba, 0x01, 0x39, 0xc6, - 0x7d, 0x97, 0xb4, 0xf7, 0x6d, 0x4a, 0x18, 0x0f, 0xc7, 0xcb, 0xc4, 0x6e, 0x35, 0xa7, 0x0c, 0xb7, - 0x85, 0x1d, 0xaa, 0x43, 0xce, 0xa1, 0xc1, 0x81, 0x87, 0x43, 0x3f, 0xa1, 0xaf, 0x66, 0x96, 0x4e, - 0x87, 0xd9, 0x50, 0x5f, 0xab, 0xeb, 0x12, 0xba, 0x59, 0x0e, 0x08, 0xb3, 0x5a, 0x58, 0x62, 0x94, - 0x9f, 0xc2, 0x54, 0x01, 0x0e, 0x28, 0xf5, 0x42, 0x88, 0x68, 0x5a, 0xb3, 0x93, 0xbb, 0x52, 0x56, - 0x98, 0x29, 0x9f, 0x07, 0x90, 0xf4, 0x71, 0x2b, 0x6c, 0x4d, 0x6b, 0x71, 0x44, 0x68, 0xe2, 0x16, - 0xf6, 0x31, 0xb1, 0xf1, 0x94, 0x5e, 0xe5, 0xe3, 0x96, 0xd0, 0xd6, 0x73, 0x19, 0x0f, 0x3b, 0x55, - 0x2c, 0x6d, 0x1b, 0x2e, 0xe3, 0x93, 0x5b, 0x96, 0x44, 0xa1, 0x1d, 0xd5, 0x43, 0x33, 0x92, 0xb8, - 0x14, 0x87, 0x38, 0xa9, 0x9d, 0xde, 0x1c, 0xb6, 0xd3, 0xc2, 0x23, 0xd0, 0xc5, 0x92, 0xc8, 0x3d, - 0x5f, 0x82, 0xd7, 0x62, 0xb0, 0x9f, 0xad, 0xf8, 0x9e, 0x68, 0xaa, 0xea, 0xbf, 0x3a, 0xbf, 0xe4, - 0x46, 0xcc, 0x70, 0x9e, 0xc3, 0x01, 0xd8, 0x87, 0x5c, 0x14, 0x82, 0x16, 0x22, 0x43, 0x5b, 0x4d, - 0xe3, 0x5b, 0x90, 0x3a, 0xb2, 0xbc, 0x00, 0x87, 0xc3, 0x38, 0x8e, 0x1c, 0x4d, 0xe5, 0xb1, 0x99, - 0x78, 0x47, 0x2b, 0xfc, 0x95, 0x80, 0xec, 0xa8, 0x44, 0xd0, 0xfb, 0x90, 0x11, 0x57, 0x9b, 0xbb, - 0x97, 0xbd, 0x17, 0x0c, 0xbd, 0xd0, 0xe7, 0xa0, 0xf7, 0x2c, 0xde, 0x09, 0x37, 0x53, 0xbd, 0x54, - 0x81, 0x1a, 0xbb, 0x16, 0xef, 0x4c, 0x38, 0x7e, 0x4d, 0x89, 0x2c, 0xfc, 0xa2, 0x81, 0x2e, 0x2c, - 0xd0, 0xbb, 0xd1, 0x8b, 0xcb, 0xd2, 0xa0, 0x5f, 0xbc, 0x36, 0x6d, 0x83, 0xa7, 0x5d, 0x4d, 0xd6, - 0x91, 0x90, 0x6b, 0x05, 0x52, 0x2e, 0x71, 0xf0, 0xb1, 0xdc, 0xa1, 0x3e, 0xf9, 0xb0, 0x2b, 0x8b, - 0x51, 0x2c, 0xc9, 0xe7, 0x16, 0x4b, 0x2d, 0x8c, 0xc5, 0x04, 0x98, 0x65, 0xd8, 0xc3, 0x36, 0xa7, - 0x7e, 0xf9, 0x25, 0xd0, 0x45, 0xa3, 0x42, 0xf3, 0x00, 0x3b, 0x7b, 0x8d, 0xc6, 0xfe, 0x27, 0x5b, - 0x8d, 0xbd, 0xfa, 0xc2, 0x8c, 0x99, 0x09, 0x13, 0xfb, 0xef, 0xd7, 0xc0, 0x37, 0x49, 0x48, 0xab, - 0x4b, 0x08, 0xfa, 0x02, 0xc0, 0xa6, 0xc4, 0x71, 0xc5, 0x18, 0x62, 0xf9, 0xc4, 0x53, 0x9a, 0xbc, - 0x72, 0x32, 0xb6, 0x87, 0x1e, 0xe6, 0x8b, 0x62, 0xb8, 0x8d, 0x27, 0x30, 0xc2, 0x2c, 0x7c, 0x97, - 0x80, 0xec, 0xc8, 0x01, 0x99, 0xd1, 0x5c, 0x9e, 0x9f, 0x50, 0x13, 0x8b, 0x6d, 0x35, 0x92, 0x54, - 0x15, 0xfd, 0x31, 0x64, 0x7b, 0x3e, 0x76, 0x5c, 0xdb, 0xe2, 0x4a, 0x81, 0xf9, 0x6a, 0x2d, 0xf6, - 0x96, 0x8d, 0xdd, 0xa1, 0x6b, 0xdc, 0xef, 0x8a, 0xd3, 0xc5, 0xd0, 0xd2, 0x50, 0xf7, 0xe4, 0xc4, - 0xc9, 0x51, 0x2b, 0x87, 0x2a, 0x97, 0x4b, 0x90, 0x1d, 0xad, 0x83, 0xe6, 0x20, 0xb3, 0x47, 0x0e, - 0x09, 0xfd, 0x92, 0x2c, 0xcc, 0xa0, 0x34, 0x24, 0xea, 0xf7, 0x17, 0x34, 0x33, 0x0d, 0xba, 0xd8, - 0x6d, 0xe1, 0x18, 0x74, 0xf1, 0xc9, 0x20, 0x6e, 0xe7, 0xcc, 0xb7, 0x2f, 0x79, 0x3b, 0x67, 0xbe, - 0x2d, 0x1c, 0x9d, 0xd1, 0x2c, 0x8b, 0x19, 0x92, 0xf0, 0x30, 0x6b, 0x8f, 0xff, 0x58, 0x9c, 0xf9, - 0xe1, 0xc9, 0xa2, 0xf6, 0x70, 0xe5, 0xe9, 0x57, 0x93, 0xf0, 0x23, 0xf2, 0x20, 0x2d, 0xbf, 0x0a, - 0x6b, 0x7f, 0x07, 0x00, 0x00, 0xff, 0xff, 0xa1, 0xf1, 0x1e, 0xf6, 0x56, 0x0e, 0x00, 0x00, + // 1221 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x97, 0x5d, 0x6f, 0x1b, 0x45, + 0x17, 0xc7, 0xb3, 0xf6, 0xda, 0x8e, 0x4f, 0xdc, 0xca, 0xcf, 0xe8, 0x11, 0x5a, 0x2d, 0x69, 0x1c, + 0xb6, 0x2a, 0x49, 0x20, 0x59, 0x13, 0x3b, 0x69, 0x21, 0x5c, 0xa0, 0x6c, 0x70, 0xdb, 0x50, 0xd7, + 0x4d, 0x8c, 0x53, 0x89, 0x82, 0x14, 0x6d, 0x76, 0xc7, 0xf6, 0x2a, 0xeb, 0x5d, 0x77, 0x67, 0x36, + 0x24, 0x48, 0x5c, 0x20, 0x21, 0xf1, 0x55, 0xf8, 0x28, 0x15, 0x37, 0x08, 0xc1, 0xb5, 0x25, 0x7a, + 0x83, 0xb8, 0xb5, 0xc4, 0x0d, 0x57, 0x68, 0x66, 0xd6, 0x8e, 0x13, 0xbf, 0xc4, 0xa1, 0x45, 0x48, + 0x5c, 0xd9, 0xbb, 0x7b, 0xce, 0xef, 0xcc, 0x39, 0x33, 0xe7, 0x3f, 0x33, 0x70, 0xa3, 0x1d, 0xf8, + 0x16, 0x26, 0x44, 0x6f, 0x07, 0x3e, 0xf5, 0x11, 0xb4, 0x30, 0x69, 0xe8, 0xf4, 0xac, 0x8d, 0x89, + 0xaa, 0x35, 0xfc, 0x86, 0x9f, 0xe7, 0xef, 0x8f, 0xc2, 0x7a, 0x9e, 0x3d, 0xf1, 0x07, 0xfe, 0x4f, + 0xd8, 0xab, 0x6f, 0xf6, 0x3f, 0x73, 0x9f, 0x3c, 0xa1, 0x41, 0x68, 0x51, 0xf1, 0x51, 0xfb, 0x6d, + 0x1e, 0x52, 0x7b, 0x02, 0x8f, 0x9a, 0x20, 0x37, 0x4d, 0xd2, 0x54, 0xa4, 0x45, 0x69, 0x39, 0x63, + 0xd4, 0xba, 0x9d, 0xdc, 0x5b, 0xec, 0x79, 0x4b, 0x5b, 0xd3, 0x16, 0x4f, 0x4c, 0xd7, 0xb1, 0x4d, + 0x8a, 0xb7, 0xb4, 0x00, 0x3f, 0x0f, 0x9d, 0x00, 0xdb, 0xab, 0xec, 0x9b, 0xf6, 0x67, 0x27, 0xf7, + 0x6e, 0xc3, 0xa1, 0xcd, 0xf0, 0x48, 0xb7, 0xfc, 0x56, 0x9e, 0x0d, 0x6d, 0xad, 0xee, 0x87, 0x9e, + 0x6d, 0x52, 0xc7, 0xf7, 0xf2, 0xd8, 0x6b, 0x38, 0x1e, 0xce, 0x33, 0x53, 0xfd, 0xa1, 0x49, 0x9a, + 0x55, 0x1e, 0x01, 0x7d, 0x0c, 0xb2, 0x67, 0xb6, 0xb0, 0x12, 0x5b, 0x94, 0x96, 0xd3, 0xc6, 0x7b, + 0xdd, 0x4e, 0x6e, 0x55, 0x44, 0x62, 0x6f, 0xb7, 0x0a, 0x23, 0xc3, 0xb5, 0x03, 0xc7, 0xa3, 0x26, + 0xb1, 0x1c, 0x47, 0xab, 0x72, 0x6f, 0xf4, 0x0c, 0x12, 0x9e, 0x6f, 0x63, 0xa2, 0xc8, 0x8b, 0xf1, + 0xe5, 0xb9, 0x82, 0xa2, 0x9f, 0x17, 0x46, 0x8f, 0x72, 0xd2, 0x2b, 0xbe, 0x8d, 0x8d, 0x77, 0xba, + 0x9d, 0xdc, 0xdb, 0x03, 0x01, 0x36, 0x06, 0x03, 0xd8, 0xce, 0x09, 0x5e, 0xed, 0x45, 0xd1, 0xaa, + 0x02, 0xc9, 0xd8, 0xd8, 0x6e, 0x60, 0xa2, 0x24, 0xc6, 0xb3, 0x4b, 0x76, 0x63, 0x98, 0xbd, 0x39, + 0x89, 0xcd, 0x91, 0xe8, 0x04, 0x52, 0xa6, 0x6d, 0x07, 0x98, 0x10, 0x25, 0xc9, 0x4b, 0xfd, 0x45, + 0xb7, 0x93, 0x5b, 0x9a, 0x54, 0x6a, 0xd3, 0xb2, 0x22, 0x0f, 0x56, 0xf0, 0xb5, 0x81, 0x82, 0x5b, + 0x3e, 0x69, 0xf9, 0x24, 0xfa, 0x59, 0x23, 0xf6, 0xb1, 0x98, 0x64, 0x7d, 0xdb, 0xb2, 0xb6, 0x85, + 0x47, 0xb5, 0x17, 0x4c, 0xfd, 0x46, 0x01, 0x99, 0xd5, 0x03, 0xdd, 0x83, 0xf8, 0x31, 0x3e, 0xe3, + 0xf3, 0x9c, 0x36, 0xee, 0x9c, 0xcf, 0x33, 0x4f, 0x60, 0x7d, 0xd4, 0x08, 0xb4, 0x2a, 0xf3, 0x40, + 0x65, 0x48, 0x06, 0x98, 0x84, 0x2e, 0xe5, 0x33, 0x37, 0x57, 0xc8, 0x8d, 0x2b, 0xb9, 0x5e, 0xe5, + 0x66, 0xc6, 0xff, 0xba, 0x9d, 0xdc, 0x8d, 0x0b, 0x53, 0xfb, 0x70, 0xa6, 0x1a, 0x31, 0xd0, 0x2e, + 0x24, 0xf0, 0x09, 0xf6, 0xa8, 0x12, 0xe7, 0xb0, 0x85, 0xb1, 0xb0, 0x12, 0xb3, 0x1a, 0x62, 0x15, + 0x19, 0x4b, 0x10, 0xd0, 0x7d, 0x90, 0xa9, 0x49, 0x8e, 0x15, 0x99, 0x93, 0x6e, 0x8d, 0x25, 0xd5, + 0x4c, 0x72, 0x3c, 0x04, 0xda, 0x60, 0x20, 0xee, 0x8f, 0x76, 0x20, 0xde, 0x32, 0xdb, 0x4a, 0x82, + 0x63, 0xe6, 0xc7, 0x62, 0x1e, 0x9b, 0xed, 0x21, 0xca, 0x26, 0xa3, 0x30, 0x6f, 0x56, 0xa5, 0xba, + 0xe3, 0x52, 0x1c, 0xf0, 0xe9, 0x9d, 0x54, 0xa5, 0xfb, 0xdc, 0x6c, 0x08, 0x75, 0x97, 0x57, 0x49, + 0x30, 0xd4, 0x9f, 0x25, 0x48, 0x8a, 0x6a, 0xa2, 0xaf, 0x21, 0xe3, 0x78, 0x84, 0x9a, 0x9e, 0x85, + 0x59, 0x33, 0xf1, 0x49, 0xc8, 0x18, 0x9f, 0x5d, 0x5a, 0x81, 0x85, 0xd7, 0xd7, 0xad, 0x17, 0xc2, + 0xa1, 0x4f, 0x20, 0xc5, 0x8a, 0xf4, 0x08, 0x9f, 0xf1, 0x19, 0x1b, 0x6e, 0xdc, 0xe2, 0x60, 0xe4, + 0xf3, 0x7e, 0x1d, 0xe8, 0x80, 0x1e, 0x40, 0xfd, 0x45, 0x82, 0x04, 0x9f, 0xd6, 0x7f, 0x3b, 0xa9, + 0x32, 0xcc, 0xf2, 0x25, 0xf4, 0x2a, 0x59, 0xf5, 0x09, 0xea, 0x4f, 0x12, 0xc8, 0x6c, 0x8d, 0xfd, + 0x97, 0xa6, 0xea, 0xc7, 0x59, 0x88, 0x3f, 0x36, 0xdb, 0xc8, 0x87, 0x94, 0x1f, 0xd2, 0x76, 0x48, + 0x89, 0x22, 0x71, 0x51, 0x5c, 0x99, 0xd4, 0x1f, 0xfa, 0x13, 0x61, 0x5b, 0xf2, 0x68, 0x70, 0x36, + 0xa4, 0x92, 0xeb, 0x13, 0x54, 0xb2, 0x17, 0x45, 0xfd, 0x23, 0x09, 0x49, 0x41, 0x41, 0xfb, 0x20, + 0x7b, 0xa1, 0xeb, 0x72, 0xc9, 0xba, 0x59, 0x58, 0x9e, 0x22, 0xb0, 0x5e, 0x09, 0x5d, 0x77, 0xa8, + 0xb3, 0xd6, 0x79, 0xab, 0x33, 0x14, 0xba, 0x0b, 0x19, 0x42, 0x03, 0xc7, 0x6b, 0x1c, 0x5a, 0xbe, + 0x47, 0x68, 0xb4, 0x17, 0x8d, 0x14, 0xac, 0x39, 0x61, 0xb8, 0xc3, 0xec, 0x50, 0x09, 0x32, 0xb6, + 0x1f, 0x1e, 0xb9, 0x38, 0xf2, 0x63, 0xf5, 0x95, 0x8c, 0xc5, 0x6e, 0x27, 0x37, 0x7f, 0xb1, 0xbe, + 0x66, 0xcb, 0xf1, 0xfc, 0x2d, 0x2d, 0xf4, 0x88, 0x59, 0xc7, 0x1c, 0x23, 0xfc, 0x04, 0xa6, 0x00, + 0x70, 0xe4, 0xfb, 0x6e, 0x04, 0x61, 0xba, 0x35, 0x3b, 0x5a, 0x98, 0xd2, 0xcc, 0x4c, 0xf8, 0xec, + 0x42, 0x3c, 0xc0, 0xf5, 0x48, 0x9d, 0xb4, 0x09, 0xda, 0x5b, 0xc7, 0x01, 0xf6, 0x2c, 0x3c, 0x46, + 0xa3, 0x02, 0x5c, 0x67, 0x05, 0x75, 0x1d, 0x42, 0x23, 0x85, 0x9a, 0xaa, 0xa0, 0x65, 0x87, 0xd0, + 0xd1, 0x52, 0xc5, 0x51, 0xa8, 0x22, 0xb4, 0x33, 0xc5, 0x89, 0x4b, 0xd3, 0x10, 0x47, 0xc9, 0xe8, + 0xbd, 0x9e, 0x8c, 0xaa, 0xcf, 0x41, 0x66, 0x21, 0x91, 0x73, 0x79, 0xdd, 0xdd, 0x9e, 0x82, 0xfd, + 0xf7, 0x56, 0xdc, 0x4b, 0x49, 0x2c, 0xf5, 0xaf, 0x2e, 0x87, 0xdc, 0x98, 0x32, 0x9d, 0xd7, 0xb0, + 0xea, 0x0f, 0x21, 0x33, 0x08, 0x41, 0xd9, 0x81, 0xcd, 0x5a, 0xec, 0xc2, 0x1f, 0x40, 0xe2, 0xc4, + 0x74, 0x43, 0x1c, 0x6d, 0xc2, 0xd3, 0x94, 0xa3, 0x2a, 0x3c, 0xb6, 0x62, 0xef, 0x4b, 0xda, 0x1b, + 0x20, 0xb3, 0xde, 0x40, 0x37, 0x01, 0x2a, 0x07, 0xe5, 0xf2, 0xe1, 0xd3, 0xed, 0xf2, 0x41, 0x29, + 0x3b, 0x63, 0xa4, 0x22, 0xec, 0x3f, 0x3e, 0x02, 0xf5, 0x5b, 0x19, 0x92, 0x62, 0xeb, 0x43, 0x6d, + 0x00, 0xcb, 0xf7, 0x6c, 0x87, 0x89, 0x1a, 0x51, 0x62, 0x57, 0xe8, 0x8a, 0x70, 0xd2, 0x77, 0x7a, + 0x1e, 0xc6, 0x9d, 0x17, 0x9d, 0xdc, 0x4c, 0xb7, 0x93, 0xbb, 0x35, 0x4e, 0x54, 0x59, 0x95, 0xb5, + 0xea, 0x40, 0x0c, 0xf5, 0xbb, 0x38, 0xa4, 0xfb, 0x00, 0x74, 0x0a, 0xe9, 0x76, 0x80, 0x6d, 0xc7, + 0x32, 0xa9, 0xc8, 0xe6, 0x66, 0xa1, 0x38, 0x75, 0x78, 0x7d, 0xaf, 0xe7, 0x3a, 0x74, 0x8a, 0x2a, + 0x8c, 0x3e, 0x45, 0x9d, 0x07, 0x43, 0xfb, 0xbd, 0x1a, 0x8a, 0x33, 0xcb, 0xff, 0x45, 0xd4, 0xde, + 0x59, 0x5d, 0x7f, 0xca, 0xbe, 0x0d, 0x61, 0x37, 0x46, 0x63, 0x05, 0x09, 0x7d, 0x7e, 0x5d, 0x7d, + 0xb8, 0x8c, 0xdf, 0x1c, 0x73, 0xf6, 0x0b, 0x70, 0x5d, 0xdb, 0x83, 0x74, 0x3f, 0x5d, 0x34, 0x07, + 0xa9, 0x03, 0xef, 0xd8, 0xf3, 0xbf, 0xf4, 0xb2, 0x33, 0x28, 0x09, 0xb1, 0xd2, 0x7e, 0x56, 0x62, + 0xbf, 0x0f, 0x6a, 0xd9, 0x18, 0x4a, 0x41, 0xfc, 0x41, 0xad, 0x94, 0x8d, 0xb3, 0x17, 0xe5, 0x5a, + 0x56, 0x66, 0x2f, 0xca, 0xb5, 0x52, 0x36, 0x81, 0x32, 0x30, 0xbb, 0xf3, 0xa4, 0x52, 0xdb, 0xde, + 0xad, 0x7c, 0x9a, 0x4d, 0xaa, 0xbf, 0xc7, 0x20, 0xdd, 0x1f, 0x0b, 0xfa, 0x08, 0x52, 0xec, 0xe8, + 0xfd, 0xe8, 0xba, 0x07, 0xd3, 0x9e, 0x17, 0xaa, 0x80, 0xdc, 0x36, 0x69, 0x33, 0x5a, 0x93, 0x4b, + 0x57, 0xa7, 0xaf, 0xef, 0x99, 0xb4, 0x39, 0x42, 0xf1, 0xab, 0x9c, 0xa3, 0xfe, 0x20, 0x81, 0xcc, + 0x2c, 0xd0, 0x87, 0x83, 0xc7, 0xe5, 0xa5, 0x6e, 0x27, 0x77, 0x7b, 0xdc, 0xa8, 0x06, 0xee, 0x28, + 0x4c, 0xc5, 0x58, 0xab, 0xac, 0x40, 0xc2, 0xf1, 0x6c, 0x7c, 0xca, 0x87, 0x25, 0x8f, 0xde, 0x5f, + 0x84, 0x45, 0x3f, 0x81, 0xf8, 0xab, 0x25, 0x50, 0x8c, 0x12, 0x30, 0x00, 0x66, 0x09, 0x76, 0xb1, + 0x45, 0xfd, 0xc0, 0x48, 0x82, 0xcc, 0x48, 0xea, 0x29, 0xc8, 0xec, 0xda, 0xc2, 0xae, 0x00, 0x24, + 0xb0, 0xae, 0x79, 0x05, 0x20, 0x81, 0xc5, 0x1c, 0xed, 0xfe, 0x6e, 0x39, 0xe5, 0xaa, 0x67, 0x1e, + 0x46, 0xf1, 0xc5, 0xaf, 0x0b, 0x33, 0xdf, 0xbf, 0x5c, 0x90, 0x9e, 0xad, 0x5c, 0x7d, 0xae, 0x89, + 0x6e, 0xbc, 0x47, 0x49, 0xde, 0x0f, 0xc5, 0xbf, 0x02, 0x00, 0x00, 0xff, 0xff, 0x3e, 0x8c, 0x12, + 0x4b, 0x03, 0x0f, 0x00, 0x00, } func (this *Process) Equal(that interface{}) bool { @@ -911,7 +935,7 @@ func (this *Process) Equal(that interface{}) bool { } else if this == nil { return false } - if !this.Hash.Equal(that1.Hash) { + if !bytes.Equal(this.Hash, that1.Hash) { return false } if this.Name != that1.Name { @@ -1116,7 +1140,7 @@ func (this *Process_Node_Result) Equal(that interface{}) bool { } else if this == nil { return false } - if !this.InstanceHash.Equal(that1.InstanceHash) { + if !bytes.Equal(this.InstanceHash, that1.InstanceHash) { return false } if this.TaskKey != that1.TaskKey { @@ -1146,7 +1170,7 @@ func (this *Process_Node_Event) Equal(that interface{}) bool { } else if this == nil { return false } - if !this.InstanceHash.Equal(that1.InstanceHash) { + if !bytes.Equal(this.InstanceHash, that1.InstanceHash) { return false } if this.EventKey != that1.EventKey { @@ -1176,7 +1200,7 @@ func (this *Process_Node_Task) Equal(that interface{}) bool { } else if this == nil { return false } - if !this.InstanceHash.Equal(that1.InstanceHash) { + if !bytes.Equal(this.InstanceHash, that1.InstanceHash) { return false } if this.TaskKey != that1.TaskKey { @@ -1484,14 +1508,14 @@ func (this *Process_Node_Map_Output_Map) Equal(that interface{}) bool { } return true } -func (this *Process_Node_Map_Output_Reference) Equal(that interface{}) bool { +func (this *Process_Node_Filter) Equal(that interface{}) bool { if that == nil { return this == nil } - that1, ok := that.(*Process_Node_Map_Output_Reference) + that1, ok := that.(*Process_Node_Filter) if !ok { - that2, ok := that.(Process_Node_Map_Output_Reference) + that2, ok := that.(Process_Node_Filter) if ok { that1 = &that2 } else { @@ -1503,25 +1527,27 @@ func (this *Process_Node_Map_Output_Reference) Equal(that interface{}) bool { } else if this == nil { return false } - if this.NodeKey != that1.NodeKey { + if len(this.Conditions) != len(that1.Conditions) { return false } - if !this.Path.Equal(that1.Path) { - return false + for i := range this.Conditions { + if !this.Conditions[i].Equal(&that1.Conditions[i]) { + return false + } } if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { return false } return true } -func (this *Process_Node_Map_Output_Reference_Path) Equal(that interface{}) bool { +func (this *Process_Node_Filter_Condition) Equal(that interface{}) bool { if that == nil { return this == nil } - that1, ok := that.(*Process_Node_Map_Output_Reference_Path) + that1, ok := that.(*Process_Node_Filter_Condition) if !ok { - that2, ok := that.(Process_Node_Map_Output_Reference_Path) + that2, ok := that.(Process_Node_Filter_Condition) if ok { that1 = &that2 } else { @@ -1533,16 +1559,13 @@ func (this *Process_Node_Map_Output_Reference_Path) Equal(that interface{}) bool } else if this == nil { return false } - if that1.Selector == nil { - if this.Selector != nil { - return false - } - } else if this.Selector == nil { + if this.Predicate != that1.Predicate { return false - } else if !this.Selector.Equal(that1.Selector) { + } + if !this.Value.Equal(that1.Value) { return false } - if !this.Path.Equal(that1.Path) { + if !this.Ref.Equal(that1.Ref) { return false } if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { @@ -1550,14 +1573,14 @@ func (this *Process_Node_Map_Output_Reference_Path) Equal(that interface{}) bool } return true } -func (this *Process_Node_Map_Output_Reference_Path_Key) Equal(that interface{}) bool { +func (this *Process_Node_Reference) Equal(that interface{}) bool { if that == nil { return this == nil } - that1, ok := that.(*Process_Node_Map_Output_Reference_Path_Key) + that1, ok := that.(*Process_Node_Reference) if !ok { - that2, ok := that.(Process_Node_Map_Output_Reference_Path_Key) + that2, ok := that.(Process_Node_Reference) if ok { that1 = &that2 } else { @@ -1569,19 +1592,25 @@ func (this *Process_Node_Map_Output_Reference_Path_Key) Equal(that interface{}) } else if this == nil { return false } - if this.Key != that1.Key { + if this.NodeKey != that1.NodeKey { + return false + } + if !this.Path.Equal(that1.Path) { + return false + } + if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { return false } return true } -func (this *Process_Node_Map_Output_Reference_Path_Index) Equal(that interface{}) bool { +func (this *Process_Node_Reference_Path) Equal(that interface{}) bool { if that == nil { return this == nil } - that1, ok := that.(*Process_Node_Map_Output_Reference_Path_Index) + that1, ok := that.(*Process_Node_Reference_Path) if !ok { - that2, ok := that.(Process_Node_Map_Output_Reference_Path_Index) + that2, ok := that.(Process_Node_Reference_Path) if ok { that1 = &that2 } else { @@ -1593,19 +1622,31 @@ func (this *Process_Node_Map_Output_Reference_Path_Index) Equal(that interface{} } else if this == nil { return false } - if this.Index != that1.Index { + if that1.Selector == nil { + if this.Selector != nil { + return false + } + } else if this.Selector == nil { + return false + } else if !this.Selector.Equal(that1.Selector) { + return false + } + if !this.Path.Equal(that1.Path) { + return false + } + if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { return false } return true } -func (this *Process_Node_Filter) Equal(that interface{}) bool { +func (this *Process_Node_Reference_Path_Key) Equal(that interface{}) bool { if that == nil { return this == nil } - that1, ok := that.(*Process_Node_Filter) + that1, ok := that.(*Process_Node_Reference_Path_Key) if !ok { - that2, ok := that.(Process_Node_Filter) + that2, ok := that.(Process_Node_Reference_Path_Key) if ok { that1 = &that2 } else { @@ -1617,27 +1658,19 @@ func (this *Process_Node_Filter) Equal(that interface{}) bool { } else if this == nil { return false } - if len(this.Conditions) != len(that1.Conditions) { - return false - } - for i := range this.Conditions { - if !this.Conditions[i].Equal(&that1.Conditions[i]) { - return false - } - } - if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { + if this.Key != that1.Key { return false } return true } -func (this *Process_Node_Filter_Condition) Equal(that interface{}) bool { +func (this *Process_Node_Reference_Path_Index) Equal(that interface{}) bool { if that == nil { return this == nil } - that1, ok := that.(*Process_Node_Filter_Condition) + that1, ok := that.(*Process_Node_Reference_Path_Index) if !ok { - that2, ok := that.(Process_Node_Filter_Condition) + that2, ok := that.(Process_Node_Reference_Path_Index) if ok { that1 = &that2 } else { @@ -1649,16 +1682,7 @@ func (this *Process_Node_Filter_Condition) Equal(that interface{}) bool { } else if this == nil { return false } - if this.Key != that1.Key { - return false - } - if this.Predicate != that1.Predicate { - return false - } - if this.Value != that1.Value { - return false - } - if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { + if this.Index != that1.Index { return false } return true diff --git a/process/process_test.go b/process/process_test.go index 6b20ad10e..c3c6c6362 100644 --- a/process/process_test.go +++ b/process/process_test.go @@ -3,8 +3,11 @@ package process import ( "testing" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/mesg-foundation/engine/hash" + "github.com/mesg-foundation/engine/protobuf/types" "github.com/stretchr/testify/assert" + "github.com/tendermint/tendermint/crypto" ) func TestValidateProcess(t *testing.T) { @@ -46,10 +49,12 @@ func TestValidateProcess(t *testing.T) { err string }{ {w: &Process{ - Hash: hash.Int(1), - Name: "invalid-struct", + Address: sdk.AccAddress(crypto.AddressHash([]byte("address"))), + Hash: hash.Int(1), + Name: "invalid-struct", }, err: "should contain exactly one trigger"}, {w: &Process{ + Address: sdk.AccAddress(crypto.AddressHash([]byte("address"))), Nodes: []*Process_Node{ { Type: &Process_Node_Result_{&Process_Node_Result{InstanceHash: hash.Int(1)}}, @@ -57,31 +62,35 @@ func TestValidateProcess(t *testing.T) { }, Hash: hash.Int(1), Name: "missing-key", - }, err: "Error:Field validation for 'TaskKey' failed on the 'required' tag"}, + }, err: "Key is a required field. TaskKey is a required field"}, {w: &Process{ - Hash: hash.Int(1), - Name: "edge-src-missing-node", - Nodes: nodes, - Edges: append(edges, &Process_Edge{Src: "-", Dst: "nodeKey2"}), + Address: sdk.AccAddress(crypto.AddressHash([]byte("address"))), + Hash: hash.Int(1), + Name: "edge-src-missing-node", + Nodes: nodes, + Edges: append(edges, &Process_Edge{Src: "-", Dst: "nodeKey2"}), }, err: "node \"-\" not found"}, {w: &Process{ - Hash: hash.Int(1), - Name: "edge-dst-missing-node", - Nodes: nodes, - Edges: append(edges, &Process_Edge{Src: "nodeKey1", Dst: "-"}), + Address: sdk.AccAddress(crypto.AddressHash([]byte("address"))), + Hash: hash.Int(1), + Name: "edge-dst-missing-node", + Nodes: nodes, + Edges: append(edges, &Process_Edge{Src: "nodeKey1", Dst: "-"}), }, err: "node \"-\" not found"}, {w: &Process{ - Hash: hash.Int(1), - Name: "cyclic-graph", - Nodes: nodes, + Address: sdk.AccAddress(crypto.AddressHash([]byte("address"))), + Hash: hash.Int(1), + Name: "cyclic-graph", + Nodes: nodes, Edges: append(edges, &Process_Edge{Src: "nodeKey1", Dst: "nodeKey2"}, &Process_Edge{Src: "nodeKey2", Dst: "nodeKey1"}, ), }, err: "process should not contain any cycles"}, {w: &Process{ - Hash: hash.Int(1), - Name: "non-connected-graph", + Address: sdk.AccAddress(crypto.AddressHash([]byte("address"))), + Hash: hash.Int(1), + Name: "non-connected-graph", Nodes: append(nodes, &Process_Node{ Key: "nodeKey3", Type: &Process_Node_Task_{&Process_Node_Task{ @@ -101,8 +110,9 @@ func TestValidateProcess(t *testing.T) { ), }, err: "process should be a connected graph"}, {w: &Process{ - Hash: hash.Int(1), - Name: "multiple-parent-graph", + Address: sdk.AccAddress(crypto.AddressHash([]byte("address"))), + Hash: hash.Int(1), + Name: "multiple-parent-graph", Nodes: append(nodes, &Process_Node{ Key: "nodeKey3", Type: &Process_Node_Task_{&Process_Node_Task{ @@ -124,8 +134,9 @@ func TestValidateProcess(t *testing.T) { ), }, err: "process should contain nodes with one parent maximum"}, {w: &Process{ - Hash: hash.Int(1), - Name: "multiple-parent-graph", + Address: sdk.AccAddress(crypto.AddressHash([]byte("address"))), + Hash: hash.Int(1), + Name: "multiple-parent-graph", Nodes: append(nodes, &Process_Node{ Key: "nodeKey3", Type: &Process_Node_Task_{&Process_Node_Task{ @@ -167,15 +178,16 @@ func TestValidateProcess(t *testing.T) { ), }, valid: true}, {w: &Process{ - Hash: hash.Int(1), - Name: "inputs-with-invalid-node", + Address: sdk.AccAddress(crypto.AddressHash([]byte("address"))), + Hash: hash.Int(1), + Name: "inputs-with-invalid-node", Nodes: append(nodes, &Process_Node{ Key: "mapping", Type: &Process_Node_Map_{&Process_Node_Map{ Outputs: map[string]*Process_Node_Map_Output{ "key": { Value: &Process_Node_Map_Output_Ref{ - Ref: &Process_Node_Map_Output_Reference{NodeKey: "invalid"}, + Ref: &Process_Node_Reference{NodeKey: "invalid"}, }, }, }, @@ -183,15 +195,16 @@ func TestValidateProcess(t *testing.T) { }), }, err: "node \"invalid\" not found"}, {w: &Process{ - Hash: hash.Int(1), - Name: "inputs-with-valid-ref", + Address: sdk.AccAddress(crypto.AddressHash([]byte("address"))), + Hash: hash.Int(1), + Name: "inputs-with-valid-ref", Nodes: append(nodes, &Process_Node{ Key: "mapping", Type: &Process_Node_Map_{&Process_Node_Map{ Outputs: map[string]*Process_Node_Map_Output{ "key": { Value: &Process_Node_Map_Output_Ref{ - Ref: &Process_Node_Map_Output_Reference{NodeKey: "nodeKey1"}, + Ref: &Process_Node_Reference{NodeKey: "nodeKey1"}, }, }, }, @@ -202,13 +215,39 @@ func TestValidateProcess(t *testing.T) { &Process_Edge{Src: "mapping", Dst: "nodeKey2"}, ), }, valid: true}, + {w: &Process{ + Address: sdk.AccAddress(crypto.AddressHash([]byte("address"))), + Hash: hash.Int(1), + Name: "filter-gte-invalid-value-type", + Nodes: append(nodes, &Process_Node{ + Key: "filter", + Type: &Process_Node_Filter_{&Process_Node_Filter{ + Conditions: []Process_Node_Filter_Condition{ + { + Ref: &Process_Node_Reference{ + NodeKey: "hello", + Path: &Process_Node_Reference_Path{ + Selector: &Process_Node_Reference_Path_Key{ + Key: "foo", + }, + }, + }, + Predicate: Process_Node_Filter_Condition_GT, + Value: &types.Value{ + Kind: &types.Value_StringValue{StringValue: "bar"}, + }, + }, + }, + }}, + }), + }, err: "filter with condition GT, GTE, LT or LTE only works with value of type Number"}, } for _, test := range tests { err := test.w.Validate() if test.valid { assert.Nil(t, err, test.w.Name) } else { - assert.Contains(t, test.w.Validate().Error(), test.err, test.w.Name) + assert.Contains(t, err.Error(), test.err, test.w.Name) } } } diff --git a/process/ref.go b/process/ref.go new file mode 100644 index 000000000..bcb025a44 --- /dev/null +++ b/process/ref.go @@ -0,0 +1,56 @@ +package process + +import ( + "fmt" + + "github.com/mesg-foundation/engine/protobuf/types" +) + +// Resolve returns the value specified in the reference. +func (path *Process_Node_Reference_Path) Resolve(data *types.Struct) (*types.Value, error) { + if path == nil { + return &types.Value{Kind: &types.Value_StructValue{StructValue: data}}, nil + } + + var v *types.Value + key, ok := path.Selector.(*Process_Node_Reference_Path_Key) + if !ok { + return nil, fmt.Errorf("first selector in the path must be a key") + } + + v, ok = data.Fields[key.Key] + if !ok { + return nil, fmt.Errorf("key %s not found", key.Key) + } + + for p := path.Path; p != nil; p = p.Path { + switch s := p.Selector.(type) { + case *Process_Node_Reference_Path_Key: + str, ok := v.GetKind().(*types.Value_StructValue) + if !ok { + return nil, fmt.Errorf("can't get key from non-struct value") + } + if str.StructValue.GetFields() == nil { + return nil, fmt.Errorf("can't get key from nil-struct") + } + v, ok = str.StructValue.Fields[s.Key] + if !ok { + return nil, fmt.Errorf("key %s not found", s.Key) + } + case *Process_Node_Reference_Path_Index: + list, ok := v.GetKind().(*types.Value_ListValue) + if !ok { + return nil, fmt.Errorf("can't get index from non-list value") + } + + if len(list.ListValue.GetValues()) <= int(s.Index) { + return nil, fmt.Errorf("index %d out of range", s.Index) + } + v = list.ListValue.Values[s.Index] + default: + return nil, fmt.Errorf("unknown selector type %T", v) + } + } + + return v, nil +} diff --git a/protobuf/api/codec.go b/protobuf/api/codec.go deleted file mode 100644 index 44269984b..000000000 --- a/protobuf/api/codec.go +++ /dev/null @@ -1,12 +0,0 @@ -package api - -import ( - "github.com/cosmos/cosmos-sdk/codec" -) - -// RegisterCodec registers interface for error. -func RegisterCodec(cdc *codec.Codec) { - cdc.RegisterInterface((*isUpdateExecutionRequest_Result)(nil), nil) - cdc.RegisterConcrete(&UpdateExecutionRequest_Outputs{}, "mesg.api.UpdateExecutionRequest_Outputs", nil) - cdc.RegisterConcrete(&UpdateExecutionRequest_Error{}, "mesg.api.UpdateExecutionRequest_Error", nil) -} diff --git a/protobuf/api/event.pb.go b/protobuf/api/event.pb.go deleted file mode 100644 index 825c0ed20..000000000 --- a/protobuf/api/event.pb.go +++ /dev/null @@ -1,389 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: protobuf/api/event.proto - -package api - -import ( - context "context" - fmt "fmt" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" - event "github.com/mesg-foundation/engine/event" - github_com_mesg_foundation_engine_hash "github.com/mesg-foundation/engine/hash" - types "github.com/mesg-foundation/engine/protobuf/types" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - math "math" -) - -// 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 - -// StreamEventRequest defines request to retrieve a stream of events. -type StreamEventRequest struct { - // Filter used to filter a stream of events. - Filter *StreamEventRequest_Filter `protobuf:"bytes,1,opt,name=filter,proto3" json:"filter,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *StreamEventRequest) Reset() { *m = StreamEventRequest{} } -func (m *StreamEventRequest) String() string { return proto.CompactTextString(m) } -func (*StreamEventRequest) ProtoMessage() {} -func (*StreamEventRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_c0ad091fa003d2ac, []int{0} -} -func (m *StreamEventRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_StreamEventRequest.Unmarshal(m, b) -} -func (m *StreamEventRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_StreamEventRequest.Marshal(b, m, deterministic) -} -func (m *StreamEventRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_StreamEventRequest.Merge(m, src) -} -func (m *StreamEventRequest) XXX_Size() int { - return xxx_messageInfo_StreamEventRequest.Size(m) -} -func (m *StreamEventRequest) XXX_DiscardUnknown() { - xxx_messageInfo_StreamEventRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_StreamEventRequest proto.InternalMessageInfo - -func (m *StreamEventRequest) GetFilter() *StreamEventRequest_Filter { - if m != nil { - return m.Filter - } - return nil -} - -// Filter contains filtering criteria. -type StreamEventRequest_Filter struct { - // hash to filter events. - Hash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=hash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"hash" validate:"omitempty,hash"` - // instance's hash to filter events. - InstanceHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,2,opt,name=instanceHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"instanceHash" validate:"omitempty,hash"` - // key is the key of the event. - Key string `protobuf:"bytes,3,opt,name=key,proto3" json:"key,omitempty" validate:"printascii"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *StreamEventRequest_Filter) Reset() { *m = StreamEventRequest_Filter{} } -func (m *StreamEventRequest_Filter) String() string { return proto.CompactTextString(m) } -func (*StreamEventRequest_Filter) ProtoMessage() {} -func (*StreamEventRequest_Filter) Descriptor() ([]byte, []int) { - return fileDescriptor_c0ad091fa003d2ac, []int{0, 0} -} -func (m *StreamEventRequest_Filter) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_StreamEventRequest_Filter.Unmarshal(m, b) -} -func (m *StreamEventRequest_Filter) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_StreamEventRequest_Filter.Marshal(b, m, deterministic) -} -func (m *StreamEventRequest_Filter) XXX_Merge(src proto.Message) { - xxx_messageInfo_StreamEventRequest_Filter.Merge(m, src) -} -func (m *StreamEventRequest_Filter) XXX_Size() int { - return xxx_messageInfo_StreamEventRequest_Filter.Size(m) -} -func (m *StreamEventRequest_Filter) XXX_DiscardUnknown() { - xxx_messageInfo_StreamEventRequest_Filter.DiscardUnknown(m) -} - -var xxx_messageInfo_StreamEventRequest_Filter proto.InternalMessageInfo - -func (m *StreamEventRequest_Filter) GetKey() string { - if m != nil { - return m.Key - } - return "" -} - -// CreateEventRequest defines request for execution update. -type CreateEventRequest struct { - // instanceHash is hash of instance that can proceed an execution. - InstanceHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=instanceHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"instanceHash" validate:"required,hash"` - // key is the key of the event. - Key string `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty" validate:"required,printascii"` - // data is the data for the event. - Data *types.Struct `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *CreateEventRequest) Reset() { *m = CreateEventRequest{} } -func (m *CreateEventRequest) String() string { return proto.CompactTextString(m) } -func (*CreateEventRequest) ProtoMessage() {} -func (*CreateEventRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_c0ad091fa003d2ac, []int{1} -} -func (m *CreateEventRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_CreateEventRequest.Unmarshal(m, b) -} -func (m *CreateEventRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_CreateEventRequest.Marshal(b, m, deterministic) -} -func (m *CreateEventRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_CreateEventRequest.Merge(m, src) -} -func (m *CreateEventRequest) XXX_Size() int { - return xxx_messageInfo_CreateEventRequest.Size(m) -} -func (m *CreateEventRequest) XXX_DiscardUnknown() { - xxx_messageInfo_CreateEventRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_CreateEventRequest proto.InternalMessageInfo - -func (m *CreateEventRequest) GetKey() string { - if m != nil { - return m.Key - } - return "" -} - -func (m *CreateEventRequest) GetData() *types.Struct { - if m != nil { - return m.Data - } - return nil -} - -// CreateEventResponse defines response for execution update. -type CreateEventResponse struct { - // Hash represents event. - Hash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=hash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"hash"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *CreateEventResponse) Reset() { *m = CreateEventResponse{} } -func (m *CreateEventResponse) String() string { return proto.CompactTextString(m) } -func (*CreateEventResponse) ProtoMessage() {} -func (*CreateEventResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_c0ad091fa003d2ac, []int{2} -} -func (m *CreateEventResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_CreateEventResponse.Unmarshal(m, b) -} -func (m *CreateEventResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_CreateEventResponse.Marshal(b, m, deterministic) -} -func (m *CreateEventResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_CreateEventResponse.Merge(m, src) -} -func (m *CreateEventResponse) XXX_Size() int { - return xxx_messageInfo_CreateEventResponse.Size(m) -} -func (m *CreateEventResponse) XXX_DiscardUnknown() { - xxx_messageInfo_CreateEventResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_CreateEventResponse proto.InternalMessageInfo - -func init() { - proto.RegisterType((*StreamEventRequest)(nil), "mesg.api.StreamEventRequest") - proto.RegisterType((*StreamEventRequest_Filter)(nil), "mesg.api.StreamEventRequest.Filter") - proto.RegisterType((*CreateEventRequest)(nil), "mesg.api.CreateEventRequest") - proto.RegisterType((*CreateEventResponse)(nil), "mesg.api.CreateEventResponse") -} - -func init() { proto.RegisterFile("protobuf/api/event.proto", fileDescriptor_c0ad091fa003d2ac) } - -var fileDescriptor_c0ad091fa003d2ac = []byte{ - // 450 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x53, 0x4d, 0x6f, 0xd3, 0x40, - 0x10, 0x8d, 0x93, 0xd6, 0x82, 0x6d, 0x2f, 0x2c, 0xaa, 0xe4, 0x9a, 0x0f, 0x57, 0xcb, 0xa5, 0xa8, - 0x60, 0xa3, 0x94, 0x13, 0x88, 0x4b, 0x10, 0x94, 0x1b, 0xc8, 0xdc, 0x38, 0x20, 0x6d, 0xec, 0x89, - 0xb3, 0xa2, 0xde, 0x75, 0x77, 0xc7, 0x95, 0xf2, 0x2b, 0x10, 0xff, 0x8a, 0xdf, 0xc0, 0xc1, 0x37, - 0x2e, 0x1c, 0xf3, 0x0b, 0xd0, 0xee, 0xb6, 0x4d, 0x9d, 0x94, 0x4b, 0x25, 0x6e, 0xd9, 0x99, 0x37, - 0xef, 0xbd, 0x99, 0x3c, 0x93, 0xa8, 0xd1, 0x0a, 0xd5, 0xb4, 0x9d, 0x65, 0xbc, 0x11, 0x19, 0x9c, - 0x83, 0xc4, 0xd4, 0x95, 0xe8, 0x9d, 0x1a, 0x4c, 0x95, 0xf2, 0x46, 0xc4, 0xac, 0x52, 0x95, 0xca, - 0xae, 0x80, 0xf6, 0xe5, 0x1e, 0xee, 0x97, 0x47, 0xc7, 0x0f, 0xae, 0xda, 0xb8, 0x68, 0xc0, 0x64, - 0x06, 0x75, 0x5b, 0x5c, 0x50, 0xc5, 0xf1, 0x5a, 0xf3, 0x9a, 0x0c, 0xfb, 0x3d, 0x24, 0xf4, 0x33, - 0x6a, 0xe0, 0xf5, 0x3b, 0x5b, 0xcd, 0xe1, 0xac, 0x05, 0x83, 0xf4, 0x35, 0x09, 0x67, 0xe2, 0x14, - 0x41, 0x47, 0xc1, 0x41, 0x70, 0xb8, 0x33, 0x7e, 0x92, 0x5e, 0xda, 0x49, 0x37, 0xd1, 0xe9, 0x7b, - 0x07, 0xcd, 0x2f, 0x46, 0xe2, 0x1f, 0x43, 0x12, 0xfa, 0x12, 0x2d, 0xc9, 0xd6, 0x9c, 0x9b, 0xb9, - 0x63, 0xd9, 0x9d, 0x7c, 0xfa, 0xd9, 0x25, 0x83, 0x5f, 0x5d, 0x72, 0x54, 0x09, 0x9c, 0xb7, 0xd3, - 0xb4, 0x50, 0x75, 0x66, 0x79, 0x9f, 0xcf, 0x54, 0x2b, 0x4b, 0x8e, 0x42, 0xc9, 0x0c, 0x64, 0x25, - 0x24, 0x64, 0x76, 0x2a, 0xfd, 0xc0, 0xcd, 0x7c, 0xd9, 0x25, 0xfb, 0xe7, 0xfc, 0x54, 0x94, 0x1c, - 0xe1, 0x15, 0x53, 0xb5, 0x40, 0xa8, 0x1b, 0x5c, 0x3c, 0xb3, 0x00, 0x96, 0x3b, 0x76, 0x8a, 0x64, - 0x57, 0x48, 0x83, 0x5c, 0x16, 0x60, 0x47, 0xa2, 0xe1, 0x7f, 0x52, 0xeb, 0xa9, 0xd0, 0x23, 0x32, - 0xfa, 0x06, 0x8b, 0x68, 0x74, 0x10, 0x1c, 0xde, 0x9d, 0xec, 0x2f, 0xbb, 0x64, 0x6f, 0x35, 0xd9, - 0x68, 0x21, 0x91, 0x9b, 0x42, 0x08, 0x96, 0x5b, 0x14, 0xfb, 0x13, 0x10, 0xfa, 0x56, 0x03, 0x47, - 0xe8, 0xdd, 0xd9, 0xac, 0x39, 0xf7, 0x77, 0xfa, 0x78, 0x3b, 0xe7, 0xd1, 0x4a, 0x5f, 0xc3, 0x59, - 0x2b, 0x34, 0x94, 0x37, 0x1a, 0x7f, 0xe9, 0x8d, 0x0f, 0x9d, 0x71, 0xb6, 0xec, 0x92, 0xc7, 0x37, - 0x0c, 0xae, 0x6f, 0x40, 0x9f, 0x92, 0xad, 0x92, 0x23, 0x77, 0xfb, 0xee, 0x8c, 0xf7, 0x7c, 0x20, - 0x2e, 0x93, 0x65, 0x53, 0xd1, 0x16, 0x98, 0x3b, 0x08, 0xfb, 0x4a, 0xee, 0xf7, 0x76, 0x35, 0x8d, - 0x92, 0x06, 0xe8, 0x49, 0x2f, 0x0c, 0xc7, 0xb7, 0x58, 0xd2, 0xff, 0xdf, 0xe3, 0xef, 0x01, 0xd9, - 0x76, 0xd4, 0xf4, 0x84, 0x84, 0x5e, 0x89, 0x3e, 0x5c, 0x25, 0x74, 0xf3, 0xce, 0xf1, 0xa3, 0x7f, - 0x74, 0xbd, 0x33, 0x36, 0xa0, 0x6f, 0x48, 0xe8, 0x83, 0x7d, 0x9d, 0x68, 0x33, 0xea, 0xf1, 0x3d, - 0xdf, 0x75, 0x1f, 0x52, 0xea, 0x3a, 0x6c, 0xf0, 0x22, 0x98, 0x6c, 0x7f, 0x19, 0xf1, 0x46, 0x4c, - 0x43, 0x77, 0x8f, 0xe3, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x3c, 0xdc, 0x83, 0xec, 0xd7, 0x03, - 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 - -// EventClient is the client API for Event service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type EventClient interface { - // Create creates event with data. - Create(ctx context.Context, in *CreateEventRequest, opts ...grpc.CallOption) (*CreateEventResponse, error) - // Stream returns a stream of events that satisfy criteria - // specified in a request. - Stream(ctx context.Context, in *StreamEventRequest, opts ...grpc.CallOption) (Event_StreamClient, error) -} - -type eventClient struct { - cc *grpc.ClientConn -} - -func NewEventClient(cc *grpc.ClientConn) EventClient { - return &eventClient{cc} -} - -func (c *eventClient) Create(ctx context.Context, in *CreateEventRequest, opts ...grpc.CallOption) (*CreateEventResponse, error) { - out := new(CreateEventResponse) - err := c.cc.Invoke(ctx, "/mesg.api.Event/Create", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *eventClient) Stream(ctx context.Context, in *StreamEventRequest, opts ...grpc.CallOption) (Event_StreamClient, error) { - stream, err := c.cc.NewStream(ctx, &_Event_serviceDesc.Streams[0], "/mesg.api.Event/Stream", opts...) - if err != nil { - return nil, err - } - x := &eventStreamClient{stream} - if err := x.ClientStream.SendMsg(in); err != nil { - return nil, err - } - if err := x.ClientStream.CloseSend(); err != nil { - return nil, err - } - return x, nil -} - -type Event_StreamClient interface { - Recv() (*event.Event, error) - grpc.ClientStream -} - -type eventStreamClient struct { - grpc.ClientStream -} - -func (x *eventStreamClient) Recv() (*event.Event, error) { - m := new(event.Event) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -// EventServer is the server API for Event service. -type EventServer interface { - // Create creates event with data. - Create(context.Context, *CreateEventRequest) (*CreateEventResponse, error) - // Stream returns a stream of events that satisfy criteria - // specified in a request. - Stream(*StreamEventRequest, Event_StreamServer) error -} - -// UnimplementedEventServer can be embedded to have forward compatible implementations. -type UnimplementedEventServer struct { -} - -func (*UnimplementedEventServer) Create(ctx context.Context, req *CreateEventRequest) (*CreateEventResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Create not implemented") -} -func (*UnimplementedEventServer) Stream(req *StreamEventRequest, srv Event_StreamServer) error { - return status.Errorf(codes.Unimplemented, "method Stream not implemented") -} - -func RegisterEventServer(s *grpc.Server, srv EventServer) { - s.RegisterService(&_Event_serviceDesc, srv) -} - -func _Event_Create_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(CreateEventRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(EventServer).Create(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/mesg.api.Event/Create", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(EventServer).Create(ctx, req.(*CreateEventRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Event_Stream_Handler(srv interface{}, stream grpc.ServerStream) error { - m := new(StreamEventRequest) - if err := stream.RecvMsg(m); err != nil { - return err - } - return srv.(EventServer).Stream(m, &eventStreamServer{stream}) -} - -type Event_StreamServer interface { - Send(*event.Event) error - grpc.ServerStream -} - -type eventStreamServer struct { - grpc.ServerStream -} - -func (x *eventStreamServer) Send(m *event.Event) error { - return x.ServerStream.SendMsg(m) -} - -var _Event_serviceDesc = grpc.ServiceDesc{ - ServiceName: "mesg.api.Event", - HandlerType: (*EventServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Create", - Handler: _Event_Create_Handler, - }, - }, - Streams: []grpc.StreamDesc{ - { - StreamName: "Stream", - Handler: _Event_Stream_Handler, - ServerStreams: true, - }, - }, - Metadata: "protobuf/api/event.proto", -} diff --git a/protobuf/api/event.proto b/protobuf/api/event.proto deleted file mode 100644 index aa6585cf0..000000000 --- a/protobuf/api/event.proto +++ /dev/null @@ -1,77 +0,0 @@ -syntax = "proto3"; - -import "gogo/protobuf/gogoproto/gogo.proto"; -import "protobuf/types/struct.proto"; -import "protobuf/types/event.proto"; - -package mesg.api; -option go_package = "api"; - -// This is the API to interact with the Events. -// -// This API is a [gRPC](https://grpc.io/) API. -// -// The source file of this API is hosted on [GitHub](https://github.com/mesg-foundation/engine/blob/master/protobuf/api/event.proto). -service Event { - // Create creates event with data. - rpc Create(CreateEventRequest) returns (CreateEventResponse) {} - - // Stream returns a stream of events that satisfy criteria - // specified in a request. - rpc Stream(StreamEventRequest) returns (stream types.Event) {} -} - -// StreamEventRequest defines request to retrieve a stream of events. -message StreamEventRequest { - // Filter contains filtering criteria. - message Filter { - // hash to filter events. - bytes hash = 1 [ - (gogoproto.moretags) = 'validate:"omitempty,hash"', - (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", - (gogoproto.nullable) = false - ]; - - // instance's hash to filter events. - bytes instanceHash = 2 [ - (gogoproto.moretags) = 'validate:"omitempty,hash"', - (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", - (gogoproto.nullable) = false - ]; - - // key is the key of the event. - string key = 3 [ - (gogoproto.moretags) = 'validate:"printascii"' - ]; - } - - // Filter used to filter a stream of events. - Filter filter = 1; -} - -// CreateEventRequest defines request for execution update. -message CreateEventRequest { - // instanceHash is hash of instance that can proceed an execution. - bytes instanceHash = 1 [ - (gogoproto.moretags) = 'validate:"required,hash"', - (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", - (gogoproto.nullable) = false - ]; - - // key is the key of the event. - string key = 2 [ - (gogoproto.moretags) = 'validate:"required,printascii"' - ]; - - // data is the data for the event. - mesg.protobuf.Struct data = 3; -} - -// CreateEventResponse defines response for execution update. -message CreateEventResponse { - // Hash represents event. - bytes hash = 1 [ - (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", - (gogoproto.nullable) = false - ]; -} diff --git a/protobuf/api/execution.go b/protobuf/api/execution.go deleted file mode 100644 index dc9efa840..000000000 --- a/protobuf/api/execution.go +++ /dev/null @@ -1,63 +0,0 @@ -package api - -import ( - fmt "fmt" - - execution "github.com/mesg-foundation/engine/execution" - "github.com/mesg-foundation/engine/ext/xstrings" -) - -// Validate checks if given filter is valid and returns error. -func (f *StreamExecutionRequest_Filter) Validate() error { - if f == nil { - return nil - } - - if !f.ExecutorHash.Valid() { - return fmt.Errorf("stream filter: executor hash is invalid") - } - - if !f.InstanceHash.Valid() { - return fmt.Errorf("stream filter: instance hash is invalid") - } - - // TODO: add validation (after adding in protobuf with print ascii) - // if f.TaskKey == "" || f.TaskKey == "*" || validation { - // return err - // } - - return nil -} - -// Match matches given execution with filter criteria. -func (f *StreamExecutionRequest_Filter) Match(e *execution.Execution) bool { - if f == nil { - return true - } - if !f.ExecutorHash.IsZero() && !f.ExecutorHash.Equal(e.ExecutorHash) { - return false - } - if !f.InstanceHash.IsZero() && !f.InstanceHash.Equal(e.InstanceHash) { - return false - } - if f.TaskKey != "" && f.TaskKey != "*" && f.TaskKey != e.TaskKey { - return false - } - - match := len(f.Statuses) == 0 - for _, status := range f.Statuses { - if status == e.Status { - match = true - break - } - } - if !match { - return false - } - for _, tag := range f.Tags { - if !xstrings.SliceContains(e.Tags, tag) { - return false - } - } - return true -} diff --git a/protobuf/api/execution.pb.go b/protobuf/api/execution.pb.go deleted file mode 100644 index 5c6a542c1..000000000 --- a/protobuf/api/execution.pb.go +++ /dev/null @@ -1,788 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: protobuf/api/execution.proto - -package api - -import ( - context "context" - fmt "fmt" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" - execution "github.com/mesg-foundation/engine/execution" - github_com_mesg_foundation_engine_hash "github.com/mesg-foundation/engine/hash" - types "github.com/mesg-foundation/engine/protobuf/types" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - math "math" -) - -// 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 - -// CreateExecutionRequest defines request to create a single execution. -type CreateExecutionRequest struct { - // taskKey to filter executions. - TaskKey string `protobuf:"bytes,2,opt,name=taskKey,proto3" json:"taskKey,omitempty" validate:"required,printascii"` - Inputs *types.Struct `protobuf:"bytes,3,opt,name=inputs,proto3" json:"inputs,omitempty"` - // tags the execution. - Tags []string `protobuf:"bytes,4,rep,name=tags,proto3" json:"tags,omitempty" validate:"dive,printascii"` - ParentHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,5,opt,name=parentHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"parentHash" validate:"omitempty,hash"` - EventHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,6,opt,name=eventHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"eventHash" validate:"omitempty,hash"` - ProcessHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,7,opt,name=processHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"processHash" validate:"omitempty,hash"` - NodeKey string `protobuf:"bytes,8,opt,name=nodeKey,proto3" json:"nodeKey,omitempty"` - ExecutorHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,9,opt,name=executorHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"executorHash" validate:"omitempty,hash"` - // price of running the execution. - Price string `protobuf:"bytes,10,opt,name=price,proto3" json:"price,omitempty" validate:"coins"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *CreateExecutionRequest) Reset() { *m = CreateExecutionRequest{} } -func (m *CreateExecutionRequest) String() string { return proto.CompactTextString(m) } -func (*CreateExecutionRequest) ProtoMessage() {} -func (*CreateExecutionRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_96e2c86581f82f05, []int{0} -} -func (m *CreateExecutionRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_CreateExecutionRequest.Unmarshal(m, b) -} -func (m *CreateExecutionRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_CreateExecutionRequest.Marshal(b, m, deterministic) -} -func (m *CreateExecutionRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_CreateExecutionRequest.Merge(m, src) -} -func (m *CreateExecutionRequest) XXX_Size() int { - return xxx_messageInfo_CreateExecutionRequest.Size(m) -} -func (m *CreateExecutionRequest) XXX_DiscardUnknown() { - xxx_messageInfo_CreateExecutionRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_CreateExecutionRequest proto.InternalMessageInfo - -func (m *CreateExecutionRequest) GetTaskKey() string { - if m != nil { - return m.TaskKey - } - return "" -} - -func (m *CreateExecutionRequest) GetInputs() *types.Struct { - if m != nil { - return m.Inputs - } - return nil -} - -func (m *CreateExecutionRequest) GetTags() []string { - if m != nil { - return m.Tags - } - return nil -} - -func (m *CreateExecutionRequest) GetNodeKey() string { - if m != nil { - return m.NodeKey - } - return "" -} - -func (m *CreateExecutionRequest) GetPrice() string { - if m != nil { - return m.Price - } - return "" -} - -// CreateExecutionResponse defines response for execution creation. -type CreateExecutionResponse struct { - // Execution's hash. - Hash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=hash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"hash"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *CreateExecutionResponse) Reset() { *m = CreateExecutionResponse{} } -func (m *CreateExecutionResponse) String() string { return proto.CompactTextString(m) } -func (*CreateExecutionResponse) ProtoMessage() {} -func (*CreateExecutionResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_96e2c86581f82f05, []int{1} -} -func (m *CreateExecutionResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_CreateExecutionResponse.Unmarshal(m, b) -} -func (m *CreateExecutionResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_CreateExecutionResponse.Marshal(b, m, deterministic) -} -func (m *CreateExecutionResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_CreateExecutionResponse.Merge(m, src) -} -func (m *CreateExecutionResponse) XXX_Size() int { - return xxx_messageInfo_CreateExecutionResponse.Size(m) -} -func (m *CreateExecutionResponse) XXX_DiscardUnknown() { - xxx_messageInfo_CreateExecutionResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_CreateExecutionResponse proto.InternalMessageInfo - -// GetExecutionRequest defines request to retrieve a single execution. -type GetExecutionRequest struct { - // Execution's hash to fetch. - Hash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=hash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"hash" validate:"required,hash"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *GetExecutionRequest) Reset() { *m = GetExecutionRequest{} } -func (m *GetExecutionRequest) String() string { return proto.CompactTextString(m) } -func (*GetExecutionRequest) ProtoMessage() {} -func (*GetExecutionRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_96e2c86581f82f05, []int{2} -} -func (m *GetExecutionRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetExecutionRequest.Unmarshal(m, b) -} -func (m *GetExecutionRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetExecutionRequest.Marshal(b, m, deterministic) -} -func (m *GetExecutionRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetExecutionRequest.Merge(m, src) -} -func (m *GetExecutionRequest) XXX_Size() int { - return xxx_messageInfo_GetExecutionRequest.Size(m) -} -func (m *GetExecutionRequest) XXX_DiscardUnknown() { - xxx_messageInfo_GetExecutionRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_GetExecutionRequest proto.InternalMessageInfo - -// StreamExecutionRequest defines request to retrieve a stream of executions. -type StreamExecutionRequest struct { - // Filter used to filter a stream of executions. - Filter *StreamExecutionRequest_Filter `protobuf:"bytes,1,opt,name=filter,proto3" json:"filter,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *StreamExecutionRequest) Reset() { *m = StreamExecutionRequest{} } -func (m *StreamExecutionRequest) String() string { return proto.CompactTextString(m) } -func (*StreamExecutionRequest) ProtoMessage() {} -func (*StreamExecutionRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_96e2c86581f82f05, []int{3} -} -func (m *StreamExecutionRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_StreamExecutionRequest.Unmarshal(m, b) -} -func (m *StreamExecutionRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_StreamExecutionRequest.Marshal(b, m, deterministic) -} -func (m *StreamExecutionRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_StreamExecutionRequest.Merge(m, src) -} -func (m *StreamExecutionRequest) XXX_Size() int { - return xxx_messageInfo_StreamExecutionRequest.Size(m) -} -func (m *StreamExecutionRequest) XXX_DiscardUnknown() { - xxx_messageInfo_StreamExecutionRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_StreamExecutionRequest proto.InternalMessageInfo - -func (m *StreamExecutionRequest) GetFilter() *StreamExecutionRequest_Filter { - if m != nil { - return m.Filter - } - return nil -} - -// Filter contains filtering criteria. -type StreamExecutionRequest_Filter struct { - // Statuses to filter executions. One status needs to be present in the execution. - Statuses []execution.Status `protobuf:"varint,1,rep,packed,name=statuses,proto3,enum=mesg.types.Status" json:"statuses,omitempty"` - // Instance's hash to filter executions. - InstanceHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,2,opt,name=instanceHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"instanceHash" validate:"omitempty,hash"` - // taskKey to filter executions. - TaskKey string `protobuf:"bytes,3,opt,name=taskKey,proto3" json:"taskKey,omitempty" validate:"printascii"` - // tags to filter executions. All tags needs to be present in the execution. - Tags []string `protobuf:"bytes,4,rep,name=tags,proto3" json:"tags,omitempty" validate:"dive,printascii"` - // Executor's hash to filter executions. - ExecutorHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,5,opt,name=executorHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"executorHash" validate:"omitempty,hash"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *StreamExecutionRequest_Filter) Reset() { *m = StreamExecutionRequest_Filter{} } -func (m *StreamExecutionRequest_Filter) String() string { return proto.CompactTextString(m) } -func (*StreamExecutionRequest_Filter) ProtoMessage() {} -func (*StreamExecutionRequest_Filter) Descriptor() ([]byte, []int) { - return fileDescriptor_96e2c86581f82f05, []int{3, 0} -} -func (m *StreamExecutionRequest_Filter) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_StreamExecutionRequest_Filter.Unmarshal(m, b) -} -func (m *StreamExecutionRequest_Filter) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_StreamExecutionRequest_Filter.Marshal(b, m, deterministic) -} -func (m *StreamExecutionRequest_Filter) XXX_Merge(src proto.Message) { - xxx_messageInfo_StreamExecutionRequest_Filter.Merge(m, src) -} -func (m *StreamExecutionRequest_Filter) XXX_Size() int { - return xxx_messageInfo_StreamExecutionRequest_Filter.Size(m) -} -func (m *StreamExecutionRequest_Filter) XXX_DiscardUnknown() { - xxx_messageInfo_StreamExecutionRequest_Filter.DiscardUnknown(m) -} - -var xxx_messageInfo_StreamExecutionRequest_Filter proto.InternalMessageInfo - -func (m *StreamExecutionRequest_Filter) GetStatuses() []execution.Status { - if m != nil { - return m.Statuses - } - return nil -} - -func (m *StreamExecutionRequest_Filter) GetTaskKey() string { - if m != nil { - return m.TaskKey - } - return "" -} - -func (m *StreamExecutionRequest_Filter) GetTags() []string { - if m != nil { - return m.Tags - } - return nil -} - -// UpdateExecutionRequest defines request for execution update. -type UpdateExecutionRequest struct { - // Hash represents execution. - Hash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=hash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"hash" validate:"required,hash"` - // result pass to execution - // - // Types that are valid to be assigned to Result: - // *UpdateExecutionRequest_Outputs - // *UpdateExecutionRequest_Error - Result isUpdateExecutionRequest_Result `protobuf_oneof:"result"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *UpdateExecutionRequest) Reset() { *m = UpdateExecutionRequest{} } -func (m *UpdateExecutionRequest) String() string { return proto.CompactTextString(m) } -func (*UpdateExecutionRequest) ProtoMessage() {} -func (*UpdateExecutionRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_96e2c86581f82f05, []int{4} -} -func (m *UpdateExecutionRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_UpdateExecutionRequest.Unmarshal(m, b) -} -func (m *UpdateExecutionRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_UpdateExecutionRequest.Marshal(b, m, deterministic) -} -func (m *UpdateExecutionRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_UpdateExecutionRequest.Merge(m, src) -} -func (m *UpdateExecutionRequest) XXX_Size() int { - return xxx_messageInfo_UpdateExecutionRequest.Size(m) -} -func (m *UpdateExecutionRequest) XXX_DiscardUnknown() { - xxx_messageInfo_UpdateExecutionRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_UpdateExecutionRequest proto.InternalMessageInfo - -type isUpdateExecutionRequest_Result interface { - isUpdateExecutionRequest_Result() -} - -type UpdateExecutionRequest_Outputs struct { - Outputs *types.Struct `protobuf:"bytes,2,opt,name=outputs,proto3,oneof" json:"outputs,omitempty"` -} -type UpdateExecutionRequest_Error struct { - Error string `protobuf:"bytes,3,opt,name=error,proto3,oneof" json:"error,omitempty"` -} - -func (*UpdateExecutionRequest_Outputs) isUpdateExecutionRequest_Result() {} -func (*UpdateExecutionRequest_Error) isUpdateExecutionRequest_Result() {} - -func (m *UpdateExecutionRequest) GetResult() isUpdateExecutionRequest_Result { - if m != nil { - return m.Result - } - return nil -} - -func (m *UpdateExecutionRequest) GetOutputs() *types.Struct { - if x, ok := m.GetResult().(*UpdateExecutionRequest_Outputs); ok { - return x.Outputs - } - return nil -} - -func (m *UpdateExecutionRequest) GetError() string { - if x, ok := m.GetResult().(*UpdateExecutionRequest_Error); ok { - return x.Error - } - return "" -} - -// XXX_OneofWrappers is for the internal use of the proto package. -func (*UpdateExecutionRequest) XXX_OneofWrappers() []interface{} { - return []interface{}{ - (*UpdateExecutionRequest_Outputs)(nil), - (*UpdateExecutionRequest_Error)(nil), - } -} - -// UpdateExecutionResponse defines response for execution update. -type UpdateExecutionResponse struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *UpdateExecutionResponse) Reset() { *m = UpdateExecutionResponse{} } -func (m *UpdateExecutionResponse) String() string { return proto.CompactTextString(m) } -func (*UpdateExecutionResponse) ProtoMessage() {} -func (*UpdateExecutionResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_96e2c86581f82f05, []int{5} -} -func (m *UpdateExecutionResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_UpdateExecutionResponse.Unmarshal(m, b) -} -func (m *UpdateExecutionResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_UpdateExecutionResponse.Marshal(b, m, deterministic) -} -func (m *UpdateExecutionResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_UpdateExecutionResponse.Merge(m, src) -} -func (m *UpdateExecutionResponse) XXX_Size() int { - return xxx_messageInfo_UpdateExecutionResponse.Size(m) -} -func (m *UpdateExecutionResponse) XXX_DiscardUnknown() { - xxx_messageInfo_UpdateExecutionResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_UpdateExecutionResponse proto.InternalMessageInfo - -// The request's data for the `List` API. -type ListExecutionRequest struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ListExecutionRequest) Reset() { *m = ListExecutionRequest{} } -func (m *ListExecutionRequest) String() string { return proto.CompactTextString(m) } -func (*ListExecutionRequest) ProtoMessage() {} -func (*ListExecutionRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_96e2c86581f82f05, []int{6} -} -func (m *ListExecutionRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ListExecutionRequest.Unmarshal(m, b) -} -func (m *ListExecutionRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ListExecutionRequest.Marshal(b, m, deterministic) -} -func (m *ListExecutionRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_ListExecutionRequest.Merge(m, src) -} -func (m *ListExecutionRequest) XXX_Size() int { - return xxx_messageInfo_ListExecutionRequest.Size(m) -} -func (m *ListExecutionRequest) XXX_DiscardUnknown() { - xxx_messageInfo_ListExecutionRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_ListExecutionRequest proto.InternalMessageInfo - -// The response's data for the `List` API. -type ListExecutionResponse struct { - // List of executions that match the request's filters. - Executions []*execution.Execution `protobuf:"bytes,1,rep,name=executions,proto3" json:"executions,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ListExecutionResponse) Reset() { *m = ListExecutionResponse{} } -func (m *ListExecutionResponse) String() string { return proto.CompactTextString(m) } -func (*ListExecutionResponse) ProtoMessage() {} -func (*ListExecutionResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_96e2c86581f82f05, []int{7} -} -func (m *ListExecutionResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ListExecutionResponse.Unmarshal(m, b) -} -func (m *ListExecutionResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ListExecutionResponse.Marshal(b, m, deterministic) -} -func (m *ListExecutionResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_ListExecutionResponse.Merge(m, src) -} -func (m *ListExecutionResponse) XXX_Size() int { - return xxx_messageInfo_ListExecutionResponse.Size(m) -} -func (m *ListExecutionResponse) XXX_DiscardUnknown() { - xxx_messageInfo_ListExecutionResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_ListExecutionResponse proto.InternalMessageInfo - -func (m *ListExecutionResponse) GetExecutions() []*execution.Execution { - if m != nil { - return m.Executions - } - return nil -} - -func init() { - proto.RegisterType((*CreateExecutionRequest)(nil), "mesg.api.CreateExecutionRequest") - proto.RegisterType((*CreateExecutionResponse)(nil), "mesg.api.CreateExecutionResponse") - proto.RegisterType((*GetExecutionRequest)(nil), "mesg.api.GetExecutionRequest") - proto.RegisterType((*StreamExecutionRequest)(nil), "mesg.api.StreamExecutionRequest") - proto.RegisterType((*StreamExecutionRequest_Filter)(nil), "mesg.api.StreamExecutionRequest.Filter") - proto.RegisterType((*UpdateExecutionRequest)(nil), "mesg.api.UpdateExecutionRequest") - proto.RegisterType((*UpdateExecutionResponse)(nil), "mesg.api.UpdateExecutionResponse") - proto.RegisterType((*ListExecutionRequest)(nil), "mesg.api.ListExecutionRequest") - proto.RegisterType((*ListExecutionResponse)(nil), "mesg.api.ListExecutionResponse") -} - -func init() { proto.RegisterFile("protobuf/api/execution.proto", fileDescriptor_96e2c86581f82f05) } - -var fileDescriptor_96e2c86581f82f05 = []byte{ - // 751 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x55, 0x41, 0x6f, 0xda, 0x48, - 0x14, 0x06, 0x0c, 0x06, 0x5e, 0xa2, 0xd5, 0x6a, 0x36, 0x21, 0x0e, 0xbb, 0x8b, 0x59, 0x5f, 0x16, - 0xed, 0x26, 0xa6, 0x25, 0xea, 0xa5, 0x6a, 0x55, 0x89, 0x2a, 0x4d, 0xaa, 0x56, 0x4d, 0xe5, 0xa8, - 0x97, 0xde, 0x06, 0xf3, 0x02, 0xa3, 0x06, 0xdb, 0x99, 0x19, 0x47, 0x4d, 0xff, 0x43, 0xff, 0x57, - 0xa5, 0xde, 0x7a, 0xec, 0x81, 0x7b, 0xaf, 0xfc, 0x80, 0xaa, 0xf2, 0x0c, 0x60, 0x02, 0x4e, 0x0e, - 0x91, 0xc8, 0xcd, 0x33, 0xef, 0x7b, 0xf3, 0xbd, 0x37, 0xf3, 0xbd, 0xcf, 0xf0, 0x57, 0xc4, 0x43, - 0x19, 0xf6, 0xe2, 0xb3, 0x36, 0x8d, 0x58, 0x1b, 0x3f, 0xa2, 0x1f, 0x4b, 0x16, 0x06, 0xae, 0xda, - 0x26, 0x95, 0x11, 0x8a, 0x81, 0x4b, 0x23, 0x56, 0x77, 0x06, 0xe1, 0x20, 0x6c, 0xcf, 0xc1, 0xc9, - 0x4a, 0x2d, 0xd4, 0x97, 0x46, 0xd7, 0xff, 0x9c, 0x87, 0xe5, 0x55, 0x84, 0xa2, 0x2d, 0x24, 0x8f, - 0x7d, 0x39, 0x0d, 0x36, 0x96, 0x82, 0x4b, 0x54, 0xce, 0xd7, 0x12, 0xd4, 0x9e, 0x73, 0xa4, 0x12, - 0x0f, 0x67, 0x11, 0x0f, 0x2f, 0x62, 0x14, 0x92, 0x3c, 0x81, 0xb2, 0xa4, 0xe2, 0xc3, 0x2b, 0xbc, - 0xb2, 0x0a, 0xcd, 0x7c, 0xab, 0xda, 0x75, 0x26, 0x63, 0xbb, 0x71, 0x49, 0xcf, 0x59, 0x9f, 0x4a, - 0x7c, 0xec, 0x70, 0xbc, 0x88, 0x19, 0xc7, 0xfe, 0x5e, 0xc4, 0x59, 0x20, 0xa9, 0xf0, 0x19, 0x73, - 0xbc, 0x59, 0x0a, 0xd9, 0x07, 0x93, 0x05, 0x51, 0x2c, 0x85, 0x65, 0x34, 0xf3, 0xad, 0x8d, 0xce, - 0xb6, 0xab, 0x9a, 0x9a, 0x95, 0xe3, 0x9e, 0xaa, 0x2a, 0xbd, 0x29, 0x88, 0x74, 0xa0, 0x28, 0xe9, - 0x40, 0x58, 0xc5, 0xa6, 0xd1, 0xaa, 0x76, 0x1b, 0x93, 0xb1, 0x5d, 0x4f, 0x99, 0xfa, 0xec, 0x12, - 0xaf, 0xb1, 0x28, 0x2c, 0x89, 0x00, 0x22, 0xca, 0x31, 0x90, 0xc7, 0x54, 0x0c, 0xad, 0x52, 0x33, - 0xdf, 0xda, 0xec, 0xbe, 0xfd, 0x32, 0xb6, 0x73, 0xdf, 0xc7, 0xf6, 0xff, 0x03, 0x26, 0x87, 0x71, - 0xcf, 0xf5, 0xc3, 0x51, 0x3b, 0x21, 0xde, 0x3f, 0x0b, 0xe3, 0xa0, 0x4f, 0x93, 0xfe, 0xda, 0x18, - 0x0c, 0x58, 0x80, 0xed, 0x21, 0x15, 0x43, 0x37, 0x49, 0x9d, 0x8c, 0xed, 0xdd, 0x94, 0x2c, 0x1c, - 0x31, 0x89, 0xa3, 0x48, 0x5e, 0xed, 0x25, 0x00, 0xc7, 0x5b, 0xe0, 0x20, 0x01, 0x54, 0xf1, 0x72, - 0x46, 0x68, 0xae, 0x89, 0x30, 0xa5, 0x20, 0x1c, 0x36, 0x22, 0x1e, 0xfa, 0x28, 0x84, 0x62, 0x2c, - 0xaf, 0x89, 0x71, 0x91, 0x84, 0x58, 0x50, 0x0e, 0xc2, 0x3e, 0x26, 0xcf, 0x5e, 0x49, 0x9e, 0xdd, - 0x9b, 0x2d, 0x89, 0x84, 0x4d, 0x2d, 0x9f, 0x90, 0xab, 0x72, 0xaa, 0x6b, 0x2a, 0xe7, 0x1a, 0x0b, - 0xf9, 0x0f, 0x4a, 0x11, 0x67, 0x3e, 0x5a, 0xa0, 0x44, 0xb8, 0x35, 0x19, 0xdb, 0xbf, 0xa7, 0xb9, - 0x7e, 0xc8, 0x02, 0xe1, 0x78, 0x1a, 0xe2, 0xf4, 0x60, 0x67, 0x45, 0xcc, 0x22, 0x0a, 0x03, 0x81, - 0xe4, 0x08, 0x8a, 0xc9, 0xe9, 0x56, 0x5e, 0x15, 0x7d, 0x70, 0x87, 0xa2, 0x3d, 0x75, 0x80, 0xf3, - 0x09, 0xfe, 0x38, 0x42, 0xb9, 0x32, 0x2d, 0xfe, 0xb5, 0xf3, 0x4f, 0xee, 0x76, 0x29, 0x56, 0xc6, - 0x74, 0xe9, 0x3b, 0xd1, 0xdc, 0x3f, 0x0c, 0xa8, 0x9d, 0x4a, 0x8e, 0x74, 0xb4, 0xc2, 0xff, 0x0c, - 0xcc, 0x33, 0x76, 0x2e, 0x91, 0xab, 0x0a, 0x36, 0x3a, 0xff, 0xba, 0x33, 0x13, 0x71, 0xb3, 0x33, - 0xdc, 0x17, 0x0a, 0xee, 0x4d, 0xd3, 0xea, 0x9f, 0x0d, 0x30, 0xf5, 0x16, 0x71, 0xa1, 0x22, 0x24, - 0x95, 0xb1, 0x40, 0x61, 0xe5, 0x9b, 0x46, 0xeb, 0xb7, 0x0e, 0xd1, 0xa7, 0x29, 0x0f, 0x71, 0x4f, - 0x55, 0xcc, 0x9b, 0x63, 0x12, 0x61, 0xb0, 0x40, 0x48, 0x1a, 0xf8, 0xa8, 0x84, 0x51, 0x58, 0x97, - 0x30, 0x16, 0x59, 0xc8, 0x41, 0xea, 0x4f, 0x86, 0x92, 0xc6, 0xee, 0x64, 0x6c, 0x6f, 0xa7, 0xd9, - 0x99, 0xb6, 0x74, 0x17, 0x9f, 0x59, 0xd6, 0x7d, 0xe9, 0x3e, 0x74, 0xef, 0x7c, 0xcb, 0x43, 0xed, - 0x5d, 0xd4, 0xcf, 0x72, 0xe6, 0xfb, 0xd0, 0x1a, 0x79, 0x08, 0xe5, 0x30, 0x96, 0xca, 0xc1, 0x0b, - 0xb7, 0x38, 0xf8, 0x71, 0xce, 0x9b, 0xe1, 0x48, 0x0d, 0x4a, 0xc8, 0x79, 0xc8, 0xf5, 0x7b, 0x1c, - 0xe7, 0x3c, 0xbd, 0xec, 0x56, 0xc0, 0xe4, 0x28, 0xe2, 0x73, 0xe9, 0xec, 0xc2, 0xce, 0x4a, 0x4f, - 0x7a, 0x40, 0x9d, 0x1a, 0x6c, 0xbd, 0x66, 0x62, 0x65, 0xb0, 0x9c, 0x37, 0xb0, 0xbd, 0xb4, 0x3f, - 0x9d, 0xe8, 0x47, 0x00, 0xf3, 0xbf, 0x99, 0xd6, 0xe9, 0xbc, 0x46, 0xad, 0xd3, 0x34, 0x65, 0x01, - 0xd8, 0xf9, 0x59, 0x80, 0xea, 0x3c, 0x42, 0x4e, 0xc0, 0xd4, 0x8e, 0x41, 0x9a, 0xe9, 0xc0, 0x64, - 0xff, 0x10, 0xeb, 0xff, 0xdc, 0x82, 0x98, 0x36, 0x91, 0x23, 0x4f, 0xc1, 0x38, 0x42, 0x49, 0xfe, - 0x4e, 0xb1, 0x19, 0x6e, 0x51, 0xcf, 0xae, 0xd3, 0xc9, 0x91, 0x97, 0x50, 0x4c, 0xba, 0x25, 0x8d, - 0x34, 0x3f, 0xeb, 0x56, 0xea, 0xf6, 0x8d, 0xf1, 0x79, 0x25, 0x87, 0x60, 0xea, 0xc9, 0x5f, 0x6c, - 0x2d, 0xdb, 0x0b, 0x6e, 0xac, 0xe7, 0x41, 0x3e, 0xb9, 0x21, 0xfd, 0x64, 0x8b, 0xc7, 0x64, 0x0b, - 0x73, 0xf1, 0x86, 0x6e, 0x7a, 0xe6, 0x5c, 0xb7, 0xf4, 0xde, 0xa0, 0x11, 0xeb, 0x99, 0x4a, 0x48, - 0x07, 0xbf, 0x02, 0x00, 0x00, 0xff, 0xff, 0xb1, 0xfc, 0x30, 0xe0, 0x0b, 0x09, 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 - -// ExecutionClient is the client API for Execution service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type ExecutionClient interface { - // Create creates a single Execution specified in a request. - Create(ctx context.Context, in *CreateExecutionRequest, opts ...grpc.CallOption) (*CreateExecutionResponse, error) - // Get returns a single Execution specified in a request. - Get(ctx context.Context, in *GetExecutionRequest, opts ...grpc.CallOption) (*execution.Execution, error) - // List returns all Executions matching the criteria of the request. - List(ctx context.Context, in *ListExecutionRequest, opts ...grpc.CallOption) (*ListExecutionResponse, error) - // Stream returns a stream of executions that satisfy criteria - // specified in a request. - Stream(ctx context.Context, in *StreamExecutionRequest, opts ...grpc.CallOption) (Execution_StreamClient, error) - // Update updates execution with outputs or an error. - Update(ctx context.Context, in *UpdateExecutionRequest, opts ...grpc.CallOption) (*UpdateExecutionResponse, error) -} - -type executionClient struct { - cc *grpc.ClientConn -} - -func NewExecutionClient(cc *grpc.ClientConn) ExecutionClient { - return &executionClient{cc} -} - -func (c *executionClient) Create(ctx context.Context, in *CreateExecutionRequest, opts ...grpc.CallOption) (*CreateExecutionResponse, error) { - out := new(CreateExecutionResponse) - err := c.cc.Invoke(ctx, "/mesg.api.Execution/Create", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *executionClient) Get(ctx context.Context, in *GetExecutionRequest, opts ...grpc.CallOption) (*execution.Execution, error) { - out := new(execution.Execution) - err := c.cc.Invoke(ctx, "/mesg.api.Execution/Get", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *executionClient) List(ctx context.Context, in *ListExecutionRequest, opts ...grpc.CallOption) (*ListExecutionResponse, error) { - out := new(ListExecutionResponse) - err := c.cc.Invoke(ctx, "/mesg.api.Execution/List", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *executionClient) Stream(ctx context.Context, in *StreamExecutionRequest, opts ...grpc.CallOption) (Execution_StreamClient, error) { - stream, err := c.cc.NewStream(ctx, &_Execution_serviceDesc.Streams[0], "/mesg.api.Execution/Stream", opts...) - if err != nil { - return nil, err - } - x := &executionStreamClient{stream} - if err := x.ClientStream.SendMsg(in); err != nil { - return nil, err - } - if err := x.ClientStream.CloseSend(); err != nil { - return nil, err - } - return x, nil -} - -type Execution_StreamClient interface { - Recv() (*execution.Execution, error) - grpc.ClientStream -} - -type executionStreamClient struct { - grpc.ClientStream -} - -func (x *executionStreamClient) Recv() (*execution.Execution, error) { - m := new(execution.Execution) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -func (c *executionClient) Update(ctx context.Context, in *UpdateExecutionRequest, opts ...grpc.CallOption) (*UpdateExecutionResponse, error) { - out := new(UpdateExecutionResponse) - err := c.cc.Invoke(ctx, "/mesg.api.Execution/Update", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// ExecutionServer is the server API for Execution service. -type ExecutionServer interface { - // Create creates a single Execution specified in a request. - Create(context.Context, *CreateExecutionRequest) (*CreateExecutionResponse, error) - // Get returns a single Execution specified in a request. - Get(context.Context, *GetExecutionRequest) (*execution.Execution, error) - // List returns all Executions matching the criteria of the request. - List(context.Context, *ListExecutionRequest) (*ListExecutionResponse, error) - // Stream returns a stream of executions that satisfy criteria - // specified in a request. - Stream(*StreamExecutionRequest, Execution_StreamServer) error - // Update updates execution with outputs or an error. - Update(context.Context, *UpdateExecutionRequest) (*UpdateExecutionResponse, error) -} - -// UnimplementedExecutionServer can be embedded to have forward compatible implementations. -type UnimplementedExecutionServer struct { -} - -func (*UnimplementedExecutionServer) Create(ctx context.Context, req *CreateExecutionRequest) (*CreateExecutionResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Create not implemented") -} -func (*UnimplementedExecutionServer) Get(ctx context.Context, req *GetExecutionRequest) (*execution.Execution, error) { - return nil, status.Errorf(codes.Unimplemented, "method Get not implemented") -} -func (*UnimplementedExecutionServer) List(ctx context.Context, req *ListExecutionRequest) (*ListExecutionResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method List not implemented") -} -func (*UnimplementedExecutionServer) Stream(req *StreamExecutionRequest, srv Execution_StreamServer) error { - return status.Errorf(codes.Unimplemented, "method Stream not implemented") -} -func (*UnimplementedExecutionServer) Update(ctx context.Context, req *UpdateExecutionRequest) (*UpdateExecutionResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Update not implemented") -} - -func RegisterExecutionServer(s *grpc.Server, srv ExecutionServer) { - s.RegisterService(&_Execution_serviceDesc, srv) -} - -func _Execution_Create_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(CreateExecutionRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ExecutionServer).Create(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/mesg.api.Execution/Create", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ExecutionServer).Create(ctx, req.(*CreateExecutionRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Execution_Get_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetExecutionRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ExecutionServer).Get(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/mesg.api.Execution/Get", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ExecutionServer).Get(ctx, req.(*GetExecutionRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Execution_List_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ListExecutionRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ExecutionServer).List(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/mesg.api.Execution/List", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ExecutionServer).List(ctx, req.(*ListExecutionRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Execution_Stream_Handler(srv interface{}, stream grpc.ServerStream) error { - m := new(StreamExecutionRequest) - if err := stream.RecvMsg(m); err != nil { - return err - } - return srv.(ExecutionServer).Stream(m, &executionStreamServer{stream}) -} - -type Execution_StreamServer interface { - Send(*execution.Execution) error - grpc.ServerStream -} - -type executionStreamServer struct { - grpc.ServerStream -} - -func (x *executionStreamServer) Send(m *execution.Execution) error { - return x.ServerStream.SendMsg(m) -} - -func _Execution_Update_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(UpdateExecutionRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ExecutionServer).Update(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/mesg.api.Execution/Update", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ExecutionServer).Update(ctx, req.(*UpdateExecutionRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _Execution_serviceDesc = grpc.ServiceDesc{ - ServiceName: "mesg.api.Execution", - HandlerType: (*ExecutionServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Create", - Handler: _Execution_Create_Handler, - }, - { - MethodName: "Get", - Handler: _Execution_Get_Handler, - }, - { - MethodName: "List", - Handler: _Execution_List_Handler, - }, - { - MethodName: "Update", - Handler: _Execution_Update_Handler, - }, - }, - Streams: []grpc.StreamDesc{ - { - StreamName: "Stream", - Handler: _Execution_Stream_Handler, - ServerStreams: true, - }, - }, - Metadata: "protobuf/api/execution.proto", -} diff --git a/protobuf/api/execution.proto b/protobuf/api/execution.proto deleted file mode 100644 index 0f7a52148..000000000 --- a/protobuf/api/execution.proto +++ /dev/null @@ -1,164 +0,0 @@ -syntax = "proto3"; - -import "gogo/protobuf/gogoproto/gogo.proto"; -import "protobuf/types/struct.proto"; -import "protobuf/types/execution.proto"; - -package mesg.api; -option go_package = "api"; - -// This is the API to interact with the Executions. -// -// This API is a [gRPC](https://grpc.io/) API. -// -// The source file of this API is hosted on [GitHub](https://github.com/mesg-foundation/engine/blob/master/protobuf/api/execution.proto). - -service Execution { - // Create creates a single Execution specified in a request. - rpc Create(CreateExecutionRequest) returns (CreateExecutionResponse) {} - - // Get returns a single Execution specified in a request. - rpc Get(GetExecutionRequest) returns (types.Execution) {} - - // List returns all Executions matching the criteria of the request. - rpc List(ListExecutionRequest) returns (ListExecutionResponse) {} - - // Stream returns a stream of executions that satisfy criteria - // specified in a request. - rpc Stream(StreamExecutionRequest) returns (stream types.Execution) {} - - // Update updates execution with outputs or an error. - rpc Update(UpdateExecutionRequest) returns (UpdateExecutionResponse) {} -} - -// CreateExecutionRequest defines request to create a single execution. -message CreateExecutionRequest { - // taskKey to filter executions. - string taskKey = 2 [ - (gogoproto.moretags) = 'validate:"required,printascii"' - ]; - - mesg.protobuf.Struct inputs = 3; - - // tags the execution. - repeated string tags = 4 [ - (gogoproto.moretags) = 'validate:"dive,printascii"' - ]; - - bytes parentHash = 5 [ - (gogoproto.moretags) = 'validate:"omitempty,hash"', - (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", - (gogoproto.nullable) = false - ]; - - bytes eventHash = 6 [ - (gogoproto.moretags) = 'validate:"omitempty,hash"', - (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", - (gogoproto.nullable) = false - ]; - - bytes processHash = 7 [ - (gogoproto.moretags) = 'validate:"omitempty,hash"', - (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", - (gogoproto.nullable) = false - ]; - - string nodeKey = 8; - - bytes executorHash = 9 [ - (gogoproto.moretags) = 'validate:"omitempty,hash"', - (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", - (gogoproto.nullable) = false - ]; - - // price of running the execution. - string price = 10 [ - (gogoproto.moretags) = 'validate:"coins"' - ]; -} - -// CreateExecutionResponse defines response for execution creation. -message CreateExecutionResponse { - // Execution's hash. - bytes hash = 1 [ - (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", - (gogoproto.nullable) = false - ]; -} - -// GetExecutionRequest defines request to retrieve a single execution. -message GetExecutionRequest { - // Execution's hash to fetch. - bytes hash = 1 [ - (gogoproto.moretags) = 'validate:"required,hash"', - (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", - (gogoproto.nullable) = false - ]; -} - -// StreamExecutionRequest defines request to retrieve a stream of executions. -message StreamExecutionRequest{ - // Filter contains filtering criteria. - message Filter { - // Statuses to filter executions. One status needs to be present in the execution. - repeated types.Status statuses = 1; - - // Instance's hash to filter executions. - bytes instanceHash = 2 [ - (gogoproto.moretags) = 'validate:"omitempty,hash"', - (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", - (gogoproto.nullable) = false - ]; - - // taskKey to filter executions. - string taskKey = 3 [ - (gogoproto.moretags) = 'validate:"printascii"' - ]; - - // tags to filter executions. All tags needs to be present in the execution. - repeated string tags = 4 [ - (gogoproto.moretags) = 'validate:"dive,printascii"' - ]; - - // Executor's hash to filter executions. - bytes executorHash = 5 [ - (gogoproto.moretags) = 'validate:"omitempty,hash"', - (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", - (gogoproto.nullable) = false - ]; - } - - // Filter used to filter a stream of executions. - Filter filter = 1; -} - -// UpdateExecutionRequest defines request for execution update. -message UpdateExecutionRequest { - // Hash represents execution. - bytes hash = 1 [ - (gogoproto.moretags) = 'validate:"required,hash"', - (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", - (gogoproto.nullable) = false - ]; - - // result pass to execution - oneof result { - // outputs is a success result. - mesg.protobuf.Struct outputs = 2; - - // error is an error result. - string error = 3; - } -} - -// UpdateExecutionResponse defines response for execution update. -message UpdateExecutionResponse {} - -// The request's data for the `List` API. -message ListExecutionRequest {} - -// The response's data for the `List` API. -message ListExecutionResponse { - // List of executions that match the request's filters. - repeated types.Execution executions = 1; -} diff --git a/protobuf/api/execution_test.go b/protobuf/api/execution_test.go deleted file mode 100644 index 6f9c7a9c5..000000000 --- a/protobuf/api/execution_test.go +++ /dev/null @@ -1,116 +0,0 @@ -package api - -import ( - "testing" - - "github.com/mesg-foundation/engine/execution" - "github.com/mesg-foundation/engine/hash" - "github.com/stretchr/testify/assert" -) - -func TestFilter(t *testing.T) { - var tests = []struct { - f *StreamExecutionRequest_Filter - e *execution.Execution - match bool - }{ - { - nil, - nil, - true, - }, - { - &StreamExecutionRequest_Filter{}, - &execution.Execution{}, - true, - }, - { - &StreamExecutionRequest_Filter{InstanceHash: hash.Int(1)}, - &execution.Execution{InstanceHash: hash.Int(1)}, - true, - }, - { - &StreamExecutionRequest_Filter{InstanceHash: hash.Int(1)}, - &execution.Execution{InstanceHash: hash.Int(2)}, - false, - }, - { - &StreamExecutionRequest_Filter{ExecutorHash: hash.Int(1)}, - &execution.Execution{ExecutorHash: hash.Int(1)}, - true, - }, - { - &StreamExecutionRequest_Filter{ExecutorHash: hash.Int(1)}, - &execution.Execution{ExecutorHash: hash.Int(2)}, - false, - }, - { - &StreamExecutionRequest_Filter{Statuses: []execution.Status{execution.Status_Proposed}}, - &execution.Execution{Status: execution.Status_Proposed}, - true, - }, - { - &StreamExecutionRequest_Filter{Statuses: []execution.Status{execution.Status_Proposed}}, - &execution.Execution{Status: execution.Status_InProgress}, - false, - }, - { - &StreamExecutionRequest_Filter{TaskKey: "0"}, - &execution.Execution{TaskKey: "0"}, - true, - }, - { - &StreamExecutionRequest_Filter{TaskKey: "*"}, - &execution.Execution{TaskKey: "0"}, - true, - }, - { - &StreamExecutionRequest_Filter{TaskKey: "0"}, - &execution.Execution{TaskKey: "1"}, - false, - }, - { - &StreamExecutionRequest_Filter{Tags: []string{"0"}}, - &execution.Execution{Tags: []string{"0"}}, - true, - }, - { - &StreamExecutionRequest_Filter{Tags: []string{"0", "1"}}, - &execution.Execution{Tags: []string{"0"}}, - false, - }, - } - - for i, tt := range tests { - assert.Equal(t, tt.match, tt.f.Match(tt.e), i) - } -} - -func TestValidateFilter(t *testing.T) { - var tests = []struct { - f *StreamExecutionRequest_Filter - isError bool - }{ - { - nil, - false, - }, - { - &StreamExecutionRequest_Filter{}, - false, - }, - { - &StreamExecutionRequest_Filter{ - TaskKey: "not-exist", - }, - false, - }, - } - for i, tt := range tests { - if tt.isError { - assert.Error(t, tt.f.Validate(), "", i) - } else { - assert.NoError(t, tt.f.Validate(), i) - } - } -} diff --git a/protobuf/api/instance.pb.go b/protobuf/api/instance.pb.go deleted file mode 100644 index 5ae05c6ac..000000000 --- a/protobuf/api/instance.pb.go +++ /dev/null @@ -1,329 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: protobuf/api/instance.proto - -package api - -import ( - context "context" - fmt "fmt" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" - github_com_mesg_foundation_engine_hash "github.com/mesg-foundation/engine/hash" - instance "github.com/mesg-foundation/engine/instance" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - math "math" -) - -// 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 - -// The request's data for the `Get` API. -type GetInstanceRequest struct { - Hash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=hash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"hash" validate:"required,hash"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *GetInstanceRequest) Reset() { *m = GetInstanceRequest{} } -func (m *GetInstanceRequest) String() string { return proto.CompactTextString(m) } -func (*GetInstanceRequest) ProtoMessage() {} -func (*GetInstanceRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_71d44b8f4a870f63, []int{0} -} -func (m *GetInstanceRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetInstanceRequest.Unmarshal(m, b) -} -func (m *GetInstanceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetInstanceRequest.Marshal(b, m, deterministic) -} -func (m *GetInstanceRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetInstanceRequest.Merge(m, src) -} -func (m *GetInstanceRequest) XXX_Size() int { - return xxx_messageInfo_GetInstanceRequest.Size(m) -} -func (m *GetInstanceRequest) XXX_DiscardUnknown() { - xxx_messageInfo_GetInstanceRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_GetInstanceRequest proto.InternalMessageInfo - -// The request's data for the `List` API. -type ListInstanceRequest struct { - // Filter used to filter a list of instance. - Filter *ListInstanceRequest_Filter `protobuf:"bytes,1,opt,name=filter,proto3" json:"filter,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ListInstanceRequest) Reset() { *m = ListInstanceRequest{} } -func (m *ListInstanceRequest) String() string { return proto.CompactTextString(m) } -func (*ListInstanceRequest) ProtoMessage() {} -func (*ListInstanceRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_71d44b8f4a870f63, []int{1} -} -func (m *ListInstanceRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ListInstanceRequest.Unmarshal(m, b) -} -func (m *ListInstanceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ListInstanceRequest.Marshal(b, m, deterministic) -} -func (m *ListInstanceRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_ListInstanceRequest.Merge(m, src) -} -func (m *ListInstanceRequest) XXX_Size() int { - return xxx_messageInfo_ListInstanceRequest.Size(m) -} -func (m *ListInstanceRequest) XXX_DiscardUnknown() { - xxx_messageInfo_ListInstanceRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_ListInstanceRequest proto.InternalMessageInfo - -func (m *ListInstanceRequest) GetFilter() *ListInstanceRequest_Filter { - if m != nil { - return m.Filter - } - return nil -} - -// Filter contains filtering criteria. -type ListInstanceRequest_Filter struct { - // Service hash to filter executions. - ServiceHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=serviceHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"serviceHash" validate:"omitempty,hash"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ListInstanceRequest_Filter) Reset() { *m = ListInstanceRequest_Filter{} } -func (m *ListInstanceRequest_Filter) String() string { return proto.CompactTextString(m) } -func (*ListInstanceRequest_Filter) ProtoMessage() {} -func (*ListInstanceRequest_Filter) Descriptor() ([]byte, []int) { - return fileDescriptor_71d44b8f4a870f63, []int{1, 0} -} -func (m *ListInstanceRequest_Filter) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ListInstanceRequest_Filter.Unmarshal(m, b) -} -func (m *ListInstanceRequest_Filter) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ListInstanceRequest_Filter.Marshal(b, m, deterministic) -} -func (m *ListInstanceRequest_Filter) XXX_Merge(src proto.Message) { - xxx_messageInfo_ListInstanceRequest_Filter.Merge(m, src) -} -func (m *ListInstanceRequest_Filter) XXX_Size() int { - return xxx_messageInfo_ListInstanceRequest_Filter.Size(m) -} -func (m *ListInstanceRequest_Filter) XXX_DiscardUnknown() { - xxx_messageInfo_ListInstanceRequest_Filter.DiscardUnknown(m) -} - -var xxx_messageInfo_ListInstanceRequest_Filter proto.InternalMessageInfo - -// The response's data for the `List` API. -type ListInstanceResponse struct { - // List of instances that match the request's filters. - Instances []*instance.Instance `protobuf:"bytes,1,rep,name=instances,proto3" json:"instances,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ListInstanceResponse) Reset() { *m = ListInstanceResponse{} } -func (m *ListInstanceResponse) String() string { return proto.CompactTextString(m) } -func (*ListInstanceResponse) ProtoMessage() {} -func (*ListInstanceResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_71d44b8f4a870f63, []int{2} -} -func (m *ListInstanceResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ListInstanceResponse.Unmarshal(m, b) -} -func (m *ListInstanceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ListInstanceResponse.Marshal(b, m, deterministic) -} -func (m *ListInstanceResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_ListInstanceResponse.Merge(m, src) -} -func (m *ListInstanceResponse) XXX_Size() int { - return xxx_messageInfo_ListInstanceResponse.Size(m) -} -func (m *ListInstanceResponse) XXX_DiscardUnknown() { - xxx_messageInfo_ListInstanceResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_ListInstanceResponse proto.InternalMessageInfo - -func (m *ListInstanceResponse) GetInstances() []*instance.Instance { - if m != nil { - return m.Instances - } - return nil -} - -func init() { - proto.RegisterType((*GetInstanceRequest)(nil), "mesg.api.GetInstanceRequest") - proto.RegisterType((*ListInstanceRequest)(nil), "mesg.api.ListInstanceRequest") - proto.RegisterType((*ListInstanceRequest_Filter)(nil), "mesg.api.ListInstanceRequest.Filter") - proto.RegisterType((*ListInstanceResponse)(nil), "mesg.api.ListInstanceResponse") -} - -func init() { proto.RegisterFile("protobuf/api/instance.proto", fileDescriptor_71d44b8f4a870f63) } - -var fileDescriptor_71d44b8f4a870f63 = []byte{ - // 362 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0xcf, 0x4e, 0xea, 0x40, - 0x14, 0xc6, 0x69, 0xe0, 0x12, 0xee, 0x70, 0x57, 0x73, 0x59, 0x60, 0x15, 0x21, 0x13, 0x17, 0x24, - 0xea, 0x34, 0xa9, 0x3b, 0x75, 0xc5, 0x42, 0xd0, 0x98, 0x68, 0x58, 0xba, 0x1b, 0xca, 0xa1, 0x9d, - 0x84, 0xce, 0x0c, 0x9d, 0x29, 0x09, 0x89, 0x0f, 0xe1, 0x63, 0xb9, 0x75, 0xeb, 0x82, 0x87, 0xf0, - 0x09, 0x4c, 0xa7, 0x40, 0x55, 0xd0, 0x85, 0xbb, 0xce, 0x77, 0xbe, 0xf3, 0xe7, 0x77, 0x4e, 0xd1, - 0xbe, 0x4a, 0xa4, 0x91, 0xa3, 0x74, 0xe2, 0x31, 0xc5, 0x3d, 0x2e, 0xb4, 0x61, 0x22, 0x00, 0x6a, - 0x55, 0x5c, 0x8b, 0x41, 0x87, 0x94, 0x29, 0xee, 0x92, 0x50, 0x86, 0xd2, 0xdb, 0x78, 0xb3, 0x97, - 0x7d, 0xd8, 0xaf, 0xdc, 0xed, 0xb6, 0x36, 0x61, 0xb3, 0x50, 0xa0, 0xbf, 0x14, 0x23, 0x0b, 0x84, - 0xfb, 0x60, 0xae, 0x57, 0xe2, 0x10, 0x66, 0x29, 0x68, 0x83, 0x03, 0x54, 0x89, 0x98, 0x8e, 0x9a, - 0x4e, 0xc7, 0xe9, 0xfe, 0xeb, 0xdd, 0x3d, 0x2f, 0xdb, 0xa5, 0xd7, 0x65, 0xfb, 0x38, 0xe4, 0x26, - 0x4a, 0x47, 0x34, 0x90, 0xb1, 0x97, 0xcd, 0x70, 0x3a, 0x91, 0xa9, 0x18, 0x33, 0xc3, 0xa5, 0xf0, - 0x40, 0x84, 0x5c, 0x80, 0x97, 0x65, 0xd1, 0x01, 0xd3, 0xd1, 0xdb, 0xb2, 0xdd, 0x9c, 0xb3, 0x29, - 0x1f, 0x33, 0x03, 0xe7, 0x24, 0x81, 0x59, 0xca, 0x13, 0x18, 0x9f, 0x64, 0x71, 0x32, 0xb4, 0xc5, - 0xc9, 0x8b, 0x83, 0xfe, 0xdf, 0x72, 0xbd, 0xd5, 0xfc, 0x12, 0x55, 0x27, 0x7c, 0x6a, 0x20, 0xb1, - 0xed, 0xeb, 0xfe, 0x11, 0x5d, 0x03, 0xd3, 0x1d, 0x76, 0x7a, 0x65, 0xbd, 0xc3, 0x55, 0x8e, 0xfb, - 0x88, 0xaa, 0xb9, 0x82, 0x13, 0x54, 0xd7, 0x90, 0xcc, 0x79, 0x00, 0x83, 0x82, 0xe5, 0xfe, 0x77, - 0x2c, 0x7b, 0x05, 0x8b, 0x8c, 0xb9, 0x81, 0x58, 0x99, 0xc5, 0x0a, 0xe6, 0x63, 0x13, 0x72, 0x83, - 0x1a, 0x9f, 0x67, 0xd4, 0x4a, 0x0a, 0x0d, 0xd8, 0x47, 0x7f, 0xd7, 0x8b, 0xd7, 0x4d, 0xa7, 0x53, - 0xee, 0xd6, 0xfd, 0x46, 0x8e, 0x65, 0xaf, 0x42, 0x37, 0x09, 0x85, 0xcd, 0x7f, 0x72, 0x50, 0x6d, - 0xad, 0xe3, 0x0b, 0x54, 0xee, 0x83, 0xc1, 0x07, 0xc5, 0x2e, 0xb6, 0xcf, 0xe6, 0xee, 0x2c, 0x49, - 0x4a, 0xb8, 0x8f, 0x2a, 0xd9, 0x54, 0xb8, 0xf5, 0xe3, 0x26, 0xdd, 0xc3, 0xef, 0xc2, 0x39, 0x04, - 0x29, 0xf5, 0xfe, 0x3c, 0x94, 0x99, 0xe2, 0xa3, 0xaa, 0xfd, 0x77, 0xce, 0xde, 0x03, 0x00, 0x00, - 0xff, 0xff, 0x7d, 0x00, 0x9a, 0x7d, 0xa7, 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 - -// InstanceClient is the client API for Instance service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type InstanceClient interface { - // Get returns an Instance matching the criteria of the request. - Get(ctx context.Context, in *GetInstanceRequest, opts ...grpc.CallOption) (*instance.Instance, error) - // List returns all Instances matching the criteria of the request. - List(ctx context.Context, in *ListInstanceRequest, opts ...grpc.CallOption) (*ListInstanceResponse, error) -} - -type instanceClient struct { - cc *grpc.ClientConn -} - -func NewInstanceClient(cc *grpc.ClientConn) InstanceClient { - return &instanceClient{cc} -} - -func (c *instanceClient) Get(ctx context.Context, in *GetInstanceRequest, opts ...grpc.CallOption) (*instance.Instance, error) { - out := new(instance.Instance) - err := c.cc.Invoke(ctx, "/mesg.api.Instance/Get", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *instanceClient) List(ctx context.Context, in *ListInstanceRequest, opts ...grpc.CallOption) (*ListInstanceResponse, error) { - out := new(ListInstanceResponse) - err := c.cc.Invoke(ctx, "/mesg.api.Instance/List", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// InstanceServer is the server API for Instance service. -type InstanceServer interface { - // Get returns an Instance matching the criteria of the request. - Get(context.Context, *GetInstanceRequest) (*instance.Instance, error) - // List returns all Instances matching the criteria of the request. - List(context.Context, *ListInstanceRequest) (*ListInstanceResponse, error) -} - -// UnimplementedInstanceServer can be embedded to have forward compatible implementations. -type UnimplementedInstanceServer struct { -} - -func (*UnimplementedInstanceServer) Get(ctx context.Context, req *GetInstanceRequest) (*instance.Instance, error) { - return nil, status.Errorf(codes.Unimplemented, "method Get not implemented") -} -func (*UnimplementedInstanceServer) List(ctx context.Context, req *ListInstanceRequest) (*ListInstanceResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method List not implemented") -} - -func RegisterInstanceServer(s *grpc.Server, srv InstanceServer) { - s.RegisterService(&_Instance_serviceDesc, srv) -} - -func _Instance_Get_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetInstanceRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(InstanceServer).Get(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/mesg.api.Instance/Get", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(InstanceServer).Get(ctx, req.(*GetInstanceRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Instance_List_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ListInstanceRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(InstanceServer).List(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/mesg.api.Instance/List", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(InstanceServer).List(ctx, req.(*ListInstanceRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _Instance_serviceDesc = grpc.ServiceDesc{ - ServiceName: "mesg.api.Instance", - HandlerType: (*InstanceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Get", - Handler: _Instance_Get_Handler, - }, - { - MethodName: "List", - Handler: _Instance_List_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "protobuf/api/instance.proto", -} diff --git a/protobuf/api/instance.proto b/protobuf/api/instance.proto deleted file mode 100644 index 8833d30f8..000000000 --- a/protobuf/api/instance.proto +++ /dev/null @@ -1,52 +0,0 @@ -syntax = "proto3"; - -import "gogo/protobuf/gogoproto/gogo.proto"; -import "protobuf/types/instance.proto"; - -package mesg.api; -option go_package = "api"; - -// This is the API to interact with the Instances. -// -// This API is a [gRPC](https://grpc.io/) API. -// -// The source file of this API is hosted on [GitHub](https://github.com/mesg-foundation/engine/blob/master/protobuf/api/instance.proto). -service Instance { - - // Get returns an Instance matching the criteria of the request. - rpc Get (GetInstanceRequest) returns (types.Instance) {} - - // List returns all Instances matching the criteria of the request. - rpc List (ListInstanceRequest) returns (ListInstanceResponse) {} -} - -// The request's data for the `Get` API. -message GetInstanceRequest { - bytes hash = 1 [ - (gogoproto.moretags) = 'validate:"required,hash"', - (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", - (gogoproto.nullable) = false - ]; -} - -// The request's data for the `List` API. -message ListInstanceRequest { - // Filter contains filtering criteria. - message Filter { - // Service hash to filter executions. - bytes serviceHash = 1 [ - (gogoproto.moretags) = 'validate:"omitempty,hash"', - (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", - (gogoproto.nullable) = false - ]; - } - - // Filter used to filter a list of instance. - Filter filter = 1; -} - -// The response's data for the `List` API. -message ListInstanceResponse { - // List of instances that match the request's filters. - repeated types.Instance instances = 1; -} diff --git a/protobuf/api/ownership.pb.go b/protobuf/api/ownership.pb.go deleted file mode 100644 index 08faad5ee..000000000 --- a/protobuf/api/ownership.pb.go +++ /dev/null @@ -1,203 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: protobuf/api/ownership.proto - -package api - -import ( - context "context" - fmt "fmt" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" - ownership "github.com/mesg-foundation/engine/ownership" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - math "math" -) - -// 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 - -// The request's data for the `List` API. -type ListOwnershipRequest struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ListOwnershipRequest) Reset() { *m = ListOwnershipRequest{} } -func (m *ListOwnershipRequest) String() string { return proto.CompactTextString(m) } -func (*ListOwnershipRequest) ProtoMessage() {} -func (*ListOwnershipRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_e3de3887ff6b0398, []int{0} -} -func (m *ListOwnershipRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ListOwnershipRequest.Unmarshal(m, b) -} -func (m *ListOwnershipRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ListOwnershipRequest.Marshal(b, m, deterministic) -} -func (m *ListOwnershipRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_ListOwnershipRequest.Merge(m, src) -} -func (m *ListOwnershipRequest) XXX_Size() int { - return xxx_messageInfo_ListOwnershipRequest.Size(m) -} -func (m *ListOwnershipRequest) XXX_DiscardUnknown() { - xxx_messageInfo_ListOwnershipRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_ListOwnershipRequest proto.InternalMessageInfo - -// The response's data for the `List` API. -type ListOwnershipResponse struct { - // List of ownerships that match the request's filters. - Ownerships []*ownership.Ownership `protobuf:"bytes,1,rep,name=ownerships,proto3" json:"ownerships,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ListOwnershipResponse) Reset() { *m = ListOwnershipResponse{} } -func (m *ListOwnershipResponse) String() string { return proto.CompactTextString(m) } -func (*ListOwnershipResponse) ProtoMessage() {} -func (*ListOwnershipResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_e3de3887ff6b0398, []int{1} -} -func (m *ListOwnershipResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ListOwnershipResponse.Unmarshal(m, b) -} -func (m *ListOwnershipResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ListOwnershipResponse.Marshal(b, m, deterministic) -} -func (m *ListOwnershipResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_ListOwnershipResponse.Merge(m, src) -} -func (m *ListOwnershipResponse) XXX_Size() int { - return xxx_messageInfo_ListOwnershipResponse.Size(m) -} -func (m *ListOwnershipResponse) XXX_DiscardUnknown() { - xxx_messageInfo_ListOwnershipResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_ListOwnershipResponse proto.InternalMessageInfo - -func (m *ListOwnershipResponse) GetOwnerships() []*ownership.Ownership { - if m != nil { - return m.Ownerships - } - return nil -} - -func init() { - proto.RegisterType((*ListOwnershipRequest)(nil), "mesg.api.ListOwnershipRequest") - proto.RegisterType((*ListOwnershipResponse)(nil), "mesg.api.ListOwnershipResponse") -} - -func init() { proto.RegisterFile("protobuf/api/ownership.proto", fileDescriptor_e3de3887ff6b0398) } - -var fileDescriptor_e3de3887ff6b0398 = []byte{ - // 185 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x29, 0x28, 0xca, 0x2f, - 0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0x4f, 0x2c, 0xc8, 0xd4, 0xcf, 0x2f, 0xcf, 0x4b, 0x2d, 0x2a, 0xce, - 0xc8, 0x2c, 0xd0, 0x03, 0x0b, 0x0b, 0x71, 0xe4, 0xa6, 0x16, 0xa7, 0xeb, 0x25, 0x16, 0x64, 0x4a, - 0x29, 0xa5, 0xe7, 0xa7, 0xe7, 0xeb, 0xc3, 0x15, 0x83, 0x78, 0x60, 0x0e, 0x98, 0x05, 0x51, 0x2d, - 0x25, 0x07, 0x97, 0x2e, 0xa9, 0x2c, 0x48, 0x2d, 0x46, 0x37, 0x4d, 0x49, 0x8c, 0x4b, 0xc4, 0x27, - 0xb3, 0xb8, 0xc4, 0x1f, 0x26, 0x1c, 0x94, 0x5a, 0x58, 0x9a, 0x5a, 0x5c, 0xa2, 0xe4, 0xc7, 0x25, - 0x8a, 0x26, 0x5e, 0x5c, 0x90, 0x9f, 0x57, 0x9c, 0x2a, 0x64, 0xca, 0xc5, 0x05, 0x37, 0xa3, 0x58, - 0x82, 0x51, 0x81, 0x59, 0x83, 0xdb, 0x48, 0x54, 0x0f, 0xec, 0x26, 0xb0, 0x0d, 0x7a, 0x08, 0x2d, - 0x48, 0x0a, 0x8d, 0xc2, 0xb8, 0x38, 0xe1, 0x12, 0x42, 0x9e, 0x5c, 0x2c, 0x20, 0xc3, 0x85, 0xe4, - 0xf4, 0x60, 0x7e, 0xd1, 0xc3, 0xe6, 0x08, 0x29, 0x79, 0x9c, 0xf2, 0x10, 0xc7, 0x28, 0x31, 0x38, - 0xb1, 0x46, 0x31, 0x27, 0x16, 0x64, 0x26, 0xb1, 0x81, 0x7d, 0x63, 0x0c, 0x08, 0x00, 0x00, 0xff, - 0xff, 0xab, 0x90, 0xd3, 0xfb, 0x3b, 0x01, 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// OwnershipClient is the client API for Ownership service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type OwnershipClient interface { - // List returns ownerships specified in a request. - List(ctx context.Context, in *ListOwnershipRequest, opts ...grpc.CallOption) (*ListOwnershipResponse, error) -} - -type ownershipClient struct { - cc *grpc.ClientConn -} - -func NewOwnershipClient(cc *grpc.ClientConn) OwnershipClient { - return &ownershipClient{cc} -} - -func (c *ownershipClient) List(ctx context.Context, in *ListOwnershipRequest, opts ...grpc.CallOption) (*ListOwnershipResponse, error) { - out := new(ListOwnershipResponse) - err := c.cc.Invoke(ctx, "/mesg.api.Ownership/List", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// OwnershipServer is the server API for Ownership service. -type OwnershipServer interface { - // List returns ownerships specified in a request. - List(context.Context, *ListOwnershipRequest) (*ListOwnershipResponse, error) -} - -// UnimplementedOwnershipServer can be embedded to have forward compatible implementations. -type UnimplementedOwnershipServer struct { -} - -func (*UnimplementedOwnershipServer) List(ctx context.Context, req *ListOwnershipRequest) (*ListOwnershipResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method List not implemented") -} - -func RegisterOwnershipServer(s *grpc.Server, srv OwnershipServer) { - s.RegisterService(&_Ownership_serviceDesc, srv) -} - -func _Ownership_List_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ListOwnershipRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(OwnershipServer).List(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/mesg.api.Ownership/List", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(OwnershipServer).List(ctx, req.(*ListOwnershipRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _Ownership_serviceDesc = grpc.ServiceDesc{ - ServiceName: "mesg.api.Ownership", - HandlerType: (*OwnershipServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "List", - Handler: _Ownership_List_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "protobuf/api/ownership.proto", -} diff --git a/protobuf/api/ownership.proto b/protobuf/api/ownership.proto deleted file mode 100644 index a988ee7f1..000000000 --- a/protobuf/api/ownership.proto +++ /dev/null @@ -1,27 +0,0 @@ -syntax = "proto3"; - -import "gogo/protobuf/gogoproto/gogo.proto"; -import "protobuf/types/ownership.proto"; - -package mesg.api; -option go_package = "api"; - -// This is the API to interact with the Ownerships. -// -// This API is a [gRPC](https://grpc.io/) API. -// -// The source file of this API is hosted on [GitHub](https://github.com/mesg-foundation/engine/blob/master/protobuf/api/ownership.proto). -service Ownership { - - // List returns ownerships specified in a request. - rpc List(ListOwnershipRequest) returns (ListOwnershipResponse) {} -} - -// The request's data for the `List` API. -message ListOwnershipRequest {} - -// The response's data for the `List` API. -message ListOwnershipResponse { - // List of ownerships that match the request's filters. - repeated types.Ownership ownerships = 1; -} diff --git a/protobuf/api/process.pb.go b/protobuf/api/process.pb.go deleted file mode 100644 index cbe3de233..000000000 --- a/protobuf/api/process.pb.go +++ /dev/null @@ -1,532 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: protobuf/api/process.proto - -package api - -import ( - context "context" - fmt "fmt" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" - github_com_mesg_foundation_engine_hash "github.com/mesg-foundation/engine/hash" - process "github.com/mesg-foundation/engine/process" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - math "math" -) - -// 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 - -// The request's data for the `Create` API. -type CreateProcessRequest struct { - // Process's name - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty" validate:"required,printascii"` - // List of nodes of the process. - Nodes []*process.Process_Node `protobuf:"bytes,4,rep,name=nodes,proto3" json:"nodes,omitempty"` - // List of edges of the process. - Edges []*process.Process_Edge `protobuf:"bytes,5,rep,name=edges,proto3" json:"edges,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *CreateProcessRequest) Reset() { *m = CreateProcessRequest{} } -func (m *CreateProcessRequest) String() string { return proto.CompactTextString(m) } -func (*CreateProcessRequest) ProtoMessage() {} -func (*CreateProcessRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_e79ddb1ea8859998, []int{0} -} -func (m *CreateProcessRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_CreateProcessRequest.Unmarshal(m, b) -} -func (m *CreateProcessRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_CreateProcessRequest.Marshal(b, m, deterministic) -} -func (m *CreateProcessRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_CreateProcessRequest.Merge(m, src) -} -func (m *CreateProcessRequest) XXX_Size() int { - return xxx_messageInfo_CreateProcessRequest.Size(m) -} -func (m *CreateProcessRequest) XXX_DiscardUnknown() { - xxx_messageInfo_CreateProcessRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_CreateProcessRequest proto.InternalMessageInfo - -func (m *CreateProcessRequest) GetName() string { - if m != nil { - return m.Name - } - return "" -} - -func (m *CreateProcessRequest) GetNodes() []*process.Process_Node { - if m != nil { - return m.Nodes - } - return nil -} - -func (m *CreateProcessRequest) GetEdges() []*process.Process_Edge { - if m != nil { - return m.Edges - } - return nil -} - -// The response's data for the `Create` API. -type CreateProcessResponse struct { - // The process's hash created. - Hash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=hash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"hash"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *CreateProcessResponse) Reset() { *m = CreateProcessResponse{} } -func (m *CreateProcessResponse) String() string { return proto.CompactTextString(m) } -func (*CreateProcessResponse) ProtoMessage() {} -func (*CreateProcessResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_e79ddb1ea8859998, []int{1} -} -func (m *CreateProcessResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_CreateProcessResponse.Unmarshal(m, b) -} -func (m *CreateProcessResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_CreateProcessResponse.Marshal(b, m, deterministic) -} -func (m *CreateProcessResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_CreateProcessResponse.Merge(m, src) -} -func (m *CreateProcessResponse) XXX_Size() int { - return xxx_messageInfo_CreateProcessResponse.Size(m) -} -func (m *CreateProcessResponse) XXX_DiscardUnknown() { - xxx_messageInfo_CreateProcessResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_CreateProcessResponse proto.InternalMessageInfo - -// The request's data for the `Delete` API. -type DeleteProcessRequest struct { - // The process's hash to delete. - Hash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=hash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"hash" validate:"required,hash"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *DeleteProcessRequest) Reset() { *m = DeleteProcessRequest{} } -func (m *DeleteProcessRequest) String() string { return proto.CompactTextString(m) } -func (*DeleteProcessRequest) ProtoMessage() {} -func (*DeleteProcessRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_e79ddb1ea8859998, []int{2} -} -func (m *DeleteProcessRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_DeleteProcessRequest.Unmarshal(m, b) -} -func (m *DeleteProcessRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_DeleteProcessRequest.Marshal(b, m, deterministic) -} -func (m *DeleteProcessRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_DeleteProcessRequest.Merge(m, src) -} -func (m *DeleteProcessRequest) XXX_Size() int { - return xxx_messageInfo_DeleteProcessRequest.Size(m) -} -func (m *DeleteProcessRequest) XXX_DiscardUnknown() { - xxx_messageInfo_DeleteProcessRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_DeleteProcessRequest proto.InternalMessageInfo - -// The response's data for the `Delete` API, doesn't contain anything. -type DeleteProcessResponse struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *DeleteProcessResponse) Reset() { *m = DeleteProcessResponse{} } -func (m *DeleteProcessResponse) String() string { return proto.CompactTextString(m) } -func (*DeleteProcessResponse) ProtoMessage() {} -func (*DeleteProcessResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_e79ddb1ea8859998, []int{3} -} -func (m *DeleteProcessResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_DeleteProcessResponse.Unmarshal(m, b) -} -func (m *DeleteProcessResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_DeleteProcessResponse.Marshal(b, m, deterministic) -} -func (m *DeleteProcessResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_DeleteProcessResponse.Merge(m, src) -} -func (m *DeleteProcessResponse) XXX_Size() int { - return xxx_messageInfo_DeleteProcessResponse.Size(m) -} -func (m *DeleteProcessResponse) XXX_DiscardUnknown() { - xxx_messageInfo_DeleteProcessResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_DeleteProcessResponse proto.InternalMessageInfo - -// The request's data for the `Get` API. -type GetProcessRequest struct { - // The process's hash to fetch. - Hash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=hash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"hash"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *GetProcessRequest) Reset() { *m = GetProcessRequest{} } -func (m *GetProcessRequest) String() string { return proto.CompactTextString(m) } -func (*GetProcessRequest) ProtoMessage() {} -func (*GetProcessRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_e79ddb1ea8859998, []int{4} -} -func (m *GetProcessRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetProcessRequest.Unmarshal(m, b) -} -func (m *GetProcessRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetProcessRequest.Marshal(b, m, deterministic) -} -func (m *GetProcessRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetProcessRequest.Merge(m, src) -} -func (m *GetProcessRequest) XXX_Size() int { - return xxx_messageInfo_GetProcessRequest.Size(m) -} -func (m *GetProcessRequest) XXX_DiscardUnknown() { - xxx_messageInfo_GetProcessRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_GetProcessRequest proto.InternalMessageInfo - -// The request's data for the `List` API. -type ListProcessRequest struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ListProcessRequest) Reset() { *m = ListProcessRequest{} } -func (m *ListProcessRequest) String() string { return proto.CompactTextString(m) } -func (*ListProcessRequest) ProtoMessage() {} -func (*ListProcessRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_e79ddb1ea8859998, []int{5} -} -func (m *ListProcessRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ListProcessRequest.Unmarshal(m, b) -} -func (m *ListProcessRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ListProcessRequest.Marshal(b, m, deterministic) -} -func (m *ListProcessRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_ListProcessRequest.Merge(m, src) -} -func (m *ListProcessRequest) XXX_Size() int { - return xxx_messageInfo_ListProcessRequest.Size(m) -} -func (m *ListProcessRequest) XXX_DiscardUnknown() { - xxx_messageInfo_ListProcessRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_ListProcessRequest proto.InternalMessageInfo - -// The response's data for the `List` API. -type ListProcessResponse struct { - // List of processes that match the request's filters. - Processes []*process.Process `protobuf:"bytes,1,rep,name=processes,proto3" json:"processes,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ListProcessResponse) Reset() { *m = ListProcessResponse{} } -func (m *ListProcessResponse) String() string { return proto.CompactTextString(m) } -func (*ListProcessResponse) ProtoMessage() {} -func (*ListProcessResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_e79ddb1ea8859998, []int{6} -} -func (m *ListProcessResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ListProcessResponse.Unmarshal(m, b) -} -func (m *ListProcessResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ListProcessResponse.Marshal(b, m, deterministic) -} -func (m *ListProcessResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_ListProcessResponse.Merge(m, src) -} -func (m *ListProcessResponse) XXX_Size() int { - return xxx_messageInfo_ListProcessResponse.Size(m) -} -func (m *ListProcessResponse) XXX_DiscardUnknown() { - xxx_messageInfo_ListProcessResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_ListProcessResponse proto.InternalMessageInfo - -func (m *ListProcessResponse) GetProcesses() []*process.Process { - if m != nil { - return m.Processes - } - return nil -} - -func init() { - proto.RegisterType((*CreateProcessRequest)(nil), "mesg.api.CreateProcessRequest") - proto.RegisterType((*CreateProcessResponse)(nil), "mesg.api.CreateProcessResponse") - proto.RegisterType((*DeleteProcessRequest)(nil), "mesg.api.DeleteProcessRequest") - proto.RegisterType((*DeleteProcessResponse)(nil), "mesg.api.DeleteProcessResponse") - proto.RegisterType((*GetProcessRequest)(nil), "mesg.api.GetProcessRequest") - proto.RegisterType((*ListProcessRequest)(nil), "mesg.api.ListProcessRequest") - proto.RegisterType((*ListProcessResponse)(nil), "mesg.api.ListProcessResponse") -} - -func init() { proto.RegisterFile("protobuf/api/process.proto", fileDescriptor_e79ddb1ea8859998) } - -var fileDescriptor_e79ddb1ea8859998 = []byte{ - // 450 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x53, 0xc1, 0x6e, 0xd3, 0x40, - 0x10, 0x8d, 0x9b, 0xa4, 0xd0, 0x81, 0x0b, 0xdb, 0x54, 0x58, 0xa6, 0xd4, 0xd1, 0x9e, 0x22, 0x01, - 0x6b, 0xd1, 0x4a, 0x48, 0x70, 0x0c, 0x54, 0xa9, 0x04, 0x02, 0xe4, 0x23, 0xe2, 0xc0, 0x26, 0x9e, - 0xda, 0x2b, 0x35, 0xbb, 0x5b, 0xef, 0x1a, 0x09, 0xf1, 0x3d, 0x5c, 0xf9, 0x0e, 0xbe, 0x81, 0x83, - 0x3f, 0xa2, 0x5f, 0x80, 0xbc, 0x76, 0x9b, 0xc6, 0x71, 0x2e, 0xa8, 0x37, 0xef, 0xcc, 0x9b, 0xf7, - 0x66, 0xde, 0x8c, 0x21, 0xd0, 0xb9, 0xb2, 0x6a, 0x5e, 0x9c, 0x47, 0x5c, 0x8b, 0x48, 0xe7, 0x6a, - 0x81, 0xc6, 0x30, 0x17, 0x24, 0xf7, 0x97, 0x68, 0x52, 0xc6, 0xb5, 0x08, 0x68, 0xaa, 0x52, 0x15, - 0xdd, 0x40, 0xab, 0x97, 0x7b, 0xb8, 0xaf, 0x1a, 0x1d, 0x1c, 0xde, 0xa4, 0xed, 0x0f, 0x8d, 0x66, - 0x9d, 0x8b, 0xfe, 0xf6, 0x60, 0xf4, 0x36, 0x47, 0x6e, 0xf1, 0x73, 0x1d, 0x8f, 0xf1, 0xb2, 0x40, - 0x63, 0xc9, 0x2b, 0x18, 0x48, 0xbe, 0x44, 0x7f, 0x67, 0xec, 0x4d, 0xf6, 0xa6, 0xf4, 0xaa, 0x0c, - 0x8f, 0xbe, 0xf3, 0x0b, 0x91, 0x70, 0x8b, 0x6f, 0x68, 0x8e, 0x97, 0x85, 0xc8, 0x31, 0x79, 0xae, - 0x73, 0x21, 0x2d, 0x37, 0x0b, 0x21, 0x68, 0xec, 0xf0, 0x84, 0xc1, 0x50, 0xaa, 0x04, 0x8d, 0x3f, - 0x18, 0xf7, 0x27, 0x0f, 0x8e, 0x7d, 0xe6, 0x9a, 0x75, 0xd2, 0xac, 0x91, 0x60, 0x1f, 0x55, 0x82, - 0x71, 0x0d, 0xab, 0xf0, 0x98, 0xa4, 0x68, 0xfc, 0xe1, 0x76, 0xfc, 0x69, 0x92, 0x62, 0x5c, 0xc3, - 0xe8, 0x37, 0x38, 0x68, 0xf5, 0x6b, 0xb4, 0x92, 0x06, 0xc9, 0x0c, 0x06, 0x19, 0x37, 0x99, 0xef, - 0x8d, 0xbd, 0xc9, 0xc3, 0xe9, 0xc9, 0x9f, 0x32, 0xec, 0xfd, 0x2d, 0xc3, 0x67, 0xa9, 0xb0, 0x59, - 0x31, 0x67, 0x0b, 0xb5, 0x8c, 0x2a, 0xe6, 0x17, 0xe7, 0xaa, 0x90, 0x09, 0xb7, 0x42, 0xc9, 0x08, - 0x65, 0x2a, 0x24, 0x46, 0x55, 0x15, 0x3b, 0xe3, 0x26, 0x8b, 0x1d, 0x01, 0xfd, 0x09, 0xa3, 0x77, - 0x78, 0x81, 0x1b, 0x8e, 0x2c, 0xd6, 0x04, 0x3e, 0xfd, 0x87, 0xc0, 0x55, 0x19, 0xfa, 0x1d, 0x26, - 0x3a, 0xd5, 0x46, 0xfc, 0x31, 0x1c, 0xb4, 0xc4, 0xeb, 0xf1, 0xe8, 0x57, 0x78, 0x34, 0x43, 0xdb, - 0x6a, 0xe9, 0xce, 0x66, 0x1e, 0x01, 0xf9, 0x20, 0x4c, 0x8b, 0x9e, 0x9e, 0xc1, 0xfe, 0x5a, 0xb4, - 0x71, 0xfa, 0x25, 0xec, 0x35, 0x47, 0x84, 0xc6, 0xf7, 0xdc, 0xda, 0xf6, 0x3b, 0xd6, 0x16, 0xaf, - 0x50, 0xc7, 0xbf, 0x76, 0xe0, 0x5e, 0x13, 0x26, 0xef, 0x61, 0xb7, 0xde, 0x20, 0x39, 0x62, 0xd7, - 0x97, 0xcc, 0xba, 0x6e, 0x30, 0x08, 0xb7, 0xe6, 0x1b, 0x53, 0x7a, 0x15, 0x59, 0xed, 0xd7, 0x6d, - 0xb2, 0xae, 0xf5, 0xdd, 0x26, 0xeb, 0x76, 0xb8, 0x47, 0x5e, 0x43, 0x7f, 0x86, 0x96, 0x3c, 0x59, - 0x21, 0x37, 0x2c, 0x0f, 0xba, 0x26, 0xa5, 0x3d, 0x72, 0x0a, 0x83, 0xca, 0x2a, 0x72, 0xb8, 0xaa, - 0xdd, 0x34, 0x34, 0x78, 0xba, 0x25, 0x7b, 0xdd, 0xc1, 0x74, 0xf8, 0xa5, 0xcf, 0xb5, 0x98, 0xef, - 0xba, 0x9f, 0xf3, 0xe4, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xe1, 0x01, 0x6e, 0x95, 0x06, 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 - -// ProcessClient is the client API for Process service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type ProcessClient interface { - // Create a Process from a Process Definition. - // It will return an unique identifier which is used to interact with the Process. - Create(ctx context.Context, in *CreateProcessRequest, opts ...grpc.CallOption) (*CreateProcessResponse, error) - // Delete a process. - // An error is returned if one or more Instances of the process are running. - Delete(ctx context.Context, in *DeleteProcessRequest, opts ...grpc.CallOption) (*DeleteProcessResponse, error) - // Get returns a process matching the criteria of the request. - Get(ctx context.Context, in *GetProcessRequest, opts ...grpc.CallOption) (*process.Process, error) - // List returns processes specified in a request. - List(ctx context.Context, in *ListProcessRequest, opts ...grpc.CallOption) (*ListProcessResponse, error) -} - -type processClient struct { - cc *grpc.ClientConn -} - -func NewProcessClient(cc *grpc.ClientConn) ProcessClient { - return &processClient{cc} -} - -func (c *processClient) Create(ctx context.Context, in *CreateProcessRequest, opts ...grpc.CallOption) (*CreateProcessResponse, error) { - out := new(CreateProcessResponse) - err := c.cc.Invoke(ctx, "/mesg.api.Process/Create", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *processClient) Delete(ctx context.Context, in *DeleteProcessRequest, opts ...grpc.CallOption) (*DeleteProcessResponse, error) { - out := new(DeleteProcessResponse) - err := c.cc.Invoke(ctx, "/mesg.api.Process/Delete", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *processClient) Get(ctx context.Context, in *GetProcessRequest, opts ...grpc.CallOption) (*process.Process, error) { - out := new(process.Process) - err := c.cc.Invoke(ctx, "/mesg.api.Process/Get", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *processClient) List(ctx context.Context, in *ListProcessRequest, opts ...grpc.CallOption) (*ListProcessResponse, error) { - out := new(ListProcessResponse) - err := c.cc.Invoke(ctx, "/mesg.api.Process/List", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// ProcessServer is the server API for Process service. -type ProcessServer interface { - // Create a Process from a Process Definition. - // It will return an unique identifier which is used to interact with the Process. - Create(context.Context, *CreateProcessRequest) (*CreateProcessResponse, error) - // Delete a process. - // An error is returned if one or more Instances of the process are running. - Delete(context.Context, *DeleteProcessRequest) (*DeleteProcessResponse, error) - // Get returns a process matching the criteria of the request. - Get(context.Context, *GetProcessRequest) (*process.Process, error) - // List returns processes specified in a request. - List(context.Context, *ListProcessRequest) (*ListProcessResponse, error) -} - -// UnimplementedProcessServer can be embedded to have forward compatible implementations. -type UnimplementedProcessServer struct { -} - -func (*UnimplementedProcessServer) Create(ctx context.Context, req *CreateProcessRequest) (*CreateProcessResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Create not implemented") -} -func (*UnimplementedProcessServer) Delete(ctx context.Context, req *DeleteProcessRequest) (*DeleteProcessResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Delete not implemented") -} -func (*UnimplementedProcessServer) Get(ctx context.Context, req *GetProcessRequest) (*process.Process, error) { - return nil, status.Errorf(codes.Unimplemented, "method Get not implemented") -} -func (*UnimplementedProcessServer) List(ctx context.Context, req *ListProcessRequest) (*ListProcessResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method List not implemented") -} - -func RegisterProcessServer(s *grpc.Server, srv ProcessServer) { - s.RegisterService(&_Process_serviceDesc, srv) -} - -func _Process_Create_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(CreateProcessRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ProcessServer).Create(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/mesg.api.Process/Create", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ProcessServer).Create(ctx, req.(*CreateProcessRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Process_Delete_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(DeleteProcessRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ProcessServer).Delete(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/mesg.api.Process/Delete", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ProcessServer).Delete(ctx, req.(*DeleteProcessRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Process_Get_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetProcessRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ProcessServer).Get(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/mesg.api.Process/Get", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ProcessServer).Get(ctx, req.(*GetProcessRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Process_List_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ListProcessRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ProcessServer).List(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/mesg.api.Process/List", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ProcessServer).List(ctx, req.(*ListProcessRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _Process_serviceDesc = grpc.ServiceDesc{ - ServiceName: "mesg.api.Process", - HandlerType: (*ProcessServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Create", - Handler: _Process_Create_Handler, - }, - { - MethodName: "Delete", - Handler: _Process_Delete_Handler, - }, - { - MethodName: "Get", - Handler: _Process_Get_Handler, - }, - { - MethodName: "List", - Handler: _Process_List_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "protobuf/api/process.proto", -} diff --git a/protobuf/api/process.proto b/protobuf/api/process.proto deleted file mode 100644 index da017cdef..000000000 --- a/protobuf/api/process.proto +++ /dev/null @@ -1,84 +0,0 @@ -syntax = "proto3"; - -import "gogo/protobuf/gogoproto/gogo.proto"; -import "protobuf/types/process.proto"; - -package mesg.api; -option go_package = "api"; - -// This is the API to interact with the Processes. -// -// This API is a [gRPC](https://grpc.io/) API. -// -// The source file of this API is hosted on [GitHub](https://github.com/mesg-foundation/engine/blob/master/protobuf/api/process.proto). -service Process { - - // Create a Process from a Process Definition. - // It will return an unique identifier which is used to interact with the Process. - rpc Create (CreateProcessRequest) returns (CreateProcessResponse) {} - - // Delete a process. - // An error is returned if one or more Instances of the process are running. - rpc Delete (DeleteProcessRequest) returns (DeleteProcessResponse) {} - - // Get returns a process matching the criteria of the request. - rpc Get(GetProcessRequest) returns (types.Process) {} - - // List returns processes specified in a request. - rpc List(ListProcessRequest) returns (ListProcessResponse) {} -} - -// The request's data for the `Create` API. -message CreateProcessRequest { - // Process's name - string name = 2 [ - (gogoproto.moretags) = 'validate:"required,printascii"' - ]; - - // List of nodes of the process. - repeated types.Process.Node nodes = 4; - - // List of edges of the process. - repeated types.Process.Edge edges = 5; -} - -// The response's data for the `Create` API. -message CreateProcessResponse { - // The process's hash created. - bytes hash = 1 [ - (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", - (gogoproto.nullable) = false - ]; -} - -// The request's data for the `Delete` API. -message DeleteProcessRequest { - // The process's hash to delete. - bytes hash = 1 [ - (gogoproto.moretags) = 'validate:"required,hash"', - (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", - (gogoproto.nullable) = false - ]; -} - -// The response's data for the `Delete` API, doesn't contain anything. -message DeleteProcessResponse { -} - -// The request's data for the `Get` API. -message GetProcessRequest { - // The process's hash to fetch. - bytes hash = 1 [ - (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", - (gogoproto.nullable) = false - ]; -} - -// The request's data for the `List` API. -message ListProcessRequest {} - -// The response's data for the `List` API. -message ListProcessResponse { - // List of processes that match the request's filters. - repeated types.Process processes = 1; -} diff --git a/protobuf/api/runner.pb.go b/protobuf/api/runner.pb.go deleted file mode 100644 index 0bc604cd3..000000000 --- a/protobuf/api/runner.pb.go +++ /dev/null @@ -1,578 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: protobuf/api/runner.proto - -package api - -import ( - context "context" - fmt "fmt" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" - github_com_mesg_foundation_engine_hash "github.com/mesg-foundation/engine/hash" - runner "github.com/mesg-foundation/engine/runner" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - math "math" -) - -// 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 - -// The request's data for the `Get` API. -type GetRunnerRequest struct { - Hash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=hash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"hash" validate:"required,hash"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *GetRunnerRequest) Reset() { *m = GetRunnerRequest{} } -func (m *GetRunnerRequest) String() string { return proto.CompactTextString(m) } -func (*GetRunnerRequest) ProtoMessage() {} -func (*GetRunnerRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_66b76d1ada2874b2, []int{0} -} -func (m *GetRunnerRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetRunnerRequest.Unmarshal(m, b) -} -func (m *GetRunnerRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetRunnerRequest.Marshal(b, m, deterministic) -} -func (m *GetRunnerRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetRunnerRequest.Merge(m, src) -} -func (m *GetRunnerRequest) XXX_Size() int { - return xxx_messageInfo_GetRunnerRequest.Size(m) -} -func (m *GetRunnerRequest) XXX_DiscardUnknown() { - xxx_messageInfo_GetRunnerRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_GetRunnerRequest proto.InternalMessageInfo - -// The request's data for the `List` API. -type ListRunnerRequest struct { - // Filter used to filter runners. - Filter *ListRunnerRequest_Filter `protobuf:"bytes,1,opt,name=filter,proto3" json:"filter,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ListRunnerRequest) Reset() { *m = ListRunnerRequest{} } -func (m *ListRunnerRequest) String() string { return proto.CompactTextString(m) } -func (*ListRunnerRequest) ProtoMessage() {} -func (*ListRunnerRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_66b76d1ada2874b2, []int{1} -} -func (m *ListRunnerRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ListRunnerRequest.Unmarshal(m, b) -} -func (m *ListRunnerRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ListRunnerRequest.Marshal(b, m, deterministic) -} -func (m *ListRunnerRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_ListRunnerRequest.Merge(m, src) -} -func (m *ListRunnerRequest) XXX_Size() int { - return xxx_messageInfo_ListRunnerRequest.Size(m) -} -func (m *ListRunnerRequest) XXX_DiscardUnknown() { - xxx_messageInfo_ListRunnerRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_ListRunnerRequest proto.InternalMessageInfo - -func (m *ListRunnerRequest) GetFilter() *ListRunnerRequest_Filter { - if m != nil { - return m.Filter - } - return nil -} - -// Filter contains filtering criteria. -type ListRunnerRequest_Filter struct { - // Filter by instance hash. - InstanceHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=instanceHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"instanceHash" validate:"hash"` - // Filter by owner - Owner string `protobuf:"bytes,2,opt,name=owner,proto3" json:"owner,omitempty" validate:"accaddress"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ListRunnerRequest_Filter) Reset() { *m = ListRunnerRequest_Filter{} } -func (m *ListRunnerRequest_Filter) String() string { return proto.CompactTextString(m) } -func (*ListRunnerRequest_Filter) ProtoMessage() {} -func (*ListRunnerRequest_Filter) Descriptor() ([]byte, []int) { - return fileDescriptor_66b76d1ada2874b2, []int{1, 0} -} -func (m *ListRunnerRequest_Filter) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ListRunnerRequest_Filter.Unmarshal(m, b) -} -func (m *ListRunnerRequest_Filter) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ListRunnerRequest_Filter.Marshal(b, m, deterministic) -} -func (m *ListRunnerRequest_Filter) XXX_Merge(src proto.Message) { - xxx_messageInfo_ListRunnerRequest_Filter.Merge(m, src) -} -func (m *ListRunnerRequest_Filter) XXX_Size() int { - return xxx_messageInfo_ListRunnerRequest_Filter.Size(m) -} -func (m *ListRunnerRequest_Filter) XXX_DiscardUnknown() { - xxx_messageInfo_ListRunnerRequest_Filter.DiscardUnknown(m) -} - -var xxx_messageInfo_ListRunnerRequest_Filter proto.InternalMessageInfo - -func (m *ListRunnerRequest_Filter) GetOwner() string { - if m != nil { - return m.Owner - } - return "" -} - -// The response's data for the `List` API. -type ListRunnerResponse struct { - // List of runners that match the request's filters. - Runners []*runner.Runner `protobuf:"bytes,1,rep,name=runners,proto3" json:"runners,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ListRunnerResponse) Reset() { *m = ListRunnerResponse{} } -func (m *ListRunnerResponse) String() string { return proto.CompactTextString(m) } -func (*ListRunnerResponse) ProtoMessage() {} -func (*ListRunnerResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_66b76d1ada2874b2, []int{2} -} -func (m *ListRunnerResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ListRunnerResponse.Unmarshal(m, b) -} -func (m *ListRunnerResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ListRunnerResponse.Marshal(b, m, deterministic) -} -func (m *ListRunnerResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_ListRunnerResponse.Merge(m, src) -} -func (m *ListRunnerResponse) XXX_Size() int { - return xxx_messageInfo_ListRunnerResponse.Size(m) -} -func (m *ListRunnerResponse) XXX_DiscardUnknown() { - xxx_messageInfo_ListRunnerResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_ListRunnerResponse proto.InternalMessageInfo - -func (m *ListRunnerResponse) GetRunners() []*runner.Runner { - if m != nil { - return m.Runners - } - return nil -} - -// The request's data for the `Create` API. -type CreateRunnerRequest struct { - // Service's hash to start the runner with. - ServiceHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=serviceHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"serviceHash" validate:"hash"` - // Environmental variables to start the runner with. - Env []string `protobuf:"bytes,2,rep,name=env,proto3" json:"env,omitempty" validate:"unique,dive,env"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *CreateRunnerRequest) Reset() { *m = CreateRunnerRequest{} } -func (m *CreateRunnerRequest) String() string { return proto.CompactTextString(m) } -func (*CreateRunnerRequest) ProtoMessage() {} -func (*CreateRunnerRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_66b76d1ada2874b2, []int{3} -} -func (m *CreateRunnerRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_CreateRunnerRequest.Unmarshal(m, b) -} -func (m *CreateRunnerRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_CreateRunnerRequest.Marshal(b, m, deterministic) -} -func (m *CreateRunnerRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_CreateRunnerRequest.Merge(m, src) -} -func (m *CreateRunnerRequest) XXX_Size() int { - return xxx_messageInfo_CreateRunnerRequest.Size(m) -} -func (m *CreateRunnerRequest) XXX_DiscardUnknown() { - xxx_messageInfo_CreateRunnerRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_CreateRunnerRequest proto.InternalMessageInfo - -func (m *CreateRunnerRequest) GetEnv() []string { - if m != nil { - return m.Env - } - return nil -} - -// The response's data for the `Create` API. -type CreateRunnerResponse struct { - // The runner's hash created. - Hash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=hash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"hash"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *CreateRunnerResponse) Reset() { *m = CreateRunnerResponse{} } -func (m *CreateRunnerResponse) String() string { return proto.CompactTextString(m) } -func (*CreateRunnerResponse) ProtoMessage() {} -func (*CreateRunnerResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_66b76d1ada2874b2, []int{4} -} -func (m *CreateRunnerResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_CreateRunnerResponse.Unmarshal(m, b) -} -func (m *CreateRunnerResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_CreateRunnerResponse.Marshal(b, m, deterministic) -} -func (m *CreateRunnerResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_CreateRunnerResponse.Merge(m, src) -} -func (m *CreateRunnerResponse) XXX_Size() int { - return xxx_messageInfo_CreateRunnerResponse.Size(m) -} -func (m *CreateRunnerResponse) XXX_DiscardUnknown() { - xxx_messageInfo_CreateRunnerResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_CreateRunnerResponse proto.InternalMessageInfo - -// The request's data for the `Delete` API. -type DeleteRunnerRequest struct { - // Runner's hash - Hash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=hash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"hash" validate:"required,hash"` - // If true, any persistent data (volumes) that belongs to the runner's container and its dependencies will also be deleted. - DeleteData bool `protobuf:"varint,2,opt,name=deleteData,proto3" json:"deleteData,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *DeleteRunnerRequest) Reset() { *m = DeleteRunnerRequest{} } -func (m *DeleteRunnerRequest) String() string { return proto.CompactTextString(m) } -func (*DeleteRunnerRequest) ProtoMessage() {} -func (*DeleteRunnerRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_66b76d1ada2874b2, []int{5} -} -func (m *DeleteRunnerRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_DeleteRunnerRequest.Unmarshal(m, b) -} -func (m *DeleteRunnerRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_DeleteRunnerRequest.Marshal(b, m, deterministic) -} -func (m *DeleteRunnerRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_DeleteRunnerRequest.Merge(m, src) -} -func (m *DeleteRunnerRequest) XXX_Size() int { - return xxx_messageInfo_DeleteRunnerRequest.Size(m) -} -func (m *DeleteRunnerRequest) XXX_DiscardUnknown() { - xxx_messageInfo_DeleteRunnerRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_DeleteRunnerRequest proto.InternalMessageInfo - -func (m *DeleteRunnerRequest) GetDeleteData() bool { - if m != nil { - return m.DeleteData - } - return false -} - -// The response's data for the `Delete` API. -type DeleteRunnerResponse struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *DeleteRunnerResponse) Reset() { *m = DeleteRunnerResponse{} } -func (m *DeleteRunnerResponse) String() string { return proto.CompactTextString(m) } -func (*DeleteRunnerResponse) ProtoMessage() {} -func (*DeleteRunnerResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_66b76d1ada2874b2, []int{6} -} -func (m *DeleteRunnerResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_DeleteRunnerResponse.Unmarshal(m, b) -} -func (m *DeleteRunnerResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_DeleteRunnerResponse.Marshal(b, m, deterministic) -} -func (m *DeleteRunnerResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_DeleteRunnerResponse.Merge(m, src) -} -func (m *DeleteRunnerResponse) XXX_Size() int { - return xxx_messageInfo_DeleteRunnerResponse.Size(m) -} -func (m *DeleteRunnerResponse) XXX_DiscardUnknown() { - xxx_messageInfo_DeleteRunnerResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_DeleteRunnerResponse proto.InternalMessageInfo - -func init() { - proto.RegisterType((*GetRunnerRequest)(nil), "mesg.api.GetRunnerRequest") - proto.RegisterType((*ListRunnerRequest)(nil), "mesg.api.ListRunnerRequest") - proto.RegisterType((*ListRunnerRequest_Filter)(nil), "mesg.api.ListRunnerRequest.Filter") - proto.RegisterType((*ListRunnerResponse)(nil), "mesg.api.ListRunnerResponse") - proto.RegisterType((*CreateRunnerRequest)(nil), "mesg.api.CreateRunnerRequest") - proto.RegisterType((*CreateRunnerResponse)(nil), "mesg.api.CreateRunnerResponse") - proto.RegisterType((*DeleteRunnerRequest)(nil), "mesg.api.DeleteRunnerRequest") - proto.RegisterType((*DeleteRunnerResponse)(nil), "mesg.api.DeleteRunnerResponse") -} - -func init() { proto.RegisterFile("protobuf/api/runner.proto", fileDescriptor_66b76d1ada2874b2) } - -var fileDescriptor_66b76d1ada2874b2 = []byte{ - // 526 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x54, 0xc1, 0x6e, 0xd3, 0x40, - 0x10, 0x8d, 0x93, 0x36, 0xb4, 0x93, 0x4a, 0xc0, 0xb6, 0xa0, 0xd4, 0x85, 0x24, 0xda, 0x53, 0x24, - 0x82, 0x8d, 0xd2, 0x03, 0x52, 0x8f, 0x69, 0xd5, 0x14, 0x09, 0x09, 0xc9, 0x47, 0x2e, 0x68, 0x13, - 0x4f, 0x92, 0x45, 0xe9, 0xda, 0xd9, 0x5d, 0xa7, 0xe2, 0x57, 0x10, 0x57, 0x3e, 0x80, 0xbf, 0xe0, - 0x1b, 0x38, 0xe4, 0x23, 0x72, 0xe1, 0x8a, 0xbc, 0x9b, 0xd6, 0x76, 0x30, 0x1c, 0x2a, 0xc1, 0xcd, - 0x3b, 0xf3, 0xf6, 0xcd, 0xbc, 0x99, 0xb7, 0x86, 0xe3, 0x58, 0x46, 0x3a, 0x1a, 0x25, 0x13, 0x9f, - 0xc5, 0xdc, 0x97, 0x89, 0x10, 0x28, 0x3d, 0x13, 0x23, 0x7b, 0xd7, 0xa8, 0xa6, 0x1e, 0x8b, 0xb9, - 0x4b, 0xa7, 0xd1, 0x34, 0xf2, 0xef, 0x90, 0xe9, 0xc9, 0x1c, 0xcc, 0x97, 0x45, 0xbb, 0x27, 0x77, - 0x69, 0xfd, 0x29, 0x46, 0x55, 0xa0, 0xa2, 0x37, 0xf0, 0x68, 0x88, 0x3a, 0x30, 0xa1, 0x00, 0x17, - 0x09, 0x2a, 0x4d, 0xc6, 0xb0, 0x33, 0x63, 0x6a, 0xd6, 0x74, 0x3a, 0x4e, 0xf7, 0x60, 0xf0, 0xee, - 0xfb, 0xaa, 0x5d, 0xf9, 0xb1, 0x6a, 0xbf, 0x98, 0x72, 0x3d, 0x4b, 0x46, 0xde, 0x38, 0xba, 0xf6, - 0xd3, 0xfa, 0x2f, 0x27, 0x51, 0x22, 0x42, 0xa6, 0x79, 0x24, 0x7c, 0x14, 0x53, 0x2e, 0xd0, 0x4f, - 0x6f, 0x79, 0x57, 0x4c, 0xcd, 0xd6, 0xab, 0x76, 0x73, 0xc9, 0xe6, 0x3c, 0x64, 0x1a, 0xcf, 0xa8, - 0xc4, 0x45, 0xc2, 0x25, 0x86, 0xbd, 0x34, 0x4f, 0x03, 0x43, 0x4e, 0x7f, 0x3a, 0xf0, 0xf8, 0x2d, - 0x57, 0x5b, 0xa5, 0xcf, 0xa0, 0x3e, 0xe1, 0x73, 0x8d, 0xd2, 0x14, 0x6f, 0xf4, 0xa9, 0x77, 0x2b, - 0xd5, 0xfb, 0x0d, 0xec, 0x5d, 0x1a, 0x64, 0xb0, 0xb9, 0xe1, 0x7e, 0x75, 0xa0, 0x6e, 0x43, 0xe4, - 0x23, 0x1c, 0x70, 0xa1, 0x34, 0x13, 0x63, 0xbc, 0xca, 0x94, 0x5c, 0xde, 0x4f, 0xc9, 0xc3, 0x4c, - 0x89, 0x15, 0x50, 0xe0, 0x26, 0x3e, 0xec, 0x46, 0x37, 0x02, 0x65, 0xb3, 0xda, 0x71, 0xba, 0xfb, - 0x83, 0xe3, 0xf5, 0xaa, 0xfd, 0x24, 0xbb, 0xc1, 0xc6, 0x63, 0x16, 0x86, 0x12, 0x95, 0xa2, 0x81, - 0xc5, 0xd1, 0x01, 0x90, 0xbc, 0x16, 0x15, 0x47, 0x42, 0x21, 0xe9, 0xc1, 0x03, 0xbb, 0x18, 0xd5, - 0x74, 0x3a, 0xb5, 0x6e, 0xa3, 0x4f, 0xac, 0x74, 0xb3, 0x33, 0x6f, 0x03, 0xbe, 0x85, 0xd0, 0x6f, - 0x0e, 0x1c, 0x9e, 0x4b, 0x64, 0x1a, 0x8b, 0xf3, 0x9b, 0x41, 0x43, 0xa1, 0x5c, 0xf2, 0x7f, 0xa2, - 0x3b, 0x4f, 0x4d, 0x5e, 0x41, 0x0d, 0xc5, 0xb2, 0x59, 0xed, 0xd4, 0xba, 0xfb, 0x83, 0xd6, 0x7a, - 0xd5, 0x76, 0x33, 0x78, 0x22, 0xf8, 0x22, 0xc1, 0x5e, 0xc8, 0x97, 0xd8, 0x43, 0xb1, 0xa4, 0x41, - 0x0a, 0xa5, 0x1f, 0xe0, 0xa8, 0xd8, 0xf2, 0x46, 0xf9, 0xb0, 0x60, 0xb7, 0xd3, 0x7b, 0x34, 0xbb, - 0xb1, 0xd4, 0x67, 0x07, 0x0e, 0x2f, 0x70, 0x8e, 0xdb, 0x43, 0xf9, 0x1f, 0x7e, 0x26, 0x2d, 0x80, - 0xd0, 0xd4, 0xbe, 0x60, 0x9a, 0x19, 0x2f, 0xec, 0x05, 0xb9, 0x08, 0x7d, 0x0a, 0x47, 0xc5, 0xde, - 0xac, 0xfa, 0xfe, 0x97, 0x2a, 0xd4, 0x6d, 0x88, 0xbc, 0x86, 0xda, 0x10, 0x35, 0x71, 0x33, 0xcf, - 0x6f, 0x3f, 0x4d, 0xb7, 0xc4, 0x14, 0xb4, 0x42, 0xce, 0x61, 0x27, 0x75, 0x14, 0x39, 0xf9, 0xcb, - 0x6b, 0x71, 0x9f, 0x95, 0x27, 0x6d, 0x1b, 0xb4, 0x42, 0xde, 0x40, 0xdd, 0xae, 0x87, 0x3c, 0xcf, - 0x90, 0x25, 0x1e, 0x73, 0x5b, 0x7f, 0x4a, 0xe7, 0xa9, 0xac, 0xd6, 0x3c, 0x55, 0xc9, 0x66, 0xf2, - 0x54, 0x65, 0xc3, 0xa1, 0x95, 0xc1, 0xee, 0xfb, 0x1a, 0x8b, 0xf9, 0xa8, 0x6e, 0xfe, 0x56, 0xa7, - 0xbf, 0x02, 0x00, 0x00, 0xff, 0xff, 0x50, 0x80, 0x3a, 0x6f, 0x15, 0x05, 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 - -// RunnerClient is the client API for Runner service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type RunnerClient interface { - // Get returns an Runner matching the criteria of the request. - Get(ctx context.Context, in *GetRunnerRequest, opts ...grpc.CallOption) (*runner.Runner, error) - // List returns all Runners matching the criteria of the request. - List(ctx context.Context, in *ListRunnerRequest, opts ...grpc.CallOption) (*ListRunnerResponse, error) - // Create an Runner from a Service's hash and custom environmental variables. - // It will return an unique identifier to identify the runner. - Create(ctx context.Context, in *CreateRunnerRequest, opts ...grpc.CallOption) (*CreateRunnerResponse, error) - // Delete an Runner. - Delete(ctx context.Context, in *DeleteRunnerRequest, opts ...grpc.CallOption) (*DeleteRunnerResponse, error) -} - -type runnerClient struct { - cc *grpc.ClientConn -} - -func NewRunnerClient(cc *grpc.ClientConn) RunnerClient { - return &runnerClient{cc} -} - -func (c *runnerClient) Get(ctx context.Context, in *GetRunnerRequest, opts ...grpc.CallOption) (*runner.Runner, error) { - out := new(runner.Runner) - err := c.cc.Invoke(ctx, "/mesg.api.Runner/Get", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *runnerClient) List(ctx context.Context, in *ListRunnerRequest, opts ...grpc.CallOption) (*ListRunnerResponse, error) { - out := new(ListRunnerResponse) - err := c.cc.Invoke(ctx, "/mesg.api.Runner/List", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *runnerClient) Create(ctx context.Context, in *CreateRunnerRequest, opts ...grpc.CallOption) (*CreateRunnerResponse, error) { - out := new(CreateRunnerResponse) - err := c.cc.Invoke(ctx, "/mesg.api.Runner/Create", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *runnerClient) Delete(ctx context.Context, in *DeleteRunnerRequest, opts ...grpc.CallOption) (*DeleteRunnerResponse, error) { - out := new(DeleteRunnerResponse) - err := c.cc.Invoke(ctx, "/mesg.api.Runner/Delete", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// RunnerServer is the server API for Runner service. -type RunnerServer interface { - // Get returns an Runner matching the criteria of the request. - Get(context.Context, *GetRunnerRequest) (*runner.Runner, error) - // List returns all Runners matching the criteria of the request. - List(context.Context, *ListRunnerRequest) (*ListRunnerResponse, error) - // Create an Runner from a Service's hash and custom environmental variables. - // It will return an unique identifier to identify the runner. - Create(context.Context, *CreateRunnerRequest) (*CreateRunnerResponse, error) - // Delete an Runner. - Delete(context.Context, *DeleteRunnerRequest) (*DeleteRunnerResponse, error) -} - -// UnimplementedRunnerServer can be embedded to have forward compatible implementations. -type UnimplementedRunnerServer struct { -} - -func (*UnimplementedRunnerServer) Get(ctx context.Context, req *GetRunnerRequest) (*runner.Runner, error) { - return nil, status.Errorf(codes.Unimplemented, "method Get not implemented") -} -func (*UnimplementedRunnerServer) List(ctx context.Context, req *ListRunnerRequest) (*ListRunnerResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method List not implemented") -} -func (*UnimplementedRunnerServer) Create(ctx context.Context, req *CreateRunnerRequest) (*CreateRunnerResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Create not implemented") -} -func (*UnimplementedRunnerServer) Delete(ctx context.Context, req *DeleteRunnerRequest) (*DeleteRunnerResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Delete not implemented") -} - -func RegisterRunnerServer(s *grpc.Server, srv RunnerServer) { - s.RegisterService(&_Runner_serviceDesc, srv) -} - -func _Runner_Get_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetRunnerRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(RunnerServer).Get(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/mesg.api.Runner/Get", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(RunnerServer).Get(ctx, req.(*GetRunnerRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Runner_List_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ListRunnerRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(RunnerServer).List(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/mesg.api.Runner/List", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(RunnerServer).List(ctx, req.(*ListRunnerRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Runner_Create_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(CreateRunnerRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(RunnerServer).Create(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/mesg.api.Runner/Create", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(RunnerServer).Create(ctx, req.(*CreateRunnerRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Runner_Delete_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(DeleteRunnerRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(RunnerServer).Delete(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/mesg.api.Runner/Delete", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(RunnerServer).Delete(ctx, req.(*DeleteRunnerRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _Runner_serviceDesc = grpc.ServiceDesc{ - ServiceName: "mesg.api.Runner", - HandlerType: (*RunnerServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Get", - Handler: _Runner_Get_Handler, - }, - { - MethodName: "List", - Handler: _Runner_List_Handler, - }, - { - MethodName: "Create", - Handler: _Runner_Create_Handler, - }, - { - MethodName: "Delete", - Handler: _Runner_Delete_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "protobuf/api/runner.proto", -} diff --git a/protobuf/api/runner.proto b/protobuf/api/runner.proto deleted file mode 100644 index 9a1f533ea..000000000 --- a/protobuf/api/runner.proto +++ /dev/null @@ -1,104 +0,0 @@ -syntax = "proto3"; - -import "gogo/protobuf/gogoproto/gogo.proto"; -import "protobuf/types/runner.proto"; - -package mesg.api; -option go_package = "api"; - -// This is the API to interact with the Runner. -// -// This API is a [gRPC](https://grpc.io/) API. -// -// The source file of this API is hosted on [GitHub](https://github.com/mesg-foundation/engine/blob/master/protobuf/api/runner.proto). -service Runner { - - // Get returns an Runner matching the criteria of the request. - rpc Get(GetRunnerRequest) returns (types.Runner) {} - - // List returns all Runners matching the criteria of the request. - rpc List(ListRunnerRequest) returns (ListRunnerResponse) {} - - // Create an Runner from a Service's hash and custom environmental variables. - // It will return an unique identifier to identify the runner. - rpc Create(CreateRunnerRequest) returns (CreateRunnerResponse) {} - - // Delete an Runner. - rpc Delete(DeleteRunnerRequest) returns (DeleteRunnerResponse) {} -} - -// The request's data for the `Get` API. -message GetRunnerRequest { - bytes hash = 1 [ - (gogoproto.moretags) = 'validate:"required,hash"', - (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", - (gogoproto.nullable) = false - ]; -} - -// The request's data for the `List` API. -message ListRunnerRequest { - // Filter contains filtering criteria. - message Filter { - // Filter by instance hash. - bytes instanceHash = 1 [ - (gogoproto.moretags) = 'validate:"hash"', - (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", - (gogoproto.nullable) = false - ]; - - // Filter by owner - string owner = 2 [ - (gogoproto.moretags) = 'validate:"accaddress"' - ]; - } - - // Filter used to filter runners. - Filter filter = 1; -} - -// The response's data for the `List` API. -message ListRunnerResponse { - // List of runners that match the request's filters. - repeated types.Runner runners = 1; -} - -// The request's data for the `Create` API. -message CreateRunnerRequest { - // Service's hash to start the runner with. - bytes serviceHash = 1 [ - (gogoproto.moretags) = 'validate:"hash"', - (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", - (gogoproto.nullable) = false - ]; - - // Environmental variables to start the runner with. - repeated string env = 2 [ - (gogoproto.moretags) = 'validate:"unique,dive,env"' - ]; -} - -// The response's data for the `Create` API. -message CreateRunnerResponse { - // The runner's hash created. - bytes hash = 1 [ - (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", - (gogoproto.nullable) = false - ]; -} - -// The request's data for the `Delete` API. -message DeleteRunnerRequest { - // Runner's hash - bytes hash = 1 [ - (gogoproto.moretags) = 'validate:"required,hash"', - (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", - (gogoproto.nullable) = false - ]; - - // If true, any persistent data (volumes) that belongs to the runner's container and its dependencies will also be deleted. - bool deleteData = 2; -} - -// The response's data for the `Delete` API. -message DeleteRunnerResponse {} diff --git a/protobuf/api/service.pb.go b/protobuf/api/service.pb.go deleted file mode 100644 index 8c85ae5e6..000000000 --- a/protobuf/api/service.pb.go +++ /dev/null @@ -1,678 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: protobuf/api/service.proto - -package api - -import ( - context "context" - fmt "fmt" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" - github_com_mesg_foundation_engine_hash "github.com/mesg-foundation/engine/hash" - service "github.com/mesg-foundation/engine/service" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - math "math" -) - -// 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 - -// The request's data for the `Create` API. -type CreateServiceRequest struct { - // Service's sid. - Sid string `protobuf:"bytes,1,opt,name=sid,proto3" json:"sid,omitempty" validate:"printascii,max=63,domain"` - // Service's name. - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty" validate:"required,printascii"` - // Service's description. - Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty" validate:"printascii"` - // Configurations related to the service - Configuration service.Service_Configuration `protobuf:"bytes,4,opt,name=configuration,proto3" json:"configuration" validate:"required"` - // The list of tasks this service can execute. - Tasks []*service.Service_Task `protobuf:"bytes,5,rep,name=tasks,proto3" json:"tasks,omitempty" validate:"dive,required"` - // The list of events this service can emit. - Events []*service.Service_Event `protobuf:"bytes,6,rep,name=events,proto3" json:"events,omitempty" validate:"dive,required"` - // The container dependencies this service requires. - Dependencies []*service.Service_Dependency `protobuf:"bytes,7,rep,name=dependencies,proto3" json:"dependencies,omitempty" validate:"dive,required"` - // Service's repository url. - Repository string `protobuf:"bytes,8,opt,name=repository,proto3" json:"repository,omitempty" validate:"omitempty,uri"` - // The hash id of service's source code on IPFS. - Source string `protobuf:"bytes,9,opt,name=source,proto3" json:"source,omitempty" validate:"required,printascii"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *CreateServiceRequest) Reset() { *m = CreateServiceRequest{} } -func (m *CreateServiceRequest) String() string { return proto.CompactTextString(m) } -func (*CreateServiceRequest) ProtoMessage() {} -func (*CreateServiceRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_0615fe53b372bcb1, []int{0} -} -func (m *CreateServiceRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_CreateServiceRequest.Unmarshal(m, b) -} -func (m *CreateServiceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_CreateServiceRequest.Marshal(b, m, deterministic) -} -func (m *CreateServiceRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_CreateServiceRequest.Merge(m, src) -} -func (m *CreateServiceRequest) XXX_Size() int { - return xxx_messageInfo_CreateServiceRequest.Size(m) -} -func (m *CreateServiceRequest) XXX_DiscardUnknown() { - xxx_messageInfo_CreateServiceRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_CreateServiceRequest proto.InternalMessageInfo - -func (m *CreateServiceRequest) GetSid() string { - if m != nil { - return m.Sid - } - return "" -} - -func (m *CreateServiceRequest) GetName() string { - if m != nil { - return m.Name - } - return "" -} - -func (m *CreateServiceRequest) GetDescription() string { - if m != nil { - return m.Description - } - return "" -} - -func (m *CreateServiceRequest) GetConfiguration() service.Service_Configuration { - if m != nil { - return m.Configuration - } - return service.Service_Configuration{} -} - -func (m *CreateServiceRequest) GetTasks() []*service.Service_Task { - if m != nil { - return m.Tasks - } - return nil -} - -func (m *CreateServiceRequest) GetEvents() []*service.Service_Event { - if m != nil { - return m.Events - } - return nil -} - -func (m *CreateServiceRequest) GetDependencies() []*service.Service_Dependency { - if m != nil { - return m.Dependencies - } - return nil -} - -func (m *CreateServiceRequest) GetRepository() string { - if m != nil { - return m.Repository - } - return "" -} - -func (m *CreateServiceRequest) GetSource() string { - if m != nil { - return m.Source - } - return "" -} - -// The response's data for the `Create` API. -type CreateServiceResponse struct { - // The service's hash created. - Hash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=hash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"hash"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *CreateServiceResponse) Reset() { *m = CreateServiceResponse{} } -func (m *CreateServiceResponse) String() string { return proto.CompactTextString(m) } -func (*CreateServiceResponse) ProtoMessage() {} -func (*CreateServiceResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_0615fe53b372bcb1, []int{1} -} -func (m *CreateServiceResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_CreateServiceResponse.Unmarshal(m, b) -} -func (m *CreateServiceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_CreateServiceResponse.Marshal(b, m, deterministic) -} -func (m *CreateServiceResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_CreateServiceResponse.Merge(m, src) -} -func (m *CreateServiceResponse) XXX_Size() int { - return xxx_messageInfo_CreateServiceResponse.Size(m) -} -func (m *CreateServiceResponse) XXX_DiscardUnknown() { - xxx_messageInfo_CreateServiceResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_CreateServiceResponse proto.InternalMessageInfo - -// The request's data for the `Get` API. -type GetServiceRequest struct { - // The service's hash to fetch. - Hash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=hash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"hash" validate:"required,hash"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *GetServiceRequest) Reset() { *m = GetServiceRequest{} } -func (m *GetServiceRequest) String() string { return proto.CompactTextString(m) } -func (*GetServiceRequest) ProtoMessage() {} -func (*GetServiceRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_0615fe53b372bcb1, []int{2} -} -func (m *GetServiceRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetServiceRequest.Unmarshal(m, b) -} -func (m *GetServiceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetServiceRequest.Marshal(b, m, deterministic) -} -func (m *GetServiceRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetServiceRequest.Merge(m, src) -} -func (m *GetServiceRequest) XXX_Size() int { - return xxx_messageInfo_GetServiceRequest.Size(m) -} -func (m *GetServiceRequest) XXX_DiscardUnknown() { - xxx_messageInfo_GetServiceRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_GetServiceRequest proto.InternalMessageInfo - -// The request's data for the `List` API. -type ListServiceRequest struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ListServiceRequest) Reset() { *m = ListServiceRequest{} } -func (m *ListServiceRequest) String() string { return proto.CompactTextString(m) } -func (*ListServiceRequest) ProtoMessage() {} -func (*ListServiceRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_0615fe53b372bcb1, []int{3} -} -func (m *ListServiceRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ListServiceRequest.Unmarshal(m, b) -} -func (m *ListServiceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ListServiceRequest.Marshal(b, m, deterministic) -} -func (m *ListServiceRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_ListServiceRequest.Merge(m, src) -} -func (m *ListServiceRequest) XXX_Size() int { - return xxx_messageInfo_ListServiceRequest.Size(m) -} -func (m *ListServiceRequest) XXX_DiscardUnknown() { - xxx_messageInfo_ListServiceRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_ListServiceRequest proto.InternalMessageInfo - -// The response's data for the `List` API. -type ListServiceResponse struct { - // List of services that match the request's filters. - Services []*service.Service `protobuf:"bytes,1,rep,name=services,proto3" json:"services,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ListServiceResponse) Reset() { *m = ListServiceResponse{} } -func (m *ListServiceResponse) String() string { return proto.CompactTextString(m) } -func (*ListServiceResponse) ProtoMessage() {} -func (*ListServiceResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_0615fe53b372bcb1, []int{4} -} -func (m *ListServiceResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ListServiceResponse.Unmarshal(m, b) -} -func (m *ListServiceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ListServiceResponse.Marshal(b, m, deterministic) -} -func (m *ListServiceResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_ListServiceResponse.Merge(m, src) -} -func (m *ListServiceResponse) XXX_Size() int { - return xxx_messageInfo_ListServiceResponse.Size(m) -} -func (m *ListServiceResponse) XXX_DiscardUnknown() { - xxx_messageInfo_ListServiceResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_ListServiceResponse proto.InternalMessageInfo - -func (m *ListServiceResponse) GetServices() []*service.Service { - if m != nil { - return m.Services - } - return nil -} - -// The request's data for the `List` API. -type ExistsServiceRequest struct { - // The service's hash of the existing service. This hash is nil if exists is fals. - Hash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=hash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"hash" validate:"required,hash"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ExistsServiceRequest) Reset() { *m = ExistsServiceRequest{} } -func (m *ExistsServiceRequest) String() string { return proto.CompactTextString(m) } -func (*ExistsServiceRequest) ProtoMessage() {} -func (*ExistsServiceRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_0615fe53b372bcb1, []int{5} -} -func (m *ExistsServiceRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ExistsServiceRequest.Unmarshal(m, b) -} -func (m *ExistsServiceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ExistsServiceRequest.Marshal(b, m, deterministic) -} -func (m *ExistsServiceRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_ExistsServiceRequest.Merge(m, src) -} -func (m *ExistsServiceRequest) XXX_Size() int { - return xxx_messageInfo_ExistsServiceRequest.Size(m) -} -func (m *ExistsServiceRequest) XXX_DiscardUnknown() { - xxx_messageInfo_ExistsServiceRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_ExistsServiceRequest proto.InternalMessageInfo - -// The response's data for the `Exists` API. -type ExistsServiceResponse struct { - // True if a service already exists, false otherwise. - Exists bool `protobuf:"varint,1,opt,name=exists,proto3" json:"exists,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ExistsServiceResponse) Reset() { *m = ExistsServiceResponse{} } -func (m *ExistsServiceResponse) String() string { return proto.CompactTextString(m) } -func (*ExistsServiceResponse) ProtoMessage() {} -func (*ExistsServiceResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_0615fe53b372bcb1, []int{6} -} -func (m *ExistsServiceResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ExistsServiceResponse.Unmarshal(m, b) -} -func (m *ExistsServiceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ExistsServiceResponse.Marshal(b, m, deterministic) -} -func (m *ExistsServiceResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_ExistsServiceResponse.Merge(m, src) -} -func (m *ExistsServiceResponse) XXX_Size() int { - return xxx_messageInfo_ExistsServiceResponse.Size(m) -} -func (m *ExistsServiceResponse) XXX_DiscardUnknown() { - xxx_messageInfo_ExistsServiceResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_ExistsServiceResponse proto.InternalMessageInfo - -func (m *ExistsServiceResponse) GetExists() bool { - if m != nil { - return m.Exists - } - return false -} - -// The request's data for the `Hash` API. -type HashServiceResponse struct { - // Hash of the service calculated. - Hash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=hash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"hash"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *HashServiceResponse) Reset() { *m = HashServiceResponse{} } -func (m *HashServiceResponse) String() string { return proto.CompactTextString(m) } -func (*HashServiceResponse) ProtoMessage() {} -func (*HashServiceResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_0615fe53b372bcb1, []int{7} -} -func (m *HashServiceResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_HashServiceResponse.Unmarshal(m, b) -} -func (m *HashServiceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_HashServiceResponse.Marshal(b, m, deterministic) -} -func (m *HashServiceResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_HashServiceResponse.Merge(m, src) -} -func (m *HashServiceResponse) XXX_Size() int { - return xxx_messageInfo_HashServiceResponse.Size(m) -} -func (m *HashServiceResponse) XXX_DiscardUnknown() { - xxx_messageInfo_HashServiceResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_HashServiceResponse proto.InternalMessageInfo - -func init() { - proto.RegisterType((*CreateServiceRequest)(nil), "mesg.api.CreateServiceRequest") - proto.RegisterType((*CreateServiceResponse)(nil), "mesg.api.CreateServiceResponse") - proto.RegisterType((*GetServiceRequest)(nil), "mesg.api.GetServiceRequest") - proto.RegisterType((*ListServiceRequest)(nil), "mesg.api.ListServiceRequest") - proto.RegisterType((*ListServiceResponse)(nil), "mesg.api.ListServiceResponse") - proto.RegisterType((*ExistsServiceRequest)(nil), "mesg.api.ExistsServiceRequest") - proto.RegisterType((*ExistsServiceResponse)(nil), "mesg.api.ExistsServiceResponse") - proto.RegisterType((*HashServiceResponse)(nil), "mesg.api.HashServiceResponse") -} - -func init() { proto.RegisterFile("protobuf/api/service.proto", fileDescriptor_0615fe53b372bcb1) } - -var fileDescriptor_0615fe53b372bcb1 = []byte{ - // 663 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x95, 0xc1, 0x6e, 0xd3, 0x40, - 0x10, 0x86, 0x93, 0x26, 0x71, 0xd3, 0x69, 0x39, 0xb0, 0x69, 0x91, 0x9b, 0x96, 0xba, 0x2c, 0x07, - 0x2a, 0x11, 0x6c, 0xa9, 0x95, 0x2a, 0x51, 0xe0, 0x92, 0x52, 0x8a, 0xd4, 0x4a, 0x95, 0x0c, 0x27, - 0x0e, 0xa8, 0x5b, 0x7b, 0x9a, 0xac, 0x8a, 0xbd, 0xae, 0x77, 0x1d, 0x35, 0xe2, 0x81, 0x78, 0x15, - 0x9e, 0x81, 0x83, 0x1f, 0x81, 0x43, 0x9e, 0x00, 0x79, 0x63, 0x92, 0x38, 0x75, 0x55, 0x84, 0x84, - 0xb8, 0x65, 0x77, 0xff, 0xf9, 0x66, 0x67, 0xfe, 0x59, 0x07, 0xda, 0x51, 0x2c, 0x94, 0xb8, 0x48, - 0x2e, 0x1d, 0x16, 0x71, 0x47, 0x62, 0x3c, 0xe0, 0x1e, 0xda, 0x7a, 0x93, 0x34, 0x03, 0x94, 0x3d, - 0x9b, 0x45, 0xbc, 0x4d, 0x7b, 0xa2, 0x27, 0x9c, 0x89, 0x34, 0x5b, 0xe9, 0x85, 0xfe, 0x35, 0x56, - 0xb7, 0x37, 0x27, 0xc7, 0x6a, 0x18, 0xa1, 0x2c, 0xb2, 0xe8, 0xb7, 0x06, 0xac, 0x1e, 0xc6, 0xc8, - 0x14, 0x7e, 0x18, 0xef, 0xbb, 0x78, 0x9d, 0xa0, 0x54, 0xe4, 0x25, 0xd4, 0x24, 0xf7, 0xcd, 0xea, - 0x76, 0x75, 0x67, 0xa9, 0xfb, 0x6c, 0x94, 0x5a, 0x4f, 0x07, 0xec, 0x0b, 0xf7, 0x99, 0xc2, 0x03, - 0x1a, 0xc5, 0x3c, 0x54, 0x4c, 0x7a, 0x9c, 0x77, 0x02, 0x76, 0xf3, 0x66, 0x7f, 0xaf, 0xe3, 0x8b, - 0x80, 0xf1, 0x90, 0xba, 0x59, 0x0c, 0xd9, 0x87, 0x7a, 0xc8, 0x02, 0x34, 0x17, 0x74, 0x2c, 0x1d, - 0xa5, 0xd6, 0xd6, 0x34, 0x36, 0xc6, 0xeb, 0x84, 0xc7, 0xe8, 0x77, 0xa6, 0x10, 0xea, 0x6a, 0x3d, - 0x79, 0x05, 0xcb, 0x3e, 0x4a, 0x2f, 0xe6, 0x91, 0xe2, 0x22, 0x34, 0x6b, 0x3a, 0x7c, 0x7d, 0x94, - 0x5a, 0x6b, 0x65, 0xa9, 0xa9, 0x3b, 0xab, 0x26, 0x3e, 0x3c, 0xf0, 0x44, 0x78, 0xc9, 0x7b, 0x49, - 0xcc, 0x74, 0x78, 0x7d, 0xbb, 0xba, 0xb3, 0xbc, 0xfb, 0xc4, 0xd6, 0xcd, 0xd2, 0xa5, 0xdb, 0x79, - 0x89, 0xf6, 0xe1, 0xac, 0xb0, 0xbb, 0xf1, 0x3d, 0xb5, 0x2a, 0xa3, 0xd4, 0x6a, 0xdd, 0xbe, 0x24, - 0x75, 0x8b, 0x50, 0x72, 0x0a, 0x0d, 0xc5, 0xe4, 0x95, 0x34, 0x1b, 0xdb, 0xb5, 0x9d, 0xe5, 0x5d, - 0xb3, 0x8c, 0xfe, 0x91, 0xc9, 0xab, 0xee, 0xe6, 0x28, 0xb5, 0xcc, 0x29, 0xd0, 0xe7, 0x03, 0xec, - 0x4c, 0xa9, 0x63, 0x08, 0x39, 0x03, 0x03, 0x07, 0x18, 0x2a, 0x69, 0x1a, 0x1a, 0xb7, 0x5e, 0x86, - 0x3b, 0xca, 0x14, 0xf7, 0xf0, 0x72, 0x0c, 0x39, 0x87, 0x15, 0x1f, 0x23, 0x0c, 0x7d, 0x0c, 0x3d, - 0x8e, 0xd2, 0x5c, 0xd4, 0xd8, 0xad, 0x32, 0xec, 0xdb, 0xdf, 0xba, 0xe1, 0x3d, 0xec, 0x02, 0x91, - 0xbc, 0x06, 0x88, 0x31, 0x12, 0x92, 0x2b, 0x11, 0x0f, 0xcd, 0xa6, 0xb6, 0x68, 0x2e, 0x5e, 0x04, - 0x5c, 0x61, 0x10, 0xa9, 0x61, 0x27, 0x89, 0x39, 0x75, 0x67, 0xf4, 0xe4, 0x00, 0x0c, 0x29, 0x92, - 0xd8, 0x43, 0x73, 0xe9, 0x8f, 0x67, 0x23, 0x8f, 0xa0, 0xe7, 0xb0, 0x36, 0x37, 0xa8, 0x32, 0x12, - 0xa1, 0x44, 0x72, 0x0c, 0xf5, 0x3e, 0x93, 0x7d, 0x3d, 0xaa, 0x2b, 0xdd, 0xbd, 0xcc, 0xcd, 0x1f, - 0xa9, 0xf5, 0xbc, 0xc7, 0x55, 0x3f, 0xb9, 0xb0, 0x3d, 0x11, 0x38, 0x59, 0xf9, 0x2f, 0x2e, 0x45, - 0x12, 0xfa, 0xda, 0x45, 0x07, 0xc3, 0x1e, 0x0f, 0xd1, 0xc9, 0xa2, 0xec, 0xf7, 0x4c, 0xf6, 0x5d, - 0x0d, 0xa0, 0x37, 0xf0, 0xf0, 0x18, 0xd5, 0xdc, 0x3b, 0xf0, 0x0a, 0xf4, 0xb3, 0xbf, 0xa0, 0x17, - 0xbb, 0x33, 0xa9, 0x51, 0xa7, 0xcc, 0x33, 0xaf, 0x02, 0x39, 0xe5, 0x72, 0x2e, 0x35, 0x7d, 0x07, - 0xad, 0xc2, 0x6e, 0x5e, 0xaf, 0x03, 0xcd, 0xfc, 0x0d, 0x4b, 0xb3, 0xaa, 0x0d, 0x6e, 0x95, 0x18, - 0xec, 0x4e, 0x44, 0xf4, 0x2b, 0xac, 0x1e, 0xdd, 0x70, 0xa9, 0xe4, 0xff, 0x28, 0xcd, 0x81, 0xb5, - 0xb9, 0xe4, 0x79, 0x19, 0x8f, 0xc0, 0x40, 0x7d, 0xa0, 0xf3, 0x37, 0xdd, 0x7c, 0x45, 0x3f, 0x43, - 0x2b, 0x43, 0xff, 0x2b, 0x97, 0x77, 0x7f, 0x2e, 0xc0, 0x62, 0x0e, 0x27, 0x27, 0x60, 0x8c, 0x67, - 0x8a, 0xe4, 0x6f, 0x84, 0x45, 0xdc, 0x2e, 0xfb, 0x1c, 0xb6, 0xad, 0x3b, 0xcf, 0xc7, 0xf7, 0xa3, - 0x95, 0xec, 0x8b, 0x79, 0x8c, 0x8a, 0x6c, 0x4c, 0x95, 0xb7, 0xa6, 0xa9, 0x5d, 0xe6, 0x14, 0xad, - 0x90, 0x23, 0xa8, 0x67, 0x4e, 0x93, 0xcd, 0x69, 0xec, 0xed, 0x79, 0x68, 0x3f, 0xbe, 0xe3, 0x74, - 0x72, 0x83, 0x13, 0x30, 0xc6, 0xbd, 0x9e, 0x2d, 0xa7, 0xcc, 0xfa, 0xd9, 0x72, 0x4a, 0xdd, 0xa1, - 0x95, 0xac, 0xe1, 0x59, 0xd7, 0xee, 0xed, 0xcc, 0xcc, 0xad, 0x4a, 0x7c, 0xa3, 0x95, 0x6e, 0xe3, - 0x53, 0x8d, 0x45, 0xfc, 0xc2, 0xd0, 0x7f, 0x38, 0x7b, 0xbf, 0x02, 0x00, 0x00, 0xff, 0xff, 0x8f, - 0x8e, 0xdc, 0x65, 0xda, 0x06, 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// ServiceClient is the client API for Service service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type ServiceClient interface { - // Create a Service from a Service Definition. - // It will return an unique identifier which is used to interact with the Service. - Create(ctx context.Context, in *CreateServiceRequest, opts ...grpc.CallOption) (*CreateServiceResponse, error) - // Get returns a Service matching the criteria of the request. - Get(ctx context.Context, in *GetServiceRequest, opts ...grpc.CallOption) (*service.Service, error) - // List returns services specified in a request. - List(ctx context.Context, in *ListServiceRequest, opts ...grpc.CallOption) (*ListServiceResponse, error) - // Exists return if a service already exists. - Exists(ctx context.Context, in *ExistsServiceRequest, opts ...grpc.CallOption) (*ExistsServiceResponse, error) - // Hash return the hash of a service - Hash(ctx context.Context, in *CreateServiceRequest, opts ...grpc.CallOption) (*HashServiceResponse, error) -} - -type serviceClient struct { - cc *grpc.ClientConn -} - -func NewServiceClient(cc *grpc.ClientConn) ServiceClient { - return &serviceClient{cc} -} - -func (c *serviceClient) Create(ctx context.Context, in *CreateServiceRequest, opts ...grpc.CallOption) (*CreateServiceResponse, error) { - out := new(CreateServiceResponse) - err := c.cc.Invoke(ctx, "/mesg.api.Service/Create", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) Get(ctx context.Context, in *GetServiceRequest, opts ...grpc.CallOption) (*service.Service, error) { - out := new(service.Service) - err := c.cc.Invoke(ctx, "/mesg.api.Service/Get", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) List(ctx context.Context, in *ListServiceRequest, opts ...grpc.CallOption) (*ListServiceResponse, error) { - out := new(ListServiceResponse) - err := c.cc.Invoke(ctx, "/mesg.api.Service/List", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) Exists(ctx context.Context, in *ExistsServiceRequest, opts ...grpc.CallOption) (*ExistsServiceResponse, error) { - out := new(ExistsServiceResponse) - err := c.cc.Invoke(ctx, "/mesg.api.Service/Exists", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) Hash(ctx context.Context, in *CreateServiceRequest, opts ...grpc.CallOption) (*HashServiceResponse, error) { - out := new(HashServiceResponse) - err := c.cc.Invoke(ctx, "/mesg.api.Service/Hash", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// ServiceServer is the server API for Service service. -type ServiceServer interface { - // Create a Service from a Service Definition. - // It will return an unique identifier which is used to interact with the Service. - Create(context.Context, *CreateServiceRequest) (*CreateServiceResponse, error) - // Get returns a Service matching the criteria of the request. - Get(context.Context, *GetServiceRequest) (*service.Service, error) - // List returns services specified in a request. - List(context.Context, *ListServiceRequest) (*ListServiceResponse, error) - // Exists return if a service already exists. - Exists(context.Context, *ExistsServiceRequest) (*ExistsServiceResponse, error) - // Hash return the hash of a service - Hash(context.Context, *CreateServiceRequest) (*HashServiceResponse, error) -} - -// UnimplementedServiceServer can be embedded to have forward compatible implementations. -type UnimplementedServiceServer struct { -} - -func (*UnimplementedServiceServer) Create(ctx context.Context, req *CreateServiceRequest) (*CreateServiceResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Create not implemented") -} -func (*UnimplementedServiceServer) Get(ctx context.Context, req *GetServiceRequest) (*service.Service, error) { - return nil, status.Errorf(codes.Unimplemented, "method Get not implemented") -} -func (*UnimplementedServiceServer) List(ctx context.Context, req *ListServiceRequest) (*ListServiceResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method List not implemented") -} -func (*UnimplementedServiceServer) Exists(ctx context.Context, req *ExistsServiceRequest) (*ExistsServiceResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Exists not implemented") -} -func (*UnimplementedServiceServer) Hash(ctx context.Context, req *CreateServiceRequest) (*HashServiceResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Hash not implemented") -} - -func RegisterServiceServer(s *grpc.Server, srv ServiceServer) { - s.RegisterService(&_Service_serviceDesc, srv) -} - -func _Service_Create_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(CreateServiceRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ServiceServer).Create(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/mesg.api.Service/Create", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ServiceServer).Create(ctx, req.(*CreateServiceRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Service_Get_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetServiceRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ServiceServer).Get(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/mesg.api.Service/Get", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ServiceServer).Get(ctx, req.(*GetServiceRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Service_List_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ListServiceRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ServiceServer).List(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/mesg.api.Service/List", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ServiceServer).List(ctx, req.(*ListServiceRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Service_Exists_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ExistsServiceRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ServiceServer).Exists(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/mesg.api.Service/Exists", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ServiceServer).Exists(ctx, req.(*ExistsServiceRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Service_Hash_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(CreateServiceRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ServiceServer).Hash(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/mesg.api.Service/Hash", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ServiceServer).Hash(ctx, req.(*CreateServiceRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _Service_serviceDesc = grpc.ServiceDesc{ - ServiceName: "mesg.api.Service", - HandlerType: (*ServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Create", - Handler: _Service_Create_Handler, - }, - { - MethodName: "Get", - Handler: _Service_Get_Handler, - }, - { - MethodName: "List", - Handler: _Service_List_Handler, - }, - { - MethodName: "Exists", - Handler: _Service_Exists_Handler, - }, - { - MethodName: "Hash", - Handler: _Service_Hash_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "protobuf/api/service.proto", -} diff --git a/protobuf/api/service.proto b/protobuf/api/service.proto deleted file mode 100644 index fce943b4d..000000000 --- a/protobuf/api/service.proto +++ /dev/null @@ -1,133 +0,0 @@ -syntax = "proto3"; - -import "gogo/protobuf/gogoproto/gogo.proto"; -import "protobuf/types/service.proto"; - -package mesg.api; -option go_package = "api"; - -// This is the API to interact with the Services. -// -// This API is a [gRPC](https://grpc.io/) API. -// -// The source file of this API is hosted on [GitHub](https://github.com/mesg-foundation/engine/blob/master/protobuf/api/service.proto). -service Service { - - // Create a Service from a Service Definition. - // It will return an unique identifier which is used to interact with the Service. - rpc Create (CreateServiceRequest) returns (CreateServiceResponse) {} - - // Get returns a Service matching the criteria of the request. - rpc Get(GetServiceRequest) returns (types.Service) {} - - // List returns services specified in a request. - rpc List(ListServiceRequest) returns (ListServiceResponse) {} - - // Exists return if a service already exists. - rpc Exists(ExistsServiceRequest) returns (ExistsServiceResponse) {} - - // Hash return the hash of a service - rpc Hash(CreateServiceRequest) returns (HashServiceResponse) {} -} - -// The request's data for the `Create` API. -message CreateServiceRequest { - // Service's sid. - string sid = 1 [ - (gogoproto.moretags) = 'validate:"printascii,max=63,domain"' - ]; - - // Service's name. - string name = 2 [ - (gogoproto.moretags) = 'validate:"required,printascii"' - ]; - - // Service's description. - string description = 3 [ - (gogoproto.moretags) = 'validate:"printascii"' - ]; - - // Configurations related to the service - types.Service.Configuration configuration = 4 [ - (gogoproto.moretags) = 'validate:"required"', - (gogoproto.nullable) = false - ]; - - // The list of tasks this service can execute. - repeated types.Service.Task tasks = 5 [ - (gogoproto.moretags) = 'validate:"dive,required"' - ]; - - // The list of events this service can emit. - repeated types.Service.Event events = 6 [ - (gogoproto.moretags) = 'validate:"dive,required"' - ]; - - // The container dependencies this service requires. - repeated types.Service.Dependency dependencies = 7 [ - (gogoproto.moretags) = 'validate:"dive,required"' - ]; - - // Service's repository url. - string repository = 8 [ - (gogoproto.moretags) = 'validate:"omitempty,uri"' - ]; - - // The hash id of service's source code on IPFS. - string source = 9 [ - (gogoproto.moretags) = 'validate:"required,printascii"' - ]; -} - -// The response's data for the `Create` API. -message CreateServiceResponse { - // The service's hash created. - bytes hash = 1 [ - (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", - (gogoproto.nullable) = false - ]; -} - -// The request's data for the `Get` API. -message GetServiceRequest { - // The service's hash to fetch. - bytes hash = 1 [ - (gogoproto.moretags) = 'validate:"required,hash"', - (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", - (gogoproto.nullable) = false - ]; -} - -// The request's data for the `List` API. -message ListServiceRequest {} - -// The response's data for the `List` API. -message ListServiceResponse { - // List of services that match the request's filters. - repeated types.Service services = 1; -} - -// The request's data for the `List` API. -message ExistsServiceRequest { - // The service's hash of the existing service. This hash is nil if exists is fals. - bytes hash = 1 [ - (gogoproto.moretags) = 'validate:"required,hash"', - (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", - (gogoproto.nullable) = false - ]; -} - -// The response's data for the `Exists` API. -message ExistsServiceResponse { - // True if a service already exists, false otherwise. - bool exists = 1; -} - -// The request's data for the `Hash` API. -message HashServiceResponse { - // Hash of the service calculated. - bytes hash = 1 [ - (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", - (gogoproto.nullable) = false - ]; -} diff --git a/protobuf/types/event.proto b/protobuf/types/event.proto index 27adb1595..5862af9a3 100644 --- a/protobuf/types/event.proto +++ b/protobuf/types/event.proto @@ -12,16 +12,14 @@ option (gogoproto.goproto_getters_all) = false; message Event { // Hash is a unique hash to identify event. bytes hash = 1 [ - (gogoproto.moretags) = 'hash:"-"', - (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", - (gogoproto.nullable) = false + (gogoproto.moretags) = 'hash:"-" validate:"required,hash"', + (gogoproto.casttype) = "github.com/mesg-foundation/engine/hash.Hash" ]; // instanceHash is hash of instance that can proceed an execution. bytes instanceHash = 2 [ (gogoproto.moretags) = 'hash:"name:2" validate:"required,hash"', - (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", - (gogoproto.nullable) = false + (gogoproto.casttype) = "github.com/mesg-foundation/engine/hash.Hash" ]; // key is the key of the event. diff --git a/protobuf/types/execution.proto b/protobuf/types/execution.proto index ac5352a88..21f427187 100644 --- a/protobuf/types/execution.proto +++ b/protobuf/types/execution.proto @@ -34,42 +34,38 @@ enum Status { message Execution { // Hash is a unique hash to identify execution. bytes hash = 1 [ - (gogoproto.moretags) = 'hash:"-"', - (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", - (gogoproto.nullable) = false + (gogoproto.moretags) = 'hash:"-" validate:"required,hash"', + (gogoproto.casttype) = "github.com/mesg-foundation/engine/hash.Hash" ]; // parentHash is the unique hash of parent execution. // if execution is triggered by another one, // dependency execution considered as the parent. bytes parentHash = 2 [ - (gogoproto.moretags) = 'hash:"name:2"', - (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", - (gogoproto.nullable) = false + (gogoproto.moretags) = 'hash:"name:2" validate:"required_without=EventHash,omitempty,hash"', + (gogoproto.casttype) = "github.com/mesg-foundation/engine/hash.Hash" ]; // eventHash is unique event hash. bytes eventHash = 3 [ - (gogoproto.moretags) = 'hash:"name:3"', - (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", - (gogoproto.nullable) = false + (gogoproto.moretags) = 'hash:"name:3" validate:"required_without=ParentHash,omitempty,hash"', + (gogoproto.casttype) = "github.com/mesg-foundation/engine/hash.Hash" ]; // Status is the current status of execution. Status status = 4 [ - (gogoproto.moretags) = 'hash:"-"' + (gogoproto.moretags) = 'hash:"-" validate:"required"' ]; // instanceHash is hash of the instance that can proceed an execution bytes instanceHash = 5 [ - (gogoproto.moretags) = 'hash:"name:5"', - (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", - (gogoproto.nullable) = false + (gogoproto.moretags) = 'hash:"name:5" validate:"required,hash"', + (gogoproto.casttype) = "github.com/mesg-foundation/engine/hash.Hash" ]; // taskKey is the key of the task of this execution. string taskKey = 6 [ - (gogoproto.moretags) = 'hash:"name:6"' + (gogoproto.moretags) = 'hash:"name:6" validate:"required,printascii"' ]; // inputs data of the execution. @@ -94,9 +90,8 @@ message Execution { // processHash is the unique hash of the process associated to this execution. bytes processHash = 11 [ - (gogoproto.moretags) = 'hash:"name:11"', - (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", - (gogoproto.nullable) = false + (gogoproto.moretags) = 'hash:"name:11" validate:"omitempty,hash"', + (gogoproto.casttype) = "github.com/mesg-foundation/engine/hash.Hash" ]; // node key of the process. @@ -106,14 +101,13 @@ message Execution { // runner that should execute this execution. bytes executorHash = 13 [ - (gogoproto.moretags) = 'hash:"name:13"', - (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", - (gogoproto.nullable) = false + (gogoproto.moretags) = 'hash:"name:13" validate:"required,hash"', + (gogoproto.casttype) = "github.com/mesg-foundation/engine/hash.Hash" ]; // price of running the exeuction. string price = 14 [ - (gogoproto.moretags) = 'hash:"name:14" validate:"coins"' + (gogoproto.moretags) = 'hash:"name:14" validate:"required,coinsPositiveZero"' ]; // blockHeight where the execution was included into blockchain. @@ -125,25 +119,24 @@ message Execution { message Emitter { // Emitter's hash. bytes runnerHash = 1 [ - (gogoproto.moretags) = 'hash:"-" validate:"hash"', - (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", - (gogoproto.nullable) = false + (gogoproto.moretags) = 'hash:"-" validate:"required,hash"', + (gogoproto.casttype) = "github.com/mesg-foundation/engine/hash.Hash" ]; // Block height when this emitter proposed the execution. int64 blockHeight = 2 [ - (gogoproto.moretags) = 'hash:"-"' + (gogoproto.moretags) = 'hash:"-" validate:"required"' ]; } // list of emitters of this execution. repeated Emitter emitters = 16 [ - (gogoproto.moretags) = 'hash:"-"' + (gogoproto.moretags) = 'hash:"-" validate:"dive"' ]; // The address of the execution. bytes address = 17 [ - (gogoproto.moretags) = 'hash:"-" validate:"accaddress"', + (gogoproto.moretags) = 'hash:"-" validate:"required,accaddress"', (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" ]; } diff --git a/protobuf/types/instance.proto b/protobuf/types/instance.proto index 433fe7e90..34fc5b709 100644 --- a/protobuf/types/instance.proto +++ b/protobuf/types/instance.proto @@ -11,19 +11,17 @@ option (gogoproto.equal_all) = true; // Instance represents service's instance. message Instance { bytes hash = 1 [ - (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", - (gogoproto.nullable) = false + (gogoproto.moretags) = 'hash:"-" validate:"required,hash"', + (gogoproto.casttype) = "github.com/mesg-foundation/engine/hash.Hash" ]; bytes serviceHash = 2 [ - (gogoproto.moretags) = 'hash:"name:2"', - (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", - (gogoproto.nullable) = false + (gogoproto.moretags) = 'hash:"name:2" validate:"required,hash"', + (gogoproto.casttype) = "github.com/mesg-foundation/engine/hash.Hash" ]; bytes envHash = 3 [ - (gogoproto.moretags) = 'hash:"name:3"', - (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", - (gogoproto.nullable) = false + (gogoproto.moretags) = 'hash:"name:3" validate:"required,hash"', + (gogoproto.casttype) = "github.com/mesg-foundation/engine/hash.Hash" ]; } diff --git a/protobuf/types/ownership.proto b/protobuf/types/ownership.proto index f9039c50a..f286197be 100644 --- a/protobuf/types/ownership.proto +++ b/protobuf/types/ownership.proto @@ -14,21 +14,20 @@ message Ownership { // Service's hash. bytes hash = 1 [ - (gogoproto.moretags) = 'hash:"-" validate:"required"', - (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", - (gogoproto.nullable) = false + (gogoproto.moretags) = 'hash:"-" validate:"required,hash"', + (gogoproto.casttype) = "github.com/mesg-foundation/engine/hash.Hash" ]; // The owner of the resource. + // TODO: to transform to accAddress string owner = 2 [ (gogoproto.moretags) = 'hash:"name:2" validate:"required"' ]; // Resource's hash. bytes resourceHash = 3 [ - (gogoproto.moretags) = 'hash:"name:3"', - (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", - (gogoproto.nullable) = false + (gogoproto.moretags) = 'hash:"name:3" validate:"required,hash"', + (gogoproto.casttype) = "github.com/mesg-foundation/engine/hash.Hash" ]; enum Resource { @@ -39,11 +38,13 @@ message Ownership { } // Resource's type. - Resource resource = 4; + Resource resource = 4 [ + (gogoproto.moretags) = 'validate:"required"' + ]; // The address of the resource. bytes resourceAddress = 5 [ - (gogoproto.moretags) = 'hash:"-" validate:"accaddress"', + (gogoproto.moretags) = 'hash:"-" validate:"required,accaddress"', (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" ]; } diff --git a/protobuf/types/process.proto b/protobuf/types/process.proto index b7a8de1df..0132ea7ef 100644 --- a/protobuf/types/process.proto +++ b/protobuf/types/process.proto @@ -1,6 +1,7 @@ syntax = "proto3"; import "gogo/protobuf/gogoproto/gogo.proto"; +import "protobuf/types/struct.proto"; package mesg.types; option go_package = "github.com/mesg-foundation/engine/process"; @@ -15,9 +16,8 @@ message Process { message Result { // Hash of the instance that triggers the process. bytes instanceHash = 2 [ - (gogoproto.moretags) = 'hash:"name:2" validate:"required"', - (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", - (gogoproto.nullable) = false + (gogoproto.moretags) = 'hash:"name:2" validate:"required,hash"', + (gogoproto.casttype) = "github.com/mesg-foundation/engine/hash.Hash" ]; // Key of the task that triggers the process. @@ -29,9 +29,8 @@ message Process { message Event { // Hash of the instance that triggers the process. bytes instanceHash = 2 [ - (gogoproto.moretags) = 'hash:"name:2" validate:"required"', - (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", - (gogoproto.nullable) = false + (gogoproto.moretags) = 'hash:"name:2" validate:"required,hash"', + (gogoproto.casttype) = "github.com/mesg-foundation/engine/hash.Hash" ]; // Key of the event that triggers the process. @@ -43,9 +42,8 @@ message Process { message Task { // Hash of the instance to execute. bytes instanceHash = 2 [ - (gogoproto.moretags) = 'hash:"name:2" validate:"required"', - (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", - (gogoproto.nullable) = false + (gogoproto.moretags) = 'hash:"name:2" validate:"required,hash"', + (gogoproto.casttype) = "github.com/mesg-foundation/engine/hash.Hash" ]; // Task of the instance to execute. @@ -74,32 +72,6 @@ message Process { ]; } - message Reference { - message Path { - oneof selector { - string key = 1 [ - (gogoproto.moretags) = 'hash:"name:1" validate:"printascii"' - ]; - uint64 index = 2 [ - (gogoproto.moretags) = 'hash:"name:2"' - ]; - } - - // Path can be nil if on the leaf - Path path = 3 [ - (gogoproto.moretags) = 'hash:"name:3"' - ]; - } - - string nodeKey = 1 [ - (gogoproto.moretags) = 'hash:"name:1" validate:"required"' - ]; - - Path path = 2 [ - (gogoproto.moretags) = 'hash:"name:2"' - ]; - } - oneof value { Null null = 1 [ (gogoproto.moretags) = 'hash:"name:1"' @@ -149,12 +121,22 @@ message Process { // Equal EQ = 1; - } - // Key to check. - string key = 1 [ - (gogoproto.moretags) = 'hash:"name:1" validate:"required,printascii"' - ]; + // Greater than + GT = 2; + + // Greater or equal than + GTE = 3; + + // Lesser than + LT = 4; + + // Lesser or equal than + LTE = 5; + + // CONTAINS + CONTAINS = 6; + } // Type of condition to apply. Predicate predicate = 2 [ @@ -162,18 +144,50 @@ message Process { ]; // Value of the filter. - string value = 3 [ - (gogoproto.moretags) = 'hash:"name:3"' + mesg.protobuf.Value value = 4 [ + (gogoproto.moretags) = 'hash:"name:4" validate:"required"' + ]; + + // Input defined as reference. + Reference ref = 5 [ + (gogoproto.moretags) = 'hash:"name:5" validate:"required"' ]; } // List of condition to apply for this filter repeated Condition conditions = 2 [ - (gogoproto.moretags) = 'hash:"name:2"', + (gogoproto.moretags) = 'hash:"name:2" validate:"dive"', (gogoproto.nullable) = false ]; } + message Reference { + message Path { + oneof selector { + string key = 1 [ + (gogoproto.moretags) = 'hash:"name:1" validate:"printascii"' + ]; + uint64 index = 2 [ + (gogoproto.moretags) = 'hash:"name:2"' + ]; + } + + // Path can be nil if on the leaf + Path path = 3 [ + (gogoproto.moretags) = 'hash:"name:3"' + ]; + } + + string nodeKey = 1 [ + (gogoproto.moretags) = 'hash:"name:1" validate:"required"' + ]; + + // Path can be nil if referencing the whole node's output + Path path = 2 [ + (gogoproto.moretags) = 'hash:"name:2"' + ]; + } + // Key that identifies the node. string key = 1 [ (gogoproto.moretags) = 'hash:"name:1" validate:"required"' @@ -217,14 +231,13 @@ message Process { // Process's hash bytes hash = 1 [ - (gogoproto.moretags) = 'hash:"-" validate:"required"', - (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", - (gogoproto.nullable) = false + (gogoproto.moretags) = 'hash:"-" validate:"required,hash"', + (gogoproto.casttype) = "github.com/mesg-foundation/engine/hash.Hash" ]; // Process's name string name = 2 [ - (gogoproto.moretags) = 'hash:"name:2" validate:"required"' + (gogoproto.moretags) = 'hash:"name:2" validate:"required,printascii"' ]; // Nodes with information related to the execution to trigger. @@ -239,7 +252,7 @@ message Process { // The address of the process. bytes address = 6 [ - (gogoproto.moretags) = 'hash:"-"', + (gogoproto.moretags) = 'hash:"-" validate:"required,accaddress"', (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" ]; } diff --git a/protobuf/types/runner.proto b/protobuf/types/runner.proto index 4e83bf559..21c5fe52f 100644 --- a/protobuf/types/runner.proto +++ b/protobuf/types/runner.proto @@ -12,26 +12,24 @@ option (gogoproto.equal_all) = true; message Runner { // Runner's hash bytes hash = 1 [ - (gogoproto.moretags) = 'hash:"-"', - (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", - (gogoproto.nullable) = false + (gogoproto.moretags) = 'hash:"-" validate:"required,hash"', + (gogoproto.casttype) = "github.com/mesg-foundation/engine/hash.Hash" ]; // owner of the engine of this runner string owner = 2 [ - (gogoproto.moretags) = 'hash:"name:2"' + (gogoproto.moretags) = 'hash:"name:2" validate:"required"' ]; // instanceHash is hash of the instance that runner will handle bytes instanceHash = 3 [ - (gogoproto.moretags) = 'hash:"name:3"', - (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", - (gogoproto.nullable) = false + (gogoproto.moretags) = 'hash:"name:3" validate:"required,hash"', + (gogoproto.casttype) = "github.com/mesg-foundation/engine/hash.Hash" ]; // The address of the runner. bytes address = 4 [ - (gogoproto.moretags) = 'hash:"-" validate:"accaddress"', + (gogoproto.moretags) = 'hash:"-" validate:"required,accaddress"', (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" ]; } diff --git a/protobuf/types/service.proto b/protobuf/types/service.proto index a11495520..a40895aa3 100644 --- a/protobuf/types/service.proto +++ b/protobuf/types/service.proto @@ -15,7 +15,7 @@ message Service { message Event { // Event's key. string key = 4 [ - (gogoproto.moretags) = 'hash:"name:4" validate:"printascii"' + (gogoproto.moretags) = 'hash:"name:4" validate:"required,printascii"' ]; // Event's name. @@ -38,7 +38,7 @@ message Service { message Task { // Task's key. string key = 8 [ - (gogoproto.moretags) = 'hash:"name:8" validate:"printascii"' + (gogoproto.moretags) = 'hash:"name:8" validate:"required,printascii"' ]; // Task's name. @@ -64,10 +64,9 @@ message Service { // Parameter describes the task's inputs, the task's outputs, and the event's data. message Parameter { - // Parameter's key. string key = 8 [ - (gogoproto.moretags) = 'hash:"name:8" validate:"printascii"' + (gogoproto.moretags) = 'hash:"name:8" validate:"required,printascii"' ]; // Parameter's name. @@ -138,12 +137,12 @@ message Service { message Dependency { // Dependency's key. string key = 8 [ - (gogoproto.moretags) = 'hash:"name:8" validate:"printascii"' + (gogoproto.moretags) = 'hash:"name:8" validate:"required,printascii"' ]; // Image's name of the container. string image = 1 [ - (gogoproto.moretags) = 'hash:"name:1" validate:"printascii"' + (gogoproto.moretags) = 'hash:"name:1" validate:"required,printascii"' ]; // List of volumes. @@ -179,9 +178,8 @@ message Service { // Service's hash. bytes hash = 10 [ - (gogoproto.moretags) = 'hash:"-" validate:"required"', - (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", - (gogoproto.nullable) = false + (gogoproto.moretags) = 'hash:"-" validate:"required,hash"', + (gogoproto.casttype) = "github.com/mesg-foundation/engine/hash.Hash" ]; // Service's sid. @@ -232,7 +230,7 @@ message Service { // The address of the service. bytes address = 14 [ - (gogoproto.moretags) = 'hash:"-" validate:"accaddress"', + (gogoproto.moretags) = 'hash:"-" validate:"required,accaddress"', (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" ]; } diff --git a/runner/builder/builder.go b/runner/builder/builder.go deleted file mode 100644 index ffa62479e..000000000 --- a/runner/builder/builder.go +++ /dev/null @@ -1,122 +0,0 @@ -package builder - -import ( - "errors" - "fmt" - - "github.com/mesg-foundation/engine/container" - "github.com/mesg-foundation/engine/cosmos" - "github.com/mesg-foundation/engine/ext/xos" - "github.com/mesg-foundation/engine/hash" - instancepb "github.com/mesg-foundation/engine/instance" - "github.com/mesg-foundation/engine/protobuf/api" - runnerpb "github.com/mesg-foundation/engine/runner" -) - -// Builder is the runner builder. -type Builder struct { - mc *cosmos.ModuleClient - container container.Container - engineName string - port string - ipfsEndpoint string -} - -// New returns the runner sdk. -func New(mc *cosmos.ModuleClient, container container.Container, engineName, port, ipfsEndpoint string) *Builder { - sdk := &Builder{ - container: container, - mc: mc, - engineName: engineName, - port: port, - ipfsEndpoint: ipfsEndpoint, - } - return sdk -} - -// Create creates a new runner. -func (b *Builder) Create(req *api.CreateRunnerRequest) (*runnerpb.Runner, error) { - // calculate instance's hash. - // TODO: this should be merged with the same logic currently in instance sdk - srv, err := b.mc.GetService(req.ServiceHash) - if err != nil { - return nil, err - } - - instanceEnv := xos.EnvMergeSlices(srv.Configuration.Env, req.Env) - envHash := hash.Dump(instanceEnv) - // TODO: should be done by instance or runner - instanceHash := hash.Dump(&instancepb.Instance{ - ServiceHash: srv.Hash, - EnvHash: envHash, - }) - acc, err := b.mc.GetAccount() - if err != nil { - return nil, err - } - expRunner := runnerpb.New(acc.GetAddress().String(), instanceHash) - expRunnerHash := expRunner.Hash - - if runExisting, _ := b.mc.GetRunner(expRunnerHash); runExisting != nil { - return nil, fmt.Errorf("runner %q already exists", runExisting.Hash) - } - - // start the container - imageHash, err := build(b.container, srv, b.ipfsEndpoint) - if err != nil { - return nil, err - } - _, err = start(b.container, srv, instanceHash, expRunnerHash, imageHash, instanceEnv, b.engineName, b.port) - if err != nil { - return nil, err - } - - run, err := b.mc.CreateRunner(req) - if err != nil { - stop(b.container, expRunnerHash, srv.Dependencies) - return nil, err - } - - if !run.Hash.Equal(expRunnerHash) { - stop(b.container, expRunnerHash, srv.Dependencies) - return nil, errors.New("calculated runner hash is not the same") - } - return run, nil -} - -// Delete deletes an existing runner. -func (b *Builder) Delete(req *api.DeleteRunnerRequest) error { - // get runner before deleting it - r, err := b.mc.GetRunner(req.Hash) - if err != nil { - return err - } - - if err := b.mc.DeleteRunner(req); err != nil { - return err - } - - inst, err := b.mc.GetInstance(r.InstanceHash) - if err != nil { - return err - } - - srv, err := b.mc.GetService(inst.ServiceHash) - if err != nil { - return err - } - - // stop the local running service - if err := stop(b.container, r.Hash, srv.Dependencies); err != nil { - return err - } - - // remove local volume - if req.DeleteData { - if err := deleteData(b.container, srv); err != nil { - return err - } - } - - return nil -} diff --git a/runner/builder/container.go b/runner/builder/container.go deleted file mode 100644 index 459339a24..000000000 --- a/runner/builder/container.go +++ /dev/null @@ -1,275 +0,0 @@ -package builder - -import ( - "errors" - "io/ioutil" - "net" - "net/http" - "os" - "strconv" - "strings" - "sync" - - "github.com/docker/docker/client" - "github.com/docker/docker/pkg/archive" - "github.com/mesg-foundation/engine/container" - "github.com/mesg-foundation/engine/ext/xerrors" - "github.com/mesg-foundation/engine/ext/xos" - "github.com/mesg-foundation/engine/hash" - "github.com/mesg-foundation/engine/service" -) - -// Build the imge of the container -func build(cont container.Container, srv *service.Service, ipfsEndpoint string) (string, error) { - // download and untar service context into path. - path, err := ioutil.TempDir("", "mesg") - if err != nil { - return "", err - } - defer os.RemoveAll(path) - - resp, err := http.Get(ipfsEndpoint + srv.Source) - if err != nil { - return "", err - } - if resp.StatusCode != 200 { - return "", errors.New("service's source code is not reachable, status: " + resp.Status + ", url: " + ipfsEndpoint + srv.Source) - } - defer resp.Body.Close() - - if err := archive.Untar(resp.Body, path, nil); err != nil { - return "", err - } - - // build service's Docker image and apply to service. - imageHash, err := cont.Build(path) - if err != nil { - return "", err - } - - return imageHash, nil -} - -// Start starts the service. -func start(cont container.Container, srv *service.Service, instanceHash hash.Hash, runnerHash hash.Hash, imageHash string, env []string, engineName, port string) (serviceIDs []string, err error) { - endpoint := net.JoinHostPort(engineName, port) - namespace := namespace(runnerHash) - networkID, err := cont.CreateNetwork(namespace) - if err != nil { - return nil, err - } - sharedNetworkID := cont.SharedNetworkID() - // BUG: https://github.com/mesg-foundation/engine/issues/382 - // After solving this by docker, switch back to deploy in parallel - configs := make([]container.ServiceOptions, 0) - - // Create dependency container configs - for _, d := range srv.Dependencies { - volumes := convertVolumes(srv, d.Volumes, d.Key) - volumesFrom, err := convertVolumesFrom(srv, d.VolumesFrom) - if err != nil { - return nil, err - } - configs = append(configs, container.ServiceOptions{ - Namespace: dependencyNamespace(namespace, d.Key), - Labels: map[string]string{ - "mesg.engine": engineName, - "mesg.sid": srv.Sid, - "mesg.service": srv.Hash.String(), - "mesg.instance": instanceHash.String(), - "mesg.runner": runnerHash.String(), - "mesg.dependency": d.Key, - }, - Image: d.Image, - Args: d.Args, - Command: d.Command, - Env: d.Env, - Mounts: append(volumes, volumesFrom...), - Ports: convertPorts(d.Ports), - Networks: []container.Network{ - {ID: networkID, Alias: d.Key}, - {ID: sharedNetworkID}, // TODO: to remove - }, - }) - } - - // Create configuration container config - volumes := convertVolumes(srv, srv.Configuration.Volumes, service.MainServiceKey) - volumesFrom, err := convertVolumesFrom(srv, srv.Configuration.VolumesFrom) - if err != nil { - return nil, err - } - configs = append(configs, container.ServiceOptions{ - Namespace: dependencyNamespace(namespace, service.MainServiceKey), - Labels: map[string]string{ - "mesg.engine": engineName, - "mesg.sid": srv.Sid, - "mesg.service": srv.Hash.String(), - "mesg.instance": instanceHash.String(), - "mesg.runner": runnerHash.String(), - "mesg.dependency": service.MainServiceKey, - }, - Image: imageHash, - Args: srv.Configuration.Args, - Command: srv.Configuration.Command, - Env: xos.EnvMergeSlices(env, []string{ - "MESG_INSTANCE_HASH=" + instanceHash.String(), - "MESG_RUNNER_HASH=" + runnerHash.String(), - "MESG_ENDPOINT=" + endpoint, - }), - Mounts: append(volumes, volumesFrom...), - Ports: convertPorts(srv.Configuration.Ports), - Networks: []container.Network{ - {ID: networkID, Alias: service.MainServiceKey}, - {ID: sharedNetworkID}, - }, - }) - - // Start - serviceIDs = make([]string, 0) - for _, c := range configs { - serviceID, err := cont.StartService(c) - if err != nil { - stop(cont, runnerHash, srv.Dependencies) - return nil, err - } - serviceIDs = append(serviceIDs, serviceID) - } - - return serviceIDs, nil -} - -// Stop stops an instance. -func stop(cont container.Container, runnerHash hash.Hash, dependencies []*service.Service_Dependency) error { - var ( - wg sync.WaitGroup - errs xerrors.SyncErrors - namespace = namespace(runnerHash) - namespaces = make([]string, 0) - ) - - for _, d := range dependencies { - namespaces = append(namespaces, dependencyNamespace(namespace, d.Key)) - } - namespaces = append(namespaces, dependencyNamespace(namespace, service.MainServiceKey)) - - for _, namespace := range namespaces { - wg.Add(1) - go func(namespace string) { - defer wg.Done() - if err := cont.StopService(namespace); err != nil { - errs.Append(err) - } - }(namespace) - } - wg.Wait() - if err := errs.ErrorOrNil(); err != nil { - return err - } - - return cont.DeleteNetwork(namespace) -} - -// deleteData deletes the data volumes of instance and its dependencies. -// TODO: right now deleteData() is not compatible to work with multiple instances of same -// service since extractVolumes() accepts service, not instance. same applies in the start -// api as well. make it work with multiple instances. -func deleteData(cont container.Container, s *service.Service) error { - var ( - wg sync.WaitGroup - errs xerrors.SyncErrors - volumes = make([]container.Mount, 0) - ) - - for _, d := range s.Dependencies { - volumes = append(volumes, convertVolumes(s, d.Volumes, d.Key)...) - } - volumes = append(volumes, convertVolumes(s, s.Configuration.Volumes, service.MainServiceKey)...) - - for _, volume := range volumes { - // TODO: is it actually necessary to remvoe in parallel? I worry that some volume will be deleted at the same time and create side effect - wg.Add(1) - go func(source string) { - defer wg.Done() - // if service is never started before, data volume won't be created and Docker Engine - // will return with the not found error. therefore, we can safely ignore it. - if err := cont.DeleteVolume(source); err != nil && !client.IsErrNotFound(err) { - errs.Append(err) - } - }(volume.Source) - } - wg.Wait() - return errs.ErrorOrNil() -} - -// namespace returns the namespace of the service. -func namespace(hash hash.Hash) string { - return hash.String() -} - -// dependencyNamespace builds the namespace of a dependency. -func dependencyNamespace(namespace string, dependencyKey string) string { - return hash.Dump(namespace + dependencyKey).String() -} - -func convertPorts(dPorts []string) []container.Port { - ports := make([]container.Port, len(dPorts)) - for i, p := range dPorts { - split := strings.Split(p, ":") - from, _ := strconv.ParseUint(split[0], 10, 64) - to := from - if len(split) > 1 { - to, _ = strconv.ParseUint(split[1], 10, 64) - } - ports[i] = container.Port{ - Target: uint32(to), - Published: uint32(from), - } - } - return ports -} - -// TODO: add test and hack for MkDir in CircleCI -func convertVolumes(s *service.Service, dVolumes []string, key string) []container.Mount { - volumes := make([]container.Mount, 0) - for _, volume := range dVolumes { - volumes = append(volumes, container.Mount{ - Source: volumeKey(s, key, volume), - Target: volume, - }) - } - return volumes -} - -func convertVolumesFrom(s *service.Service, dVolumesFrom []string) ([]container.Mount, error) { - volumesFrom := make([]container.Mount, 0) - for _, depName := range dVolumesFrom { - var depVolumes []string - if depName == service.MainServiceKey { - depVolumes = s.Configuration.Volumes - } else { - dep, err := s.GetDependency(depName) - if err != nil { - return nil, err - } - depVolumes = dep.Volumes - } - for _, volume := range depVolumes { - volumesFrom = append(volumesFrom, container.Mount{ - Source: volumeKey(s, depName, volume), - Target: volume, - }) - } - } - return volumesFrom, nil -} - -// volumeKey creates a key for service's volume based on the sid to make sure that the volume -// will stay the same for different versions of the service. -func volumeKey(s *service.Service, dependency, volume string) string { - return hash.Dump([]string{ - s.Sid, - dependency, - volume, - }).String() -} diff --git a/runner/runner.go b/runner/runner.go index 9a1483b71..400a92479 100644 --- a/runner/runner.go +++ b/runner/runner.go @@ -2,17 +2,18 @@ package runner import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/mesg-foundation/engine/ext/xvalidator" "github.com/mesg-foundation/engine/hash" "github.com/tendermint/tendermint/crypto" ) // New returns a new execution. -func New(owner string, instanceHash hash.Hash) *Runner { +func New(owner string, instanceHash hash.Hash) (*Runner, error) { run := &Runner{ Owner: owner, InstanceHash: instanceHash, } run.Hash = hash.Dump(run) run.Address = sdk.AccAddress(crypto.AddressHash(run.Hash)) - return run + return run, xvalidator.Struct(run) } diff --git a/runner/runner.pb.go b/runner/runner.pb.go index 09517fc9d..f79433bcb 100644 --- a/runner/runner.pb.go +++ b/runner/runner.pb.go @@ -27,13 +27,13 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Runner represents one node service's instance. type Runner struct { // Runner's hash - Hash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=hash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"hash" hash:"-"` + Hash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=hash,proto3,casttype=github.com/mesg-foundation/engine/hash.Hash" json:"hash,omitempty" hash:"-" validate:"required,hash"` // owner of the engine of this runner - Owner string `protobuf:"bytes,2,opt,name=owner,proto3" json:"owner,omitempty" hash:"name:2"` + Owner string `protobuf:"bytes,2,opt,name=owner,proto3" json:"owner,omitempty" hash:"name:2" validate:"required"` // instanceHash is hash of the instance that runner will handle - InstanceHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,3,opt,name=instanceHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"instanceHash" hash:"name:3"` + InstanceHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,3,opt,name=instanceHash,proto3,casttype=github.com/mesg-foundation/engine/hash.Hash" json:"instanceHash,omitempty" hash:"name:3" validate:"required,hash"` // The address of the runner. - Address github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,4,opt,name=address,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"address,omitempty" hash:"-" validate:"accaddress"` + Address github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,4,opt,name=address,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"address,omitempty" hash:"-" validate:"required,accaddress"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -70,27 +70,27 @@ func init() { func init() { proto.RegisterFile("runner.proto", fileDescriptor_48eceea7e2abc593) } var fileDescriptor_48eceea7e2abc593 = []byte{ - // 307 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x91, 0xb1, 0x4e, 0xf3, 0x30, - 0x14, 0x85, 0x9b, 0xfe, 0xfd, 0x0b, 0x58, 0x61, 0x20, 0x53, 0xc4, 0x10, 0x47, 0x5e, 0x88, 0x84, - 0x12, 0x4b, 0xed, 0x96, 0x05, 0x35, 0x62, 0x60, 0x4e, 0x37, 0x36, 0xc7, 0x71, 0x93, 0x08, 0x62, - 0x57, 0xb1, 0x03, 0xe2, 0x8d, 0x78, 0x94, 0x3e, 0x03, 0x83, 0x11, 0x3c, 0x42, 0x46, 0x26, 0x14, - 0xbb, 0x95, 0xca, 0x84, 0xc4, 0x64, 0x5f, 0xfb, 0xdc, 0xef, 0x1c, 0xfb, 0x02, 0xb7, 0xeb, 0x39, - 0x67, 0x5d, 0xb2, 0xed, 0x84, 0x12, 0x1e, 0x68, 0x99, 0xac, 0x12, 0xf5, 0xb2, 0x65, 0xf2, 0x12, - 0x55, 0xa2, 0x12, 0xd8, 0x9c, 0x17, 0xfd, 0x06, 0x8f, 0x95, 0x29, 0xcc, 0xce, 0xea, 0xd1, 0xfb, - 0x14, 0xcc, 0x73, 0x03, 0xf0, 0xd6, 0x60, 0x56, 0x13, 0x59, 0xfb, 0x4e, 0xe8, 0x44, 0x6e, 0x76, - 0xb3, 0xd3, 0x70, 0xf2, 0xa6, 0xe1, 0x75, 0xd5, 0xa8, 0xba, 0x2f, 0x12, 0x2a, 0x5a, 0x3c, 0xb2, - 0xe3, 0x8d, 0xe8, 0x79, 0x49, 0x54, 0x23, 0x38, 0x66, 0xbc, 0x6a, 0x38, 0xc3, 0x63, 0x57, 0x72, - 0x47, 0x64, 0x3d, 0x68, 0x78, 0x3a, 0x16, 0x29, 0x8a, 0x51, 0x6e, 0x60, 0xde, 0x15, 0xf8, 0x2f, - 0x9e, 0x39, 0xeb, 0xfc, 0x69, 0xe8, 0x44, 0x67, 0xd9, 0xc5, 0xa0, 0xe1, 0xb9, 0x95, 0x70, 0xd2, - 0xb2, 0x74, 0x81, 0x72, 0x7b, 0xef, 0xd5, 0xc0, 0x6d, 0xb8, 0x54, 0x84, 0x53, 0x36, 0xa2, 0xfc, - 0x7f, 0x26, 0xc5, 0xed, 0xdf, 0x52, 0x1c, 0x5b, 0x2c, 0x51, 0xfe, 0x83, 0xec, 0xb5, 0xe0, 0x84, - 0x94, 0x65, 0xc7, 0xa4, 0xf4, 0x67, 0xc6, 0x64, 0x3d, 0x68, 0x18, 0x1c, 0x72, 0x87, 0x4f, 0xe4, - 0xb1, 0x29, 0x89, 0x62, 0x29, 0x22, 0x94, 0xee, 0x85, 0xe8, 0x4b, 0xc3, 0xf8, 0x28, 0x02, 0x15, - 0xb2, 0x15, 0x72, 0xbf, 0xc4, 0xb2, 0x7c, 0xc0, 0xe6, 0xc7, 0x93, 0x15, 0xa5, 0x2b, 0xdb, 0x91, - 0x1f, 0x3c, 0xb2, 0xc5, 0xee, 0x23, 0x98, 0xbc, 0x7e, 0x06, 0xce, 0x7d, 0xf4, 0xfb, 0x23, 0xec, - 0x2c, 0x8b, 0xb9, 0x19, 0xce, 0xf2, 0x3b, 0x00, 0x00, 0xff, 0xff, 0x91, 0x27, 0xd4, 0xaf, 0xdc, - 0x01, 0x00, 0x00, + // 315 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x92, 0x31, 0x4e, 0xc3, 0x30, + 0x14, 0x86, 0x09, 0x2d, 0x45, 0x58, 0x9d, 0x32, 0x45, 0x0c, 0x4d, 0xb1, 0x04, 0x54, 0x82, 0xc4, + 0x52, 0xbb, 0x95, 0xa9, 0x9d, 0x98, 0x23, 0x16, 0x10, 0x8b, 0x6b, 0xbf, 0x26, 0x16, 0xc4, 0x2e, + 0xb6, 0x53, 0xc4, 0xc0, 0x75, 0x10, 0x47, 0xe1, 0x14, 0x91, 0xe0, 0x08, 0x1d, 0x99, 0x90, 0x9d, + 0x22, 0x8a, 0x84, 0x60, 0x61, 0xb2, 0x9f, 0xfd, 0xfe, 0xff, 0xfb, 0xe5, 0x67, 0xd4, 0xd5, 0x95, + 0x94, 0xa0, 0xd3, 0x85, 0x56, 0x56, 0x85, 0xa8, 0x04, 0x93, 0xa7, 0xf6, 0x61, 0x01, 0x66, 0x1f, + 0xe7, 0x2a, 0x57, 0xc4, 0x9f, 0xcf, 0xaa, 0x39, 0x71, 0x95, 0x2f, 0xfc, 0xae, 0xe9, 0xc7, 0x4f, + 0x2d, 0xd4, 0xc9, 0xbc, 0x41, 0x58, 0xa0, 0x76, 0x41, 0x4d, 0x11, 0x05, 0xfd, 0x60, 0xd0, 0x9d, + 0x5e, 0xac, 0xea, 0xf8, 0xc0, 0xd5, 0x63, 0x9c, 0xe0, 0xfe, 0x92, 0xde, 0x0a, 0x4e, 0x2d, 0x8c, + 0xb1, 0x86, 0xbb, 0x4a, 0x68, 0xe0, 0xa7, 0xee, 0x0e, 0xbf, 0xd7, 0xf1, 0x49, 0x2e, 0x6c, 0x51, + 0xcd, 0x52, 0xa6, 0x4a, 0xe2, 0xe0, 0xc9, 0x5c, 0x55, 0x92, 0x53, 0x2b, 0x94, 0x24, 0x20, 0x73, + 0x21, 0x81, 0xb8, 0xd6, 0xf4, 0x9c, 0x9a, 0x22, 0xf3, 0x84, 0xf0, 0x0c, 0xed, 0xa8, 0x7b, 0x09, + 0x3a, 0xda, 0xee, 0x07, 0x83, 0xbd, 0xe9, 0xe1, 0x17, 0x4a, 0xd2, 0x12, 0xc6, 0xc3, 0x9f, 0x78, + 0x38, 0x6b, 0x34, 0xe1, 0x23, 0xea, 0x0a, 0x69, 0x2c, 0x95, 0x0c, 0x9c, 0x65, 0xd4, 0xf2, 0x71, + 0x2f, 0x57, 0x75, 0x7c, 0xb4, 0xe1, 0x31, 0xfa, 0xbf, 0xcc, 0xdf, 0x70, 0xe1, 0x12, 0xed, 0x52, + 0xce, 0x35, 0x18, 0x13, 0xb5, 0x3d, 0xf9, 0x7a, 0x55, 0xc7, 0xc7, 0xbf, 0x3d, 0x14, 0x65, 0x6c, + 0xad, 0x70, 0xe8, 0x64, 0x03, 0xcd, 0x94, 0x29, 0x95, 0x59, 0x2f, 0x89, 0xe1, 0x37, 0xc4, 0x0f, + 0x2e, 0x9d, 0x30, 0x36, 0x69, 0x14, 0xd9, 0x27, 0x6c, 0x3a, 0x7c, 0x79, 0xed, 0x6d, 0x3d, 0xbf, + 0xf5, 0x82, 0xab, 0xc1, 0xdf, 0xe1, 0x9b, 0x2f, 0x31, 0xeb, 0xf8, 0x19, 0x8f, 0x3e, 0x02, 0x00, + 0x00, 0xff, 0xff, 0x26, 0x68, 0x89, 0x70, 0x23, 0x02, 0x00, 0x00, } func (this *Runner) Equal(that interface{}) bool { @@ -112,13 +112,13 @@ func (this *Runner) Equal(that interface{}) bool { } else if this == nil { return false } - if !this.Hash.Equal(that1.Hash) { + if !bytes.Equal(this.Hash, that1.Hash) { return false } if this.Owner != that1.Owner { return false } - if !this.InstanceHash.Equal(that1.InstanceHash) { + if !bytes.Equal(this.InstanceHash, that1.InstanceHash) { return false } if !bytes.Equal(this.Address, that1.Address) { diff --git a/scripts/build-proto.sh b/scripts/build-proto.sh index 7c5d6a17b..c1fd8da4c 100755 --- a/scripts/build-proto.sh +++ b/scripts/build-proto.sh @@ -1,22 +1,27 @@ #!/bin/bash +# generate modules' msg +protoc --gogo_out=paths=source_relative:. x/service/internal/types/msg.proto +protoc --gogo_out=paths=source_relative:. x/process/internal/types/msg.proto +protoc --gogo_out=paths=source_relative:. x/runner/internal/types/msg.proto +protoc --gogo_out=paths=source_relative:. x/execution/internal/types/msg.proto +protoc --gogo_out=paths=source_relative:. x/ownership/internal/types/msg.proto + +# generate gRPC api +protoc --gogo_out=paths=source_relative,plugins=grpc:. server/grpc/runner/runner.proto +protoc --gogo_out=paths=source_relative,plugins=grpc:. server/grpc/orchestrator/execution.proto +protoc --gogo_out=paths=source_relative,plugins=grpc:. server/grpc/orchestrator/runner.proto +protoc --gogo_out=paths=source_relative,plugins=grpc:. server/grpc/orchestrator/event.proto + TYPES_PATH=protobuf/types -APIS_PATH=protobuf/api # generate type for file in "${TYPES_PATH}"/{event,execution,instance,service,process,ownership,runner}.proto do file=$(basename ${file}) dir="${file%.*}" - protoc --gogo_out=paths=source_relative:"${dir}" --proto_path . --proto_path "${TYPES_PATH}" "${file}" done # generate google type protoc --gogo_out=paths=source_relative:. protobuf/types/struct.proto - -# generate services -for file in "${APIS_PATH}"/{event,execution,instance,service,process,ownership,runner}.proto -do - protoc --gogo_out=plugins=grpc:. --proto_path . "${file}" -done diff --git a/scripts/dev.sh b/scripts/dev.sh index 4dbfd9107..9d1318e8d 100755 --- a/scripts/dev.sh +++ b/scripts/dev.sh @@ -83,7 +83,6 @@ function start_engine { --label com.docker.stack.namespace=$MESG_NAME \ --label com.docker.stack.image=mesg/engine:local \ --env MESG_NAME=$MESG_NAME \ - --mount type=bind,source=/var/run/docker.sock,destination=/var/run/docker.sock \ --mount type=bind,source=$MESG_PATH,destination=/root/.mesg \ --network $MESG_NAME \ --network name=$MESG_TENDERMINT_NETWORK \ diff --git a/scripts/publish-cmds.sh b/scripts/publish-cmds.sh index 999833bed..19a35a14a 100755 --- a/scripts/publish-cmds.sh +++ b/scripts/publish-cmds.sh @@ -6,7 +6,7 @@ if [[ -z "$1" || -z "$2" || ( "$2" != "dev" && "$2" != "prod" ) ]]; then exit 1 fi -LDFLAGS="-s -w -X 'github.com/mesg-foundation/engine/version.Version=$1'" +LDFLAGS="-s -w -X 'github.com/mesg-foundation/engine/version.Version=$1' -X 'github.com/cosmos/cosmos-sdk/version.Name=mesg' -X 'github.com/cosmos/cosmos-sdk/version.ServerName=mesg-daemon' -X 'github.com/cosmos/cosmos-sdk/version.ClientName=mesg-cli' -X 'github.com/cosmos/cosmos-sdk/version.Version=$1'" archs=(amd64 386) oss=(linux darwin) diff --git a/server/grpc/api/event.go b/server/grpc/api/event.go deleted file mode 100644 index 6c918fb32..000000000 --- a/server/grpc/api/event.go +++ /dev/null @@ -1,63 +0,0 @@ -package api - -import ( - "context" - "errors" - "fmt" - - "github.com/mesg-foundation/engine/event" - "github.com/mesg-foundation/engine/event/publisher" - "github.com/mesg-foundation/engine/protobuf/acknowledgement" - "github.com/mesg-foundation/engine/protobuf/api" -) - -// EventServer serve event functions. -type EventServer struct { - ep *publisher.EventPublisher -} - -// NewEventServer creates a new EventServer. -func NewEventServer(ep *publisher.EventPublisher) *EventServer { - return &EventServer{ep: ep} -} - -// Create creates a new event. -func (s *EventServer) Create(ctx context.Context, req *api.CreateEventRequest) (*api.CreateEventResponse, error) { - if req.Key == "" { - return nil, errors.New("create event: key missing") - } - - event, err := s.ep.Publish(req.InstanceHash, req.Key, req.Data) - if err != nil { - return nil, fmt.Errorf("create event: data %s", err) - } - - return &api.CreateEventResponse{Hash: event.Hash}, nil -} - -// Stream returns stream of events. -func (s *EventServer) Stream(req *api.StreamEventRequest, resp api.Event_StreamServer) error { - var f *event.Filter - if req.Filter != nil { - f = &event.Filter{ - Hash: req.Filter.Hash, - InstanceHash: req.Filter.InstanceHash, - Key: req.Filter.Key, - } - } - stream := s.ep.GetStream(f) - defer stream.Close() - - // send header to notify client that the stream is ready. - if err := acknowledgement.SetStreamReady(resp); err != nil { - return err - } - - for event := range stream.C { - if err := resp.Send(event); err != nil { - return err - } - } - - return nil -} diff --git a/server/grpc/api/execution.go b/server/grpc/api/execution.go deleted file mode 100644 index 3ad00307d..000000000 --- a/server/grpc/api/execution.go +++ /dev/null @@ -1,83 +0,0 @@ -package api - -import ( - "context" - - "github.com/mesg-foundation/engine/cosmos" - "github.com/mesg-foundation/engine/execution" - "github.com/mesg-foundation/engine/protobuf/acknowledgement" - "github.com/mesg-foundation/engine/protobuf/api" -) - -// ExecutionServer serve execution functions. -type ExecutionServer struct { - mc *cosmos.ModuleClient - execPrice string -} - -// NewExecutionServer creates a new ExecutionServer. -func NewExecutionServer(mc *cosmos.ModuleClient, execPrice string) *ExecutionServer { - return &ExecutionServer{mc: mc, execPrice: execPrice} -} - -// Create creates an execution. -func (s *ExecutionServer) Create(ctx context.Context, req *api.CreateExecutionRequest) (*api.CreateExecutionResponse, error) { - if req.Price == "" { - req.Price = s.execPrice - } - exec, err := s.mc.CreateExecution(req) - if err != nil { - return nil, err - } - return &api.CreateExecutionResponse{Hash: exec.Hash}, nil -} - -// Get returns execution from given hash. -func (s *ExecutionServer) Get(ctx context.Context, req *api.GetExecutionRequest) (*execution.Execution, error) { - return s.mc.GetExecution(req.Hash) -} - -// Stream returns stream of executions. -func (s *ExecutionServer) Stream(req *api.StreamExecutionRequest, resp api.Execution_StreamServer) error { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - - stream, errC, err := s.mc.StreamExecution(ctx, req) - if err != nil { - return err - } - - if err := acknowledgement.SetStreamReady(resp); err != nil { - return err - } - - for { - select { - case exec := <-stream: - if err := resp.Send(exec); err != nil { - return err - } - case err := <-errC: - return err - case <-resp.Context().Done(): - return resp.Context().Err() - } - } -} - -// Update updates execution from given hash. -func (s *ExecutionServer) Update(ctx context.Context, req *api.UpdateExecutionRequest) (*api.UpdateExecutionResponse, error) { - if _, err := s.mc.UpdateExecution(req); err != nil { - return nil, err - } - return &api.UpdateExecutionResponse{}, nil -} - -// List returns all executions. -func (s *ExecutionServer) List(ctx context.Context, req *api.ListExecutionRequest) (*api.ListExecutionResponse, error) { - executions, err := s.mc.ListExecution() - if err != nil { - return nil, err - } - return &api.ListExecutionResponse{Executions: executions}, nil -} diff --git a/server/grpc/api/instance.go b/server/grpc/api/instance.go deleted file mode 100644 index 14146239d..000000000 --- a/server/grpc/api/instance.go +++ /dev/null @@ -1,33 +0,0 @@ -package api - -import ( - "context" - - "github.com/mesg-foundation/engine/cosmos" - instancepb "github.com/mesg-foundation/engine/instance" - protobuf_api "github.com/mesg-foundation/engine/protobuf/api" -) - -// InstanceServer is the type to aggregate all Instance APIs. -type InstanceServer struct { - mc *cosmos.ModuleClient -} - -// NewInstanceServer creates a new ServiceServer. -func NewInstanceServer(mc *cosmos.ModuleClient) *InstanceServer { - return &InstanceServer{mc: mc} -} - -// List instances. -func (s *InstanceServer) List(ctx context.Context, req *protobuf_api.ListInstanceRequest) (*protobuf_api.ListInstanceResponse, error) { - out, err := s.mc.ListInstance(req) - if err != nil { - return nil, err - } - return &protobuf_api.ListInstanceResponse{Instances: out}, nil -} - -// Get retrives instance. -func (s *InstanceServer) Get(ctx context.Context, req *protobuf_api.GetInstanceRequest) (*instancepb.Instance, error) { - return s.mc.GetInstance(req.Hash) -} diff --git a/server/grpc/api/ownership.go b/server/grpc/api/ownership.go deleted file mode 100644 index 9a0803de0..000000000 --- a/server/grpc/api/ownership.go +++ /dev/null @@ -1,27 +0,0 @@ -package api - -import ( - "context" - - "github.com/mesg-foundation/engine/cosmos" - "github.com/mesg-foundation/engine/protobuf/api" -) - -// OwnershipServer is the type to aggregate all Ownership APIs. -type OwnershipServer struct { - mc *cosmos.ModuleClient -} - -// NewOwnershipServer creates a new OwnershipServer. -func NewOwnershipServer(mc *cosmos.ModuleClient) *OwnershipServer { - return &OwnershipServer{mc: mc} -} - -// List returns all ownerships. -func (s *OwnershipServer) List(ctx context.Context, req *api.ListOwnershipRequest) (*api.ListOwnershipResponse, error) { - out, err := s.mc.ListOwnership() - if err != nil { - return nil, err - } - return &api.ListOwnershipResponse{Ownerships: out}, nil -} diff --git a/server/grpc/api/process.go b/server/grpc/api/process.go deleted file mode 100644 index 6434b39c0..000000000 --- a/server/grpc/api/process.go +++ /dev/null @@ -1,47 +0,0 @@ -package api - -import ( - "context" - - "github.com/mesg-foundation/engine/cosmos" - "github.com/mesg-foundation/engine/process" - "github.com/mesg-foundation/engine/protobuf/api" -) - -// ProcessServer is the type to aggregate all Service APIs. -type ProcessServer struct { - mc *cosmos.ModuleClient -} - -// NewProcessServer creates a new ProcessServer. -func NewProcessServer(mc *cosmos.ModuleClient) *ProcessServer { - return &ProcessServer{mc: mc} -} - -// Create creates a new process. -func (s *ProcessServer) Create(ctx context.Context, req *api.CreateProcessRequest) (*api.CreateProcessResponse, error) { - wf, err := s.mc.CreateProcess(req) - if err != nil { - return nil, err - } - return &api.CreateProcessResponse{Hash: wf.Hash}, nil -} - -// Delete deletes process by hash or sid. -func (s *ProcessServer) Delete(ctx context.Context, req *api.DeleteProcessRequest) (*api.DeleteProcessResponse, error) { - return &api.DeleteProcessResponse{}, s.mc.DeleteProcess(req) -} - -// Get returns process from given hash. -func (s *ProcessServer) Get(ctx context.Context, req *api.GetProcessRequest) (*process.Process, error) { - return s.mc.GetProcess(req.Hash) -} - -// List returns all processes. -func (s *ProcessServer) List(ctx context.Context, req *api.ListProcessRequest) (*api.ListProcessResponse, error) { - processes, err := s.mc.ListProcess() - if err != nil { - return nil, err - } - return &api.ListProcessResponse{Processes: processes}, nil -} diff --git a/server/grpc/api/runner.go b/server/grpc/api/runner.go deleted file mode 100644 index e7a1325da..000000000 --- a/server/grpc/api/runner.go +++ /dev/null @@ -1,63 +0,0 @@ -package api - -import ( - "context" - - "github.com/mesg-foundation/engine/cosmos" - "github.com/mesg-foundation/engine/protobuf/api" - "github.com/mesg-foundation/engine/runner" - "github.com/mesg-foundation/engine/runner/builder" -) - -// RunnerServer is the type to aggregate all Runner APIs. -type RunnerServer struct { - mc *cosmos.ModuleClient - b *builder.Builder -} - -// NewRunnerServer creates a new RunnerServer. -func NewRunnerServer(mc *cosmos.ModuleClient, b *builder.Builder) *RunnerServer { - return &RunnerServer{ - mc: mc, - b: b, - } -} - -// Create creates a new runner. -func (s *RunnerServer) Create(ctx context.Context, req *api.CreateRunnerRequest) (*api.CreateRunnerResponse, error) { - r, err := s.b.Create(req) - if err != nil { - return nil, err - } - return &api.CreateRunnerResponse{Hash: r.Hash}, nil -} - -// Delete deletes a runner. -func (s *RunnerServer) Delete(ctx context.Context, req *api.DeleteRunnerRequest) (*api.DeleteRunnerResponse, error) { - if err := s.b.Delete(req); err != nil { - return nil, err - } - return &api.DeleteRunnerResponse{}, nil -} - -// Get returns runner from given hash. -func (s *RunnerServer) Get(ctx context.Context, req *api.GetRunnerRequest) (*runner.Runner, error) { - return s.mc.GetRunner(req.Hash) -} - -// List returns all runners. -func (s *RunnerServer) List(ctx context.Context, req *api.ListRunnerRequest) (*api.ListRunnerResponse, error) { - var f *cosmos.FilterRunner - if req.Filter != nil { - f = &cosmos.FilterRunner{ - Owner: req.Filter.Owner, - InstanceHash: req.Filter.InstanceHash, - } - } - runners, err := s.mc.ListRunner(f) - if err != nil { - return nil, err - } - - return &api.ListRunnerResponse{Runners: runners}, nil -} diff --git a/server/grpc/api/service.go b/server/grpc/api/service.go deleted file mode 100644 index 63cf2970c..000000000 --- a/server/grpc/api/service.go +++ /dev/null @@ -1,61 +0,0 @@ -package api - -import ( - "context" - - "github.com/mesg-foundation/engine/cosmos" - protobuf_api "github.com/mesg-foundation/engine/protobuf/api" - "github.com/mesg-foundation/engine/service" -) - -// ServiceServer is the type to aggregate all Service APIs. -type ServiceServer struct { - mc *cosmos.ModuleClient -} - -// NewServiceServer creates a new ServiceServer. -func NewServiceServer(mc *cosmos.ModuleClient) *ServiceServer { - return &ServiceServer{mc: mc} -} - -// Create creates a new service from definition. -func (s *ServiceServer) Create(ctx context.Context, req *protobuf_api.CreateServiceRequest) (*protobuf_api.CreateServiceResponse, error) { - srv, err := s.mc.CreateService(req) - if err != nil { - return nil, err - } - return &protobuf_api.CreateServiceResponse{Hash: srv.Hash}, nil -} - -// Get returns service from given hash. -func (s *ServiceServer) Get(ctx context.Context, req *protobuf_api.GetServiceRequest) (*service.Service, error) { - return s.mc.GetService(req.Hash) -} - -// List returns all services. -func (s *ServiceServer) List(ctx context.Context, req *protobuf_api.ListServiceRequest) (*protobuf_api.ListServiceResponse, error) { - services, err := s.mc.ListService() - if err != nil { - return nil, err - } - - return &protobuf_api.ListServiceResponse{Services: services}, nil -} - -// Exists returns if a service already exists. -func (s *ServiceServer) Exists(ctx context.Context, req *protobuf_api.ExistsServiceRequest) (*protobuf_api.ExistsServiceResponse, error) { - exist, err := s.mc.ExistService(req.Hash) - if err != nil { - return nil, err - } - return &protobuf_api.ExistsServiceResponse{Exists: exist}, nil -} - -// Hash returns the calculated hash of a service request. -func (s *ServiceServer) Hash(ctx context.Context, req *protobuf_api.CreateServiceRequest) (*protobuf_api.HashServiceResponse, error) { - h, err := s.mc.HashService(req) - if err != nil { - return nil, err - } - return &protobuf_api.HashServiceResponse{Hash: h}, nil -} diff --git a/server/grpc/orchestrator/authorizer.go b/server/grpc/orchestrator/authorizer.go new file mode 100644 index 000000000..c14ce6c0f --- /dev/null +++ b/server/grpc/orchestrator/authorizer.go @@ -0,0 +1,74 @@ +package orchestrator + +import ( + "context" + "encoding/base64" + "fmt" + + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/tendermint/tendermint/crypto" + "google.golang.org/grpc/metadata" +) + +// RequestSignature is the name of the key to use in the gRPC metadata to set the request signature. +const RequestSignature = "mesg_request_signature" + +// Authorizer is the type to aggregate all Admin APIs. +type Authorizer struct { + cdc *codec.Codec + authorizedPubKeys []crypto.PubKey +} + +// NewAuthorizer creates a new Authorizer. +func NewAuthorizer(cdc *codec.Codec, authorizedPubKeys []string) (*Authorizer, error) { + // decode public keys + pks := make([]crypto.PubKey, 0) + for _, pkS := range authorizedPubKeys { + pk, err := sdk.GetPubKeyFromBech32(sdk.Bech32PubKeyTypeAccPub, pkS) + if err != nil { + return nil, err + } + pks = append(pks, pk) + } + + return &Authorizer{ + cdc: cdc, + authorizedPubKeys: pks, + }, nil +} + +// IsAuthorized checks the context for a signature signed by one of the authorizedPubKeys. +func (a *Authorizer) IsAuthorized(ctx context.Context, payload interface{}) error { + md, ok := metadata.FromIncomingContext(ctx) + if !ok { + return fmt.Errorf("signature not found in metadata, make sure to set it using the key %q", RequestSignature) + } + if len(md[RequestSignature]) == 0 { + return fmt.Errorf("signature not found in metadata, make sure to set it using the key %q", RequestSignature) + } + signature := md[RequestSignature][0] + signatureBytes, err := base64.StdEncoding.DecodeString(signature) + if err != nil { + return err + } + encodedValue, err := a.cdc.MarshalJSON(payload) + if err != nil { + return err + } + encodedValueSorted, err := sdk.SortJSON(encodedValue) + if err != nil { + return err + } + isAuthorized := false + for _, authorizedPubKey := range a.authorizedPubKeys { + if authorizedPubKey.VerifyBytes(encodedValueSorted, signatureBytes) { + isAuthorized = true + break + } + } + if !isAuthorized { + return fmt.Errorf("verification of the signature failed") + } + return nil +} diff --git a/server/grpc/orchestrator/event.go b/server/grpc/orchestrator/event.go new file mode 100644 index 000000000..b319d3530 --- /dev/null +++ b/server/grpc/orchestrator/event.go @@ -0,0 +1,55 @@ +package orchestrator + +import ( + "github.com/mesg-foundation/engine/event" + "github.com/mesg-foundation/engine/event/publisher" + "github.com/mesg-foundation/engine/protobuf/acknowledgement" +) + +type eventServer struct { + eventPublisher *publisher.EventPublisher + auth *Authorizer +} + +// NewEventServer creates a new Event Server. +func NewEventServer(eventPublisher *publisher.EventPublisher, auth *Authorizer) EventServer { + return &eventServer{ + eventPublisher: eventPublisher, + auth: auth, + } +} + +// Stream returns stream of events. +func (s *eventServer) Stream(req *EventStreamRequest, stream Event_StreamServer) error { + // check authorization + if err := s.auth.IsAuthorized(stream.Context(), req); err != nil { + return err + } + + var f *event.Filter + if req.Filter != nil { + f = &event.Filter{ + Hash: req.Filter.Hash, + InstanceHash: req.Filter.InstanceHash, + Key: req.Filter.Key, + } + } + eventStream := s.eventPublisher.GetStream(f) + defer eventStream.Close() + + // send header to notify client that the stream is ready. + if err := acknowledgement.SetStreamReady(stream); err != nil { + return err + } + + for { + select { + case event := <-eventStream.C: + if err := stream.Send(event); err != nil { + return err + } + case <-stream.Context().Done(): + return stream.Context().Err() + } + } +} diff --git a/server/grpc/orchestrator/event.pb.go b/server/grpc/orchestrator/event.pb.go new file mode 100644 index 000000000..02704b00d --- /dev/null +++ b/server/grpc/orchestrator/event.pb.go @@ -0,0 +1,270 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: server/grpc/orchestrator/event.proto + +package orchestrator + +import ( + context "context" + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + event "github.com/mesg-foundation/engine/event" + github_com_mesg_foundation_engine_hash "github.com/mesg-foundation/engine/hash" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + math "math" +) + +// 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 + +// Stream returns a stream of events that satisfy specified filter. +type EventStreamRequest struct { + // Filter used to filter a stream of events. + Filter *EventStreamRequest_Filter `protobuf:"bytes,1,opt,name=filter,proto3" json:"filter,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *EventStreamRequest) Reset() { *m = EventStreamRequest{} } +func (m *EventStreamRequest) String() string { return proto.CompactTextString(m) } +func (*EventStreamRequest) ProtoMessage() {} +func (*EventStreamRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_ffc57e99336b2294, []int{0} +} +func (m *EventStreamRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_EventStreamRequest.Unmarshal(m, b) +} +func (m *EventStreamRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_EventStreamRequest.Marshal(b, m, deterministic) +} +func (m *EventStreamRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventStreamRequest.Merge(m, src) +} +func (m *EventStreamRequest) XXX_Size() int { + return xxx_messageInfo_EventStreamRequest.Size(m) +} +func (m *EventStreamRequest) XXX_DiscardUnknown() { + xxx_messageInfo_EventStreamRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_EventStreamRequest proto.InternalMessageInfo + +func (m *EventStreamRequest) GetFilter() *EventStreamRequest_Filter { + if m != nil { + return m.Filter + } + return nil +} + +// Filter contains filtering criteria. +type EventStreamRequest_Filter struct { + // hash to filter events. + Hash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=hash,proto3,casttype=github.com/mesg-foundation/engine/hash.Hash" json:"hash,omitempty" validate:"omitempty,hash"` + // instance's hash to filter events. + InstanceHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,2,opt,name=instanceHash,proto3,casttype=github.com/mesg-foundation/engine/hash.Hash" json:"instanceHash,omitempty" validate:"omitempty,hash"` + // key is the key of the event. + Key string `protobuf:"bytes,3,opt,name=key,proto3" json:"key,omitempty" validate:"printascii"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *EventStreamRequest_Filter) Reset() { *m = EventStreamRequest_Filter{} } +func (m *EventStreamRequest_Filter) String() string { return proto.CompactTextString(m) } +func (*EventStreamRequest_Filter) ProtoMessage() {} +func (*EventStreamRequest_Filter) Descriptor() ([]byte, []int) { + return fileDescriptor_ffc57e99336b2294, []int{0, 0} +} +func (m *EventStreamRequest_Filter) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_EventStreamRequest_Filter.Unmarshal(m, b) +} +func (m *EventStreamRequest_Filter) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_EventStreamRequest_Filter.Marshal(b, m, deterministic) +} +func (m *EventStreamRequest_Filter) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventStreamRequest_Filter.Merge(m, src) +} +func (m *EventStreamRequest_Filter) XXX_Size() int { + return xxx_messageInfo_EventStreamRequest_Filter.Size(m) +} +func (m *EventStreamRequest_Filter) XXX_DiscardUnknown() { + xxx_messageInfo_EventStreamRequest_Filter.DiscardUnknown(m) +} + +var xxx_messageInfo_EventStreamRequest_Filter proto.InternalMessageInfo + +func (m *EventStreamRequest_Filter) GetHash() github_com_mesg_foundation_engine_hash.Hash { + if m != nil { + return m.Hash + } + return nil +} + +func (m *EventStreamRequest_Filter) GetInstanceHash() github_com_mesg_foundation_engine_hash.Hash { + if m != nil { + return m.InstanceHash + } + return nil +} + +func (m *EventStreamRequest_Filter) GetKey() string { + if m != nil { + return m.Key + } + return "" +} + +func init() { + proto.RegisterType((*EventStreamRequest)(nil), "mesg.grpc.orchestrator.EventStreamRequest") + proto.RegisterType((*EventStreamRequest_Filter)(nil), "mesg.grpc.orchestrator.EventStreamRequest.Filter") +} + +func init() { + proto.RegisterFile("server/grpc/orchestrator/event.proto", fileDescriptor_ffc57e99336b2294) +} + +var fileDescriptor_ffc57e99336b2294 = []byte{ + // 346 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x92, 0xb1, 0x4e, 0xe3, 0x40, + 0x10, 0x86, 0xcf, 0xc9, 0x9d, 0xa5, 0xdb, 0x4b, 0x73, 0x2b, 0xdd, 0x29, 0x71, 0x93, 0xc8, 0xa2, + 0x88, 0x08, 0xec, 0x42, 0xe8, 0x40, 0x34, 0x91, 0x40, 0x20, 0xa8, 0x0c, 0x15, 0x15, 0x1b, 0x67, + 0x62, 0xaf, 0x88, 0x77, 0xcd, 0xee, 0x38, 0x52, 0x1e, 0x81, 0x97, 0xcc, 0x0b, 0xd0, 0xa5, 0xa4, + 0x42, 0xbb, 0x46, 0x10, 0x14, 0x24, 0x68, 0xe8, 0x3c, 0x33, 0xdf, 0xfc, 0xbf, 0x35, 0xfb, 0x93, + 0x2d, 0x0b, 0x66, 0x0e, 0x86, 0x67, 0xa6, 0x4c, 0xb9, 0x36, 0x69, 0x0e, 0x16, 0x8d, 0x40, 0x6d, + 0x38, 0xcc, 0x41, 0x21, 0x2b, 0x8d, 0x46, 0x4d, 0xff, 0x17, 0x60, 0x33, 0xe6, 0x18, 0xb6, 0xce, + 0x44, 0x71, 0xa6, 0x33, 0xcd, 0x3d, 0x33, 0xae, 0xa6, 0xdc, 0x55, 0xbe, 0xf0, 0x5f, 0xf5, 0x6e, + 0x14, 0xbd, 0x8e, 0x71, 0x51, 0x82, 0x5d, 0xd7, 0x8d, 0x1f, 0x1b, 0x84, 0x9e, 0xb8, 0xfa, 0x0a, + 0x0d, 0x88, 0x22, 0x81, 0xfb, 0x0a, 0x2c, 0xd2, 0x73, 0x12, 0x4e, 0xe5, 0x0c, 0xc1, 0xb4, 0x83, + 0x5e, 0xd0, 0xff, 0x33, 0xdc, 0x67, 0x1f, 0xfb, 0xb3, 0xcd, 0x5d, 0x76, 0xea, 0x17, 0x93, 0x17, + 0x81, 0xe8, 0xa1, 0x41, 0xc2, 0xba, 0x45, 0x6f, 0xc9, 0xcf, 0x5c, 0xd8, 0xdc, 0x6b, 0xb6, 0x46, + 0x97, 0xab, 0x65, 0xb7, 0x33, 0x17, 0x33, 0x39, 0x11, 0x08, 0x87, 0xb1, 0x2e, 0x24, 0x42, 0x51, + 0xe2, 0x62, 0xc7, 0x31, 0xf1, 0xd3, 0xb2, 0x3b, 0xc8, 0x24, 0xe6, 0xd5, 0x98, 0xa5, 0xba, 0xe0, + 0xce, 0x7e, 0x77, 0xaa, 0x2b, 0x35, 0x11, 0x28, 0xb5, 0xe2, 0xa0, 0x32, 0xa9, 0x80, 0x3b, 0x94, + 0x9d, 0x09, 0x9b, 0x27, 0x5e, 0x99, 0x96, 0xa4, 0x25, 0x95, 0x45, 0xa1, 0x52, 0x70, 0xdd, 0x76, + 0xe3, 0x1b, 0x9c, 0xde, 0x39, 0xd0, 0x01, 0x69, 0xde, 0xc1, 0xa2, 0xdd, 0xec, 0x05, 0xfd, 0xdf, + 0xa3, 0xce, 0x6a, 0xd9, 0xfd, 0xf7, 0x66, 0x54, 0x1a, 0xa9, 0x50, 0xd8, 0x54, 0xca, 0x38, 0x71, + 0xd4, 0xf0, 0x9a, 0xfc, 0xf2, 0x07, 0xa3, 0x17, 0x24, 0xac, 0x8f, 0x46, 0xb7, 0xbf, 0x7e, 0xd9, + 0xe8, 0x6f, 0xcd, 0xfa, 0x57, 0xac, 0xe7, 0xf1, 0x8f, 0xbd, 0x60, 0x74, 0x7c, 0x73, 0xf4, 0xf9, + 0xff, 0xbb, 0x94, 0xc9, 0x14, 0x36, 0x63, 0x36, 0x0e, 0x7d, 0x12, 0x0e, 0x9e, 0x03, 0x00, 0x00, + 0xff, 0xff, 0x3a, 0x31, 0xc6, 0xad, 0x89, 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 + +// EventClient is the client API for Event service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type EventClient interface { + // Stream returns a stream of events that satisfy criteria specified. + Stream(ctx context.Context, in *EventStreamRequest, opts ...grpc.CallOption) (Event_StreamClient, error) +} + +type eventClient struct { + cc *grpc.ClientConn +} + +func NewEventClient(cc *grpc.ClientConn) EventClient { + return &eventClient{cc} +} + +func (c *eventClient) Stream(ctx context.Context, in *EventStreamRequest, opts ...grpc.CallOption) (Event_StreamClient, error) { + stream, err := c.cc.NewStream(ctx, &_Event_serviceDesc.Streams[0], "/mesg.grpc.orchestrator.Event/Stream", opts...) + if err != nil { + return nil, err + } + x := &eventStreamClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type Event_StreamClient interface { + Recv() (*event.Event, error) + grpc.ClientStream +} + +type eventStreamClient struct { + grpc.ClientStream +} + +func (x *eventStreamClient) Recv() (*event.Event, error) { + m := new(event.Event) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// EventServer is the server API for Event service. +type EventServer interface { + // Stream returns a stream of events that satisfy criteria specified. + Stream(*EventStreamRequest, Event_StreamServer) error +} + +// UnimplementedEventServer can be embedded to have forward compatible implementations. +type UnimplementedEventServer struct { +} + +func (*UnimplementedEventServer) Stream(req *EventStreamRequest, srv Event_StreamServer) error { + return status.Errorf(codes.Unimplemented, "method Stream not implemented") +} + +func RegisterEventServer(s *grpc.Server, srv EventServer) { + s.RegisterService(&_Event_serviceDesc, srv) +} + +func _Event_Stream_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(EventStreamRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(EventServer).Stream(m, &eventStreamServer{stream}) +} + +type Event_StreamServer interface { + Send(*event.Event) error + grpc.ServerStream +} + +type eventStreamServer struct { + grpc.ServerStream +} + +func (x *eventStreamServer) Send(m *event.Event) error { + return x.ServerStream.SendMsg(m) +} + +var _Event_serviceDesc = grpc.ServiceDesc{ + ServiceName: "mesg.grpc.orchestrator.Event", + HandlerType: (*EventServer)(nil), + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{ + { + StreamName: "Stream", + Handler: _Event_Stream_Handler, + ServerStreams: true, + }, + }, + Metadata: "server/grpc/orchestrator/event.proto", +} diff --git a/server/grpc/orchestrator/event.proto b/server/grpc/orchestrator/event.proto new file mode 100644 index 000000000..44cd2a199 --- /dev/null +++ b/server/grpc/orchestrator/event.proto @@ -0,0 +1,40 @@ +syntax = "proto3"; + +import "gogo/protobuf/gogoproto/gogo.proto"; +import "protobuf/types/event.proto"; + +package mesg.grpc.orchestrator; +option go_package = "github.com/mesg-foundation/engine/service/grpc/orchestrator"; + +// This is the Event API to interact with the Orchestrator. +// This API requires all requests to be signed for authentication. The signature should be passed in the request's metadata using the key `mesg_request_signature` and base64 encoded. +service Event { + // Stream returns a stream of events that satisfy criteria specified. + rpc Stream(EventStreamRequest) returns (stream types.Event) {} +} + +// Stream returns a stream of events that satisfy specified filter. +message EventStreamRequest { + // Filter contains filtering criteria. + message Filter { + // hash to filter events. + bytes hash = 1 [ + (gogoproto.moretags) = 'validate:"omitempty,hash"', + (gogoproto.casttype) = "github.com/mesg-foundation/engine/hash.Hash" + ]; + + // instance's hash to filter events. + bytes instanceHash = 2 [ + (gogoproto.moretags) = 'validate:"omitempty,hash"', + (gogoproto.casttype) = "github.com/mesg-foundation/engine/hash.Hash" + ]; + + // key is the key of the event. + string key = 3 [ + (gogoproto.moretags) = 'validate:"printascii"' + ]; + } + + // Filter used to filter a stream of events. + Filter filter = 1; +} diff --git a/server/grpc/orchestrator/execution.go b/server/grpc/orchestrator/execution.go new file mode 100644 index 000000000..8261d917e --- /dev/null +++ b/server/grpc/orchestrator/execution.go @@ -0,0 +1,151 @@ +package orchestrator + +import ( + "context" + fmt "fmt" + + "github.com/mesg-foundation/engine/cosmos" + "github.com/mesg-foundation/engine/execution" + "github.com/mesg-foundation/engine/ext/xstrings" + "github.com/mesg-foundation/engine/hash" + "github.com/mesg-foundation/engine/protobuf/acknowledgement" + executionmodule "github.com/mesg-foundation/engine/x/execution" +) + +type executionServer struct { + rpc *cosmos.RPC + auth *Authorizer +} + +// NewExecutionServer creates a new Execution Server. +func NewExecutionServer(rpc *cosmos.RPC, auth *Authorizer) ExecutionServer { + return &executionServer{ + rpc: rpc, + auth: auth, + } +} + +// Create creates an execution. +func (s *executionServer) Create(ctx context.Context, req *ExecutionCreateRequest) (*ExecutionCreateResponse, error) { + // check authorization + if err := s.auth.IsAuthorized(ctx, req); err != nil { + return nil, err + } + + // create execution + acc, err := s.rpc.GetAccount() + if err != nil { + return nil, err + } + eventHash, err := hash.Random() + if err != nil { + return nil, err + } + msg := executionmodule.MsgCreate{ + Signer: acc.GetAddress(), + EventHash: eventHash, + ExecutorHash: req.ExecutorHash, + Inputs: req.Inputs, + Price: req.Price, + Tags: req.Tags, + TaskKey: req.TaskKey, + } + tx, err := s.rpc.BuildAndBroadcastMsg(msg) + if err != nil { + return nil, err + } + return &ExecutionCreateResponse{ + Hash: tx.Data, + }, nil +} + +// Stream returns stream of executions. +func (s *executionServer) Stream(req *ExecutionStreamRequest, stream Execution_StreamServer) error { + // check authorization + if err := s.auth.IsAuthorized(stream.Context(), req); err != nil { + return err + } + + // create rpc event stream + ctx, cancel := context.WithCancel(stream.Context()) + defer cancel() + subscriber := xstrings.RandASCIILetters(8) + query := fmt.Sprintf("%s.%s EXISTS", executionmodule.EventType, executionmodule.AttributeKeyHash) + eventStream, err := s.rpc.Subscribe(ctx, subscriber, query, 0) + defer s.rpc.Unsubscribe(context.Background(), subscriber, query) + if err != nil { + return err + } + if err := acknowledgement.SetStreamReady(stream); err != nil { + return err + } + + // listen to event stream + for { + select { + case event := <-eventStream: + attrHash := fmt.Sprintf("%s.%s", executionmodule.EventType, executionmodule.AttributeKeyHash) + attrs := event.Events[attrHash] + alreadySeeHashes := make(map[string]bool) + for _, attr := range attrs { + // skip already see hash. it deduplicate same execution in multiple event. + if alreadySeeHashes[attr] { + continue + } + alreadySeeHashes[attr] = true + hash, err := hash.Decode(attr) + if err != nil { + return err + } + var exec *execution.Execution + route := fmt.Sprintf("custom/%s/%s/%s", executionmodule.QuerierRoute, executionmodule.QueryGet, hash) + if err := s.rpc.QueryJSON(route, nil, &exec); err != nil { + return err + } + if !req.Filter.Match(exec) { + continue + } + if err := stream.Send(exec); err != nil { + return err + } + } + case <-ctx.Done(): + return ctx.Err() + case <-stream.Context().Done(): + return stream.Context().Err() + } + } +} + +// Match matches given execution with filter criteria. +func (f *ExecutionStreamRequest_Filter) Match(e *execution.Execution) bool { + if f == nil { + return true + } + if !f.ExecutorHash.IsZero() && !f.ExecutorHash.Equal(e.ExecutorHash) { + return false + } + if !f.InstanceHash.IsZero() && !f.InstanceHash.Equal(e.InstanceHash) { + return false + } + if f.TaskKey != "" && f.TaskKey != "*" && f.TaskKey != e.TaskKey { + return false + } + + match := len(f.Statuses) == 0 + for _, status := range f.Statuses { + if status == e.Status { + match = true + break + } + } + if !match { + return false + } + for _, tag := range f.Tags { + if !xstrings.SliceContains(e.Tags, tag) { + return false + } + } + return true +} diff --git a/server/grpc/orchestrator/execution.pb.go b/server/grpc/orchestrator/execution.pb.go new file mode 100644 index 000000000..4057136e6 --- /dev/null +++ b/server/grpc/orchestrator/execution.pb.go @@ -0,0 +1,454 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: server/grpc/orchestrator/execution.proto + +package orchestrator + +import ( + context "context" + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + execution "github.com/mesg-foundation/engine/execution" + github_com_mesg_foundation_engine_hash "github.com/mesg-foundation/engine/hash" + types "github.com/mesg-foundation/engine/protobuf/types" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + math "math" +) + +// 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 + +// ExecutionCreateRequest is the request of the endpoint ExecutionCreate. +type ExecutionCreateRequest struct { + TaskKey string `protobuf:"bytes,1,opt,name=taskKey,proto3" json:"taskKey,omitempty" validate:"required,printascii"` + Inputs *types.Struct `protobuf:"bytes,2,opt,name=inputs,proto3" json:"inputs,omitempty"` + Tags []string `protobuf:"bytes,3,rep,name=tags,proto3" json:"tags,omitempty" validate:"dive,printascii"` + ExecutorHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,4,opt,name=executorHash,proto3,casttype=github.com/mesg-foundation/engine/hash.Hash" json:"executorHash,omitempty" validate:"omitempty,hash"` + Price string `protobuf:"bytes,5,opt,name=price,proto3" json:"price,omitempty" validate:"coins"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ExecutionCreateRequest) Reset() { *m = ExecutionCreateRequest{} } +func (m *ExecutionCreateRequest) String() string { return proto.CompactTextString(m) } +func (*ExecutionCreateRequest) ProtoMessage() {} +func (*ExecutionCreateRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_9756b90bba6be877, []int{0} +} +func (m *ExecutionCreateRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ExecutionCreateRequest.Unmarshal(m, b) +} +func (m *ExecutionCreateRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ExecutionCreateRequest.Marshal(b, m, deterministic) +} +func (m *ExecutionCreateRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_ExecutionCreateRequest.Merge(m, src) +} +func (m *ExecutionCreateRequest) XXX_Size() int { + return xxx_messageInfo_ExecutionCreateRequest.Size(m) +} +func (m *ExecutionCreateRequest) XXX_DiscardUnknown() { + xxx_messageInfo_ExecutionCreateRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_ExecutionCreateRequest proto.InternalMessageInfo + +func (m *ExecutionCreateRequest) GetTaskKey() string { + if m != nil { + return m.TaskKey + } + return "" +} + +func (m *ExecutionCreateRequest) GetInputs() *types.Struct { + if m != nil { + return m.Inputs + } + return nil +} + +func (m *ExecutionCreateRequest) GetTags() []string { + if m != nil { + return m.Tags + } + return nil +} + +func (m *ExecutionCreateRequest) GetExecutorHash() github_com_mesg_foundation_engine_hash.Hash { + if m != nil { + return m.ExecutorHash + } + return nil +} + +func (m *ExecutionCreateRequest) GetPrice() string { + if m != nil { + return m.Price + } + return "" +} + +// ExecutionCreateResponse is the response of the endpoint ExecutionCreate. +type ExecutionCreateResponse struct { + // Execution's hash. + Hash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=hash,proto3,casttype=github.com/mesg-foundation/engine/hash.Hash" json:"hash,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ExecutionCreateResponse) Reset() { *m = ExecutionCreateResponse{} } +func (m *ExecutionCreateResponse) String() string { return proto.CompactTextString(m) } +func (*ExecutionCreateResponse) ProtoMessage() {} +func (*ExecutionCreateResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_9756b90bba6be877, []int{1} +} +func (m *ExecutionCreateResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ExecutionCreateResponse.Unmarshal(m, b) +} +func (m *ExecutionCreateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ExecutionCreateResponse.Marshal(b, m, deterministic) +} +func (m *ExecutionCreateResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_ExecutionCreateResponse.Merge(m, src) +} +func (m *ExecutionCreateResponse) XXX_Size() int { + return xxx_messageInfo_ExecutionCreateResponse.Size(m) +} +func (m *ExecutionCreateResponse) XXX_DiscardUnknown() { + xxx_messageInfo_ExecutionCreateResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_ExecutionCreateResponse proto.InternalMessageInfo + +func (m *ExecutionCreateResponse) GetHash() github_com_mesg_foundation_engine_hash.Hash { + if m != nil { + return m.Hash + } + return nil +} + +// ExecutionStreamRequest defines request to retrieve a stream of executions. +type ExecutionStreamRequest struct { + // Filter used to filter a stream of executions. + Filter *ExecutionStreamRequest_Filter `protobuf:"bytes,1,opt,name=filter,proto3" json:"filter,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ExecutionStreamRequest) Reset() { *m = ExecutionStreamRequest{} } +func (m *ExecutionStreamRequest) String() string { return proto.CompactTextString(m) } +func (*ExecutionStreamRequest) ProtoMessage() {} +func (*ExecutionStreamRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_9756b90bba6be877, []int{2} +} +func (m *ExecutionStreamRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ExecutionStreamRequest.Unmarshal(m, b) +} +func (m *ExecutionStreamRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ExecutionStreamRequest.Marshal(b, m, deterministic) +} +func (m *ExecutionStreamRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_ExecutionStreamRequest.Merge(m, src) +} +func (m *ExecutionStreamRequest) XXX_Size() int { + return xxx_messageInfo_ExecutionStreamRequest.Size(m) +} +func (m *ExecutionStreamRequest) XXX_DiscardUnknown() { + xxx_messageInfo_ExecutionStreamRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_ExecutionStreamRequest proto.InternalMessageInfo + +func (m *ExecutionStreamRequest) GetFilter() *ExecutionStreamRequest_Filter { + if m != nil { + return m.Filter + } + return nil +} + +// Filter contains filtering criteria. +type ExecutionStreamRequest_Filter struct { + // Statuses to filter executions. One status needs to be present in the execution. + Statuses []execution.Status `protobuf:"varint,1,rep,packed,name=statuses,proto3,enum=mesg.types.Status" json:"statuses,omitempty"` + // Instance's hash to filter executions. + InstanceHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,2,opt,name=instanceHash,proto3,casttype=github.com/mesg-foundation/engine/hash.Hash" json:"instanceHash,omitempty" validate:"omitempty,hash"` + // taskKey to filter executions. + TaskKey string `protobuf:"bytes,3,opt,name=taskKey,proto3" json:"taskKey,omitempty" validate:"printascii"` + // tags to filter executions. All tags needs to be present in the execution. + Tags []string `protobuf:"bytes,4,rep,name=tags,proto3" json:"tags,omitempty" validate:"dive,printascii"` + // Executor's hash to filter executions. + ExecutorHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,5,opt,name=executorHash,proto3,casttype=github.com/mesg-foundation/engine/hash.Hash" json:"executorHash,omitempty" validate:"omitempty,hash"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ExecutionStreamRequest_Filter) Reset() { *m = ExecutionStreamRequest_Filter{} } +func (m *ExecutionStreamRequest_Filter) String() string { return proto.CompactTextString(m) } +func (*ExecutionStreamRequest_Filter) ProtoMessage() {} +func (*ExecutionStreamRequest_Filter) Descriptor() ([]byte, []int) { + return fileDescriptor_9756b90bba6be877, []int{2, 0} +} +func (m *ExecutionStreamRequest_Filter) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ExecutionStreamRequest_Filter.Unmarshal(m, b) +} +func (m *ExecutionStreamRequest_Filter) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ExecutionStreamRequest_Filter.Marshal(b, m, deterministic) +} +func (m *ExecutionStreamRequest_Filter) XXX_Merge(src proto.Message) { + xxx_messageInfo_ExecutionStreamRequest_Filter.Merge(m, src) +} +func (m *ExecutionStreamRequest_Filter) XXX_Size() int { + return xxx_messageInfo_ExecutionStreamRequest_Filter.Size(m) +} +func (m *ExecutionStreamRequest_Filter) XXX_DiscardUnknown() { + xxx_messageInfo_ExecutionStreamRequest_Filter.DiscardUnknown(m) +} + +var xxx_messageInfo_ExecutionStreamRequest_Filter proto.InternalMessageInfo + +func (m *ExecutionStreamRequest_Filter) GetStatuses() []execution.Status { + if m != nil { + return m.Statuses + } + return nil +} + +func (m *ExecutionStreamRequest_Filter) GetInstanceHash() github_com_mesg_foundation_engine_hash.Hash { + if m != nil { + return m.InstanceHash + } + return nil +} + +func (m *ExecutionStreamRequest_Filter) GetTaskKey() string { + if m != nil { + return m.TaskKey + } + return "" +} + +func (m *ExecutionStreamRequest_Filter) GetTags() []string { + if m != nil { + return m.Tags + } + return nil +} + +func (m *ExecutionStreamRequest_Filter) GetExecutorHash() github_com_mesg_foundation_engine_hash.Hash { + if m != nil { + return m.ExecutorHash + } + return nil +} + +func init() { + proto.RegisterType((*ExecutionCreateRequest)(nil), "mesg.grpc.orchestrator.ExecutionCreateRequest") + proto.RegisterType((*ExecutionCreateResponse)(nil), "mesg.grpc.orchestrator.ExecutionCreateResponse") + proto.RegisterType((*ExecutionStreamRequest)(nil), "mesg.grpc.orchestrator.ExecutionStreamRequest") + proto.RegisterType((*ExecutionStreamRequest_Filter)(nil), "mesg.grpc.orchestrator.ExecutionStreamRequest.Filter") +} + +func init() { + proto.RegisterFile("server/grpc/orchestrator/execution.proto", fileDescriptor_9756b90bba6be877) +} + +var fileDescriptor_9756b90bba6be877 = []byte{ + // 556 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x54, 0x4d, 0x6f, 0xd3, 0x40, + 0x10, 0xad, 0xeb, 0xd4, 0xd0, 0x6d, 0x84, 0xd0, 0x8a, 0x14, 0xd7, 0x48, 0x71, 0xe4, 0x93, 0x05, + 0xed, 0x1a, 0xa5, 0xe2, 0xc2, 0xc7, 0x25, 0x15, 0x08, 0x09, 0xb8, 0x38, 0x37, 0x0e, 0x48, 0x1b, + 0x67, 0xe2, 0xac, 0xda, 0x78, 0xdd, 0xdd, 0x71, 0x44, 0x7e, 0x00, 0x3f, 0x8f, 0x33, 0x37, 0xff, + 0x05, 0xa4, 0x1c, 0x39, 0x21, 0xaf, 0x9b, 0xaf, 0x36, 0x52, 0x8b, 0x50, 0x6f, 0xd9, 0xcc, 0x7b, + 0xf3, 0x66, 0xe7, 0x3d, 0x2f, 0x09, 0x35, 0xa8, 0x29, 0xa8, 0x28, 0x55, 0x79, 0x12, 0x49, 0x95, + 0x8c, 0x41, 0xa3, 0xe2, 0x28, 0x55, 0x04, 0xdf, 0x21, 0x29, 0x50, 0xc8, 0x8c, 0xe5, 0x4a, 0xa2, + 0xa4, 0x87, 0x13, 0xd0, 0x29, 0xab, 0x70, 0x6c, 0x1d, 0xe7, 0x05, 0xa9, 0x4c, 0x65, 0x64, 0x30, + 0x83, 0x62, 0x14, 0x55, 0x27, 0x73, 0x30, 0xbf, 0x6a, 0xae, 0xd7, 0x5e, 0x96, 0x71, 0x96, 0x83, + 0xbe, 0xde, 0xdb, 0x7b, 0x76, 0xad, 0xae, 0x51, 0x15, 0x09, 0xd6, 0xc5, 0xe0, 0xd7, 0x2e, 0x39, + 0x7c, 0xbf, 0x20, 0x9c, 0x29, 0xe0, 0x08, 0x31, 0x5c, 0x16, 0xa0, 0x91, 0xbe, 0x25, 0x0f, 0x90, + 0xeb, 0xf3, 0x4f, 0x30, 0x73, 0xad, 0x8e, 0x15, 0xee, 0xf7, 0x82, 0x79, 0xe9, 0xb7, 0xa7, 0xfc, + 0x42, 0x0c, 0x39, 0xc2, 0xeb, 0x40, 0xc1, 0x65, 0x21, 0x14, 0x0c, 0x8f, 0x73, 0x25, 0x32, 0xe4, + 0x3a, 0x11, 0x22, 0x88, 0x17, 0x14, 0x7a, 0x42, 0x1c, 0x91, 0xe5, 0x05, 0x6a, 0x77, 0xb7, 0x63, + 0x85, 0x07, 0xdd, 0x16, 0x33, 0x57, 0x5c, 0xcc, 0xc2, 0xfa, 0x66, 0x8a, 0xf8, 0x0a, 0x44, 0xbb, + 0xa4, 0x81, 0x3c, 0xd5, 0xae, 0xdd, 0xb1, 0xc3, 0xfd, 0x5e, 0x7b, 0x5e, 0xfa, 0xde, 0x4a, 0x69, + 0x28, 0xa6, 0xb0, 0xa1, 0x62, 0xb0, 0x34, 0x27, 0xcd, 0xfa, 0xae, 0x52, 0x7d, 0xe4, 0x7a, 0xec, + 0x36, 0x3a, 0x56, 0xd8, 0xec, 0x7d, 0x9e, 0x97, 0xfe, 0xd1, 0x8a, 0x2b, 0x27, 0x02, 0x61, 0x92, + 0xe3, 0xec, 0x78, 0xcc, 0xf5, 0x38, 0xf8, 0x53, 0xfa, 0x2f, 0x52, 0x81, 0xe3, 0x62, 0xc0, 0x12, + 0x39, 0x89, 0xaa, 0x99, 0x4e, 0x46, 0xb2, 0xc8, 0x86, 0xbc, 0x5a, 0x40, 0x04, 0x59, 0x2a, 0x32, + 0x88, 0x2a, 0x28, 0xab, 0x7a, 0xc6, 0x1b, 0x0a, 0xf4, 0x39, 0xd9, 0xcb, 0x95, 0x48, 0xc0, 0xdd, + 0x33, 0x0b, 0x79, 0x32, 0x2f, 0xfd, 0xc7, 0x2b, 0xa9, 0x44, 0x8a, 0x4c, 0x07, 0x71, 0x0d, 0x09, + 0xbe, 0x91, 0xa7, 0x37, 0x16, 0xab, 0x73, 0x99, 0x69, 0xa0, 0x67, 0xa4, 0x51, 0x29, 0x98, 0xb5, + 0x36, 0x7b, 0xd1, 0xbf, 0xce, 0x64, 0xc8, 0xc1, 0x6f, 0x7b, 0xcd, 0xb9, 0x3e, 0x2a, 0xe0, 0x93, + 0x85, 0x73, 0x5f, 0x88, 0x33, 0x12, 0x17, 0x08, 0xca, 0x28, 0x1c, 0x74, 0x5f, 0xb1, 0xed, 0xf1, + 0x62, 0xdb, 0xf9, 0xec, 0x83, 0x21, 0xc7, 0x57, 0x4d, 0xbc, 0x1f, 0x36, 0x71, 0xea, 0xbf, 0x28, + 0x23, 0x0f, 0x35, 0x72, 0x2c, 0x34, 0x68, 0xd7, 0xea, 0xd8, 0xe1, 0xa3, 0x2e, 0xad, 0x7b, 0x9b, + 0x68, 0xb1, 0xbe, 0xa9, 0xc5, 0x4b, 0x4c, 0x65, 0x91, 0xc8, 0x34, 0xf2, 0x2c, 0x01, 0x63, 0xd1, + 0xee, 0x7d, 0x58, 0xb4, 0xae, 0x40, 0x4f, 0x57, 0xa9, 0xb5, 0x8d, 0x49, 0x47, 0xf3, 0xd2, 0x6f, + 0xad, 0xc4, 0xb6, 0x86, 0x75, 0x91, 0xbe, 0xc6, 0x7f, 0xa4, 0x6f, 0xef, 0xbe, 0xd3, 0xd7, 0xfd, + 0x69, 0x91, 0xfd, 0xa5, 0x63, 0xf4, 0x9c, 0x38, 0x75, 0xac, 0x28, 0xbb, 0xd5, 0xde, 0x8d, 0x0f, + 0xdb, 0x8b, 0xee, 0x8c, 0xaf, 0xf3, 0x1a, 0xec, 0xd0, 0x3e, 0x71, 0xea, 0x88, 0xdc, 0x41, 0x6c, + 0x23, 0x4b, 0x5e, 0x6b, 0x3d, 0x1f, 0x4b, 0x4c, 0xb0, 0xf3, 0xd2, 0xea, 0xbd, 0xfb, 0xfa, 0xe6, + 0xf6, 0x65, 0x54, 0x4f, 0xa8, 0x48, 0xe0, 0xe6, 0x1b, 0x3a, 0x70, 0xcc, 0x5b, 0x72, 0xfa, 0x37, + 0x00, 0x00, 0xff, 0xff, 0x92, 0xbc, 0x92, 0xb8, 0x66, 0x05, 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 + +// ExecutionClient is the client API for Execution service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type ExecutionClient interface { + // Create an execution on the blockchain. + Create(ctx context.Context, in *ExecutionCreateRequest, opts ...grpc.CallOption) (*ExecutionCreateResponse, error) + // Stream returns a stream of executions that satisfy specified filter. + Stream(ctx context.Context, in *ExecutionStreamRequest, opts ...grpc.CallOption) (Execution_StreamClient, error) +} + +type executionClient struct { + cc *grpc.ClientConn +} + +func NewExecutionClient(cc *grpc.ClientConn) ExecutionClient { + return &executionClient{cc} +} + +func (c *executionClient) Create(ctx context.Context, in *ExecutionCreateRequest, opts ...grpc.CallOption) (*ExecutionCreateResponse, error) { + out := new(ExecutionCreateResponse) + err := c.cc.Invoke(ctx, "/mesg.grpc.orchestrator.Execution/Create", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *executionClient) Stream(ctx context.Context, in *ExecutionStreamRequest, opts ...grpc.CallOption) (Execution_StreamClient, error) { + stream, err := c.cc.NewStream(ctx, &_Execution_serviceDesc.Streams[0], "/mesg.grpc.orchestrator.Execution/Stream", opts...) + if err != nil { + return nil, err + } + x := &executionStreamClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type Execution_StreamClient interface { + Recv() (*execution.Execution, error) + grpc.ClientStream +} + +type executionStreamClient struct { + grpc.ClientStream +} + +func (x *executionStreamClient) Recv() (*execution.Execution, error) { + m := new(execution.Execution) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// ExecutionServer is the server API for Execution service. +type ExecutionServer interface { + // Create an execution on the blockchain. + Create(context.Context, *ExecutionCreateRequest) (*ExecutionCreateResponse, error) + // Stream returns a stream of executions that satisfy specified filter. + Stream(*ExecutionStreamRequest, Execution_StreamServer) error +} + +// UnimplementedExecutionServer can be embedded to have forward compatible implementations. +type UnimplementedExecutionServer struct { +} + +func (*UnimplementedExecutionServer) Create(ctx context.Context, req *ExecutionCreateRequest) (*ExecutionCreateResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Create not implemented") +} +func (*UnimplementedExecutionServer) Stream(req *ExecutionStreamRequest, srv Execution_StreamServer) error { + return status.Errorf(codes.Unimplemented, "method Stream not implemented") +} + +func RegisterExecutionServer(s *grpc.Server, srv ExecutionServer) { + s.RegisterService(&_Execution_serviceDesc, srv) +} + +func _Execution_Create_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ExecutionCreateRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ExecutionServer).Create(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/mesg.grpc.orchestrator.Execution/Create", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ExecutionServer).Create(ctx, req.(*ExecutionCreateRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Execution_Stream_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(ExecutionStreamRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(ExecutionServer).Stream(m, &executionStreamServer{stream}) +} + +type Execution_StreamServer interface { + Send(*execution.Execution) error + grpc.ServerStream +} + +type executionStreamServer struct { + grpc.ServerStream +} + +func (x *executionStreamServer) Send(m *execution.Execution) error { + return x.ServerStream.SendMsg(m) +} + +var _Execution_serviceDesc = grpc.ServiceDesc{ + ServiceName: "mesg.grpc.orchestrator.Execution", + HandlerType: (*ExecutionServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Create", + Handler: _Execution_Create_Handler, + }, + }, + Streams: []grpc.StreamDesc{ + { + StreamName: "Stream", + Handler: _Execution_Stream_Handler, + ServerStreams: true, + }, + }, + Metadata: "server/grpc/orchestrator/execution.proto", +} diff --git a/server/grpc/orchestrator/execution.proto b/server/grpc/orchestrator/execution.proto new file mode 100644 index 000000000..ab792841a --- /dev/null +++ b/server/grpc/orchestrator/execution.proto @@ -0,0 +1,82 @@ +syntax = "proto3"; + +import "gogo/protobuf/gogoproto/gogo.proto"; +import "protobuf/types/execution.proto"; +import "protobuf/types/struct.proto"; + +package mesg.grpc.orchestrator; +option go_package = "github.com/mesg-foundation/engine/service/grpc/orchestrator"; + +// This is the Execution API to interact with the Orchestrator. +// This API requires all requests to be signed for authentication. The signature should be passed in the request's metadata using the key `mesg_request_signature` and base64 encoded. +service Execution { + // Create an execution on the blockchain. + rpc Create(ExecutionCreateRequest) returns (ExecutionCreateResponse) {} + + // Stream returns a stream of executions that satisfy specified filter. + rpc Stream(ExecutionStreamRequest) returns (stream types.Execution) {} +} + +// ExecutionCreateRequest is the request of the endpoint ExecutionCreate. +message ExecutionCreateRequest { + string taskKey = 1 [ + (gogoproto.moretags) = 'validate:"required,printascii"' + ]; + + mesg.protobuf.Struct inputs = 2; + + repeated string tags = 3 [ + (gogoproto.moretags) = 'validate:"dive,printascii"' + ]; + + bytes executorHash = 4 [ + (gogoproto.moretags) = 'validate:"omitempty,hash"', + (gogoproto.casttype) = "github.com/mesg-foundation/engine/hash.Hash" + ]; + + string price = 5 [ + (gogoproto.moretags) = 'validate:"coins"' + ]; +} + +// ExecutionCreateResponse is the response of the endpoint ExecutionCreate. +message ExecutionCreateResponse { + // Execution's hash. + bytes hash = 1 [ + (gogoproto.casttype) = "github.com/mesg-foundation/engine/hash.Hash" + ]; +} + +// ExecutionStreamRequest defines request to retrieve a stream of executions. +message ExecutionStreamRequest{ + // Filter contains filtering criteria. + message Filter { + // Statuses to filter executions. One status needs to be present in the execution. + repeated types.Status statuses = 1; + + // Instance's hash to filter executions. + bytes instanceHash = 2 [ + (gogoproto.moretags) = 'validate:"omitempty,hash"', + (gogoproto.casttype) = "github.com/mesg-foundation/engine/hash.Hash" + ]; + + // taskKey to filter executions. + string taskKey = 3 [ + (gogoproto.moretags) = 'validate:"printascii"' + ]; + + // tags to filter executions. All tags needs to be present in the execution. + repeated string tags = 4 [ + (gogoproto.moretags) = 'validate:"dive,printascii"' + ]; + + // Executor's hash to filter executions. + bytes executorHash = 5 [ + (gogoproto.moretags) = 'validate:"omitempty,hash"', + (gogoproto.casttype) = "github.com/mesg-foundation/engine/hash.Hash" + ]; + } + + // Filter used to filter a stream of executions. + Filter filter = 1; +} diff --git a/server/grpc/orchestrator/runner.go b/server/grpc/orchestrator/runner.go new file mode 100644 index 000000000..3a96260e7 --- /dev/null +++ b/server/grpc/orchestrator/runner.go @@ -0,0 +1,131 @@ +package orchestrator + +import ( + "context" + fmt "fmt" + "sync" + + "github.com/mesg-foundation/engine/cosmos" + "github.com/mesg-foundation/engine/hash" + "github.com/mesg-foundation/engine/instance" + "github.com/mesg-foundation/engine/runner" + runnermodule "github.com/mesg-foundation/engine/x/runner" +) + +type runnerServer struct { + rpc *cosmos.RPC + tokenToRunnerHash *sync.Map + auth *Authorizer +} + +// NewRunnerServer creates a new Runner Server. +func NewRunnerServer(rpc *cosmos.RPC, tokenToRunnerHash *sync.Map, auth *Authorizer) RunnerServer { + return &runnerServer{ + rpc: rpc, + tokenToRunnerHash: tokenToRunnerHash, + auth: auth, + } +} + +// Register register a new runner. +func (s *runnerServer) Register(ctx context.Context, req *RunnerRegisterRequest) (*RunnerRegisterResponse, error) { + // check authorization + if err := s.auth.IsAuthorized(ctx, req); err != nil { + return nil, err + } + + // get engine account + acc, err := s.rpc.GetAccount() + if err != nil { + return nil, err + } + + // calculate runner hash + inst, err := instance.New(req.ServiceHash, req.EnvHash) + if err != nil { + return nil, err + } + run, err := runner.New(acc.GetAddress().String(), inst.Hash) + if err != nil { + return nil, err + } + runnerHash := run.Hash + + // check that runner doesn't already exist + var runnerExist bool + route := fmt.Sprintf("custom/%s/%s/%s", runnermodule.QuerierRoute, runnermodule.QueryExist, runnerHash) + if err := s.rpc.QueryJSON(route, nil, &runnerExist); err != nil { + return nil, err + } + + // only broadcast if runner doesn't exist + if !runnerExist { + tx, err := s.rpc.BuildAndBroadcastMsg(runnermodule.MsgCreate{ + Owner: acc.GetAddress(), + ServiceHash: req.ServiceHash, + EnvHash: req.EnvHash, + }) + if err != nil { + return nil, err + } + runnerHashCreated, err := hash.DecodeFromBytes(tx.Data) + if err != nil { + return nil, err + } + if !runnerHashCreated.Equal(runnerHash) { + // delete wrong runner + _, err := s.rpc.BuildAndBroadcastMsg(runnermodule.MsgDelete{ + Owner: acc.GetAddress(), + Hash: runnerHashCreated, + }) + if err != nil { + return nil, err + } + return nil, fmt.Errorf("runner hash created is not expected: got %q, expect %q", runnerHashCreated, runnerHash) + } + } + + // delete any other token corresponding to runnerHash + s.tokenToRunnerHash.Range(func(key, value interface{}) bool { + savedRunnerHash := value.(hash.Hash) + if savedRunnerHash.Equal(runnerHash) { + s.tokenToRunnerHash.Delete(key) + } + return true + }) + + // generate unique token + token, err := hash.Random() + if err != nil { + return nil, err + } + + // save token locally with ref to runnerHash + s.tokenToRunnerHash.Store(token.String(), runnerHash) + + return &RunnerRegisterResponse{ + Token: token.String(), + }, nil +} + +// Delete deletes an runner. +func (s *runnerServer) Delete(ctx context.Context, req *RunnerDeleteRequest) (*RunnerDeleteResponse, error) { + // check authorization + if err := s.auth.IsAuthorized(ctx, req); err != nil { + return nil, err + } + + // create execution + acc, err := s.rpc.GetAccount() + if err != nil { + return nil, err + } + msg := runnermodule.MsgDelete{ + Owner: acc.GetAddress(), + Hash: req.RunnerHash, + } + if _, err := s.rpc.BuildAndBroadcastMsg(msg); err != nil { + return nil, err + } + return &RunnerDeleteResponse{}, nil +} diff --git a/server/grpc/orchestrator/runner.pb.go b/server/grpc/orchestrator/runner.pb.go new file mode 100644 index 000000000..c65332258 --- /dev/null +++ b/server/grpc/orchestrator/runner.pb.go @@ -0,0 +1,348 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: server/grpc/orchestrator/runner.proto + +package orchestrator + +import ( + context "context" + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + github_com_mesg_foundation_engine_hash "github.com/mesg-foundation/engine/hash" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + math "math" +) + +// 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 + +// RunnerRegisterRequest is the request of the endpoint Register. +type RunnerRegisterRequest struct { + // Service's hash to start the runner with. + ServiceHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=serviceHash,proto3,casttype=github.com/mesg-foundation/engine/hash.Hash" json:"serviceHash,omitempty" validate:"required,hash"` + // Hash of the customized environmental variables (not the ones in the service configuration). + EnvHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,2,opt,name=envHash,proto3,casttype=github.com/mesg-foundation/engine/hash.Hash" json:"envHash,omitempty" validate:"omitempty,hash"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *RunnerRegisterRequest) Reset() { *m = RunnerRegisterRequest{} } +func (m *RunnerRegisterRequest) String() string { return proto.CompactTextString(m) } +func (*RunnerRegisterRequest) ProtoMessage() {} +func (*RunnerRegisterRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_3e34c5b198626b67, []int{0} +} +func (m *RunnerRegisterRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_RunnerRegisterRequest.Unmarshal(m, b) +} +func (m *RunnerRegisterRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_RunnerRegisterRequest.Marshal(b, m, deterministic) +} +func (m *RunnerRegisterRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_RunnerRegisterRequest.Merge(m, src) +} +func (m *RunnerRegisterRequest) XXX_Size() int { + return xxx_messageInfo_RunnerRegisterRequest.Size(m) +} +func (m *RunnerRegisterRequest) XXX_DiscardUnknown() { + xxx_messageInfo_RunnerRegisterRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_RunnerRegisterRequest proto.InternalMessageInfo + +func (m *RunnerRegisterRequest) GetServiceHash() github_com_mesg_foundation_engine_hash.Hash { + if m != nil { + return m.ServiceHash + } + return nil +} + +func (m *RunnerRegisterRequest) GetEnvHash() github_com_mesg_foundation_engine_hash.Hash { + if m != nil { + return m.EnvHash + } + return nil +} + +// RunnerRegisterResponse is the response of the endpoint Register. +type RunnerRegisterResponse struct { + // token to use with the other endpoints of this API. + Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *RunnerRegisterResponse) Reset() { *m = RunnerRegisterResponse{} } +func (m *RunnerRegisterResponse) String() string { return proto.CompactTextString(m) } +func (*RunnerRegisterResponse) ProtoMessage() {} +func (*RunnerRegisterResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_3e34c5b198626b67, []int{1} +} +func (m *RunnerRegisterResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_RunnerRegisterResponse.Unmarshal(m, b) +} +func (m *RunnerRegisterResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_RunnerRegisterResponse.Marshal(b, m, deterministic) +} +func (m *RunnerRegisterResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_RunnerRegisterResponse.Merge(m, src) +} +func (m *RunnerRegisterResponse) XXX_Size() int { + return xxx_messageInfo_RunnerRegisterResponse.Size(m) +} +func (m *RunnerRegisterResponse) XXX_DiscardUnknown() { + xxx_messageInfo_RunnerRegisterResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_RunnerRegisterResponse proto.InternalMessageInfo + +func (m *RunnerRegisterResponse) GetToken() string { + if m != nil { + return m.Token + } + return "" +} + +// RunnerDeleteRequest is the request of the endpoint DeleteRunner. +type RunnerDeleteRequest struct { + RunnerHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=runnerHash,proto3,casttype=github.com/mesg-foundation/engine/hash.Hash" json:"runnerHash,omitempty" validate:"required,hash"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *RunnerDeleteRequest) Reset() { *m = RunnerDeleteRequest{} } +func (m *RunnerDeleteRequest) String() string { return proto.CompactTextString(m) } +func (*RunnerDeleteRequest) ProtoMessage() {} +func (*RunnerDeleteRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_3e34c5b198626b67, []int{2} +} +func (m *RunnerDeleteRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_RunnerDeleteRequest.Unmarshal(m, b) +} +func (m *RunnerDeleteRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_RunnerDeleteRequest.Marshal(b, m, deterministic) +} +func (m *RunnerDeleteRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_RunnerDeleteRequest.Merge(m, src) +} +func (m *RunnerDeleteRequest) XXX_Size() int { + return xxx_messageInfo_RunnerDeleteRequest.Size(m) +} +func (m *RunnerDeleteRequest) XXX_DiscardUnknown() { + xxx_messageInfo_RunnerDeleteRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_RunnerDeleteRequest proto.InternalMessageInfo + +func (m *RunnerDeleteRequest) GetRunnerHash() github_com_mesg_foundation_engine_hash.Hash { + if m != nil { + return m.RunnerHash + } + return nil +} + +// RunnerDeleteResponse is the response of the endpoint DeleteRunner. +type RunnerDeleteResponse struct { + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *RunnerDeleteResponse) Reset() { *m = RunnerDeleteResponse{} } +func (m *RunnerDeleteResponse) String() string { return proto.CompactTextString(m) } +func (*RunnerDeleteResponse) ProtoMessage() {} +func (*RunnerDeleteResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_3e34c5b198626b67, []int{3} +} +func (m *RunnerDeleteResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_RunnerDeleteResponse.Unmarshal(m, b) +} +func (m *RunnerDeleteResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_RunnerDeleteResponse.Marshal(b, m, deterministic) +} +func (m *RunnerDeleteResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_RunnerDeleteResponse.Merge(m, src) +} +func (m *RunnerDeleteResponse) XXX_Size() int { + return xxx_messageInfo_RunnerDeleteResponse.Size(m) +} +func (m *RunnerDeleteResponse) XXX_DiscardUnknown() { + xxx_messageInfo_RunnerDeleteResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_RunnerDeleteResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*RunnerRegisterRequest)(nil), "mesg.grpc.orchestrator.RunnerRegisterRequest") + proto.RegisterType((*RunnerRegisterResponse)(nil), "mesg.grpc.orchestrator.RunnerRegisterResponse") + proto.RegisterType((*RunnerDeleteRequest)(nil), "mesg.grpc.orchestrator.RunnerDeleteRequest") + proto.RegisterType((*RunnerDeleteResponse)(nil), "mesg.grpc.orchestrator.RunnerDeleteResponse") +} + +func init() { + proto.RegisterFile("server/grpc/orchestrator/runner.proto", fileDescriptor_3e34c5b198626b67) +} + +var fileDescriptor_3e34c5b198626b67 = []byte{ + // 355 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x53, 0x31, 0x4b, 0x03, 0x31, + 0x14, 0xf6, 0x04, 0xab, 0x46, 0xa7, 0x58, 0x4b, 0xed, 0x52, 0x09, 0x08, 0x42, 0xdb, 0x04, 0x74, + 0x53, 0x5c, 0x8a, 0x83, 0xa0, 0xd3, 0x8d, 0x6e, 0xd7, 0xeb, 0x6b, 0x2e, 0xb4, 0x97, 0x5c, 0x93, + 0x5c, 0xc1, 0xd5, 0xdf, 0x29, 0xfd, 0x09, 0x0e, 0x1d, 0x9d, 0x24, 0x89, 0x87, 0xad, 0x16, 0x2d, + 0x82, 0xd3, 0xdd, 0xe3, 0xbe, 0xf7, 0x7d, 0xdf, 0xfb, 0xde, 0x3b, 0x74, 0x66, 0x40, 0xcf, 0x40, + 0x33, 0xae, 0x8b, 0x94, 0x29, 0x9d, 0x66, 0x60, 0xac, 0x4e, 0xac, 0xd2, 0x4c, 0x97, 0x52, 0x82, + 0xa6, 0x85, 0x56, 0x56, 0xe1, 0x46, 0x0e, 0x86, 0x53, 0x07, 0xa2, 0xcb, 0xa0, 0x16, 0xe1, 0x8a, + 0x2b, 0xe6, 0x31, 0x83, 0x72, 0xc4, 0x5c, 0xe5, 0x0b, 0xff, 0x16, 0x7a, 0xc9, 0x6b, 0x84, 0x8e, + 0x63, 0x4f, 0x16, 0x03, 0x17, 0xc6, 0xba, 0xe7, 0xb4, 0x04, 0x63, 0x71, 0x8e, 0x0e, 0x9c, 0xbc, + 0x48, 0xe1, 0x2e, 0x31, 0x59, 0x33, 0x3a, 0x8d, 0xce, 0x0f, 0xfb, 0xf7, 0x8b, 0x79, 0xbb, 0x39, + 0x4b, 0x26, 0x62, 0x98, 0x58, 0xb8, 0x22, 0x1a, 0xa6, 0xa5, 0xd0, 0x30, 0xec, 0x66, 0x89, 0xc9, + 0xc8, 0xdb, 0xbc, 0xdd, 0xe1, 0xc2, 0x66, 0xe5, 0x80, 0xa6, 0x2a, 0x67, 0xce, 0x55, 0x6f, 0xa4, + 0x4a, 0x39, 0x4c, 0xac, 0x50, 0x92, 0x81, 0xe4, 0x42, 0x02, 0x73, 0x50, 0xea, 0x28, 0xe3, 0x65, + 0x7e, 0x3c, 0x42, 0xbb, 0x20, 0x67, 0x5e, 0x6a, 0xdb, 0x4b, 0x3d, 0x2c, 0xe6, 0xed, 0x93, 0x4f, + 0x29, 0x95, 0x0b, 0x0b, 0x79, 0x61, 0x9f, 0xfe, 0xa6, 0x55, 0x91, 0x13, 0x8a, 0x1a, 0x5f, 0xe7, + 0x35, 0x85, 0x92, 0x06, 0x70, 0x1d, 0xed, 0x58, 0x35, 0x06, 0xe9, 0x47, 0xdd, 0x8f, 0x43, 0x41, + 0x9e, 0x23, 0x74, 0x14, 0x1a, 0x6e, 0x61, 0x02, 0x16, 0xaa, 0x78, 0xc6, 0x08, 0x85, 0x25, 0xfc, + 0x57, 0x3a, 0x4b, 0xf4, 0xa4, 0x81, 0xea, 0xab, 0x1e, 0x82, 0xe5, 0x8b, 0x97, 0x08, 0xd5, 0xc2, + 0x07, 0x3c, 0x46, 0x7b, 0xd5, 0x44, 0xb8, 0x47, 0xd7, 0x5f, 0x04, 0x5d, 0xbb, 0xe9, 0x16, 0xdd, + 0x14, 0x1e, 0x54, 0xc9, 0x16, 0x06, 0x54, 0x0b, 0x4e, 0x70, 0xe7, 0xe7, 0xde, 0x95, 0xcc, 0x5a, + 0xdd, 0xcd, 0xc0, 0x95, 0x4c, 0xff, 0xe6, 0xf1, 0xfa, 0xf7, 0xc4, 0x3e, 0x8e, 0xe8, 0xfb, 0x4f, + 0x32, 0xa8, 0xf9, 0x13, 0xbf, 0x7c, 0x0f, 0x00, 0x00, 0xff, 0xff, 0x96, 0x67, 0xbe, 0x61, 0x47, + 0x03, 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 + +// RunnerClient is the client API for Runner service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type RunnerClient interface { + // Register registers a new runner to the Engine. + // This endpoint should only be called when the runner is ready to receive execution and emit events. + // This endpoint returns a credential token that must be use to reach the Runner APIs. + Register(ctx context.Context, in *RunnerRegisterRequest, opts ...grpc.CallOption) (*RunnerRegisterResponse, error) + // Delete a runner from the blockchain. + Delete(ctx context.Context, in *RunnerDeleteRequest, opts ...grpc.CallOption) (*RunnerDeleteResponse, error) +} + +type runnerClient struct { + cc *grpc.ClientConn +} + +func NewRunnerClient(cc *grpc.ClientConn) RunnerClient { + return &runnerClient{cc} +} + +func (c *runnerClient) Register(ctx context.Context, in *RunnerRegisterRequest, opts ...grpc.CallOption) (*RunnerRegisterResponse, error) { + out := new(RunnerRegisterResponse) + err := c.cc.Invoke(ctx, "/mesg.grpc.orchestrator.Runner/Register", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *runnerClient) Delete(ctx context.Context, in *RunnerDeleteRequest, opts ...grpc.CallOption) (*RunnerDeleteResponse, error) { + out := new(RunnerDeleteResponse) + err := c.cc.Invoke(ctx, "/mesg.grpc.orchestrator.Runner/Delete", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// RunnerServer is the server API for Runner service. +type RunnerServer interface { + // Register registers a new runner to the Engine. + // This endpoint should only be called when the runner is ready to receive execution and emit events. + // This endpoint returns a credential token that must be use to reach the Runner APIs. + Register(context.Context, *RunnerRegisterRequest) (*RunnerRegisterResponse, error) + // Delete a runner from the blockchain. + Delete(context.Context, *RunnerDeleteRequest) (*RunnerDeleteResponse, error) +} + +// UnimplementedRunnerServer can be embedded to have forward compatible implementations. +type UnimplementedRunnerServer struct { +} + +func (*UnimplementedRunnerServer) Register(ctx context.Context, req *RunnerRegisterRequest) (*RunnerRegisterResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Register not implemented") +} +func (*UnimplementedRunnerServer) Delete(ctx context.Context, req *RunnerDeleteRequest) (*RunnerDeleteResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Delete not implemented") +} + +func RegisterRunnerServer(s *grpc.Server, srv RunnerServer) { + s.RegisterService(&_Runner_serviceDesc, srv) +} + +func _Runner_Register_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(RunnerRegisterRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(RunnerServer).Register(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/mesg.grpc.orchestrator.Runner/Register", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(RunnerServer).Register(ctx, req.(*RunnerRegisterRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Runner_Delete_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(RunnerDeleteRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(RunnerServer).Delete(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/mesg.grpc.orchestrator.Runner/Delete", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(RunnerServer).Delete(ctx, req.(*RunnerDeleteRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Runner_serviceDesc = grpc.ServiceDesc{ + ServiceName: "mesg.grpc.orchestrator.Runner", + HandlerType: (*RunnerServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Register", + Handler: _Runner_Register_Handler, + }, + { + MethodName: "Delete", + Handler: _Runner_Delete_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "server/grpc/orchestrator/runner.proto", +} diff --git a/server/grpc/orchestrator/runner.proto b/server/grpc/orchestrator/runner.proto new file mode 100644 index 000000000..3a1fe9ca5 --- /dev/null +++ b/server/grpc/orchestrator/runner.proto @@ -0,0 +1,50 @@ +syntax = "proto3"; + +import "gogo/protobuf/gogoproto/gogo.proto"; + +package mesg.grpc.orchestrator; +option go_package = "github.com/mesg-foundation/engine/service/grpc/orchestrator"; + +// This is the Runner API to interact with the Orchestrator. +// This API requires all requests to be signed for authentication. The signature should be passed in the request's metadata using the key `mesg_request_signature` and base64 encoded. +service Runner { + // Register registers a new runner to the Engine. + // This endpoint should only be called when the runner is ready to receive execution and emit events. + // This endpoint returns a credential token that must be use to reach the Runner APIs. + rpc Register(RunnerRegisterRequest) returns (RunnerRegisterResponse) {} + + // Delete a runner from the blockchain. + rpc Delete(RunnerDeleteRequest) returns (RunnerDeleteResponse) {} +} + +// RunnerRegisterRequest is the request of the endpoint Register. +message RunnerRegisterRequest { + // Service's hash to start the runner with. + bytes serviceHash = 1 [ + (gogoproto.moretags) = 'validate:"required,hash"', + (gogoproto.casttype) = "github.com/mesg-foundation/engine/hash.Hash" + ]; + + // Hash of the customized environmental variables (not the ones in the service configuration). + bytes envHash = 2 [ + (gogoproto.moretags) = 'validate:"omitempty,hash"', + (gogoproto.casttype) = "github.com/mesg-foundation/engine/hash.Hash" + ]; +} + +// RunnerRegisterResponse is the response of the endpoint Register. +message RunnerRegisterResponse { + // token to use with the other endpoints of this API. + string token = 1; +} + +// RunnerDeleteRequest is the request of the endpoint DeleteRunner. +message RunnerDeleteRequest { + bytes runnerHash = 1 [ + (gogoproto.moretags) = 'validate:"required,hash"', + (gogoproto.casttype) = "github.com/mesg-foundation/engine/hash.Hash" + ]; +} + +// RunnerDeleteResponse is the response of the endpoint DeleteRunner. +message RunnerDeleteResponse {} diff --git a/server/grpc/runner/runner.go b/server/grpc/runner/runner.go new file mode 100644 index 000000000..ef15a885b --- /dev/null +++ b/server/grpc/runner/runner.go @@ -0,0 +1,183 @@ +package runner + +import ( + "context" + "fmt" + "sync" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/mesg-foundation/engine/cosmos" + "github.com/mesg-foundation/engine/event/publisher" + "github.com/mesg-foundation/engine/execution" + "github.com/mesg-foundation/engine/ext/xstrings" + "github.com/mesg-foundation/engine/hash" + "github.com/mesg-foundation/engine/protobuf/acknowledgement" + "github.com/mesg-foundation/engine/runner" + executionmodule "github.com/mesg-foundation/engine/x/execution" + runnermodule "github.com/mesg-foundation/engine/x/runner" + "google.golang.org/grpc/metadata" +) + +// CredentialToken is the name to use in the gRPC metadata to set and read the credential token. +const CredentialToken = "mesg_credential_token" + +// Server is the type to aggregate all Runner APIs. +type Server struct { + rpc *cosmos.RPC + eventPublisher *publisher.EventPublisher + tokenToRunnerHash *sync.Map +} + +// NewServer creates a new Server. +func NewServer(rpc *cosmos.RPC, eventPublisher *publisher.EventPublisher, tokenToRunnerHash *sync.Map) *Server { + return &Server{ + rpc: rpc, + eventPublisher: eventPublisher, + tokenToRunnerHash: tokenToRunnerHash, + } +} + +// isAuthorized checks the context for a token, matches it against the saved tokens, returns the runner hash if found. +func (s *Server) isAuthorized(ctx context.Context) (hash.Hash, error) { + md, ok := metadata.FromIncomingContext(ctx) + if !ok { + return nil, fmt.Errorf("credential not found in metadata, make sure to set it using the name %q", CredentialToken) + } + if len(md[CredentialToken]) == 0 { + return nil, fmt.Errorf("credential not found in metadata, make sure to set it using the name %q", CredentialToken) + } + token := md[CredentialToken][0] + runnerHash, ok := s.tokenToRunnerHash.Load(token) + if !ok { + return nil, fmt.Errorf("credential token doesn't exist") + } + return runnerHash.(hash.Hash), nil +} + +// Execution returns a stream of Execution for a specific Runner. +func (s *Server) Execution(req *ExecutionRequest, stream Runner_ExecutionServer) error { + // check authorization and get runner hash + runnerHash, err := s.isAuthorized(stream.Context()) + if err != nil { + return err + } + + // create rpc event stream + ctx, cancel := context.WithCancel(stream.Context()) + defer cancel() + subscriber := xstrings.RandASCIILetters(8) + query := fmt.Sprintf("%s.%s='%s' AND %s.%s='%s'", + executionmodule.EventType, executionmodule.AttributeKeyExecutor, runnerHash.String(), + executionmodule.EventType, sdk.AttributeKeyAction, executionmodule.AttributeActionCreated, + ) + eventStream, err := s.rpc.Subscribe(ctx, subscriber, query, 0) + defer s.rpc.Unsubscribe(context.Background(), subscriber, query) + if err != nil { + return err + } + if err := acknowledgement.SetStreamReady(stream); err != nil { + return err + } + + // listen to event stream + for { + select { + case event := <-eventStream: + // get the index of the action=created attributes + attrKeyActionCreated := fmt.Sprintf("%s.%s", executionmodule.EventType, sdk.AttributeKeyAction) + attrIndexes := make([]int, 0) + for index, attr := range event.Events[attrKeyActionCreated] { + if attr == executionmodule.AttributeActionCreated { + attrIndexes = append(attrIndexes, index) + } + } + // iterate only on the index of attribute hash where action=created + attrKeyHash := fmt.Sprintf("%s.%s", executionmodule.EventType, executionmodule.AttributeKeyHash) + for _, index := range attrIndexes { + attr := event.Events[attrKeyHash][index] + hash, err := hash.Decode(attr) + if err != nil { + return err + } + var exec *execution.Execution + route := fmt.Sprintf("custom/%s/%s/%s", executionmodule.QuerierRoute, executionmodule.QueryGet, hash) + if err := s.rpc.QueryJSON(route, nil, &exec); err != nil { + return err + } + if err := stream.Send(exec); err != nil { + return err + } + } + case <-ctx.Done(): + return ctx.Err() + case <-stream.Context().Done(): + return stream.Context().Err() + } + } +} + +// Result emits the result of an Execution. +func (s *Server) Result(ctx context.Context, req *ResultRequest) (*ResultResponse, error) { + // check authorization and get runner hash + runnerHash, err := s.isAuthorized(ctx) + if err != nil { + return nil, err + } + + // make sure runner is allowed to update this execution + var exec *execution.Execution + route := fmt.Sprintf("custom/%s/%s/%s", executionmodule.QuerierRoute, executionmodule.QueryGet, req.ExecutionHash) + if err := s.rpc.QueryJSON(route, nil, &exec); err != nil { + return nil, err + } + if !exec.ExecutorHash.Equal(runnerHash) { + return nil, fmt.Errorf("this runner (%q) is not authorized to submit the result of this execution, the executor should be %q", runnerHash, exec.ExecutorHash) + } + + // update execution + acc, err := s.rpc.GetAccount() + if err != nil { + return nil, err + } + msg := executionmodule.MsgUpdate{ + Executor: acc.GetAddress(), + Hash: req.ExecutionHash, + } + switch result := req.Result.(type) { + case *ResultRequest_Outputs: + msg.Result = &executionmodule.MsgUpdateOutputs{ + Outputs: result.Outputs, + } + case *ResultRequest_Error: + msg.Result = &executionmodule.MsgUpdateError{ + Error: result.Error, + } + } + if _, err := s.rpc.BuildAndBroadcastMsg(msg); err != nil { + return nil, err + } + return &ResultResponse{}, nil +} + +// Event emits an event. +func (s *Server) Event(ctx context.Context, req *EventRequest) (*EventResponse, error) { + // check authorization and get runner hash + runnerHash, err := s.isAuthorized(ctx) + if err != nil { + return nil, err + } + + // get runner to access instance hash + var run *runner.Runner + route := fmt.Sprintf("custom/%s/%s/%s", runnermodule.QuerierRoute, runnermodule.QueryGet, runnerHash) + if err := s.rpc.QueryJSON(route, nil, &run); err != nil { + return nil, err + } + + // publish event + if _, err := s.eventPublisher.Publish(run.InstanceHash, req.Key, req.Data); err != nil { + return nil, err + } + + return &EventResponse{}, nil +} diff --git a/server/grpc/runner/runner.pb.go b/server/grpc/runner/runner.pb.go new file mode 100644 index 000000000..46f2b9b28 --- /dev/null +++ b/server/grpc/runner/runner.pb.go @@ -0,0 +1,494 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: server/grpc/runner/runner.proto + +package runner + +import ( + context "context" + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + execution "github.com/mesg-foundation/engine/execution" + github_com_mesg_foundation_engine_hash "github.com/mesg-foundation/engine/hash" + types "github.com/mesg-foundation/engine/protobuf/types" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + math "math" +) + +// 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 + +// ExecutionRequest is the request of the endpoint Execution. +type ExecutionRequest struct { + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ExecutionRequest) Reset() { *m = ExecutionRequest{} } +func (m *ExecutionRequest) String() string { return proto.CompactTextString(m) } +func (*ExecutionRequest) ProtoMessage() {} +func (*ExecutionRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_1650fde6416bd437, []int{0} +} +func (m *ExecutionRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ExecutionRequest.Unmarshal(m, b) +} +func (m *ExecutionRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ExecutionRequest.Marshal(b, m, deterministic) +} +func (m *ExecutionRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_ExecutionRequest.Merge(m, src) +} +func (m *ExecutionRequest) XXX_Size() int { + return xxx_messageInfo_ExecutionRequest.Size(m) +} +func (m *ExecutionRequest) XXX_DiscardUnknown() { + xxx_messageInfo_ExecutionRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_ExecutionRequest proto.InternalMessageInfo + +// EventRequest is the request of the endpoint Result. +type ResultRequest struct { + // Execution's hash of the executed execution. + ExecutionHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=executionHash,proto3,casttype=github.com/mesg-foundation/engine/hash.Hash" json:"executionHash,omitempty" validate:"required,hash"` + // Execution's result. + // + // Types that are valid to be assigned to Result: + // *ResultRequest_Outputs + // *ResultRequest_Error + Result isResultRequest_Result `protobuf_oneof:"result"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ResultRequest) Reset() { *m = ResultRequest{} } +func (m *ResultRequest) String() string { return proto.CompactTextString(m) } +func (*ResultRequest) ProtoMessage() {} +func (*ResultRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_1650fde6416bd437, []int{1} +} +func (m *ResultRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ResultRequest.Unmarshal(m, b) +} +func (m *ResultRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ResultRequest.Marshal(b, m, deterministic) +} +func (m *ResultRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_ResultRequest.Merge(m, src) +} +func (m *ResultRequest) XXX_Size() int { + return xxx_messageInfo_ResultRequest.Size(m) +} +func (m *ResultRequest) XXX_DiscardUnknown() { + xxx_messageInfo_ResultRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_ResultRequest proto.InternalMessageInfo + +type isResultRequest_Result interface { + isResultRequest_Result() +} + +type ResultRequest_Outputs struct { + Outputs *types.Struct `protobuf:"bytes,2,opt,name=outputs,proto3,oneof" json:"outputs,omitempty"` +} +type ResultRequest_Error struct { + Error string `protobuf:"bytes,3,opt,name=error,proto3,oneof" json:"error,omitempty"` +} + +func (*ResultRequest_Outputs) isResultRequest_Result() {} +func (*ResultRequest_Error) isResultRequest_Result() {} + +func (m *ResultRequest) GetResult() isResultRequest_Result { + if m != nil { + return m.Result + } + return nil +} + +func (m *ResultRequest) GetExecutionHash() github_com_mesg_foundation_engine_hash.Hash { + if m != nil { + return m.ExecutionHash + } + return nil +} + +func (m *ResultRequest) GetOutputs() *types.Struct { + if x, ok := m.GetResult().(*ResultRequest_Outputs); ok { + return x.Outputs + } + return nil +} + +func (m *ResultRequest) GetError() string { + if x, ok := m.GetResult().(*ResultRequest_Error); ok { + return x.Error + } + return "" +} + +// XXX_OneofWrappers is for the internal use of the proto package. +func (*ResultRequest) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*ResultRequest_Outputs)(nil), + (*ResultRequest_Error)(nil), + } +} + +// ResultResponse is the response of the endpoint Result. +type ResultResponse struct { + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ResultResponse) Reset() { *m = ResultResponse{} } +func (m *ResultResponse) String() string { return proto.CompactTextString(m) } +func (*ResultResponse) ProtoMessage() {} +func (*ResultResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_1650fde6416bd437, []int{2} +} +func (m *ResultResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ResultResponse.Unmarshal(m, b) +} +func (m *ResultResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ResultResponse.Marshal(b, m, deterministic) +} +func (m *ResultResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_ResultResponse.Merge(m, src) +} +func (m *ResultResponse) XXX_Size() int { + return xxx_messageInfo_ResultResponse.Size(m) +} +func (m *ResultResponse) XXX_DiscardUnknown() { + xxx_messageInfo_ResultResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_ResultResponse proto.InternalMessageInfo + +// EventRequest is the request of the endpoint Event. +type EventRequest struct { + // Event's key + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty" validate:"required,printascii"` + // Event's data + Data *types.Struct `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *EventRequest) Reset() { *m = EventRequest{} } +func (m *EventRequest) String() string { return proto.CompactTextString(m) } +func (*EventRequest) ProtoMessage() {} +func (*EventRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_1650fde6416bd437, []int{3} +} +func (m *EventRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_EventRequest.Unmarshal(m, b) +} +func (m *EventRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_EventRequest.Marshal(b, m, deterministic) +} +func (m *EventRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventRequest.Merge(m, src) +} +func (m *EventRequest) XXX_Size() int { + return xxx_messageInfo_EventRequest.Size(m) +} +func (m *EventRequest) XXX_DiscardUnknown() { + xxx_messageInfo_EventRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_EventRequest proto.InternalMessageInfo + +func (m *EventRequest) GetKey() string { + if m != nil { + return m.Key + } + return "" +} + +func (m *EventRequest) GetData() *types.Struct { + if m != nil { + return m.Data + } + return nil +} + +// EventResponse is the response of the endpoint Event. +type EventResponse struct { + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *EventResponse) Reset() { *m = EventResponse{} } +func (m *EventResponse) String() string { return proto.CompactTextString(m) } +func (*EventResponse) ProtoMessage() {} +func (*EventResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_1650fde6416bd437, []int{4} +} +func (m *EventResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_EventResponse.Unmarshal(m, b) +} +func (m *EventResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_EventResponse.Marshal(b, m, deterministic) +} +func (m *EventResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventResponse.Merge(m, src) +} +func (m *EventResponse) XXX_Size() int { + return xxx_messageInfo_EventResponse.Size(m) +} +func (m *EventResponse) XXX_DiscardUnknown() { + xxx_messageInfo_EventResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_EventResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*ExecutionRequest)(nil), "mesg.grpc.runner.ExecutionRequest") + proto.RegisterType((*ResultRequest)(nil), "mesg.grpc.runner.ResultRequest") + proto.RegisterType((*ResultResponse)(nil), "mesg.grpc.runner.ResultResponse") + proto.RegisterType((*EventRequest)(nil), "mesg.grpc.runner.EventRequest") + proto.RegisterType((*EventResponse)(nil), "mesg.grpc.runner.EventResponse") +} + +func init() { proto.RegisterFile("server/grpc/runner/runner.proto", fileDescriptor_1650fde6416bd437) } + +var fileDescriptor_1650fde6416bd437 = []byte{ + // 435 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x53, 0x4d, 0x6f, 0x13, 0x31, + 0x10, 0xcd, 0x52, 0x1a, 0xc8, 0xd0, 0x40, 0x64, 0x09, 0x14, 0x2d, 0x52, 0x36, 0xf2, 0x29, 0x08, + 0xf0, 0x42, 0x01, 0x21, 0x71, 0x8c, 0x54, 0x29, 0x2a, 0xe2, 0x62, 0x6e, 0xdc, 0x9c, 0xcd, 0x74, + 0x63, 0xd1, 0xda, 0x1b, 0x7f, 0x44, 0xf4, 0x97, 0x72, 0xcb, 0x5f, 0x40, 0xea, 0x91, 0x13, 0xb2, + 0x77, 0x37, 0xb4, 0xa1, 0xa1, 0xa7, 0x64, 0xfc, 0xde, 0xbe, 0x99, 0x37, 0xcf, 0x86, 0xcc, 0xa2, + 0x59, 0xa3, 0xc9, 0x4b, 0x53, 0x15, 0xb9, 0xf1, 0x4a, 0xa1, 0x69, 0x7e, 0x58, 0x65, 0xb4, 0xd3, + 0x64, 0x70, 0x81, 0xb6, 0x64, 0x01, 0x66, 0xf5, 0x79, 0x4a, 0x4b, 0x5d, 0xea, 0x3c, 0xa2, 0x73, + 0x7f, 0x96, 0x87, 0x2a, 0x16, 0xf1, 0x5f, 0xfd, 0x55, 0x3a, 0xda, 0xc2, 0xee, 0xb2, 0x42, 0x9b, + 0xe3, 0x0f, 0x2c, 0xbc, 0x93, 0x5a, 0x35, 0xf8, 0xf3, 0x1d, 0xdc, 0x3a, 0xe3, 0x0b, 0x57, 0x83, + 0x94, 0xc0, 0xe0, 0xa4, 0xe5, 0x73, 0x5c, 0x79, 0xb4, 0x8e, 0xfe, 0x4c, 0xa0, 0xcf, 0xd1, 0xfa, + 0x73, 0xd7, 0x9c, 0x90, 0x15, 0xf4, 0xb7, 0xaa, 0x33, 0x61, 0x97, 0xc3, 0x64, 0x9c, 0x4c, 0x8e, + 0xa6, 0x9f, 0xaf, 0x36, 0xd9, 0x70, 0x2d, 0xce, 0xe5, 0x42, 0x38, 0xfc, 0x44, 0x0d, 0xae, 0xbc, + 0x34, 0xb8, 0x78, 0xb5, 0x14, 0x76, 0x49, 0x7f, 0x6f, 0xb2, 0x97, 0xa5, 0x74, 0x4b, 0x3f, 0x67, + 0x85, 0xbe, 0xc8, 0x83, 0xb5, 0xd7, 0x67, 0xda, 0xab, 0x85, 0x08, 0x2a, 0x39, 0xaa, 0x52, 0x2a, + 0xcc, 0x03, 0x95, 0x05, 0x49, 0x7e, 0xb3, 0x03, 0x79, 0x0b, 0x0f, 0xb4, 0x77, 0x95, 0x77, 0x76, + 0x78, 0x6f, 0x9c, 0x4c, 0x1e, 0x1d, 0x3f, 0x65, 0x71, 0x3b, 0xad, 0x19, 0xf6, 0x35, 0xda, 0x98, + 0x75, 0x78, 0xcb, 0x23, 0xcf, 0xe0, 0x10, 0x8d, 0xd1, 0x66, 0x78, 0x30, 0x4e, 0x26, 0xbd, 0x59, + 0x87, 0xd7, 0xe5, 0xf4, 0x21, 0x74, 0x4d, 0xb4, 0x43, 0x07, 0xf0, 0xb8, 0x35, 0x66, 0x2b, 0xad, + 0x2c, 0x52, 0x0d, 0x47, 0x27, 0x6b, 0x54, 0x5b, 0xa7, 0xef, 0xe1, 0xe0, 0x3b, 0x5e, 0x46, 0x7f, + 0xbd, 0x29, 0xbd, 0xda, 0x64, 0xa3, 0x5b, 0xfc, 0x55, 0x46, 0x2a, 0x27, 0x6c, 0x21, 0x25, 0xe5, + 0x81, 0x4e, 0x5e, 0xc0, 0xfd, 0x85, 0x70, 0xe2, 0xbf, 0x93, 0xf2, 0x48, 0xa1, 0x4f, 0xa0, 0xdf, + 0x34, 0xac, 0x27, 0x38, 0xfe, 0x95, 0x40, 0x97, 0xc7, 0xb4, 0xc9, 0x29, 0xf4, 0xb6, 0x61, 0x10, + 0xca, 0x76, 0x6f, 0x03, 0xdb, 0x4d, 0x2a, 0x6d, 0x3a, 0xc5, 0x5c, 0xff, 0xa2, 0xb4, 0xf3, 0x26, + 0x21, 0x5f, 0xa0, 0x5b, 0x5b, 0x25, 0xd9, 0xbf, 0x42, 0x37, 0xd2, 0x4d, 0xc7, 0xfb, 0x09, 0xcd, + 0x96, 0x3a, 0xe4, 0x14, 0x0e, 0xe3, 0xd8, 0x64, 0x74, 0xcb, 0x58, 0xd7, 0x16, 0x98, 0x66, 0x7b, + 0xf1, 0x56, 0x6b, 0xfa, 0xf1, 0xdb, 0x87, 0xbb, 0x2f, 0x46, 0x78, 0x2b, 0xb2, 0xc0, 0xeb, 0x8f, + 0x65, 0xde, 0x8d, 0x2b, 0x7d, 0xf7, 0x27, 0x00, 0x00, 0xff, 0xff, 0x1b, 0x11, 0xa1, 0x7b, 0x49, + 0x03, 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 + +// RunnerClient is the client API for Runner service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type RunnerClient interface { + // Execution returns a stream of executions that contains the Execution the Runner must execute. + // This request requires the credential token, obtained from the Register endpoint, to be injected in the request's metadata using the key "mesg_credential_token". + Execution(ctx context.Context, in *ExecutionRequest, opts ...grpc.CallOption) (Runner_ExecutionClient, error) + // Result should be used to return the result of an Execution. + // This request requires the credential token, obtained from the Register endpoint, to be injected in the request's metadata using the key "mesg_credential_token". + Result(ctx context.Context, in *ResultRequest, opts ...grpc.CallOption) (*ResultResponse, error) + // Event should be used to emits an event. + // This request requires the credential token, obtained from the Register endpoint, to be injected in the request's metadata using the key "mesg_credential_token". + Event(ctx context.Context, in *EventRequest, opts ...grpc.CallOption) (*EventResponse, error) +} + +type runnerClient struct { + cc *grpc.ClientConn +} + +func NewRunnerClient(cc *grpc.ClientConn) RunnerClient { + return &runnerClient{cc} +} + +func (c *runnerClient) Execution(ctx context.Context, in *ExecutionRequest, opts ...grpc.CallOption) (Runner_ExecutionClient, error) { + stream, err := c.cc.NewStream(ctx, &_Runner_serviceDesc.Streams[0], "/mesg.grpc.runner.Runner/Execution", opts...) + if err != nil { + return nil, err + } + x := &runnerExecutionClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type Runner_ExecutionClient interface { + Recv() (*execution.Execution, error) + grpc.ClientStream +} + +type runnerExecutionClient struct { + grpc.ClientStream +} + +func (x *runnerExecutionClient) Recv() (*execution.Execution, error) { + m := new(execution.Execution) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *runnerClient) Result(ctx context.Context, in *ResultRequest, opts ...grpc.CallOption) (*ResultResponse, error) { + out := new(ResultResponse) + err := c.cc.Invoke(ctx, "/mesg.grpc.runner.Runner/Result", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *runnerClient) Event(ctx context.Context, in *EventRequest, opts ...grpc.CallOption) (*EventResponse, error) { + out := new(EventResponse) + err := c.cc.Invoke(ctx, "/mesg.grpc.runner.Runner/Event", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// RunnerServer is the server API for Runner service. +type RunnerServer interface { + // Execution returns a stream of executions that contains the Execution the Runner must execute. + // This request requires the credential token, obtained from the Register endpoint, to be injected in the request's metadata using the key "mesg_credential_token". + Execution(*ExecutionRequest, Runner_ExecutionServer) error + // Result should be used to return the result of an Execution. + // This request requires the credential token, obtained from the Register endpoint, to be injected in the request's metadata using the key "mesg_credential_token". + Result(context.Context, *ResultRequest) (*ResultResponse, error) + // Event should be used to emits an event. + // This request requires the credential token, obtained from the Register endpoint, to be injected in the request's metadata using the key "mesg_credential_token". + Event(context.Context, *EventRequest) (*EventResponse, error) +} + +// UnimplementedRunnerServer can be embedded to have forward compatible implementations. +type UnimplementedRunnerServer struct { +} + +func (*UnimplementedRunnerServer) Execution(req *ExecutionRequest, srv Runner_ExecutionServer) error { + return status.Errorf(codes.Unimplemented, "method Execution not implemented") +} +func (*UnimplementedRunnerServer) Result(ctx context.Context, req *ResultRequest) (*ResultResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Result not implemented") +} +func (*UnimplementedRunnerServer) Event(ctx context.Context, req *EventRequest) (*EventResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Event not implemented") +} + +func RegisterRunnerServer(s *grpc.Server, srv RunnerServer) { + s.RegisterService(&_Runner_serviceDesc, srv) +} + +func _Runner_Execution_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(ExecutionRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(RunnerServer).Execution(m, &runnerExecutionServer{stream}) +} + +type Runner_ExecutionServer interface { + Send(*execution.Execution) error + grpc.ServerStream +} + +type runnerExecutionServer struct { + grpc.ServerStream +} + +func (x *runnerExecutionServer) Send(m *execution.Execution) error { + return x.ServerStream.SendMsg(m) +} + +func _Runner_Result_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ResultRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(RunnerServer).Result(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/mesg.grpc.runner.Runner/Result", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(RunnerServer).Result(ctx, req.(*ResultRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Runner_Event_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(EventRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(RunnerServer).Event(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/mesg.grpc.runner.Runner/Event", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(RunnerServer).Event(ctx, req.(*EventRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Runner_serviceDesc = grpc.ServiceDesc{ + ServiceName: "mesg.grpc.runner.Runner", + HandlerType: (*RunnerServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Result", + Handler: _Runner_Result_Handler, + }, + { + MethodName: "Event", + Handler: _Runner_Event_Handler, + }, + }, + Streams: []grpc.StreamDesc{ + { + StreamName: "Execution", + Handler: _Runner_Execution_Handler, + ServerStreams: true, + }, + }, + Metadata: "server/grpc/runner/runner.proto", +} diff --git a/server/grpc/runner/runner.proto b/server/grpc/runner/runner.proto new file mode 100644 index 000000000..b3b260359 --- /dev/null +++ b/server/grpc/runner/runner.proto @@ -0,0 +1,62 @@ +syntax = "proto3"; + +import "gogo/protobuf/gogoproto/gogo.proto"; +import "protobuf/types/execution.proto"; +import "protobuf/types/struct.proto"; + +package mesg.grpc.runner; +option go_package = "github.com/mesg-foundation/engine/service/grpc/runner"; + +// This is the API the Runners use to interact with the Engine. +service Runner { + // Execution returns a stream of executions that contains the Execution the Runner must execute. + // This request requires the credential token, obtained from the Register endpoint, to be injected in the request's metadata using the key "mesg_credential_token". + rpc Execution(ExecutionRequest) returns (stream types.Execution) {} + + // Result should be used to return the result of an Execution. + // This request requires the credential token, obtained from the Register endpoint, to be injected in the request's metadata using the key "mesg_credential_token". + rpc Result(ResultRequest) returns (ResultResponse) {} + + // Event should be used to emits an event. + // This request requires the credential token, obtained from the Register endpoint, to be injected in the request's metadata using the key "mesg_credential_token". + rpc Event(EventRequest) returns (EventResponse) {} +} + +// ExecutionRequest is the request of the endpoint Execution. +message ExecutionRequest {} + +// EventRequest is the request of the endpoint Result. +message ResultRequest { + // Execution's hash of the executed execution. + bytes executionHash = 1 [ + (gogoproto.moretags) = 'validate:"required,hash"', + (gogoproto.casttype) = "github.com/mesg-foundation/engine/hash.Hash" + ]; + + // Execution's result. + oneof result { + // outputs of the result. + mesg.protobuf.Struct outputs = 2; + + // error should contain the error occured during the execution. + string error = 3; + } +} + +// ResultResponse is the response of the endpoint Result. +message ResultResponse {} + + +// EventRequest is the request of the endpoint Event. +message EventRequest { + // Event's key + string key = 1 [ + (gogoproto.moretags) = 'validate:"required,printascii"' + ]; + + // Event's data + mesg.protobuf.Struct data = 2; +} + +// EventResponse is the response of the endpoint Event. +message EventResponse {} diff --git a/server/grpc/server.go b/server/grpc/server.go index e164f72c7..954349f60 100644 --- a/server/grpc/server.go +++ b/server/grpc/server.go @@ -3,6 +3,7 @@ package grpc import ( "context" "net" + "sync" "time" grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware" @@ -11,9 +12,8 @@ import ( "github.com/mesg-foundation/engine/cosmos" "github.com/mesg-foundation/engine/event/publisher" "github.com/mesg-foundation/engine/ext/xvalidator" - protobuf_api "github.com/mesg-foundation/engine/protobuf/api" - "github.com/mesg-foundation/engine/runner/builder" - "github.com/mesg-foundation/engine/server/grpc/api" + "github.com/mesg-foundation/engine/server/grpc/orchestrator" + "github.com/mesg-foundation/engine/server/grpc/runner" "github.com/sirupsen/logrus" "google.golang.org/grpc" "google.golang.org/grpc/keepalive" @@ -22,20 +22,18 @@ import ( // Server contains the server config. type Server struct { - instance *grpc.Server - mc *cosmos.ModuleClient - ep *publisher.EventPublisher - b *builder.Builder - execPrice string + instance *grpc.Server + rpc *cosmos.RPC + ep *publisher.EventPublisher + authorizedPubKeys []string } // New returns a new gRPC server. -func New(mc *cosmos.ModuleClient, ep *publisher.EventPublisher, b *builder.Builder, execPrice string) *Server { +func New(rpc *cosmos.RPC, ep *publisher.EventPublisher, authorizedPubKeys []string) *Server { return &Server{ - mc: mc, - ep: ep, - b: b, - execPrice: execPrice, + rpc: rpc, + ep: ep, + authorizedPubKeys: authorizedPubKeys, } } @@ -63,7 +61,9 @@ func (s *Server) Serve(address string) error { validateInterceptor, )), ) - s.register() + if err := s.register(); err != nil { + return err + } grpc_prometheus.Register(s.instance) logrus.WithField("module", "grpc").Info("server listens on ", ln.Addr()) return s.instance.Serve(ln) @@ -74,22 +74,29 @@ func (s *Server) Close() { s.instance.GracefulStop() } +// TODO: could use github.com/grpc-ecosystem/go-grpc-middleware@v1.2.0/validator/validator.go for validating any request with a `Validate() error` function. func validateInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { - if err := xvalidator.Validate.Struct(req); err != nil { + if err := xvalidator.Struct(req); err != nil { return nil, err } return handler(ctx, req) } // register all server -func (s *Server) register() { - protobuf_api.RegisterEventServer(s.instance, api.NewEventServer(s.ep)) - protobuf_api.RegisterExecutionServer(s.instance, api.NewExecutionServer(s.mc, s.execPrice)) - protobuf_api.RegisterInstanceServer(s.instance, api.NewInstanceServer(s.mc)) - protobuf_api.RegisterServiceServer(s.instance, api.NewServiceServer(s.mc)) - protobuf_api.RegisterProcessServer(s.instance, api.NewProcessServer(s.mc)) - protobuf_api.RegisterOwnershipServer(s.instance, api.NewOwnershipServer(s.mc)) - protobuf_api.RegisterRunnerServer(s.instance, api.NewRunnerServer(s.mc, s.b)) +func (s *Server) register() error { + tokenToRunnerHash := &sync.Map{} + + runner.RegisterRunnerServer(s.instance, runner.NewServer(s.rpc, s.ep, tokenToRunnerHash)) + + authorizer, err := orchestrator.NewAuthorizer(s.rpc.Codec(), s.authorizedPubKeys) + if err != nil { + return err + } + orchestrator.RegisterEventServer(s.instance, orchestrator.NewEventServer(s.ep, authorizer)) + orchestrator.RegisterExecutionServer(s.instance, orchestrator.NewExecutionServer(s.rpc, authorizer)) + orchestrator.RegisterRunnerServer(s.instance, orchestrator.NewRunnerServer(s.rpc, tokenToRunnerHash, authorizer)) reflection.Register(s.instance) + + return nil } diff --git a/server/grpc/server_test.go b/server/grpc/server_test.go deleted file mode 100644 index 697cd3427..000000000 --- a/server/grpc/server_test.go +++ /dev/null @@ -1,17 +0,0 @@ -package grpc - -import ( - "testing" - "time" - - "github.com/stretchr/testify/require" -) - -func TestServerServe(t *testing.T) { - s := New(nil, nil, nil, "10000atto") - go func() { - time.Sleep(500 * time.Millisecond) - s.Close() - }() - require.NoError(t, s.Serve("localhost:50052")) -} diff --git a/service/service.go b/service/service.go index f2aae2664..2484b3b55 100644 --- a/service/service.go +++ b/service/service.go @@ -3,9 +3,40 @@ package service import ( "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/mesg-foundation/engine/hash" "github.com/mesg-foundation/engine/protobuf/types" + "github.com/tendermint/tendermint/crypto" ) +// New initializes a new Service. +func New(sid, name, description string, configuration Service_Configuration, tasks []*Service_Task, events []*Service_Event, dependencies []*Service_Dependency, repository, source string) (*Service, error) { + // create service + srv := &Service{ + Sid: sid, + Name: name, + Description: description, + Configuration: configuration, + Tasks: tasks, + Events: events, + Dependencies: dependencies, + Repository: repository, + Source: source, + } + + // calculate and apply hash to service. + srv.Hash = hash.Dump(srv) + srv.Address = sdk.AccAddress(crypto.AddressHash(srv.Hash)) + + // set a sid if this one is empty (yes, after hash calculation..) + if srv.Sid == "" { + // make sure that sid doesn't have the same length with id. + srv.Sid = "_" + srv.Hash.String() + } + + return srv, srv.Validate() +} + // MainServiceKey is key for main service. const MainServiceKey = "service" diff --git a/service/service.pb.go b/service/service.pb.go index 679d5ab49..f72579e90 100644 --- a/service/service.pb.go +++ b/service/service.pb.go @@ -27,7 +27,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Service represents the service's type. type Service struct { // Service's hash. - Hash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,10,opt,name=hash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"hash" hash:"-" validate:"required"` + Hash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,10,opt,name=hash,proto3,casttype=github.com/mesg-foundation/engine/hash.Hash" json:"hash,omitempty" hash:"-" validate:"required,hash"` // Service's sid. Sid string `protobuf:"bytes,12,opt,name=sid,proto3" json:"sid,omitempty" hash:"name:12" validate:"required,printascii,max=63,domain"` // Service's name. @@ -47,7 +47,7 @@ type Service struct { // The hash id of service's source code on IPFS. Source string `protobuf:"bytes,13,opt,name=source,proto3" json:"source,omitempty" hash:"name:13" validate:"required,printascii"` // The address of the service. - Address github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,14,opt,name=address,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"address,omitempty" hash:"-" validate:"accaddress"` + Address github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,14,opt,name=address,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"address,omitempty" hash:"-" validate:"required,accaddress"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -80,7 +80,7 @@ var xxx_messageInfo_Service proto.InternalMessageInfo // Events are emitted by the service whenever the service wants. type Service_Event struct { // Event's key. - Key string `protobuf:"bytes,4,opt,name=key,proto3" json:"key,omitempty" hash:"name:4" validate:"printascii"` + Key string `protobuf:"bytes,4,opt,name=key,proto3" json:"key,omitempty" hash:"name:4" validate:"required,printascii"` // Event's name. Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty" hash:"name:1" validate:"printascii"` // Event's description. @@ -119,7 +119,7 @@ var xxx_messageInfo_Service_Event proto.InternalMessageInfo // Task is a function that requires inputs and returns output. type Service_Task struct { // Task's key. - Key string `protobuf:"bytes,8,opt,name=key,proto3" json:"key,omitempty" hash:"name:8" validate:"printascii"` + Key string `protobuf:"bytes,8,opt,name=key,proto3" json:"key,omitempty" hash:"name:8" validate:"required,printascii"` // Task's name. Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty" hash:"name:1" validate:"printascii"` // Task's description. @@ -160,7 +160,7 @@ var xxx_messageInfo_Service_Task proto.InternalMessageInfo // Parameter describes the task's inputs, the task's outputs, and the event's data. type Service_Parameter struct { // Parameter's key. - Key string `protobuf:"bytes,8,opt,name=key,proto3" json:"key,omitempty" hash:"name:8" validate:"printascii"` + Key string `protobuf:"bytes,8,opt,name=key,proto3" json:"key,omitempty" hash:"name:8" validate:"required,printascii"` // Parameter's name. Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty" hash:"name:1" validate:"printascii"` // Parameter's description. @@ -248,9 +248,9 @@ var xxx_messageInfo_Service_Configuration proto.InternalMessageInfo // A dependency is a configuration of an other container that runs separately from the service. type Service_Dependency struct { // Dependency's key. - Key string `protobuf:"bytes,8,opt,name=key,proto3" json:"key,omitempty" hash:"name:8" validate:"printascii"` + Key string `protobuf:"bytes,8,opt,name=key,proto3" json:"key,omitempty" hash:"name:8" validate:"required,printascii"` // Image's name of the container. - Image string `protobuf:"bytes,1,opt,name=image,proto3" json:"image,omitempty" hash:"name:1" validate:"printascii"` + Image string `protobuf:"bytes,1,opt,name=image,proto3" json:"image,omitempty" hash:"name:1" validate:"required,printascii"` // List of volumes. Volumes []string `protobuf:"bytes,2,rep,name=volumes,proto3" json:"volumes,omitempty" hash:"name:2" validate:"unique,dive,printascii"` // List of volumes mounted from other dependencies. @@ -304,70 +304,70 @@ func init() { func init() { proto.RegisterFile("service.proto", fileDescriptor_a0b84a42fa06f626) } var fileDescriptor_a0b84a42fa06f626 = []byte{ - // 995 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x97, 0x4d, 0x73, 0xdb, 0x44, - 0x18, 0xc7, 0xeb, 0x48, 0xb6, 0x93, 0x4d, 0xc2, 0x0c, 0x7b, 0xda, 0x7a, 0x20, 0x52, 0xc5, 0x0c, - 0xb8, 0xe0, 0x97, 0x26, 0x6e, 0x43, 0x93, 0x4e, 0x80, 0x98, 0xd2, 0xa1, 0xcc, 0xf0, 0xa6, 0xc0, - 0x30, 0xd3, 0x99, 0x1e, 0xd6, 0xd2, 0x46, 0x59, 0x1c, 0xed, 0xaa, 0xbb, 0x2b, 0x0f, 0xbe, 0xf3, - 0x05, 0xf8, 0x16, 0xf0, 0x11, 0xb8, 0xc2, 0xa5, 0x9f, 0x81, 0x83, 0x66, 0xe0, 0x23, 0xe8, 0xc8, - 0x89, 0xd1, 0xca, 0x4e, 0xe4, 0x58, 0x76, 0x5e, 0xca, 0x05, 0x4e, 0xb5, 0x3a, 0xcf, 0xff, 0xf7, - 0x97, 0x9e, 0xe7, 0xff, 0x68, 0x23, 0xb0, 0x29, 0x89, 0x18, 0x51, 0x8f, 0x74, 0x22, 0xc1, 0x15, - 0x87, 0x20, 0x24, 0x32, 0xe8, 0xa8, 0x71, 0x44, 0x64, 0xc3, 0x09, 0x78, 0xc0, 0xbb, 0xfa, 0xff, - 0x07, 0xf1, 0x71, 0x37, 0xbb, 0xd2, 0x17, 0xfa, 0x57, 0x5e, 0xef, 0xfc, 0x7e, 0x1b, 0xd4, 0x8f, - 0x72, 0x02, 0x0c, 0x80, 0x79, 0x82, 0xe5, 0x09, 0x02, 0x76, 0xa5, 0xb9, 0xd1, 0x3f, 0x7a, 0x99, - 0x58, 0xb7, 0xfe, 0x48, 0xac, 0xf7, 0x02, 0xaa, 0x4e, 0xe2, 0x41, 0xc7, 0xe3, 0x61, 0x37, 0x83, - 0xb7, 0x8f, 0x79, 0xcc, 0x7c, 0xac, 0x28, 0x67, 0x5d, 0xc2, 0x02, 0xca, 0x48, 0x37, 0x53, 0x75, - 0x3e, 0xc5, 0xf2, 0x24, 0x4d, 0xac, 0x37, 0xb2, 0x8b, 0x7d, 0xa7, 0xed, 0xd8, 0x23, 0x7c, 0x4a, - 0x7d, 0xac, 0xc8, 0xbe, 0x23, 0xc8, 0x8b, 0x98, 0x0a, 0xe2, 0x3b, 0xae, 0x36, 0x80, 0x5f, 0x03, - 0x43, 0x52, 0x1f, 0x6d, 0xd8, 0x95, 0xe6, 0x5a, 0xff, 0xc3, 0x34, 0xb1, 0x1e, 0xe5, 0x22, 0x86, - 0x43, 0xb2, 0xbf, 0xbd, 0x53, 0x26, 0x6d, 0x45, 0x82, 0x32, 0x85, 0xa5, 0x47, 0x69, 0x2b, 0xc4, - 0x3f, 0x1c, 0xec, 0xf6, 0x5a, 0x3e, 0x0f, 0x31, 0x65, 0x8e, 0x9b, 0xb1, 0xe0, 0x63, 0x60, 0x66, - 0x6a, 0x54, 0xd1, 0xcc, 0x7b, 0x69, 0x62, 0xb5, 0x8a, 0xcc, 0x4b, 0x90, 0x8e, 0xab, 0xd5, 0xf0, - 0x29, 0x58, 0xf7, 0x89, 0xf4, 0x04, 0x8d, 0xb2, 0xc7, 0x43, 0x2b, 0x1a, 0xf6, 0x4e, 0x9a, 0x58, - 0x6f, 0x15, 0x60, 0x33, 0xf7, 0x57, 0x64, 0x14, 0xb5, 0x50, 0x80, 0x4d, 0x8f, 0xb3, 0x63, 0x1a, - 0xc4, 0x42, 0xf7, 0x0a, 0xad, 0xda, 0x95, 0xe6, 0xfa, 0xce, 0x9d, 0xce, 0xf9, 0x80, 0x3a, 0x93, - 0xc6, 0x77, 0x3e, 0x2e, 0x16, 0xf6, 0xef, 0x66, 0x8d, 0x4f, 0x13, 0xeb, 0x4e, 0xc1, 0xf3, 0x61, - 0x79, 0x3b, 0x67, 0x2d, 0xe0, 0x33, 0x50, 0x55, 0x58, 0x0e, 0x25, 0xaa, 0xda, 0x46, 0x73, 0x7d, - 0x07, 0x95, 0x79, 0x7d, 0x83, 0xe5, 0xb0, 0xff, 0x6e, 0x9a, 0x58, 0x6f, 0x17, 0xf0, 0x0f, 0x8a, - 0x78, 0x9f, 0x8e, 0x48, 0xeb, 0xdc, 0x23, 0x47, 0xc2, 0xe7, 0xa0, 0x46, 0x46, 0x84, 0x29, 0x89, - 0x6a, 0x1a, 0x7e, 0xbb, 0x0c, 0xfe, 0x49, 0x56, 0x31, 0x47, 0xdf, 0x5d, 0x42, 0x9f, 0x40, 0x21, - 0x03, 0x1b, 0x3e, 0x89, 0x08, 0xf3, 0x09, 0xf3, 0x28, 0x91, 0xa8, 0xae, 0x4d, 0xb6, 0xca, 0x4c, - 0x1e, 0x4f, 0xeb, 0xc6, 0x73, 0x4e, 0xef, 0x2f, 0x71, 0x9a, 0xe1, 0xc3, 0xcf, 0x00, 0x10, 0x24, - 0xe2, 0x92, 0x2a, 0x2e, 0xc6, 0x68, 0x4d, 0x0f, 0xfa, 0x22, 0x6d, 0xaf, 0x48, 0xe3, 0x21, 0x55, - 0x24, 0x8c, 0xd4, 0xb8, 0x15, 0x0b, 0xea, 0xb8, 0x05, 0x35, 0x7c, 0x0a, 0x6a, 0x92, 0xc7, 0xc2, - 0x23, 0x68, 0x53, 0x73, 0xb6, 0xd3, 0xc4, 0x6a, 0x17, 0xd3, 0xd7, 0xbb, 0x34, 0x7e, 0x13, 0x00, - 0x0c, 0x41, 0x1d, 0xfb, 0xbe, 0x20, 0x52, 0xa2, 0xd7, 0xf2, 0x2d, 0x4c, 0x13, 0x6b, 0xab, 0x64, - 0xa5, 0xb0, 0xe7, 0x4d, 0x0a, 0x9d, 0xbf, 0x13, 0xab, 0x5d, 0xd8, 0x51, 0x8f, 0xcb, 0x90, 0xcb, - 0xc9, 0x3f, 0x6d, 0xe9, 0x0f, 0xbb, 0x79, 0xfb, 0x0e, 0x3d, 0xef, 0x30, 0x57, 0xb8, 0x53, 0x8f, - 0xc6, 0x2f, 0x2b, 0xa0, 0xaa, 0x67, 0x06, 0xf7, 0x80, 0x31, 0x24, 0x63, 0x64, 0x96, 0x26, 0xfe, - 0xfe, 0xa2, 0xc4, 0x67, 0x1a, 0xf8, 0x68, 0x66, 0xf5, 0x2e, 0x6a, 0xb7, 0x17, 0x69, 0xff, 0xf5, - 0x8d, 0x7b, 0x0e, 0x4c, 0x1f, 0x2b, 0x8c, 0x0c, 0x1d, 0x9d, 0x37, 0xcb, 0xa2, 0xf3, 0x15, 0x16, - 0x38, 0x24, 0x8a, 0x88, 0xb9, 0x59, 0xf7, 0x96, 0x24, 0x47, 0x63, 0x1b, 0x3f, 0x19, 0xc0, 0xcc, - 0x96, 0x67, 0xda, 0xaa, 0xd5, 0xd2, 0x5b, 0x7d, 0xf8, 0x9f, 0x68, 0x15, 0x06, 0x35, 0xca, 0xa2, - 0xf8, 0x6c, 0x99, 0xaf, 0xd9, 0xac, 0xa5, 0x0b, 0x9d, 0x83, 0xa1, 0x07, 0xea, 0x3c, 0x56, 0xda, - 0xa3, 0x7e, 0x13, 0x8f, 0x65, 0xab, 0x3c, 0x25, 0x37, 0x7e, 0x34, 0xc1, 0xda, 0x19, 0xe2, 0xff, - 0x30, 0x98, 0x21, 0x30, 0xb3, 0x06, 0x21, 0x43, 0x33, 0xbe, 0x4b, 0x13, 0xeb, 0x68, 0x51, 0x48, - 0xcb, 0x4e, 0x46, 0xce, 0x08, 0x3f, 0x3e, 0x38, 0x52, 0x82, 0xb2, 0xc0, 0xfe, 0x22, 0x0e, 0x07, - 0x44, 0xd8, 0x7d, 0xce, 0x4f, 0x09, 0x66, 0xf6, 0x97, 0x83, 0xef, 0x89, 0xa7, 0xec, 0x43, 0x36, - 0x76, 0x5c, 0x6d, 0x02, 0xdb, 0x60, 0x95, 0x6b, 0x5b, 0x7c, 0xaa, 0x17, 0x7f, 0xb5, 0xff, 0x7a, - 0x9a, 0x58, 0x9b, 0x33, 0x8b, 0xef, 0x9e, 0x95, 0x64, 0xe5, 0x82, 0x44, 0x04, 0x2b, 0xe2, 0xeb, - 0x17, 0xe6, 0x7c, 0xf9, 0x9e, 0xe3, 0x9e, 0x95, 0x40, 0x0a, 0x6a, 0x5c, 0x5b, 0x22, 0x70, 0x95, - 0xf9, 0xef, 0xa4, 0x89, 0xd5, 0x29, 0xf6, 0xfc, 0x5e, 0xf1, 0x61, 0x63, 0x46, 0x5f, 0xc4, 0xa4, - 0x75, 0x31, 0x6b, 0xb9, 0x41, 0xe3, 0x37, 0x03, 0x6c, 0xce, 0x9c, 0xa1, 0xf0, 0x73, 0x50, 0x1f, - 0xf1, 0xd3, 0x38, 0x24, 0x12, 0x55, 0x6c, 0xa3, 0xb9, 0xd6, 0xef, 0xa5, 0x89, 0xd5, 0x5d, 0x34, - 0xd2, 0x22, 0xbd, 0x38, 0x9a, 0x29, 0x03, 0x7e, 0x0b, 0xd6, 0x27, 0x3f, 0x9f, 0x08, 0x1e, 0xa2, - 0x95, 0x52, 0xe4, 0xce, 0x55, 0x90, 0x45, 0x0e, 0x7c, 0x02, 0xaa, 0x11, 0x17, 0x4a, 0xea, 0x57, - 0xd6, 0xfc, 0x5f, 0x2d, 0xbd, 0x85, 0x40, 0x2e, 0x54, 0x88, 0x23, 0xc7, 0xcd, 0xe5, 0xf0, 0x23, - 0x60, 0x62, 0x11, 0x48, 0x64, 0x6a, 0x4c, 0x2b, 0x4d, 0xac, 0xe6, 0xd2, 0xc3, 0x7d, 0x26, 0xc2, - 0x99, 0x12, 0x1e, 0x82, 0xba, 0xc7, 0xc3, 0x10, 0x33, 0x1f, 0x55, 0xaf, 0x77, 0x04, 0x4c, 0x75, - 0xf0, 0x03, 0x60, 0x10, 0x36, 0xd2, 0x2f, 0x94, 0xf9, 0x7b, 0xd8, 0x5d, 0xf4, 0x28, 0x84, 0x8d, - 0x1c, 0x37, 0x13, 0x36, 0x7e, 0x35, 0x01, 0x38, 0x3f, 0xda, 0x5f, 0x65, 0x99, 0x0f, 0x40, 0x95, - 0x86, 0x38, 0xb8, 0xf6, 0x36, 0xe7, 0xaa, 0x62, 0x76, 0x5e, 0x61, 0xd0, 0x8b, 0xb2, 0x63, 0x94, - 0x22, 0x7b, 0x37, 0xcf, 0x8e, 0x59, 0x9a, 0x9d, 0xfb, 0xd7, 0xcd, 0xce, 0x15, 0xe6, 0x76, 0xd3, - 0xec, 0x3c, 0xb8, 0x6a, 0x76, 0xd6, 0x4a, 0xef, 0x61, 0xef, 0xd2, 0xec, 0xf4, 0x7b, 0x2f, 0xff, - 0xdc, 0xba, 0xf5, 0xf3, 0x5f, 0x5b, 0x95, 0x67, 0x77, 0x2f, 0xff, 0x5a, 0x99, 0x7c, 0x30, 0x0d, - 0x6a, 0xfa, 0x0b, 0xa8, 0xf7, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xdb, 0x41, 0x89, 0x13, 0x42, - 0x0d, 0x00, 0x00, + // 1000 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x97, 0xdd, 0x6e, 0xdb, 0x36, + 0x14, 0xc7, 0xeb, 0x48, 0xb6, 0x63, 0x26, 0x1e, 0x30, 0x5e, 0xb1, 0x06, 0x16, 0xa9, 0x1a, 0xb0, + 0xba, 0x9b, 0x3f, 0x1a, 0x3b, 0xcd, 0x9a, 0x14, 0xdd, 0x16, 0xaf, 0x0b, 0xd6, 0x01, 0xfb, 0x52, + 0x3a, 0x0c, 0x28, 0xd6, 0x0b, 0x5a, 0x62, 0x6c, 0xce, 0x11, 0xa9, 0x92, 0x92, 0x31, 0x3f, 0xc4, + 0x5e, 0x60, 0x4f, 0xb0, 0xeb, 0x3d, 0xc2, 0xae, 0x0a, 0xec, 0x1d, 0x04, 0x6c, 0x8f, 0xa0, 0xcb, + 0x5e, 0x0d, 0xa2, 0xec, 0x44, 0x8e, 0x65, 0x3b, 0xcd, 0x72, 0xb3, 0x5e, 0x45, 0x8a, 0xcf, 0xf9, + 0xfd, 0xc9, 0x73, 0xfe, 0x87, 0x92, 0x40, 0x55, 0x12, 0x31, 0xa6, 0x0e, 0x69, 0xf9, 0x82, 0x07, + 0x1c, 0x02, 0x8f, 0xc8, 0x41, 0x2b, 0x98, 0xf8, 0x44, 0xd6, 0xac, 0x01, 0x1f, 0xf0, 0xb6, 0xfa, + 0x7f, 0x3f, 0x3c, 0x6d, 0x27, 0x77, 0xea, 0x46, 0x5d, 0xa5, 0xf1, 0xd6, 0xeb, 0xdb, 0xa0, 0x7c, + 0x92, 0x12, 0xe0, 0x10, 0xe8, 0x43, 0x2c, 0x87, 0x08, 0x98, 0x85, 0xfa, 0x76, 0xef, 0x59, 0x1c, + 0x19, 0x77, 0x92, 0xfb, 0x43, 0xab, 0x69, 0x99, 0x63, 0x7c, 0x46, 0x5d, 0x1c, 0x90, 0x43, 0x4b, + 0x90, 0x97, 0x21, 0x15, 0xc4, 0x6d, 0x24, 0xbf, 0x59, 0xaf, 0x23, 0xe3, 0xa3, 0x01, 0x0d, 0x86, + 0x61, 0xbf, 0xe5, 0x70, 0xaf, 0x9d, 0xa8, 0x37, 0x4f, 0x79, 0xc8, 0x5c, 0x1c, 0x50, 0xce, 0xda, + 0x84, 0x0d, 0x28, 0x23, 0xed, 0x24, 0xb4, 0xf5, 0x25, 0x96, 0x43, 0x5b, 0x29, 0xc0, 0xef, 0x81, + 0x26, 0xa9, 0x8b, 0xb6, 0xcd, 0x42, 0xbd, 0xd2, 0xfb, 0x34, 0x8e, 0x8c, 0x47, 0xa9, 0x10, 0xc3, + 0x1e, 0x39, 0xdc, 0xed, 0xe4, 0xca, 0xf9, 0x82, 0xb2, 0x00, 0x4b, 0x87, 0xd2, 0x86, 0x87, 0x7f, + 0x79, 0xbc, 0xdf, 0x6d, 0xb8, 0xdc, 0xc3, 0x94, 0x59, 0x76, 0xc2, 0x82, 0x4f, 0x80, 0x9e, 0x64, + 0xa3, 0x82, 0x62, 0xde, 0x8f, 0x23, 0xa3, 0x91, 0x65, 0xae, 0x41, 0x5a, 0xb6, 0xca, 0x86, 0x4f, + 0xc1, 0x96, 0x4b, 0xa4, 0x23, 0xa8, 0x9f, 0x2c, 0x1f, 0x6d, 0x28, 0xd8, 0xdd, 0x38, 0x32, 0xde, + 0xcf, 0xc0, 0xe6, 0xd6, 0x97, 0x65, 0x64, 0x73, 0xa1, 0x00, 0x55, 0x87, 0xb3, 0x53, 0x3a, 0x08, + 0x85, 0xaa, 0x05, 0xda, 0x34, 0x0b, 0xf5, 0xad, 0xce, 0x9d, 0xd6, 0x45, 0x87, 0x5a, 0xd3, 0xca, + 0xb7, 0x3e, 0xcf, 0x06, 0xf6, 0xee, 0xbd, 0x8a, 0x8c, 0x5b, 0x17, 0xd5, 0x57, 0x9a, 0x0f, 0xf3, + 0x36, 0x60, 0xd9, 0xf3, 0x12, 0xf0, 0x39, 0x28, 0x06, 0x58, 0x8e, 0x24, 0x2a, 0x9a, 0x5a, 0x7d, + 0xab, 0x83, 0xf2, 0xb4, 0x9e, 0x61, 0x39, 0xea, 0x7d, 0x18, 0x47, 0xc6, 0x07, 0x19, 0xfc, 0x83, + 0x2c, 0xde, 0xa5, 0x63, 0xd2, 0xb8, 0xd0, 0x48, 0x91, 0xf0, 0x05, 0x28, 0x91, 0x31, 0x61, 0x81, + 0x44, 0x25, 0x05, 0xbf, 0x9d, 0x07, 0xff, 0x22, 0x89, 0x58, 0xa0, 0xef, 0xaf, 0xa0, 0x4f, 0xa1, + 0x90, 0x81, 0x6d, 0x97, 0xf8, 0x84, 0xb9, 0x84, 0x39, 0x94, 0x48, 0x54, 0x56, 0x22, 0x3b, 0x79, + 0x22, 0x4f, 0x66, 0x71, 0x93, 0x05, 0xa5, 0x8f, 0x57, 0x28, 0xcd, 0xf1, 0xe1, 0x57, 0x00, 0x08, + 0xe2, 0x73, 0x49, 0x03, 0x2e, 0x26, 0xa8, 0xa2, 0x1a, 0x7d, 0x99, 0x76, 0x90, 0xa5, 0x71, 0x8f, + 0x06, 0xc4, 0xf3, 0x83, 0x49, 0x23, 0x14, 0xd4, 0xb2, 0x33, 0xd9, 0xf0, 0x29, 0x28, 0x49, 0x1e, + 0x0a, 0x87, 0xa0, 0xaa, 0xe2, 0xec, 0xc6, 0x91, 0xd1, 0xcc, 0xba, 0xaf, 0xbb, 0xd6, 0x7e, 0x53, + 0x00, 0x1c, 0x83, 0x32, 0x76, 0x5d, 0x41, 0xa4, 0x44, 0xef, 0xa8, 0x31, 0xfc, 0x29, 0x8e, 0x8c, + 0xbb, 0xab, 0xc6, 0x10, 0x3b, 0xce, 0x34, 0x23, 0x19, 0xc6, 0x66, 0x66, 0x18, 0x1d, 0x2e, 0x3d, + 0x2e, 0xa7, 0x7f, 0x9a, 0xd2, 0x1d, 0xb5, 0xd3, 0x3a, 0x1e, 0x39, 0xce, 0x51, 0x9a, 0x61, 0xcf, + 0xc4, 0x6a, 0x7f, 0x6c, 0x80, 0xa2, 0x6a, 0x1e, 0xec, 0x01, 0x6d, 0x44, 0x26, 0x48, 0xcf, 0x9d, + 0xa3, 0xbd, 0xb5, 0x1b, 0x49, 0x92, 0xe1, 0xa3, 0xb9, 0x61, 0xbc, 0x3c, 0x3f, 0xbb, 0xcb, 0xe6, + 0xe7, 0xc6, 0x67, 0xf0, 0x05, 0xd0, 0x5d, 0x1c, 0x60, 0xa4, 0x29, 0x33, 0xbd, 0x97, 0x67, 0xa6, + 0xef, 0xb0, 0xc0, 0x1e, 0x09, 0x88, 0x58, 0xe8, 0x7e, 0x77, 0x85, 0x97, 0x14, 0xb6, 0xf6, 0x9b, + 0x06, 0xf4, 0x64, 0x9c, 0x66, 0x35, 0xdb, 0xcc, 0xad, 0xd9, 0xc3, 0xff, 0x57, 0xcd, 0x30, 0x28, + 0x51, 0xe6, 0x87, 0xe7, 0x73, 0xfe, 0x86, 0x55, 0x5b, 0x39, 0xeb, 0x29, 0x18, 0x3a, 0xa0, 0xcc, + 0xc3, 0x40, 0x69, 0x94, 0xaf, 0xa3, 0xb1, 0x6a, 0xca, 0x67, 0xe4, 0xda, 0xaf, 0x3a, 0xa8, 0x9c, + 0x23, 0xde, 0xaa, 0x0e, 0x8d, 0x80, 0x9e, 0x54, 0x0a, 0x69, 0x8a, 0xf1, 0x63, 0x1c, 0x19, 0x27, + 0xcb, 0x6c, 0x9b, 0xf7, 0xf4, 0xe4, 0x8c, 0xf0, 0xd3, 0xc7, 0x27, 0x81, 0xa0, 0x6c, 0x60, 0x7e, + 0x13, 0x7a, 0x7d, 0x22, 0xcc, 0x1e, 0xe7, 0x67, 0x04, 0x33, 0xf3, 0xdb, 0xfe, 0xcf, 0xc4, 0x09, + 0xcc, 0x23, 0x36, 0xb1, 0x6c, 0x25, 0x02, 0x9b, 0x60, 0x93, 0x2b, 0x59, 0x7c, 0xa6, 0xce, 0x84, + 0xcd, 0xde, 0xbb, 0x71, 0x64, 0x54, 0xe7, 0xce, 0x04, 0xfb, 0x3c, 0x24, 0x09, 0x17, 0xc4, 0x27, + 0x38, 0x20, 0xae, 0x3a, 0x54, 0x17, 0xc3, 0x0f, 0x2c, 0xfb, 0x3c, 0x04, 0x52, 0x50, 0xe2, 0x4a, + 0x12, 0x81, 0xab, 0x18, 0xa1, 0x13, 0x47, 0x46, 0x2b, 0x5b, 0xf3, 0xfb, 0xd9, 0xcd, 0x86, 0x8c, + 0xbe, 0x0c, 0x49, 0xe3, 0xb2, 0xe9, 0x52, 0x81, 0xda, 0x9f, 0x1a, 0xa8, 0xce, 0x3d, 0x67, 0xe1, + 0xd7, 0xa0, 0x3c, 0xe6, 0x67, 0xa1, 0x47, 0x24, 0x2a, 0x98, 0x5a, 0xbd, 0xd2, 0xeb, 0xc6, 0x91, + 0xd1, 0x5e, 0xd6, 0xd2, 0x2c, 0x3d, 0xdb, 0x9a, 0x19, 0x03, 0xfe, 0x00, 0xb6, 0xa6, 0x97, 0xc7, + 0x82, 0x7b, 0x68, 0x23, 0x17, 0xd9, 0xb9, 0x0a, 0x32, 0xcb, 0x81, 0xc7, 0xa0, 0xe8, 0x73, 0x11, + 0x48, 0x75, 0x88, 0x2d, 0x7a, 0xb7, 0xbb, 0x14, 0xc8, 0x45, 0xe0, 0x61, 0xdf, 0xb2, 0xd3, 0x74, + 0xf8, 0x19, 0xd0, 0xb1, 0x18, 0x48, 0xa4, 0x2b, 0x4c, 0x23, 0x8e, 0x8c, 0xfa, 0xca, 0x17, 0x80, + 0x39, 0x0b, 0x27, 0x99, 0xf0, 0x08, 0x94, 0x1d, 0xee, 0x79, 0x98, 0xb9, 0xa8, 0x98, 0x6b, 0xdf, + 0xbd, 0x65, 0xf6, 0x9d, 0xe5, 0xc1, 0x4f, 0x80, 0x46, 0xd8, 0x58, 0x9d, 0x2c, 0x8b, 0x6b, 0xd8, + 0x5f, 0xb6, 0x15, 0xc2, 0xc6, 0x96, 0x9d, 0x24, 0xd6, 0xfe, 0xd2, 0x01, 0xb8, 0x78, 0xfc, 0xdf, + 0xc8, 0x54, 0x1f, 0x83, 0x22, 0xf5, 0xf0, 0xe0, 0xfa, 0x6f, 0x8e, 0x69, 0x7a, 0xd6, 0x4d, 0xff, + 0xa1, 0xf5, 0xcb, 0xdc, 0xa4, 0xe5, 0x22, 0xbb, 0xd7, 0x77, 0x93, 0x9e, 0xeb, 0xa6, 0xbd, 0x37, + 0x75, 0xd3, 0x15, 0x3a, 0x79, 0x5d, 0x37, 0x3d, 0xb8, 0xaa, 0x9b, 0x2a, 0xb9, 0x6b, 0x38, 0x58, + 0xeb, 0xa6, 0x5e, 0xf7, 0xd5, 0xdf, 0x3b, 0xb7, 0x7e, 0xff, 0x67, 0xa7, 0xf0, 0xfc, 0xde, 0xfa, + 0x6f, 0x98, 0xe9, 0x77, 0x56, 0xbf, 0xa4, 0x3e, 0x9c, 0xba, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, + 0x91, 0xe6, 0x6a, 0x10, 0x79, 0x0d, 0x00, 0x00, } func (this *Service) Equal(that interface{}) bool { @@ -389,7 +389,7 @@ func (this *Service) Equal(that interface{}) bool { } else if this == nil { return false } - if !this.Hash.Equal(that1.Hash) { + if !bytes.Equal(this.Hash, that1.Hash) { return false } if this.Sid != that1.Sid { diff --git a/service/validator/validator.go b/service/validate.go similarity index 69% rename from service/validator/validator.go rename to service/validate.go index c9ad122f6..ab4b05764 100644 --- a/service/validator/validator.go +++ b/service/validate.go @@ -1,28 +1,27 @@ -package validator +package service import ( "fmt" "strings" + validator "github.com/go-playground/validator/v10" "github.com/mesg-foundation/engine/ext/xerrors" "github.com/mesg-foundation/engine/ext/xvalidator" - "github.com/mesg-foundation/engine/service" - validator "gopkg.in/go-playground/validator.v9" ) const namespacePrefix = "service." -var validate, translator = xvalidator.NewWithPrefix(namespacePrefix) +var validate, translator = xvalidator.New(namespacePrefix) -// ValidateService validates if service contains proper data. -func ValidateService(s *service.Service) error { - if err := validateServiceStruct(s); err != nil { +// Validate validates if service contains proper data. +func (s *Service) Validate() error { + if err := s.validateStruct(); err != nil { return err } - return validateServiceData(s) + return s.validateData() } -func validateServiceStruct(s *service.Service) error { +func (s *Service) validateStruct() error { var errs xerrors.Errors // validate service struct based on tag if err := validate.Struct(s); err != nil { @@ -41,9 +40,9 @@ func validateServiceStruct(s *service.Service) error { return errs.ErrorOrNil() } -func validateServiceData(s *service.Service) error { +func (s *Service) validateData() error { var errs xerrors.Errors - if err := isServiceKeysUnique(s); err != nil { + if err := s.areKeysUnique(); err != nil { errs = append(errs, err) } @@ -80,7 +79,7 @@ func validateServiceData(s *service.Service) error { break } } - if !found && depVolumeKey != service.MainServiceKey { + if !found && depVolumeKey != MainServiceKey { err := fmt.Errorf("dependencies[%s].volumesFrom is invalid: dependency %q does not exist", dep.Key, depVolumeKey) errs = append(errs, err) } @@ -89,8 +88,8 @@ func validateServiceData(s *service.Service) error { return errs.ErrorOrNil() } -// isServiceKeysUnique checks uniqueness of service deps/tasks/events/params keys. -func isServiceKeysUnique(s *service.Service) error { +// areKeysUnique checks uniqueness of service deps/tasks/events/params keys. +func (s *Service) areKeysUnique() error { var errs xerrors.Errors exist := make(map[string]bool) for _, dep := range s.Dependencies { @@ -106,10 +105,10 @@ func isServiceKeysUnique(s *service.Service) error { errs = append(errs, fmt.Errorf("tasks[%s] already exists", task.Key)) } exist[task.Key] = true - if err := isServiceParamsUnique(task.Inputs, fmt.Sprintf("tasks[%s].inputs", task.Key)); err != nil { + if err := areServiceParamsUnique(task.Inputs, fmt.Sprintf("tasks[%s].inputs", task.Key)); err != nil { errs = append(errs, err) } - if err := isServiceParamsUnique(task.Outputs, fmt.Sprintf("tasks[%s].outputs", task.Key)); err != nil { + if err := areServiceParamsUnique(task.Outputs, fmt.Sprintf("tasks[%s].outputs", task.Key)); err != nil { errs = append(errs, err) } } @@ -121,15 +120,15 @@ func isServiceKeysUnique(s *service.Service) error { } exist[event.Key] = true - if err := isServiceParamsUnique(event.Data, fmt.Sprintf("events[%s].data", event.Key)); err != nil { + if err := areServiceParamsUnique(event.Data, fmt.Sprintf("events[%s].data", event.Key)); err != nil { errs = append(errs, err) } } return errs.ErrorOrNil() } -// isServiceParamsUnique checks uniqueness of service params. -func isServiceParamsUnique(ps []*service.Service_Parameter, errprefix string) error { +// areServiceParamsUnique checks uniqueness of service params. +func areServiceParamsUnique(ps []*Service_Parameter, errprefix string) error { if len(ps) == 0 { return nil } @@ -142,7 +141,7 @@ func isServiceParamsUnique(ps []*service.Service_Parameter, errprefix string) er } existparam[p.Key] = true - if err := isServiceParamsUnique(p.Object, fmt.Sprintf("%s[%s].object", errprefix, p.Key)); err != nil { + if err := areServiceParamsUnique(p.Object, fmt.Sprintf("%s[%s].object", errprefix, p.Key)); err != nil { errs = append(errs, err) } } diff --git a/x/execution/alias.go b/x/execution/alias.go index 4b7dd5249..304d72f01 100644 --- a/x/execution/alias.go +++ b/x/execution/alias.go @@ -25,13 +25,21 @@ var ( ModuleCdc = types.ModuleCdc - QueryGetExecution = types.QueryGetExecution - QueryListExecution = types.QueryListExecution - - NewMsgCreateExecution = types.NewMsgCreateExecution - NewMsgUpdateExecution = types.NewMsgUpdateExecution + QueryGet = types.QueryGet + QueryList = types.QueryList M = keeper.M + + EventType = types.EventType + AttributeKeyHash = types.AttributeKeyHash + AttributeKeyAddress = types.AttributeKeyAddress + AttributeKeyExecutor = types.AttributeKeyExecutor + AttributeKeyProcess = types.AttributeKeyProcess + AttributeKeyInstance = types.AttributeKeyInstance + AttributeActionProposed = types.AttributeActionProposed + AttributeActionCreated = types.AttributeActionCreated + AttributeActionCompleted = types.AttributeActionCompleted + AttributeActionFailed = types.AttributeActionFailed ) // module types @@ -40,6 +48,8 @@ type ( GenesisState = types.GenesisState Params = types.Params - MsgCreateExecution = types.MsgCreateExecution - MsgUpdateExecution = types.MsgUpdateExecution + MsgCreate = types.MsgCreate + MsgUpdate = types.MsgUpdate + MsgUpdateOutputs = types.MsgUpdate_Outputs + MsgUpdateError = types.MsgUpdate_Error ) diff --git a/x/execution/client/cli/query.go b/x/execution/client/cli/query.go index 106af38bf..c264117d7 100644 --- a/x/execution/client/cli/query.go +++ b/x/execution/client/cli/query.go @@ -25,22 +25,22 @@ func GetQueryCmd(queryRoute string, cdc *codec.Codec) *cobra.Command { executionQueryCmd.AddCommand( flags.GetCommands( - GetCmdGetExecution(queryRoute, cdc), - GetCmdListExecution(queryRoute, cdc), + GetCmdGet(queryRoute, cdc), + GetCmdList(queryRoute, cdc), )..., ) return executionQueryCmd } -func GetCmdGetExecution(queryRoute string, cdc *codec.Codec) *cobra.Command { +func GetCmdGet(queryRoute string, cdc *codec.Codec) *cobra.Command { return &cobra.Command{ Use: "get [hash]", Short: "get", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { cliCtx := context.NewCLIContext().WithCodec(cdc) - res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s/%s", queryRoute, types.QueryGetExecution, args[0]), nil) + res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s/%s", queryRoute, types.QueryGet, args[0]), nil) if err != nil { fmt.Printf("could not get execution\n%s\n", err.Error()) return nil @@ -53,13 +53,13 @@ func GetCmdGetExecution(queryRoute string, cdc *codec.Codec) *cobra.Command { } } -func GetCmdListExecution(queryRoute string, cdc *codec.Codec) *cobra.Command { +func GetCmdList(queryRoute string, cdc *codec.Codec) *cobra.Command { return &cobra.Command{ Use: "list", Short: "list", RunE: func(cmd *cobra.Command, args []string) error { cliCtx := context.NewCLIContext().WithCodec(cdc) - res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryListExecution), nil) + res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryList), nil) if err != nil { fmt.Printf("could not list executions\n%s\n", err.Error()) return nil diff --git a/x/execution/client/rest/query.go b/x/execution/client/rest/query.go index b92b25a9f..38afb940e 100644 --- a/x/execution/client/rest/query.go +++ b/x/execution/client/rest/query.go @@ -18,6 +18,7 @@ func registerQueryRoutes(cliCtx context.CLIContext, r *mux.Router) { "/execution/get/{hash}", queryGetHandlerFn(cliCtx), ).Methods(http.MethodGet) + r.HandleFunc( "/execution/list", queryListHandlerFn(cliCtx), @@ -33,7 +34,7 @@ func queryGetHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { return } - route := fmt.Sprintf("custom/%s/%s/%s", types.QuerierRoute, types.QueryGetExecution, vars["hash"]) + route := fmt.Sprintf("custom/%s/%s/%s", types.QuerierRoute, types.QueryGet, vars["hash"]) res, height, err := cliCtx.QueryWithData(route, nil) if err != nil { @@ -59,7 +60,7 @@ func queryListHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { return } - route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryListExecution) + route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryList) res, height, err := cliCtx.QueryWithData(route, nil) if err != nil { diff --git a/x/execution/handler.go b/x/execution/handler.go index 00d4d2266..7864b8a73 100644 --- a/x/execution/handler.go +++ b/x/execution/handler.go @@ -3,7 +3,6 @@ package execution import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/mesg-foundation/engine/execution" "github.com/mesg-foundation/engine/x/execution/internal/types" ) @@ -12,46 +11,30 @@ func NewHandler(k Keeper) sdk.Handler { return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { ctx = ctx.WithEventManager(sdk.NewEventManager()) switch msg := msg.(type) { - case MsgCreateExecution: - return handleMsgCreateExecution(ctx, k, msg) - case MsgUpdateExecution: - return handleMsgUpdateExecution(ctx, k, msg) + case MsgCreate: + return handleMsgCreate(ctx, k, msg) + case MsgUpdate: + return handleMsgUpdate(ctx, k, msg) default: return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized %s message type: %T", types.ModuleName, msg) } } } -// handleMsgCreateExecution creates a new execution. -func handleMsgCreateExecution(ctx sdk.Context, k Keeper, msg MsgCreateExecution) (*sdk.Result, error) { +// handleMsgCreate creates a new execution. +func handleMsgCreate(ctx sdk.Context, k Keeper, msg MsgCreate) (*sdk.Result, error) { exec, err := k.Create(ctx, msg) if err != nil { return nil, err } - // TODO: don't emit propsoed event to not break the stream listener in cosmos/client.go#152. - // ctx.EventManager().EmitEvent( - // sdk.NewEvent( - // sdk.EventTypeMessage, - // sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - // sdk.NewAttribute(sdk.AttributeKeyAction, types.EventTypeExecutionProposed), - // sdk.NewAttribute(sdk.AttributeKeySender, msg.Signer.String()), - // sdk.NewAttribute(types.AttributeHash, exec.Hash.String()), - // ), - // ) - - // emit EventTypeExecutionInProgress event only when execution status is "in progress" - if exec.Status == execution.Status_InProgress { - ctx.EventManager().EmitEvent( - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - sdk.NewAttribute(sdk.AttributeKeyAction, types.EventTypeExecutionInProgress), - sdk.NewAttribute(sdk.AttributeKeySender, msg.Signer.String()), - sdk.NewAttribute(types.AttributeHash, exec.Hash.String()), - ), - ) - } + ctx.EventManager().EmitEvent( + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, ModuleName), + sdk.NewAttribute(sdk.AttributeKeySender, msg.Signer.String()), + ), + ) return &sdk.Result{ Data: exec.Hash, @@ -59,9 +42,9 @@ func handleMsgCreateExecution(ctx sdk.Context, k Keeper, msg MsgCreateExecution) }, nil } -// handleMsgUpdateExecution updates an execution. -func handleMsgUpdateExecution(ctx sdk.Context, k Keeper, msg MsgUpdateExecution) (*sdk.Result, error) { - s, err := k.Update(ctx, msg) +// handleMsgUpdate updates an execution. +func handleMsgUpdate(ctx sdk.Context, k Keeper, msg MsgUpdate) (*sdk.Result, error) { + exec, err := k.Update(ctx, msg) if err != nil { return nil, err } @@ -69,15 +52,13 @@ func handleMsgUpdateExecution(ctx sdk.Context, k Keeper, msg MsgUpdateExecution) ctx.EventManager().EmitEvent( sdk.NewEvent( sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - sdk.NewAttribute(sdk.AttributeKeyAction, types.EventTypeUpdateExecution), + sdk.NewAttribute(sdk.AttributeKeyModule, ModuleName), sdk.NewAttribute(sdk.AttributeKeySender, msg.Executor.String()), - sdk.NewAttribute(types.AttributeHash, s.Hash.String()), ), ) return &sdk.Result{ - Data: s.Hash, + Data: exec.Hash, Events: ctx.EventManager().Events(), }, nil } diff --git a/x/execution/internal/keeper/keeper.go b/x/execution/internal/keeper/keeper.go index 7ddb2c146..5a17787bb 100644 --- a/x/execution/internal/keeper/keeper.go +++ b/x/execution/internal/keeper/keeper.go @@ -14,7 +14,6 @@ import ( executionpb "github.com/mesg-foundation/engine/execution" "github.com/mesg-foundation/engine/hash" "github.com/mesg-foundation/engine/process" - "github.com/mesg-foundation/engine/protobuf/api" typespb "github.com/mesg-foundation/engine/protobuf/types" "github.com/mesg-foundation/engine/runner" "github.com/mesg-foundation/engine/x/execution/internal/types" @@ -64,9 +63,9 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { // The execution reaches consensus only when more than 2/3 of emitters proposed the same execution. // TODO: we should split the message and keeper function of execution create from user and for process. //nolint:gocyclo -func (k *Keeper) Create(ctx sdk.Context, msg types.MsgCreateExecution) (*executionpb.Execution, error) { +func (k *Keeper) Create(ctx sdk.Context, msg types.MsgCreate) (*executionpb.Execution, error) { // TODO: all the following verification should be moved to a runner.Validate function - price, err := sdk.ParseCoins(msg.Request.Price) + price, err := sdk.ParseCoins(msg.Price) if err != nil { return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidCoins, err.Error()) } @@ -79,7 +78,7 @@ func (k *Keeper) Create(ctx sdk.Context, msg types.MsgCreateExecution) (*executi return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidCoins, "execution price too low. Min value: %q", minPriceCoin.String()) } - run, err := k.runnerKeeper.Get(ctx, msg.Request.ExecutorHash) + run, err := k.runnerKeeper.Get(ctx, msg.ExecutorHash) if err != nil { return nil, err } @@ -91,12 +90,12 @@ func (k *Keeper) Create(ctx sdk.Context, msg types.MsgCreateExecution) (*executi if err != nil { return nil, err } - if err := srv.RequireTaskInputs(msg.Request.TaskKey, msg.Request.Inputs); err != nil { + if err := srv.RequireTaskInputs(msg.TaskKey, msg.Inputs); err != nil { return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, err.Error()) } var proc *process.Process - if !msg.Request.ProcessHash.IsZero() { - proc, err = k.processKeeper.Get(ctx, msg.Request.ProcessHash) + if !msg.ProcessHash.IsZero() { + proc, err = k.processKeeper.Get(ctx, msg.ProcessHash) if err != nil { return nil, err } @@ -106,18 +105,21 @@ func (k *Keeper) Create(ctx sdk.Context, msg types.MsgCreateExecution) (*executi return nil, sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "signer is not the execution's executor") } - exec := executionpb.New( - msg.Request.ProcessHash, + exec, err := executionpb.New( + msg.ProcessHash, run.InstanceHash, - msg.Request.ParentHash, - msg.Request.EventHash, - msg.Request.NodeKey, - msg.Request.TaskKey, - msg.Request.Price, - msg.Request.Inputs, - msg.Request.Tags, - msg.Request.ExecutorHash, + msg.ParentHash, + msg.EventHash, + msg.NodeKey, + msg.TaskKey, + msg.Price, + msg.Inputs, + msg.Tags, + msg.ExecutorHash, ) + if err != nil { + return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, err.Error()) + } // check if exec already exists store := ctx.KVStore(k.storeKey) @@ -165,6 +167,23 @@ func (k *Keeper) Create(ctx sdk.Context, msg types.MsgCreateExecution) (*executi if runEmitter.Owner == msg.Signer.String() { emitterIsPresent = true emitter.BlockHeight = ctx.BlockHeight() + + // emit event with action proposed + event := sdk.NewEvent( + types.EventType, + sdk.NewAttribute(sdk.AttributeKeyAction, types.AttributeActionProposed), + sdk.NewAttribute(types.AttributeKeyHash, exec.Hash.String()), + sdk.NewAttribute(types.AttributeKeyAddress, exec.Address.String()), + sdk.NewAttribute(types.AttributeKeyExecutor, exec.ExecutorHash.String()), + sdk.NewAttribute(types.AttributeKeyInstance, exec.InstanceHash.String()), + ) + if !exec.ProcessHash.IsZero() { + event = event.AppendAttributes( + sdk.NewAttribute(types.AttributeKeyExecutor, exec.ProcessHash.String()), + ) + } + ctx.EventManager().EmitEvent(event) + break } } @@ -192,6 +211,23 @@ func (k *Keeper) Create(ctx sdk.Context, msg types.MsgCreateExecution) (*executi if err := exec.Execute(); err != nil { return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, err.Error()) } + + // emit event + event := sdk.NewEvent( + types.EventType, + sdk.NewAttribute(sdk.AttributeKeyAction, types.AttributeActionCreated), + sdk.NewAttribute(types.AttributeKeyHash, exec.Hash.String()), + sdk.NewAttribute(types.AttributeKeyAddress, exec.Address.String()), + sdk.NewAttribute(types.AttributeKeyExecutor, exec.ExecutorHash.String()), + sdk.NewAttribute(types.AttributeKeyInstance, exec.InstanceHash.String()), + ) + if !exec.ProcessHash.IsZero() { + event = event.AppendAttributes( + sdk.NewAttribute(types.AttributeKeyExecutor, exec.ProcessHash.String()), + ) + } + ctx.EventManager().EmitEvent(event) + if !ctx.IsCheckTx() { M.InProgress.Add(1) } @@ -212,17 +248,18 @@ func (k *Keeper) Create(ctx sdk.Context, msg types.MsgCreateExecution) (*executi return nil, sdkerrors.Wrapf(sdkerrors.ErrJSONMarshal, err.Error()) } store.Set(exec.Hash, value) + return exec, nil } // Update updates a new execution from definition. -func (k *Keeper) Update(ctx sdk.Context, msg types.MsgUpdateExecution) (*executionpb.Execution, error) { +func (k *Keeper) Update(ctx sdk.Context, msg types.MsgUpdate) (*executionpb.Execution, error) { store := ctx.KVStore(k.storeKey) - if !store.Has(msg.Request.Hash) { - return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "execution %q doesn't exist", msg.Request.Hash) + if !store.Has(msg.Hash) { + return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "execution %q doesn't exist", msg.Hash) } var exec *executionpb.Execution - if err := k.cdc.UnmarshalBinaryLengthPrefixed(store.Get(msg.Request.Hash), &exec); err != nil { + if err := k.cdc.UnmarshalBinaryLengthPrefixed(store.Get(msg.Hash), &exec); err != nil { return nil, sdkerrors.Wrapf(sdkerrors.ErrJSONUnmarshal, err.Error()) } @@ -235,16 +272,18 @@ func (k *Keeper) Update(ctx sdk.Context, msg types.MsgUpdateExecution) (*executi return nil, sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "signer is not the execution's executor") } - switch res := msg.Request.Result.(type) { - case *api.UpdateExecutionRequest_Outputs: - if err := k.validateExecutionOutput(ctx, exec.InstanceHash, exec.TaskKey, res.Outputs); err != nil { + eventAction := types.AttributeActionFailed + switch res := msg.Result.(type) { + case *types.MsgUpdate_Outputs: + if err := k.validateOutput(ctx, exec.InstanceHash, exec.TaskKey, res.Outputs); err != nil { if err1 := exec.Fail(err); err1 != nil { return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, err1.Error()) } } else if err := exec.Complete(res.Outputs); err != nil { return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, err.Error()) } - case *api.UpdateExecutionRequest_Error: + eventAction = types.AttributeActionCompleted + case *types.MsgUpdate_Error: if err := exec.Fail(errors.New(res.Error)); err != nil { return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, err.Error()) } @@ -275,6 +314,23 @@ func (k *Keeper) Update(ctx sdk.Context, msg types.MsgUpdateExecution) (*executi } store.Set(exec.Hash, value) + + // emit event + event := sdk.NewEvent( + types.EventType, + sdk.NewAttribute(sdk.AttributeKeyAction, eventAction), + sdk.NewAttribute(types.AttributeKeyHash, exec.Hash.String()), + sdk.NewAttribute(types.AttributeKeyAddress, exec.Address.String()), + sdk.NewAttribute(types.AttributeKeyExecutor, exec.ExecutorHash.String()), + sdk.NewAttribute(types.AttributeKeyInstance, exec.InstanceHash.String()), + ) + if !exec.ProcessHash.IsZero() { + event = event.AppendAttributes( + sdk.NewAttribute(types.AttributeKeyExecutor, exec.ProcessHash.String()), + ) + } + ctx.EventManager().EmitEvent(event) + return exec, nil } @@ -359,7 +415,7 @@ func (k *Keeper) distributePriceShares(ctx sdk.Context, execAddress, runnerAddre return nil } -func (k *Keeper) validateExecutionOutput(ctx sdk.Context, instanceHash hash.Hash, taskKey string, outputs *typespb.Struct) error { +func (k *Keeper) validateOutput(ctx sdk.Context, instanceHash hash.Hash, taskKey string, outputs *typespb.Struct) error { inst, err := k.instanceKeeper.Get(ctx, instanceHash) if err != nil { return err diff --git a/x/execution/internal/keeper/querier.go b/x/execution/internal/keeper/querier.go index e3e7cd168..1f7b3ee7e 100644 --- a/x/execution/internal/keeper/querier.go +++ b/x/execution/internal/keeper/querier.go @@ -12,17 +12,17 @@ import ( func NewQuerier(k Keeper) sdk.Querier { return func(ctx sdk.Context, path []string, req abci.RequestQuery) ([]byte, error) { switch path[0] { - case types.QueryGetExecution: - return getExecution(ctx, k, path[1:]) - case types.QueryListExecution: - return listExecution(ctx, k) + case types.QueryGet: + return get(ctx, k, path[1:]) + case types.QueryList: + return list(ctx, k) default: return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "unknown execution query endpoint") } } } -func getExecution(ctx sdk.Context, k Keeper, path []string) ([]byte, error) { +func get(ctx sdk.Context, k Keeper, path []string) ([]byte, error) { if len(path) == 0 { return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "missing hash") } @@ -43,7 +43,7 @@ func getExecution(ctx sdk.Context, k Keeper, path []string) ([]byte, error) { return res, nil } -func listExecution(ctx sdk.Context, k Keeper) ([]byte, error) { +func list(ctx sdk.Context, k Keeper) ([]byte, error) { es, err := k.List(ctx) if err != nil { return nil, err diff --git a/x/execution/internal/types/codec.go b/x/execution/internal/types/codec.go index f573c4922..22ef42239 100644 --- a/x/execution/internal/types/codec.go +++ b/x/execution/internal/types/codec.go @@ -2,14 +2,16 @@ package types import ( "github.com/cosmos/cosmos-sdk/codec" - "github.com/mesg-foundation/engine/protobuf/api" "github.com/mesg-foundation/engine/protobuf/types" ) // RegisterCodec registers concrete types on codec func RegisterCodec(cdc *codec.Codec) { - cdc.RegisterConcrete(MsgCreateExecution{}, "execution/CreateExecution", nil) - cdc.RegisterConcrete(MsgUpdateExecution{}, "execution/UpdateExecution", nil) + cdc.RegisterConcrete(MsgCreate{}, "execution/create", nil) + cdc.RegisterConcrete(MsgUpdate{}, "execution/update", nil) + cdc.RegisterInterface((*isMsgUpdate_Result)(nil), nil) + cdc.RegisterConcrete(&MsgUpdate_Outputs{}, "mesg.execution.types.MsgUpdate_Outputs", nil) + cdc.RegisterConcrete(&MsgUpdate_Error{}, "mesg.execution.types.MsgUpdate_Error", nil) } // ModuleCdc defines the module codec @@ -19,7 +21,6 @@ func init() { ModuleCdc = codec.New() RegisterCodec(ModuleCdc) types.RegisterCodec(ModuleCdc) - api.RegisterCodec(ModuleCdc) codec.RegisterCrypto(ModuleCdc) ModuleCdc.Seal() } diff --git a/x/execution/internal/types/events.go b/x/execution/internal/types/events.go index 419913020..3048586a5 100644 --- a/x/execution/internal/types/events.go +++ b/x/execution/internal/types/events.go @@ -1,12 +1,17 @@ package types -// execution module event types +// module event types and attributes const ( - EventTypeExecutionProposed = "ExecutionProposed" - EventTypeExecutionInProgress = "ExecutionInProgress" - EventTypeUpdateExecution = "UpdateExecution" + EventType = "execution" - AttributeHash = "hash" + AttributeKeyHash = "hash" + AttributeKeyAddress = "address" + AttributeKeyExecutor = "executor" + AttributeKeyProcess = "process" + AttributeKeyInstance = "instance" - AttributeValueCategory = ModuleName + AttributeActionProposed = "proposed" + AttributeActionCreated = "created" + AttributeActionCompleted = "completed" + AttributeActionFailed = "failed" ) diff --git a/x/execution/internal/types/msg.go b/x/execution/internal/types/msg.go index 58ddf2918..b8e1b395c 100644 --- a/x/execution/internal/types/msg.go +++ b/x/execution/internal/types/msg.go @@ -4,105 +4,60 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/mesg-foundation/engine/ext/xvalidator" - "github.com/mesg-foundation/engine/protobuf/api" ) -// MsgCreateExecution defines a state transition to create a execution. -type MsgCreateExecution struct { - Request *api.CreateExecutionRequest `json:"request"` - Signer sdk.AccAddress `json:"signer"` -} - -// NewMsgCreateExecution is a constructor function for MsgCreateExecution. -func NewMsgCreateExecution(req *api.CreateExecutionRequest, signer sdk.AccAddress) *MsgCreateExecution { - return &MsgCreateExecution{ - Request: req, - Signer: signer, - } -} - // Route should return the name of the module. -func (msg MsgCreateExecution) Route() string { +func (msg MsgCreate) Route() string { return ModuleName } // Type returns the action. -func (msg MsgCreateExecution) Type() string { - return "CreateExecution" +func (msg MsgCreate) Type() string { + return "create" } // ValidateBasic runs stateless checks on the message. -func (msg MsgCreateExecution) ValidateBasic() error { - price, err := sdk.ParseCoins(msg.Request.Price) - if err != nil { - return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, "cannot parse price") - } - if price.IsAnyNegative() { - return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, "price must be positive") - } - if err := xvalidator.Validate.Struct(msg); err != nil { +func (msg MsgCreate) ValidateBasic() error { + if err := xvalidator.Struct(msg); err != nil { return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error()) } - if !msg.Request.ParentHash.IsZero() && !msg.Request.EventHash.IsZero() { - return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "cannot have both parent and event hash") - } - if msg.Request.ParentHash.IsZero() && msg.Request.EventHash.IsZero() { - return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "should have at least an event hash or parent hash") - } - if msg.Request.ExecutorHash.IsZero() { - return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "should have a executor hash") - } return nil } // GetSignBytes encodes the message for signing. -func (msg MsgCreateExecution) GetSignBytes() []byte { +func (msg MsgCreate) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(msg)) } // GetSigners defines whose signature is required. -func (msg MsgCreateExecution) GetSigners() []sdk.AccAddress { +func (msg MsgCreate) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{msg.Signer} } -// MsgUpdateExecution defines a state transition to update a execution. -type MsgUpdateExecution struct { - Request *api.UpdateExecutionRequest `json:"request"` - Executor sdk.AccAddress `json:"executor"` -} - -// NewMsgUpdateExecution is a constructor function for MsgUpdateExecution. -func NewMsgUpdateExecution(req *api.UpdateExecutionRequest, executor sdk.AccAddress) *MsgUpdateExecution { - return &MsgUpdateExecution{ - Request: req, - Executor: executor, - } -} - // Route should return the name of the module. -func (msg MsgUpdateExecution) Route() string { +func (msg MsgUpdate) Route() string { return ModuleName } // Type returns the action. -func (msg MsgUpdateExecution) Type() string { - return "UpdateExecution" +func (msg MsgUpdate) Type() string { + return "update" } // ValidateBasic runs stateless checks on the message. -func (msg MsgUpdateExecution) ValidateBasic() error { - if msg.Executor.Empty() { - return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "executor is missing") +func (msg MsgUpdate) ValidateBasic() error { + if err := xvalidator.Struct(msg); err != nil { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error()) } return nil } // GetSignBytes encodes the message for signing. -func (msg MsgUpdateExecution) GetSignBytes() []byte { +func (msg MsgUpdate) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(msg)) } // GetSigners defines whose signature is required. -func (msg MsgUpdateExecution) GetSigners() []sdk.AccAddress { +func (msg MsgUpdate) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{msg.Executor} } diff --git a/x/execution/internal/types/msg.pb.go b/x/execution/internal/types/msg.pb.go new file mode 100644 index 000000000..af0001142 --- /dev/null +++ b/x/execution/internal/types/msg.pb.go @@ -0,0 +1,288 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: x/execution/internal/types/msg.proto + +package types + +import ( + fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + github_com_mesg_foundation_engine_hash "github.com/mesg-foundation/engine/hash" + types "github.com/mesg-foundation/engine/protobuf/types" + math "math" +) + +// 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 + +// The message to create an Execution. +type MsgCreate struct { + // The msg's signer. + Signer github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,opt,name=signer,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"signer,omitempty" validate:"required,accaddress"` + // taskKey to filter executions. + TaskKey string `protobuf:"bytes,2,opt,name=taskKey,proto3" json:"taskKey,omitempty" validate:"required,printascii"` + Inputs *types.Struct `protobuf:"bytes,3,opt,name=inputs,proto3" json:"inputs,omitempty"` + // tags the execution. + Tags []string `protobuf:"bytes,4,rep,name=tags,proto3" json:"tags,omitempty" validate:"dive,printascii"` + ParentHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,5,opt,name=parentHash,proto3,casttype=github.com/mesg-foundation/engine/hash.Hash" json:"parentHash,omitempty" validate:"required_without=EventHash,omitempty,hash"` + EventHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,6,opt,name=eventHash,proto3,casttype=github.com/mesg-foundation/engine/hash.Hash" json:"eventHash,omitempty" validate:"required_without=ParentHash,omitempty,hash"` + ProcessHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,7,opt,name=processHash,proto3,casttype=github.com/mesg-foundation/engine/hash.Hash" json:"processHash,omitempty" validate:"omitempty,hash"` + NodeKey string `protobuf:"bytes,8,opt,name=nodeKey,proto3" json:"nodeKey,omitempty"` + ExecutorHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,9,opt,name=executorHash,proto3,casttype=github.com/mesg-foundation/engine/hash.Hash" json:"executorHash,omitempty" validate:"required,hash"` + // price of running the execution. + Price string `protobuf:"bytes,10,opt,name=price,proto3" json:"price,omitempty" validate:"coinsPositiveZero"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *MsgCreate) Reset() { *m = MsgCreate{} } +func (m *MsgCreate) String() string { return proto.CompactTextString(m) } +func (*MsgCreate) ProtoMessage() {} +func (*MsgCreate) Descriptor() ([]byte, []int) { + return fileDescriptor_6c59efd9270dae25, []int{0} +} +func (m *MsgCreate) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_MsgCreate.Unmarshal(m, b) +} +func (m *MsgCreate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_MsgCreate.Marshal(b, m, deterministic) +} +func (m *MsgCreate) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreate.Merge(m, src) +} +func (m *MsgCreate) XXX_Size() int { + return xxx_messageInfo_MsgCreate.Size(m) +} +func (m *MsgCreate) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreate.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreate proto.InternalMessageInfo + +func (m *MsgCreate) GetSigner() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.Signer + } + return nil +} + +func (m *MsgCreate) GetTaskKey() string { + if m != nil { + return m.TaskKey + } + return "" +} + +func (m *MsgCreate) GetInputs() *types.Struct { + if m != nil { + return m.Inputs + } + return nil +} + +func (m *MsgCreate) GetTags() []string { + if m != nil { + return m.Tags + } + return nil +} + +func (m *MsgCreate) GetParentHash() github_com_mesg_foundation_engine_hash.Hash { + if m != nil { + return m.ParentHash + } + return nil +} + +func (m *MsgCreate) GetEventHash() github_com_mesg_foundation_engine_hash.Hash { + if m != nil { + return m.EventHash + } + return nil +} + +func (m *MsgCreate) GetProcessHash() github_com_mesg_foundation_engine_hash.Hash { + if m != nil { + return m.ProcessHash + } + return nil +} + +func (m *MsgCreate) GetNodeKey() string { + if m != nil { + return m.NodeKey + } + return "" +} + +func (m *MsgCreate) GetExecutorHash() github_com_mesg_foundation_engine_hash.Hash { + if m != nil { + return m.ExecutorHash + } + return nil +} + +func (m *MsgCreate) GetPrice() string { + if m != nil { + return m.Price + } + return "" +} + +// The message to update an Execution. +type MsgUpdate struct { + // The execution's executor. + Executor github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,opt,name=executor,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"executor,omitempty" validate:"required,accaddress"` + // Hash represents execution. + Hash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,2,opt,name=hash,proto3,casttype=github.com/mesg-foundation/engine/hash.Hash" json:"hash,omitempty" validate:"required,hash"` + // result pass to execution + // + // Types that are valid to be assigned to Result: + // *MsgUpdate_Outputs + // *MsgUpdate_Error + Result isMsgUpdate_Result `protobuf_oneof:"result"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *MsgUpdate) Reset() { *m = MsgUpdate{} } +func (m *MsgUpdate) String() string { return proto.CompactTextString(m) } +func (*MsgUpdate) ProtoMessage() {} +func (*MsgUpdate) Descriptor() ([]byte, []int) { + return fileDescriptor_6c59efd9270dae25, []int{1} +} +func (m *MsgUpdate) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_MsgUpdate.Unmarshal(m, b) +} +func (m *MsgUpdate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_MsgUpdate.Marshal(b, m, deterministic) +} +func (m *MsgUpdate) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdate.Merge(m, src) +} +func (m *MsgUpdate) XXX_Size() int { + return xxx_messageInfo_MsgUpdate.Size(m) +} +func (m *MsgUpdate) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdate.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdate proto.InternalMessageInfo + +type isMsgUpdate_Result interface { + isMsgUpdate_Result() +} + +type MsgUpdate_Outputs struct { + Outputs *types.Struct `protobuf:"bytes,3,opt,name=outputs,proto3,oneof" json:"outputs,omitempty"` +} +type MsgUpdate_Error struct { + Error string `protobuf:"bytes,4,opt,name=error,proto3,oneof" json:"error,omitempty"` +} + +func (*MsgUpdate_Outputs) isMsgUpdate_Result() {} +func (*MsgUpdate_Error) isMsgUpdate_Result() {} + +func (m *MsgUpdate) GetResult() isMsgUpdate_Result { + if m != nil { + return m.Result + } + return nil +} + +func (m *MsgUpdate) GetExecutor() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.Executor + } + return nil +} + +func (m *MsgUpdate) GetHash() github_com_mesg_foundation_engine_hash.Hash { + if m != nil { + return m.Hash + } + return nil +} + +func (m *MsgUpdate) GetOutputs() *types.Struct { + if x, ok := m.GetResult().(*MsgUpdate_Outputs); ok { + return x.Outputs + } + return nil +} + +func (m *MsgUpdate) GetError() string { + if x, ok := m.GetResult().(*MsgUpdate_Error); ok { + return x.Error + } + return "" +} + +// XXX_OneofWrappers is for the internal use of the proto package. +func (*MsgUpdate) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*MsgUpdate_Outputs)(nil), + (*MsgUpdate_Error)(nil), + } +} + +func init() { + proto.RegisterType((*MsgCreate)(nil), "mesg.execution.types.MsgCreate") + proto.RegisterType((*MsgUpdate)(nil), "mesg.execution.types.MsgUpdate") +} + +func init() { + proto.RegisterFile("x/execution/internal/types/msg.proto", fileDescriptor_6c59efd9270dae25) +} + +var fileDescriptor_6c59efd9270dae25 = []byte{ + // 578 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x94, 0xcf, 0x6e, 0xd3, 0x4e, + 0x10, 0xc7, 0xeb, 0x36, 0x75, 0x9a, 0x6d, 0x4f, 0xab, 0xdf, 0x0f, 0x99, 0x82, 0xea, 0xc8, 0xe2, + 0x10, 0x89, 0xc4, 0x16, 0xe5, 0xcf, 0x01, 0x15, 0xa4, 0x06, 0x21, 0x45, 0x2a, 0x48, 0x95, 0x2b, + 0x2e, 0xbd, 0x54, 0x9b, 0xf5, 0xd4, 0x5e, 0x25, 0xde, 0x35, 0xbb, 0xeb, 0xd0, 0xbc, 0x00, 0xbc, + 0x0f, 0x0f, 0x64, 0xde, 0xc1, 0x47, 0x4e, 0xc8, 0xeb, 0x38, 0x49, 0x05, 0xa5, 0x12, 0x85, 0x93, + 0x3d, 0xda, 0xef, 0xcc, 0xe7, 0xbb, 0xe3, 0x19, 0xa3, 0x47, 0x57, 0x01, 0x5c, 0x01, 0xcd, 0x35, + 0x13, 0x3c, 0x60, 0x5c, 0x83, 0xe4, 0x64, 0x1a, 0xe8, 0x79, 0x06, 0x2a, 0x48, 0x55, 0xec, 0x67, + 0x52, 0x68, 0x81, 0xff, 0x4b, 0x41, 0xc5, 0xfe, 0x52, 0xe8, 0x9b, 0xf3, 0x7d, 0x2f, 0x16, 0xb1, + 0x08, 0x8c, 0x62, 0x9c, 0x5f, 0x06, 0x55, 0x64, 0x02, 0xf3, 0x56, 0x67, 0xee, 0x3f, 0x58, 0x1e, + 0xd7, 0x35, 0x95, 0x96, 0x39, 0xd5, 0xf5, 0xa1, 0xf7, 0xcd, 0x46, 0x9d, 0xf7, 0x2a, 0x7e, 0x23, + 0x81, 0x68, 0xc0, 0x13, 0x64, 0x2b, 0x16, 0x73, 0x90, 0x8e, 0xd5, 0xb5, 0x7a, 0x7b, 0xc3, 0xb3, + 0xb2, 0x70, 0x0f, 0x66, 0x64, 0xca, 0x22, 0xa2, 0xe1, 0xa5, 0x27, 0xe1, 0x63, 0xce, 0x24, 0x44, + 0x7d, 0x42, 0x29, 0x89, 0x22, 0x09, 0x4a, 0x79, 0xdf, 0x0b, 0x77, 0x10, 0x33, 0x9d, 0xe4, 0x63, + 0x9f, 0x8a, 0x34, 0xa0, 0x42, 0xa5, 0x42, 0x2d, 0x1e, 0x03, 0x15, 0x4d, 0x6a, 0xa8, 0x7f, 0x4c, + 0xe9, 0x71, 0x9d, 0x11, 0x2e, 0x10, 0xf8, 0x08, 0xb5, 0x35, 0x51, 0x93, 0x13, 0x98, 0x3b, 0x9b, + 0x5d, 0xab, 0xd7, 0x19, 0x7a, 0x37, 0xd0, 0x32, 0xc9, 0xb8, 0x26, 0x8a, 0x32, 0xe6, 0x85, 0x4d, + 0x0a, 0x1e, 0x20, 0x9b, 0xf1, 0x2c, 0xd7, 0xca, 0xd9, 0xea, 0x5a, 0xbd, 0xdd, 0xc3, 0xff, 0x7d, + 0xd3, 0xa0, 0xe6, 0xae, 0xfe, 0x99, 0xb9, 0x65, 0xb8, 0x10, 0xe1, 0x43, 0xd4, 0xd2, 0x24, 0x56, + 0x4e, 0xab, 0xbb, 0xd5, 0xeb, 0x0c, 0x0f, 0xca, 0xc2, 0xdd, 0x5f, 0x91, 0x22, 0x36, 0x83, 0x6b, + 0x14, 0xa3, 0xc5, 0x5f, 0x2c, 0x84, 0x32, 0x22, 0x81, 0xeb, 0x11, 0x51, 0x89, 0xb3, 0x6d, 0x5a, + 0x12, 0x97, 0x85, 0xfb, 0xec, 0x67, 0x93, 0x17, 0x9f, 0x98, 0x4e, 0x44, 0xae, 0x5f, 0xbd, 0x9d, + 0x2d, 0xf4, 0x7d, 0x91, 0x32, 0x0d, 0x69, 0xa6, 0xe7, 0xfd, 0x84, 0xa8, 0xa4, 0x6a, 0xd4, 0xe3, + 0xb5, 0x46, 0x55, 0x6e, 0x07, 0x97, 0x22, 0xe7, 0x11, 0x31, 0x1f, 0x1e, 0x78, 0xcc, 0x38, 0x04, + 0x95, 0xd4, 0xaf, 0xd2, 0xc3, 0x35, 0x34, 0xfe, 0x6c, 0xa1, 0x0e, 0x34, 0x85, 0x1d, 0xdb, 0x18, + 0x49, 0xca, 0xc2, 0x7d, 0xfe, 0x1b, 0x23, 0xa7, 0xcb, 0xf4, 0xbb, 0x3a, 0x59, 0xa1, 0x31, 0x47, + 0xbb, 0x99, 0x14, 0x14, 0x94, 0x32, 0x4e, 0xda, 0xc6, 0xc9, 0xbb, 0xb2, 0x70, 0xef, 0xaf, 0x9c, + 0xdc, 0x91, 0xb6, 0x0e, 0xc0, 0x0e, 0x6a, 0x73, 0x11, 0x41, 0x35, 0x23, 0x3b, 0xd5, 0x8c, 0x84, + 0x4d, 0x88, 0x05, 0xda, 0xab, 0x97, 0x41, 0x48, 0x63, 0xa5, 0x63, 0xac, 0x9c, 0x94, 0x85, 0xeb, + 0xfc, 0x62, 0x84, 0xfe, 0xc8, 0xc9, 0x35, 0x00, 0x7e, 0x81, 0xb6, 0x33, 0xc9, 0x28, 0x38, 0xc8, + 0x0c, 0x6b, 0xb7, 0x2c, 0xdc, 0x87, 0x2b, 0x12, 0x15, 0x8c, 0xab, 0x53, 0xa1, 0x98, 0x66, 0x33, + 0x38, 0x07, 0x29, 0xbc, 0xb0, 0x96, 0x7b, 0x5f, 0x37, 0xcd, 0x86, 0x7d, 0xc8, 0x2a, 0x21, 0x16, + 0x68, 0xa7, 0xa9, 0xfa, 0x2f, 0x77, 0x6c, 0x09, 0xc1, 0x17, 0xa8, 0x55, 0xdd, 0xc8, 0xac, 0xd8, + 0x5f, 0xee, 0x8f, 0x29, 0x8c, 0x9f, 0xa0, 0xb6, 0xc8, 0xf5, 0xad, 0x9b, 0x38, 0xda, 0x08, 0x1b, + 0x1d, 0xbe, 0x87, 0xb6, 0x41, 0x4a, 0x21, 0x9d, 0x56, 0xd5, 0xca, 0xd1, 0x46, 0x58, 0x87, 0xc3, + 0x1d, 0x64, 0x4b, 0x50, 0xf9, 0x54, 0x0f, 0x5f, 0x9f, 0x1f, 0xdd, 0xee, 0xe4, 0xe6, 0xff, 0xe6, + 0xd8, 0x36, 0xf4, 0xa7, 0x3f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x07, 0x1d, 0x85, 0xd5, 0x5c, 0x05, + 0x00, 0x00, +} diff --git a/x/execution/internal/types/msg.proto b/x/execution/internal/types/msg.proto new file mode 100644 index 000000000..8909513a2 --- /dev/null +++ b/x/execution/internal/types/msg.proto @@ -0,0 +1,79 @@ +syntax = "proto3"; + +import "gogo/protobuf/gogoproto/gogo.proto"; +import "protobuf/types/struct.proto"; + +package mesg.execution.types; +option go_package = "github.com/mesg-foundation/engine/x/execution/internal/types"; + +// The message to create an Execution. +message MsgCreate { + // The msg's signer. + bytes signer = 1 [ + (gogoproto.moretags) = 'validate:"required,accaddress"', + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" + ]; + + // taskKey to filter executions. + string taskKey = 2 [ + (gogoproto.moretags) = 'validate:"required,printascii"' + ]; + + mesg.protobuf.Struct inputs = 3; + + // tags the execution. + repeated string tags = 4 [ + (gogoproto.moretags) = 'validate:"dive,printascii"' + ]; + + bytes parentHash = 5 [ + (gogoproto.moretags) = 'validate:"required_without=EventHash,omitempty,hash"', + (gogoproto.casttype) = "github.com/mesg-foundation/engine/hash.Hash" + ]; + + bytes eventHash = 6 [ + (gogoproto.moretags) = 'validate:"required_without=ParentHash,omitempty,hash"', + (gogoproto.casttype) = "github.com/mesg-foundation/engine/hash.Hash" + ]; + + bytes processHash = 7 [ + (gogoproto.moretags) = 'validate:"omitempty,hash"', + (gogoproto.casttype) = "github.com/mesg-foundation/engine/hash.Hash" + ]; + + string nodeKey = 8; + + bytes executorHash = 9 [ + (gogoproto.moretags) = 'validate:"required,hash"', + (gogoproto.casttype) = "github.com/mesg-foundation/engine/hash.Hash" + ]; + + // price of running the execution. + string price = 10 [ + (gogoproto.moretags) = 'validate:"coinsPositiveZero"' + ]; +} + +// The message to update an Execution. +message MsgUpdate { + // The execution's executor. + bytes executor = 1 [ + (gogoproto.moretags) = 'validate:"required,accaddress"', + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" + ]; + + // Hash represents execution. + bytes hash = 2 [ + (gogoproto.moretags) = 'validate:"required,hash"', + (gogoproto.casttype) = "github.com/mesg-foundation/engine/hash.Hash" + ]; + + // result pass to execution + oneof result { + // outputs is a success result. + mesg.protobuf.Struct outputs = 3; + + // error is an error result. + string error = 4; + } +} diff --git a/x/execution/internal/types/querier.go b/x/execution/internal/types/querier.go index cd2a8920f..24f2f46fe 100644 --- a/x/execution/internal/types/querier.go +++ b/x/execution/internal/types/querier.go @@ -1,6 +1,6 @@ package types const ( - QueryGetExecution = "get" - QueryListExecution = "list" + QueryGet = "get" + QueryList = "list" ) diff --git a/x/instance/alias.go b/x/instance/alias.go index 558da0ee9..b814ed649 100644 --- a/x/instance/alias.go +++ b/x/instance/alias.go @@ -23,9 +23,14 @@ var ( DefaultGenesisState = types.DefaultGenesisState ValidateGenesis = types.ValidateGenesis - ModuleCdc = types.ModuleCdc - QueryGetInstance = types.QueryGetInstance - QueryListInstances = types.QueryListInstances + ModuleCdc = types.ModuleCdc + QueryGet = types.QueryGet + QueryList = types.QueryList + + EventType = types.EventType + AttributeKeyHash = types.AttributeKeyHash + AttributeKeyService = types.AttributeKeyService + AttributeActionCreated = types.AttributeActionCreated ) // module types diff --git a/x/instance/client/cli/query.go b/x/instance/client/cli/query.go index 2152c26e9..4fc9fb3f6 100644 --- a/x/instance/client/cli/query.go +++ b/x/instance/client/cli/query.go @@ -25,22 +25,22 @@ func GetQueryCmd(queryRoute string, cdc *codec.Codec) *cobra.Command { instanceQueryCmd.AddCommand( flags.GetCommands( - GetCmdGetInstance(queryRoute, cdc), - GetCmdListInstances(queryRoute, cdc), + GetCmdGet(queryRoute, cdc), + GetCmdLists(queryRoute, cdc), )..., ) return instanceQueryCmd } -func GetCmdGetInstance(queryRoute string, cdc *codec.Codec) *cobra.Command { +func GetCmdGet(queryRoute string, cdc *codec.Codec) *cobra.Command { return &cobra.Command{ Use: "get", Short: "get", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { cliCtx := context.NewCLIContext().WithCodec(cdc) - res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s/%s", queryRoute, types.QueryGetInstance, args[0]), nil) + res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s/%s", queryRoute, types.QueryGet, args[0]), nil) if err != nil { fmt.Printf("could not get instance\n%s\n", err.Error()) return nil @@ -53,13 +53,13 @@ func GetCmdGetInstance(queryRoute string, cdc *codec.Codec) *cobra.Command { } } -func GetCmdListInstances(queryRoute string, cdc *codec.Codec) *cobra.Command { +func GetCmdLists(queryRoute string, cdc *codec.Codec) *cobra.Command { return &cobra.Command{ Use: "list", Short: "list", RunE: func(cmd *cobra.Command, args []string) error { cliCtx := context.NewCLIContext().WithCodec(cdc) - res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryListInstances), nil) + res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryList), nil) if err != nil { fmt.Printf("could not list instances\n%s\n", err.Error()) return nil diff --git a/x/instance/client/rest/query.go b/x/instance/client/rest/query.go index 8ac2b595e..c06778f43 100644 --- a/x/instance/client/rest/query.go +++ b/x/instance/client/rest/query.go @@ -15,14 +15,16 @@ func registerQueryRoutes(cliCtx context.CLIContext, r *mux.Router) { "/instance/get/{hash}", queryGetHandlerFn(cliCtx), ).Methods(http.MethodGet) + r.HandleFunc( "/instance/list", queryListHandlerFn(cliCtx), ).Methods(http.MethodGet) + r.HandleFunc( "/instance/parameters", queryParametersHandlerFn(cliCtx), - ).Methods("GET") + ).Methods(http.MethodGet) } func queryGetHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { @@ -34,7 +36,7 @@ func queryGetHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { return } - route := fmt.Sprintf("custom/%s/%s/%s", types.QuerierRoute, types.QueryGetInstance, vars["hash"]) + route := fmt.Sprintf("custom/%s/%s/%s", types.QuerierRoute, types.QueryGet, vars["hash"]) res, height, err := cliCtx.QueryWithData(route, nil) if err != nil { @@ -54,7 +56,7 @@ func queryListHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { return } - route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryListInstances) + route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryList) res, height, err := cliCtx.QueryWithData(route, nil) if err != nil { diff --git a/x/instance/internal/keeper/keeper.go b/x/instance/internal/keeper/keeper.go index da85d7785..0a7d10224 100644 --- a/x/instance/internal/keeper/keeper.go +++ b/x/instance/internal/keeper/keeper.go @@ -8,7 +8,6 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/mesg-foundation/engine/hash" "github.com/mesg-foundation/engine/instance" - "github.com/mesg-foundation/engine/protobuf/api" "github.com/mesg-foundation/engine/x/instance/internal/types" "github.com/tendermint/tendermint/libs/log" ) @@ -37,11 +36,10 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { func (k Keeper) FetchOrCreate(ctx sdk.Context, serviceHash hash.Hash, envHash hash.Hash) (*instance.Instance, error) { store := ctx.KVStore(k.storeKey) - inst := &instance.Instance{ - ServiceHash: serviceHash, - EnvHash: envHash, + inst, err := instance.New(serviceHash, envHash) + if err != nil { + return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, err.Error()) } - inst.Hash = hash.Dump(inst) if !store.Has(inst.Hash) { value, err := k.cdc.MarshalBinaryLengthPrefixed(inst) @@ -49,6 +47,14 @@ func (k Keeper) FetchOrCreate(ctx sdk.Context, serviceHash hash.Hash, envHash ha return nil, sdkerrors.Wrapf(sdkerrors.ErrJSONMarshal, err.Error()) } store.Set(inst.Hash, value) + + // emit event + ctx.EventManager().EmitEvent(sdk.NewEvent( + types.EventType, + sdk.NewAttribute(sdk.AttributeKeyAction, types.AttributeActionCreated), + sdk.NewAttribute(types.AttributeKeyHash, inst.Hash.String()), + sdk.NewAttribute(types.AttributeKeyService, inst.ServiceHash.String()), + )) } return inst, nil @@ -69,7 +75,7 @@ func (k Keeper) Get(ctx sdk.Context, instanceHash hash.Hash) (*instance.Instance } // List returns instances from the keeper. -func (k Keeper) List(ctx sdk.Context, f *api.ListInstanceRequest_Filter) ([]*instance.Instance, error) { +func (k Keeper) List(ctx sdk.Context) ([]*instance.Instance, error) { store := ctx.KVStore(k.storeKey) iter := store.Iterator(nil, nil) var items []*instance.Instance @@ -79,9 +85,7 @@ func (k Keeper) List(ctx sdk.Context, f *api.ListInstanceRequest_Filter) ([]*ins if err := k.cdc.UnmarshalBinaryLengthPrefixed(iter.Value(), &item); err != nil { return nil, sdkerrors.Wrapf(sdkerrors.ErrJSONUnmarshal, err.Error()) } - if f == nil || f.ServiceHash.IsZero() || item.ServiceHash.Equal(f.ServiceHash) { - items = append(items, item) - } + items = append(items, item) iter.Next() } iter.Close() diff --git a/x/instance/internal/keeper/querier.go b/x/instance/internal/keeper/querier.go index f29e29318..c7ce223d8 100644 --- a/x/instance/internal/keeper/querier.go +++ b/x/instance/internal/keeper/querier.go @@ -4,7 +4,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/mesg-foundation/engine/hash" - "github.com/mesg-foundation/engine/protobuf/api" "github.com/mesg-foundation/engine/x/instance/internal/types" abci "github.com/tendermint/tendermint/abci/types" ) @@ -13,17 +12,17 @@ import ( func NewQuerier(k Keeper) sdk.Querier { return func(ctx sdk.Context, path []string, req abci.RequestQuery) ([]byte, error) { switch path[0] { - case types.QueryGetInstance: - return getInstance(ctx, path[1:], k) - case types.QueryListInstances: - return listInstance(ctx, req, k) + case types.QueryGet: + return get(ctx, path[1:], k) + case types.QueryList: + return list(ctx, k) default: return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "unknown instance query endpoint") } } } -func getInstance(ctx sdk.Context, path []string, k Keeper) ([]byte, error) { +func get(ctx sdk.Context, path []string, k Keeper) ([]byte, error) { if len(path) == 0 { return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "missing hash") } @@ -44,17 +43,8 @@ func getInstance(ctx sdk.Context, path []string, k Keeper) ([]byte, error) { return res, nil } -func listInstance(ctx sdk.Context, req abci.RequestQuery, k Keeper) ([]byte, error) { - var f *api.ListInstanceRequest_Filter - if len(req.Data) > 0 { - var r *api.ListInstanceRequest - if err := types.ModuleCdc.UnmarshalJSON(req.Data, &r); err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - f = r.Filter - } - - instances, err := k.List(ctx, f) +func list(ctx sdk.Context, k Keeper) ([]byte, error) { + instances, err := k.List(ctx) if err != nil { return nil, err } diff --git a/x/instance/internal/types/events.go b/x/instance/internal/types/events.go new file mode 100644 index 000000000..aff1f95df --- /dev/null +++ b/x/instance/internal/types/events.go @@ -0,0 +1,11 @@ +package types + +// module event types and attributes +const ( + EventType = "instance" + + AttributeKeyHash = "hash" + AttributeKeyService = "service" + + AttributeActionCreated = "created" +) diff --git a/x/instance/internal/types/querier.go b/x/instance/internal/types/querier.go index ec91f8b77..13411808e 100644 --- a/x/instance/internal/types/querier.go +++ b/x/instance/internal/types/querier.go @@ -2,6 +2,6 @@ package types // Query endpoints supported by the instance querier const ( - QueryGetInstance = "get" - QueryListInstances = "list" + QueryGet = "get" + QueryList = "list" ) diff --git a/x/ownership/alias.go b/x/ownership/alias.go index 617409936..3db12dd79 100644 --- a/x/ownership/alias.go +++ b/x/ownership/alias.go @@ -23,10 +23,16 @@ var ( DefaultGenesisState = types.DefaultGenesisState ValidateGenesis = types.ValidateGenesis - ModuleCdc = types.ModuleCdc - QueryListOwnerships = types.QueryListOwnerships + ModuleCdc = types.ModuleCdc + QueryList = types.QueryList - NewMsgWithdrawCoins = types.NewMsgWithdrawCoins + EventType = types.EventType + AttributeKeyHash = types.AttributeKeyHash + AttributeKeyResourceHash = types.AttributeKeyResourceHash + AttributeKeyResourceType = types.AttributeKeyResourceType + AttributeKeyResourceAddress = types.AttributeKeyResourceAddress + AttributeActionCreated = types.AttributeActionCreated + AttributeActionDeleted = types.AttributeActionDeleted ) // module types @@ -35,5 +41,5 @@ type ( GenesisState = types.GenesisState Params = types.Params - MsgWithdrawCoins = types.MsgWithdrawCoins + MsgWithdraw = types.MsgWithdraw ) diff --git a/x/ownership/client/cli/query.go b/x/ownership/client/cli/query.go index 2172df13e..2818b1569 100644 --- a/x/ownership/client/cli/query.go +++ b/x/ownership/client/cli/query.go @@ -25,21 +25,21 @@ func GetQueryCmd(queryRoute string, cdc *codec.Codec) *cobra.Command { ownershipQueryCmd.AddCommand( flags.GetCommands( - GetCmdListOwnerships(queryRoute, cdc), + GetCmdList(queryRoute, cdc), )..., ) return ownershipQueryCmd } -// GetCmdListOwnerships returns command listing ownerships -func GetCmdListOwnerships(queryRoute string, cdc *codec.Codec) *cobra.Command { +// GetCmdList returns command listing ownerships +func GetCmdList(queryRoute string, cdc *codec.Codec) *cobra.Command { return &cobra.Command{ Use: "list", Short: "list", RunE: func(cmd *cobra.Command, args []string) error { cliCtx := context.NewCLIContext().WithCodec(cdc) - res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryListOwnerships), nil) + res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryList), nil) if err != nil { fmt.Printf("could not get ownerships\n%s\n", err.Error()) return nil diff --git a/x/ownership/client/cli/tx.go b/x/ownership/client/cli/tx.go index c3df07e36..d6be73e06 100644 --- a/x/ownership/client/cli/tx.go +++ b/x/ownership/client/cli/tx.go @@ -27,13 +27,13 @@ func GetTxCmd(cdc *codec.Codec) *cobra.Command { } ownershipTxCmd.AddCommand(flags.PostCommands( - GetCmdWithdrawCoins(cdc), + GetCmdWithdraw(cdc), )...) return ownershipTxCmd } -// GetCmdWithdrawCoins is the CLI command for sending a WithdrawCoins transaction -func GetCmdWithdrawCoins(cdc *codec.Codec) *cobra.Command { +// GetCmdWithdraw is the CLI command for sending a Withdraw transaction +func GetCmdWithdraw(cdc *codec.Codec) *cobra.Command { return &cobra.Command{ Use: "withdraw-coins [resource] [amount]", Short: "withdraw amount from resource address", @@ -49,12 +49,11 @@ func GetCmdWithdrawCoins(cdc *codec.Codec) *cobra.Command { return err } - coins, err := sdk.ParseCoins(args[1]) - if err != nil { - return err + msg := types.MsgWithdraw{ + Owner: cliCtx.GetFromAddress(), + ResourceHash: h, + Amount: args[1], } - - msg := types.NewMsgWithdrawCoins(h, coins, cliCtx.GetFromAddress()) if err = msg.ValidateBasic(); err != nil { return err } diff --git a/x/ownership/client/rest/query.go b/x/ownership/client/rest/query.go index 92706b341..1a9663f5f 100644 --- a/x/ownership/client/rest/query.go +++ b/x/ownership/client/rest/query.go @@ -15,6 +15,7 @@ func registerQueryRoutes(cliCtx context.CLIContext, r *mux.Router) { "/ownership/list", queryListHandlerFn(cliCtx), ).Methods(http.MethodGet) + r.HandleFunc( "/ownership/parameters", queryParamsHandlerFn(cliCtx), @@ -28,7 +29,7 @@ func queryListHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { return } - route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryListOwnerships) + route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryList) res, height, err := cliCtx.QueryWithData(route, nil) if err != nil { rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) diff --git a/x/ownership/client/rest/tx.go b/x/ownership/client/rest/tx.go index ef371501b..2f2cc048a 100644 --- a/x/ownership/client/rest/tx.go +++ b/x/ownership/client/rest/tx.go @@ -12,7 +12,7 @@ import ( "github.com/mesg-foundation/engine/x/ownership/internal/types" ) -type withdrawCoinsReq struct { +type withdrawReq struct { BaseReq rest.BaseReq `json:"base_req"` Amount string `json:"amount"` Hash hash.Hash `json:"hash"` @@ -21,13 +21,13 @@ type withdrawCoinsReq struct { func registerTxRoutes(cliCtx context.CLIContext, r *mux.Router) { r.HandleFunc( "/ownership/withdraw-coins", - txWithdrawCoinsHandlerFn(cliCtx), + txWithdrawHandlerFn(cliCtx), ).Methods(http.MethodPost) } -func txWithdrawCoinsHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { +func txWithdrawHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - var req withdrawCoinsReq + var req withdrawReq if !rest.ReadRESTReq(w, r, cliCtx.Codec, &req) { rest.WriteErrorResponse(w, http.StatusBadRequest, "failed to parse request") @@ -45,13 +45,11 @@ func txWithdrawCoinsHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { return } - amt, err := sdk.ParseCoins(req.Amount) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return + msg := types.MsgWithdraw{ + Owner: owner, + ResourceHash: req.Hash, + Amount: req.Amount, } - - msg := types.NewMsgWithdrawCoins(req.Hash, amt, owner) if err := msg.ValidateBasic(); err != nil { rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) return diff --git a/x/ownership/handler.go b/x/ownership/handler.go index e6fae32af..e1adada41 100644 --- a/x/ownership/handler.go +++ b/x/ownership/handler.go @@ -13,8 +13,8 @@ func NewHandler(k Keeper) sdk.Handler { return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { ctx = ctx.WithEventManager(sdk.NewEventManager()) switch msg := msg.(type) { - case MsgWithdrawCoins: - return handleMsgWithdrawCoins(ctx, k, msg) + case MsgWithdraw: + return handleMsgWithdraw(ctx, k, msg) default: errMsg := fmt.Sprintf("unrecognized %s message type: %T", types.ModuleName, msg) return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg) @@ -22,18 +22,17 @@ func NewHandler(k Keeper) sdk.Handler { } } -// handleMsgWithdrawCoins withdraws coins from resource to the owner. -func handleMsgWithdrawCoins(ctx sdk.Context, k Keeper, msg MsgWithdrawCoins) (*sdk.Result, error) { - if err := k.WithdrawCoins(ctx, msg); err != nil { +// handleMsgWithdraw withdraws coins from resource to the owner. +func handleMsgWithdraw(ctx sdk.Context, k Keeper, msg MsgWithdraw) (*sdk.Result, error) { + if err := k.Withdraw(ctx, msg); err != nil { return nil, err } ctx.EventManager().EmitEvent( sdk.NewEvent( sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - sdk.NewAttribute(sdk.AttributeKeyAction, types.EventTypeWithdrawCoins), - sdk.NewAttribute(sdk.AttributeKeySender, msg.Hash.String()), + sdk.NewAttribute(sdk.AttributeKeyModule, ModuleName), + sdk.NewAttribute(sdk.AttributeKeySender, msg.Owner.String()), ), ) diff --git a/x/ownership/internal/keeper/keeper.go b/x/ownership/internal/keeper/keeper.go index 5951d00c1..b933541da 100644 --- a/x/ownership/internal/keeper/keeper.go +++ b/x/ownership/internal/keeper/keeper.go @@ -57,7 +57,7 @@ func (k *Keeper) List(ctx sdk.Context) ([]*ownership.Ownership, error) { // Set creates a new ownership. func (k Keeper) Set(ctx sdk.Context, owner sdk.AccAddress, resourceHash hash.Hash, resource ownership.Ownership_Resource, resourceAddress sdk.AccAddress) (*ownership.Ownership, error) { store := ctx.KVStore(k.storeKey) - own, err := k.getOwnership(store, resourceHash) + own, err := k.get(store, resourceHash) if err != nil { return nil, err } @@ -65,27 +65,36 @@ func (k Keeper) Set(ctx sdk.Context, owner sdk.AccAddress, resourceHash hash.Has return nil, sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "resource %s:%q already has an owner", resource, resourceHash) } - // TODO: should be moved to a new function - own = &ownership.Ownership{ - Owner: owner.String(), - Resource: resource, - ResourceHash: resourceHash, - ResourceAddress: resourceAddress, + own, err = ownership.New(owner.String(), resource, resourceHash, resourceAddress) + if err != nil { + return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, err.Error()) } - own.Hash = hash.Dump(own) data, err := k.cdc.MarshalBinaryLengthPrefixed(own) if err != nil { return nil, sdkerrors.Wrapf(sdkerrors.ErrJSONMarshal, err.Error()) } store.Set(own.Hash, data) + + // emit event + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventType, + sdk.NewAttribute(sdk.AttributeKeyAction, types.AttributeActionCreated), + sdk.NewAttribute(types.AttributeKeyHash, own.Hash.String()), + sdk.NewAttribute(types.AttributeKeyResourceHash, own.ResourceHash.String()), + sdk.NewAttribute(types.AttributeKeyResourceType, own.Resource.String()), + sdk.NewAttribute(types.AttributeKeyResourceAddress, own.ResourceAddress.String()), + ), + ) + return own, nil } // Delete deletes an ownership. func (k Keeper) Delete(ctx sdk.Context, owner sdk.AccAddress, resourceHash hash.Hash) error { store := ctx.KVStore(k.storeKey) - own, err := k.getOwnership(store, resourceHash) + own, err := k.get(store, resourceHash) if err != nil { return err } @@ -106,27 +115,44 @@ func (k Keeper) Delete(ctx sdk.Context, owner sdk.AccAddress, resourceHash hash. // remove ownership store.Delete(own.Hash) + + // emit event + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventType, + sdk.NewAttribute(sdk.AttributeKeyAction, types.AttributeActionDeleted), + sdk.NewAttribute(types.AttributeKeyHash, own.Hash.String()), + sdk.NewAttribute(types.AttributeKeyResourceHash, own.ResourceHash.String()), + sdk.NewAttribute(types.AttributeKeyResourceType, own.Resource.String()), + sdk.NewAttribute(types.AttributeKeyResourceAddress, own.ResourceAddress.String()), + ), + ) + return nil } -// WithdrawCoins try to withdraw coins to owner rom specific resource. -func (k Keeper) WithdrawCoins(ctx sdk.Context, msg types.MsgWithdrawCoins) error { +// Withdraw try to withdraw coins to owner rom specific resource. +func (k Keeper) Withdraw(ctx sdk.Context, msg types.MsgWithdraw) error { store := ctx.KVStore(k.storeKey) - own, err := k.getOwnership(store, msg.Hash) + amount, err := sdk.ParseCoins(msg.Amount) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, err.Error()) + } + own, err := k.get(store, msg.ResourceHash) if err != nil { return err } if own == nil { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "resource %q does not have any ownership", msg.Hash) + return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "resource %q does not have any ownership", msg.ResourceHash) } if own.Owner != msg.Owner.String() { - return sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "resource %q is not owned by you", msg.Hash) + return sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "resource %q is not owned by you", msg.ResourceHash) } - return k.bankKeeper.SendCoins(ctx, own.ResourceAddress, msg.Owner, msg.Amount) + return k.bankKeeper.SendCoins(ctx, own.ResourceAddress, msg.Owner, amount) } -// getOwnership returns the ownership of a given resource. -func (k Keeper) getOwnership(store sdk.KVStore, resourceHash hash.Hash) (*ownership.Ownership, error) { +// get returns the ownership of a given resource. +func (k Keeper) get(store sdk.KVStore, resourceHash hash.Hash) (*ownership.Ownership, error) { iter := store.Iterator(nil, nil) var own *ownership.Ownership for iter.Valid() { diff --git a/x/ownership/internal/keeper/querier.go b/x/ownership/internal/keeper/querier.go index 9dd8b3117..aa7583ebe 100644 --- a/x/ownership/internal/keeper/querier.go +++ b/x/ownership/internal/keeper/querier.go @@ -11,15 +11,15 @@ import ( func NewQuerier(k Keeper) sdk.Querier { return func(ctx sdk.Context, path []string, req abci.RequestQuery) ([]byte, error) { switch path[0] { - case types.QueryListOwnerships: - return listOwnerships(ctx, k) + case types.QueryList: + return list(ctx, k) default: return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "unknown ownership query endpoint") } } } -func listOwnerships(ctx sdk.Context, k Keeper) ([]byte, error) { +func list(ctx sdk.Context, k Keeper) ([]byte, error) { ownerships, err := k.List(ctx) if err != nil { return nil, err diff --git a/x/ownership/internal/types/codec.go b/x/ownership/internal/types/codec.go index eacaa243d..f4df6dd2f 100644 --- a/x/ownership/internal/types/codec.go +++ b/x/ownership/internal/types/codec.go @@ -6,7 +6,7 @@ import ( // RegisterCodec registers concrete types on codec. func RegisterCodec(cdc *codec.Codec) { - cdc.RegisterConcrete(MsgWithdrawCoins{}, "ownership/WithdrawCoins", nil) + cdc.RegisterConcrete(MsgWithdraw{}, "ownership/withdraw", nil) } // ModuleCdc defines the module codec. diff --git a/x/ownership/internal/types/events.go b/x/ownership/internal/types/events.go index 9152c4e12..fd15e098c 100644 --- a/x/ownership/internal/types/events.go +++ b/x/ownership/internal/types/events.go @@ -1,8 +1,14 @@ package types -// ownership module event types +// module event types and attributes const ( - EventTypeWithdrawCoins = "WithdrawCoins" + EventType = "ownership" - AttributeValueCategory = ModuleName + AttributeKeyHash = "hash" + AttributeKeyResourceHash = "resource_hash" + AttributeKeyResourceType = "ressource_type" + AttributeKeyResourceAddress = "ressource_address" + + AttributeActionCreated = "created" + AttributeActionDeleted = "deleted" ) diff --git a/x/ownership/internal/types/msg.go b/x/ownership/internal/types/msg.go index b695b6f49..71acdac00 100644 --- a/x/ownership/internal/types/msg.go +++ b/x/ownership/internal/types/msg.go @@ -3,56 +3,33 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/mesg-foundation/engine/hash" + "github.com/mesg-foundation/engine/ext/xvalidator" ) -// MsgWithdrawCoins defines a state transition to create a execution. -type MsgWithdrawCoins struct { - Hash hash.Hash `json:"hash"` - Amount sdk.Coins `json:"amount"` - Owner sdk.AccAddress `json:"owner"` -} - -// NewMsgWithdrawCoins is a constructor function for MsgWithdrawCoins. -func NewMsgWithdrawCoins(h hash.Hash, amount sdk.Coins, owner sdk.AccAddress) *MsgWithdrawCoins { - return &MsgWithdrawCoins{ - Hash: h, - Amount: amount, - Owner: owner, - } -} - // Route should return the name of the module. -func (msg MsgWithdrawCoins) Route() string { +func (msg MsgWithdraw) Route() string { return ModuleName } // Type returns the action. -func (msg MsgWithdrawCoins) Type() string { - return "WithdrawCoins" +func (msg MsgWithdraw) Type() string { + return "withdraw" } // ValidateBasic runs stateless checks on the message. -func (msg MsgWithdrawCoins) ValidateBasic() error { - if msg.Amount.IsAnyNegative() { - return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, "price must be positive") - } - if msg.Owner.Empty() { - return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, msg.Owner.String()) +func (msg MsgWithdraw) ValidateBasic() error { + if err := xvalidator.Struct(msg); err != nil { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error()) } - if msg.Hash.IsZero() || !msg.Hash.Valid() { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid hash") - } - return nil } // GetSignBytes encodes the message for signing. -func (msg MsgWithdrawCoins) GetSignBytes() []byte { +func (msg MsgWithdraw) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(msg)) } // GetSigners defines whose signature is required. -func (msg MsgWithdrawCoins) GetSigners() []sdk.AccAddress { +func (msg MsgWithdraw) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{msg.Owner} } diff --git a/x/ownership/internal/types/msg.pb.go b/x/ownership/internal/types/msg.pb.go new file mode 100644 index 000000000..eec6b3a4c --- /dev/null +++ b/x/ownership/internal/types/msg.pb.go @@ -0,0 +1,114 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: x/ownership/internal/types/msg.proto + +package types + +import ( + fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + github_com_mesg_foundation_engine_hash "github.com/mesg-foundation/engine/hash" + math "math" +) + +// 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 + +// The message to withdraw coins from an ownership. +type MsgWithdraw struct { + // The ownership's owner. + Owner github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,opt,name=owner,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"owner,omitempty" validate:"required,accaddress"` + // Hash of the resource to withdraw from. + ResourceHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,2,opt,name=resourceHash,proto3,casttype=github.com/mesg-foundation/engine/hash.Hash" json:"resourceHash,omitempty" validate:"required,hash"` + // amount to withdraw + Amount string `protobuf:"bytes,3,opt,name=amount,proto3" json:"amount,omitempty" validate:"required,coinsPositiveZero"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *MsgWithdraw) Reset() { *m = MsgWithdraw{} } +func (m *MsgWithdraw) String() string { return proto.CompactTextString(m) } +func (*MsgWithdraw) ProtoMessage() {} +func (*MsgWithdraw) Descriptor() ([]byte, []int) { + return fileDescriptor_875fd6c128efe9e4, []int{0} +} +func (m *MsgWithdraw) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_MsgWithdraw.Unmarshal(m, b) +} +func (m *MsgWithdraw) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_MsgWithdraw.Marshal(b, m, deterministic) +} +func (m *MsgWithdraw) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgWithdraw.Merge(m, src) +} +func (m *MsgWithdraw) XXX_Size() int { + return xxx_messageInfo_MsgWithdraw.Size(m) +} +func (m *MsgWithdraw) XXX_DiscardUnknown() { + xxx_messageInfo_MsgWithdraw.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgWithdraw proto.InternalMessageInfo + +func (m *MsgWithdraw) GetOwner() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.Owner + } + return nil +} + +func (m *MsgWithdraw) GetResourceHash() github_com_mesg_foundation_engine_hash.Hash { + if m != nil { + return m.ResourceHash + } + return nil +} + +func (m *MsgWithdraw) GetAmount() string { + if m != nil { + return m.Amount + } + return "" +} + +func init() { + proto.RegisterType((*MsgWithdraw)(nil), "mesg.ownership.types.MsgWithdraw") +} + +func init() { + proto.RegisterFile("x/ownership/internal/types/msg.proto", fileDescriptor_875fd6c128efe9e4) +} + +var fileDescriptor_875fd6c128efe9e4 = []byte{ + // 307 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x91, 0xc1, 0x4b, 0xc3, 0x30, + 0x14, 0xc6, 0xd9, 0xc4, 0x81, 0x75, 0xa7, 0xe2, 0xa1, 0x78, 0xb0, 0xa3, 0x28, 0x4c, 0x74, 0xcd, + 0xc1, 0x9b, 0x88, 0xb0, 0x9d, 0x04, 0x11, 0x64, 0x1e, 0x84, 0xdd, 0xb2, 0xe4, 0x2d, 0x0d, 0xae, + 0x79, 0x33, 0x2f, 0xd9, 0xf4, 0x7f, 0xf2, 0x6f, 0xea, 0x1f, 0xd1, 0xa3, 0x27, 0x69, 0x3a, 0x44, + 0x61, 0xe2, 0x29, 0xf9, 0xc8, 0xf7, 0x7d, 0xbf, 0x24, 0x2f, 0x3a, 0x7d, 0x63, 0xb8, 0x31, 0x60, + 0xa9, 0xd0, 0x2b, 0xa6, 0x8d, 0x03, 0x6b, 0xf8, 0x92, 0xb9, 0xf7, 0x15, 0x10, 0x2b, 0x49, 0xe5, + 0x2b, 0x8b, 0x0e, 0xe3, 0xa3, 0x12, 0x48, 0xe5, 0xdf, 0xc6, 0x3c, 0x9c, 0x1f, 0x67, 0x0a, 0x15, + 0xb2, 0xe0, 0x98, 0xfb, 0x05, 0x6b, 0x54, 0x10, 0x61, 0xd7, 0x26, 0xb3, 0x8f, 0x6e, 0x74, 0xf8, + 0x40, 0xea, 0x59, 0xbb, 0x42, 0x5a, 0xbe, 0x89, 0x75, 0xb4, 0x1f, 0x6a, 0x92, 0xce, 0xa0, 0x33, + 0xec, 0x4f, 0x9e, 0xea, 0x2a, 0x3d, 0x59, 0xf3, 0xa5, 0x96, 0xdc, 0xc1, 0x75, 0x66, 0xe1, 0xd5, + 0x6b, 0x0b, 0xf2, 0x92, 0x0b, 0xc1, 0xa5, 0xb4, 0x40, 0x94, 0x7d, 0x56, 0xe9, 0x48, 0x69, 0x57, + 0xf8, 0x79, 0x2e, 0xb0, 0x64, 0x02, 0xa9, 0x44, 0xda, 0x2e, 0x23, 0x92, 0x2f, 0xed, 0x65, 0xf3, + 0xb1, 0x10, 0xe3, 0x36, 0x31, 0x6d, 0x09, 0x31, 0x46, 0x7d, 0x0b, 0x84, 0xde, 0x0a, 0xb8, 0xe3, + 0x54, 0x24, 0xdd, 0x40, 0xbc, 0xaf, 0xab, 0x34, 0xd9, 0x41, 0x2c, 0x38, 0x15, 0x0d, 0xeb, 0xe2, + 0x07, 0xab, 0x79, 0xf5, 0x68, 0x81, 0xde, 0x48, 0xee, 0x34, 0x1a, 0x06, 0x46, 0x69, 0x03, 0xac, + 0xb1, 0xe6, 0x4d, 0xe5, 0xf4, 0x17, 0x20, 0x1e, 0x47, 0x3d, 0x5e, 0xa2, 0x37, 0x2e, 0xd9, 0x1b, + 0x74, 0x86, 0x07, 0x93, 0xf3, 0xba, 0x4a, 0xcf, 0x76, 0xa0, 0x04, 0x6a, 0x43, 0x8f, 0x48, 0xda, + 0xe9, 0x35, 0xcc, 0xc0, 0x62, 0x36, 0xdd, 0x06, 0x27, 0xb7, 0xb3, 0x9b, 0xff, 0xf9, 0x7f, 0x8f, + 0x6c, 0xde, 0x0b, 0xbf, 0x7e, 0xf5, 0x15, 0x00, 0x00, 0xff, 0xff, 0x0d, 0x13, 0xa3, 0xab, 0xd7, + 0x01, 0x00, 0x00, +} diff --git a/x/ownership/internal/types/msg.proto b/x/ownership/internal/types/msg.proto new file mode 100644 index 000000000..349ddf594 --- /dev/null +++ b/x/ownership/internal/types/msg.proto @@ -0,0 +1,26 @@ +syntax = "proto3"; + +import "gogo/protobuf/gogoproto/gogo.proto"; + +package mesg.ownership.types; +option go_package = "github.com/mesg-foundation/engine/x/ownership/internal/types"; + +// The message to withdraw coins from an ownership. +message MsgWithdraw { + // The ownership's owner. + bytes owner = 1 [ + (gogoproto.moretags) = 'validate:"required,accaddress"', + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" + ]; + + // Hash of the resource to withdraw from. + bytes resourceHash = 2 [ + (gogoproto.moretags) = 'validate:"required,hash"', + (gogoproto.casttype) = "github.com/mesg-foundation/engine/hash.Hash" + ]; + + // amount to withdraw + string amount = 3 [ + (gogoproto.moretags) = 'validate:"required,coinsPositiveZero"' + ]; +} diff --git a/x/ownership/internal/types/querier.go b/x/ownership/internal/types/querier.go index 96ab75048..8f6a066ba 100644 --- a/x/ownership/internal/types/querier.go +++ b/x/ownership/internal/types/querier.go @@ -2,5 +2,5 @@ package types // Query endpoints supported by the ownership querier const ( - QueryListOwnerships = "list" + QueryList = "list" ) diff --git a/x/process/alias.go b/x/process/alias.go index 83d4bc449..a6fb21e75 100644 --- a/x/process/alias.go +++ b/x/process/alias.go @@ -25,11 +25,15 @@ var ( ModuleCdc = types.ModuleCdc - QueryGetProcess = types.QueryGetProcess - QueryListProcesses = types.QueryListProcesses - - NewMsgCreateProcess = types.NewMsgCreateProcess - NewMsgDeleteProcess = types.NewMsgDeleteProcess + QueryGet = types.QueryGet + QueryList = types.QueryList + QueryExist = types.QueryExist + + EventType = types.EventType + AttributeKeyHash = types.AttributeKeyHash + AttributeKeyAddress = types.AttributeKeyAddress + AttributeActionCreated = types.AttributeActionCreated + AttributeActionDeleted = types.AttributeActionDeleted ) // module types @@ -38,6 +42,6 @@ type ( GenesisState = types.GenesisState Params = types.Params - MsgCreateProcess = types.MsgCreateProcess - MsgDeleteProcess = types.MsgDeleteProcess + MsgCreate = types.MsgCreate + MsgDelete = types.MsgDelete ) diff --git a/x/process/client/cli/query.go b/x/process/client/cli/query.go index 26ba27146..8a658b46e 100644 --- a/x/process/client/cli/query.go +++ b/x/process/client/cli/query.go @@ -25,22 +25,23 @@ func GetQueryCmd(queryRoute string, cdc *codec.Codec) *cobra.Command { processQueryCmd.AddCommand( flags.GetCommands( - GetCmdGetProcess(queryRoute, cdc), - GetCmdListProcesses(queryRoute, cdc), + GetCmdGet(queryRoute, cdc), + GetCmdList(queryRoute, cdc), + GetCmdExist(queryRoute, cdc), )..., ) return processQueryCmd } -func GetCmdGetProcess(queryRoute string, cdc *codec.Codec) *cobra.Command { +func GetCmdGet(queryRoute string, cdc *codec.Codec) *cobra.Command { return &cobra.Command{ Use: "get", Short: "get", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { cliCtx := context.NewCLIContext().WithCodec(cdc) - res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s/%s", queryRoute, types.QueryGetProcess, args[0]), nil) + res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s/%s", queryRoute, types.QueryGet, args[0]), nil) if err != nil { fmt.Printf("could not get process\n%s\n", err.Error()) return nil @@ -53,13 +54,13 @@ func GetCmdGetProcess(queryRoute string, cdc *codec.Codec) *cobra.Command { } } -func GetCmdListProcesses(queryRoute string, cdc *codec.Codec) *cobra.Command { +func GetCmdList(queryRoute string, cdc *codec.Codec) *cobra.Command { return &cobra.Command{ Use: "list", Short: "list", RunE: func(cmd *cobra.Command, args []string) error { cliCtx := context.NewCLIContext().WithCodec(cdc) - res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryListProcesses), nil) + res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryList), nil) if err != nil { fmt.Printf("could not list processes\n%s\n", err.Error()) return nil @@ -71,3 +72,23 @@ func GetCmdListProcesses(queryRoute string, cdc *codec.Codec) *cobra.Command { }, } } + +func GetCmdExist(queryRoute string, cdc *codec.Codec) *cobra.Command { + return &cobra.Command{ + Use: "exist [hash]", + Short: "exist", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + cliCtx := context.NewCLIContext().WithCodec(cdc) + res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s/%s", queryRoute, types.QueryExist, args[0]), nil) + if err != nil { + fmt.Printf("could not check process\n%s\n", err.Error()) + return nil + } + + var out bool + cdc.MustUnmarshalJSON(res, &out) + return cliCtx.PrintOutput(out) + }, + } +} diff --git a/x/process/client/cli/tx.go b/x/process/client/cli/tx.go index d6e4faa7b..468417750 100644 --- a/x/process/client/cli/tx.go +++ b/x/process/client/cli/tx.go @@ -21,16 +21,16 @@ func GetTxCmd(cdc *codec.Codec) *cobra.Command { } processTxCmd.AddCommand(flags.PostCommands( - GetCmdCreateProcess(cdc), - GetCmdDeleteProcess(cdc), + GetCmdCreate(cdc), + GetCmdDelete(cdc), )...) return processTxCmd } -func GetCmdCreateProcess(cdc *codec.Codec) *cobra.Command { +func GetCmdCreate(cdc *codec.Codec) *cobra.Command { return &cobra.Command{ - Use: "createProcess [serviceHash] [key=val]...", + Use: "create [serviceHash] [key=val]...", Short: "Creates a new process", Args: cobra.MinimumNArgs(1), RunE: func(cmd *cobra.Command, args []string) error { @@ -40,9 +40,9 @@ func GetCmdCreateProcess(cdc *codec.Codec) *cobra.Command { } } -func GetCmdDeleteProcess(cdc *codec.Codec) *cobra.Command { +func GetCmdDelete(cdc *codec.Codec) *cobra.Command { return &cobra.Command{ - Use: "createProcess [serviceHash] [key=val]...", + Use: "create [serviceHash] [key=val]...", Short: "Creates a new process", Args: cobra.MinimumNArgs(1), RunE: func(cmd *cobra.Command, args []string) error { diff --git a/x/process/client/rest/query.go b/x/process/client/rest/query.go index cd08952cc..2a9f1f648 100644 --- a/x/process/client/rest/query.go +++ b/x/process/client/rest/query.go @@ -2,11 +2,13 @@ package rest import ( "fmt" + "io/ioutil" "net/http" "github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/types/rest" "github.com/gorilla/mux" + "github.com/mesg-foundation/engine/process" "github.com/mesg-foundation/engine/x/process/internal/types" ) @@ -15,15 +17,26 @@ func registerQueryRoutes(cliCtx context.CLIContext, r *mux.Router) { "/process/get/{hash}", queryGetHandlerFn(cliCtx), ).Methods(http.MethodGet) + r.HandleFunc( "/process/list", queryListHandlerFn(cliCtx), ).Methods(http.MethodGet) + r.HandleFunc( + "/process/hash", + queryHashHandlerFn(cliCtx), + ).Methods(http.MethodPost) + r.HandleFunc( "/process/parameters", queryParamsHandlerFn(cliCtx), - ).Methods("GET") + ).Methods(http.MethodGet) + + r.HandleFunc( + "/process/exist/{hash}", + queryExistHandlerFn(cliCtx), + ).Methods(http.MethodGet) } func queryGetHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { @@ -35,7 +48,7 @@ func queryGetHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { return } - route := fmt.Sprintf("custom/%s/%s/%s", types.QuerierRoute, types.QueryGetProcess, vars["hash"]) + route := fmt.Sprintf("custom/%s/%s/%s", types.QuerierRoute, types.QueryGet, vars["hash"]) res, height, err := cliCtx.QueryWithData(route, nil) if err != nil { @@ -55,7 +68,7 @@ func queryListHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { return } - route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryListProcesses) + route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryList) res, height, err := cliCtx.QueryWithData(route, nil) if err != nil { @@ -87,3 +100,61 @@ func queryParamsHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { rest.PostProcessResponse(w, cliCtx, res) } } + +// HashRequest is the request of the hash endpoint. +type HashRequest struct { + Name string `json:"name,omitempty"` + Nodes []*process.Process_Node `json:"nodes,omitempty"` + Edges []*process.Process_Edge `json:"edges,omitempty"` +} + +func queryHashHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) + if !ok { + return + } + + data, err := ioutil.ReadAll(r.Body) + if err != nil { + rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) + return + } + + var req HashRequest + if err := cliCtx.Codec.UnmarshalJSON(data, &req); err != nil { + rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) + return + } + + proc, err := process.New(req.Name, req.Nodes, req.Edges) + if err != nil { + rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) + return + } + + rest.PostProcessResponse(w, cliCtx, proc.Hash.String()) + } +} + +func queryExistHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + vars := mux.Vars(r) + + cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) + if !ok { + return + } + + route := fmt.Sprintf("custom/%s/%s/%s", types.QuerierRoute, types.QueryExist, vars["hash"]) + + res, height, err := cliCtx.QueryWithData(route, nil) + if err != nil { + rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) + return + } + + cliCtx = cliCtx.WithHeight(height) + rest.PostProcessResponse(w, cliCtx, res) + } +} diff --git a/x/process/handler.go b/x/process/handler.go index b33e64b1d..c3a528231 100644 --- a/x/process/handler.go +++ b/x/process/handler.go @@ -11,18 +11,18 @@ func NewHandler(k Keeper) sdk.Handler { return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { ctx = ctx.WithEventManager(sdk.NewEventManager()) switch msg := msg.(type) { - case MsgCreateProcess: - return handleMsgCreateProcess(ctx, k, &msg) - case MsgDeleteProcess: - return handleMsgDeleteProcess(ctx, k, &msg) + case MsgCreate: + return handleMsgCreate(ctx, k, &msg) + case MsgDelete: + return handleMsgDelete(ctx, k, &msg) default: return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized %s message type: %T", types.ModuleName, msg) } } } -// handleMsgCreateProcess creates a new process. -func handleMsgCreateProcess(ctx sdk.Context, k Keeper, msg *MsgCreateProcess) (*sdk.Result, error) { +// handleMsgCreate creates a new process. +func handleMsgCreate(ctx sdk.Context, k Keeper, msg *MsgCreate) (*sdk.Result, error) { p, err := k.Create(ctx, msg) if err != nil { return nil, err @@ -31,10 +31,8 @@ func handleMsgCreateProcess(ctx sdk.Context, k Keeper, msg *MsgCreateProcess) (* ctx.EventManager().EmitEvent( sdk.NewEvent( sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - sdk.NewAttribute(sdk.AttributeKeyAction, types.EventTypeCreateProcess), + sdk.NewAttribute(sdk.AttributeKeyModule, ModuleName), sdk.NewAttribute(sdk.AttributeKeySender, msg.Owner.String()), - sdk.NewAttribute(types.AttributeHash, p.Hash.String()), ), ) @@ -44,8 +42,8 @@ func handleMsgCreateProcess(ctx sdk.Context, k Keeper, msg *MsgCreateProcess) (* }, nil } -// handleMsgDeleteProcess deletes a process. -func handleMsgDeleteProcess(ctx sdk.Context, k Keeper, msg *MsgDeleteProcess) (*sdk.Result, error) { +// handleMsgDelete deletes a process. +func handleMsgDelete(ctx sdk.Context, k Keeper, msg *MsgDelete) (*sdk.Result, error) { if err := k.Delete(ctx, msg); err != nil { return nil, err } @@ -53,10 +51,8 @@ func handleMsgDeleteProcess(ctx sdk.Context, k Keeper, msg *MsgDeleteProcess) (* ctx.EventManager().EmitEvent( sdk.NewEvent( sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - sdk.NewAttribute(sdk.AttributeKeyAction, types.EventTypeDeleteProcess), + sdk.NewAttribute(sdk.AttributeKeyModule, ModuleName), sdk.NewAttribute(sdk.AttributeKeySender, msg.Owner.String()), - sdk.NewAttribute(types.AttributeHash, msg.Request.Hash.String()), ), ) diff --git a/x/process/internal/keeper/keeper.go b/x/process/internal/keeper/keeper.go index 16928f29c..1d17330df 100644 --- a/x/process/internal/keeper/keeper.go +++ b/x/process/internal/keeper/keeper.go @@ -43,9 +43,14 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { } // Create creates a new process. -func (k Keeper) Create(ctx sdk.Context, msg *types.MsgCreateProcess) (*processpb.Process, error) { +func (k Keeper) Create(ctx sdk.Context, msg *types.MsgCreate) (*processpb.Process, error) { store := ctx.KVStore(k.storeKey) - p := process.New(msg.Request.Name, msg.Request.Nodes, msg.Request.Edges) + + p, err := process.New(msg.Name, msg.Nodes, msg.Edges) + if err != nil { + return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, err.Error()) + } + if store.Has(p.Hash) { return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "process %q already exists", p.Hash) } @@ -85,15 +90,41 @@ func (k Keeper) Create(ctx sdk.Context, msg *types.MsgCreateProcess) (*processpb } store.Set(p.Hash, value) + + // emit event + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventType, + sdk.NewAttribute(sdk.AttributeKeyAction, types.AttributeActionCreated), + sdk.NewAttribute(types.AttributeKeyHash, p.Hash.String()), + sdk.NewAttribute(types.AttributeKeyAddress, p.Address.String()), + ), + ) + return p, nil } // Delete deletes a process. -func (k Keeper) Delete(ctx sdk.Context, msg *types.MsgDeleteProcess) error { - if err := k.ownershipKeeper.Delete(ctx, msg.Owner, msg.Request.Hash); err != nil { +func (k Keeper) Delete(ctx sdk.Context, msg *types.MsgDelete) error { + p, err := k.Get(ctx, msg.Hash) + if err != nil { return err } - ctx.KVStore(k.storeKey).Delete(msg.Request.Hash) + if err := k.ownershipKeeper.Delete(ctx, msg.Owner, msg.Hash); err != nil { + return err + } + ctx.KVStore(k.storeKey).Delete(msg.Hash) + + // emit event + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventType, + sdk.NewAttribute(sdk.AttributeKeyAction, types.AttributeActionDeleted), + sdk.NewAttribute(types.AttributeKeyHash, p.Hash.String()), + sdk.NewAttribute(types.AttributeKeyAddress, p.Address.String()), + ), + ) + return nil } @@ -111,6 +142,11 @@ func (k Keeper) Get(ctx sdk.Context, hash hash.Hash) (*processpb.Process, error) return p, nil } +// Exists returns true if a specific set of data exists in the database, false otherwise +func (k Keeper) Exists(ctx sdk.Context, hash hash.Hash) (bool, error) { + return ctx.KVStore(k.storeKey).Has(hash), nil +} + // List returns all processes. func (k Keeper) List(ctx sdk.Context) ([]*processpb.Process, error) { var ( diff --git a/x/process/internal/keeper/querier.go b/x/process/internal/keeper/querier.go index d910b35b9..6adaf5aca 100644 --- a/x/process/internal/keeper/querier.go +++ b/x/process/internal/keeper/querier.go @@ -12,17 +12,19 @@ import ( func NewQuerier(k Keeper) sdk.Querier { return func(ctx sdk.Context, path []string, req abci.RequestQuery) ([]byte, error) { switch path[0] { - case types.QueryGetProcess: - return getProcess(ctx, path[1:], k) - case types.QueryListProcesses: - return listProcess(ctx, k) + case types.QueryGet: + return get(ctx, path[1:], k) + case types.QueryList: + return list(ctx, k) + case types.QueryExist: + return exist(ctx, k, path[1:]) default: return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "unknown process query endpoint") } } } -func getProcess(ctx sdk.Context, path []string, k Keeper) ([]byte, error) { +func get(ctx sdk.Context, path []string, k Keeper) ([]byte, error) { if len(path) == 0 { return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "missing hash") } @@ -43,7 +45,7 @@ func getProcess(ctx sdk.Context, path []string, k Keeper) ([]byte, error) { return res, nil } -func listProcess(ctx sdk.Context, k Keeper) ([]byte, error) { +func list(ctx sdk.Context, k Keeper) ([]byte, error) { instances, err := k.List(ctx) if err != nil { return nil, err @@ -55,3 +57,24 @@ func listProcess(ctx sdk.Context, k Keeper) ([]byte, error) { } return res, nil } + +func exist(ctx sdk.Context, k Keeper, path []string) ([]byte, error) { + if len(path) == 0 { + return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "missing hash") + } + hash, err := hash.Decode(path[0]) + if err != nil { + return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error()) + } + + exists, err := k.Exists(ctx, hash) + if err != nil { + return nil, err + } + + res, err := types.ModuleCdc.MarshalJSON(exists) + if err != nil { + return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) + } + return res, nil +} diff --git a/x/process/internal/types/codec.go b/x/process/internal/types/codec.go index e2ba8cb35..b3d831847 100644 --- a/x/process/internal/types/codec.go +++ b/x/process/internal/types/codec.go @@ -3,13 +3,14 @@ package types import ( "github.com/cosmos/cosmos-sdk/codec" processpb "github.com/mesg-foundation/engine/process" + "github.com/mesg-foundation/engine/protobuf/types" ) // RegisterCodec registers concrete types on codec func RegisterCodec(cdc *codec.Codec) { processpb.RegisterCodec(cdc) - cdc.RegisterConcrete(MsgCreateProcess{}, "process/CreateProcess", nil) - cdc.RegisterConcrete(MsgDeleteProcess{}, "process/DeleteProcess", nil) + cdc.RegisterConcrete(MsgCreate{}, "process/create", nil) + cdc.RegisterConcrete(MsgDelete{}, "process/delete", nil) } // ModuleCdc defines the module codec @@ -19,5 +20,6 @@ func init() { ModuleCdc = codec.New() RegisterCodec(ModuleCdc) codec.RegisterCrypto(ModuleCdc) + types.RegisterCodec(ModuleCdc) ModuleCdc.Seal() } diff --git a/x/process/internal/types/events.go b/x/process/internal/types/events.go index 57e107415..7bf9d2784 100644 --- a/x/process/internal/types/events.go +++ b/x/process/internal/types/events.go @@ -1,11 +1,12 @@ package types -// module event types +// module event types and attributes const ( - EventTypeCreateProcess = "CreateProcess" - EventTypeDeleteProcess = "DeleteProcess" + EventType = "process" - AttributeHash = "hash" + AttributeKeyHash = "hash" + AttributeKeyAddress = "address" - AttributeValueCategory = ModuleName + AttributeActionCreated = "created" + AttributeActionDeleted = "deleted" ) diff --git a/x/process/internal/types/msg.go b/x/process/internal/types/msg.go index 735e3c8a6..37eecf7ca 100644 --- a/x/process/internal/types/msg.go +++ b/x/process/internal/types/msg.go @@ -5,100 +5,63 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/mesg-foundation/engine/ext/xvalidator" processpb "github.com/mesg-foundation/engine/process" - "github.com/mesg-foundation/engine/protobuf/api" ) -// MsgCreateProcess defines a state transition to create a process. -type MsgCreateProcess struct { - Owner sdk.AccAddress `json:"address" validate:"required,accaddress"` - Request *api.CreateProcessRequest `json:"request" validate:"required"` -} - -// NewMsgCreateProcess is a constructor function for MsgCreateProcess. -func NewMsgCreateProcess(owner sdk.AccAddress, request *api.CreateProcessRequest) *MsgCreateProcess { - return &MsgCreateProcess{ - Owner: owner, - Request: request, - } -} - // Route should return the name of the module route. -func (msg MsgCreateProcess) Route() string { +func (msg MsgCreate) Route() string { return RouterKey } // Type returns the action. -func (msg MsgCreateProcess) Type() string { - return "CreateProcess" +func (msg MsgCreate) Type() string { + return "create" } // ValidateBasic runs stateless checks on the message. -func (msg MsgCreateProcess) ValidateBasic() error { - if msg.Owner.Empty() { - return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "owner is missing") - } - if err := xvalidator.Validate.Struct(msg); err != nil { +func (msg MsgCreate) ValidateBasic() error { + if err := xvalidator.Struct(msg); err != nil { return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error()) } - p := processpb.New(msg.Request.Name, msg.Request.Nodes, msg.Request.Edges) - if err := p.Validate(); err != nil { + if _, err := processpb.New(msg.Name, msg.Nodes, msg.Edges); err != nil { return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error()) } - return nil } // GetSignBytes encodes the message for signing. -func (msg MsgCreateProcess) GetSignBytes() []byte { +func (msg MsgCreate) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(msg)) } // GetSigners defines whose signature is required. -func (msg MsgCreateProcess) GetSigners() []sdk.AccAddress { +func (msg MsgCreate) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{msg.Owner} } -// MsgDeleteProcess defines a state transition to delete a process. -type MsgDeleteProcess struct { - Owner sdk.AccAddress `json:"address" validate:"required,accaddress"` - Request *api.DeleteProcessRequest `json:"request" validate:"required"` -} - -// NewMsgDeleteProcess is a constructor function for MsgDeleteProcess. -func NewMsgDeleteProcess(owner sdk.AccAddress, request *api.DeleteProcessRequest) *MsgDeleteProcess { - return &MsgDeleteProcess{ - Owner: owner, - Request: request, - } -} - // Route should return the name of the module. -func (msg MsgDeleteProcess) Route() string { +func (msg MsgDelete) Route() string { return ModuleName } // Type returns the action. -func (msg MsgDeleteProcess) Type() string { - return "DeleteProcess" +func (msg MsgDelete) Type() string { + return "delete" } // ValidateBasic runs stateless checks on the message. -func (msg MsgDeleteProcess) ValidateBasic() error { - if msg.Owner.Empty() { - return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "owner is missing") - } - if err := xvalidator.Validate.Struct(msg); err != nil { +func (msg MsgDelete) ValidateBasic() error { + if err := xvalidator.Struct(msg); err != nil { return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error()) } return nil } // GetSignBytes encodes the message for signing. -func (msg MsgDeleteProcess) GetSignBytes() []byte { +func (msg MsgDelete) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(msg)) } // GetSigners defines whose signature is required. -func (msg MsgDeleteProcess) GetSigners() []sdk.AccAddress { +func (msg MsgDelete) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{msg.Owner} } diff --git a/x/process/internal/types/msg.pb.go b/x/process/internal/types/msg.pb.go new file mode 100644 index 000000000..0a636e802 --- /dev/null +++ b/x/process/internal/types/msg.pb.go @@ -0,0 +1,176 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: x/process/internal/types/msg.proto + +package types + +import ( + fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + github_com_mesg_foundation_engine_hash "github.com/mesg-foundation/engine/hash" + process "github.com/mesg-foundation/engine/process" + math "math" +) + +// 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 + +// The message to create a Process. +type MsgCreate struct { + // Process's name + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty" validate:"required,printascii"` + // List of nodes of the process. + Nodes []*process.Process_Node `protobuf:"bytes,2,rep,name=nodes,proto3" json:"nodes,omitempty" validate:"dive"` + // List of edges of the process. + Edges []*process.Process_Edge `protobuf:"bytes,3,rep,name=edges,proto3" json:"edges,omitempty" validate:"dive"` + // The process's owner. + Owner github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,4,opt,name=owner,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"owner,omitempty" validate:"required,accaddress"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *MsgCreate) Reset() { *m = MsgCreate{} } +func (m *MsgCreate) String() string { return proto.CompactTextString(m) } +func (*MsgCreate) ProtoMessage() {} +func (*MsgCreate) Descriptor() ([]byte, []int) { + return fileDescriptor_808972a653e2953a, []int{0} +} +func (m *MsgCreate) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_MsgCreate.Unmarshal(m, b) +} +func (m *MsgCreate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_MsgCreate.Marshal(b, m, deterministic) +} +func (m *MsgCreate) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreate.Merge(m, src) +} +func (m *MsgCreate) XXX_Size() int { + return xxx_messageInfo_MsgCreate.Size(m) +} +func (m *MsgCreate) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreate.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreate proto.InternalMessageInfo + +func (m *MsgCreate) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *MsgCreate) GetNodes() []*process.Process_Node { + if m != nil { + return m.Nodes + } + return nil +} + +func (m *MsgCreate) GetEdges() []*process.Process_Edge { + if m != nil { + return m.Edges + } + return nil +} + +func (m *MsgCreate) GetOwner() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.Owner + } + return nil +} + +// The message to delete a Process. +type MsgDelete struct { + // The process's hash to delete. + Hash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=hash,proto3,casttype=github.com/mesg-foundation/engine/hash.Hash" json:"hash,omitempty" validate:"required,hash"` + // The process's owner. + Owner github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,2,opt,name=owner,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"owner,omitempty" validate:"required,accaddress"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *MsgDelete) Reset() { *m = MsgDelete{} } +func (m *MsgDelete) String() string { return proto.CompactTextString(m) } +func (*MsgDelete) ProtoMessage() {} +func (*MsgDelete) Descriptor() ([]byte, []int) { + return fileDescriptor_808972a653e2953a, []int{1} +} +func (m *MsgDelete) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_MsgDelete.Unmarshal(m, b) +} +func (m *MsgDelete) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_MsgDelete.Marshal(b, m, deterministic) +} +func (m *MsgDelete) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDelete.Merge(m, src) +} +func (m *MsgDelete) XXX_Size() int { + return xxx_messageInfo_MsgDelete.Size(m) +} +func (m *MsgDelete) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDelete.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgDelete proto.InternalMessageInfo + +func (m *MsgDelete) GetHash() github_com_mesg_foundation_engine_hash.Hash { + if m != nil { + return m.Hash + } + return nil +} + +func (m *MsgDelete) GetOwner() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.Owner + } + return nil +} + +func init() { + proto.RegisterType((*MsgCreate)(nil), "mesg.process.types.MsgCreate") + proto.RegisterType((*MsgDelete)(nil), "mesg.process.types.MsgDelete") +} + +func init() { proto.RegisterFile("x/process/internal/types/msg.proto", fileDescriptor_808972a653e2953a) } + +var fileDescriptor_808972a653e2953a = []byte{ + // 374 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x52, 0x4f, 0x4b, 0xe3, 0x40, + 0x14, 0x27, 0xfd, 0xb3, 0xd0, 0x6c, 0x61, 0x21, 0x7b, 0x09, 0x65, 0xd9, 0x94, 0x39, 0x15, 0x76, + 0x9b, 0x81, 0x5d, 0xf0, 0x50, 0xbc, 0x34, 0x55, 0x10, 0x44, 0x91, 0x78, 0xf3, 0x22, 0xd3, 0x99, + 0xd7, 0xc9, 0x60, 0x33, 0x13, 0x67, 0x26, 0x55, 0xbf, 0x99, 0xdf, 0xc4, 0x5b, 0x3e, 0x44, 0x8f, + 0x9e, 0x24, 0x93, 0x6a, 0x3d, 0x18, 0x3c, 0x79, 0xca, 0xbc, 0xbc, 0xdf, 0x9f, 0xf7, 0x7b, 0x3c, + 0x1f, 0xdd, 0xe3, 0x42, 0x2b, 0x0a, 0xc6, 0x60, 0x21, 0x2d, 0x68, 0x49, 0xd6, 0xd8, 0x3e, 0x14, + 0x60, 0x70, 0x6e, 0x78, 0x5c, 0x68, 0x65, 0x55, 0x10, 0xe4, 0xd0, 0xbc, 0x6b, 0x58, 0xec, 0xba, + 0x23, 0xc4, 0x15, 0x57, 0xd8, 0xf5, 0x97, 0xe5, 0x0a, 0xd7, 0x95, 0x2b, 0xdc, 0xab, 0xe1, 0x8d, + 0x7e, 0xbd, 0xb5, 0x1b, 0xc5, 0x57, 0x05, 0xf7, 0x1b, 0x3d, 0x76, 0xfc, 0xc1, 0x99, 0xe1, 0x0b, + 0x0d, 0xc4, 0x42, 0x70, 0xe0, 0xf7, 0x24, 0xc9, 0x21, 0xf4, 0xc6, 0xde, 0x64, 0x90, 0xa0, 0x6d, + 0x15, 0xfd, 0xde, 0x90, 0xb5, 0x60, 0xc4, 0xc2, 0x0c, 0x69, 0xb8, 0x2d, 0x85, 0x06, 0xf6, 0xb7, + 0xd0, 0x42, 0x5a, 0x62, 0xa8, 0x10, 0x28, 0x75, 0xf8, 0x60, 0xe1, 0xf7, 0xa5, 0x62, 0x60, 0xc2, + 0xce, 0xb8, 0x3b, 0xf9, 0xfe, 0x2f, 0x8c, 0xdd, 0xac, 0xce, 0x2f, 0xbe, 0xd8, 0xf9, 0x9d, 0x2b, + 0x06, 0xc9, 0xcf, 0x6d, 0x15, 0xfd, 0xd8, 0x4b, 0x32, 0xb1, 0x01, 0x94, 0x36, 0xdc, 0x5a, 0x04, + 0x18, 0x07, 0x13, 0x76, 0xdb, 0x45, 0x8e, 0x19, 0x6f, 0x13, 0x71, 0xdc, 0x40, 0xf8, 0x7d, 0x75, + 0x27, 0x41, 0x87, 0xbd, 0xb1, 0x37, 0x19, 0x26, 0x97, 0x2d, 0x11, 0x08, 0xa5, 0x84, 0x31, 0x0d, + 0xc6, 0xa0, 0xe7, 0x2a, 0x9a, 0x72, 0x61, 0xb3, 0x72, 0x19, 0x53, 0x95, 0x63, 0xaa, 0x4c, 0xae, + 0xcc, 0xee, 0x33, 0x35, 0xec, 0xa6, 0x59, 0x5b, 0x3c, 0xa7, 0x74, 0xde, 0x30, 0xd2, 0xc6, 0x01, + 0x3d, 0x79, 0x6e, 0x75, 0x47, 0xb0, 0x06, 0x0b, 0xc1, 0xb5, 0xdf, 0xcb, 0x88, 0xc9, 0xdc, 0xea, + 0x86, 0xc9, 0xe9, 0xb6, 0x8a, 0xc2, 0x0f, 0x7c, 0x6b, 0x48, 0xed, 0xf8, 0xe7, 0x9d, 0x63, 0x1d, + 0x73, 0xba, 0x52, 0xa5, 0x64, 0xc4, 0x0a, 0x25, 0x31, 0x48, 0x2e, 0x24, 0xe0, 0x1a, 0x1a, 0x9f, + 0x10, 0x93, 0xa5, 0x4e, 0x78, 0x9f, 0xac, 0xf3, 0xd5, 0xc9, 0x92, 0xc3, 0xab, 0xd9, 0xe7, 0xf3, + 0xb5, 0x9d, 0xec, 0xf2, 0x9b, 0xbb, 0xac, 0xff, 0x2f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xb9, 0x5e, + 0x87, 0x3a, 0xd5, 0x02, 0x00, 0x00, +} diff --git a/x/process/internal/types/msg.proto b/x/process/internal/types/msg.proto new file mode 100644 index 000000000..54da16036 --- /dev/null +++ b/x/process/internal/types/msg.proto @@ -0,0 +1,46 @@ +syntax = "proto3"; + +import "gogo/protobuf/gogoproto/gogo.proto"; +import "protobuf/types/process.proto"; + +package mesg.process.types; +option go_package = "github.com/mesg-foundation/engine/x/process/internal/types"; + +// The message to create a Process. +message MsgCreate { + // Process's name + string name = 1 [ + (gogoproto.moretags) = 'validate:"required,printascii"' + ]; + + // List of nodes of the process. + repeated mesg.types.Process.Node nodes = 2 [ + (gogoproto.moretags) = 'validate:"dive"' + ]; + + // List of edges of the process. + repeated mesg.types.Process.Edge edges = 3 [ + (gogoproto.moretags) = 'validate:"dive"' + ]; + + // The process's owner. + bytes owner = 4 [ + (gogoproto.moretags) = 'validate:"required,accaddress"', + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" + ]; +} + +// The message to delete a Process. +message MsgDelete { + // The process's hash to delete. + bytes hash = 1 [ + (gogoproto.moretags) = 'validate:"required,hash"', + (gogoproto.casttype) = "github.com/mesg-foundation/engine/hash.Hash" + ]; + + // The process's owner. + bytes owner = 2 [ + (gogoproto.moretags) = 'validate:"required,accaddress"', + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" + ]; +} diff --git a/x/process/internal/types/querier.go b/x/process/internal/types/querier.go index c8c2a911b..b8981af87 100644 --- a/x/process/internal/types/querier.go +++ b/x/process/internal/types/querier.go @@ -2,6 +2,7 @@ package types // Query endpoints supported by the process querier const ( - QueryGetProcess = "get" - QueryListProcesses = "list" + QueryGet = "get" + QueryList = "list" + QueryExist = "exist" ) diff --git a/x/runner/alias.go b/x/runner/alias.go index 7f9a24901..c73abefed 100644 --- a/x/runner/alias.go +++ b/x/runner/alias.go @@ -25,11 +25,16 @@ var ( ModuleCdc = types.ModuleCdc - QueryGetRunner = types.QueryGetRunner - QueryListRunners = types.QueryListRunners - - NewMsgCreateRunner = types.NewMsgCreateRunner - NewMsgDeleteRunner = types.NewMsgDeleteRunner + QueryGet = types.QueryGet + QueryList = types.QueryList + QueryExist = types.QueryExist + + EventType = types.EventType + AttributeKeyHash = types.AttributeKeyHash + AttributeKeyAddress = types.AttributeKeyAddress + AttributeKeyInstance = types.AttributeKeyInstance + AttributeActionCreated = types.AttributeActionCreated + AttributeActionDeleted = types.AttributeActionDeleted ) // module types @@ -38,6 +43,6 @@ type ( GenesisState = types.GenesisState Params = types.Params - MsgCreateRunner = types.MsgCreateRunner - MsgDeleteRunner = types.MsgDeleteRunner + MsgCreate = types.MsgCreate + MsgDelete = types.MsgDelete ) diff --git a/x/runner/client/cli/query.go b/x/runner/client/cli/query.go index 55051811e..4f96d95a8 100644 --- a/x/runner/client/cli/query.go +++ b/x/runner/client/cli/query.go @@ -25,22 +25,23 @@ func GetQueryCmd(queryRoute string, cdc *codec.Codec) *cobra.Command { runnerQueryCmd.AddCommand( flags.GetCommands( - GetCmdGetRunner(queryRoute, cdc), - GetCmdListRunners(queryRoute, cdc), + GetCmdGet(queryRoute, cdc), + GetCmdList(queryRoute, cdc), + GetCmdExist(queryRoute, cdc), )..., ) return runnerQueryCmd } -func GetCmdGetRunner(queryRoute string, cdc *codec.Codec) *cobra.Command { +func GetCmdGet(queryRoute string, cdc *codec.Codec) *cobra.Command { return &cobra.Command{ Use: "get", Short: "get", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { cliCtx := context.NewCLIContext().WithCodec(cdc) - res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s/%s", queryRoute, types.QueryGetRunner, args[0]), nil) + res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s/%s", queryRoute, types.QueryGet, args[0]), nil) if err != nil { fmt.Printf("could not get runner\n%s\n", err.Error()) return nil @@ -53,13 +54,13 @@ func GetCmdGetRunner(queryRoute string, cdc *codec.Codec) *cobra.Command { } } -func GetCmdListRunners(queryRoute string, cdc *codec.Codec) *cobra.Command { +func GetCmdList(queryRoute string, cdc *codec.Codec) *cobra.Command { return &cobra.Command{ Use: "list", Short: "list", RunE: func(cmd *cobra.Command, args []string) error { cliCtx := context.NewCLIContext().WithCodec(cdc) - res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryListRunners), nil) + res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryList), nil) if err != nil { fmt.Printf("could not list runners\n%s\n", err.Error()) return nil @@ -71,3 +72,23 @@ func GetCmdListRunners(queryRoute string, cdc *codec.Codec) *cobra.Command { }, } } + +func GetCmdExist(queryRoute string, cdc *codec.Codec) *cobra.Command { + return &cobra.Command{ + Use: "exist [hash]", + Short: "exist", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + cliCtx := context.NewCLIContext().WithCodec(cdc) + res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s/%s", queryRoute, types.QueryExist, args[0]), nil) + if err != nil { + fmt.Printf("could not check runner\n%s\n", err.Error()) + return nil + } + + var out bool + cdc.MustUnmarshalJSON(res, &out) + return cliCtx.PrintOutput(out) + }, + } +} diff --git a/x/runner/client/cli/tx.go b/x/runner/client/cli/tx.go index 812bbd521..403e5e54b 100644 --- a/x/runner/client/cli/tx.go +++ b/x/runner/client/cli/tx.go @@ -21,16 +21,16 @@ func GetTxCmd(cdc *codec.Codec) *cobra.Command { } runnerTxCmd.AddCommand(flags.PostCommands( - GetCmdCreateRunner(cdc), - GetCmdDeleteRunner(cdc), + GetCmdCreate(cdc), + GetCmdDelete(cdc), )...) return runnerTxCmd } -func GetCmdCreateRunner(cdc *codec.Codec) *cobra.Command { +func GetCmdCreate(cdc *codec.Codec) *cobra.Command { return &cobra.Command{ - Use: "createRunner [serviceHash] [key=val]...", + Use: "create [runnerHash] [key=val]...", Short: "Creates a new runner", Args: cobra.MinimumNArgs(1), RunE: func(cmd *cobra.Command, args []string) error { @@ -40,9 +40,9 @@ func GetCmdCreateRunner(cdc *codec.Codec) *cobra.Command { } } -func GetCmdDeleteRunner(cdc *codec.Codec) *cobra.Command { +func GetCmdDelete(cdc *codec.Codec) *cobra.Command { return &cobra.Command{ - Use: "createRunner [serviceHash] [key=val]...", + Use: "delete [runnerHash] [key=val]...", Short: "Creates a new runner", Args: cobra.MinimumNArgs(1), RunE: func(cmd *cobra.Command, args []string) error { diff --git a/x/runner/client/rest/query.go b/x/runner/client/rest/query.go index f61664fbf..3f9c6e094 100644 --- a/x/runner/client/rest/query.go +++ b/x/runner/client/rest/query.go @@ -2,11 +2,15 @@ package rest import ( "fmt" + "io/ioutil" "net/http" "github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/types/rest" "github.com/gorilla/mux" + "github.com/mesg-foundation/engine/hash" + "github.com/mesg-foundation/engine/instance" + "github.com/mesg-foundation/engine/runner" "github.com/mesg-foundation/engine/x/runner/internal/types" ) @@ -15,15 +19,26 @@ func registerQueryRoutes(cliCtx context.CLIContext, r *mux.Router) { "/runner/get/{hash}", queryGetHandlerFn(cliCtx), ).Methods(http.MethodGet) + r.HandleFunc( "/runner/list", queryListHandlerFn(cliCtx), ).Methods(http.MethodGet) + r.HandleFunc( + "/runner/hash", + queryHashHandlerFn(cliCtx), + ).Methods(http.MethodPost) + r.HandleFunc( "/runner/parameters", queryParamsHandlerFn(cliCtx), - ).Methods("GET") + ).Methods(http.MethodGet) + + r.HandleFunc( + "/runner/exist/{hash}", + queryExistHandlerFn(cliCtx), + ).Methods(http.MethodGet) } func queryGetHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { @@ -35,7 +50,7 @@ func queryGetHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { return } - route := fmt.Sprintf("custom/%s/%s/%s", types.QuerierRoute, types.QueryGetRunner, vars["hash"]) + route := fmt.Sprintf("custom/%s/%s/%s", types.QuerierRoute, types.QueryGet, vars["hash"]) res, height, err := cliCtx.QueryWithData(route, nil) if err != nil { @@ -55,7 +70,7 @@ func queryListHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { return } - route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryListRunners) + route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryList) res, height, err := cliCtx.QueryWithData(route, nil) if err != nil { @@ -87,3 +102,81 @@ func queryParamsHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { rest.PostProcessResponse(w, cliCtx, res) } } + +// HashRequest is the request of the hash endpoint. +type HashRequest struct { + ServiceHash hash.Hash `json:"serviceHash"` + Env []string `json:"env"` + Address string `json:"address"` +} + +// HashResponse is the response of the hash endpoint. +type HashResponse struct { + RunnerHash hash.Hash `json:"runnerHash"` + InstanceHash hash.Hash `json:"instanceHash"` + EnvHash hash.Hash `json:"envHash"` +} + +func queryHashHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) + if !ok { + return + } + + data, err := ioutil.ReadAll(r.Body) + if err != nil { + rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) + return + } + + var req HashRequest + if err := cliCtx.Codec.UnmarshalJSON(data, &req); err != nil { + rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) + return + } + + envHash := hash.Dump(req.Env) + inst, err := instance.New(req.ServiceHash, envHash) + if err != nil { + rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) + return + } + + run, err := runner.New(req.Address, inst.Hash) + if err != nil { + rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) + return + } + + res := HashResponse{ + RunnerHash: run.Hash, + InstanceHash: inst.Hash, + EnvHash: envHash, + } + + rest.PostProcessResponse(w, cliCtx, res) + } +} + +func queryExistHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + vars := mux.Vars(r) + + cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) + if !ok { + return + } + + route := fmt.Sprintf("custom/%s/%s/%s", types.QuerierRoute, types.QueryExist, vars["hash"]) + + res, height, err := cliCtx.QueryWithData(route, nil) + if err != nil { + rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) + return + } + + cliCtx = cliCtx.WithHeight(height) + rest.PostProcessResponse(w, cliCtx, res) + } +} diff --git a/x/runner/handler.go b/x/runner/handler.go index 31f904c55..9bed8c2af 100644 --- a/x/runner/handler.go +++ b/x/runner/handler.go @@ -11,19 +11,19 @@ func NewHandler(k Keeper) sdk.Handler { return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { ctx = ctx.WithEventManager(sdk.NewEventManager()) switch msg := msg.(type) { - case MsgCreateRunner: - return handleMsgCreateRunner(ctx, k, &msg) - case MsgDeleteRunner: - return handleMsgDeleteRunner(ctx, k, &msg) + case MsgCreate: + return handleMsgCreate(ctx, k, &msg) + case MsgDelete: + return handleMsgDelete(ctx, k, &msg) default: return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized %s message type: %T", types.ModuleName, msg) } } } -// handleMsgCreateRunner creates a new runner. -func handleMsgCreateRunner(ctx sdk.Context, k Keeper, msg *MsgCreateRunner) (*sdk.Result, error) { - runner, err := k.Create(ctx, msg) +// handleMsgCreate creates a new runner. +func handleMsgCreate(ctx sdk.Context, k Keeper, msg *MsgCreate) (*sdk.Result, error) { + run, err := k.Create(ctx, msg) if err != nil { return nil, err } @@ -31,21 +31,19 @@ func handleMsgCreateRunner(ctx sdk.Context, k Keeper, msg *MsgCreateRunner) (*sd ctx.EventManager().EmitEvent( sdk.NewEvent( sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - sdk.NewAttribute(sdk.AttributeKeyAction, types.EventTypeCreateRunner), - sdk.NewAttribute(sdk.AttributeKeySender, msg.Address.String()), - sdk.NewAttribute(types.AttributeHash, runner.Hash.String()), + sdk.NewAttribute(sdk.AttributeKeyModule, ModuleName), + sdk.NewAttribute(sdk.AttributeKeySender, msg.Owner.String()), ), ) return &sdk.Result{ - Data: runner.Hash, + Data: run.Hash, Events: ctx.EventManager().Events(), }, nil } -// handleMsgDeleteRunner deletes a runner. -func handleMsgDeleteRunner(ctx sdk.Context, k Keeper, msg *MsgDeleteRunner) (*sdk.Result, error) { +// handleMsgDelete deletes a runner. +func handleMsgDelete(ctx sdk.Context, k Keeper, msg *MsgDelete) (*sdk.Result, error) { if err := k.Delete(ctx, msg); err != nil { return nil, err } @@ -53,10 +51,8 @@ func handleMsgDeleteRunner(ctx sdk.Context, k Keeper, msg *MsgDeleteRunner) (*sd ctx.EventManager().EmitEvent( sdk.NewEvent( sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - sdk.NewAttribute(sdk.AttributeKeyAction, types.EventTypeDeleteRunner), - sdk.NewAttribute(sdk.AttributeKeySender, msg.Address.String()), - sdk.NewAttribute(types.AttributeHash, msg.RunnerHash.String()), + sdk.NewAttribute(sdk.AttributeKeyModule, ModuleName), + sdk.NewAttribute(sdk.AttributeKeySender, msg.Owner.String()), ), ) diff --git a/x/runner/internal/keeper/keeper.go b/x/runner/internal/keeper/keeper.go index 91b95f66f..2283b7ffc 100644 --- a/x/runner/internal/keeper/keeper.go +++ b/x/runner/internal/keeper/keeper.go @@ -38,14 +38,18 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { } // Create creates a new runner. -func (k Keeper) Create(ctx sdk.Context, msg *types.MsgCreateRunner) (*runner.Runner, error) { +func (k Keeper) Create(ctx sdk.Context, msg *types.MsgCreate) (*runner.Runner, error) { store := ctx.KVStore(k.storeKey) inst, err := k.instanceKeeper.FetchOrCreate(ctx, msg.ServiceHash, msg.EnvHash) if err != nil { return nil, err } - r := runner.New(msg.Address.String(), inst.Hash) + r, err := runner.New(msg.Owner.String(), inst.Hash) + if err != nil { + return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, err.Error()) + } + if store.Has(r.Hash) { return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "runner %q already exists", r.Hash) } @@ -55,34 +59,57 @@ func (k Keeper) Create(ctx sdk.Context, msg *types.MsgCreateRunner) (*runner.Run return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) } - if _, err := k.ownershipKeeper.Set(ctx, msg.Address, r.Hash, ownershippb.Ownership_Runner, r.Address); err != nil { + if _, err := k.ownershipKeeper.Set(ctx, msg.Owner, r.Hash, ownershippb.Ownership_Runner, r.Address); err != nil { return nil, err } store.Set(r.Hash, value) + + // emit event + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventType, + sdk.NewAttribute(sdk.AttributeKeyAction, types.AttributeActionCreated), + sdk.NewAttribute(types.AttributeKeyHash, r.Hash.String()), + sdk.NewAttribute(types.AttributeKeyAddress, r.Address.String()), + sdk.NewAttribute(types.AttributeKeyInstance, r.InstanceHash.String()), + ), + ) + return r, nil } // Delete deletes a runner. -func (k Keeper) Delete(ctx sdk.Context, msg *types.MsgDeleteRunner) error { +func (k Keeper) Delete(ctx sdk.Context, msg *types.MsgDelete) error { store := ctx.KVStore(k.storeKey) - if !store.Has(msg.RunnerHash) { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "runner %q not found", msg.RunnerHash) + if !store.Has(msg.Hash) { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "runner %q not found", msg.Hash) } - value := store.Get(msg.RunnerHash) - var r *runner.Runner - if err := k.cdc.UnmarshalBinaryLengthPrefixed(value, &r); err != nil { - return sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) + r, err := k.Get(ctx, msg.Hash) + if err != nil { + return err } - if r.Owner != msg.Address.String() { + if r.Owner != msg.Owner.String() { return sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "only the runner owner can remove itself") } - if err := k.ownershipKeeper.Delete(ctx, msg.Address, r.Hash); err != nil { + if err := k.ownershipKeeper.Delete(ctx, msg.Owner, r.Hash); err != nil { return err } - store.Delete(msg.RunnerHash) + store.Delete(msg.Hash) + + // emit event + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventType, + sdk.NewAttribute(sdk.AttributeKeyAction, types.AttributeActionDeleted), + sdk.NewAttribute(types.AttributeKeyHash, r.Hash.String()), + sdk.NewAttribute(types.AttributeKeyAddress, r.Address.String()), + sdk.NewAttribute(types.AttributeKeyInstance, r.InstanceHash.String()), + ), + ) + return nil } @@ -100,6 +127,11 @@ func (k Keeper) Get(ctx sdk.Context, hash hash.Hash) (*runner.Runner, error) { return r, nil } +// Exists returns true if a specific set of data exists in the database, false otherwise +func (k Keeper) Exists(ctx sdk.Context, hash hash.Hash) (bool, error) { + return ctx.KVStore(k.storeKey).Has(hash), nil +} + // List returns all runners. func (k Keeper) List(ctx sdk.Context) ([]*runner.Runner, error) { var ( diff --git a/x/runner/internal/keeper/querier.go b/x/runner/internal/keeper/querier.go index 32d6a4a28..83a6dff1a 100644 --- a/x/runner/internal/keeper/querier.go +++ b/x/runner/internal/keeper/querier.go @@ -12,17 +12,19 @@ import ( func NewQuerier(k Keeper) sdk.Querier { return func(ctx sdk.Context, path []string, req abci.RequestQuery) ([]byte, error) { switch path[0] { - case types.QueryGetRunner: - return getRunner(ctx, path[1:], k) - case types.QueryListRunners: - return listRunner(ctx, k) + case types.QueryGet: + return get(ctx, path[1:], k) + case types.QueryList: + return list(ctx, k) + case types.QueryExist: + return exist(ctx, k, path[1:]) default: return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "unknown runner query endpoint") } } } -func getRunner(ctx sdk.Context, path []string, k Keeper) ([]byte, error) { +func get(ctx sdk.Context, path []string, k Keeper) ([]byte, error) { if len(path) == 0 { return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "missing hash") } @@ -43,7 +45,7 @@ func getRunner(ctx sdk.Context, path []string, k Keeper) ([]byte, error) { return res, nil } -func listRunner(ctx sdk.Context, k Keeper) ([]byte, error) { +func list(ctx sdk.Context, k Keeper) ([]byte, error) { instances, err := k.List(ctx) if err != nil { return nil, err @@ -55,3 +57,24 @@ func listRunner(ctx sdk.Context, k Keeper) ([]byte, error) { } return res, nil } + +func exist(ctx sdk.Context, k Keeper, path []string) ([]byte, error) { + if len(path) == 0 { + return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "missing hash") + } + hash, err := hash.Decode(path[0]) + if err != nil { + return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error()) + } + + exists, err := k.Exists(ctx, hash) + if err != nil { + return nil, err + } + + res, err := types.ModuleCdc.MarshalJSON(exists) + if err != nil { + return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) + } + return res, nil +} diff --git a/x/runner/internal/types/codec.go b/x/runner/internal/types/codec.go index ad4d320ff..5070e5836 100644 --- a/x/runner/internal/types/codec.go +++ b/x/runner/internal/types/codec.go @@ -6,8 +6,8 @@ import ( // RegisterCodec registers concrete types on codec func RegisterCodec(cdc *codec.Codec) { - cdc.RegisterConcrete(MsgCreateRunner{}, "runner/CreateRunner", nil) - cdc.RegisterConcrete(MsgDeleteRunner{}, "runner/DeleteRunner", nil) + cdc.RegisterConcrete(MsgCreate{}, "runner/create", nil) + cdc.RegisterConcrete(MsgDelete{}, "runner/delete", nil) } // ModuleCdc defines the module codec diff --git a/x/runner/internal/types/events.go b/x/runner/internal/types/events.go index 0795732ff..fb0638ab7 100644 --- a/x/runner/internal/types/events.go +++ b/x/runner/internal/types/events.go @@ -1,11 +1,13 @@ package types -// module event types +// module event types and attributes const ( - EventTypeCreateRunner = "CreateRunner" - EventTypeDeleteRunner = "DeleteRunner" + EventType = "runner" - AttributeHash = "hash" + AttributeKeyHash = "hash" + AttributeKeyAddress = "address" + AttributeKeyInstance = "instance" - AttributeValueCategory = ModuleName + AttributeActionCreated = "created" + AttributeActionDeleted = "deleted" ) diff --git a/x/runner/internal/types/msg.go b/x/runner/internal/types/msg.go index 9acc4c039..b46ffac7f 100644 --- a/x/runner/internal/types/msg.go +++ b/x/runner/internal/types/msg.go @@ -4,107 +4,60 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/mesg-foundation/engine/ext/xvalidator" - "github.com/mesg-foundation/engine/hash" ) -// MsgCreateRunner defines a state transition to create a runner. -type MsgCreateRunner struct { - // TODO: address should be renamed to owner - Address sdk.AccAddress `json:"address" validate:"required,accaddress"` - ServiceHash hash.Hash `json:"serviceHash" validate:"required,hash"` - EnvHash hash.Hash `json:"envHash" validate:"omitempty,hash"` -} - -// NewMsgCreateRunner is a constructor function for MsgCreateRunner. -func NewMsgCreateRunner(address sdk.AccAddress, serviceHash hash.Hash, envHash hash.Hash) *MsgCreateRunner { - return &MsgCreateRunner{ - Address: address, - ServiceHash: serviceHash, - EnvHash: envHash, - } -} - // Route should return the name of the module route. -func (msg MsgCreateRunner) Route() string { +func (msg MsgCreate) Route() string { return RouterKey } // Type returns the action. -func (msg MsgCreateRunner) Type() string { - return "CreateRunner" +func (msg MsgCreate) Type() string { + return "create" } // ValidateBasic runs stateless checks on the message. -func (msg MsgCreateRunner) ValidateBasic() error { - if err := xvalidator.Validate.Struct(msg); err != nil { +func (msg MsgCreate) ValidateBasic() error { + if err := xvalidator.Struct(msg); err != nil { return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error()) } - if msg.ServiceHash.IsZero() { - return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "serviceHash is missing") - } - if msg.EnvHash.IsZero() { - return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "envHash is missing") - } - if msg.Address.Empty() { - return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "address is missing") - } return nil } // GetSignBytes encodes the message for signing. -func (msg MsgCreateRunner) GetSignBytes() []byte { +func (msg MsgCreate) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(msg)) } // GetSigners defines whose signature is required. -func (msg MsgCreateRunner) GetSigners() []sdk.AccAddress { - return []sdk.AccAddress{msg.Address} -} - -// MsgDeleteRunner defines a state transition to delete a runner. -type MsgDeleteRunner struct { - Address sdk.AccAddress `json:"address" validate:"required,accaddress"` - RunnerHash hash.Hash `json:"runnerHash" validate:"required,hash"` -} - -// NewMsgDeleteRunner is a constructor function for MsgDeleteRunner. -func NewMsgDeleteRunner(address sdk.AccAddress, runnerHash hash.Hash) *MsgDeleteRunner { - return &MsgDeleteRunner{ - Address: address, - RunnerHash: runnerHash, - } +func (msg MsgCreate) GetSigners() []sdk.AccAddress { + return []sdk.AccAddress{msg.Owner} } // Route should return the name of the module. -func (msg MsgDeleteRunner) Route() string { +func (msg MsgDelete) Route() string { return ModuleName } // Type returns the action. -func (msg MsgDeleteRunner) Type() string { - return "DeleteRunner" +func (msg MsgDelete) Type() string { + return "delete" } // ValidateBasic runs stateless checks on the message. -func (msg MsgDeleteRunner) ValidateBasic() error { - if err := xvalidator.Validate.Struct(msg); err != nil { +func (msg MsgDelete) ValidateBasic() error { + if err := xvalidator.Struct(msg); err != nil { return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error()) } - if msg.RunnerHash.IsZero() { - return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "runnerHash is missing") - } - if msg.Address.Empty() { - return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "address is missing") - } return nil } // GetSignBytes encodes the message for signing. -func (msg MsgDeleteRunner) GetSignBytes() []byte { +func (msg MsgDelete) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(msg)) } // GetSigners defines whose signature is required. -func (msg MsgDeleteRunner) GetSigners() []sdk.AccAddress { - return []sdk.AccAddress{msg.Address} +func (msg MsgDelete) GetSigners() []sdk.AccAddress { + return []sdk.AccAddress{msg.Owner} } diff --git a/x/runner/internal/types/msg.pb.go b/x/runner/internal/types/msg.pb.go new file mode 100644 index 000000000..96d68d62b --- /dev/null +++ b/x/runner/internal/types/msg.pb.go @@ -0,0 +1,162 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: x/runner/internal/types/msg.proto + +package types + +import ( + fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + github_com_mesg_foundation_engine_hash "github.com/mesg-foundation/engine/hash" + math "math" +) + +// 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 + +// The message to create a Runner. +type MsgCreate struct { + // The Runner's owner. + Owner github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,opt,name=owner,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"owner,omitempty" validate:"required,accaddress"` + // Service's hash to start the runner with. + ServiceHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,2,opt,name=serviceHash,proto3,casttype=github.com/mesg-foundation/engine/hash.Hash" json:"serviceHash,omitempty" validate:"required,hash"` + // Hash of the customized environmental variables (not the ones in the service configuration). + EnvHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,3,opt,name=envHash,proto3,casttype=github.com/mesg-foundation/engine/hash.Hash" json:"envHash,omitempty" validate:"omitempty,hash"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *MsgCreate) Reset() { *m = MsgCreate{} } +func (m *MsgCreate) String() string { return proto.CompactTextString(m) } +func (*MsgCreate) ProtoMessage() {} +func (*MsgCreate) Descriptor() ([]byte, []int) { + return fileDescriptor_0041db5ef7393ba5, []int{0} +} +func (m *MsgCreate) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_MsgCreate.Unmarshal(m, b) +} +func (m *MsgCreate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_MsgCreate.Marshal(b, m, deterministic) +} +func (m *MsgCreate) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreate.Merge(m, src) +} +func (m *MsgCreate) XXX_Size() int { + return xxx_messageInfo_MsgCreate.Size(m) +} +func (m *MsgCreate) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreate.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreate proto.InternalMessageInfo + +func (m *MsgCreate) GetOwner() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.Owner + } + return nil +} + +func (m *MsgCreate) GetServiceHash() github_com_mesg_foundation_engine_hash.Hash { + if m != nil { + return m.ServiceHash + } + return nil +} + +func (m *MsgCreate) GetEnvHash() github_com_mesg_foundation_engine_hash.Hash { + if m != nil { + return m.EnvHash + } + return nil +} + +// The message to delete a Runner. +type MsgDelete struct { + // The Runner's owner. + Owner github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,opt,name=owner,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"owner,omitempty" validate:"required,accaddress"` + // Runner's hash + Hash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,2,opt,name=hash,proto3,casttype=github.com/mesg-foundation/engine/hash.Hash" json:"hash,omitempty" validate:"required,hash"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *MsgDelete) Reset() { *m = MsgDelete{} } +func (m *MsgDelete) String() string { return proto.CompactTextString(m) } +func (*MsgDelete) ProtoMessage() {} +func (*MsgDelete) Descriptor() ([]byte, []int) { + return fileDescriptor_0041db5ef7393ba5, []int{1} +} +func (m *MsgDelete) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_MsgDelete.Unmarshal(m, b) +} +func (m *MsgDelete) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_MsgDelete.Marshal(b, m, deterministic) +} +func (m *MsgDelete) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDelete.Merge(m, src) +} +func (m *MsgDelete) XXX_Size() int { + return xxx_messageInfo_MsgDelete.Size(m) +} +func (m *MsgDelete) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDelete.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgDelete proto.InternalMessageInfo + +func (m *MsgDelete) GetOwner() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.Owner + } + return nil +} + +func (m *MsgDelete) GetHash() github_com_mesg_foundation_engine_hash.Hash { + if m != nil { + return m.Hash + } + return nil +} + +func init() { + proto.RegisterType((*MsgCreate)(nil), "mesg.runner.types.MsgCreate") + proto.RegisterType((*MsgDelete)(nil), "mesg.runner.types.MsgDelete") +} + +func init() { proto.RegisterFile("x/runner/internal/types/msg.proto", fileDescriptor_0041db5ef7393ba5) } + +var fileDescriptor_0041db5ef7393ba5 = []byte{ + // 317 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x92, 0x31, 0x4f, 0xfb, 0x30, + 0x10, 0xc5, 0xd5, 0xfe, 0xff, 0x80, 0x30, 0x2c, 0x64, 0x2a, 0x0c, 0x04, 0x32, 0x21, 0x41, 0xed, + 0x81, 0x09, 0x98, 0x5a, 0x18, 0x90, 0x80, 0xa5, 0x6c, 0x2c, 0xc8, 0xb5, 0xaf, 0x8e, 0x45, 0x6d, + 0x17, 0x9f, 0x13, 0xe8, 0x87, 0x64, 0x66, 0xcb, 0x87, 0xc8, 0xc8, 0x84, 0xe2, 0x80, 0xe8, 0x00, + 0x42, 0x42, 0x82, 0xc9, 0x3e, 0xdd, 0xbd, 0xf7, 0xb3, 0x9f, 0x8e, 0xec, 0x3e, 0x32, 0x5f, 0x58, + 0x0b, 0x9e, 0x69, 0x1b, 0xc0, 0x5b, 0x3e, 0x65, 0x61, 0x3e, 0x03, 0x64, 0x06, 0x15, 0x9d, 0x79, + 0x17, 0x5c, 0xb2, 0x61, 0x00, 0x15, 0x6d, 0xa7, 0x68, 0x6c, 0x6e, 0x65, 0xca, 0x29, 0xc7, 0x62, + 0x7b, 0x5c, 0x4c, 0x58, 0x53, 0xc5, 0x22, 0xde, 0x5a, 0x59, 0xf6, 0xd4, 0x25, 0xab, 0x57, 0xa8, + 0x4e, 0x3d, 0xf0, 0x00, 0x89, 0x26, 0x4b, 0xee, 0xc1, 0x82, 0xef, 0x75, 0x76, 0x3a, 0x7b, 0xeb, + 0xc3, 0xeb, 0xba, 0x4a, 0xb7, 0x4b, 0x3e, 0xd5, 0x92, 0x07, 0x38, 0xce, 0x3c, 0xdc, 0x17, 0xda, + 0x83, 0x3c, 0xe0, 0x42, 0x70, 0x29, 0x3d, 0x20, 0x66, 0x2f, 0x55, 0xda, 0x57, 0x3a, 0xe4, 0xc5, + 0x98, 0x0a, 0x67, 0x98, 0x70, 0x68, 0x1c, 0xbe, 0x1d, 0x7d, 0x94, 0x77, 0xed, 0x3b, 0xe9, 0x40, + 0x88, 0x41, 0xab, 0x18, 0xb5, 0x84, 0xc4, 0x90, 0x35, 0x04, 0x5f, 0x6a, 0x01, 0xe7, 0x1c, 0xf3, + 0x5e, 0x37, 0x02, 0x2f, 0xea, 0x2a, 0xed, 0x7d, 0x02, 0xcc, 0x39, 0xe6, 0x0d, 0x6a, 0x7f, 0x01, + 0xd5, 0xfc, 0xb7, 0x3f, 0x71, 0x85, 0x95, 0x3c, 0x68, 0x67, 0x19, 0x58, 0xa5, 0x2d, 0xb0, 0x66, + 0x94, 0x36, 0x96, 0xa3, 0x45, 0xff, 0x64, 0x42, 0x56, 0xc0, 0x96, 0x11, 0xf5, 0x2f, 0xa2, 0x2e, + 0xeb, 0x2a, 0xdd, 0xfc, 0x40, 0x39, 0xa3, 0x03, 0x98, 0x59, 0x98, 0xff, 0x8c, 0xf5, 0x6e, 0x9e, + 0x3d, 0x77, 0x62, 0x9e, 0x67, 0x30, 0x85, 0xbf, 0xcd, 0xf3, 0x96, 0xfc, 0xcf, 0x7f, 0x29, 0xc8, + 0x68, 0x3c, 0x3c, 0xb9, 0x39, 0xfa, 0x5e, 0xf4, 0xc5, 0x9e, 0x8e, 0x97, 0xe3, 0xb6, 0x1d, 0xbe, + 0x06, 0x00, 0x00, 0xff, 0xff, 0x80, 0xc0, 0x64, 0x2b, 0xc9, 0x02, 0x00, 0x00, +} diff --git a/x/runner/internal/types/msg.proto b/x/runner/internal/types/msg.proto new file mode 100644 index 000000000..a9cf1d4d9 --- /dev/null +++ b/x/runner/internal/types/msg.proto @@ -0,0 +1,43 @@ +syntax = "proto3"; + +import "gogo/protobuf/gogoproto/gogo.proto"; + +package mesg.runner.types; +option go_package = "github.com/mesg-foundation/engine/x/runner/internal/types"; + +// The message to create a Runner. +message MsgCreate { + // The Runner's owner. + bytes owner = 1 [ + (gogoproto.moretags) = 'validate:"required,accaddress"', + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" + ]; + + // Service's hash to start the runner with. + bytes serviceHash = 2 [ + (gogoproto.moretags) = 'validate:"required,hash"', + (gogoproto.casttype) = "github.com/mesg-foundation/engine/hash.Hash" + ]; + + // Hash of the customized environmental variables (not the ones in the service configuration). + bytes envHash = 3 [ + (gogoproto.moretags) = 'validate:"omitempty,hash"', + (gogoproto.casttype) = "github.com/mesg-foundation/engine/hash.Hash" + ]; + +} + +// The message to delete a Runner. +message MsgDelete { + // The Runner's owner. + bytes owner = 1 [ + (gogoproto.moretags) = 'validate:"required,accaddress"', + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" + ]; + + // Runner's hash + bytes hash = 2 [ + (gogoproto.moretags) = 'validate:"required,hash"', + (gogoproto.casttype) = "github.com/mesg-foundation/engine/hash.Hash" + ]; +} diff --git a/x/runner/internal/types/querier.go b/x/runner/internal/types/querier.go index 687e9326c..2d24c7032 100644 --- a/x/runner/internal/types/querier.go +++ b/x/runner/internal/types/querier.go @@ -2,6 +2,7 @@ package types // Query endpoints supported by the runner querier const ( - QueryGetRunner = "get" - QueryListRunners = "list" + QueryGet = "get" + QueryList = "list" + QueryExist = "exist" ) diff --git a/x/service/alias.go b/x/service/alias.go index 24f54257f..7e51e6780 100644 --- a/x/service/alias.go +++ b/x/service/alias.go @@ -25,12 +25,14 @@ var ( ModuleCdc = types.ModuleCdc - QueryGetService = types.QueryGetService - QueryListService = types.QueryListService - QueryHashService = types.QueryHashService - QueryExistService = types.QueryExistService - - NewMsgCreateService = types.NewMsgCreateService + QueryGet = types.QueryGet + QueryList = types.QueryList + QueryExist = types.QueryExist + + EventType = types.EventType + AttributeKeyHash = types.AttributeKeyHash + AttributeKeyAddress = types.AttributeKeyAddress + AttributeActionCreated = types.AttributeActionCreated ) // module types @@ -39,5 +41,5 @@ type ( GenesisState = types.GenesisState Params = types.Params - MsgCreateService = types.MsgCreateService + MsgCreate = types.MsgCreate ) diff --git a/x/service/client/cli/query.go b/x/service/client/cli/query.go index bea3e9ac3..1fb5b95d2 100644 --- a/x/service/client/cli/query.go +++ b/x/service/client/cli/query.go @@ -7,7 +7,6 @@ import ( "github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/codec" - "github.com/mesg-foundation/engine/hash" "github.com/mesg-foundation/engine/service" "github.com/mesg-foundation/engine/x/service/internal/types" "github.com/spf13/cobra" @@ -26,24 +25,23 @@ func GetQueryCmd(queryRoute string, cdc *codec.Codec) *cobra.Command { serviceQueryCmd.AddCommand( flags.GetCommands( - GetCmdGetService(queryRoute, cdc), - GetCmdListService(queryRoute, cdc), - GetCmdHashService(queryRoute, cdc), - GetCmdExistService(queryRoute, cdc), + GetCmdGet(queryRoute, cdc), + GetCmdList(queryRoute, cdc), + GetCmdExist(queryRoute, cdc), )..., ) return serviceQueryCmd } -func GetCmdGetService(queryRoute string, cdc *codec.Codec) *cobra.Command { +func GetCmdGet(queryRoute string, cdc *codec.Codec) *cobra.Command { return &cobra.Command{ Use: "get [hash]", Short: "get", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { cliCtx := context.NewCLIContext().WithCodec(cdc) - res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s/%s", queryRoute, types.QueryGetService, args[0]), nil) + res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s/%s", queryRoute, types.QueryGet, args[0]), nil) if err != nil { fmt.Printf("could not get service\n%s\n", err.Error()) return nil @@ -56,13 +54,13 @@ func GetCmdGetService(queryRoute string, cdc *codec.Codec) *cobra.Command { } } -func GetCmdListService(queryRoute string, cdc *codec.Codec) *cobra.Command { +func GetCmdList(queryRoute string, cdc *codec.Codec) *cobra.Command { return &cobra.Command{ Use: "list", Short: "list", RunE: func(cmd *cobra.Command, args []string) error { cliCtx := context.NewCLIContext().WithCodec(cdc) - res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryListService), nil) + res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryList), nil) if err != nil { fmt.Printf("could not list services\n%s\n", err.Error()) return nil @@ -75,34 +73,14 @@ func GetCmdListService(queryRoute string, cdc *codec.Codec) *cobra.Command { } } -func GetCmdHashService(queryRoute string, cdc *codec.Codec) *cobra.Command { - return &cobra.Command{ - Use: "hash [definition]", - Short: "hash", - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - cliCtx := context.NewCLIContext().WithCodec(cdc) - res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryHashService), []byte(args[0])) - if err != nil { - fmt.Printf("could not check service\n%s\n", err.Error()) - return nil - } - - var out hash.Hash - cdc.MustUnmarshalJSON(res, &out) - return cliCtx.PrintOutput(out) - }, - } -} - -func GetCmdExistService(queryRoute string, cdc *codec.Codec) *cobra.Command { +func GetCmdExist(queryRoute string, cdc *codec.Codec) *cobra.Command { return &cobra.Command{ Use: "exist [hash]", Short: "exist", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { cliCtx := context.NewCLIContext().WithCodec(cdc) - res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s/%s", queryRoute, types.QueryExistService, args[0]), nil) + res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s/%s", queryRoute, types.QueryExist, args[0]), nil) if err != nil { fmt.Printf("could not check service\n%s\n", err.Error()) return nil diff --git a/x/service/client/rest/query.go b/x/service/client/rest/query.go index 739ec7075..9e409abea 100644 --- a/x/service/client/rest/query.go +++ b/x/service/client/rest/query.go @@ -9,6 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/types/rest" + "github.com/mesg-foundation/engine/service" "github.com/mesg-foundation/engine/x/service/internal/types" ) @@ -17,14 +18,17 @@ func registerQueryRoutes(cliCtx context.CLIContext, r *mux.Router) { "/service/get/{hash}", queryGetHandlerFn(cliCtx), ).Methods(http.MethodGet) + r.HandleFunc( "/service/list", queryListHandlerFn(cliCtx), ).Methods(http.MethodGet) + r.HandleFunc( "/service/hash", queryHashHandlerFn(cliCtx), ).Methods(http.MethodPost) + r.HandleFunc( "/service/exist/{hash}", queryExistHandlerFn(cliCtx), @@ -40,7 +44,7 @@ func queryGetHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { return } - route := fmt.Sprintf("custom/%s/%s/%s", types.QuerierRoute, types.QueryGetService, vars["hash"]) + route := fmt.Sprintf("custom/%s/%s/%s", types.QuerierRoute, types.QueryGet, vars["hash"]) res, height, err := cliCtx.QueryWithData(route, nil) if err != nil { @@ -60,7 +64,7 @@ func queryListHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { return } - route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryListService) + route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryList) res, height, err := cliCtx.QueryWithData(route, nil) if err != nil { @@ -73,6 +77,19 @@ func queryListHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { } } +// HashRequest is the request of the hash endpoint. +type HashRequest struct { + Sid string `json:"sid,omitempty"` + Name string `json:"name,omitempty"` + Description string `json:"description,omitempty"` + Configuration service.Service_Configuration `json:"configuration"` + Tasks []*service.Service_Task `json:"tasks,omitempty"` + Events []*service.Service_Event `json:"events,omitempty"` + Dependencies []*service.Service_Dependency `json:"dependencies,omitempty"` + Repository string `json:"repository,omitempty"` + Source string `json:"source,omitempty"` +} + func queryHashHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) @@ -86,16 +103,29 @@ func queryHashHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { return } - route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryHashService) + var req HashRequest + if err := cliCtx.Codec.UnmarshalJSON(data, &req); err != nil { + rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) + return + } - res, height, err := cliCtx.QueryWithData(route, data) + srv, err := service.New( + req.Sid, + req.Name, + req.Description, + req.Configuration, + req.Tasks, + req.Events, + req.Dependencies, + req.Repository, + req.Source, + ) if err != nil { - rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) + rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) return } - cliCtx = cliCtx.WithHeight(height) - rest.PostProcessResponse(w, cliCtx, res) + rest.PostProcessResponse(w, cliCtx, srv.Hash.String()) } } @@ -108,7 +138,7 @@ func queryExistHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { return } - route := fmt.Sprintf("custom/%s/%s/%s", types.QuerierRoute, types.QueryExistService, vars["hash"]) + route := fmt.Sprintf("custom/%s/%s/%s", types.QuerierRoute, types.QueryExist, vars["hash"]) res, height, err := cliCtx.QueryWithData(route, nil) if err != nil { diff --git a/x/service/handler.go b/x/service/handler.go index d6cc38b68..11b4700cb 100644 --- a/x/service/handler.go +++ b/x/service/handler.go @@ -11,16 +11,16 @@ func NewHandler(k Keeper) sdk.Handler { return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { ctx = ctx.WithEventManager(sdk.NewEventManager()) switch msg := msg.(type) { - case MsgCreateService: - return handleMsgCreateService(ctx, k, &msg) + case MsgCreate: + return handleMsgCreate(ctx, k, &msg) default: return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized %s message type: %T", types.ModuleName, msg) } } } -// handleMsgCreateService creates a new process. -func handleMsgCreateService(ctx sdk.Context, k Keeper, msg *MsgCreateService) (*sdk.Result, error) { +// handleMsgCreate creates a new process. +func handleMsgCreate(ctx sdk.Context, k Keeper, msg *MsgCreate) (*sdk.Result, error) { s, err := k.Create(ctx, msg) if err != nil { return nil, err @@ -29,10 +29,8 @@ func handleMsgCreateService(ctx sdk.Context, k Keeper, msg *MsgCreateService) (* ctx.EventManager().EmitEvent( sdk.NewEvent( sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - sdk.NewAttribute(sdk.AttributeKeyAction, types.EventTypeCreateService), + sdk.NewAttribute(sdk.AttributeKeyModule, ModuleName), sdk.NewAttribute(sdk.AttributeKeySender, msg.Owner.String()), - sdk.NewAttribute(types.AttributeHash, s.Hash.String()), ), ) diff --git a/x/service/internal/keeper/keeper.go b/x/service/internal/keeper/keeper.go index d90c1759a..2ecdf2e6f 100644 --- a/x/service/internal/keeper/keeper.go +++ b/x/service/internal/keeper/keeper.go @@ -8,11 +8,8 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/mesg-foundation/engine/hash" ownershippb "github.com/mesg-foundation/engine/ownership" - "github.com/mesg-foundation/engine/protobuf/api" servicepb "github.com/mesg-foundation/engine/service" - "github.com/mesg-foundation/engine/service/validator" "github.com/mesg-foundation/engine/x/service/internal/types" - "github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/libs/log" ) @@ -39,26 +36,29 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { } // Create creates a new service. -func (k Keeper) Create(ctx sdk.Context, msg *types.MsgCreateService) (*servicepb.Service, error) { +func (k Keeper) Create(ctx sdk.Context, msg *types.MsgCreate) (*servicepb.Service, error) { store := ctx.KVStore(k.storeKey) // create service - srv := initializeService(msg.Request) + srv, err := servicepb.New( + msg.Sid, + msg.Name, + msg.Description, + msg.Configuration, + msg.Tasks, + msg.Events, + msg.Dependencies, + msg.Repository, + msg.Source, + ) + if err != nil { + return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, err.Error()) + } // check if service already exists. if store.Has(srv.Hash) { return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "service %q already exists", srv.Hash) } - // TODO: the following test should be moved in New function - if srv.Sid == "" { - // make sure that sid doesn't have the same length with id. - srv.Sid = "_" + srv.Hash.String() - } - - if err := validator.ValidateService(srv); err != nil { - return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, err.Error()) - } - if _, err := k.ownershipKeeper.Set(ctx, msg.Owner, srv.Hash, ownershippb.Ownership_Service, srv.Address); err != nil { return nil, err } @@ -68,6 +68,17 @@ func (k Keeper) Create(ctx sdk.Context, msg *types.MsgCreateService) (*servicepb return nil, sdkerrors.Wrapf(sdkerrors.ErrJSONMarshal, err.Error()) } store.Set(srv.Hash, value) + + // emit event + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventType, + sdk.NewAttribute(sdk.AttributeKeyAction, types.AttributeActionCreated), + sdk.NewAttribute(types.AttributeKeyHash, srv.Hash.String()), + sdk.NewAttribute(types.AttributeKeyAddress, srv.Address.String()), + ), + ) + return srv, nil } @@ -89,11 +100,6 @@ func (k Keeper) Exists(ctx sdk.Context, hash hash.Hash) (bool, error) { return ctx.KVStore(k.storeKey).Has(hash), nil } -// Hash returns the hash of a service request. -func (k Keeper) Hash(_ sdk.Context, serviceRequest *api.CreateServiceRequest) hash.Hash { - return initializeService(serviceRequest).Hash -} - // List returns all services. func (k Keeper) List(ctx sdk.Context) ([]*servicepb.Service, error) { var ( @@ -111,23 +117,3 @@ func (k Keeper) List(ctx sdk.Context) ([]*servicepb.Service, error) { iter.Close() return services, nil } - -func initializeService(req *api.CreateServiceRequest) *servicepb.Service { - // create service - srv := &servicepb.Service{ - Sid: req.Sid, - Name: req.Name, - Description: req.Description, - Configuration: req.Configuration, - Tasks: req.Tasks, - Events: req.Events, - Dependencies: req.Dependencies, - Repository: req.Repository, - Source: req.Source, - } - - // calculate and apply hash to service. - srv.Hash = hash.Dump(srv) - srv.Address = sdk.AccAddress(crypto.AddressHash(srv.Hash)) - return srv -} diff --git a/x/service/internal/keeper/querier.go b/x/service/internal/keeper/querier.go index 1f943d1ab..42e67fe53 100644 --- a/x/service/internal/keeper/querier.go +++ b/x/service/internal/keeper/querier.go @@ -4,7 +4,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/mesg-foundation/engine/hash" - "github.com/mesg-foundation/engine/protobuf/api" "github.com/mesg-foundation/engine/x/service/internal/types" abci "github.com/tendermint/tendermint/abci/types" ) @@ -13,21 +12,19 @@ import ( func NewQuerier(k Keeper) sdk.Querier { return func(ctx sdk.Context, path []string, req abci.RequestQuery) ([]byte, error) { switch path[0] { - case types.QueryGetService: - return getService(ctx, k, path[1:]) - case types.QueryListService: - return listService(ctx, k) - case types.QueryHashService: - return hashService(ctx, k, req) - case types.QueryExistService: - return existService(ctx, k, path[1:]) + case types.QueryGet: + return get(ctx, k, path[1:]) + case types.QueryList: + return list(ctx, k) + case types.QueryExist: + return exist(ctx, k, path[1:]) default: return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "unknown service query endpoint") } } } -func getService(ctx sdk.Context, k Keeper, path []string) ([]byte, error) { +func get(ctx sdk.Context, k Keeper, path []string) ([]byte, error) { if len(path) == 0 { return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "missing hash") } @@ -48,22 +45,7 @@ func getService(ctx sdk.Context, k Keeper, path []string) ([]byte, error) { return res, nil } -func hashService(ctx sdk.Context, k Keeper, req abci.RequestQuery) ([]byte, error) { - var createServiceRequest api.CreateServiceRequest - if err := k.cdc.UnmarshalJSON(req.Data, &createServiceRequest); err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - hash := k.Hash(ctx, &createServiceRequest) - - res, err := types.ModuleCdc.MarshalJSON(hash) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - return res, nil -} - -func listService(ctx sdk.Context, k Keeper) ([]byte, error) { +func list(ctx sdk.Context, k Keeper) ([]byte, error) { srvs, err := k.List(ctx) if err != nil { return nil, err @@ -76,7 +58,7 @@ func listService(ctx sdk.Context, k Keeper) ([]byte, error) { return res, nil } -func existService(ctx sdk.Context, k Keeper, path []string) ([]byte, error) { +func exist(ctx sdk.Context, k Keeper, path []string) ([]byte, error) { if len(path) == 0 { return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "missing hash") } @@ -85,12 +67,12 @@ func existService(ctx sdk.Context, k Keeper, path []string) ([]byte, error) { return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error()) } - srv, err := k.Exists(ctx, hash) + exists, err := k.Exists(ctx, hash) if err != nil { return nil, err } - res, err := types.ModuleCdc.MarshalJSON(srv) + res, err := types.ModuleCdc.MarshalJSON(exists) if err != nil { return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) } diff --git a/x/service/internal/types/codec.go b/x/service/internal/types/codec.go index f660358cb..6a2791224 100644 --- a/x/service/internal/types/codec.go +++ b/x/service/internal/types/codec.go @@ -6,7 +6,7 @@ import ( // RegisterCodec registers concrete types on codec func RegisterCodec(cdc *codec.Codec) { - cdc.RegisterConcrete(MsgCreateService{}, "service/CreateService", nil) + cdc.RegisterConcrete(MsgCreate{}, "service/create", nil) } // ModuleCdc defines the module codec diff --git a/x/service/internal/types/events.go b/x/service/internal/types/events.go index 49046f01c..ff8599f25 100644 --- a/x/service/internal/types/events.go +++ b/x/service/internal/types/events.go @@ -1,10 +1,11 @@ package types -// service module event types +// module event types and attributes const ( - EventTypeCreateService = "CreateService" + EventType = "service" - AttributeHash = "hash" + AttributeKeyHash = "hash" + AttributeKeyAddress = "address" - AttributeValueCategory = ModuleName + AttributeActionCreated = "created" ) diff --git a/x/service/internal/types/msg.go b/x/service/internal/types/msg.go index f51bf6fef..9414429ed 100644 --- a/x/service/internal/types/msg.go +++ b/x/service/internal/types/msg.go @@ -4,50 +4,32 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/mesg-foundation/engine/ext/xvalidator" - "github.com/mesg-foundation/engine/protobuf/api" ) -// MsgCreateService defines a state transition to create a service. -type MsgCreateService struct { - Owner sdk.AccAddress `json:"owner" validate:"required,accaddress"` - Request *api.CreateServiceRequest `json:"request" validate:"required"` -} - -// NewMsgCreateService is a constructor function for MsgCreateService. -func NewMsgCreateService(owner sdk.AccAddress, request *api.CreateServiceRequest) *MsgCreateService { - return &MsgCreateService{ - Owner: owner, - Request: request, - } -} - // Route should return the name of the module route. -func (msg MsgCreateService) Route() string { +func (msg MsgCreate) Route() string { return RouterKey } // Type returns the action. -func (msg MsgCreateService) Type() string { - return "CreateService" +func (msg MsgCreate) Type() string { + return "create" } // ValidateBasic runs stateless checks on the message. -func (msg MsgCreateService) ValidateBasic() error { - if msg.Owner.Empty() { - return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "owner is missing") - } - if err := xvalidator.Validate.Struct(msg); err != nil { +func (msg MsgCreate) ValidateBasic() error { + if err := xvalidator.Struct(msg); err != nil { return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error()) } return nil } // GetSignBytes encodes the message for signing. -func (msg MsgCreateService) GetSignBytes() []byte { +func (msg MsgCreate) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(msg)) } // GetSigners defines whose signature is required. -func (msg MsgCreateService) GetSigners() []sdk.AccAddress { +func (msg MsgCreate) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{msg.Owner} } diff --git a/x/service/internal/types/msg.pb.go b/x/service/internal/types/msg.pb.go new file mode 100644 index 000000000..60782e4dd --- /dev/null +++ b/x/service/internal/types/msg.pb.go @@ -0,0 +1,186 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: x/service/internal/types/msg.proto + +package types + +import ( + fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + service "github.com/mesg-foundation/engine/service" + math "math" +) + +// 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 + +// The message to create a Service. +type MsgCreate struct { + // Service's sid. + Sid string `protobuf:"bytes,1,opt,name=sid,proto3" json:"sid,omitempty" validate:"omitempty,printascii,max=63,domain"` + // Service's name. + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty" validate:"required,printascii"` + // Service's description. + Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty" validate:"printascii"` + // Configurations related to the service + Configuration service.Service_Configuration `protobuf:"bytes,4,opt,name=configuration,proto3" json:"configuration" validate:"required"` + // The list of tasks this service can execute. + Tasks []*service.Service_Task `protobuf:"bytes,5,rep,name=tasks,proto3" json:"tasks,omitempty" validate:"dive,required"` + // The list of events this service can emit. + Events []*service.Service_Event `protobuf:"bytes,6,rep,name=events,proto3" json:"events,omitempty" validate:"dive,required"` + // The container dependencies this service requires. + Dependencies []*service.Service_Dependency `protobuf:"bytes,7,rep,name=dependencies,proto3" json:"dependencies,omitempty" validate:"dive,required"` + // Service's repository url. + Repository string `protobuf:"bytes,8,opt,name=repository,proto3" json:"repository,omitempty" validate:"omitempty,uri"` + // The hash id of service's source code on IPFS. + Source string `protobuf:"bytes,9,opt,name=source,proto3" json:"source,omitempty" validate:"required,printascii"` + // The service's owner. + Owner github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,10,opt,name=owner,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"owner,omitempty" validate:"required,accaddress"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *MsgCreate) Reset() { *m = MsgCreate{} } +func (m *MsgCreate) String() string { return proto.CompactTextString(m) } +func (*MsgCreate) ProtoMessage() {} +func (*MsgCreate) Descriptor() ([]byte, []int) { + return fileDescriptor_95b7141f6bdf41b9, []int{0} +} +func (m *MsgCreate) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_MsgCreate.Unmarshal(m, b) +} +func (m *MsgCreate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_MsgCreate.Marshal(b, m, deterministic) +} +func (m *MsgCreate) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreate.Merge(m, src) +} +func (m *MsgCreate) XXX_Size() int { + return xxx_messageInfo_MsgCreate.Size(m) +} +func (m *MsgCreate) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreate.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreate proto.InternalMessageInfo + +func (m *MsgCreate) GetSid() string { + if m != nil { + return m.Sid + } + return "" +} + +func (m *MsgCreate) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *MsgCreate) GetDescription() string { + if m != nil { + return m.Description + } + return "" +} + +func (m *MsgCreate) GetConfiguration() service.Service_Configuration { + if m != nil { + return m.Configuration + } + return service.Service_Configuration{} +} + +func (m *MsgCreate) GetTasks() []*service.Service_Task { + if m != nil { + return m.Tasks + } + return nil +} + +func (m *MsgCreate) GetEvents() []*service.Service_Event { + if m != nil { + return m.Events + } + return nil +} + +func (m *MsgCreate) GetDependencies() []*service.Service_Dependency { + if m != nil { + return m.Dependencies + } + return nil +} + +func (m *MsgCreate) GetRepository() string { + if m != nil { + return m.Repository + } + return "" +} + +func (m *MsgCreate) GetSource() string { + if m != nil { + return m.Source + } + return "" +} + +func (m *MsgCreate) GetOwner() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.Owner + } + return nil +} + +func init() { + proto.RegisterType((*MsgCreate)(nil), "mesg.service.types.MsgCreate") +} + +func init() { proto.RegisterFile("x/service/internal/types/msg.proto", fileDescriptor_95b7141f6bdf41b9) } + +var fileDescriptor_95b7141f6bdf41b9 = []byte{ + // 495 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0x41, 0x6f, 0xd3, 0x30, + 0x14, 0xc7, 0x29, 0x5d, 0x0b, 0x75, 0xc7, 0xc5, 0x08, 0xc9, 0x1b, 0xd3, 0x52, 0x72, 0xea, 0xa1, + 0x4d, 0xc4, 0x26, 0xed, 0x50, 0xc6, 0x61, 0x2d, 0xdc, 0x40, 0x48, 0x1d, 0x27, 0x4e, 0xb8, 0xf6, + 0x6b, 0xb0, 0xba, 0xd8, 0xc1, 0xcf, 0x29, 0xeb, 0xc7, 0xe0, 0x5b, 0xf1, 0x29, 0xf2, 0x21, 0x7a, + 0xe4, 0x84, 0xea, 0x74, 0x24, 0x83, 0x4e, 0xdb, 0x29, 0x71, 0xde, 0xff, 0xf7, 0x4b, 0xec, 0xbc, + 0x47, 0xc2, 0xeb, 0x18, 0xc1, 0x2e, 0x95, 0x80, 0x58, 0x69, 0x07, 0x56, 0xf3, 0xab, 0xd8, 0xad, + 0x32, 0xc0, 0x38, 0xc5, 0x24, 0xca, 0xac, 0x71, 0x86, 0xd2, 0x14, 0x30, 0x89, 0xb6, 0xb1, 0xc8, + 0x57, 0x0f, 0xc3, 0xc4, 0x24, 0x26, 0xf6, 0xf5, 0x59, 0x3e, 0x8f, 0x37, 0x2b, 0xbf, 0xf0, 0x77, + 0x25, 0x77, 0x78, 0xf4, 0xb7, 0x5c, 0x1a, 0x6f, 0x0c, 0xfe, 0x71, 0xf8, 0xb3, 0x4d, 0x3a, 0x1f, + 0x31, 0x99, 0x58, 0xe0, 0x0e, 0xe8, 0x84, 0x34, 0x51, 0x49, 0xd6, 0xe8, 0x35, 0xfa, 0x9d, 0xf1, + 0xeb, 0x75, 0x11, 0x0c, 0x97, 0xfc, 0x4a, 0x49, 0xee, 0x60, 0x14, 0x9a, 0x54, 0x39, 0x48, 0x33, + 0xb7, 0x1a, 0x64, 0x56, 0x69, 0xc7, 0x51, 0x28, 0x35, 0x48, 0xf9, 0xf5, 0xdb, 0xb3, 0xd3, 0x81, + 0x34, 0x29, 0x57, 0x3a, 0x9c, 0x6e, 0x68, 0x7a, 0x46, 0xf6, 0x34, 0x4f, 0x81, 0x3d, 0xf6, 0x96, + 0x70, 0x5d, 0x04, 0xc7, 0x95, 0xc5, 0xc2, 0xf7, 0x5c, 0x59, 0x90, 0x35, 0x49, 0x38, 0xf5, 0x79, + 0xfa, 0x86, 0x74, 0x25, 0xa0, 0xb0, 0x2a, 0x73, 0xca, 0x68, 0xd6, 0xf4, 0xf8, 0xc1, 0xba, 0x08, + 0x5e, 0x54, 0x78, 0x9d, 0xaa, 0xa7, 0xa9, 0x24, 0xcf, 0x84, 0xd1, 0x73, 0x95, 0xe4, 0x96, 0x7b, + 0x7c, 0xaf, 0xd7, 0xe8, 0x77, 0x4f, 0x5e, 0x45, 0xfe, 0xd4, 0xfc, 0xce, 0xa3, 0xcb, 0xed, 0xce, + 0x27, 0xf5, 0xe0, 0xf8, 0xe5, 0xaf, 0x22, 0x78, 0xb4, 0x2e, 0x82, 0xe7, 0xff, 0x7f, 0x64, 0x38, + 0xbd, 0x2d, 0xa5, 0x1f, 0x48, 0xcb, 0x71, 0x5c, 0x20, 0x6b, 0xf5, 0x9a, 0xfd, 0xee, 0x09, 0xdb, + 0x65, 0xff, 0xcc, 0x71, 0x31, 0x3e, 0x5a, 0x17, 0x01, 0xab, 0x84, 0x52, 0x2d, 0x61, 0x50, 0x59, + 0x4b, 0x09, 0xfd, 0x44, 0xda, 0xb0, 0x04, 0xed, 0x90, 0xb5, 0xbd, 0xee, 0x60, 0x97, 0xee, 0xfd, + 0x26, 0x71, 0x8f, 0x6f, 0xab, 0xa1, 0x5f, 0xc9, 0xbe, 0x84, 0x0c, 0xb4, 0x04, 0x2d, 0x14, 0x20, + 0x7b, 0xe2, 0xb5, 0xc7, 0xbb, 0xb4, 0xef, 0x6e, 0x72, 0xab, 0x7b, 0xdc, 0xb7, 0x8c, 0xf4, 0x9c, + 0x10, 0x0b, 0x99, 0x41, 0xe5, 0x8c, 0x5d, 0xb1, 0xa7, 0xfe, 0x17, 0xfd, 0xc3, 0x57, 0x7d, 0x92, + 0x5b, 0x15, 0x4e, 0x6b, 0x79, 0x3a, 0x22, 0x6d, 0x34, 0xb9, 0x15, 0xc0, 0x3a, 0x0f, 0xee, 0x8d, + 0x2d, 0x41, 0x15, 0x69, 0x99, 0x1f, 0x1a, 0x2c, 0x23, 0xbd, 0x46, 0x7f, 0x7f, 0x7c, 0x79, 0x07, + 0xca, 0x85, 0xe0, 0x52, 0x5a, 0x40, 0x0c, 0x7f, 0x17, 0xc1, 0x30, 0x51, 0xee, 0x5b, 0x3e, 0x8b, + 0x84, 0x49, 0x63, 0x61, 0x30, 0x35, 0xb8, 0xbd, 0x0c, 0x51, 0x2e, 0xca, 0x79, 0x88, 0x2e, 0x84, + 0xb8, 0x28, 0x89, 0x69, 0xf9, 0x86, 0xf1, 0xf9, 0x97, 0x51, 0x8d, 0xdb, 0x1c, 0xde, 0x70, 0x6e, + 0x72, 0x2d, 0x7d, 0x0f, 0xc4, 0xa0, 0x13, 0xa5, 0x21, 0xbe, 0x6b, 0x62, 0x67, 0x6d, 0x3f, 0x58, + 0xa7, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0xa1, 0x8e, 0x9d, 0x2f, 0xd4, 0x03, 0x00, 0x00, +} diff --git a/x/service/internal/types/msg.proto b/x/service/internal/types/msg.proto new file mode 100644 index 000000000..761f7494f --- /dev/null +++ b/x/service/internal/types/msg.proto @@ -0,0 +1,62 @@ +syntax = "proto3"; + +import "gogo/protobuf/gogoproto/gogo.proto"; +import "protobuf/types/service.proto"; + +package mesg.service.types; +option go_package = "github.com/mesg-foundation/engine/x/service/internal/types"; + +// The message to create a Service. +message MsgCreate { + // Service's sid. + string sid = 1 [ + (gogoproto.moretags) = 'validate:"omitempty,printascii,max=63,domain"' + ]; + + // Service's name. + string name = 2 [ + (gogoproto.moretags) = 'validate:"required,printascii"' + ]; + + // Service's description. + string description = 3 [ + (gogoproto.moretags) = 'validate:"printascii"' + ]; + + // Configurations related to the service + mesg.types.Service.Configuration configuration = 4 [ + (gogoproto.moretags) = 'validate:"required"', + (gogoproto.nullable) = false + ]; + + // The list of tasks this service can execute. + repeated mesg.types.Service.Task tasks = 5 [ + (gogoproto.moretags) = 'validate:"dive,required"' + ]; + + // The list of events this service can emit. + repeated mesg.types.Service.Event events = 6 [ + (gogoproto.moretags) = 'validate:"dive,required"' + ]; + + // The container dependencies this service requires. + repeated mesg.types.Service.Dependency dependencies = 7 [ + (gogoproto.moretags) = 'validate:"dive,required"' + ]; + + // Service's repository url. + string repository = 8 [ + (gogoproto.moretags) = 'validate:"omitempty,uri"' + ]; + + // The hash id of service's source code on IPFS. + string source = 9 [ + (gogoproto.moretags) = 'validate:"required,printascii"' + ]; + + // The service's owner. + bytes owner = 10 [ + (gogoproto.moretags) = 'validate:"required,accaddress"', + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" + ]; +} diff --git a/x/service/internal/types/querier.go b/x/service/internal/types/querier.go index 474039158..f4b1a69b6 100644 --- a/x/service/internal/types/querier.go +++ b/x/service/internal/types/querier.go @@ -2,8 +2,7 @@ package types // Query endpoints supported by the service querier const ( - QueryGetService = "get" - QueryListService = "list" - QueryHashService = "hash" - QueryExistService = "exist" + QueryGet = "get" + QueryList = "list" + QueryExist = "exist" ) diff --git a/x/service/module.go b/x/service/module.go index 592f15ce8..ef8e1c546 100644 --- a/x/service/module.go +++ b/x/service/module.go @@ -73,15 +73,13 @@ type AppModule struct { AppModuleBasic keeper Keeper - // TODO: Add keepers that your application depends on } // NewAppModule creates a new AppModule object -func NewAppModule(k Keeper /*TODO: Add Keepers that your application depends on*/) AppModule { +func NewAppModule(k Keeper) AppModule { return AppModule{ AppModuleBasic: AppModuleBasic{}, keeper: k, - // TODO: Add keepers that your application depends on } }