diff --git a/proto/vaas/provider/v1/genesis.proto b/proto/vaas/provider/v1/genesis.proto index ee000e3..366faa0 100644 --- a/proto/vaas/provider/v1/genesis.proto +++ b/proto/vaas/provider/v1/genesis.proto @@ -5,6 +5,7 @@ package vaas.provider.v1; option go_package = "github.com/allinbits/vaas/x/vaas/provider/types"; import "gogoproto/gogo.proto"; +import "google/protobuf/timestamp.proto"; import "vaas/v1/shared_consumer.proto"; import "vaas/v1/wire.proto"; import "vaas/provider/v1/provider.proto"; @@ -38,22 +39,43 @@ message GenesisState { // // Note this type is only used internally to the provider VAAS module. message ConsumerState { - // ChainID defines the chain ID for the consumer chain - string chain_id = 1; + // ConsumerID is the internal numeric consumer id. + uint64 consumer_id = 1; + // ChainID is the external chain identifier of the consumer chain (e.g. + // "atomone-1"), as supplied by the consumer owner at registration. + string chain_id = 2; // ClientID defines the IBC client ID for the consumer chain. - string client_id = 2; - // InitalHeight defines the initial block height for the consumer chain - uint64 initial_height = 3; + string client_id = 3; + // InitialHeight defines the initial block height for the consumer chain + uint64 initial_height = 4; // ConsumerGenesis defines the initial consumer chain genesis states - vaas.v1.ConsumerGenesisState consumer_genesis = 4 + vaas.v1.ConsumerGenesisState consumer_genesis = 5 [ (gogoproto.nullable) = false ]; // PendingValsetChanges defines the pending validator set changes for the // consumer chain - repeated vaas.v1.ValidatorSetChangePacketData - pending_valset_changes = 5 [ (gogoproto.nullable) = false ]; - repeated string slash_downtime_ack = 6; + repeated vaas.v1.ValidatorSetChangePacketData pending_valset_changes = 6 [ (gogoproto.nullable) = false ]; + repeated string slash_downtime_ack = 7; // the phase of the consumer chain - ConsumerPhase phase = 7; + ConsumerPhase phase = 8; + // OwnerAddress is the bech32 address that authorises owner-only operations + // (UpdateConsumer, RemoveConsumer, key assignment, etc.) on the consumer. + // Always non-empty for any existing consumer record; set at REGISTERED. + string owner_address = 9; + // Metadata is the owner-supplied descriptor (name/description/repo). + // Preserved through DELETED so block explorers can show information + // about removed chains without an archive node. + vaas.provider.v1.ConsumerMetadata metadata = 10; + // InitParams are the owner-supplied launch parameters: spawn time, + // initial height, genesis hash, binary hash, etc. Preserved through + // DELETED for the same explorer reason. Carries the spawn_time used + // to re-derive the keeper's spawn-time queue, and the initial_height + // used to re-derive equivocation_evidence_min_height, at InitGenesis. + vaas.provider.v1.ConsumerInitializationParameters init_params = 11; + // RemovalTime is the wall-clock time at which a STOPPED consumer is + // scheduled to transition to DELETED. Set only when phase == STOPPED; + // absent otherwise. Used to re-derive the keeper's removal-time queue. + google.protobuf.Timestamp removal_time = 12 + [ (gogoproto.stdtime) = true ]; } // ValsetUpdateIdToHeight defines the genesis information for the mapping diff --git a/proto/vaas/provider/v1/provider.proto b/proto/vaas/provider/v1/provider.proto index 4b826a6..4b6e1d2 100644 --- a/proto/vaas/provider/v1/provider.proto +++ b/proto/vaas/provider/v1/provider.proto @@ -67,28 +67,28 @@ message KeyAssignmentReplacement { } // Used to serialize the ValidatorConsumerPubKey index from key assignment -// ValidatorConsumerPubKey: (chainID, providerAddr consAddr) -> consumerKey +// ValidatorConsumerPubKey: (consumerID, providerAddr consAddr) -> consumerKey // tmprotocrypto.PublicKey message ValidatorConsumerPubKey { - string chain_id = 1; + uint64 consumer_id = 1; bytes provider_addr = 2; tendermint.crypto.PublicKey consumer_key = 3; } // Used to serialize the ValidatorConsumerAddr index from key assignment -// ValidatorByConsumerAddr: (chainID, consumerAddr consAddr) -> providerAddr +// ValidatorByConsumerAddr: (consumerID, consumerAddr consAddr) -> providerAddr // consAddr message ValidatorByConsumerAddr { - string chain_id = 1; + uint64 consumer_id = 1; bytes consumer_addr = 2; bytes provider_addr = 3; } // Used to serialize the ConsumerAddrsToPrune index from key assignment -// ConsumerAddrsToPrune: (chainID, pruneTs time.Time) -> consumerAddrs +// ConsumerAddrsToPrune: (consumerID, pruneTs time.Time) -> consumerAddrs // AddressList message ConsumerAddrsToPrune { - string chain_id = 1; + uint64 consumer_id = 1; google.protobuf.Timestamp prune_ts = 2 [ (gogoproto.stdtime) = true, (gogoproto.nullable) = false ]; AddressList consumer_addrs = 3; @@ -170,8 +170,7 @@ message ConsumerInitializationParameters { } // ConsumerIds contains consumer ids of chains -// Used so we can easily (de)serialize slices of strings -message ConsumerIds { repeated string ids = 1; } +message ConsumerIds { repeated uint64 ids = 1; } // ConsumerPhase indicates the phases of a consumer chain according to ADR 019 enum ConsumerPhase { diff --git a/proto/vaas/provider/v1/query.proto b/proto/vaas/provider/v1/query.proto index d7b369e..ab3c7be 100644 --- a/proto/vaas/provider/v1/query.proto +++ b/proto/vaas/provider/v1/query.proto @@ -109,7 +109,7 @@ service Query { } message QueryConsumerGenesisRequest { - string consumer_id = 1; + uint64 consumer_id = 1; } message QueryConsumerGenesisResponse { @@ -137,7 +137,7 @@ message Chain { string phase = 3; // The metadata of the consumer chain ConsumerMetadata metadata = 4 [(gogoproto.nullable) = false ]; - string consumer_id = 5; + uint64 consumer_id = 5; // Infraction parameters for slashing and jailing InfractionParameters infraction_parameters = 6; // The deterministic provider-side account that must be funded @@ -151,7 +151,7 @@ message QueryValidatorConsumerAddrRequest { // The consensus address of the validator on the provider chain string provider_address = 1 [ (gogoproto.moretags) = "yaml:\"address\"" ]; // The id of the consumer chain - string consumer_id = 2; + uint64 consumer_id = 2; } message QueryValidatorConsumerAddrResponse { @@ -165,7 +165,7 @@ message QueryValidatorProviderAddrRequest { // The consensus address of the validator on the consumer chain string consumer_address = 1 [ (gogoproto.moretags) = "yaml:\"address\"" ]; // The id of the consumer chain - string consumer_id = 2; + uint64 consumer_id = 2; } message QueryValidatorProviderAddrResponse { @@ -175,7 +175,7 @@ message QueryValidatorProviderAddrResponse { message QueryAllPairsValConsAddrByConsumerRequest { // The id of the consumer chain - string consumer_id = 1; + uint64 consumer_id = 1; } message QueryAllPairsValConsAddrByConsumerResponse { @@ -197,7 +197,7 @@ message QueryParamsResponse { } message QueryConsumerValidatorsRequest { - string consumer_id = 1; + uint64 consumer_id = 1; } message QueryConsumerValidatorsValidator { @@ -246,15 +246,15 @@ message QueryConsumerIdFromClientIdRequest { message QueryConsumerIdFromClientIdResponse { // the consumer id of the chain associated with this client id - string consumer_id = 1; + uint64 consumer_id = 1; } message QueryConsumerChainRequest { - string consumer_id = 1; + uint64 consumer_id = 1; } message QueryConsumerChainResponse { - string consumer_id = 1; + uint64 consumer_id = 1; string chain_id = 2; string owner_address = 3; string phase = 4; @@ -270,7 +270,7 @@ message QueryConsumerChainResponse { } message QueryConsumerGenesisTimeRequest { - string consumer_id = 1; + uint64 consumer_id = 1; } message QueryConsumerGenesisTimeResponse { diff --git a/proto/vaas/provider/v1/tx.proto b/proto/vaas/provider/v1/tx.proto index e3b2eae..3ac3677 100644 --- a/proto/vaas/provider/v1/tx.proto +++ b/proto/vaas/provider/v1/tx.proto @@ -35,7 +35,7 @@ message MsgAssignConsumerKey { option (gogoproto.goproto_getters) = false; // the consumer id of the consumer chain to assign a consensus public key to - string consumer_id = 1; + uint64 consumer_id = 1; // The validator address on the provider string provider_addr = 2 [(gogoproto.moretags) = "yaml:\"address\""]; // The consensus public key to use on the consumer. @@ -60,7 +60,7 @@ message MsgSubmitConsumerMisbehaviour { // two conflicting IBC headers ibc.lightclients.tendermint.v1.Misbehaviour misbehaviour = 2; // the consumer id of the consumer chain where the misbehaviour occurred - string consumer_id = 3; + uint64 consumer_id = 3; } message MsgSubmitConsumerMisbehaviourResponse {} @@ -79,7 +79,7 @@ message MsgSubmitConsumerDoubleVoting { // The light client header of the infraction block ibc.lightclients.tendermint.v1.Header infraction_block_header = 3; // the consumer id of the consumer chain where the double-voting took place - string consumer_id = 4; + uint64 consumer_id = 4; } message MsgSubmitConsumerDoubleVotingResponse {} @@ -103,7 +103,7 @@ message MsgRemoveConsumer { option (cosmos.msg.v1.signer) = "owner"; // the consumer id of the consumer chain to be stopped - string consumer_id = 1; + uint64 consumer_id = 1; // the address of the owner of the consumer chain to be stopped string owner = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; } @@ -132,7 +132,7 @@ message MsgCreateConsumer { // MsgCreateConsumerResponse defines response type for MsgCreateConsumer message MsgCreateConsumerResponse { - string consumer_id = 1; + uint64 consumer_id = 1; } // MsgUpdateConsumer defines the message used to modify a consumer chain. @@ -143,7 +143,7 @@ message MsgUpdateConsumer { string owner = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // the consumer id of the consumer chain to be updated - string consumer_id = 2; + uint64 consumer_id = 2; // the new owner of the consumer when updated string new_owner_address = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"]; diff --git a/tests/e2e/e2e_genesis_roundtrip_test.go b/tests/e2e/e2e_genesis_roundtrip_test.go new file mode 100644 index 0000000..b5c4b91 --- /dev/null +++ b/tests/e2e/e2e_genesis_roundtrip_test.go @@ -0,0 +1,256 @@ +package e2e + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "os" + "path/filepath" + "time" + + "github.com/ory/dockertest/v3" + "github.com/ory/dockertest/v3/docker" +) + +// testGenesisRoundTrip stops the provider chain, exports its genesis, starts a +// new provider chain initialised from the exported genesis, and verifies the +// previously-registered consumer chain still exists in the new chain's state. +// +// This is the end-to-end counterpart of TestGenesisRoundTrip in +// x/vaas/provider/keeper/genesis_test.go: the unit test proves the keeper-level +// round-trip is a fixed point; this test proves the binary's export and init +// commands honour the same contract. +// +// MUST run last in TestVAAS — it stops and replaces the provider container, +// after which the relayer and the original consumer chain may produce noise +// but the suite is about to tear down anyway. +func (s *IntegrationTestSuite) testGenesisRoundTrip() { + s.Run("genesis round-trip across provider restart", func() { + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) + defer cancel() + + oldRes := s.providerValRes[0] + oldDataDir := s.provider.dataDir + + // 1. Stop the provider container gracefully so the data dir is in a + // consistent state for export. + s.T().Log("stopping provider container for export...") + s.Require().NoError(s.dkrPool.Client.StopContainer(oldRes.Container.ID, 30)) + + // 2. Run an ephemeral container that exports the genesis to stdout + // with --for-zero-height so the resulting JSON is suitable for + // initialising a fresh chain. + s.T().Log("exporting genesis via ephemeral container...") + exportedJSON := s.exportProviderGenesis(ctx, oldDataDir) + + // 3. Parse + verify the exported JSON carries the new ConsumerState + // fields with populated values. + s.T().Log("verifying exported genesis contains owner/metadata/init_params...") + s.verifyExportedGenesis(exportedJSON) + + // 4. Bootstrap a new provider data dir from the old: same validator + // keys + config, but the exported JSON as genesis.json and a + // fresh data/ so the chain initialises from genesis. + s.T().Log("bootstrapping new provider data dir from exported genesis...") + newDataDir := s.bootstrapRestartedProviderDir(oldDataDir, exportedJSON) + + // 5. Purge the old container so its port bindings are released and + // the teardown step doesn't try to purge a stopped container. + s.T().Log("purging old provider container...") + s.Require().NoError(s.dkrPool.Purge(oldRes)) + s.providerValRes = s.providerValRes[:0] + + // 6. Start a new provider container from the new data dir on the + // same ports the old container used. + s.T().Log("starting restarted provider container...") + newRes := s.startRestartedProvider(newDataDir) + s.providerValRes = append(s.providerValRes, newRes) + + // 7. Wait for the new provider to produce blocks. + s.T().Log("waiting for restarted provider to produce blocks...") + waitCtx, waitCancel := context.WithTimeout(ctx, 2*time.Minute) + defer waitCancel() + s.Require().NoError(s.waitForChainHeight(waitCtx, "http://localhost:26657", 3), + "restarted provider failed to produce blocks") + + // 8. Verify the consumer chain is still registered. + s.T().Log("verifying consumer chain is still registered after restart...") + chainsOutput, err := s.queryProviderConsumerChains() + s.Require().NoError(err, "failed to query consumer chains on restarted provider") + s.Require().Contains(chainsOutput, consumerChainID, + "consumer chain %s should still be registered after restart", consumerChainID) + }) +} + +// exportProviderGenesis launches an ephemeral container that mounts the +// provider's data directory and runs `provider export --for-zero-height`. +// Returns the exported genesis JSON. +func (s *IntegrationTestSuite) exportProviderGenesis(ctx context.Context, dataDir string) []byte { + exportRes, err := s.dkrPool.RunWithOptions( + &dockertest.RunOptions{ + Name: fmt.Sprintf("%s-export", providerChainID), + Repository: e2eChainImage, + NetworkID: s.dkrNet.Network.ID, + User: "nonroot", + Mounts: []string{ + fmt.Sprintf("%s:%s", dataDir, providerHomePath), + }, + Cmd: []string{ + providerBinary, "export", + "--home", providerHomePath, + "--for-zero-height", + }, + }, + func(config *docker.HostConfig) { + config.RestartPolicy = docker.RestartPolicy{Name: "no"} + }, + ) + s.Require().NoError(err, "failed to start export container") + defer func() { + if perr := s.dkrPool.Purge(exportRes); perr != nil { + s.T().Logf("failed to purge export container: %v", perr) + } + }() + + exitCode, err := s.dkrPool.Client.WaitContainerWithContext(exportRes.Container.ID, ctx) + s.Require().NoError(err, "export container wait failed") + + var stdoutBuf, stderrBuf bytes.Buffer + err = s.dkrPool.Client.Logs(docker.LogsOptions{ + Container: exportRes.Container.ID, + OutputStream: &stdoutBuf, + ErrorStream: &stderrBuf, + Stdout: true, + Stderr: true, + }) + s.Require().NoError(err, "failed to read export container logs") + s.Require().Equalf(0, exitCode, + "export container failed (exit=%d)\nstdout:\n%s\nstderr:\n%s", + exitCode, stdoutBuf.String(), stderrBuf.String()) + + // Some SDK versions log "exported genesis ..." lines before the JSON + // body on stdout. Strip anything before the first '{'. + raw := stdoutBuf.Bytes() + if i := bytes.IndexByte(raw, '{'); i > 0 { + raw = raw[i:] + } + return raw +} + +// verifyExportedGenesis asserts that the exported JSON includes the consumer +// registered during setup along with the new ConsumerState fields populated. +func (s *IntegrationTestSuite) verifyExportedGenesis(exportedJSON []byte) { + var top map[string]json.RawMessage + s.Require().NoError(json.Unmarshal(exportedJSON, &top), "exported genesis is not valid JSON") + + appState, ok := top["app_state"] + s.Require().True(ok, "exported genesis missing app_state") + + var app map[string]json.RawMessage + s.Require().NoError(json.Unmarshal(appState, &app)) + + providerState, ok := app["provider"] + s.Require().True(ok, "app_state missing provider module") + + type consumerStateJSON struct { + ConsumerId uint64 `json:"consumer_id,string"` + ChainId string `json:"chain_id"` + Phase string `json:"phase"` + OwnerAddress string `json:"owner_address"` + Metadata map[string]interface{} `json:"metadata"` + InitParams map[string]interface{} `json:"init_params"` + } + var provider struct { + ConsumerStates []consumerStateJSON `json:"consumer_states"` + } + s.Require().NoError(json.Unmarshal(providerState, &provider)) + s.Require().GreaterOrEqual(len(provider.ConsumerStates), 1, "no consumer states exported") + + var found *consumerStateJSON + for i := range provider.ConsumerStates { + if provider.ConsumerStates[i].ChainId == consumerChainID { + found = &provider.ConsumerStates[i] + break + } + } + s.Require().NotNil(found, "expected consumer %s not found in export", consumerChainID) + + s.Require().NotEmpty(found.OwnerAddress, "owner_address must be exported for consumer %s", consumerChainID) + s.Require().NotNil(found.Metadata, "metadata must be exported for consumer %s", consumerChainID) + s.Require().NotNil(found.InitParams, "init_params must be exported for consumer %s", consumerChainID) +} + +// bootstrapRestartedProviderDir builds a new provider data directory that +// reuses the old chain's validator and node keys + config files, but uses +// the exported JSON as its genesis.json and starts with an empty data/. +func (s *IntegrationTestSuite) bootstrapRestartedProviderDir(oldDir string, exportedJSON []byte) string { + newDir, err := os.MkdirTemp("", "vaas-e2e-provider-restart-") + s.Require().NoError(err) + s.tmpDirs = append(s.tmpDirs, newDir) + s.Require().NoError(os.Chmod(newDir, 0o777)) + s.Require().NoError(os.MkdirAll(filepath.Join(newDir, "config"), 0o777)) + s.Require().NoError(os.MkdirAll(filepath.Join(newDir, "data"), 0o777)) + + // Copy validator + node keys and chain config files from the old dir. + for _, name := range []string{ + "config/priv_validator_key.json", + "config/node_key.json", + "config/app.toml", + "config/config.toml", + } { + data, err := os.ReadFile(filepath.Join(oldDir, name)) + s.Require().NoErrorf(err, "read %s from old data dir", name) + s.Require().NoErrorf(os.WriteFile(filepath.Join(newDir, name), data, 0o644), + "write %s to new data dir", name) + } + + // Write the exported JSON as the new chain's genesis. + s.Require().NoError(os.WriteFile( + filepath.Join(newDir, "config", "genesis.json"), + exportedJSON, + 0o644, + ), "failed to write exported genesis") + + // Reset priv_validator_state.json so the validator can sign blocks at + // the new chain's initial height without tripping double-sign detection. + s.Require().NoError(os.WriteFile( + filepath.Join(newDir, "data", "priv_validator_state.json"), + []byte(`{"height":"0","round":0,"step":0}`), + 0o644, + ), "failed to write priv_validator_state.json") + + s.Require().NoError(os.Chmod(filepath.Join(newDir, "config"), 0o777)) + s.Require().NoError(os.Chmod(filepath.Join(newDir, "data"), 0o777)) + return newDir +} + +// startRestartedProvider runs a new provider container on the same host ports +// the original used, mounting the new data dir. +func (s *IntegrationTestSuite) startRestartedProvider(dataDir string) *dockertest.Resource { + // Update so subsequent helpers find the new data dir. + s.provider.dataDir = dataDir + + resource, err := s.dkrPool.RunWithOptions( + &dockertest.RunOptions{ + Name: fmt.Sprintf("%s-val0", providerChainID), + Repository: e2eChainImage, + NetworkID: s.dkrNet.Network.ID, + Mounts: []string{ + fmt.Sprintf("%s:%s", dataDir, providerHomePath), + }, + PortBindings: map[docker.Port][]docker.PortBinding{ + "26657/tcp": {{HostIP: "", HostPort: "26657"}}, + "9090/tcp": {{HostIP: "", HostPort: "9090"}}, + "1317/tcp": {{HostIP: "", HostPort: "1317"}}, + "26656/tcp": {{HostIP: "", HostPort: "26656"}}, + }, + Cmd: []string{providerBinary, "start", "--home", providerHomePath}, + }, + func(config *docker.HostConfig) { + config.RestartPolicy = docker.RestartPolicy{Name: "no"} + }, + ) + s.Require().NoError(err, "failed to start restarted provider container") + return resource +} diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index c08b5a8..b176c90 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -8,4 +8,7 @@ func (s *IntegrationTestSuite) TestVAAS() { s.testProviderOnConsumer() s.testValidatorSetSync() s.testConsumerDebtFlow() + // Run last: stops the provider container and replaces it with a fresh + // one started from the exported genesis. + s.testGenesisRoundTrip() } diff --git a/x/vaas/provider/client/cli/query.go b/x/vaas/provider/client/cli/query.go index 061bde4..5a6ee8d 100644 --- a/x/vaas/provider/client/cli/query.go +++ b/x/vaas/provider/client/cli/query.go @@ -14,6 +14,15 @@ import ( "github.com/cosmos/cosmos-sdk/version" ) +// parseConsumerIdArg parses a CLI positional argument as a uint64 consumer id. +func parseConsumerIdArg(arg string) (uint64, error) { + cid, err := strconv.ParseUint(arg, 10, 64) + if err != nil { + return 0, fmt.Errorf("invalid consumer id %q: %w", arg, err) + } + return cid, nil +} + // NewQueryCmd returns a root CLI command handler for all x/vaas/provider query commands. func NewQueryCmd() *cobra.Command { cmd := &cobra.Command{ @@ -51,7 +60,11 @@ func CmdConsumerGenesis() *cobra.Command { } queryClient := types.NewQueryClient(clientCtx) - req := types.QueryConsumerGenesisRequest{ConsumerId: args[0]} + cid, err := parseConsumerIdArg(args[0]) + if err != nil { + return err + } + req := types.QueryConsumerGenesisRequest{ConsumerId: cid} res, err := queryClient.QueryConsumerGenesis(cmd.Context(), &req) if err != nil { return err @@ -139,7 +152,10 @@ $ %s query provider validator-consumer-key 3 %s1gghjut3ccd8ay0zduzj64hwre2fxs9ld } queryClient := types.NewQueryClient(clientCtx) - consumerId := args[0] + consumerId, err := parseConsumerIdArg(args[0]) + if err != nil { + return err + } addr, err := sdk.ConsAddressFromBech32(args[1]) if err != nil { @@ -186,7 +202,10 @@ $ %s query provider validator-provider-key 333 %s1gghjut3ccd8ay0zduzj64hwre2fxs9 } queryClient := types.NewQueryClient(clientCtx) - consumerID := args[0] + consumerID, err := parseConsumerIdArg(args[0]) + if err != nil { + return err + } addr, err := sdk.ConsAddressFromBech32(args[1]) if err != nil { @@ -223,7 +242,11 @@ func CmdAllPairsValConsAddrByConsumer() *cobra.Command { } queryClient := types.NewQueryClient(clientCtx) - req := types.QueryAllPairsValConsAddrByConsumerRequest{ConsumerId: args[0]} + cid, err := parseConsumerIdArg(args[0]) + if err != nil { + return err + } + req := types.QueryAllPairsValConsAddrByConsumerRequest{ConsumerId: cid} res, err := queryClient.QueryAllPairsValConsAddrByConsumer(cmd.Context(), &req) if err != nil { return err @@ -292,8 +315,12 @@ $ %s consumer-validators 3 } queryClient := types.NewQueryClient(clientCtx) + cid, err := parseConsumerIdArg(args[0]) + if err != nil { + return err + } res, err := queryClient.QueryConsumerValidators(cmd.Context(), - &types.QueryConsumerValidatorsRequest{ConsumerId: args[0]}) + &types.QueryConsumerValidatorsRequest{ConsumerId: cid}) if err != nil { return err } @@ -373,7 +400,11 @@ func CmdConsumerChain() *cobra.Command { } queryClient := types.NewQueryClient(clientCtx) - req := &types.QueryConsumerChainRequest{ConsumerId: args[0]} + cid, err := parseConsumerIdArg(args[0]) + if err != nil { + return err + } + req := &types.QueryConsumerChainRequest{ConsumerId: cid} res, err := queryClient.QueryConsumerChain(cmd.Context(), req) if err != nil { return err @@ -400,7 +431,11 @@ func CmdConsumerGenesisTime() *cobra.Command { } queryClient := types.NewQueryClient(clientCtx) - req := &types.QueryConsumerGenesisTimeRequest{ConsumerId: args[0]} + cid, err := parseConsumerIdArg(args[0]) + if err != nil { + return err + } + req := &types.QueryConsumerGenesisTimeRequest{ConsumerId: cid} res, err := queryClient.QueryConsumerGenesisTime(cmd.Context(), req) if err != nil { return err diff --git a/x/vaas/provider/client/cli/tx.go b/x/vaas/provider/client/cli/tx.go index f8ec061..865b5d9 100644 --- a/x/vaas/provider/client/cli/tx.go +++ b/x/vaas/provider/client/cli/tx.go @@ -61,7 +61,11 @@ func NewAssignConsumerKeyCmd() *cobra.Command { providerValAddr := clientCtx.GetFromAddress() - msg, err := types.NewMsgAssignConsumerKey(args[0], sdk.ValAddress(providerValAddr), args[1], submitter) + cid, err := parseConsumerIdArg(args[0]) + if err != nil { + return err + } + msg, err := types.NewMsgAssignConsumerKey(cid, sdk.ValAddress(providerValAddr), args[1], submitter) if err != nil { return err } @@ -118,7 +122,11 @@ Example: return fmt.Errorf("misbehaviour unmarshalling failed: %s", err) } - msg, err := types.NewMsgSubmitConsumerMisbehaviour(args[0], submitter, &misbehaviour) + cid, err := parseConsumerIdArg(args[0]) + if err != nil { + return err + } + msg, err := types.NewMsgSubmitConsumerMisbehaviour(cid, submitter, &misbehaviour) if err != nil { return err } @@ -187,7 +195,11 @@ Example: return fmt.Errorf("infraction IBC header unmarshalling failed: %s", err) } - msg, err := types.NewMsgSubmitConsumerDoubleVoting(args[0], submitter, &ev, &header) + cid, err := parseConsumerIdArg(args[0]) + if err != nil { + return err + } + msg, err := types.NewMsgSubmitConsumerDoubleVoting(cid, submitter, &ev, &header) if err != nil { return err } @@ -378,10 +390,6 @@ If one of the fields is missing, it will be set to its zero value. return fmt.Errorf("consumer data unmarshalling failed: %w", err) } - if strings.TrimSpace(consUpdate.ConsumerId) == "" { - return fmt.Errorf("consumer_id can't be empty") - } - msg, err := types.NewMsgUpdateConsumer(owner, consUpdate.ConsumerId, consUpdate.NewOwnerAddress, consUpdate.Metadata, consUpdate.InitializationParameters, consUpdate.NewChainId, consUpdate.InfractionParameters) if err != nil { @@ -425,7 +433,10 @@ Example: txf = txf.WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever) owner := clientCtx.GetFromAddress().String() - consumerId := args[0] + consumerId, err := parseConsumerIdArg(args[0]) + if err != nil { + return err + } msg, err := types.NewMsgRemoveConsumer(owner, consumerId) if err != nil { diff --git a/x/vaas/provider/ibc_module_test.go b/x/vaas/provider/ibc_module_test.go index 6a6b3ff..d56971a 100644 --- a/x/vaas/provider/ibc_module_test.go +++ b/x/vaas/provider/ibc_module_test.go @@ -38,7 +38,7 @@ func TestIBCModuleOnAcknowledgementPacketHandlesErrorSentinel(t *testing.T) { providerKeeper, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - consumerID := "0" + consumerID := uint64(0) clientID := "07-tendermint-0" providerKeeper.SetConsumerClientId(ctx, consumerID, clientID) @@ -66,7 +66,7 @@ func TestIBCModuleOnTimeoutPacketFormatsSequence(t *testing.T) { providerKeeper, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - consumerID := "0" + consumerID := uint64(0) clientID := "07-tendermint-0" providerKeeper.SetConsumerClientId(ctx, consumerID, clientID) diff --git a/x/vaas/provider/keeper/consumer_equivocation.go b/x/vaas/provider/keeper/consumer_equivocation.go index f5846d0..63163c5 100644 --- a/x/vaas/provider/keeper/consumer_equivocation.go +++ b/x/vaas/provider/keeper/consumer_equivocation.go @@ -30,7 +30,7 @@ import ( // and a public key and, if successful, executes the slashing, jailing, and tombstoning of the malicious validator. func (k Keeper) HandleConsumerDoubleVoting( ctx sdk.Context, - consumerId string, + consumerId uint64, evidence *tmtypes.DuplicateVoteEvidence, pubkey cryptotypes.PubKey, ) error { @@ -38,7 +38,7 @@ func (k Keeper) HandleConsumerDoubleVoting( if k.GetConsumerPhase(ctx, consumerId) != types.CONSUMER_PHASE_LAUNCHED { return errorsmod.Wrapf( vaastypes.ErrInvalidDoubleVotingEvidence, - "consumer chain %s is not launched", + "consumer chain %d is not launched", consumerId, ) } @@ -48,7 +48,7 @@ func (k Keeper) HandleConsumerDoubleVoting( if uint64(evidence.VoteA.Height) < minHeight { return errorsmod.Wrapf( vaastypes.ErrInvalidDoubleVotingEvidence, - "evidence for consumer chain %s is too old - evidence height (%d), min (%d)", + "evidence for consumer chain %d is too old - evidence height (%d), min (%d)", consumerId, evidence.VoteA.Height, minHeight, @@ -168,7 +168,7 @@ func (k Keeper) VerifyDoubleVotingEvidence( // HandleConsumerMisbehaviour checks if the given IBC misbehaviour corresponds to an equivocation light client attack, // and in this case, slashes, jails, and tombstones -func (k Keeper) HandleConsumerMisbehaviour(ctx sdk.Context, consumerId string, misbehaviour ibctmtypes.Misbehaviour) error { +func (k Keeper) HandleConsumerMisbehaviour(ctx sdk.Context, consumerId uint64, misbehaviour ibctmtypes.Misbehaviour) error { logger := k.Logger(ctx) // Check that the misbehaviour is valid and that the client consensus states at trusted heights are within trusting period @@ -311,14 +311,14 @@ func headerToLightBlock(h ibctmtypes.Header) (*tmtypes.LightBlock, error) { // CheckMisbehaviour checks that headers in the given misbehaviour forms // a valid light client attack from an ICS consumer chain and that the light client isn't expired -func (k Keeper) CheckMisbehaviour(ctx sdk.Context, consumerId string, misbehaviour ibctmtypes.Misbehaviour) error { +func (k Keeper) CheckMisbehaviour(ctx sdk.Context, consumerId uint64, misbehaviour ibctmtypes.Misbehaviour) error { chainId := misbehaviour.Header1.Header.ChainID consumerChainId, err := k.GetConsumerChainId(ctx, consumerId) if err != nil { return err } else if consumerChainId != chainId { - return fmt.Errorf("incorrect misbehaviour for a different chain id (%s) than that of the consumer chain %s (consumerId: %s)", + return fmt.Errorf("incorrect misbehaviour for a different chain id (%s) than that of the consumer chain %s (consumerId: %d)", chainId, consumerChainId, consumerId) @@ -327,9 +327,9 @@ func (k Keeper) CheckMisbehaviour(ctx sdk.Context, consumerId string, misbehavio // check that the misbehaviour is for an ICS consumer chain clientId, found := k.GetConsumerClientId(ctx, consumerId) if !found { - return fmt.Errorf("incorrect misbehaviour with conflicting headers from a non-existent consumer chain (consumerId: %s)", consumerId) + return fmt.Errorf("incorrect misbehaviour with conflicting headers from a non-existent consumer chain (consumerId: %d)", consumerId) } else if misbehaviour.ClientId != clientId { - return fmt.Errorf("incorrect misbehaviour: expected client ID for consumer chain with id %s is %s got %s", + return fmt.Errorf("incorrect misbehaviour: expected client ID for consumer chain with id %d is %s got %s", consumerId, clientId, misbehaviour.ClientId, @@ -351,7 +351,7 @@ func (k Keeper) CheckMisbehaviour(ctx sdk.Context, consumerId string, misbehavio if evidenceHeight < minHeight { return errorsmod.Wrapf( vaastypes.ErrInvalidDoubleVotingEvidence, - "evidence for consumer chain %s is too old - evidence height (%d), min (%d)", + "evidence for consumer chain %d is too old - evidence height (%d), min (%d)", consumerId, evidenceHeight, minHeight, diff --git a/x/vaas/provider/keeper/consumer_equivocation_test.go b/x/vaas/provider/keeper/consumer_equivocation_test.go index 97ff8ec..5e9803a 100644 --- a/x/vaas/provider/keeper/consumer_equivocation_test.go +++ b/x/vaas/provider/keeper/consumer_equivocation_test.go @@ -27,7 +27,7 @@ func TestVerifyDoubleVotingEvidence(t *testing.T) { keeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - chainID := CONSUMER_CHAIN_ID + const chainID = "chain-0" signer1 := tmtypes.NewMockPV() signer2 := tmtypes.NewMockPV() @@ -789,20 +789,20 @@ func TestSlashValidatorDoesNotSlashIfValidatorIsUnbonded(t *testing.T) { } func TestEquivocationEvidenceMinHeightCRUD(t *testing.T) { - chainID := CONSUMER_CHAIN_ID + consumerID := CONSUMER_ID expMinHeight := uint64(12) keeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - height := keeper.GetEquivocationEvidenceMinHeight(ctx, chainID) + height := keeper.GetEquivocationEvidenceMinHeight(ctx, consumerID) require.Zero(t, height, "equivocation evidence min height should be 0") - keeper.SetEquivocationEvidenceMinHeight(ctx, chainID, expMinHeight) - height = keeper.GetEquivocationEvidenceMinHeight(ctx, chainID) + keeper.SetEquivocationEvidenceMinHeight(ctx, consumerID, expMinHeight) + height = keeper.GetEquivocationEvidenceMinHeight(ctx, consumerID) require.Equal(t, height, expMinHeight) - keeper.DeleteEquivocationEvidenceMinHeight(ctx, chainID) - height = keeper.GetEquivocationEvidenceMinHeight(ctx, chainID) + keeper.DeleteEquivocationEvidenceMinHeight(ctx, consumerID) + height = keeper.GetEquivocationEvidenceMinHeight(ctx, consumerID) require.Zero(t, height, "equivocation evidence min height should be 0") } diff --git a/x/vaas/provider/keeper/consumer_lifecycle.go b/x/vaas/provider/keeper/consumer_lifecycle.go index 9b54edc..d4d9360 100644 --- a/x/vaas/provider/keeper/consumer_lifecycle.go +++ b/x/vaas/provider/keeper/consumer_lifecycle.go @@ -24,7 +24,7 @@ import ( // PrepareConsumerForLaunch prepares to move the launch of a consumer chain from the previous spawn time to spawn time. // Previous spawn time can correspond to its zero value if the validator was not previously set for launch. -func (k Keeper) PrepareConsumerForLaunch(ctx sdk.Context, consumerId string, previousSpawnTime, spawnTime time.Time) error { +func (k Keeper) PrepareConsumerForLaunch(ctx sdk.Context, consumerId uint64, previousSpawnTime, spawnTime time.Time) error { if !previousSpawnTime.IsZero() { // if this is not the first initialization and hence `previousSpawnTime` does not contain the zero value of `Time` // remove the consumer id from the previous spawn time @@ -38,7 +38,7 @@ func (k Keeper) PrepareConsumerForLaunch(ctx sdk.Context, consumerId string, pre // InitializeConsumer tries to move a consumer with `consumerId` to the initialized phase. // If successful, it returns the spawn time and true. -func (k Keeper) InitializeConsumer(ctx sdk.Context, consumerId string) (time.Time, bool) { +func (k Keeper) InitializeConsumer(ctx sdk.Context, consumerId uint64) (time.Time, bool) { // a chain needs to be in the registered or initialized phase phase := k.GetConsumerPhase(ctx, consumerId) if phase != types.CONSUMER_PHASE_REGISTERED && phase != types.CONSUMER_PHASE_INITIALIZED { @@ -95,12 +95,12 @@ func (k Keeper) BeginBlockLaunchConsumers(ctx sdk.Context) error { initializationRecord, err := k.GetConsumerInitializationParameters(ctx, consumerId) if err != nil { return errorsmod.Wrapf(vaastypes.ErrInvalidConsumerState, - "getting initialization parameters, consumerId(%s): %s", consumerId, err.Error()) + "getting initialization parameters, consumerId(%d): %s", consumerId, err.Error()) } initializationRecord.SpawnTime = time.Time{} err = k.SetConsumerInitializationParameters(ctx, consumerId, initializationRecord) if err != nil { - return fmt.Errorf("setting consumer initialization parameters, consumerId(%s): %w", consumerId, err) + return fmt.Errorf("setting consumer initialization parameters, consumerId(%d): %w", consumerId, err) } // also set the phase to registered k.SetConsumerPhase(ctx, consumerId, types.CONSUMER_PHASE_REGISTERED) @@ -120,11 +120,11 @@ func (k Keeper) ConsumeIdsFromTimeQueue( timeQueue collections.Map[[]byte, types.ConsumerIds], getIds func(context.Context, time.Time) (types.ConsumerIds, error), deleteAllIds func(context.Context, time.Time), - appendId func(context.Context, string, time.Time) error, + appendId func(context.Context, uint64, time.Time) error, limit int, -) ([]string, error) { - result := []string{} - nextTime := []string{} +) ([]uint64, error) { + result := []uint64{} + nextTime := []uint64{} timestampsToDelete := []time.Time{} iter, err := timeQueue.Iterate(ctx, nil) @@ -181,7 +181,7 @@ func (k Keeper) ConsumeIdsFromTimeQueue( err := appendId(ctx, consumerId, ts) if err != nil { return result, - fmt.Errorf("failed to append consumer id, consumerId(%s), ts(%s): %w", + fmt.Errorf("failed to append consumer id, consumerId(%d), ts(%s): %w", consumerId, ts.String(), err) } } @@ -192,17 +192,17 @@ func (k Keeper) ConsumeIdsFromTimeQueue( } // HasActiveConsumerValidator checks whether at least one active validator is opted in to chain with `consumerId` -func (k Keeper) HasActiveConsumerValidator(ctx sdk.Context, consumerId string, activeValidators []stakingtypes.Validator) (bool, error) { +func (k Keeper) HasActiveConsumerValidator(ctx sdk.Context, consumerId uint64, activeValidators []stakingtypes.Validator) (bool, error) { currentValidatorSet, err := k.GetConsumerValSet(ctx, consumerId) if err != nil { - return false, fmt.Errorf("getting consumer validator set of chain with consumerId (%s): %w", consumerId, err) + return false, fmt.Errorf("getting consumer validator set of chain with consumerId (%d): %w", consumerId, err) } isActiveValidator := make(map[string]bool) for _, val := range activeValidators { consAddr, err := val.GetConsAddr() if err != nil { - return false, fmt.Errorf("getting consensus address of validator (%+v), consumerId (%s): %w", val, consumerId, err) + return false, fmt.Errorf("getting consensus address of validator (%+v), consumerId (%d): %w", val, consumerId, err) } providerConsAddr := types.NewProviderConsAddress(consAddr) isActiveValidator[providerConsAddr.String()] = true @@ -223,31 +223,31 @@ func (k Keeper) HasActiveConsumerValidator(ctx sdk.Context, consumerId string, a func (k Keeper) LaunchConsumer( ctx sdk.Context, bondedValidators []stakingtypes.Validator, - consumerId string, + consumerId uint64, ) error { initializationRecord, err := k.GetConsumerInitializationParameters(ctx, consumerId) if err != nil { - return fmt.Errorf("getting initialization parameters, consumerId(%s): %w", consumerId, err) + return fmt.Errorf("getting initialization parameters, consumerId(%d): %w", consumerId, err) } // compute consumer initial validator set (all validators validate all consumers) initialValUpdates, err := k.ComputeConsumerNextValSet(ctx, bondedValidators, consumerId, []types.ConsensusValidator{}) if err != nil { - return fmt.Errorf("computing consumer next validator set, consumerId(%s): %w", consumerId, err) + return fmt.Errorf("computing consumer next validator set, consumerId(%d): %w", consumerId, err) } if len(initialValUpdates) == 0 { - return fmt.Errorf("cannot launch consumer with no consumer validator, consumerId(%s)", consumerId) + return fmt.Errorf("cannot launch consumer with no consumer validator, consumerId(%d)", consumerId) } // create consumer genesis genesisState, err := k.MakeConsumerGenesis(ctx, consumerId, initialValUpdates) if err != nil { - return fmt.Errorf("creating consumer genesis state, consumerId(%s): %w", consumerId, err) + return fmt.Errorf("creating consumer genesis state, consumerId(%d): %w", consumerId, err) } err = k.SetConsumerGenesis(ctx, consumerId, genesisState) if err != nil { - return fmt.Errorf("setting consumer genesis state, consumerId(%s): %w", consumerId, err) + return fmt.Errorf("setting consumer genesis state, consumerId(%d): %w", consumerId, err) } k.SetEquivocationEvidenceMinHeight(ctx, consumerId, initializationRecord.InitialHeight.RevisionHeight) @@ -266,13 +266,13 @@ func (k Keeper) LaunchConsumer( // as well as the validator hash of the initial validator set of the consumer chain func (k Keeper) MakeConsumerGenesis( ctx sdk.Context, - consumerId string, + consumerId uint64, initialValidatorUpdates []abci.ValidatorUpdate, ) (gen vaastypes.ConsumerGenesisState, err error) { initializationRecord, err := k.GetConsumerInitializationParameters(ctx, consumerId) if err != nil { return gen, errorsmod.Wrapf(vaastypes.ErrInvalidConsumerState, - "getting initialization parameters, consumerId(%s): %s", consumerId, err.Error()) + "getting initialization parameters, consumerId(%d): %s", consumerId, err.Error()) } // Create consumer genesis params consumerGenesisParams := vaastypes.NewParams( @@ -336,7 +336,7 @@ func (k Keeper) getSelfConsensusState(ctx sdk.Context, height clienttypes.Height // StopAndPrepareForConsumerRemoval sets the phase of the chain to stopped and prepares to get the state of the // chain removed after unbonding period elapses -func (k Keeper) StopAndPrepareForConsumerRemoval(ctx sdk.Context, consumerId string) error { +func (k Keeper) StopAndPrepareForConsumerRemoval(ctx sdk.Context, consumerId uint64) error { // The phase of the chain is immediately set to stopped, albeit its state is removed later (see below). // Setting the phase here helps in not considering this chain when we look at launched chains (e.g., in `QueueVSCPackets) k.SetConsumerPhase(ctx, consumerId, types.CONSUMER_PHASE_STOPPED) @@ -388,10 +388,10 @@ func (k Keeper) BeginBlockRemoveConsumers(ctx sdk.Context) error { } // DeleteConsumerChain cleans up the state of the given consumer chain. -func (k Keeper) DeleteConsumerChain(ctx sdk.Context, consumerId string) (err error) { +func (k Keeper) DeleteConsumerChain(ctx sdk.Context, consumerId uint64) (err error) { phase := k.GetConsumerPhase(ctx, consumerId) if phase != types.CONSUMER_PHASE_STOPPED { - return fmt.Errorf("cannot delete non-stopped chain: %s", consumerId) + return fmt.Errorf("cannot delete non-stopped chain: %d", consumerId) } // clean up states diff --git a/x/vaas/provider/keeper/debt.go b/x/vaas/provider/keeper/debt.go index 2d6b78a..400bde8 100644 --- a/x/vaas/provider/keeper/debt.go +++ b/x/vaas/provider/keeper/debt.go @@ -10,33 +10,33 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -func (k Keeper) IsConsumerInDebt(ctx context.Context, consumerId string) bool { +func (k Keeper) IsConsumerInDebt(ctx context.Context, consumerId uint64) bool { inDebt, err := k.ConsumerDebt.Get(ctx, consumerId) if err != nil { if errors.Is(err, collections.ErrNotFound) { return false } - panic(fmt.Errorf("failed to read consumer debt status for %s: %w", consumerId, err)) + panic(fmt.Errorf("failed to read consumer debt status for %d: %w", consumerId, err)) } return inDebt } -func (k Keeper) SetConsumerInDebt(ctx context.Context, consumerId string, inDebt bool) { +func (k Keeper) SetConsumerInDebt(ctx context.Context, consumerId uint64, inDebt bool) { if err := k.ConsumerDebt.Set(ctx, consumerId, inDebt); err != nil { - panic(fmt.Errorf("failed to set consumer debt status for %s: %w", consumerId, err)) + panic(fmt.Errorf("failed to set consumer debt status for %d: %w", consumerId, err)) } } -func (k Keeper) DeleteConsumerDebt(ctx context.Context, consumerId string) { +func (k Keeper) DeleteConsumerDebt(ctx context.Context, consumerId uint64) { if err := k.ConsumerDebt.Remove(ctx, consumerId); err != nil && !errors.Is(err, collections.ErrNotFound) { - panic(fmt.Errorf("failed to delete consumer debt status for %s: %w", consumerId, err)) + panic(fmt.Errorf("failed to delete consumer debt status for %d: %w", consumerId, err)) } } // UpdateConsumerDebtStatus persists a new debt state and logs state transitions. // The updated flag reaches the consumer on the next epoch VSC packet, which // piggybacks the current debt state on the normal validator-set change flow. -func (k Keeper) UpdateConsumerDebtStatus(ctx sdk.Context, consumerId string, inDebt bool) { +func (k Keeper) UpdateConsumerDebtStatus(ctx sdk.Context, consumerId uint64, inDebt bool) { if k.IsConsumerInDebt(ctx, consumerId) == inDebt { return } diff --git a/x/vaas/provider/keeper/fees.go b/x/vaas/provider/keeper/fees.go index 6bc5417..15b7502 100644 --- a/x/vaas/provider/keeper/fees.go +++ b/x/vaas/provider/keeper/fees.go @@ -19,8 +19,8 @@ import ( // GetConsumerFeePoolAddress returns the deterministic provider-side fee pool // account for a consumer. This is a plain account address used for fee funding, // not a registered module account in the app's module-account permissions. -func (k Keeper) GetConsumerFeePoolAddress(consumerId string) sdk.AccAddress { - return authtypes.NewModuleAddress(fmt.Sprintf("%s-consumer-fee-pool-%s", types.ModuleName, consumerId)) +func (k Keeper) GetConsumerFeePoolAddress(consumerId uint64) sdk.AccAddress { + return authtypes.NewModuleAddress(fmt.Sprintf("%s-consumer-fee-pool-%d", types.ModuleName, consumerId)) } // CollectFeesFromConsumers collects fees from all active consumer chains. diff --git a/x/vaas/provider/keeper/genesis.go b/x/vaas/provider/keeper/genesis.go index 1cf8619..473a2e7 100644 --- a/x/vaas/provider/keeper/genesis.go +++ b/x/vaas/provider/keeper/genesis.go @@ -1,59 +1,145 @@ package keeper import ( + "errors" "fmt" + "reflect" "github.com/allinbits/vaas/x/vaas/provider/types" vaastypes "github.com/allinbits/vaas/x/vaas/types" abci "github.com/cometbft/cometbft/abci/types" + "cosmossdk.io/collections" + sdk "github.com/cosmos/cosmos-sdk/types" ) -// InitGenesis initializes the CCV provider state. +// InitGenesis initializes the VAAS provider state from a GenesisState. +// +// Per-consumer state (owner, metadata, init params, removal time, client id, +// consumer genesis) is read directly from each ConsumerState, keyed by the +// canonical consumer id carried in cs.ConsumerId. The keeper's derived +// collections (spawn-time queue, removal-time queue, equivocation evidence +// min height) are then reconstructed in a second pass from the per-consumer +// fields. ConsumerDebt is left unset; the first BeginBlock after import +// re-derives it from the fee pool balance. After all consumers are imported, +// the ConsumerId sequence counter is advanced past the highest imported id +// so subsequent MsgCreateConsumer calls do not collide with the imported +// records. func (k Keeper) InitGenesis(ctx sdk.Context, genState *types.GenesisState) []abci.ValidatorUpdate { k.SetValidatorSetUpdateId(ctx, genState.ValsetUpdateId) for _, v2h := range genState.ValsetUpdateIdToHeight { k.SetValsetUpdateBlockHeight(ctx, v2h.ValsetUpdateId, v2h.Height) } - // Set initial state for each consumer chain - for _, cs := range genState.ConsumerStates { - chainID := cs.ChainId + // First pass: write all per-consumer keeper collections under the + // provided consumer id from each ConsumerState. + maxConsumerId := uint64(0) + for i := range genState.ConsumerStates { + cs := &genState.ConsumerStates[i] + consumerId := cs.ConsumerId + + // Track the highest imported consumer id so we can advance the keeper's + // ConsumerId sequence past it below; future MsgCreateConsumer calls + // then won't collide with the imported records. + if consumerId > maxConsumerId { + maxConsumerId = consumerId + } + + k.SetConsumerChainId(ctx, consumerId, cs.ChainId) + k.SetConsumerPhase(ctx, consumerId, cs.Phase) + + if cs.OwnerAddress != "" { + k.SetConsumerOwnerAddress(ctx, consumerId, cs.OwnerAddress) + } + if cs.Metadata != nil { + if err := k.SetConsumerMetadata(ctx, consumerId, *cs.Metadata); err != nil { + panic(fmt.Errorf("init: set metadata for %d: %w", consumerId, err)) + } + } + if cs.InitParams != nil { + if err := k.SetConsumerInitializationParameters(ctx, consumerId, *cs.InitParams); err != nil { + panic(fmt.Errorf("init: set init params for %d: %w", consumerId, err)) + } + } if cs.ClientId != "" { - k.SetConsumerClientId(ctx, chainID, cs.ClientId) + k.SetConsumerClientId(ctx, consumerId, cs.ClientId) + } + // reflect.DeepEqual is used here because ConsumerGenesisState + // transitively references types from cometbft/ibc-go that do not + // have a generated Equal method, so we can't enable + // gogoproto.equal_all on its proto file. + if !reflect.DeepEqual(cs.ConsumerGenesis, vaastypes.ConsumerGenesisState{}) { + if err := k.SetConsumerGenesis(ctx, consumerId, cs.ConsumerGenesis); err != nil { + panic(fmt.Errorf("init: set consumer genesis for %d: %w", consumerId, err)) + } + } + if cs.RemovalTime != nil { + if err := k.SetConsumerRemovalTime(ctx, consumerId, *cs.RemovalTime); err != nil { + panic(fmt.Errorf("init: set removal time for %d: %w", consumerId, err)) + } + } + if len(cs.PendingValsetChanges) > 0 { + k.AppendPendingVSCPackets(ctx, consumerId, cs.PendingValsetChanges...) + } + } + + // Second pass: derive queue and equivocation-min-height state from the + // per-consumer fields just written. + for i := range genState.ConsumerStates { + cs := &genState.ConsumerStates[i] + consumerId := cs.ConsumerId + + switch cs.Phase { + case types.CONSUMER_PHASE_INITIALIZED: + if cs.InitParams != nil { + if err := k.AppendConsumerToBeLaunched(ctx, consumerId, cs.InitParams.SpawnTime); err != nil { + panic(fmt.Errorf("init: enqueue spawn for %d: %w", consumerId, err)) + } + } + case types.CONSUMER_PHASE_LAUNCHED: + if cs.InitParams != nil { + k.SetEquivocationEvidenceMinHeight(ctx, consumerId, cs.InitParams.InitialHeight.RevisionHeight) + } + case types.CONSUMER_PHASE_STOPPED: + if cs.InitParams != nil { + k.SetEquivocationEvidenceMinHeight(ctx, consumerId, cs.InitParams.InitialHeight.RevisionHeight) + } + if cs.RemovalTime != nil { + if err := k.AppendConsumerToBeRemoved(ctx, consumerId, *cs.RemovalTime); err != nil { + panic(fmt.Errorf("init: enqueue removal for %d: %w", consumerId, err)) + } + } } - k.SetConsumerPhase(ctx, chainID, cs.Phase) - if err := k.SetConsumerGenesis(ctx, chainID, cs.ConsumerGenesis); err != nil { - // An error here would indicate something is very wrong, - // the ConsumerGenesis validated in ConsumerState.Validate(). - panic(fmt.Errorf("consumer chain genesis could not be persisted: %w", err)) + } + + // Advance the ConsumerId sequence past the highest imported id so + // MsgCreateConsumer's next FetchAndIncrementConsumerId does not collide. + if len(genState.ConsumerStates) > 0 { + if err := k.ConsumerId.Set(ctx, maxConsumerId+1); err != nil { + panic(fmt.Errorf("init: advance consumer id sequence to %d: %w", maxConsumerId+1, err)) } - k.AppendPendingVSCPackets(ctx, chainID, cs.PendingValsetChanges...) } // Import key assignment state for _, item := range genState.ValidatorConsumerPubkeys { providerAddr := types.NewProviderConsAddress(item.ProviderAddr) - k.SetValidatorConsumerPubKey(ctx, item.ChainId, providerAddr, *item.ConsumerKey) + k.SetValidatorConsumerPubKey(ctx, item.ConsumerId, providerAddr, *item.ConsumerKey) } - for _, item := range genState.ValidatorsByConsumerAddr { consumerAddr := types.NewConsumerConsAddress(item.ConsumerAddr) providerAddr := types.NewProviderConsAddress(item.ProviderAddr) - k.SetValidatorByConsumerAddr(ctx, item.ChainId, consumerAddr, providerAddr) + k.SetValidatorByConsumerAddr(ctx, item.ConsumerId, consumerAddr, providerAddr) } - for _, item := range genState.ConsumerAddrsToPrune { for _, addr := range item.ConsumerAddrs.Addresses { consumerAddr := types.NewConsumerConsAddress(addr) - k.AppendConsumerAddrsToPrune(ctx, item.ChainId, item.PruneTs, consumerAddr) + k.AppendConsumerAddrsToPrune(ctx, item.ConsumerId, item.PruneTs, consumerAddr) } } k.SetParams(ctx, genState.Params) - return k.InitGenesisValUpdates(ctx) } @@ -99,47 +185,83 @@ func (k Keeper) InitGenesisValUpdates(ctx sdk.Context) []abci.ValidatorUpdate { return valUpdates } -// ExportGenesis returns the CCV provider module's exported genesis +// ExportGenesis returns the VAAS provider module's exported genesis +// +// Per-consumer state is exported for every consumer id (across all phases +// including DELETED) so that state-export software upgrades preserve the +// audit trail that the keeper itself maintains (see DeleteConsumerChain in +// consumer_lifecycle.go for the policy of keeping owner/metadata/init_params +// past deletion). +// +// Spawn-time queue, removal-time queue, equivocation-evidence-min-height, +// and per-consumer debt are NOT exported because they are derivable from +// the per-consumer fields above and / or other module state at InitGenesis. func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { - activeConsumerIds := k.GetAllActiveConsumerIds(ctx) + allConsumerIds := k.GetAllConsumerIds(ctx) - // export states for each consumer chains - var consumerStates []types.ConsumerState - for _, consumerId := range activeConsumerIds { - clientId, _ := k.GetConsumerClientId(ctx, consumerId) + consumerStates := make([]types.ConsumerState, 0, len(allConsumerIds)) + for _, consumerId := range allConsumerIds { phase := k.GetConsumerPhase(ctx, consumerId) - gen, found := k.GetConsumerGenesis(ctx, consumerId) - if !found { - if phase != types.CONSUMER_PHASE_REGISTERED && phase != types.CONSUMER_PHASE_INITIALIZED { - panic(fmt.Errorf("cannot find genesis for consumer chain %s in phase %d", consumerId, phase)) - } - gen = *vaastypes.DefaultConsumerGenesisState() + + chainId, err := k.GetConsumerChainId(ctx, consumerId) + if err != nil { + panic(fmt.Errorf("export: failed to read chain id for consumer %d: %w", consumerId, err)) } cs := types.ConsumerState{ - ChainId: consumerId, - ClientId: clientId, - ConsumerGenesis: gen, + ConsumerId: consumerId, + ChainId: chainId, Phase: phase, PendingValsetChanges: k.GetPendingVSCPackets(ctx, consumerId), } + + if owner, err := k.GetConsumerOwnerAddress(ctx, consumerId); err == nil { + cs.OwnerAddress = owner + } else if !errors.Is(err, collections.ErrNotFound) { + panic(fmt.Errorf("export: failed to read owner for consumer %d: %w", consumerId, err)) + } + + if md, err := k.GetConsumerMetadata(ctx, consumerId); err == nil { + cs.Metadata = &md + } else if !errors.Is(err, collections.ErrNotFound) { + panic(fmt.Errorf("export: failed to read metadata for consumer %d: %w", consumerId, err)) + } + + if ip, err := k.GetConsumerInitializationParameters(ctx, consumerId); err == nil { + cs.InitParams = &ip + } else if !errors.Is(err, collections.ErrNotFound) { + panic(fmt.Errorf("export: failed to read init params for consumer %d: %w", consumerId, err)) + } + + if clientId, ok := k.GetConsumerClientId(ctx, consumerId); ok { + cs.ClientId = clientId + } + if gen, ok := k.GetConsumerGenesis(ctx, consumerId); ok { + cs.ConsumerGenesis = gen + } + + if rt, err := k.GetConsumerRemovalTime(ctx, consumerId); err == nil { + rtCopy := rt // copy to avoid aliasing the loop-local variable + cs.RemovalTime = &rtCopy + } else if !errors.Is(err, collections.ErrNotFound) { + panic(fmt.Errorf("export: failed to read removal time for consumer %d: %w", consumerId, err)) + } + consumerStates = append(consumerStates, cs) } - // ConsumerAddrsToPrune are added only for registered consumer chains consumerAddrsToPrune := []types.ConsumerAddrsToPrune{} - for _, chainID := range activeConsumerIds { - consumerAddrsToPrune = append(consumerAddrsToPrune, k.GetAllConsumerAddrsToPrune(ctx, chainID)...) + for _, consumerId := range allConsumerIds { + consumerAddrsToPrune = append(consumerAddrsToPrune, + k.GetAllConsumerAddrsToPrune(ctx, consumerId)...) } - params := k.GetParams(ctx) - // TODO (PERMISSIONLESS) return types.NewGenesisState( k.GetValidatorSetUpdateId(ctx), k.GetAllValsetUpdateBlockHeights(ctx), consumerStates, - params, + k.GetParams(ctx), k.GetAllValidatorConsumerPubKeys(ctx, nil), k.GetAllValidatorsByConsumerAddr(ctx, nil), consumerAddrsToPrune, diff --git a/x/vaas/provider/keeper/genesis_test.go b/x/vaas/provider/keeper/genesis_test.go index 4b17397..5114d75 100644 --- a/x/vaas/provider/keeper/genesis_test.go +++ b/x/vaas/provider/keeper/genesis_test.go @@ -1,12 +1,23 @@ package keeper_test import ( + "fmt" + "sort" "testing" + "time" "github.com/stretchr/testify/require" + "go.uber.org/mock/gomock" + clienttypes "github.com/cosmos/ibc-go/v10/modules/core/02-client/types" + + sdk "github.com/cosmos/cosmos-sdk/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + + cryptotestutil "github.com/allinbits/vaas/testutil/crypto" testkeeper "github.com/allinbits/vaas/testutil/keeper" providertypes "github.com/allinbits/vaas/x/vaas/provider/types" + vaastypes "github.com/allinbits/vaas/x/vaas/types" ) func TestExportGenesis_ConsumerWithoutGenesis(t *testing.T) { @@ -16,12 +27,13 @@ func TestExportGenesis_ConsumerWithoutGenesis(t *testing.T) { pk.SetParams(ctx, providertypes.DefaultParams()) consumerId := pk.FetchAndIncrementConsumerId(ctx) + pk.SetConsumerChainId(ctx, consumerId, fmt.Sprintf("chain-%d", consumerId)) pk.SetConsumerPhase(ctx, consumerId, providertypes.CONSUMER_PHASE_REGISTERED) genState := pk.ExportGenesis(ctx) require.NotNil(t, genState) require.Len(t, genState.ConsumerStates, 1) - require.Equal(t, consumerId, genState.ConsumerStates[0].ChainId) + require.Equal(t, fmt.Sprintf("chain-%d", consumerId), genState.ConsumerStates[0].ChainId) require.Equal(t, providertypes.CONSUMER_PHASE_REGISTERED, genState.ConsumerStates[0].Phase) require.Equal(t, "", genState.ConsumerStates[0].ClientId) } @@ -33,25 +45,361 @@ func TestExportGenesis_InitializedConsumerWithoutGenesis(t *testing.T) { pk.SetParams(ctx, providertypes.DefaultParams()) consumerId := pk.FetchAndIncrementConsumerId(ctx) + pk.SetConsumerChainId(ctx, consumerId, fmt.Sprintf("chain-%d", consumerId)) pk.SetConsumerPhase(ctx, consumerId, providertypes.CONSUMER_PHASE_INITIALIZED) genState := pk.ExportGenesis(ctx) require.NotNil(t, genState) require.Len(t, genState.ConsumerStates, 1) - require.Equal(t, consumerId, genState.ConsumerStates[0].ChainId) + require.Equal(t, fmt.Sprintf("chain-%d", consumerId), genState.ConsumerStates[0].ChainId) require.Equal(t, providertypes.CONSUMER_PHASE_INITIALIZED, genState.ConsumerStates[0].Phase) } -func TestExportGenesis_LaunchedConsumerWithoutGenesisPanics(t *testing.T) { +func TestExportGenesisIncludesNewFields(t *testing.T) { pk, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() + owner := sdk.AccAddress([]byte("vaas-test-owner-1234")).String() + metadata := providertypes.ConsumerMetadata{Name: "n", Description: "d", Metadata: "m"} + initParams := providertypes.ConsumerInitializationParameters{ + InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 42}, + GenesisHash: []byte("g"), + BinaryHash: []byte("b"), + SpawnTime: time.Unix(1_700_000_000, 0).UTC(), + UnbondingPeriod: time.Hour, + VaasTimeoutPeriod: time.Hour, + HistoricalEntries: 10, + } + removalTime := time.Unix(1_800_000_000, 0).UTC() + cg := *vaastypes.DefaultConsumerGenesisState() + cg.NewChain = true + + // Chain IDs use a non-numeric suffix so ParseChainID returns revision 0 for + // all of them, letting a single initParams (RevisionNumber: 0) pass Validate(). + chainIDs := []string{"consumer-alpha", "consumer-beta", "consumer-gamma", "consumer-delta", "consumer-epsilon"} + + // Allocate five consumer ids ("0".."4") and set their chain ids. + for i := range 5 { + id := pk.FetchAndIncrementConsumerId(ctx) + pk.SetConsumerChainId(ctx, id, chainIDs[i]) + } + + // id 0 REGISTERED. + pk.SetConsumerPhase(ctx, 0, providertypes.CONSUMER_PHASE_REGISTERED) + pk.SetConsumerOwnerAddress(ctx, 0, owner) + require.NoError(t, pk.SetConsumerMetadata(ctx, 0, metadata)) + + // id 1 INITIALIZED. + pk.SetConsumerPhase(ctx, 1, providertypes.CONSUMER_PHASE_INITIALIZED) + pk.SetConsumerOwnerAddress(ctx, 1, owner) + require.NoError(t, pk.SetConsumerMetadata(ctx, 1, metadata)) + require.NoError(t, pk.SetConsumerInitializationParameters(ctx, 1, initParams)) + + // id 2 LAUNCHED. + pk.SetConsumerPhase(ctx, 2, providertypes.CONSUMER_PHASE_LAUNCHED) + pk.SetConsumerOwnerAddress(ctx, 2, owner) + require.NoError(t, pk.SetConsumerMetadata(ctx, 2, metadata)) + require.NoError(t, pk.SetConsumerInitializationParameters(ctx, 2, initParams)) + pk.SetConsumerClientId(ctx, 2, "07-tendermint-0") + require.NoError(t, pk.SetConsumerGenesis(ctx, 2, cg)) + + // id 3 STOPPED. + pk.SetConsumerPhase(ctx, 3, providertypes.CONSUMER_PHASE_STOPPED) + pk.SetConsumerOwnerAddress(ctx, 3, owner) + require.NoError(t, pk.SetConsumerMetadata(ctx, 3, metadata)) + require.NoError(t, pk.SetConsumerInitializationParameters(ctx, 3, initParams)) + pk.SetConsumerClientId(ctx, 3, "07-tendermint-1") + require.NoError(t, pk.SetConsumerGenesis(ctx, 3, cg)) + require.NoError(t, pk.SetConsumerRemovalTime(ctx, 3, removalTime)) + + // id 4 DELETED. + pk.SetConsumerPhase(ctx, 4, providertypes.CONSUMER_PHASE_DELETED) + pk.SetConsumerOwnerAddress(ctx, 4, owner) + require.NoError(t, pk.SetConsumerMetadata(ctx, 4, metadata)) + require.NoError(t, pk.SetConsumerInitializationParameters(ctx, 4, initParams)) + pk.SetParams(ctx, providertypes.DefaultParams()) + pk.SetValidatorSetUpdateId(ctx, 1) - consumerId := pk.FetchAndIncrementConsumerId(ctx) - pk.SetConsumerPhase(ctx, consumerId, providertypes.CONSUMER_PHASE_LAUNCHED) + got := pk.ExportGenesis(ctx) + require.NoError(t, got.Validate()) + + require.Len(t, got.ConsumerStates, 5, "all five phases must be exported (including DELETED)") + + byID := map[string]providertypes.ConsumerState{} + for _, cs := range got.ConsumerStates { + byID[cs.ChainId] = cs + } + + for _, id := range chainIDs { + cs, ok := byID[id] + require.True(t, ok, "consumer %s missing from export", id) + require.Equal(t, owner, cs.OwnerAddress, "owner missing on consumer %s", id) + require.NotNil(t, cs.Metadata, "metadata missing on consumer %s", id) + } + + require.Nil(t, byID["consumer-alpha"].InitParams, "REGISTERED must not have init_params") + require.NotNil(t, byID["consumer-beta"].InitParams, "INITIALIZED must have init_params") + require.Equal(t, "07-tendermint-0", byID["consumer-gamma"].ClientId, "LAUNCHED must have client_id") + require.NotNil(t, byID["consumer-delta"].RemovalTime, "STOPPED must carry removal_time") + require.Equal(t, removalTime, *byID["consumer-delta"].RemovalTime) + require.Equal(t, providertypes.CONSUMER_PHASE_DELETED, byID["consumer-epsilon"].Phase) +} + +func TestInitGenesisRestoresPerConsumerStateAndDerivedQueues(t *testing.T) { + pk, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + // InitGenesis calls InitGenesisValUpdates which queries the bonded validator set. + // MaxValidators is not called (GetMaxProviderConsensusValidators reads from keeper params), + // so we only expect GetBondedValidatorsByPower once. + mocks.MockStakingKeeper.EXPECT().GetBondedValidatorsByPower(gomock.Any()).Return([]stakingtypes.Validator{}, nil).Times(1) + + owner := sdk.AccAddress([]byte("vaas-test-owner-1234")).String() + md := providertypes.ConsumerMetadata{Name: "n", Description: "d", Metadata: "m"} + spawnAt := time.Unix(1_700_000_000, 0).UTC() + removeAt := time.Unix(1_800_000_000, 0).UTC() + initialHeight := clienttypes.Height{RevisionNumber: 0, RevisionHeight: 42} + ip := providertypes.ConsumerInitializationParameters{ + InitialHeight: initialHeight, + GenesisHash: []byte("g"), + BinaryHash: []byte("b"), + SpawnTime: spawnAt, + UnbondingPeriod: time.Hour, + VaasTimeoutPeriod: time.Hour, + HistoricalEntries: 10, + } + cg := *vaastypes.DefaultConsumerGenesisState() + cg.NewChain = true + + gs := &providertypes.GenesisState{ + ValsetUpdateId: 1, + Params: providertypes.DefaultParams(), + ConsumerStates: []providertypes.ConsumerState{ + {ConsumerId: 0, ChainId: "consumer-alpha", Phase: providertypes.CONSUMER_PHASE_REGISTERED, + OwnerAddress: owner, Metadata: &md}, + {ConsumerId: 1, ChainId: "consumer-beta", Phase: providertypes.CONSUMER_PHASE_INITIALIZED, + OwnerAddress: owner, Metadata: &md, InitParams: &ip}, + {ConsumerId: 2, ChainId: "consumer-gamma", Phase: providertypes.CONSUMER_PHASE_LAUNCHED, + OwnerAddress: owner, Metadata: &md, InitParams: &ip, + ClientId: "07-tendermint-0", ConsumerGenesis: cg}, + {ConsumerId: 3, ChainId: "consumer-delta", Phase: providertypes.CONSUMER_PHASE_STOPPED, + OwnerAddress: owner, Metadata: &md, InitParams: &ip, + ClientId: "07-tendermint-1", ConsumerGenesis: cg, RemovalTime: &removeAt}, + {ConsumerId: 4, ChainId: "consumer-epsilon", Phase: providertypes.CONSUMER_PHASE_DELETED, + OwnerAddress: owner, Metadata: &md, InitParams: &ip}, + }, + } + + require.NoError(t, gs.Validate(), "test fixture must validate") + + _ = pk.InitGenesis(ctx, gs) + + // Sanity check: the sequence counter must have advanced so that + // GetAllConsumerIds returns all 5 imported consumers. + allIds := pk.GetAllConsumerIds(ctx) + require.Equal(t, []uint64{0, 1, 2, 3, 4}, allIds, + "GetAllConsumerIds must return all imported consumer ids in order") - require.Panics(t, func() { - pk.ExportGenesis(ctx) + // ConsumerStates are imported in order; InitGenesis allocates numeric ids + // starting at "0": + // "0" → consumer-alpha (REGISTERED) + // "1" → consumer-beta (INITIALIZED) + // "2" → consumer-gamma (LAUNCHED) + // "3" → consumer-delta (STOPPED) + // "4" → consumer-epsilon (DELETED) + idChain := []struct { + consumerId uint64 + chainId string + }{ + {0, "consumer-alpha"}, + {1, "consumer-beta"}, + {2, "consumer-gamma"}, + {3, "consumer-delta"}, + {4, "consumer-epsilon"}, + } + + // Per-consumer fields: chain id, owner, metadata must be present on all five. + for _, entry := range idChain { + gotChain, err := pk.GetConsumerChainId(ctx, entry.consumerId) + require.NoError(t, err, "chain id missing for consumer %d", entry.consumerId) + require.Equal(t, entry.chainId, gotChain) + + gotOwner, err := pk.GetConsumerOwnerAddress(ctx, entry.consumerId) + require.NoError(t, err, "owner missing for consumer %d", entry.consumerId) + require.Equal(t, owner, gotOwner) + + gotMd, err := pk.GetConsumerMetadata(ctx, entry.consumerId) + require.NoError(t, err, "metadata missing for consumer %d", entry.consumerId) + require.Equal(t, md, gotMd) + } + + // init_params are set on INITIALIZED, LAUNCHED, STOPPED, DELETED (ids 1–4). + for _, consumerId := range []uint64{1, 2, 3, 4} { + gotIp, err := pk.GetConsumerInitializationParameters(ctx, consumerId) + require.NoError(t, err, "init_params missing for consumer %d", consumerId) + require.Equal(t, ip, gotIp) + } + + // Spawn queue: only INITIALIZED (id 1) is enqueued at init_params.spawn_time. + spawnIds, err := pk.GetConsumersToBeLaunched(ctx, spawnAt) + require.NoError(t, err) + require.Equal(t, []uint64{1}, spawnIds.Ids) + + // Removal queue: only STOPPED (id 3) is enqueued at removal_time. + removeIds, err := pk.GetConsumersToBeRemoved(ctx, removeAt) + require.NoError(t, err) + require.Equal(t, []uint64{3}, removeIds.Ids) + + // EquivocationEvidenceMinHeight: set for LAUNCHED (2) and STOPPED (3) only. + require.Equal(t, initialHeight.RevisionHeight, pk.GetEquivocationEvidenceMinHeight(ctx, 2)) + require.Equal(t, initialHeight.RevisionHeight, pk.GetEquivocationEvidenceMinHeight(ctx, 3)) + require.Zero(t, pk.GetEquivocationEvidenceMinHeight(ctx, 0)) + require.Zero(t, pk.GetEquivocationEvidenceMinHeight(ctx, 1)) + require.Zero(t, pk.GetEquivocationEvidenceMinHeight(ctx, 4)) + + // RemovalTime: per-consumer collection set for STOPPED (id 3). + rt, err := pk.GetConsumerRemovalTime(ctx, 3) + require.NoError(t, err) + require.Equal(t, removeAt, rt) +} + +// TestGenesisRoundTrip verifies that ExportGenesis -> Validate -> fresh +// keeper -> InitGenesis -> ExportGenesis produces an equal GenesisState +// across all five consumer phases. +func TestGenesisRoundTrip(t *testing.T) { + pkA, ctxA, ctrlA, stakingA := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrlA.Finish() + + owner := sdk.AccAddress([]byte("vaas-test-owner-1234")).String() + md := providertypes.ConsumerMetadata{Name: "n", Description: "d", Metadata: "m"} + spawnAt := time.Unix(1_700_000_000, 0).UTC() + removeAt := time.Unix(1_800_000_000, 0).UTC() + ip := providertypes.ConsumerInitializationParameters{ + InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 42}, + GenesisHash: []byte("g"), + BinaryHash: []byte("b"), + SpawnTime: spawnAt, + UnbondingPeriod: time.Hour, + VaasTimeoutPeriod: time.Hour, + HistoricalEntries: 10, + } + cg := *vaastypes.DefaultConsumerGenesisState() + cg.NewChain = true + + // Seed keeper A by going through FetchAndIncrementConsumerId for each + // consumer, mirroring what production code does at MsgCreateConsumer time. + // This produces consumer ids "0".."4" in alpha..epsilon order. + type seed struct { + chainId string + phase providertypes.ConsumerPhase + clientId string + setRT bool + setSpawn bool // → enqueue spawn + setRem bool // → enqueue removal + setMinHeight + setMinHt bool // → setEquivocationEvidenceMinHeight (LAUNCHED+STOPPED) + } + seeds := []seed{ + {"consumer-alpha", providertypes.CONSUMER_PHASE_REGISTERED, "", false, false, false, false}, + {"consumer-beta", providertypes.CONSUMER_PHASE_INITIALIZED, "", false, true, false, false}, + {"consumer-gamma", providertypes.CONSUMER_PHASE_LAUNCHED, "07-tendermint-0", false, false, false, true}, + {"consumer-delta", providertypes.CONSUMER_PHASE_STOPPED, "07-tendermint-1", true, false, true, true}, + {"consumer-epsilon", providertypes.CONSUMER_PHASE_DELETED, "", false, false, false, false}, + } + for _, s := range seeds { + id := pkA.FetchAndIncrementConsumerId(ctxA) + pkA.SetConsumerChainId(ctxA, id, s.chainId) + pkA.SetConsumerPhase(ctxA, id, s.phase) + pkA.SetConsumerOwnerAddress(ctxA, id, owner) + require.NoError(t, pkA.SetConsumerMetadata(ctxA, id, md)) + // init_params present for INITIALIZED..DELETED (every phase except REGISTERED). + if s.phase != providertypes.CONSUMER_PHASE_REGISTERED { + require.NoError(t, pkA.SetConsumerInitializationParameters(ctxA, id, ip)) + } + if s.clientId != "" { + pkA.SetConsumerClientId(ctxA, id, s.clientId) + } + if s.phase == providertypes.CONSUMER_PHASE_LAUNCHED || s.phase == providertypes.CONSUMER_PHASE_STOPPED { + require.NoError(t, pkA.SetConsumerGenesis(ctxA, id, cg)) + } + if s.setRT { + require.NoError(t, pkA.SetConsumerRemovalTime(ctxA, id, removeAt)) + } + if s.setSpawn { + require.NoError(t, pkA.AppendConsumerToBeLaunched(ctxA, id, spawnAt)) + } + if s.setRem { + require.NoError(t, pkA.AppendConsumerToBeRemoved(ctxA, id, removeAt)) + } + if s.setMinHt { + pkA.SetEquivocationEvidenceMinHeight(ctxA, id, ip.InitialHeight.RevisionHeight) + } + } + // Seed one entry per consumer-id-keyed key-assignment / prune collection + // so the round-trip actually covers them. Without these entries those + // three import loops iterate over empty slices and a future regression + // that mis-keys them (e.g. anything that breaks consumer-id continuity + // between Export and Init) would pass the round-trip silently. + assignedConsumerKey := cryptotestutil.NewCryptoIdentityFromIntSeed(42).TMProtoCryptoPublicKey() + assignedProviderConsAddr := providertypes.NewProviderConsAddress([]byte("provider-addr-key-asn")) + assignedConsumerConsAddr := providertypes.NewConsumerConsAddress([]byte("consumer-addr-key-asn")) + pruneTs := time.Unix(1_900_000_000, 0).UTC() + prunedAddr := providertypes.NewConsumerConsAddress([]byte("consumer-addr-to-prune-x")) + + // Seed on consumer 2 (LAUNCHED — has a populated state to assign keys against). + const keyedConsumerID uint64 = 2 + pkA.SetValidatorConsumerPubKey(ctxA, keyedConsumerID, assignedProviderConsAddr, assignedConsumerKey) + pkA.SetValidatorByConsumerAddr(ctxA, keyedConsumerID, assignedConsumerConsAddr, assignedProviderConsAddr) + pkA.AppendConsumerAddrsToPrune(ctxA, keyedConsumerID, pruneTs, prunedAddr) + + pkA.SetParams(ctxA, providertypes.DefaultParams()) + pkA.SetValidatorSetUpdateId(ctxA, 1) + + expA := pkA.ExportGenesis(ctxA) + require.NoError(t, expA.Validate(), "first export must validate") + + // Sanity: the export must carry the key-assignment / prune entries + // keyed by the actual consumer id (matching the original alloc). + require.Len(t, expA.ValidatorConsumerPubkeys, 1) + require.Equal(t, keyedConsumerID, expA.ValidatorConsumerPubkeys[0].ConsumerId) + require.Len(t, expA.ValidatorsByConsumerAddr, 1) + require.Equal(t, keyedConsumerID, expA.ValidatorsByConsumerAddr[0].ConsumerId) + require.Len(t, expA.ConsumerAddrsToPrune, 1) + require.Equal(t, keyedConsumerID, expA.ConsumerAddrsToPrune[0].ConsumerId) + + // Fresh keeper B. + pkB, ctxB, ctrlB, stakingB := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrlB.Finish() + + // InitGenesisValUpdates reads from staking; mock it on both keepers. + stakingA.MockStakingKeeper.EXPECT().GetBondedValidatorsByPower(gomock.Any()).Return(nil, nil).AnyTimes() + stakingB.MockStakingKeeper.EXPECT().GetBondedValidatorsByPower(gomock.Any()).Return(nil, nil).AnyTimes() + + _ = pkB.InitGenesis(ctxB, expA) + + // After import, the consumer-id-keyed key-assignment state must reconnect + // to the same consumer id; this is the bug guard for the proto rename + // (chain_id → consumer_id on ValidatorConsumerPubKey / ValidatorByConsumerAddr + // / ConsumerAddrsToPrune). + gotKey, foundKey := pkB.GetValidatorConsumerPubKey(ctxB, keyedConsumerID, assignedProviderConsAddr) + require.True(t, foundKey, "ValidatorConsumerPubKey lost across round-trip") + require.Equal(t, assignedConsumerKey, gotKey) + gotProvider, foundProvider := pkB.GetValidatorByConsumerAddr(ctxB, keyedConsumerID, assignedConsumerConsAddr) + require.True(t, foundProvider, "ValidatorByConsumerAddr lost across round-trip") + require.Equal(t, assignedProviderConsAddr, gotProvider) + require.Len(t, pkB.GetAllConsumerAddrsToPrune(ctxB, keyedConsumerID), 1, + "ConsumerAddrsToPrune lost across round-trip") + + expB := pkB.ExportGenesis(ctxB) + + // Order-independent comparison on ConsumerStates (the only slice whose + // order is not part of the contract). + sort.Slice(expA.ConsumerStates, func(i, j int) bool { + return expA.ConsumerStates[i].ConsumerId < expA.ConsumerStates[j].ConsumerId + }) + sort.Slice(expB.ConsumerStates, func(i, j int) bool { + return expB.ConsumerStates[i].ConsumerId < expB.ConsumerStates[j].ConsumerId }) + + require.Equal(t, expA, expB, "round-trip must be a fixed point") } diff --git a/x/vaas/provider/keeper/grpc_query.go b/x/vaas/provider/keeper/grpc_query.go index f31f207..98a55d9 100644 --- a/x/vaas/provider/keeper/grpc_query.go +++ b/x/vaas/provider/keeper/grpc_query.go @@ -28,15 +28,11 @@ func (k Keeper) QueryConsumerGenesis(c context.Context, req *types.QueryConsumer } consumerId := req.ConsumerId - if err := vaastypes.ValidateConsumerId(consumerId); err != nil { - return nil, status.Error(codes.InvalidArgument, err.Error()) - } - gen, ok := k.GetConsumerGenesis(ctx, consumerId) if !ok { return nil, status.Error( codes.NotFound, - errorsmod.Wrap(types.ErrUnknownConsumerId, consumerId).Error(), + errorsmod.Wrapf(types.ErrUnknownConsumerId, "%d", consumerId).Error(), ) } @@ -54,14 +50,14 @@ func (k Keeper) QueryConsumerChains(goCtx context.Context, req *types.QueryConsu ctx, k.ConsumerPhase, req.Pagination, - func(consumerId string, phaseValue uint32) (bool, error) { + func(consumerId uint64, phaseValue uint32) (bool, error) { // Filter by phase if specified if req.Phase != types.CONSUMER_PHASE_UNSPECIFIED { return types.ConsumerPhase(phaseValue) == req.Phase, nil } return true, nil }, - func(consumerId string, phaseValue uint32) (*types.Chain, error) { + func(consumerId uint64, phaseValue uint32) (*types.Chain, error) { c, err := k.GetConsumerChain(ctx, consumerId) if err != nil { return nil, err @@ -77,17 +73,17 @@ func (k Keeper) QueryConsumerChains(goCtx context.Context, req *types.QueryConsu } // GetConsumerChain returns a Chain data structure with all the necessary fields -func (k Keeper) GetConsumerChain(ctx sdk.Context, consumerId string) (types.Chain, error) { +func (k Keeper) GetConsumerChain(ctx sdk.Context, consumerId uint64) (types.Chain, error) { chainID, err := k.GetConsumerChainId(ctx, consumerId) if err != nil { - return types.Chain{}, fmt.Errorf("cannot find chainID for consumer (%s)", consumerId) + return types.Chain{}, fmt.Errorf("cannot find chainID for consumer (%d)", consumerId) } clientID, _ := k.GetConsumerClientId(ctx, consumerId) metadata, err := k.GetConsumerMetadata(ctx, consumerId) if err != nil { - return types.Chain{}, fmt.Errorf("cannot find metadata (%s): %s", consumerId, err.Error()) + return types.Chain{}, fmt.Errorf("cannot find metadata (%d): %s", consumerId, err.Error()) } infractionParameters, err := types.DefaultConsumerInfractionParameters(ctx, k.slashingKeeper) @@ -114,10 +110,6 @@ func (k Keeper) QueryValidatorConsumerAddr(goCtx context.Context, req *types.Que ctx := sdk.UnwrapSDKContext(goCtx) consumerId := req.ConsumerId - if err := vaastypes.ValidateConsumerId(consumerId); err != nil { - return nil, status.Error(codes.InvalidArgument, err.Error()) - } - providerAddrTmp, err := sdk.ConsAddressFromBech32(req.ProviderAddress) if err != nil { return nil, err @@ -171,10 +163,6 @@ func (k Keeper) QueryAllPairsValConsAddrByConsumer( } consumerId := req.ConsumerId - if err := vaastypes.ValidateConsumerId(consumerId); err != nil { - return nil, status.Error(codes.InvalidArgument, err.Error()) - } - pairValConAddrs := []*types.PairValConAddrProviderAndConsumer{} ctx := sdk.UnwrapSDKContext(goCtx) @@ -213,15 +201,11 @@ func (k Keeper) QueryConsumerValidators(goCtx context.Context, req *types.QueryC } consumerId := req.ConsumerId - if err := vaastypes.ValidateConsumerId(consumerId); err != nil { - return nil, status.Error(codes.InvalidArgument, err.Error()) - } - ctx := sdk.UnwrapSDKContext(goCtx) phase := k.GetConsumerPhase(ctx, consumerId) if phase == types.CONSUMER_PHASE_UNSPECIFIED { - return nil, status.Errorf(codes.InvalidArgument, "cannot find a phase for consumer: %s", consumerId) + return nil, status.Errorf(codes.InvalidArgument, "cannot find a phase for consumer: %d", consumerId) } var consumerValSet []types.ConsensusValidator @@ -294,29 +278,26 @@ func (k Keeper) QueryConsumerChain(goCtx context.Context, req *types.QueryConsum } consumerId := req.ConsumerId - if err := vaastypes.ValidateConsumerId(consumerId); err != nil { - return nil, status.Error(codes.InvalidArgument, err.Error()) - } ctx := sdk.UnwrapSDKContext(goCtx) chainId, err := k.GetConsumerChainId(ctx, consumerId) if err != nil { - return nil, status.Errorf(codes.InvalidArgument, "cannot retrieve chain id for consumer id: %s", consumerId) + return nil, status.Errorf(codes.InvalidArgument, "cannot retrieve chain id for consumer id: %d", consumerId) } ownerAddress, err := k.GetConsumerOwnerAddress(ctx, consumerId) if err != nil { - return nil, status.Errorf(codes.InvalidArgument, "cannot retrieve owner address for consumer id: %s", consumerId) + return nil, status.Errorf(codes.InvalidArgument, "cannot retrieve owner address for consumer id: %d", consumerId) } phase := k.GetConsumerPhase(ctx, consumerId) if phase == types.CONSUMER_PHASE_UNSPECIFIED { - return nil, status.Errorf(codes.InvalidArgument, "cannot retrieve phase for consumer id: %s", consumerId) + return nil, status.Errorf(codes.InvalidArgument, "cannot retrieve phase for consumer id: %d", consumerId) } metadata, err := k.GetConsumerMetadata(ctx, consumerId) if err != nil { - return nil, status.Errorf(codes.InvalidArgument, "cannot retrieve metadata for consumer id: %s", consumerId) + return nil, status.Errorf(codes.InvalidArgument, "cannot retrieve metadata for consumer id: %d", consumerId) } initParams, _ := k.GetConsumerInitializationParameters(ctx, consumerId) @@ -346,16 +327,13 @@ func (k Keeper) QueryConsumerGenesisTime(goCtx context.Context, req *types.Query } consumerId := req.ConsumerId - if err := vaastypes.ValidateConsumerId(consumerId); err != nil { - return nil, status.Error(codes.InvalidArgument, err.Error()) - } ctx := sdk.UnwrapSDKContext(goCtx) params, err := k.GetConsumerInitializationParameters(ctx, consumerId) if err != nil { return nil, status.Errorf( codes.InvalidArgument, - "cannot get consumer genesis time for consumer Id: %s: %s", + "cannot get consumer genesis time for consumer Id: %d: %s", consumerId, types.ErrUnknownConsumerId, ) } @@ -364,7 +342,7 @@ func (k Keeper) QueryConsumerGenesisTime(goCtx context.Context, req *types.Query if !ok { return nil, status.Errorf( codes.InvalidArgument, - "cannot get consumer genesis time for consumer Id: %s: consumer hasn't been launched or has been stopped and deleted", + "cannot get consumer genesis time for consumer Id: %d: consumer hasn't been launched or has been stopped and deleted", consumerId, ) } @@ -377,7 +355,7 @@ func (k Keeper) QueryConsumerGenesisTime(goCtx context.Context, req *types.Query if !ok { return nil, status.Errorf( codes.InvalidArgument, - "cannot get consumer genesis time for consumer Id: %s: cannot find consensus state for initial height: %s", + "cannot get consumer genesis time for consumer Id: %d: cannot find consensus state for initial height: %s", consumerId, params.InitialHeight, ) diff --git a/x/vaas/provider/keeper/hooks.go b/x/vaas/provider/keeper/hooks.go index 403c601..0067bed 100644 --- a/x/vaas/provider/keeper/hooks.go +++ b/x/vaas/provider/keeper/hooks.go @@ -57,9 +57,9 @@ func (h Hooks) AfterValidatorRemoved(goCtx context.Context, valConsAddr sdk.Cons panic("cannot get address of consumer key") } consumerAddr := providertypes.NewConsumerConsAddress(consumerAddrTmp) - h.k.DeleteValidatorByConsumerAddr(ctx, validatorConsumerPubKey.ChainId, consumerAddr) + h.k.DeleteValidatorByConsumerAddr(ctx, validatorConsumerPubKey.ConsumerId, consumerAddr) providerAddr := providertypes.NewProviderConsAddress(validatorConsumerPubKey.ProviderAddr) - h.k.DeleteValidatorConsumerPubKey(ctx, validatorConsumerPubKey.ChainId, providerAddr) + h.k.DeleteValidatorConsumerPubKey(ctx, validatorConsumerPubKey.ConsumerId, providerAddr) } } diff --git a/x/vaas/provider/keeper/hooks_test.go b/x/vaas/provider/keeper/hooks_test.go index c770b71..852303b 100644 --- a/x/vaas/provider/keeper/hooks_test.go +++ b/x/vaas/provider/keeper/hooks_test.go @@ -34,15 +34,15 @@ func TestValidatorConsensusKeyInUse(t *testing.T) { name: "in use by another validator", setup: func(ctx sdk.Context, k providerkeeper.Keeper) { k.FetchAndIncrementConsumerId(ctx) - k.SetConsumerPhase(ctx, "0", types.CONSUMER_PHASE_INITIALIZED) + k.SetConsumerPhase(ctx, 0, types.CONSUMER_PHASE_INITIALIZED) // We are trying to add a new validator, but its address has already been used // by another validator - k.SetValidatorByConsumerAddr(ctx, "0", + k.SetValidatorByConsumerAddr(ctx, 0, newValidator.ConsumerConsAddress(), anotherValidator0.ProviderConsAddress(), ) - k.SetConsumerClientId(ctx, "0", "clientId") + k.SetConsumerClientId(ctx, 0, "clientId") }, expect: true, }, @@ -51,22 +51,22 @@ func TestValidatorConsensusKeyInUse(t *testing.T) { setup: func(ctx sdk.Context, k providerkeeper.Keeper) { k.FetchAndIncrementConsumerId(ctx) k.FetchAndIncrementConsumerId(ctx) - k.SetConsumerPhase(ctx, "0", types.CONSUMER_PHASE_INITIALIZED) - k.SetConsumerPhase(ctx, "1", types.CONSUMER_PHASE_INITIALIZED) + k.SetConsumerPhase(ctx, 0, types.CONSUMER_PHASE_INITIALIZED) + k.SetConsumerPhase(ctx, 1, types.CONSUMER_PHASE_INITIALIZED) // We are trying to add a new validator, but its address has already been used // by another validator, of which there are several, across potentially several chains - k.SetValidatorByConsumerAddr(ctx, "0", + k.SetValidatorByConsumerAddr(ctx, 0, newValidator.ConsumerConsAddress(), anotherValidator0.ProviderConsAddress(), ) - k.SetConsumerClientId(ctx, "0", "clientId0") + k.SetConsumerClientId(ctx, 0, "clientId0") - k.SetValidatorByConsumerAddr(ctx, "1", + k.SetValidatorByConsumerAddr(ctx, 1, anotherValidator1.ConsumerConsAddress(), anotherValidator1.ProviderConsAddress(), ) - k.SetConsumerClientId(ctx, "1", "clientId1") + k.SetConsumerClientId(ctx, 1, "clientId1") }, expect: true, }, diff --git a/x/vaas/provider/keeper/ibc_v2_integration_test.go b/x/vaas/provider/keeper/ibc_v2_integration_test.go index c2615ca..52d8176 100644 --- a/x/vaas/provider/keeper/ibc_v2_integration_test.go +++ b/x/vaas/provider/keeper/ibc_v2_integration_test.go @@ -23,7 +23,7 @@ func TestIBCV2PacketQueueing(t *testing.T) { providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - consumerId := "0" + consumerId := uint64(0) clientId := "07-tendermint-0" providerKeeper.SetConsumerClientId(ctx, consumerId, clientId) @@ -61,13 +61,13 @@ func TestIBCV2MultipleConsumers(t *testing.T) { defer ctrl.Finish() consumers := []struct { - id string + id uint64 clientId string chainId string }{ - {"0", "07-tendermint-0", "consumer-1"}, - {"1", "07-tendermint-1", "consumer-2"}, - {"2", "07-tendermint-2", "consumer-3"}, + {0, "07-tendermint-0", "consumer-1"}, + {1, "07-tendermint-1", "consumer-2"}, + {2, "07-tendermint-2", "consumer-3"}, } for _, c := range consumers { @@ -87,7 +87,7 @@ func TestIBCV2MultipleConsumers(t *testing.T) { for _, c := range consumers { pending := providerKeeper.GetPendingVSCPackets(ctx, c.id) - require.Len(t, pending, 1, "consumer %s should have 1 pending packet", c.id) + require.Len(t, pending, 1, "consumer %d should have 1 pending packet", c.id) } } @@ -96,7 +96,7 @@ func TestIBCV2ConsumerRemovalOnTimeout(t *testing.T) { providerKeeper, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - consumerId := "0" + consumerId := uint64(0) clientId := "07-tendermint-0" providerKeeper.SetConsumerClientId(ctx, consumerId, clientId) @@ -124,7 +124,7 @@ func TestIBCV2ConsumerRemovalOnErrorAck(t *testing.T) { providerKeeper, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - consumerId := "0" + consumerId := uint64(0) clientId := "07-tendermint-0" providerKeeper.SetConsumerClientId(ctx, consumerId, clientId) @@ -149,7 +149,7 @@ func TestIBCV2DualModeRouting(t *testing.T) { providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - consumerId := "0" + consumerId := uint64(0) clientId := "07-tendermint-0" providerKeeper.SetConsumerClientId(ctx, consumerId, clientId) diff --git a/x/vaas/provider/keeper/indexes.go b/x/vaas/provider/keeper/indexes.go index fe80e04..dcb9313 100644 --- a/x/vaas/provider/keeper/indexes.go +++ b/x/vaas/provider/keeper/indexes.go @@ -6,13 +6,13 @@ import ( ) // ConsumerClientIndexes defines the indexes for consumer-client mappings -// Primary key: ConsumerId (string) -> Value: ClientId (string) +// Primary key: ConsumerId (uint64) -> Value: ClientId (string) // Index: ByClientId allows reverse lookup from ClientId -> ConsumerId type ConsumerClientIndexes struct { // ByClientId is a unique index that maps ClientId -> ConsumerId - ByClientId *indexes.Unique[string, string, string] + ByClientId *indexes.Unique[string, uint64, string] } -func (i ConsumerClientIndexes) IndexesList() []collections.Index[string, string] { - return []collections.Index[string, string]{i.ByClientId} +func (i ConsumerClientIndexes) IndexesList() []collections.Index[uint64, string] { + return []collections.Index[uint64, string]{i.ByClientId} } diff --git a/x/vaas/provider/keeper/keeper.go b/x/vaas/provider/keeper/keeper.go index 82539e0..a3db49e 100644 --- a/x/vaas/provider/keeper/keeper.go +++ b/x/vaas/provider/keeper/keeper.go @@ -52,29 +52,29 @@ type Keeper struct { Params collections.Item[types.Params] ValidatorSetUpdateId collections.Sequence ConsumerId collections.Sequence - ConsumerClients *collections.IndexedMap[string, string, ConsumerClientIndexes] - ConsumerGenesis collections.Map[string, vaastypes.ConsumerGenesisState] + ConsumerClients *collections.IndexedMap[uint64, string, ConsumerClientIndexes] + ConsumerGenesis collections.Map[uint64, vaastypes.ConsumerGenesisState] ValsetUpdateBlockHeight collections.Map[uint64, uint64] - InitChainHeight collections.Map[string, uint64] - PendingVSCPackets collections.Map[string, types.ValidatorSetChangePackets] - ConsumerChainId collections.Map[string, string] - ConsumerOwnerAddress collections.Map[string, string] - ConsumerMetadata collections.Map[string, types.ConsumerMetadata] - ConsumerInitParams collections.Map[string, types.ConsumerInitializationParameters] - ConsumerPhase collections.Map[string, uint32] - ConsumerDebt collections.Map[string, bool] - EquivocationEvidenceMinHeight collections.Map[string, uint64] - ConsumerRemovalTime collections.Map[string, []byte] + InitChainHeight collections.Map[uint64, uint64] + PendingVSCPackets collections.Map[uint64, types.ValidatorSetChangePackets] + ConsumerChainId collections.Map[uint64, string] + ConsumerOwnerAddress collections.Map[uint64, string] + ConsumerMetadata collections.Map[uint64, types.ConsumerMetadata] + ConsumerInitParams collections.Map[uint64, types.ConsumerInitializationParameters] + ConsumerPhase collections.Map[uint64, uint32] + ConsumerDebt collections.Map[uint64, bool] + EquivocationEvidenceMinHeight collections.Map[uint64, uint64] + ConsumerRemovalTime collections.Map[uint64, []byte] SpawnTimeToConsumerIds collections.Map[[]byte, types.ConsumerIds] RemovalTimeToConsumerIds collections.Map[[]byte, types.ConsumerIds] // Key assignment collections - ValidatorConsumerPubKey collections.Map[collections.Pair[string, []byte], []byte] - ValidatorByConsumerAddr collections.Map[collections.Pair[string, []byte], []byte] - ConsumerAddrsToPrune collections.Map[collections.Pair[string, []byte], types.AddressList] + ValidatorConsumerPubKey collections.Map[collections.Pair[uint64, []byte], []byte] + ValidatorByConsumerAddr collections.Map[collections.Pair[uint64, []byte], []byte] + ConsumerAddrsToPrune collections.Map[collections.Pair[uint64, []byte], types.AddressList] // Validator set collections - ConsumerValidators collections.Map[collections.Pair[string, []byte], types.ConsensusValidator] + ConsumerValidators collections.Map[collections.Pair[uint64, []byte], types.ConsensusValidator] LastProviderConsensusVals collections.Map[[]byte, types.ConsensusValidator] } @@ -116,7 +116,7 @@ func NewKeeper( sb, types.ConsumerIdToClientIdPrefix, "consumer_clients", - collections.StringKey, + collections.Uint64Key, collections.StringValue, ConsumerClientIndexes{ ByClientId: indexes.NewUnique( @@ -124,35 +124,35 @@ func NewKeeper( types.ClientIdToConsumerIdPrefix, "consumer_clients_by_client_id", collections.StringKey, - collections.StringKey, - func(_ string, clientId string) (string, error) { + collections.Uint64Key, + func(_ uint64, clientId string) (string, error) { return clientId, nil }, ), }, ), - ConsumerGenesis: collections.NewMap(sb, types.ConsumerGenesisPrefix, "consumer_genesis", collections.StringKey, codec.CollValue[vaastypes.ConsumerGenesisState](cdc)), + ConsumerGenesis: collections.NewMap(sb, types.ConsumerGenesisPrefix, "consumer_genesis", collections.Uint64Key, codec.CollValue[vaastypes.ConsumerGenesisState](cdc)), ValsetUpdateBlockHeight: collections.NewMap(sb, types.ValsetUpdateBlockHeightPrefix, "valset_update_block_height", collections.Uint64Key, collections.Uint64Value), - InitChainHeight: collections.NewMap(sb, types.InitChainHeightPrefix, "init_chain_height", collections.StringKey, collections.Uint64Value), - PendingVSCPackets: collections.NewMap(sb, types.PendingVSCsPrefix, "pending_vsc_packets", collections.StringKey, codec.CollValue[types.ValidatorSetChangePackets](cdc)), - ConsumerChainId: collections.NewMap(sb, types.ConsumerIdToChainIdPrefix, "consumer_chain_id", collections.StringKey, collections.StringValue), - ConsumerOwnerAddress: collections.NewMap(sb, types.ConsumerIdToOwnerAddressPrefix, "consumer_owner_address", collections.StringKey, collections.StringValue), - ConsumerMetadata: collections.NewMap(sb, types.ConsumerIdToMetadataPrefix, "consumer_metadata", collections.StringKey, codec.CollValue[types.ConsumerMetadata](cdc)), - ConsumerInitParams: collections.NewMap(sb, types.ConsumerIdToInitializationParamsPrefix, "consumer_init_params", collections.StringKey, codec.CollValue[types.ConsumerInitializationParameters](cdc)), - ConsumerPhase: collections.NewMap(sb, types.ConsumerIdToPhasePrefix, "consumer_phase", collections.StringKey, collections.Uint32Value), - ConsumerDebt: collections.NewMap(sb, types.ConsumerIdToDebtPrefix, "consumer_debt", collections.StringKey, collections.BoolValue), - EquivocationEvidenceMinHeight: collections.NewMap(sb, types.EquivocationEvidenceMinHeightPrefix, "equivocation_evidence_min_height", collections.StringKey, collections.Uint64Value), - ConsumerRemovalTime: collections.NewMap(sb, types.ConsumerIdToRemovalTimePrefix, "consumer_removal_time", collections.StringKey, collections.BytesValue), + InitChainHeight: collections.NewMap(sb, types.InitChainHeightPrefix, "init_chain_height", collections.Uint64Key, collections.Uint64Value), + PendingVSCPackets: collections.NewMap(sb, types.PendingVSCsPrefix, "pending_vsc_packets", collections.Uint64Key, codec.CollValue[types.ValidatorSetChangePackets](cdc)), + ConsumerChainId: collections.NewMap(sb, types.ConsumerIdToChainIdPrefix, "consumer_chain_id", collections.Uint64Key, collections.StringValue), + ConsumerOwnerAddress: collections.NewMap(sb, types.ConsumerIdToOwnerAddressPrefix, "consumer_owner_address", collections.Uint64Key, collections.StringValue), + ConsumerMetadata: collections.NewMap(sb, types.ConsumerIdToMetadataPrefix, "consumer_metadata", collections.Uint64Key, codec.CollValue[types.ConsumerMetadata](cdc)), + ConsumerInitParams: collections.NewMap(sb, types.ConsumerIdToInitializationParamsPrefix, "consumer_init_params", collections.Uint64Key, codec.CollValue[types.ConsumerInitializationParameters](cdc)), + ConsumerPhase: collections.NewMap(sb, types.ConsumerIdToPhasePrefix, "consumer_phase", collections.Uint64Key, collections.Uint32Value), + ConsumerDebt: collections.NewMap(sb, types.ConsumerIdToDebtPrefix, "consumer_debt", collections.Uint64Key, collections.BoolValue), + EquivocationEvidenceMinHeight: collections.NewMap(sb, types.EquivocationEvidenceMinHeightPrefix, "equivocation_evidence_min_height", collections.Uint64Key, collections.Uint64Value), + ConsumerRemovalTime: collections.NewMap(sb, types.ConsumerIdToRemovalTimePrefix, "consumer_removal_time", collections.Uint64Key, collections.BytesValue), SpawnTimeToConsumerIds: collections.NewMap(sb, types.SpawnTimeToConsumerIdsPrefix, "spawn_time_to_consumer_ids", collections.BytesKey, codec.CollValue[types.ConsumerIds](cdc)), RemovalTimeToConsumerIds: collections.NewMap(sb, types.RemovalTimeToConsumerIdsPrefix, "removal_time_to_consumer_ids", collections.BytesKey, codec.CollValue[types.ConsumerIds](cdc)), // Key assignment collections - ValidatorConsumerPubKey: collections.NewMap(sb, types.ConsumerValidatorsPrefix, "validator_consumer_pub_key", collections.PairKeyCodec(collections.StringKey, collections.BytesKey), collections.BytesValue), - ValidatorByConsumerAddr: collections.NewMap(sb, types.ValidatorsByConsumerAddrPrefix, "validator_by_consumer_addr", collections.PairKeyCodec(collections.StringKey, collections.BytesKey), collections.BytesValue), - ConsumerAddrsToPrune: collections.NewMap(sb, types.ConsumerAddrsToPrunePrefix, "consumer_addrs_to_prune", collections.PairKeyCodec(collections.StringKey, collections.BytesKey), codec.CollValue[types.AddressList](cdc)), + ValidatorConsumerPubKey: collections.NewMap(sb, types.ConsumerValidatorsPrefix, "validator_consumer_pub_key", collections.PairKeyCodec(collections.Uint64Key, collections.BytesKey), collections.BytesValue), + ValidatorByConsumerAddr: collections.NewMap(sb, types.ValidatorsByConsumerAddrPrefix, "validator_by_consumer_addr", collections.PairKeyCodec(collections.Uint64Key, collections.BytesKey), collections.BytesValue), + ConsumerAddrsToPrune: collections.NewMap(sb, types.ConsumerAddrsToPrunePrefix, "consumer_addrs_to_prune", collections.PairKeyCodec(collections.Uint64Key, collections.BytesKey), codec.CollValue[types.AddressList](cdc)), // Validator set collections - ConsumerValidators: collections.NewMap(sb, types.ConsumerValidatorPrefix, "consumer_validators", collections.PairKeyCodec(collections.StringKey, collections.BytesKey), codec.CollValue[types.ConsensusValidator](cdc)), + ConsumerValidators: collections.NewMap(sb, types.ConsumerValidatorPrefix, "consumer_validators", collections.PairKeyCodec(collections.Uint64Key, collections.BytesKey), codec.CollValue[types.ConsensusValidator](cdc)), LastProviderConsensusVals: collections.NewMap(sb, types.LastProviderConsensusVals, "last_provider_consensus_vals", collections.BytesKey, codec.CollValue[types.ConsensusValidator](cdc)), } @@ -195,11 +195,11 @@ func (k Keeper) Logger(ctx context.Context) log.Logger { return sdkCtx.Logger().With("module", "x/"+ibchost.ModuleName+"-"+types.ModuleName) } -func (k Keeper) SetConsumerGenesis(ctx context.Context, consumerId string, gen vaastypes.ConsumerGenesisState) error { +func (k Keeper) SetConsumerGenesis(ctx context.Context, consumerId uint64, gen vaastypes.ConsumerGenesisState) error { return k.ConsumerGenesis.Set(ctx, consumerId, gen) } -func (k Keeper) GetConsumerGenesis(ctx context.Context, consumerId string) (vaastypes.ConsumerGenesisState, bool) { +func (k Keeper) GetConsumerGenesis(ctx context.Context, consumerId uint64) (vaastypes.ConsumerGenesisState, bool) { gen, err := k.ConsumerGenesis.Get(ctx, consumerId) if err != nil { return vaastypes.ConsumerGenesisState{}, false @@ -207,7 +207,7 @@ func (k Keeper) GetConsumerGenesis(ctx context.Context, consumerId string) (vaas return gen, true } -func (k Keeper) DeleteConsumerGenesis(ctx context.Context, consumerId string) { +func (k Keeper) DeleteConsumerGenesis(ctx context.Context, consumerId uint64) { if err := k.ConsumerGenesis.Remove(ctx, consumerId); err != nil { panic(fmt.Errorf("failed to delete consumer genesis: %w", err)) } @@ -278,14 +278,14 @@ func (k Keeper) DeleteValsetUpdateBlockHeight(ctx context.Context, valsetUpdateI } // SetInitChainHeight sets the provider block height when the given consumer chain was initiated -func (k Keeper) SetInitChainHeight(ctx context.Context, consumerId string, height uint64) { +func (k Keeper) SetInitChainHeight(ctx context.Context, consumerId uint64, height uint64) { if err := k.InitChainHeight.Set(ctx, consumerId, height); err != nil { panic(fmt.Errorf("failed to set init chain height: %w", err)) } } // GetInitChainHeight returns the provider block height when the given consumer chain was initiated -func (k Keeper) GetInitChainHeight(ctx context.Context, consumerId string) (uint64, bool) { +func (k Keeper) GetInitChainHeight(ctx context.Context, consumerId uint64) (uint64, bool) { height, err := k.InitChainHeight.Get(ctx, consumerId) if err != nil { return 0, false @@ -294,14 +294,14 @@ func (k Keeper) GetInitChainHeight(ctx context.Context, consumerId string) (uint } // DeleteInitChainHeight deletes the block height value for which the given consumer chain's channel was established -func (k Keeper) DeleteInitChainHeight(ctx context.Context, consumerId string) { +func (k Keeper) DeleteInitChainHeight(ctx context.Context, consumerId uint64) { if err := k.InitChainHeight.Remove(ctx, consumerId); err != nil { panic(fmt.Errorf("failed to delete init chain height: %w", err)) } } // GetPendingVSCPackets returns the list of pending ValidatorSetChange packets stored under consumer id -func (k Keeper) GetPendingVSCPackets(ctx context.Context, consumerId string) []vaastypes.ValidatorSetChangePacketData { +func (k Keeper) GetPendingVSCPackets(ctx context.Context, consumerId uint64) []vaastypes.ValidatorSetChangePacketData { packets, err := k.PendingVSCPackets.Get(ctx, consumerId) if err != nil { return []vaastypes.ValidatorSetChangePacketData{} @@ -311,7 +311,7 @@ func (k Keeper) GetPendingVSCPackets(ctx context.Context, consumerId string) []v // AppendPendingVSCPackets adds the given ValidatorSetChange packet to the list // of pending ValidatorSetChange packets stored under consumer id -func (k Keeper) AppendPendingVSCPackets(ctx context.Context, consumerId string, newPackets ...vaastypes.ValidatorSetChangePacketData) { +func (k Keeper) AppendPendingVSCPackets(ctx context.Context, consumerId uint64, newPackets ...vaastypes.ValidatorSetChangePacketData) { pds := append(k.GetPendingVSCPackets(ctx, consumerId), newPackets...) packets := types.ValidatorSetChangePackets{List: pds} @@ -321,7 +321,7 @@ func (k Keeper) AppendPendingVSCPackets(ctx context.Context, consumerId string, } // DeletePendingVSCPackets deletes the list of pending ValidatorSetChange packets for chain ID -func (k Keeper) DeletePendingVSCPackets(ctx context.Context, consumerId string) { +func (k Keeper) DeletePendingVSCPackets(ctx context.Context, consumerId uint64) { if err := k.PendingVSCPackets.Remove(ctx, consumerId); err != nil { panic(fmt.Errorf("failed to delete pending VSC packets: %w", err)) } @@ -329,14 +329,14 @@ func (k Keeper) DeletePendingVSCPackets(ctx context.Context, consumerId string) // SetConsumerClientId sets the client id for the given consumer id. // The reverse index is automatically maintained by the indexed map. -func (k Keeper) SetConsumerClientId(ctx context.Context, consumerId, clientId string) { +func (k Keeper) SetConsumerClientId(ctx context.Context, consumerId uint64, clientId string) { if err := k.ConsumerClients.Set(ctx, consumerId, clientId); err != nil { panic(fmt.Errorf("failed to set consumer id to client id: %w", err)) } } // GetConsumerClientId returns the client id for the given consumer id. -func (k Keeper) GetConsumerClientId(ctx context.Context, consumerId string) (string, bool) { +func (k Keeper) GetConsumerClientId(ctx context.Context, consumerId uint64) (string, bool) { clientId, err := k.ConsumerClients.Get(ctx, consumerId) if err != nil { return "", false @@ -345,17 +345,17 @@ func (k Keeper) GetConsumerClientId(ctx context.Context, consumerId string) (str } // GetClientIdToConsumerId returns the consumer id associated with this client id -func (k Keeper) GetClientIdToConsumerId(ctx context.Context, clientId string) (string, bool) { +func (k Keeper) GetClientIdToConsumerId(ctx context.Context, clientId string) (uint64, bool) { consumerId, err := k.ConsumerClients.Indexes.ByClientId.MatchExact(ctx, clientId) if err != nil { - return "", false + return 0, false } return consumerId, true } // DeleteConsumerClientId removes from the store the client id for the given consumer id. // The reverse index is automatically cleaned up by the indexed map. -func (k Keeper) DeleteConsumerClientId(ctx context.Context, consumerId string) { +func (k Keeper) DeleteConsumerClientId(ctx context.Context, consumerId uint64) { if err := k.ConsumerClients.Remove(ctx, consumerId); err != nil { panic(fmt.Errorf("failed to remove consumer id to client id mapping: %w", err)) } @@ -366,24 +366,23 @@ func (k Keeper) BondDenom(ctx sdk.Context) (string, error) { } // GetAllConsumerIds returns all the existing consumer ids -func (k Keeper) GetAllConsumerIds(ctx context.Context) []string { +func (k Keeper) GetAllConsumerIds(ctx context.Context) []uint64 { latestConsumerId, found := k.GetConsumerId(ctx) if !found { - return []string{} + return []uint64{} } - consumerIds := []string{} - for i := range latestConsumerId { - consumerId := fmt.Sprintf("%d", i) - consumerIds = append(consumerIds, consumerId) + consumerIds := make([]uint64, 0, latestConsumerId) + for i := uint64(0); i < latestConsumerId; i++ { + consumerIds = append(consumerIds, i) } return consumerIds } // GetAllActiveConsumerIds returns all the consumer ids of chains that are registered, initialized, or launched -func (k Keeper) GetAllActiveConsumerIds(ctx context.Context) []string { - consumerIds := []string{} +func (k Keeper) GetAllActiveConsumerIds(ctx context.Context) []uint64 { + consumerIds := []uint64{} for _, consumerId := range k.GetAllConsumerIds(ctx) { if !k.IsConsumerActive(ctx, consumerId) { continue @@ -394,8 +393,8 @@ func (k Keeper) GetAllActiveConsumerIds(ctx context.Context) []string { } // GetAllLaunchedConsumerIds returns all consumer ids in the launched phase. -func (k Keeper) GetAllLaunchedConsumerIds(ctx context.Context) []string { - consumerIds := []string{} +func (k Keeper) GetAllLaunchedConsumerIds(ctx context.Context) []uint64 { + consumerIds := []uint64{} for _, consumerId := range k.GetAllConsumerIds(ctx) { if k.GetConsumerPhase(ctx, consumerId) != types.CONSUMER_PHASE_LAUNCHED { continue @@ -441,14 +440,14 @@ func (k Keeper) CreateProviderConsensusValidator(ctx sdk.Context, val stakingtyp } // SetEquivocationEvidenceMinHeight sets the minimum height for a valid consumer equivocation evidence -func (k Keeper) SetEquivocationEvidenceMinHeight(ctx context.Context, consumerId string, height uint64) { +func (k Keeper) SetEquivocationEvidenceMinHeight(ctx context.Context, consumerId uint64, height uint64) { if err := k.EquivocationEvidenceMinHeight.Set(ctx, consumerId, height); err != nil { panic(fmt.Errorf("failed to set equivocation evidence min height: %w", err)) } } // GetEquivocationEvidenceMinHeight returns the minimum height for a valid consumer equivocation evidence -func (k Keeper) GetEquivocationEvidenceMinHeight(ctx context.Context, consumerId string) uint64 { +func (k Keeper) GetEquivocationEvidenceMinHeight(ctx context.Context, consumerId uint64) uint64 { height, err := k.EquivocationEvidenceMinHeight.Get(ctx, consumerId) if err != nil { return 0 @@ -457,41 +456,41 @@ func (k Keeper) GetEquivocationEvidenceMinHeight(ctx context.Context, consumerId } // DeleteEquivocationEvidenceMinHeight deletes the minimum height for a valid consumer equivocation evidence -func (k Keeper) DeleteEquivocationEvidenceMinHeight(ctx context.Context, consumerId string) { +func (k Keeper) DeleteEquivocationEvidenceMinHeight(ctx context.Context, consumerId uint64) { if err := k.EquivocationEvidenceMinHeight.Remove(ctx, consumerId); err != nil { panic(fmt.Errorf("failed to delete equivocation evidence min height: %w", err)) } } // SetConsumerRemovalTime sets the removal time associated with this consumer id -func (k Keeper) SetConsumerRemovalTime(ctx context.Context, consumerId string, removalTime time.Time) error { +func (k Keeper) SetConsumerRemovalTime(ctx context.Context, consumerId uint64, removalTime time.Time) error { buf, err := removalTime.MarshalBinary() if err != nil { - return fmt.Errorf("failed to marshal removal time (%+v) for consumer id (%s): %w", removalTime, consumerId, err) + return fmt.Errorf("failed to marshal removal time (%+v) for consumer id (%d): %w", removalTime, consumerId, err) } if err := k.ConsumerRemovalTime.Set(ctx, consumerId, buf); err != nil { - return fmt.Errorf("failed to set removal time for consumer id (%s): %w", consumerId, err) + return fmt.Errorf("failed to set removal time for consumer id (%d): %w", consumerId, err) } return nil } // GetConsumerRemovalTime returns the removal time associated with the to-be-removed chain with consumer id -func (k Keeper) GetConsumerRemovalTime(ctx context.Context, consumerId string) (time.Time, error) { +func (k Keeper) GetConsumerRemovalTime(ctx context.Context, consumerId uint64) (time.Time, error) { buf, err := k.ConsumerRemovalTime.Get(ctx, consumerId) if err != nil { - return time.Time{}, fmt.Errorf("failed to retrieve removal time for consumer id (%s): %w", consumerId, err) + return time.Time{}, fmt.Errorf("failed to retrieve removal time for consumer id (%d): %w", consumerId, err) } var t time.Time if err := t.UnmarshalBinary(buf); err != nil { - return time.Time{}, fmt.Errorf("failed to unmarshal removal time for consumer id (%s): %w", consumerId, err) + return time.Time{}, fmt.Errorf("failed to unmarshal removal time for consumer id (%d): %w", consumerId, err) } return t, nil } // DeleteConsumerRemovalTime deletes the removal time associated with this consumer id -func (k Keeper) DeleteConsumerRemovalTime(ctx context.Context, consumerId string) { +func (k Keeper) DeleteConsumerRemovalTime(ctx context.Context, consumerId uint64) { if err := k.ConsumerRemovalTime.Remove(ctx, consumerId); err != nil { - panic(fmt.Errorf("failed to delete removal time for consumer id (%s): %w", consumerId, err)) + panic(fmt.Errorf("failed to delete removal time for consumer id (%d): %w", consumerId, err)) } } @@ -521,7 +520,7 @@ func (k Keeper) GetConsumersToBeLaunched(ctx context.Context, spawnTime time.Tim } // AppendConsumerToBeLaunched appends the provider consumer id for the given spawn time -func (k Keeper) AppendConsumerToBeLaunched(ctx context.Context, consumerId string, spawnTime time.Time) error { +func (k Keeper) AppendConsumerToBeLaunched(ctx context.Context, consumerId uint64, spawnTime time.Time) error { consumers, err := k.GetConsumersToBeLaunched(ctx, spawnTime) if err != nil { return err @@ -536,7 +535,7 @@ func (k Keeper) AppendConsumerToBeLaunched(ctx context.Context, consumerId strin } // RemoveConsumerToBeLaunched removes consumer id from if stored for this specific spawn time -func (k Keeper) RemoveConsumerToBeLaunched(ctx context.Context, consumerId string, spawnTime time.Time) error { +func (k Keeper) RemoveConsumerToBeLaunched(ctx context.Context, consumerId uint64, spawnTime time.Time) error { consumers, err := k.GetConsumersToBeLaunched(ctx, spawnTime) if err != nil { return err @@ -556,7 +555,7 @@ func (k Keeper) RemoveConsumerToBeLaunched(ctx context.Context, consumerId strin } if index == -1 { - return fmt.Errorf("failed to find consumer id (%s)", consumerId) + return fmt.Errorf("failed to find consumer id (%d)", consumerId) } key := timeToBytes(spawnTime) @@ -590,7 +589,7 @@ func (k Keeper) GetConsumersToBeRemoved(ctx context.Context, removalTime time.Ti } // AppendConsumerToBeRemoved appends the provider consumer id for the given removal time -func (k Keeper) AppendConsumerToBeRemoved(ctx context.Context, consumerId string, removalTime time.Time) error { +func (k Keeper) AppendConsumerToBeRemoved(ctx context.Context, consumerId uint64, removalTime time.Time) error { consumers, err := k.GetConsumersToBeRemoved(ctx, removalTime) if err != nil { return err @@ -605,7 +604,7 @@ func (k Keeper) AppendConsumerToBeRemoved(ctx context.Context, consumerId string } // RemoveConsumerToBeRemoved removes consumer id from the given removal time -func (k Keeper) RemoveConsumerToBeRemoved(ctx context.Context, consumerId string, removalTime time.Time) error { +func (k Keeper) RemoveConsumerToBeRemoved(ctx context.Context, consumerId uint64, removalTime time.Time) error { consumers, err := k.GetConsumersToBeRemoved(ctx, removalTime) if err != nil { return err @@ -625,7 +624,7 @@ func (k Keeper) RemoveConsumerToBeRemoved(ctx context.Context, consumerId string } if index == -1 { - return fmt.Errorf("failed to find consumer id (%s)", consumerId) + return fmt.Errorf("failed to find consumer id (%d)", consumerId) } key := timeToBytes(removalTime) @@ -653,7 +652,7 @@ func (k Keeper) DeleteAllConsumersToBeRemoved(ctx context.Context, removalTime t // GetValidatorConsumerPubKey returns a validator's public key assigned for a consumer chain func (k Keeper) GetValidatorConsumerPubKey( ctx context.Context, - consumerId string, + consumerId uint64, providerAddr types.ProviderConsAddress, ) (consumerKey tmprotocrypto.PublicKey, found bool) { bz, err := k.ValidatorConsumerPubKey.Get(ctx, collections.Join(consumerId, providerAddr.ToSdkConsAddr().Bytes())) @@ -669,7 +668,7 @@ func (k Keeper) GetValidatorConsumerPubKey( // SetValidatorConsumerPubKey sets a validator's public key assigned for a consumer chain func (k Keeper) SetValidatorConsumerPubKey( ctx context.Context, - consumerId string, + consumerId uint64, providerAddr types.ProviderConsAddress, consumerKey tmprotocrypto.PublicKey, ) { @@ -683,21 +682,21 @@ func (k Keeper) SetValidatorConsumerPubKey( } // DeleteValidatorConsumerPubKey deletes a validator's public key assigned for a consumer chain -func (k Keeper) DeleteValidatorConsumerPubKey(ctx context.Context, consumerId string, providerAddr types.ProviderConsAddress) { +func (k Keeper) DeleteValidatorConsumerPubKey(ctx context.Context, consumerId uint64, providerAddr types.ProviderConsAddress) { if err := k.ValidatorConsumerPubKey.Remove(ctx, collections.Join(consumerId, providerAddr.ToSdkConsAddr().Bytes())); err != nil { panic(fmt.Errorf("failed to delete validator consumer pub key: %w", err)) } } // GetAllValidatorConsumerPubKeys gets all the validators public keys assigned for a consumer chain -func (k Keeper) GetAllValidatorConsumerPubKeys(ctx context.Context, consumerId *string) (validatorConsumerPubKeys []types.ValidatorConsumerPubKey) { - var iter collections.Iterator[collections.Pair[string, []byte], []byte] +func (k Keeper) GetAllValidatorConsumerPubKeys(ctx context.Context, consumerId *uint64) (validatorConsumerPubKeys []types.ValidatorConsumerPubKey) { + var iter collections.Iterator[collections.Pair[uint64, []byte], []byte] var err error if consumerId == nil { iter, err = k.ValidatorConsumerPubKey.Iterate(ctx, nil) } else { - iter, err = k.ValidatorConsumerPubKey.Iterate(ctx, collections.NewPrefixedPairRange[string, []byte](*consumerId)) + iter, err = k.ValidatorConsumerPubKey.Iterate(ctx, collections.NewPrefixedPairRange[uint64, []byte](*consumerId)) } if err != nil { return validatorConsumerPubKeys @@ -714,7 +713,7 @@ func (k Keeper) GetAllValidatorConsumerPubKeys(ctx context.Context, consumerId * panic(fmt.Sprintf("failed to unmarshal consumer key: %v", err)) } validatorConsumerPubKeys = append(validatorConsumerPubKeys, types.ValidatorConsumerPubKey{ - ChainId: kv.Key.K1(), + ConsumerId: kv.Key.K1(), ProviderAddr: kv.Key.K2(), ConsumerKey: &consumerKey, }) @@ -727,7 +726,7 @@ func (k Keeper) GetAllValidatorConsumerPubKeys(ctx context.Context, consumerId * // given the validator's consensus address on a consumer func (k Keeper) GetValidatorByConsumerAddr( ctx context.Context, - consumerId string, + consumerId uint64, consumerAddr types.ConsumerConsAddress, ) (providerAddr types.ProviderConsAddress, found bool) { bz, err := k.ValidatorByConsumerAddr.Get(ctx, collections.Join(consumerId, consumerAddr.ToSdkConsAddr().Bytes())) @@ -742,7 +741,7 @@ func (k Keeper) GetValidatorByConsumerAddr( // to the validator's consensus address on the provider func (k Keeper) SetValidatorByConsumerAddr( ctx context.Context, - consumerId string, + consumerId uint64, consumerAddr types.ConsumerConsAddress, providerAddr types.ProviderConsAddress, ) { @@ -753,7 +752,7 @@ func (k Keeper) SetValidatorByConsumerAddr( // DeleteValidatorByConsumerAddr deletes the mapping from a validator's consensus address on a consumer // to the validator's consensus address on the provider -func (k Keeper) DeleteValidatorByConsumerAddr(ctx context.Context, consumerId string, consumerAddr types.ConsumerConsAddress) { +func (k Keeper) DeleteValidatorByConsumerAddr(ctx context.Context, consumerId uint64, consumerAddr types.ConsumerConsAddress) { if err := k.ValidatorByConsumerAddr.Remove(ctx, collections.Join(consumerId, consumerAddr.ToSdkConsAddr().Bytes())); err != nil { panic(fmt.Errorf("failed to delete validator by consumer addr: %w", err)) } @@ -761,14 +760,14 @@ func (k Keeper) DeleteValidatorByConsumerAddr(ctx context.Context, consumerId st // GetAllValidatorsByConsumerAddr gets all the mappings from consensus addresses on consumer chains // to consensus addresses on the provider chain -func (k Keeper) GetAllValidatorsByConsumerAddr(ctx context.Context, consumerId *string) (validatorConsumerAddrs []types.ValidatorByConsumerAddr) { - var iter collections.Iterator[collections.Pair[string, []byte], []byte] +func (k Keeper) GetAllValidatorsByConsumerAddr(ctx context.Context, consumerId *uint64) (validatorConsumerAddrs []types.ValidatorByConsumerAddr) { + var iter collections.Iterator[collections.Pair[uint64, []byte], []byte] var err error if consumerId == nil { iter, err = k.ValidatorByConsumerAddr.Iterate(ctx, nil) } else { - iter, err = k.ValidatorByConsumerAddr.Iterate(ctx, collections.NewPrefixedPairRange[string, []byte](*consumerId)) + iter, err = k.ValidatorByConsumerAddr.Iterate(ctx, collections.NewPrefixedPairRange[uint64, []byte](*consumerId)) } if err != nil { return validatorConsumerAddrs @@ -786,7 +785,7 @@ func (k Keeper) GetAllValidatorsByConsumerAddr(ctx context.Context, consumerId * validatorConsumerAddrs = append(validatorConsumerAddrs, types.ValidatorByConsumerAddr{ ConsumerAddr: consumerAddr.ToSdkConsAddr(), ProviderAddr: providerAddr.ToSdkConsAddr(), - ChainId: kv.Key.K1(), + ConsumerId: kv.Key.K1(), }) } @@ -797,7 +796,7 @@ func (k Keeper) GetAllValidatorsByConsumerAddr(ctx context.Context, consumerId * // that can be pruned once the block time is at least pruneTs. func (k Keeper) AppendConsumerAddrsToPrune( ctx context.Context, - consumerId string, + consumerId uint64, pruneTs time.Time, consumerAddr types.ConsumerConsAddress, ) { @@ -815,7 +814,7 @@ func (k Keeper) AppendConsumerAddrsToPrune( // GetConsumerAddrsToPrune returns the list of consumer addresses to prune stored under timestamp ts. func (k Keeper) GetConsumerAddrsToPrune( ctx context.Context, - consumerId string, + consumerId uint64, ts time.Time, ) (consumerAddrsToPrune types.AddressList) { key := collections.Join(consumerId, timeToBytes(ts)) @@ -827,7 +826,7 @@ func (k Keeper) GetConsumerAddrsToPrune( } // DeleteConsumerAddrsToPrune deletes the list of consumer addresses mapped to a timestamp -func (k Keeper) DeleteConsumerAddrsToPrune(ctx context.Context, consumerId string, pruneTs time.Time) { +func (k Keeper) DeleteConsumerAddrsToPrune(ctx context.Context, consumerId uint64, pruneTs time.Time) { key := collections.Join(consumerId, timeToBytes(pruneTs)) if err := k.ConsumerAddrsToPrune.Remove(ctx, key); err != nil { panic(fmt.Errorf("failed to delete consumer addrs to prune: %w", err)) @@ -835,8 +834,8 @@ func (k Keeper) DeleteConsumerAddrsToPrune(ctx context.Context, consumerId strin } // GetAllConsumerAddrsToPrune gets all consumer addresses that can be eventually pruned for a given consumerId. -func (k Keeper) GetAllConsumerAddrsToPrune(ctx context.Context, consumerId string) (consumerAddrsToPrune []types.ConsumerAddrsToPrune) { - iter, err := k.ConsumerAddrsToPrune.Iterate(ctx, collections.NewPrefixedPairRange[string, []byte](consumerId)) +func (k Keeper) GetAllConsumerAddrsToPrune(ctx context.Context, consumerId uint64) (consumerAddrsToPrune []types.ConsumerAddrsToPrune) { + iter, err := k.ConsumerAddrsToPrune.Iterate(ctx, collections.NewPrefixedPairRange[uint64, []byte](consumerId)) if err != nil { return consumerAddrsToPrune } @@ -854,7 +853,7 @@ func (k Keeper) GetAllConsumerAddrsToPrune(ctx context.Context, consumerId strin consumerAddrsToPrune = append(consumerAddrsToPrune, types.ConsumerAddrsToPrune{ PruneTs: ts, ConsumerAddrs: &kv.Value, - ChainId: consumerId, + ConsumerId: consumerId, }) } @@ -865,16 +864,16 @@ func (k Keeper) GetAllConsumerAddrsToPrune(ctx context.Context, consumerId strin // The returned addresses are removed from the store. func (k Keeper) ConsumeConsumerAddrsToPrune( ctx context.Context, - consumerId string, + consumerId uint64, ts time.Time, ) (consumerAddrsToPrune types.AddressList) { - iter, err := k.ConsumerAddrsToPrune.Iterate(ctx, collections.NewPrefixedPairRange[string, []byte](consumerId)) + iter, err := k.ConsumerAddrsToPrune.Iterate(ctx, collections.NewPrefixedPairRange[uint64, []byte](consumerId)) if err != nil { return consumerAddrsToPrune } defer iter.Close() - var keysToDel []collections.Pair[string, []byte] + var keysToDel []collections.Pair[uint64, []byte] for ; iter.Valid(); iter.Next() { kv, err := iter.KeyValue() if err != nil { @@ -907,14 +906,14 @@ func (k Keeper) ConsumeConsumerAddrsToPrune( // SetConsumerValidator sets provided consumer `validator` on the consumer chain with `consumerId` func (k Keeper) SetConsumerValidator( ctx context.Context, - consumerId string, + consumerId uint64, validator types.ConsensusValidator, ) error { return k.ConsumerValidators.Set(ctx, collections.Join(consumerId, validator.ProviderConsAddr), validator) } // GetConsumerValidator returns the consumer validator with `providerAddr` if it exists for chain with `consumerId` -func (k Keeper) GetConsumerValidator(ctx context.Context, consumerId string, providerAddr types.ProviderConsAddress) (types.ConsensusValidator, bool) { +func (k Keeper) GetConsumerValidator(ctx context.Context, consumerId uint64, providerAddr types.ProviderConsAddress) (types.ConsensusValidator, bool) { validator, err := k.ConsumerValidators.Get(ctx, collections.Join(consumerId, providerAddr.ToSdkConsAddr().Bytes())) if err != nil { return types.ConsensusValidator{}, false @@ -925,7 +924,7 @@ func (k Keeper) GetConsumerValidator(ctx context.Context, consumerId string, pro // DeleteConsumerValidator removes consumer validator with `providerAddr` address func (k Keeper) DeleteConsumerValidator( ctx context.Context, - consumerId string, + consumerId uint64, providerConsAddr types.ProviderConsAddress, ) { if err := k.ConsumerValidators.Remove(ctx, collections.Join(consumerId, providerConsAddr.ToSdkConsAddr().Bytes())); err != nil { @@ -934,7 +933,7 @@ func (k Keeper) DeleteConsumerValidator( } // IsConsumerValidator returns `true` if the consumer validator with `providerAddr` exists for chain with `consumerId` -func (k Keeper) IsConsumerValidator(ctx context.Context, consumerId string, providerAddr types.ProviderConsAddress) bool { +func (k Keeper) IsConsumerValidator(ctx context.Context, consumerId uint64, providerAddr types.ProviderConsAddress) bool { has, err := k.ConsumerValidators.Has(ctx, collections.Join(consumerId, providerAddr.ToSdkConsAddr().Bytes())) if err != nil { return false @@ -945,10 +944,10 @@ func (k Keeper) IsConsumerValidator(ctx context.Context, consumerId string, prov // GetConsumerValSet returns all the consumer validators for chain with `consumerId` func (k Keeper) GetConsumerValSet( ctx context.Context, - consumerId string, + consumerId uint64, ) ([]types.ConsensusValidator, error) { var validators []types.ConsensusValidator - iter, err := k.ConsumerValidators.Iterate(ctx, collections.NewPrefixedPairRange[string, []byte](consumerId)) + iter, err := k.ConsumerValidators.Iterate(ctx, collections.NewPrefixedPairRange[uint64, []byte](consumerId)) if err != nil { return validators, err } @@ -966,7 +965,7 @@ func (k Keeper) GetConsumerValSet( } // SetConsumerValSet resets the current consumer validators with the `nextValidators` -func (k Keeper) SetConsumerValSet(ctx context.Context, consumerId string, nextValidators []types.ConsensusValidator) error { +func (k Keeper) SetConsumerValSet(ctx context.Context, consumerId uint64, nextValidators []types.ConsensusValidator) error { // First delete existing validators k.DeleteConsumerValSet(ctx, consumerId) @@ -980,14 +979,14 @@ func (k Keeper) SetConsumerValSet(ctx context.Context, consumerId string, nextVa } // DeleteConsumerValSet deletes all the stored consumer validators for chain with `consumerId` -func (k Keeper) DeleteConsumerValSet(ctx context.Context, consumerId string) { - iter, err := k.ConsumerValidators.Iterate(ctx, collections.NewPrefixedPairRange[string, []byte](consumerId)) +func (k Keeper) DeleteConsumerValSet(ctx context.Context, consumerId uint64) { + iter, err := k.ConsumerValidators.Iterate(ctx, collections.NewPrefixedPairRange[uint64, []byte](consumerId)) if err != nil { return } defer iter.Close() - var keysToDel []collections.Pair[string, []byte] + var keysToDel []collections.Pair[uint64, []byte] for ; iter.Valid(); iter.Next() { key, err := iter.Key() if err != nil { diff --git a/x/vaas/provider/keeper/keeper_test.go b/x/vaas/provider/keeper/keeper_test.go index 3cb543d..3023821 100644 --- a/x/vaas/provider/keeper/keeper_test.go +++ b/x/vaas/provider/keeper/keeper_test.go @@ -18,8 +18,7 @@ import ( ) const ( - CONSUMER_CHAIN_ID = "chain-id" - CONSUMER_ID = "0" + CONSUMER_ID uint64 = 0 ) // TestValsetUpdateBlockHeight tests the getter, setter, and deletion methods for valset updates mapped to block height @@ -94,9 +93,9 @@ func TestPendingVSCs(t *testing.T) { providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - chainID := CONSUMER_CHAIN_ID + consumerID := CONSUMER_ID - pending := providerKeeper.GetPendingVSCPackets(ctx, chainID) + pending := providerKeeper.GetPendingVSCPackets(ctx, consumerID) require.Len(t, pending, 0) _, pks, _ := ibctesting.GenerateKeys(t, 4) @@ -120,9 +119,9 @@ func TestPendingVSCs(t *testing.T) { ValsetUpdateId: 2, }, } - providerKeeper.AppendPendingVSCPackets(ctx, chainID, packetList...) + providerKeeper.AppendPendingVSCPackets(ctx, consumerID, packetList...) - packets := providerKeeper.GetPendingVSCPackets(ctx, chainID) + packets := providerKeeper.GetPendingVSCPackets(ctx, consumerID) require.Len(t, packets, 2) newPacket := vaastypes.ValidatorSetChangePacketData{ @@ -131,14 +130,14 @@ func TestPendingVSCs(t *testing.T) { }, ValsetUpdateId: 3, } - providerKeeper.AppendPendingVSCPackets(ctx, chainID, newPacket) - vscs := providerKeeper.GetPendingVSCPackets(ctx, chainID) + providerKeeper.AppendPendingVSCPackets(ctx, consumerID, newPacket) + vscs := providerKeeper.GetPendingVSCPackets(ctx, consumerID) require.Len(t, vscs, 3) require.True(t, vscs[len(vscs)-1].ValsetUpdateId == 3) require.True(t, vscs[len(vscs)-1].GetValidatorUpdates()[0].PubKey.String() == ppks[3].String()) - providerKeeper.DeletePendingVSCPackets(ctx, chainID) - pending = providerKeeper.GetPendingVSCPackets(ctx, chainID) + providerKeeper.DeletePendingVSCPackets(ctx, consumerID) + pending = providerKeeper.GetPendingVSCPackets(ctx, consumerID) require.Len(t, pending, 0) } @@ -163,19 +162,19 @@ func TestInitHeight(t *testing.T) { defer ctrl.Finish() tc := []struct { - chainID string - expected uint64 + consumerID uint64 + expected uint64 }{ - {expected: 0, chainID: "chain"}, - {expected: 10, chainID: "chain1"}, - {expected: 12, chainID: "chain2"}, + {expected: 0, consumerID: 0}, + {expected: 10, consumerID: 1}, + {expected: 12, consumerID: 2}, } - providerKeeper.SetInitChainHeight(ctx, tc[1].chainID, tc[1].expected) - providerKeeper.SetInitChainHeight(ctx, tc[2].chainID, tc[2].expected) + providerKeeper.SetInitChainHeight(ctx, tc[1].consumerID, tc[1].expected) + providerKeeper.SetInitChainHeight(ctx, tc[2].consumerID, tc[2].expected) for _, tc := range tc { - height, _ := providerKeeper.GetInitChainHeight(ctx, tc.chainID) + height, _ := providerKeeper.GetInitChainHeight(ctx, tc.consumerID) require.Equal(t, tc.expected, height) } } @@ -185,7 +184,7 @@ func TestConsumerClientId(t *testing.T) { providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - consumerId := "123" + consumerId := uint64(123) clientIds := []string{"clientId1", "clientId2"} _, found := providerKeeper.GetConsumerClientId(ctx, consumerId) @@ -199,9 +198,9 @@ func TestConsumerClientId(t *testing.T) { res, found := providerKeeper.GetConsumerClientId(ctx, consumerId) require.True(t, found) require.Equal(t, clientIds[0], res) - res, found = providerKeeper.GetClientIdToConsumerId(ctx, clientIds[0]) + gotCid, found := providerKeeper.GetClientIdToConsumerId(ctx, clientIds[0]) require.True(t, found) - require.Equal(t, consumerId, res) + require.Equal(t, consumerId, gotCid) _, found = providerKeeper.GetClientIdToConsumerId(ctx, clientIds[1]) require.False(t, found) @@ -210,9 +209,9 @@ func TestConsumerClientId(t *testing.T) { res, found = providerKeeper.GetConsumerClientId(ctx, consumerId) require.True(t, found) require.Equal(t, clientIds[1], res) - res, found = providerKeeper.GetClientIdToConsumerId(ctx, clientIds[1]) + gotCid, found = providerKeeper.GetClientIdToConsumerId(ctx, clientIds[1]) require.True(t, found) - require.Equal(t, consumerId, res) + require.Equal(t, consumerId, gotCid) _, found = providerKeeper.GetClientIdToConsumerId(ctx, clientIds[0]) require.False(t, found) diff --git a/x/vaas/provider/keeper/key_assignment.go b/x/vaas/provider/keeper/key_assignment.go index 75a9f83..9300ffe 100644 --- a/x/vaas/provider/keeper/key_assignment.go +++ b/x/vaas/provider/keeper/key_assignment.go @@ -67,7 +67,7 @@ func (k Keeper) ParseConsumerKey(consumerKey string) (tmprotocrypto.PublicKey, e // voted on in a ConsumerAddition governance proposal func (k Keeper) AssignConsumerKey( ctx sdk.Context, - consumerId string, + consumerId uint64, validator stakingtypes.Validator, consumerKey tmprotocrypto.PublicKey, ) error { @@ -75,7 +75,7 @@ func (k Keeper) AssignConsumerKey( // check that the consumer chain is either registered, initialized, or launched return errorsmod.Wrapf( types.ErrInvalidPhase, - "cannot assign a key to a consumer chain that is not in the registered, initialized, or launched phase: %s", consumerId) + "cannot assign a key to a consumer chain that is not in the registered, initialized, or launched phase: %d", consumerId) } consAddrTmp, err := vaastypes.TMCryptoPublicKeyToConsAddr(consumerKey) @@ -165,7 +165,7 @@ func (k Keeper) AssignConsumerKey( // consAddr set as the consensus address on a consumer chain func (k Keeper) GetProviderAddrFromConsumerAddr( ctx sdk.Context, - consumerId string, + consumerId uint64, consumerAddr types.ConsumerConsAddress, ) types.ProviderConsAddress { // check if this address is known only to the consumer chain @@ -179,7 +179,7 @@ func (k Keeper) GetProviderAddrFromConsumerAddr( // PruneKeyAssignments prunes the consumer addresses no longer needed // as they cannot be referenced in slash requests (by a correct consumer) -func (k Keeper) PruneKeyAssignments(ctx sdk.Context, consumerId string) { +func (k Keeper) PruneKeyAssignments(ctx sdk.Context, consumerId uint64) { now := ctx.BlockTime() consumerAddrs := k.ConsumeConsumerAddrsToPrune(ctx, consumerId, now) @@ -194,7 +194,7 @@ func (k Keeper) PruneKeyAssignments(ctx sdk.Context, consumerId string) { } // DeleteKeyAssignments deletes all the state needed for key assignments on a consumer chain -func (k Keeper) DeleteKeyAssignments(ctx sdk.Context, consumerId string) { +func (k Keeper) DeleteKeyAssignments(ctx sdk.Context, consumerId uint64) { // delete ValidatorConsumerPubKey for _, validatorConsumerAddr := range k.GetAllValidatorConsumerPubKeys(ctx, &consumerId) { providerAddr := types.NewProviderConsAddress(validatorConsumerAddr.ProviderAddr) diff --git a/x/vaas/provider/keeper/key_assignment_test.go b/x/vaas/provider/keeper/key_assignment_test.go index 7e82066..f001318 100644 --- a/x/vaas/provider/keeper/key_assignment_test.go +++ b/x/vaas/provider/keeper/key_assignment_test.go @@ -25,22 +25,22 @@ import ( ) func TestValidatorConsumerPubKeyCRUD(t *testing.T) { - chainID := CONSUMER_CHAIN_ID + consumerID := CONSUMER_ID providerAddr := types.NewProviderConsAddress([]byte("providerAddr")) consumerKey := cryptotestutil.NewCryptoIdentityFromIntSeed(1).TMProtoCryptoPublicKey() keeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - keeper.SetValidatorConsumerPubKey(ctx, chainID, providerAddr, consumerKey) + keeper.SetValidatorConsumerPubKey(ctx, consumerID, providerAddr, consumerKey) - consumerPubKey, found := keeper.GetValidatorConsumerPubKey(ctx, chainID, providerAddr) + consumerPubKey, found := keeper.GetValidatorConsumerPubKey(ctx, consumerID, providerAddr) require.True(t, found, "consumer pubkey not found") require.NotEmpty(t, consumerPubKey, "consumer pubkey is empty") require.Equal(t, consumerPubKey, consumerKey) - keeper.DeleteValidatorConsumerPubKey(ctx, chainID, providerAddr) - consumerPubKey, found = keeper.GetValidatorConsumerPubKey(ctx, chainID, providerAddr) + keeper.DeleteValidatorConsumerPubKey(ctx, consumerID, providerAddr) + consumerPubKey, found = keeper.GetValidatorConsumerPubKey(ctx, consumerID, providerAddr) require.False(t, found, "consumer pubkey was found") require.Empty(t, consumerPubKey, "consumer pubkey was returned") require.NotEqual(t, consumerPubKey, consumerKey) @@ -53,7 +53,7 @@ func TestGetAllValidatorConsumerPubKey(t *testing.T) { seed := time.Now().UnixNano() rng := rand.New(rand.NewSource(seed)) - chainIDs := []string{"consumer-1", "consumer-2", "consumer-3"} + consumerIDs := []uint64{1, 2, 3} numAssignments := 10 testAssignments := []types.ValidatorConsumerPubKey{} for i := range numAssignments { @@ -61,19 +61,19 @@ func TestGetAllValidatorConsumerPubKey(t *testing.T) { providerAddr := cryptotestutil.NewCryptoIdentityFromIntSeed(numAssignments + i).ProviderConsAddress() testAssignments = append(testAssignments, types.ValidatorConsumerPubKey{ - ChainId: chainIDs[rng.Intn(len(chainIDs))], + ConsumerId: consumerIDs[rng.Intn(len(consumerIDs))], ProviderAddr: providerAddr.ToSdkConsAddr(), ConsumerKey: &consumerKey, }, ) } // select a consumerId with more than two assignments - var chainID string - for i := range chainIDs { - chainID = chainIDs[i] + var consumerID uint64 + for i := range consumerIDs { + consumerID = consumerIDs[i] count := 0 for _, assignment := range testAssignments { - if assignment.ChainId == chainID { + if assignment.ConsumerId == consumerID { count++ } } @@ -83,7 +83,7 @@ func TestGetAllValidatorConsumerPubKey(t *testing.T) { } expectedGetAllOneConsumerOrder := []types.ValidatorConsumerPubKey{} for _, assignment := range testAssignments { - if assignment.ChainId == chainID { + if assignment.ConsumerId == consumerID { expectedGetAllOneConsumerOrder = append(expectedGetAllOneConsumerOrder, assignment) } } @@ -94,10 +94,10 @@ func TestGetAllValidatorConsumerPubKey(t *testing.T) { for _, assignment := range testAssignments { providerAddr := types.NewProviderConsAddress(assignment.ProviderAddr) - pk.SetValidatorConsumerPubKey(ctx, assignment.ChainId, providerAddr, *assignment.ConsumerKey) + pk.SetValidatorConsumerPubKey(ctx, assignment.ConsumerId, providerAddr, *assignment.ConsumerKey) } - result := pk.GetAllValidatorConsumerPubKeys(ctx, &chainID) + result := pk.GetAllValidatorConsumerPubKeys(ctx, &consumerID) require.Equal(t, expectedGetAllOneConsumerOrder, result) result = pk.GetAllValidatorConsumerPubKeys(ctx, nil) @@ -105,22 +105,22 @@ func TestGetAllValidatorConsumerPubKey(t *testing.T) { } func TestValidatorByConsumerAddrCRUD(t *testing.T) { - chainID := CONSUMER_CHAIN_ID + consumerID := CONSUMER_ID providerAddr := types.NewProviderConsAddress([]byte("providerAddr")) consumerAddr := types.NewConsumerConsAddress([]byte("consumerAddr")) keeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - keeper.SetValidatorByConsumerAddr(ctx, chainID, consumerAddr, providerAddr) + keeper.SetValidatorByConsumerAddr(ctx, consumerID, consumerAddr, providerAddr) - providerAddrResult, found := keeper.GetValidatorByConsumerAddr(ctx, chainID, consumerAddr) + providerAddrResult, found := keeper.GetValidatorByConsumerAddr(ctx, consumerID, consumerAddr) require.True(t, found, "provider address not found") require.NotEmpty(t, providerAddrResult, "provider address is empty") require.Equal(t, providerAddr, providerAddrResult) - keeper.DeleteValidatorByConsumerAddr(ctx, chainID, consumerAddr) - providerAddrResult, found = keeper.GetValidatorByConsumerAddr(ctx, chainID, consumerAddr) + keeper.DeleteValidatorByConsumerAddr(ctx, consumerID, consumerAddr) + providerAddrResult, found = keeper.GetValidatorByConsumerAddr(ctx, consumerID, consumerAddr) require.False(t, found, "provider address was found") require.Empty(t, providerAddrResult, "provider address not empty") require.NotEqual(t, providerAddr, providerAddrResult) @@ -133,7 +133,7 @@ func TestGetAllValidatorsByConsumerAddr(t *testing.T) { seed := time.Now().UnixNano() rng := rand.New(rand.NewSource(seed)) - chainIDs := []string{"consumer-1", "consumer-2", "consumer-3"} + consumerIDs := []uint64{1, 2, 3} numAssignments := 10 testAssignments := []types.ValidatorByConsumerAddr{} for i := range numAssignments { @@ -141,19 +141,19 @@ func TestGetAllValidatorsByConsumerAddr(t *testing.T) { providerAddr := cryptotestutil.NewCryptoIdentityFromIntSeed(numAssignments + i).ProviderConsAddress() testAssignments = append(testAssignments, types.ValidatorByConsumerAddr{ - ChainId: chainIDs[rng.Intn(len(chainIDs))], + ConsumerId: consumerIDs[rng.Intn(len(consumerIDs))], ConsumerAddr: consumerAddr.ToSdkConsAddr(), ProviderAddr: providerAddr.ToSdkConsAddr(), }, ) } // select a consumerId with more than two assignments - var chainID string - for i := range chainIDs { - chainID = chainIDs[i] + var consumerID uint64 + for i := range consumerIDs { + consumerID = consumerIDs[i] count := 0 for _, assignment := range testAssignments { - if assignment.ChainId == chainID { + if assignment.ConsumerId == consumerID { count++ } } @@ -163,7 +163,7 @@ func TestGetAllValidatorsByConsumerAddr(t *testing.T) { } expectedGetAllOneConsumerOrder := []types.ValidatorByConsumerAddr{} for _, assignment := range testAssignments { - if assignment.ChainId == chainID { + if assignment.ConsumerId == consumerID { expectedGetAllOneConsumerOrder = append(expectedGetAllOneConsumerOrder, assignment) } } @@ -175,10 +175,10 @@ func TestGetAllValidatorsByConsumerAddr(t *testing.T) { for _, assignment := range testAssignments { consumerAddr := types.NewConsumerConsAddress(assignment.ConsumerAddr) providerAddr := types.NewProviderConsAddress(assignment.ProviderAddr) - pk.SetValidatorByConsumerAddr(ctx, assignment.ChainId, consumerAddr, providerAddr) + pk.SetValidatorByConsumerAddr(ctx, assignment.ConsumerId, consumerAddr, providerAddr) } - result := pk.GetAllValidatorsByConsumerAddr(ctx, &chainID) + result := pk.GetAllValidatorsByConsumerAddr(ctx, &consumerID) require.Equal(t, expectedGetAllOneConsumerOrder, result) result = pk.GetAllValidatorsByConsumerAddr(ctx, nil) @@ -186,7 +186,7 @@ func TestGetAllValidatorsByConsumerAddr(t *testing.T) { } func TestConsumerAddrsToPruneCRUD(t *testing.T) { - chainID := CONSUMER_CHAIN_ID + consumerID := CONSUMER_ID consumerAddr1 := types.NewConsumerConsAddress([]byte("consumerAddr1")) consumerAddr2 := types.NewConsumerConsAddress([]byte("consumerAddr2")) @@ -196,40 +196,40 @@ func TestConsumerAddrsToPruneCRUD(t *testing.T) { ts1 := ctx.BlockTime() ts2 := ts1.Add(time.Hour) - addrsToPrune := keeper.GetConsumerAddrsToPrune(ctx, chainID, ts1).Addresses + addrsToPrune := keeper.GetConsumerAddrsToPrune(ctx, consumerID, ts1).Addresses require.Empty(t, addrsToPrune) - keeper.AppendConsumerAddrsToPrune(ctx, chainID, ts1, consumerAddr1) + keeper.AppendConsumerAddrsToPrune(ctx, consumerID, ts1, consumerAddr1) - addrsToPrune = keeper.GetConsumerAddrsToPrune(ctx, chainID, ts1).Addresses + addrsToPrune = keeper.GetConsumerAddrsToPrune(ctx, consumerID, ts1).Addresses require.NotEmpty(t, addrsToPrune, "addresses to prune is empty") require.Len(t, addrsToPrune, 1, "addresses to prune is not len 1") require.Equal(t, addrsToPrune[0], consumerAddr1.ToSdkConsAddr().Bytes()) - keeper.AppendConsumerAddrsToPrune(ctx, chainID, ts2, consumerAddr2) + keeper.AppendConsumerAddrsToPrune(ctx, consumerID, ts2, consumerAddr2) - addrsToPrune = keeper.GetConsumerAddrsToPrune(ctx, chainID, ts2).Addresses + addrsToPrune = keeper.GetConsumerAddrsToPrune(ctx, consumerID, ts2).Addresses require.NotEmpty(t, addrsToPrune, "addresses to prune is empty") require.Len(t, addrsToPrune, 1, "addresses to prune is not len 1") require.Equal(t, addrsToPrune[0], consumerAddr2.ToSdkConsAddr().Bytes()) - keeper.DeleteConsumerAddrsToPrune(ctx, chainID, ts1) - addrsToPrune = keeper.GetConsumerAddrsToPrune(ctx, chainID, ts1).Addresses + keeper.DeleteConsumerAddrsToPrune(ctx, consumerID, ts1) + addrsToPrune = keeper.GetConsumerAddrsToPrune(ctx, consumerID, ts1).Addresses require.Empty(t, addrsToPrune, "addresses to prune was returned") - addrsToPrune = keeper.GetConsumerAddrsToPrune(ctx, chainID, ts2).Addresses + addrsToPrune = keeper.GetConsumerAddrsToPrune(ctx, consumerID, ts2).Addresses require.NotEmpty(t, addrsToPrune, "addresses to prune is empty") require.Len(t, addrsToPrune, 1, "addresses to prune is not len 1") require.Equal(t, addrsToPrune[0], consumerAddr2.ToSdkConsAddr().Bytes()) - keeper.AppendConsumerAddrsToPrune(ctx, chainID, ts1, consumerAddr1) + keeper.AppendConsumerAddrsToPrune(ctx, consumerID, ts1, consumerAddr1) - addrsToPrune = keeper.ConsumeConsumerAddrsToPrune(ctx, chainID, ts1).Addresses + addrsToPrune = keeper.ConsumeConsumerAddrsToPrune(ctx, consumerID, ts1).Addresses require.NotEmpty(t, addrsToPrune, "addresses to prune was returned") require.Len(t, addrsToPrune, 1, "addresses to prune is not len 1") require.Equal(t, addrsToPrune[0], consumerAddr1.ToSdkConsAddr().Bytes()) - addrsToPrune = keeper.GetConsumerAddrsToPrune(ctx, chainID, ts1).Addresses + addrsToPrune = keeper.GetConsumerAddrsToPrune(ctx, consumerID, ts1).Addresses require.Empty(t, addrsToPrune, "addresses to prune was returned") - addrsToPrune = keeper.GetConsumerAddrsToPrune(ctx, chainID, ts2).Addresses + addrsToPrune = keeper.GetConsumerAddrsToPrune(ctx, consumerID, ts2).Addresses require.NotEmpty(t, addrsToPrune, "addresses to prune is empty") require.Len(t, addrsToPrune, 1, "addresses to prune is not len 1") require.Equal(t, addrsToPrune[0], consumerAddr2.ToSdkConsAddr().Bytes()) @@ -242,7 +242,7 @@ func TestGetAllConsumerAddrsToPrune(t *testing.T) { seed := time.Now().UnixNano() rng := rand.New(rand.NewSource(seed)) - chainIDs := []string{"consumer-1", "consumer-2", "consumer-3"} + consumerIDs := []uint64{1, 2, 3} numAssignments := 10 testAssignments := []types.ConsumerAddrsToPrune{} for i := range numAssignments { @@ -253,19 +253,19 @@ func TestGetAllConsumerAddrsToPrune(t *testing.T) { } testAssignments = append(testAssignments, types.ConsumerAddrsToPrune{ - ChainId: chainIDs[rng.Intn(len(chainIDs))], + ConsumerId: consumerIDs[rng.Intn(len(consumerIDs))], PruneTs: time.Now().UTC(), ConsumerAddrs: &consumerAddresses, }, ) } // select a consumerId with more than two assignments - var chainID string - for i := range chainIDs { - chainID = chainIDs[i] + var consumerID uint64 + for i := range consumerIDs { + consumerID = consumerIDs[i] count := 0 for _, assignment := range testAssignments { - if assignment.ChainId == chainID { + if assignment.ConsumerId == consumerID { count++ } } @@ -275,7 +275,7 @@ func TestGetAllConsumerAddrsToPrune(t *testing.T) { } expectedGetAllOrder := []types.ConsumerAddrsToPrune{} for _, assignment := range testAssignments { - if assignment.ChainId == chainID { + if assignment.ConsumerId == consumerID { expectedGetAllOrder = append(expectedGetAllOrder, assignment) } } @@ -287,17 +287,17 @@ func TestGetAllConsumerAddrsToPrune(t *testing.T) { for _, assignment := range testAssignments { for _, addr := range assignment.ConsumerAddrs.Addresses { consumerAddr := types.NewConsumerConsAddress(addr) - pk.AppendConsumerAddrsToPrune(ctx, assignment.ChainId, assignment.PruneTs, consumerAddr) + pk.AppendConsumerAddrsToPrune(ctx, assignment.ConsumerId, assignment.PruneTs, consumerAddr) } } - result := pk.GetAllConsumerAddrsToPrune(ctx, chainID) + result := pk.GetAllConsumerAddrsToPrune(ctx, consumerID) require.Equal(t, expectedGetAllOrder, result) } // checkCorrectPruningProperty checks that the pruning property is correct for a given // consumer chain. See AppendConsumerAddrsToPrune for a formulation of the property. -func checkCorrectPruningProperty(ctx sdk.Context, k providerkeeper.Keeper, chainID string) bool { +func checkCorrectPruningProperty(ctx sdk.Context, k providerkeeper.Keeper, consumerID uint64) bool { /* For each consumer address cAddr in ValidatorByConsumerAddr, - either there exists a provider address pAddr in ValidatorConsumerPubKey, @@ -305,7 +305,7 @@ func checkCorrectPruningProperty(ctx sdk.Context, k providerkeeper.Keeper, chain - or there exists a timestamp in ConsumerAddrsToPrune s.t. cAddr in ConsumerAddrsToPrune(timestamp) */ willBePruned := map[string]bool{} - for _, consAddrToPrune := range k.GetAllConsumerAddrsToPrune(ctx, chainID) { + for _, consAddrToPrune := range k.GetAllConsumerAddrsToPrune(ctx, consumerID) { for _, cAddr := range consAddrToPrune.ConsumerAddrs.Addresses { willBePruned[string(cAddr)] = true } @@ -320,7 +320,7 @@ func checkCorrectPruningProperty(ctx sdk.Context, k providerkeeper.Keeper, chain // Try to find a validator who has this consumer address currently assigned isCurrentlyAssigned := false - for _, valconsPubKey := range k.GetAllValidatorConsumerPubKeys(ctx, &valByConsAddr.ChainId) { + for _, valconsPubKey := range k.GetAllValidatorConsumerPubKeys(ctx, &valByConsAddr.ConsumerId) { consumerAddr, _ := vaastypes.TMCryptoPublicKeyToConsAddr(*valconsPubKey.ConsumerKey) if consumerAddr.Equals(sdk.ConsAddress(valByConsAddr.ConsumerAddr)) { isCurrentlyAssigned = true @@ -339,7 +339,7 @@ func checkCorrectPruningProperty(ctx sdk.Context, k providerkeeper.Keeper, chain } func TestAssignConsensusKeyForConsumerChain(t *testing.T) { - consumerId := "0" + consumerId := uint64(0) providerIdentities := []*cryptotestutil.CryptoIdentity{ cryptotestutil.NewCryptoIdentityFromIntSeed(0), cryptotestutil.NewCryptoIdentityFromIntSeed(1), diff --git a/x/vaas/provider/keeper/msg_server.go b/x/vaas/provider/keeper/msg_server.go index 012a0f9..e844ad8 100644 --- a/x/vaas/provider/keeper/msg_server.go +++ b/x/vaas/provider/keeper/msg_server.go @@ -2,6 +2,7 @@ package keeper import ( "context" + "strconv" "strings" "time" @@ -89,7 +90,7 @@ func (k msgServer) AssignConsumerKey(goCtx context.Context, msg *types.MsgAssign sdk.NewEvent( types.EventTypeAssignConsumerKey, sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), - sdk.NewAttribute(types.AttributeConsumerId, msg.ConsumerId), + sdk.NewAttribute(types.AttributeConsumerId, strconv.FormatUint(msg.ConsumerId, 10)), sdk.NewAttribute(types.AttributeConsumerChainId, chainId), sdk.NewAttribute(types.AttributeProviderValidatorAddress, msg.ProviderAddr), sdk.NewAttribute(types.AttributeConsumerConsensusPubKey, msg.ConsumerKey), @@ -110,7 +111,7 @@ func (k msgServer) SubmitConsumerMisbehaviour(goCtx context.Context, msg *types. sdk.NewEvent( vaastypes.EventTypeSubmitConsumerMisbehaviour, sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), - sdk.NewAttribute(types.AttributeConsumerId, msg.ConsumerId), + sdk.NewAttribute(types.AttributeConsumerId, strconv.FormatUint(msg.ConsumerId, 10)), sdk.NewAttribute(types.AttributeConsumerChainId, msg.Misbehaviour.Header1.Header.ChainID), sdk.NewAttribute(vaastypes.AttributeConsumerMisbehaviour, msg.Misbehaviour.String()), sdk.NewAttribute(vaastypes.AttributeMisbehaviourClientId, msg.Misbehaviour.ClientId), @@ -164,7 +165,7 @@ func (k msgServer) SubmitConsumerDoubleVoting(goCtx context.Context, msg *types. sdk.NewEvent( vaastypes.EventTypeSubmitConsumerDoubleVoting, sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), - sdk.NewAttribute(types.AttributeConsumerId, msg.ConsumerId), + sdk.NewAttribute(types.AttributeConsumerId, strconv.FormatUint(msg.ConsumerId, 10)), sdk.NewAttribute(types.AttributeConsumerChainId, msg.InfractionBlockHeader.Header.ChainID), sdk.NewAttribute(vaastypes.AttributeConsumerDoubleVoting, msg.DuplicateVoteEvidence.String()), sdk.NewAttribute(types.AttributeSubmitterAddress, msg.Submitter), @@ -204,7 +205,7 @@ func (k msgServer) CreateConsumer(goCtx context.Context, msg *types.MsgCreateCon // add event attributes eventAttributes = append(eventAttributes, []sdk.Attribute{ sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), - sdk.NewAttribute(types.AttributeConsumerId, consumerId), + sdk.NewAttribute(types.AttributeConsumerId, strconv.FormatUint(consumerId, 10)), sdk.NewAttribute(types.AttributeConsumerChainId, msg.ChainId), sdk.NewAttribute(types.AttributeConsumerName, msg.Metadata.Name), sdk.NewAttribute(types.AttributeSubmitterAddress, msg.Submitter), @@ -228,7 +229,7 @@ func (k msgServer) CreateConsumer(goCtx context.Context, msg *types.MsgCreateCon if spawnTime, initialized := k.Keeper.InitializeConsumer(ctx, consumerId); initialized { if err := k.Keeper.PrepareConsumerForLaunch(ctx, consumerId, time.Time{}, spawnTime); err != nil { return &resp, errorsmod.Wrapf(vaastypes.ErrInvalidConsumerState, - "prepare consumer for launch, consumerId(%s), spawnTime(%s): %s", consumerId, spawnTime, err.Error()) + "prepare consumer for launch, consumerId(%d), spawnTime(%s): %s", consumerId, spawnTime, err.Error()) } // add SpawnTime event attribute @@ -271,7 +272,7 @@ func (k msgServer) UpdateConsumer(goCtx context.Context, msg *types.MsgUpdateCon if !k.Keeper.IsConsumerActive(ctx, consumerId) { return &resp, errorsmod.Wrapf(types.ErrInvalidPhase, - "cannot update consumer chain that is not in the registered, initialized, or launched phase: %s", consumerId) + "cannot update consumer chain that is not in the registered, initialized, or launched phase: %d", consumerId) } ownerAddress, err := k.Keeper.GetConsumerOwnerAddress(ctx, consumerId) @@ -315,7 +316,7 @@ func (k msgServer) UpdateConsumer(goCtx context.Context, msg *types.MsgUpdateCon // add event attributes eventAttributes = append(eventAttributes, []sdk.Attribute{ sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), - sdk.NewAttribute(types.AttributeConsumerId, consumerId), + sdk.NewAttribute(types.AttributeConsumerId, strconv.FormatUint(consumerId, 10)), sdk.NewAttribute(types.AttributeConsumerChainId, chainId), sdk.NewAttribute(types.AttributeSubmitterAddress, msg.Owner), }...) @@ -344,7 +345,7 @@ func (k msgServer) UpdateConsumer(goCtx context.Context, msg *types.MsgUpdateCon previousInitializationParameters, err := k.Keeper.GetConsumerInitializationParameters(ctx, consumerId) if err != nil { return &resp, errorsmod.Wrapf(vaastypes.ErrInvalidConsumerState, - "cannot get consumer initialized parameters, consumerId(%s): %s", consumerId, err.Error()) + "cannot get consumer initialized parameters, consumerId(%d): %s", consumerId, err.Error()) } previousSpawnTime := previousInitializationParameters.SpawnTime @@ -389,7 +390,7 @@ func (k msgServer) UpdateConsumer(goCtx context.Context, msg *types.MsgUpdateCon if spawnTime, initialized := k.Keeper.InitializeConsumer(ctx, consumerId); initialized { if err := k.Keeper.PrepareConsumerForLaunch(ctx, consumerId, previousSpawnTime, spawnTime); err != nil { return &resp, errorsmod.Wrapf(vaastypes.ErrInvalidConsumerState, - "prepare consumer for launch, consumerId(%s), previousSpawnTime(%s), spawnTime(%s): %s", + "prepare consumer for launch, consumerId(%d), previousSpawnTime(%s), spawnTime(%s): %s", consumerId, previousSpawnTime, spawnTime, err.Error()) } } @@ -442,7 +443,7 @@ func (k msgServer) RemoveConsumer(goCtx context.Context, msg *types.MsgRemoveCon phase := k.Keeper.GetConsumerPhase(ctx, consumerId) if phase != types.CONSUMER_PHASE_LAUNCHED { return &resp, errorsmod.Wrapf(types.ErrInvalidPhase, - "chain with consumer id: %s has to be in its launched phase", consumerId) + "chain with consumer id: %d has to be in its launched phase", consumerId) } err = k.Keeper.StopAndPrepareForConsumerRemoval(ctx, consumerId) @@ -457,7 +458,7 @@ func (k msgServer) RemoveConsumer(goCtx context.Context, msg *types.MsgRemoveCon sdk.NewEvent( types.EventTypeRemoveConsumer, sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), - sdk.NewAttribute(types.AttributeConsumerId, consumerId), + sdk.NewAttribute(types.AttributeConsumerId, strconv.FormatUint(consumerId, 10)), sdk.NewAttribute(types.AttributeConsumerChainId, chainId), sdk.NewAttribute(types.AttributeSubmitterAddress, msg.Owner), ), diff --git a/x/vaas/provider/keeper/msg_server_test.go b/x/vaas/provider/keeper/msg_server_test.go index 5724f8c..9b610fb 100644 --- a/x/vaas/provider/keeper/msg_server_test.go +++ b/x/vaas/provider/keeper/msg_server_test.go @@ -28,14 +28,14 @@ func TestCreateConsumer(t *testing.T) { InitializationParameters: &providertypes.ConsumerInitializationParameters{}, }) require.NoError(t, err) - require.Equal(t, "0", response.ConsumerId) - actualMetadata, err := providerKeeper.GetConsumerMetadata(ctx, "0") + require.Equal(t, uint64(0), response.ConsumerId) + actualMetadata, err := providerKeeper.GetConsumerMetadata(ctx, 0) require.NoError(t, err) require.Equal(t, consumerMetadata, actualMetadata) - ownerAddress, err := providerKeeper.GetConsumerOwnerAddress(ctx, "0") + ownerAddress, err := providerKeeper.GetConsumerOwnerAddress(ctx, 0) require.NoError(t, err) require.Equal(t, "submitter", ownerAddress) - phase := providerKeeper.GetConsumerPhase(ctx, "0") + phase := providerKeeper.GetConsumerPhase(ctx, 0) require.Equal(t, providertypes.CONSUMER_PHASE_REGISTERED, phase) // Create another consumer with a different chain id @@ -50,14 +50,14 @@ func TestCreateConsumer(t *testing.T) { }) require.NoError(t, err) // assert that the consumer id is different from the previously registered chain - require.Equal(t, "1", response.ConsumerId) - actualMetadata, err = providerKeeper.GetConsumerMetadata(ctx, "1") + require.Equal(t, uint64(1), response.ConsumerId) + actualMetadata, err = providerKeeper.GetConsumerMetadata(ctx, 1) require.NoError(t, err) require.Equal(t, consumerMetadata, actualMetadata) - ownerAddress, err = providerKeeper.GetConsumerOwnerAddress(ctx, "1") + ownerAddress, err = providerKeeper.GetConsumerOwnerAddress(ctx, 1) require.NoError(t, err) require.Equal(t, "submitter2", ownerAddress) - phase = providerKeeper.GetConsumerPhase(ctx, "1") + phase = providerKeeper.GetConsumerPhase(ctx, 1) require.Equal(t, providertypes.CONSUMER_PHASE_REGISTERED, phase) } @@ -79,7 +79,7 @@ func TestCreateConsumerDuplicateChainId(t *testing.T) { InitializationParameters: &providertypes.ConsumerInitializationParameters{}, }) require.NoError(t, err) - require.Equal(t, "0", response.ConsumerId) + require.Equal(t, uint64(0), response.ConsumerId) // Attempt to register another consumer with the same chainId _, err = msgServer.CreateConsumer(ctx, @@ -100,7 +100,7 @@ func TestUpdateConsumer(t *testing.T) { // try to update a non-existing consumer _, err := msgServer.UpdateConsumer(ctx, &providertypes.MsgUpdateConsumer{ - Owner: "owner", ConsumerId: "0", NewOwnerAddress: "cosmos1dkas8mu4kyhl5jrh4nzvm65qz588hy9qcz08la", + Owner: "owner", ConsumerId: 0, NewOwnerAddress: "cosmos1dkas8mu4kyhl5jrh4nzvm65qz588hy9qcz08la", }) require.Error(t, err, "cannot update consumer chain") diff --git a/x/vaas/provider/keeper/permissionless.go b/x/vaas/provider/keeper/permissionless.go index efb0c6f..99d9d92 100644 --- a/x/vaas/provider/keeper/permissionless.go +++ b/x/vaas/provider/keeper/permissionless.go @@ -3,7 +3,6 @@ package keeper import ( "context" "fmt" - "strconv" "github.com/allinbits/vaas/x/vaas/provider/types" ) @@ -25,19 +24,19 @@ func (k Keeper) GetConsumerId(ctx context.Context) (uint64, bool) { // FetchAndIncrementConsumerId fetches the first consumer id that can be used and increments the // underlying consumer id -func (k Keeper) FetchAndIncrementConsumerId(ctx context.Context) string { +func (k Keeper) FetchAndIncrementConsumerId(ctx context.Context) uint64 { consumerId, err := k.ConsumerId.Next(ctx) if err != nil { panic(fmt.Errorf("failed to get next consumer id: %w", err)) } - return strconv.FormatUint(consumerId, 10) + return consumerId } // GetConsumerChainId returns the chain id associated with this consumer id -func (k Keeper) GetConsumerChainId(ctx context.Context, consumerId string) (string, error) { +func (k Keeper) GetConsumerChainId(ctx context.Context, consumerId uint64) (string, error) { chainId, err := k.ConsumerChainId.Get(ctx, consumerId) if err != nil { - return "", fmt.Errorf("failed to retrieve chain id for consumer id (%s): %w", consumerId, err) + return "", fmt.Errorf("failed to retrieve chain id for consumer id (%d): %w", consumerId, err) } return chainId, nil } @@ -63,102 +62,102 @@ func (k Keeper) ChainIdInUse(ctx context.Context, chainId string) (bool, error) } // SetConsumerChainId sets the chain id associated with this consumer id -func (k Keeper) SetConsumerChainId(ctx context.Context, consumerId, chainId string) { +func (k Keeper) SetConsumerChainId(ctx context.Context, consumerId uint64, chainId string) { if err := k.ConsumerChainId.Set(ctx, consumerId, chainId); err != nil { - panic(fmt.Errorf("failed to set chain id for consumer id (%s): %w", consumerId, err)) + panic(fmt.Errorf("failed to set chain id for consumer id (%d): %w", consumerId, err)) } } // DeleteConsumerChainId deletes the chain id associated with this consumer id -func (k Keeper) DeleteConsumerChainId(ctx context.Context, consumerId string) { +func (k Keeper) DeleteConsumerChainId(ctx context.Context, consumerId uint64) { if err := k.ConsumerChainId.Remove(ctx, consumerId); err != nil { - panic(fmt.Errorf("failed to delete chain id for consumer id (%s): %w", consumerId, err)) + panic(fmt.Errorf("failed to delete chain id for consumer id (%d): %w", consumerId, err)) } } // GetConsumerOwnerAddress returns the owner address associated with this consumer id -func (k Keeper) GetConsumerOwnerAddress(ctx context.Context, consumerId string) (string, error) { +func (k Keeper) GetConsumerOwnerAddress(ctx context.Context, consumerId uint64) (string, error) { owner, err := k.ConsumerOwnerAddress.Get(ctx, consumerId) if err != nil { - return "", fmt.Errorf("failed to retrieve owner address for consumer id (%s): %w", consumerId, err) + return "", fmt.Errorf("failed to retrieve owner address for consumer id (%d): %w", consumerId, err) } return owner, nil } // SetConsumerOwnerAddress sets the owner address associated with this consumer id -func (k Keeper) SetConsumerOwnerAddress(ctx context.Context, consumerId, owner string) { +func (k Keeper) SetConsumerOwnerAddress(ctx context.Context, consumerId uint64, owner string) { if err := k.ConsumerOwnerAddress.Set(ctx, consumerId, owner); err != nil { - panic(fmt.Errorf("failed to set owner address for consumer id (%s): %w", consumerId, err)) + panic(fmt.Errorf("failed to set owner address for consumer id (%d): %w", consumerId, err)) } } // DeleteConsumerOwnerAddress deletes the owner address associated with this consumer id -func (k Keeper) DeleteConsumerOwnerAddress(ctx context.Context, consumerId string) { +func (k Keeper) DeleteConsumerOwnerAddress(ctx context.Context, consumerId uint64) { if err := k.ConsumerOwnerAddress.Remove(ctx, consumerId); err != nil { - panic(fmt.Errorf("failed to delete owner address for consumer id (%s): %w", consumerId, err)) + panic(fmt.Errorf("failed to delete owner address for consumer id (%d): %w", consumerId, err)) } } // GetConsumerMetadata returns the registration record associated with this consumer id -func (k Keeper) GetConsumerMetadata(ctx context.Context, consumerId string) (types.ConsumerMetadata, error) { +func (k Keeper) GetConsumerMetadata(ctx context.Context, consumerId uint64) (types.ConsumerMetadata, error) { metadata, err := k.ConsumerMetadata.Get(ctx, consumerId) if err != nil { - return types.ConsumerMetadata{}, fmt.Errorf("failed to retrieve metadata for consumer id (%s): %w", consumerId, err) + return types.ConsumerMetadata{}, fmt.Errorf("failed to retrieve metadata for consumer id (%d): %w", consumerId, err) } return metadata, nil } // SetConsumerMetadata sets the registration record associated with this consumer id -func (k Keeper) SetConsumerMetadata(ctx context.Context, consumerId string, metadata types.ConsumerMetadata) error { +func (k Keeper) SetConsumerMetadata(ctx context.Context, consumerId uint64, metadata types.ConsumerMetadata) error { if err := k.ConsumerMetadata.Set(ctx, consumerId, metadata); err != nil { - return fmt.Errorf("failed to set metadata for consumer id (%s): %w", consumerId, err) + return fmt.Errorf("failed to set metadata for consumer id (%d): %w", consumerId, err) } return nil } // DeleteConsumerMetadata deletes the metadata associated with this consumer id -func (k Keeper) DeleteConsumerMetadata(ctx context.Context, consumerId string) { +func (k Keeper) DeleteConsumerMetadata(ctx context.Context, consumerId uint64) { if err := k.ConsumerMetadata.Remove(ctx, consumerId); err != nil { - panic(fmt.Errorf("failed to delete metadata for consumer id (%s): %w", consumerId, err)) + panic(fmt.Errorf("failed to delete metadata for consumer id (%d): %w", consumerId, err)) } } // GetConsumerInitializationParameters returns the initialization parameters associated with this consumer id -func (k Keeper) GetConsumerInitializationParameters(ctx context.Context, consumerId string) (types.ConsumerInitializationParameters, error) { +func (k Keeper) GetConsumerInitializationParameters(ctx context.Context, consumerId uint64) (types.ConsumerInitializationParameters, error) { params, err := k.ConsumerInitParams.Get(ctx, consumerId) if err != nil { - return types.ConsumerInitializationParameters{}, fmt.Errorf("failed to retrieve initialization parameters for consumer id (%s): %w", consumerId, err) + return types.ConsumerInitializationParameters{}, fmt.Errorf("failed to retrieve initialization parameters for consumer id (%d): %w", consumerId, err) } return params, nil } // SetConsumerInitializationParameters sets the initialization parameters associated with this consumer id -func (k Keeper) SetConsumerInitializationParameters(ctx context.Context, consumerId string, parameters types.ConsumerInitializationParameters) error { +func (k Keeper) SetConsumerInitializationParameters(ctx context.Context, consumerId uint64, parameters types.ConsumerInitializationParameters) error { chainId, err := k.GetConsumerChainId(ctx, consumerId) if err != nil { - return fmt.Errorf("failed to get consumer chain ID for consumer id (%s): %w", consumerId, err) + return fmt.Errorf("failed to get consumer chain ID for consumer id (%d): %w", consumerId, err) } // validate that the initial height matches the chain ID if err := types.ValidateInitialHeight(parameters.InitialHeight, chainId); err != nil { - return fmt.Errorf("invalid initial height for consumer id (%s): %w", consumerId, err) + return fmt.Errorf("invalid initial height for consumer id (%d): %w", consumerId, err) } if err := k.ConsumerInitParams.Set(ctx, consumerId, parameters); err != nil { - return fmt.Errorf("failed to set initialization parameters for consumer id (%s): %w", consumerId, err) + return fmt.Errorf("failed to set initialization parameters for consumer id (%d): %w", consumerId, err) } return nil } // validateExistingIBCLink validates that an existing IBC connection is fully functional. // DeleteConsumerInitializationParameters deletes the initialization parameters associated with this consumer id -func (k Keeper) DeleteConsumerInitializationParameters(ctx context.Context, consumerId string) { +func (k Keeper) DeleteConsumerInitializationParameters(ctx context.Context, consumerId uint64) { if err := k.ConsumerInitParams.Remove(ctx, consumerId); err != nil { - panic(fmt.Errorf("failed to delete initialization parameters for consumer id (%s): %w", consumerId, err)) + panic(fmt.Errorf("failed to delete initialization parameters for consumer id (%d): %w", consumerId, err)) } } // GetConsumerPhase returns the phase associated with this consumer id -func (k Keeper) GetConsumerPhase(ctx context.Context, consumerId string) types.ConsumerPhase { +func (k Keeper) GetConsumerPhase(ctx context.Context, consumerId uint64) types.ConsumerPhase { phase, err := k.ConsumerPhase.Get(ctx, consumerId) if err != nil { return types.CONSUMER_PHASE_UNSPECIFIED @@ -167,28 +166,28 @@ func (k Keeper) GetConsumerPhase(ctx context.Context, consumerId string) types.C } // SetConsumerPhase sets the phase associated with this consumer id -func (k Keeper) SetConsumerPhase(ctx context.Context, consumerId string, phase types.ConsumerPhase) { +func (k Keeper) SetConsumerPhase(ctx context.Context, consumerId uint64, phase types.ConsumerPhase) { if err := k.ConsumerPhase.Set(ctx, consumerId, uint32(phase)); err != nil { - panic(fmt.Errorf("failed to set consumer phase for consumer id (%s): %w", consumerId, err)) + panic(fmt.Errorf("failed to set consumer phase for consumer id (%d): %w", consumerId, err)) } } // DeleteConsumerPhase deletes the phase associated with this consumer id -func (k Keeper) DeleteConsumerPhase(ctx context.Context, consumerId string) { +func (k Keeper) DeleteConsumerPhase(ctx context.Context, consumerId uint64) { if err := k.ConsumerPhase.Remove(ctx, consumerId); err != nil { - panic(fmt.Errorf("failed to delete consumer phase for consumer id (%s): %w", consumerId, err)) + panic(fmt.Errorf("failed to delete consumer phase for consumer id (%d): %w", consumerId, err)) } } // IsConsumerPrelaunched checks if a consumer chain is in its prelaunch phase -func (k Keeper) IsConsumerPrelaunched(ctx context.Context, consumerId string) bool { +func (k Keeper) IsConsumerPrelaunched(ctx context.Context, consumerId uint64) bool { phase := k.GetConsumerPhase(ctx, consumerId) return phase == types.CONSUMER_PHASE_REGISTERED || phase == types.CONSUMER_PHASE_INITIALIZED } // IsConsumerActive checks if a consumer chain is either registered, initialized, or launched. -func (k Keeper) IsConsumerActive(ctx context.Context, consumerId string) bool { +func (k Keeper) IsConsumerActive(ctx context.Context, consumerId uint64) bool { phase := k.GetConsumerPhase(ctx, consumerId) return phase == types.CONSUMER_PHASE_REGISTERED || phase == types.CONSUMER_PHASE_INITIALIZED || diff --git a/x/vaas/provider/keeper/permissionless_test.go b/x/vaas/provider/keeper/permissionless_test.go index 1a9b9c3..17be29b 100644 --- a/x/vaas/provider/keeper/permissionless_test.go +++ b/x/vaas/provider/keeper/permissionless_test.go @@ -20,13 +20,13 @@ func TestConsumerId(t *testing.T) { require.False(t, found) consumerId := providerKeeper.FetchAndIncrementConsumerId(ctx) - require.Equal(t, "0", consumerId) + require.Equal(t, uint64(0), consumerId) consumerIdNum, found := providerKeeper.GetConsumerId(ctx) require.Equal(t, uint64(1), consumerIdNum) require.True(t, found) consumerId = providerKeeper.FetchAndIncrementConsumerId(ctx) - require.Equal(t, "1", consumerId) + require.Equal(t, uint64(1), consumerId) consumerIdNum, found = providerKeeper.GetConsumerId(ctx) require.Equal(t, uint64(2), consumerIdNum) require.True(t, found) @@ -37,28 +37,28 @@ func TestConsumerChainId(t *testing.T) { providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - _, err := providerKeeper.GetConsumerChainId(ctx, "chainId") + _, err := providerKeeper.GetConsumerChainId(ctx, 1) require.Error(t, err, "failed to retrieve chain id") - providerKeeper.SetConsumerChainId(ctx, "chainId", "chainId") - chainId, err := providerKeeper.GetConsumerChainId(ctx, "chainId") + providerKeeper.SetConsumerChainId(ctx, 1, "chainId") + chainId, err := providerKeeper.GetConsumerChainId(ctx, 1) require.NoError(t, err) require.Equal(t, "chainId", chainId) // write under a different key - providerKeeper.SetConsumerChainId(ctx, "consumerId2", "chainId") - chainId, err = providerKeeper.GetConsumerChainId(ctx, "consumerId2") + providerKeeper.SetConsumerChainId(ctx, 2, "chainId") + chainId, err = providerKeeper.GetConsumerChainId(ctx, 2) require.NoError(t, err) require.Equal(t, "chainId", chainId) // assert that overwriting the current key works - providerKeeper.SetConsumerChainId(ctx, "chainId", "chainId2") - chainId, err = providerKeeper.GetConsumerChainId(ctx, "chainId") + providerKeeper.SetConsumerChainId(ctx, 1, "chainId2") + chainId, err = providerKeeper.GetConsumerChainId(ctx, 1) require.NoError(t, err) require.Equal(t, "chainId2", chainId) - providerKeeper.DeleteConsumerChainId(ctx, "chainId") - _, err = providerKeeper.GetConsumerChainId(ctx, "chainId") + providerKeeper.DeleteConsumerChainId(ctx, 1) + _, err = providerKeeper.GetConsumerChainId(ctx, 1) require.Error(t, err, "failed to retrieve chain id") } @@ -67,7 +67,7 @@ func TestConsumerOwnerAddress(t *testing.T) { providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - _, err := providerKeeper.GetConsumerOwnerAddress(ctx, "ownerAddress") + _, err := providerKeeper.GetConsumerOwnerAddress(ctx, 99) require.Error(t, err, "failed to retrieve owner address") providerKeeper.SetConsumerOwnerAddress(ctx, CONSUMER_ID, "owner address") @@ -76,8 +76,8 @@ func TestConsumerOwnerAddress(t *testing.T) { require.Equal(t, "owner address", ownerAddress) // write under a different key - providerKeeper.SetConsumerOwnerAddress(ctx, "consumerId2", "owner address") - ownerAddress, err = providerKeeper.GetConsumerOwnerAddress(ctx, "consumerId2") + providerKeeper.SetConsumerOwnerAddress(ctx, 2, "owner address") + ownerAddress, err = providerKeeper.GetConsumerOwnerAddress(ctx, 2) require.NoError(t, err) require.Equal(t, "owner address", ownerAddress) diff --git a/x/vaas/provider/keeper/relay.go b/x/vaas/provider/keeper/relay.go index 46849fd..21f8b91 100644 --- a/x/vaas/provider/keeper/relay.go +++ b/x/vaas/provider/keeper/relay.go @@ -135,7 +135,7 @@ func (k Keeper) SendVSCPackets(ctx sdk.Context) error { } if err := k.SendVSCPacketsToChain(ctx, consumerId, clientID); err != nil { - return fmt.Errorf("sending VSCPacket to consumer, consumerId(%s): %w", consumerId, err) + return fmt.Errorf("sending VSCPacket to consumer, consumerId(%d): %w", consumerId, err) } } return nil @@ -145,7 +145,7 @@ func (k Keeper) SendVSCPackets(ctx sdk.Context) error { // and returns the one with the highest latest height that has a counterparty registered. // This allows the provider to use a client being actively updated by a relayer. // The current client is only replaced if it is expired, frozen, or has no counterparty. -func (k Keeper) discoverActiveConsumerClient(ctx sdk.Context, consumerId, currentClientID string) string { +func (k Keeper) discoverActiveConsumerClient(ctx sdk.Context, consumerId uint64, currentClientID string) string { if currentClientID != "" { currentStatus := k.clientKeeper.GetClientStatus(ctx, currentClientID) if currentStatus == ibcexported.Active { @@ -196,7 +196,7 @@ func (k Keeper) discoverActiveConsumerClient(ctx sdk.Context, consumerId, curren return currentClientID } -func (k Keeper) SendVSCPacketsToChain(ctx sdk.Context, consumerId, clientId string) error { +func (k Keeper) SendVSCPacketsToChain(ctx sdk.Context, consumerId uint64, clientId string) error { if k.channelKeeperV2 == nil { k.Logger(ctx).Debug("IBC v2 channel keeper not configured, skipping send", "consumerId", consumerId, @@ -276,13 +276,13 @@ func (k Keeper) QueueVSCPackets(ctx sdk.Context) error { currentValSet, err := k.GetConsumerValSet(ctx, consumerId) if err != nil { - return fmt.Errorf("getting consumer current validator set, consumerId(%s): %w", consumerId, err) + return fmt.Errorf("getting consumer current validator set, consumerId(%d): %w", consumerId, err) } // compute consumer next validator set (all validators validate all consumers) valUpdates, err := k.ComputeConsumerNextValSet(ctx, bondedValidators, consumerId, currentValSet) if err != nil { - return fmt.Errorf("computing consumer next validator set, consumerId(%s): %w", consumerId, err) + return fmt.Errorf("computing consumer next validator set, consumerId(%d): %w", consumerId, err) } // Always enqueue a VSC packet per launched consumer each epoch, even diff --git a/x/vaas/provider/keeper/relay_test.go b/x/vaas/provider/keeper/relay_test.go index a9631cf..c1eeac5 100644 --- a/x/vaas/provider/keeper/relay_test.go +++ b/x/vaas/provider/keeper/relay_test.go @@ -19,7 +19,7 @@ func TestOnAcknowledgementPacketV2(t *testing.T) { providerKeeper, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - consumerId := "0" + consumerId := uint64(0) clientId := "07-tendermint-0" // Setup consumer with client mapping @@ -66,7 +66,7 @@ func TestOnTimeoutPacketV2(t *testing.T) { providerKeeper, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - consumerId := "0" + consumerId := uint64(0) clientId := "07-tendermint-0" // Setup consumer with client mapping @@ -108,7 +108,7 @@ func TestClientIdToConsumerIdMapping(t *testing.T) { providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - consumerId := "consumer-1" + consumerId := uint64(1) clientId := "07-tendermint-0" // Initially no mapping @@ -143,7 +143,7 @@ func TestSendVSCPacketsToChainNoHandler(t *testing.T) { providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - consumerId := "0" + consumerId := uint64(0) clientId := "07-tendermint-0" // Setup consumer with pending packets diff --git a/x/vaas/provider/keeper/validator_set_update.go b/x/vaas/provider/keeper/validator_set_update.go index 856410f..37dc218 100644 --- a/x/vaas/provider/keeper/validator_set_update.go +++ b/x/vaas/provider/keeper/validator_set_update.go @@ -55,7 +55,7 @@ func DiffValidators( } // CreateConsumerValidator creates a consumer validator for `consumerId` from the given staking `validator` -func (k Keeper) CreateConsumerValidator(ctx sdk.Context, consumerId string, validator stakingtypes.Validator) (types.ConsensusValidator, error) { +func (k Keeper) CreateConsumerValidator(ctx sdk.Context, consumerId uint64, validator stakingtypes.Validator) (types.ConsensusValidator, error) { valAddr, err := sdk.ValAddressFromBech32(validator.GetOperator()) if err != nil { return types.ConsensusValidator{}, err @@ -98,7 +98,7 @@ func (k Keeper) CreateConsumerValidator(ctx sdk.Context, consumerId string, vali // the filtered set. func (k Keeper) FilterValidators( ctx sdk.Context, - consumerId string, + consumerId uint64, bondedValidators []stakingtypes.Validator, predicate func(providerAddr types.ProviderConsAddress) (bool, error), ) ([]types.ConsensusValidator, error) { @@ -129,7 +129,7 @@ func (k Keeper) FilterValidators( // PSS (Partial Set Security) has been removed - all validators validate all consumers. func (k Keeper) ComputeNextValidators( ctx sdk.Context, - consumerId string, + consumerId uint64, bondedValidators []stakingtypes.Validator, ) ([]types.ConsensusValidator, error) { // sort the bonded validators by number of staked tokens in descending order @@ -180,20 +180,20 @@ func (k Keeper) GetLastProviderConsensusActiveValidators(ctx sdk.Context) ([]sta func (k Keeper) ComputeConsumerNextValSet( ctx sdk.Context, bondedValidators []stakingtypes.Validator, - consumerId string, + consumerId uint64, currentConsumerValSet []types.ConsensusValidator, ) ([]abci.ValidatorUpdate, error) { // All validators validate all consumers (no opt-in/out, no power shaping) nextValidators, err := k.ComputeNextValidators(ctx, consumerId, bondedValidators) if err != nil { return []abci.ValidatorUpdate{}, - fmt.Errorf("computing next validators, consumerId(%s): %w", consumerId, err) + fmt.Errorf("computing next validators, consumerId(%d): %w", consumerId, err) } err = k.SetConsumerValSet(ctx, consumerId, nextValidators) if err != nil { return []abci.ValidatorUpdate{}, - fmt.Errorf("setting consumer validator set, consumerId(%s): %w", consumerId, err) + fmt.Errorf("setting consumer validator set, consumerId(%d): %w", consumerId, err) } // get the initial updates with the latest set consumer public keys diff --git a/x/vaas/provider/types/genesis.go b/x/vaas/provider/types/genesis.go index 4686f7d..aadad2b 100644 --- a/x/vaas/provider/types/genesis.go +++ b/x/vaas/provider/types/genesis.go @@ -7,6 +7,8 @@ import ( vaastypes "github.com/allinbits/vaas/x/vaas/types" errorsmod "cosmossdk.io/errors" + + sdk "github.com/cosmos/cosmos-sdk/types" ) func NewGenesisState( @@ -49,9 +51,16 @@ func (gs GenesisState) Validate() error { } } + seenConsumerIds := map[uint64]bool{} for _, cs := range gs.ConsumerStates { + if seenConsumerIds[cs.ConsumerId] { + return errorsmod.Wrap(vaastypes.ErrInvalidGenesis, + fmt.Sprintf("duplicate consumer id %d in genesis", cs.ConsumerId)) + } + seenConsumerIds[cs.ConsumerId] = true if err := cs.Validate(); err != nil { - return errorsmod.Wrap(vaastypes.ErrInvalidGenesis, fmt.Sprintf("%s: for consumer chain id: %s", err, cs.ChainId)) + return errorsmod.Wrap(vaastypes.ErrInvalidGenesis, + fmt.Sprintf("%s: for consumer id %d (chain id %q)", err, cs.ConsumerId, cs.ChainId)) } } @@ -69,25 +78,100 @@ func (gs GenesisState) Validate() error { return nil } -// Validate performs a consumer state validation returning an error upon any failure. -// It ensures that the chain id, client id and consumer genesis states are valid and non-empty. +// Validate performs a phase-aware consumer state validation. +// Each phase has different required and forbidden fields, mirroring the +// invariants the keeper maintains (see x/vaas/provider/keeper/consumer_lifecycle.go). func (cs ConsumerState) Validate() error { if cs.ChainId == "" { return errors.New("chain id cannot be empty") } - if cs.ClientId == "" { - return errors.New("client id cannot be empty") + if cs.OwnerAddress == "" { + return errors.New("owner address cannot be empty") } - // validate a new chain genesis - if err := cs.ConsumerGenesis.Validate(); err != nil { - return err + if _, err := sdk.AccAddressFromBech32(cs.OwnerAddress); err != nil { + return fmt.Errorf("invalid owner address %q: %w", cs.OwnerAddress, err) } - for _, pVSC := range cs.PendingValsetChanges { if pVSC.ValsetUpdateId == 0 { return errors.New("valset update ID cannot be equal to zero") } } + switch cs.Phase { + case CONSUMER_PHASE_REGISTERED: + // Pre-launch: no IBC client, no consumer genesis, no init params, no removal time. + if cs.ClientId != "" { + return fmt.Errorf("client id must be empty for phase %s", cs.Phase) + } + if cs.InitParams != nil { + return fmt.Errorf("init params must be empty for phase %s", cs.Phase) + } + if cs.RemovalTime != nil { + return fmt.Errorf("removal time must be empty for phase %s", cs.Phase) + } + + case CONSUMER_PHASE_INITIALIZED: + // Pre-launch but configured: init_params required; still no IBC client. + if cs.InitParams == nil { + return fmt.Errorf("init params required for phase %s", cs.Phase) + } + if cs.ClientId != "" { + return fmt.Errorf("client id must be empty for phase %s", cs.Phase) + } + if cs.RemovalTime != nil { + return fmt.Errorf("removal time must be empty for phase %s", cs.Phase) + } + + case CONSUMER_PHASE_LAUNCHED: + // Live: init_params + IBC client + consumer genesis all required. + if cs.InitParams == nil { + return fmt.Errorf("init params required for phase %s", cs.Phase) + } + if cs.ClientId == "" { + return fmt.Errorf("client id required for phase %s", cs.Phase) + } + if err := cs.ConsumerGenesis.Validate(); err != nil { + return err + } + if cs.RemovalTime != nil { + return fmt.Errorf("removal time must be empty for phase %s", cs.Phase) + } + + case CONSUMER_PHASE_STOPPED: + // Scheduled for removal: LAUNCHED requirements plus a removal time. + if cs.InitParams == nil { + return fmt.Errorf("init params required for phase %s", cs.Phase) + } + if cs.ClientId == "" { + return fmt.Errorf("client id required for phase %s", cs.Phase) + } + if err := cs.ConsumerGenesis.Validate(); err != nil { + return err + } + if cs.RemovalTime == nil { + return fmt.Errorf("removal time required for phase %s", cs.Phase) + } + + case CONSUMER_PHASE_DELETED: + // Tombstoned: keeper retains owner+metadata+init_params for explorer UX + // (see consumer_lifecycle.go DeleteConsumerChain comment). + // Everything else is cleared. + if cs.InitParams == nil { + return fmt.Errorf("init params required for phase %s", cs.Phase) + } + if cs.Metadata == nil { + return fmt.Errorf("metadata required for phase %s", cs.Phase) + } + if cs.ClientId != "" { + return fmt.Errorf("client id must be empty for phase %s", cs.Phase) + } + if cs.RemovalTime != nil { + return fmt.Errorf("removal time must be empty for phase %s", cs.Phase) + } + + default: + return fmt.Errorf("invalid phase: %s", cs.Phase) + } + return nil } diff --git a/x/vaas/provider/types/genesis.pb.go b/x/vaas/provider/types/genesis.pb.go index f0e4d4a..c9341c3 100644 --- a/x/vaas/provider/types/genesis.pb.go +++ b/x/vaas/provider/types/genesis.pb.go @@ -8,15 +8,19 @@ import ( types "github.com/allinbits/vaas/x/vaas/types" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" + github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types" + _ "google.golang.org/protobuf/types/known/timestamppb" io "io" math "math" math_bits "math/bits" + time "time" ) // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal var _ = fmt.Errorf var _ = math.Inf +var _ = time.Kitchen // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. @@ -127,20 +131,41 @@ func (m *GenesisState) GetConsumerAddrsToPrune() []ConsumerAddrsToPrune { // // Note this type is only used internally to the provider VAAS module. type ConsumerState struct { - // ChainID defines the chain ID for the consumer chain - ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + // ConsumerID is the internal numeric consumer id. + ConsumerId uint64 `protobuf:"varint,1,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` + // ChainID is the external chain identifier of the consumer chain (e.g. + // "atomone-1"), as supplied by the consumer owner at registration. + ChainId string `protobuf:"bytes,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` // ClientID defines the IBC client ID for the consumer chain. - ClientId string `protobuf:"bytes,2,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` - // InitalHeight defines the initial block height for the consumer chain - InitialHeight uint64 `protobuf:"varint,3,opt,name=initial_height,json=initialHeight,proto3" json:"initial_height,omitempty"` + ClientId string `protobuf:"bytes,3,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` + // InitialHeight defines the initial block height for the consumer chain + InitialHeight uint64 `protobuf:"varint,4,opt,name=initial_height,json=initialHeight,proto3" json:"initial_height,omitempty"` // ConsumerGenesis defines the initial consumer chain genesis states - ConsumerGenesis types.ConsumerGenesisState `protobuf:"bytes,4,opt,name=consumer_genesis,json=consumerGenesis,proto3" json:"consumer_genesis"` + ConsumerGenesis types.ConsumerGenesisState `protobuf:"bytes,5,opt,name=consumer_genesis,json=consumerGenesis,proto3" json:"consumer_genesis"` // PendingValsetChanges defines the pending validator set changes for the // consumer chain - PendingValsetChanges []types.ValidatorSetChangePacketData `protobuf:"bytes,5,rep,name=pending_valset_changes,json=pendingValsetChanges,proto3" json:"pending_valset_changes"` - SlashDowntimeAck []string `protobuf:"bytes,6,rep,name=slash_downtime_ack,json=slashDowntimeAck,proto3" json:"slash_downtime_ack,omitempty"` + PendingValsetChanges []types.ValidatorSetChangePacketData `protobuf:"bytes,6,rep,name=pending_valset_changes,json=pendingValsetChanges,proto3" json:"pending_valset_changes"` + SlashDowntimeAck []string `protobuf:"bytes,7,rep,name=slash_downtime_ack,json=slashDowntimeAck,proto3" json:"slash_downtime_ack,omitempty"` // the phase of the consumer chain - Phase ConsumerPhase `protobuf:"varint,7,opt,name=phase,proto3,enum=vaas.provider.v1.ConsumerPhase" json:"phase,omitempty"` + Phase ConsumerPhase `protobuf:"varint,8,opt,name=phase,proto3,enum=vaas.provider.v1.ConsumerPhase" json:"phase,omitempty"` + // OwnerAddress is the bech32 address that authorises owner-only operations + // (UpdateConsumer, RemoveConsumer, key assignment, etc.) on the consumer. + // Always non-empty for any existing consumer record; set at REGISTERED. + OwnerAddress string `protobuf:"bytes,9,opt,name=owner_address,json=ownerAddress,proto3" json:"owner_address,omitempty"` + // Metadata is the owner-supplied descriptor (name/description/repo). + // Preserved through DELETED so block explorers can show information + // about removed chains without an archive node. + Metadata *ConsumerMetadata `protobuf:"bytes,10,opt,name=metadata,proto3" json:"metadata,omitempty"` + // InitParams are the owner-supplied launch parameters: spawn time, + // initial height, genesis hash, binary hash, etc. Preserved through + // DELETED for the same explorer reason. Carries the spawn_time used + // to re-derive the keeper's spawn-time queue, and the initial_height + // used to re-derive equivocation_evidence_min_height, at InitGenesis. + InitParams *ConsumerInitializationParameters `protobuf:"bytes,11,opt,name=init_params,json=initParams,proto3" json:"init_params,omitempty"` + // RemovalTime is the wall-clock time at which a STOPPED consumer is + // scheduled to transition to DELETED. Set only when phase == STOPPED; + // absent otherwise. Used to re-derive the keeper's removal-time queue. + RemovalTime *time.Time `protobuf:"bytes,12,opt,name=removal_time,json=removalTime,proto3,stdtime" json:"removal_time,omitempty"` } func (m *ConsumerState) Reset() { *m = ConsumerState{} } @@ -176,6 +201,13 @@ func (m *ConsumerState) XXX_DiscardUnknown() { var xxx_messageInfo_ConsumerState proto.InternalMessageInfo +func (m *ConsumerState) GetConsumerId() uint64 { + if m != nil { + return m.ConsumerId + } + return 0 +} + func (m *ConsumerState) GetChainId() string { if m != nil { return m.ChainId @@ -225,6 +257,34 @@ func (m *ConsumerState) GetPhase() ConsumerPhase { return CONSUMER_PHASE_UNSPECIFIED } +func (m *ConsumerState) GetOwnerAddress() string { + if m != nil { + return m.OwnerAddress + } + return "" +} + +func (m *ConsumerState) GetMetadata() *ConsumerMetadata { + if m != nil { + return m.Metadata + } + return nil +} + +func (m *ConsumerState) GetInitParams() *ConsumerInitializationParameters { + if m != nil { + return m.InitParams + } + return nil +} + +func (m *ConsumerState) GetRemovalTime() *time.Time { + if m != nil { + return m.RemovalTime + } + return nil +} + // ValsetUpdateIdToHeight defines the genesis information for the mapping // of each valset update id to a block height type ValsetUpdateIdToHeight struct { @@ -288,48 +348,57 @@ func init() { func init() { proto.RegisterFile("vaas/provider/v1/genesis.proto", fileDescriptor_c9071b84cde652f9) } var fileDescriptor_c9071b84cde652f9 = []byte{ - // 648 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0x4f, 0x6f, 0xd3, 0x30, - 0x14, 0x6f, 0xf6, 0xa7, 0xdb, 0x3c, 0x56, 0x2a, 0x6b, 0x2a, 0x61, 0xd3, 0xd2, 0xa9, 0xd2, 0x50, - 0x91, 0x50, 0xa3, 0x0d, 0xc1, 0x81, 0xdb, 0xba, 0x49, 0x50, 0x21, 0xa1, 0xaa, 0x1b, 0x1c, 0x76, - 0x89, 0xdc, 0xd8, 0x4a, 0x4c, 0x53, 0x3b, 0x8a, 0xdd, 0x8c, 0x7c, 0x01, 0x0e, 0x9c, 0xf8, 0x58, - 0x3b, 0xee, 0xc8, 0x69, 0x42, 0xdb, 0x37, 0xe0, 0x13, 0x20, 0x3b, 0x4e, 0xb6, 0xfe, 0x01, 0xc4, - 0x2d, 0x79, 0xbf, 0x9f, 0x7f, 0xbf, 0xf7, 0xfc, 0x9e, 0x1f, 0x70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 0xb9, 0x0f, 0x1a, 0xe9, 0x42, 0x14, 0xbe, 0x06, 0xd5, 0x18, 0x25, 0x68, 0x2c, 0xec, - 0x95, 0x7d, 0xab, 0xbd, 0x79, 0x64, 0xcf, 0xeb, 0xf6, 0x35, 0x6e, 0x74, 0x0c, 0x1b, 0x8e, 0x75, - 0x8e, 0x14, 0x23, 0xc9, 0x93, 0xb2, 0x33, 0x5e, 0x3c, 0x19, 0x8e, 0x48, 0x26, 0xec, 0x55, 0x9d, - 0xe3, 0xf3, 0x85, 0x39, 0xe6, 0x67, 0x8a, 0x1b, 0xea, 0x4f, 0x86, 0xef, 0x49, 0x66, 0xc4, 0xed, - 0x74, 0x01, 0xac, 0x04, 0x21, 0x03, 0xbb, 0x25, 0x26, 0xbc, 0x61, 0x76, 0x6f, 0x89, 0x30, 0x4e, - 0xec, 0xea, 0x3f, 0xfd, 0xba, 0x59, 0x21, 0x79, 0x8c, 0x71, 0x32, 0xe7, 0x27, 0xa6, 0x71, 0xe8, - 0x83, 0x27, 0x53, 0x0e, 0x42, 0x35, 0x20, 0x4e, 0x26, 0x8c, 0xd8, 0x6b, 0xda, 0xeb, 0xd9, 0x9f, - 0x9b, 0xae, 0x04, 0xc4, 0x39, 0xef, 0x2b, 0xb6, 0x31, 0xda, 0xf6, 0x17, 0x60, 0xad, 0xaf, 0xcb, - 0x60, 0x6b, 0x6a, 0x52, 0xe0, 0x53, 0xb0, 0xee, 0x87, 0x88, 0xb2, 0x62, 0x0a, 0x37, 0x06, 0x6b, - 0xfa, 0xbf, 0x87, 0xe1, 0x2e, 0xd8, 0xf0, 0x23, 0x4a, 0x98, 0x54, 0xd8, 0x92, 0xc6, 0xd6, 0xf3, - 0x40, 0x0f, 0xc3, 0x03, 0x50, 0xa3, 0x8c, 0x4a, 0x8a, 0xa2, 0xfb, 0x29, 0x51, 0x33, 0xbc, 0x65, - 0xa2, 0xa6, 0xd9, 0x1f, 0x40, 0xbd, 0xac, 0xca, 0xbc, 0x49, 0xd3, 0xf6, 0xbd, 0xbc, 0x9c, 0x07, - 0x55, 0x3c, 0x7c, 0x25, 0xa6, 0x8a, 0x72, 0xfe, 0x0d, 0x06, 0x11, 0x68, 0xc4, 0x84, 0x61, 0xca, - 0x02, 0xcf, 0x0c, 0xac, 0x1f, 0x22, 0x16, 0x90, 0x62, 0x00, 0x0e, 0x4a, 0xd5, 0xb2, 0x0f, 0x67, - 0x44, 0x9e, 0x68, 0x4e, 0x1f, 0xf9, 0x23, 0x22, 0x4f, 0x91, 0x44, 0xc5, 0x1d, 0x19, 0xa9, 0x7c, - 0x8c, 0x73, 0x92, 0x80, 0x2f, 0x00, 0x14, 0x11, 0x12, 0xa1, 0x87, 0xf9, 0x25, 0x93, 0x74, 0x4c, - 0x3c, 0xe4, 0x8f, 0x74, 0xbf, 0x37, 0x06, 0x75, 0x8d, 0x9c, 0x1a, 0xe0, 0xd8, 0x1f, 0xc1, 0x57, - 0x60, 0x35, 0x0e, 0x91, 0x50, 0x4d, 0xb2, 0xda, 0xb5, 0xbf, 0xbd, 0xcc, 0xbe, 0xa2, 0x0d, 0x72, - 0x76, 0xeb, 0x02, 0x34, 0x16, 0x3f, 0x9e, 0xff, 0x58, 0x0f, 0x0d, 0x50, 0x35, 0x57, 0xbf, 0xa4, - 0x71, 0xf3, 0xd7, 0xed, 0x5d, 0xdd, 0x3a, 0xd6, 0xf5, 0xad, 0x63, 0xfd, 0xbc, 0x75, 0xac, 0xef, - 0x77, 0x4e, 0xe5, 0xfa, 0xce, 0xa9, 0xfc, 0xb8, 0x73, 0x2a, 0x17, 0x6e, 0x40, 0x65, 0x38, 0x19, - 0x76, 0x7c, 0x3e, 0x76, 0x51, 0x14, 0x51, 0x36, 0xa4, 0x52, 0xb8, 0x7a, 0x83, 0x7d, 0x71, 0xa7, - 0x17, 0x99, 0xcc, 0x62, 0x22, 0x86, 0x55, 0xbd, 0xc3, 0x5e, 0xfe, 0x0e, 0x00, 0x00, 0xff, 0xff, - 0xd7, 0x85, 0xc9, 0x36, 0x61, 0x05, 0x00, 0x00, + // 795 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xcd, 0x6e, 0xeb, 0x44, + 0x18, 0x8d, 0xdb, 0x24, 0x37, 0x99, 0xa4, 0x21, 0x1a, 0x5d, 0x05, 0x93, 0xab, 0xeb, 0x44, 0x41, + 0x17, 0x05, 0x09, 0xd9, 0x6a, 0x11, 0x2c, 0x58, 0x20, 0x35, 0xad, 0x04, 0x11, 0x02, 0x45, 0x6e, + 0x61, 0xd1, 0x8d, 0x35, 0xf1, 0x0c, 0xf6, 0x10, 0xdb, 0x63, 0x79, 0x26, 0x2e, 0xe1, 0x11, 0x58, + 0xf5, 0x29, 0x78, 0x96, 0x2e, 0xbb, 0x64, 0x55, 0x50, 0xfb, 0x06, 0x3c, 0x01, 0x9a, 0xf1, 0xd8, + 0x34, 0x4d, 0x0a, 0x62, 0x67, 0x7f, 0xe7, 0xcc, 0x39, 0xdf, 0xcc, 0xf7, 0x03, 0xac, 0x1c, 0x21, + 0xee, 0xa4, 0x19, 0xcb, 0x29, 0x26, 0x99, 0x93, 0x1f, 0x3b, 0x01, 0x49, 0x08, 0xa7, 0xdc, 0x4e, + 0x33, 0x26, 0x18, 0xec, 0x4b, 0xdc, 0x2e, 0x71, 0x3b, 0x3f, 0x1e, 0xbe, 0x0e, 0x58, 0xc0, 0x14, + 0xe8, 0xc8, 0xaf, 0x82, 0x37, 0x1c, 0x05, 0x8c, 0x05, 0x11, 0x71, 0xd4, 0xdf, 0x72, 0xfd, 0xa3, + 0x23, 0x68, 0x4c, 0xb8, 0x40, 0x71, 0xaa, 0x09, 0x6f, 0x95, 0x51, 0x7e, 0xec, 0xf0, 0x10, 0x65, + 0x04, 0x7b, 0x3e, 0x4b, 0xf8, 0x3a, 0x26, 0x99, 0x86, 0x61, 0x09, 0x5f, 0xd3, 0x8c, 0x94, 0x9a, + 0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, 0x9b, 0xcd, 0x6f, 0x1f, 0x2c, 0xe3, 0xee, 0xc1, 0x32, 0xfe, 0x7c, + 0xb0, 0x8c, 0x9b, 0x47, 0xab, 0x76, 0xf7, 0x68, 0xd5, 0x7e, 0x7f, 0xb4, 0x6a, 0x57, 0x4e, 0x40, + 0x45, 0xb8, 0x5e, 0xda, 0x3e, 0x8b, 0x1d, 0x14, 0x45, 0x34, 0x59, 0x52, 0xc1, 0x1d, 0xb5, 0xe1, + 0x7f, 0x76, 0xb6, 0x17, 0xbd, 0xd8, 0xa4, 0x84, 0x2f, 0x9b, 0xea, 0x36, 0x9f, 0xfe, 0x1d, 0x00, + 0x00, 0xff, 0xff, 0x5e, 0xf7, 0x5c, 0x97, 0xa2, 0x06, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -460,10 +529,51 @@ func (m *ConsumerState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.RemovalTime != nil { + n2, err2 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(*m.RemovalTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(*m.RemovalTime):]) + if err2 != nil { + return 0, err2 + } + i -= n2 + i = encodeVarintGenesis(dAtA, i, uint64(n2)) + i-- + dAtA[i] = 0x62 + } + if m.InitParams != nil { + { + size, err := m.InitParams.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x5a + } + if m.Metadata != nil { + { + size, err := m.Metadata.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x52 + } + if len(m.OwnerAddress) > 0 { + i -= len(m.OwnerAddress) + copy(dAtA[i:], m.OwnerAddress) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.OwnerAddress))) + i-- + dAtA[i] = 0x4a + } if m.Phase != 0 { i = encodeVarintGenesis(dAtA, i, uint64(m.Phase)) i-- - dAtA[i] = 0x38 + dAtA[i] = 0x40 } if len(m.SlashDowntimeAck) > 0 { for iNdEx := len(m.SlashDowntimeAck) - 1; iNdEx >= 0; iNdEx-- { @@ -471,7 +581,7 @@ func (m *ConsumerState) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.SlashDowntimeAck[iNdEx]) i = encodeVarintGenesis(dAtA, i, uint64(len(m.SlashDowntimeAck[iNdEx]))) i-- - dAtA[i] = 0x32 + dAtA[i] = 0x3a } } if len(m.PendingValsetChanges) > 0 { @@ -485,7 +595,7 @@ func (m *ConsumerState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenesis(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x2a + dAtA[i] = 0x32 } } { @@ -497,25 +607,30 @@ func (m *ConsumerState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenesis(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x22 + dAtA[i] = 0x2a if m.InitialHeight != 0 { i = encodeVarintGenesis(dAtA, i, uint64(m.InitialHeight)) i-- - dAtA[i] = 0x18 + dAtA[i] = 0x20 } if len(m.ClientId) > 0 { i -= len(m.ClientId) copy(dAtA[i:], m.ClientId) i = encodeVarintGenesis(dAtA, i, uint64(len(m.ClientId))) i-- - dAtA[i] = 0x12 + dAtA[i] = 0x1a } if len(m.ChainId) > 0 { i -= len(m.ChainId) copy(dAtA[i:], m.ChainId) i = encodeVarintGenesis(dAtA, i, uint64(len(m.ChainId))) i-- - dAtA[i] = 0xa + dAtA[i] = 0x12 + } + if m.ConsumerId != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.ConsumerId)) + i-- + dAtA[i] = 0x8 } return len(dAtA) - i, nil } @@ -614,6 +729,9 @@ func (m *ConsumerState) Size() (n int) { } var l int _ = l + if m.ConsumerId != 0 { + n += 1 + sovGenesis(uint64(m.ConsumerId)) + } l = len(m.ChainId) if l > 0 { n += 1 + l + sovGenesis(uint64(l)) @@ -642,6 +760,22 @@ func (m *ConsumerState) Size() (n int) { if m.Phase != 0 { n += 1 + sovGenesis(uint64(m.Phase)) } + l = len(m.OwnerAddress) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + if m.Metadata != nil { + l = m.Metadata.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + if m.InitParams != nil { + l = m.InitParams.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + if m.RemovalTime != nil { + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(*m.RemovalTime) + n += 1 + l + sovGenesis(uint64(l)) + } return n } @@ -968,6 +1102,25 @@ func (m *ConsumerState) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ConsumerId", wireType) + } + m.ConsumerId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ConsumerId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType) } @@ -999,7 +1152,7 @@ func (m *ConsumerState) Unmarshal(dAtA []byte) error { } m.ChainId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 2: + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ClientId", wireType) } @@ -1031,7 +1184,7 @@ func (m *ConsumerState) Unmarshal(dAtA []byte) error { } m.ClientId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 3: + case 4: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field InitialHeight", wireType) } @@ -1050,7 +1203,7 @@ func (m *ConsumerState) Unmarshal(dAtA []byte) error { break } } - case 4: + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ConsumerGenesis", wireType) } @@ -1083,7 +1236,7 @@ func (m *ConsumerState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 5: + case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field PendingValsetChanges", wireType) } @@ -1117,7 +1270,7 @@ func (m *ConsumerState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 6: + case 7: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field SlashDowntimeAck", wireType) } @@ -1149,7 +1302,7 @@ func (m *ConsumerState) Unmarshal(dAtA []byte) error { } m.SlashDowntimeAck = append(m.SlashDowntimeAck, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex - case 7: + case 8: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Phase", wireType) } @@ -1168,6 +1321,146 @@ func (m *ConsumerState) Unmarshal(dAtA []byte) error { break } } + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OwnerAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.OwnerAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Metadata == nil { + m.Metadata = &ConsumerMetadata{} + } + if err := m.Metadata.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 11: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field InitParams", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.InitParams == nil { + m.InitParams = &ConsumerInitializationParameters{} + } + if err := m.InitParams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 12: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RemovalTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.RemovalTime == nil { + m.RemovalTime = new(time.Time) + } + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(m.RemovalTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/vaas/provider/types/genesis_test.go b/x/vaas/provider/types/genesis_test.go index d53d4ef..58e7550 100644 --- a/x/vaas/provider/types/genesis_test.go +++ b/x/vaas/provider/types/genesis_test.go @@ -16,6 +16,28 @@ import ( ) func TestValidateGenesisState(t *testing.T) { + // minimal init params required for LAUNCHED/STOPPED/DELETED consumer states + testInitParams := &types.ConsumerInitializationParameters{ + InitialHeight: clienttypes.Height{RevisionNumber: 1, RevisionHeight: 1}, + GenesisHash: []byte("g"), + BinaryHash: []byte("b"), + SpawnTime: time.Unix(100, 0).UTC(), + UnbondingPeriod: time.Hour, + VaasTimeoutPeriod: time.Hour, + HistoricalEntries: 10, + } + launchedCS := func(consumerID uint64, chainID, clientID string, preVAAS bool) types.ConsumerState { + return types.ConsumerState{ + ConsumerId: consumerID, + ChainId: chainID, + ClientId: clientID, + Phase: types.CONSUMER_PHASE_LAUNCHED, + OwnerAddress: sdk.AccAddress([]byte("vaas-test-owner-1234")).String(), + InitParams: testInitParams, + ConsumerGenesis: getInitialConsumerGenesis(t, chainID, preVAAS), + } + } + testCases := []struct { name string genState *types.GenesisState @@ -26,7 +48,7 @@ func TestValidateGenesisState(t *testing.T) { types.NewGenesisState( types.DefaultValsetUpdateID, nil, - []types.ConsumerState{{ChainId: "chainid-1", ClientId: "client-id", ConsumerGenesis: getInitialConsumerGenesis(t, "chainid-1", false)}}, + []types.ConsumerState{launchedCS(0, "chainid-1", "client-id", false)}, types.DefaultParams(), nil, nil, @@ -40,10 +62,10 @@ func TestValidateGenesisState(t *testing.T) { types.DefaultValsetUpdateID, nil, []types.ConsumerState{ - {ChainId: "chainid-1", ClientId: "client-id", ConsumerGenesis: getInitialConsumerGenesis(t, "chainid-1", false)}, - {ChainId: "chainid-2", ClientId: "client-id", ConsumerGenesis: getInitialConsumerGenesis(t, "chainid-2", true)}, - {ChainId: "chainid-3", ClientId: "client-id", ConsumerGenesis: getInitialConsumerGenesis(t, "chainid-3", false)}, - {ChainId: "chainid-4", ClientId: "client-id", ConsumerGenesis: getInitialConsumerGenesis(t, "chainid-4", true)}, + launchedCS(0, "chainid-1", "client-id", false), + launchedCS(1, "chainid-2", "client-id", true), + launchedCS(2, "chainid-3", "client-id", false), + launchedCS(3, "chainid-4", "client-id", true), }, types.DefaultParams(), nil, @@ -57,7 +79,7 @@ func TestValidateGenesisState(t *testing.T) { types.NewGenesisState( types.DefaultValsetUpdateID, nil, - []types.ConsumerState{{ChainId: "chainid-1", ClientId: "client-id", ConsumerGenesis: getInitialConsumerGenesis(t, "chainid-1", false)}}, + []types.ConsumerState{launchedCS(0, "chainid-1", "client-id", false)}, types.NewParams( types.DefaultTrustingPeriodFraction, time.Hour, 600, 180, sdk.NewInt64Coin("uphoton", 42)), nil, @@ -97,7 +119,7 @@ func TestValidateGenesisState(t *testing.T) { types.NewGenesisState( types.DefaultValsetUpdateID, nil, - []types.ConsumerState{{ChainId: "chainid-1", ClientId: "client-id"}}, + []types.ConsumerState{launchedCS(0, "chainid-1", "client-id", false)}, types.NewParams( "0.0", // 0 trusting period fraction here vaastypes.DefaultVAASTimeoutPeriod, 600, 180, sdk.NewInt64Coin("uphoton", 42)), @@ -112,7 +134,7 @@ func TestValidateGenesisState(t *testing.T) { types.NewGenesisState( types.DefaultValsetUpdateID, nil, - []types.ConsumerState{{ChainId: "chainid-1", ClientId: "client-id"}}, + []types.ConsumerState{launchedCS(0, "chainid-1", "client-id", false)}, types.NewParams( types.DefaultTrustingPeriodFraction, 0, // 0 ccv timeout here @@ -136,25 +158,12 @@ func TestValidateGenesisState(t *testing.T) { ), false, }, - { - "empty consumer state client id", - types.NewGenesisState( - types.DefaultValsetUpdateID, - nil, - []types.ConsumerState{{ChainId: "chainid", ClientId: ""}}, - types.DefaultParams(), - nil, - nil, - nil, - ), - false, - }, { "valid consumer state with client id", types.NewGenesisState( types.DefaultValsetUpdateID, nil, - []types.ConsumerState{{ChainId: "chainid", ClientId: "abc", ConsumerGenesis: getInitialConsumerGenesis(t, "chainid", false)}}, + []types.ConsumerState{launchedCS(0, "chainid", "abc", false)}, types.DefaultParams(), nil, nil, @@ -167,12 +176,11 @@ func TestValidateGenesisState(t *testing.T) { types.NewGenesisState( types.DefaultValsetUpdateID, nil, - []types.ConsumerState{{ - ChainId: "chainid", - ClientId: "client-id", - ConsumerGenesis: getInitialConsumerGenesis(t, "chainid", false), - PendingValsetChanges: []vaastypes.ValidatorSetChangePacketData{{}}, - }}, + []types.ConsumerState{func() types.ConsumerState { + cs := launchedCS(0, "chainid", "client-id", false) + cs.PendingValsetChanges = []vaastypes.ValidatorSetChangePacketData{{}} // ValsetUpdateId=0 + return cs + }()}, types.DefaultParams(), nil, nil, @@ -195,6 +203,121 @@ func TestValidateGenesisState(t *testing.T) { } } +func TestConsumerStateValidatePerPhase(t *testing.T) { + validMetadata := types.ConsumerMetadata{Name: "n", Description: "d", Metadata: "m"} + validInit := &types.ConsumerInitializationParameters{ + InitialHeight: clienttypes.Height{RevisionNumber: 1, RevisionHeight: 1}, + GenesisHash: []byte("g"), + BinaryHash: []byte("b"), + SpawnTime: time.Unix(100, 0).UTC(), + UnbondingPeriod: time.Hour, + VaasTimeoutPeriod: time.Hour, + HistoricalEntries: 10, + } + rt := time.Unix(200, 0).UTC() + + base := func(phase types.ConsumerPhase) types.ConsumerState { + return types.ConsumerState{ + ConsumerId: 0, + ChainId: "test-consumer", + Phase: phase, + OwnerAddress: sdk.AccAddress([]byte("vaas-test-owner-1234")).String(), + ConsumerGenesis: *vaastypes.DefaultConsumerGenesisState(), + } + } + + cases := []struct { + name string + mutate func(*types.ConsumerState) + wantErr string // "" means valid + }{ + // REGISTERED: only chain_id + owner required. + {"REGISTERED valid", func(cs *types.ConsumerState) { *cs = base(types.CONSUMER_PHASE_REGISTERED) }, ""}, + {"REGISTERED empty owner", func(cs *types.ConsumerState) { + *cs = base(types.CONSUMER_PHASE_REGISTERED) + cs.OwnerAddress = "" + }, "owner address"}, + {"REGISTERED invalid owner bech32", func(cs *types.ConsumerState) { + *cs = base(types.CONSUMER_PHASE_REGISTERED) + cs.OwnerAddress = "cosmos1notavalidchecksum" + }, "invalid owner address"}, + {"REGISTERED with stray client_id", func(cs *types.ConsumerState) { + *cs = base(types.CONSUMER_PHASE_REGISTERED) + cs.ClientId = "07-tendermint-0" + }, "client id must be empty"}, + + // INITIALIZED: requires init_params; client_id absent. + {"INITIALIZED valid", func(cs *types.ConsumerState) { + *cs = base(types.CONSUMER_PHASE_INITIALIZED) + cs.InitParams = validInit + }, ""}, + {"INITIALIZED missing init_params", func(cs *types.ConsumerState) { + *cs = base(types.CONSUMER_PHASE_INITIALIZED) + }, "init params required"}, + + // LAUNCHED: requires init_params + client_id + non-default consumer_genesis. + {"LAUNCHED valid", func(cs *types.ConsumerState) { + *cs = base(types.CONSUMER_PHASE_LAUNCHED) + cs.InitParams = validInit + cs.ClientId = "07-tendermint-0" + cs.ConsumerGenesis = nonDefaultConsumerGenesis() + }, ""}, + {"LAUNCHED missing client_id", func(cs *types.ConsumerState) { + *cs = base(types.CONSUMER_PHASE_LAUNCHED) + cs.InitParams = validInit + cs.ConsumerGenesis = nonDefaultConsumerGenesis() + }, "client id"}, + + // STOPPED: LAUNCHED requirements + removal_time. + {"STOPPED valid", func(cs *types.ConsumerState) { + *cs = base(types.CONSUMER_PHASE_STOPPED) + cs.InitParams = validInit + cs.ClientId = "07-tendermint-0" + cs.ConsumerGenesis = nonDefaultConsumerGenesis() + cs.RemovalTime = &rt + }, ""}, + {"STOPPED missing removal_time", func(cs *types.ConsumerState) { + *cs = base(types.CONSUMER_PHASE_STOPPED) + cs.InitParams = validInit + cs.ClientId = "07-tendermint-0" + cs.ConsumerGenesis = nonDefaultConsumerGenesis() + }, "removal time"}, + + // DELETED: chain_id + owner + init_params + metadata preserved; everything else cleared. + {"DELETED valid", func(cs *types.ConsumerState) { + *cs = base(types.CONSUMER_PHASE_DELETED) + cs.InitParams = validInit + cs.Metadata = &validMetadata + cs.ConsumerGenesis = vaastypes.ConsumerGenesisState{} // cleared + }, ""}, + {"DELETED missing metadata", func(cs *types.ConsumerState) { + *cs = base(types.CONSUMER_PHASE_DELETED) + cs.InitParams = validInit + cs.ConsumerGenesis = vaastypes.ConsumerGenesisState{} + }, "metadata required"}, + } + + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + cs := types.ConsumerState{} + tc.mutate(&cs) + err := cs.Validate() + if tc.wantErr == "" { + require.NoError(t, err) + } else { + require.Error(t, err) + require.Contains(t, err.Error(), tc.wantErr) + } + }) + } +} + +func nonDefaultConsumerGenesis() vaastypes.ConsumerGenesisState { + gs := vaastypes.DefaultConsumerGenesisState() + gs.NewChain = true + return *gs +} + func getInitialConsumerGenesis(t *testing.T, chainID string, preVAAS bool) vaastypes.ConsumerGenesisState { t.Helper() cId := crypto.NewCryptoIdentityFromIntSeed(239668) diff --git a/x/vaas/provider/types/key_assignment.go b/x/vaas/provider/types/key_assignment.go index 5e02fa5..9ab59ad 100644 --- a/x/vaas/provider/types/key_assignment.go +++ b/x/vaas/provider/types/key_assignment.go @@ -2,7 +2,6 @@ package types import ( "fmt" - "strings" vaastypes "github.com/allinbits/vaas/x/vaas/types" @@ -70,9 +69,6 @@ func KeyAssignmentValidateBasic( consumerAddrsToPrune []ConsumerAddrsToPrune, ) error { for _, e := range assignedKeys { - if strings.TrimSpace(e.ChainId) == "" { - return errorsmod.Wrap(vaastypes.ErrInvalidGenesis, "consumer chain id must not be blank") - } if err := sdk.VerifyAddressFormat(e.ProviderAddr); err != nil { return errorsmod.Wrap(vaastypes.ErrInvalidGenesis, fmt.Sprintf("invalid provider address: %s", e.ProviderAddr)) } @@ -81,9 +77,6 @@ func KeyAssignmentValidateBasic( } } for _, e := range byConsumerAddrs { - if strings.TrimSpace(e.ChainId) == "" { - return errorsmod.Wrap(vaastypes.ErrInvalidGenesis, "consumer chain id must not be blank") - } if err := sdk.VerifyAddressFormat(e.ProviderAddr); err != nil { return errorsmod.Wrap(vaastypes.ErrInvalidGenesis, fmt.Sprintf("invalid provider address: %s", e.ProviderAddr)) } @@ -92,9 +85,6 @@ func KeyAssignmentValidateBasic( } } for _, e := range consumerAddrsToPrune { - if strings.TrimSpace(e.ChainId) == "" { - return errorsmod.Wrap(vaastypes.ErrInvalidGenesis, "consumer chain id must not be blank") - } for _, a := range e.ConsumerAddrs.Addresses { if err := sdk.VerifyAddressFormat(a); err != nil { return errorsmod.Wrap(vaastypes.ErrInvalidGenesis, fmt.Sprintf("invalid consumer address: %s", a)) diff --git a/x/vaas/provider/types/msg.go b/x/vaas/provider/types/msg.go index 08a6f55..736b4c4 100644 --- a/x/vaas/provider/types/msg.go +++ b/x/vaas/provider/types/msg.go @@ -50,7 +50,7 @@ var ( // NewMsgAssignConsumerKey creates a new MsgAssignConsumerKey instance. // Delegator address and validator address are the same. -func NewMsgAssignConsumerKey(consumerId string, providerValidatorAddress sdk.ValAddress, +func NewMsgAssignConsumerKey(consumerId uint64, providerValidatorAddress sdk.ValAddress, consumerConsensusPubKey, signer string, ) (*MsgAssignConsumerKey, error) { return &MsgAssignConsumerKey{ @@ -63,10 +63,6 @@ func NewMsgAssignConsumerKey(consumerId string, providerValidatorAddress sdk.Val // ValidateBasic implements the sdk.HasValidateBasic interface. func (msg MsgAssignConsumerKey) ValidateBasic() error { - if err := vaastypes.ValidateConsumerId(msg.ConsumerId); err != nil { - return errorsmod.Wrapf(ErrInvalidMsgAssignConsumerKey, "ConsumerId: %s", err.Error()) - } - if err := validateProviderAddress(msg.ProviderAddr, msg.Signer); err != nil { return errorsmod.Wrapf(ErrInvalidMsgAssignConsumerKey, "ProviderAddr: %s", err.Error()) } @@ -82,7 +78,7 @@ func (msg MsgAssignConsumerKey) ValidateBasic() error { } func NewMsgSubmitConsumerMisbehaviour( - consumerId string, + consumerId uint64, submitter sdk.AccAddress, misbehaviour *ibctmtypes.Misbehaviour, ) (*MsgSubmitConsumerMisbehaviour, error) { @@ -95,10 +91,6 @@ func NewMsgSubmitConsumerMisbehaviour( // ValidateBasic implements the sdk.HasValidateBasic interface. func (msg MsgSubmitConsumerMisbehaviour) ValidateBasic() error { - if err := vaastypes.ValidateConsumerId(msg.ConsumerId); err != nil { - return errorsmod.Wrapf(ErrInvalidMsgSubmitConsumerMisbehaviour, "ConsumerId: %s", err.Error()) - } - if err := msg.Misbehaviour.ValidateBasic(); err != nil { return errorsmod.Wrapf(ErrInvalidMsgSubmitConsumerMisbehaviour, "Misbehaviour: %s", err.Error()) } @@ -106,7 +98,7 @@ func (msg MsgSubmitConsumerMisbehaviour) ValidateBasic() error { } func NewMsgSubmitConsumerDoubleVoting( - consumerId string, + consumerId uint64, submitter sdk.AccAddress, ev *tmtypes.DuplicateVoteEvidence, header *ibctmtypes.Header, @@ -133,10 +125,6 @@ func (msg MsgSubmitConsumerDoubleVoting) ValidateBasic() error { return errorsmod.Wrapf(ErrInvalidMsgSubmitConsumerDoubleVoting, "ValidateTendermintHeader: %s", err.Error()) } - if err := vaastypes.ValidateConsumerId(msg.ConsumerId); err != nil { - return errorsmod.Wrapf(ErrInvalidMsgSubmitConsumerDoubleVoting, "ConsumerId: %s", err.Error()) - } - return nil } @@ -205,7 +193,7 @@ func (msg MsgCreateConsumer) ValidateBasic() error { } // NewMsgUpdateConsumer creates a new MsgUpdateConsumer instance -func NewMsgUpdateConsumer(owner, consumerId, ownerAddress string, metadata *ConsumerMetadata, +func NewMsgUpdateConsumer(owner string, consumerId uint64, ownerAddress string, metadata *ConsumerMetadata, initializationParameters *ConsumerInitializationParameters, newChainId string, infractionParameters *InfractionParameters, ) (*MsgUpdateConsumer, error) { @@ -222,10 +210,6 @@ func NewMsgUpdateConsumer(owner, consumerId, ownerAddress string, metadata *Cons // ValidateBasic implements the sdk.HasValidateBasic interface. func (msg MsgUpdateConsumer) ValidateBasic() error { - if err := vaastypes.ValidateConsumerId(msg.ConsumerId); err != nil { - return errorsmod.Wrapf(ErrInvalidMsgUpdateConsumer, "ConsumerId: %s", err.Error()) - } - // Note that NewOwnerAddress is validated when handling the message in UpdateConsumer if msg.Metadata != nil { @@ -250,7 +234,7 @@ func (msg MsgUpdateConsumer) ValidateBasic() error { } // NewMsgRemoveConsumer creates a new MsgRemoveConsumer instance -func NewMsgRemoveConsumer(owner, consumerId string) (*MsgRemoveConsumer, error) { +func NewMsgRemoveConsumer(owner string, consumerId uint64) (*MsgRemoveConsumer, error) { return &MsgRemoveConsumer{ Owner: owner, ConsumerId: consumerId, @@ -259,9 +243,6 @@ func NewMsgRemoveConsumer(owner, consumerId string) (*MsgRemoveConsumer, error) // ValidateBasic implements the sdk.HasValidateBasic interface. func (msg MsgRemoveConsumer) ValidateBasic() error { - if err := vaastypes.ValidateConsumerId(msg.ConsumerId); err != nil { - return err - } return nil } diff --git a/x/vaas/provider/types/msg_test.go b/x/vaas/provider/types/msg_test.go index e1f5762..a9ad1ab 100644 --- a/x/vaas/provider/types/msg_test.go +++ b/x/vaas/provider/types/msg_test.go @@ -395,7 +395,7 @@ func TestMsgUpdateConsumerValidateBasic(t *testing.T) { } for _, tc := range testCases { - msg, _ := types.NewMsgUpdateConsumer("", "0", "cosmos1p3ucd3ptpw902fluyjzhq3ffgq4ntddac9sa3s", nil, nil, tc.newChainId, nil) + msg, _ := types.NewMsgUpdateConsumer("", 0, "cosmos1p3ucd3ptpw902fluyjzhq3ffgq4ntddac9sa3s", nil, nil, tc.newChainId, nil) err := msg.ValidateBasic() if tc.expPass { require.NoError(t, err, "valid case: %s should not return error. got %w", tc.name, err) @@ -423,47 +423,37 @@ func TestMsgAssignConsumerKeyValidateBasic(t *testing.T) { providerAddr string signer string consumerKey string - consumerId string + consumerId uint64 expErr bool }{ - { - name: "invalid: consumerId empty", - consumerId: "", - expErr: true, - }, - { - name: "invalid: consumerId is not a number", - consumerId: "consumerId", - expErr: true, - }, { name: "invalid: provider address is empty", - consumerId: "1", + consumerId: 1, expErr: true, }, { name: "invalid: provider address is invalid", - consumerId: "1", + consumerId: 1, providerAddr: "some address", expErr: true, }, { name: "invalid: provider address != submitter address", - consumerId: "1", + consumerId: 1, providerAddr: valOpAddr1.String(), signer: acc2, expErr: true, }, { name: "invalid: consumer pubkey empty", - consumerId: "1", + consumerId: 1, providerAddr: valOpAddr1.String(), signer: acc1, expErr: true, }, { name: "valid", - consumerId: "1", + consumerId: 1, providerAddr: valOpAddr1.String(), signer: acc1, consumerKey: "{\"@type\": \"/cosmos.crypto.ed25519.PubKey\", \"key\": \"e3BehnEIlGUAnJYn9V8gBXuMh4tXO8xxlxyXD1APGyk=\"}", diff --git a/x/vaas/provider/types/provider.pb.go b/x/vaas/provider/types/provider.pb.go index dcf0eed..74d51d0 100644 --- a/x/vaas/provider/types/provider.pb.go +++ b/x/vaas/provider/types/provider.pb.go @@ -322,10 +322,10 @@ func (m *KeyAssignmentReplacement) GetPower() int64 { } // Used to serialize the ValidatorConsumerPubKey index from key assignment -// ValidatorConsumerPubKey: (chainID, providerAddr consAddr) -> consumerKey +// ValidatorConsumerPubKey: (consumerID, providerAddr consAddr) -> consumerKey // tmprotocrypto.PublicKey type ValidatorConsumerPubKey struct { - ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + ConsumerId uint64 `protobuf:"varint,1,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` ProviderAddr []byte `protobuf:"bytes,2,opt,name=provider_addr,json=providerAddr,proto3" json:"provider_addr,omitempty"` ConsumerKey *crypto.PublicKey `protobuf:"bytes,3,opt,name=consumer_key,json=consumerKey,proto3" json:"consumer_key,omitempty"` } @@ -363,11 +363,11 @@ func (m *ValidatorConsumerPubKey) XXX_DiscardUnknown() { var xxx_messageInfo_ValidatorConsumerPubKey proto.InternalMessageInfo -func (m *ValidatorConsumerPubKey) GetChainId() string { +func (m *ValidatorConsumerPubKey) GetConsumerId() uint64 { if m != nil { - return m.ChainId + return m.ConsumerId } - return "" + return 0 } func (m *ValidatorConsumerPubKey) GetProviderAddr() []byte { @@ -385,10 +385,10 @@ func (m *ValidatorConsumerPubKey) GetConsumerKey() *crypto.PublicKey { } // Used to serialize the ValidatorConsumerAddr index from key assignment -// ValidatorByConsumerAddr: (chainID, consumerAddr consAddr) -> providerAddr +// ValidatorByConsumerAddr: (consumerID, consumerAddr consAddr) -> providerAddr // consAddr type ValidatorByConsumerAddr struct { - ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + ConsumerId uint64 `protobuf:"varint,1,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` ConsumerAddr []byte `protobuf:"bytes,2,opt,name=consumer_addr,json=consumerAddr,proto3" json:"consumer_addr,omitempty"` ProviderAddr []byte `protobuf:"bytes,3,opt,name=provider_addr,json=providerAddr,proto3" json:"provider_addr,omitempty"` } @@ -426,11 +426,11 @@ func (m *ValidatorByConsumerAddr) XXX_DiscardUnknown() { var xxx_messageInfo_ValidatorByConsumerAddr proto.InternalMessageInfo -func (m *ValidatorByConsumerAddr) GetChainId() string { +func (m *ValidatorByConsumerAddr) GetConsumerId() uint64 { if m != nil { - return m.ChainId + return m.ConsumerId } - return "" + return 0 } func (m *ValidatorByConsumerAddr) GetConsumerAddr() []byte { @@ -448,10 +448,10 @@ func (m *ValidatorByConsumerAddr) GetProviderAddr() []byte { } // Used to serialize the ConsumerAddrsToPrune index from key assignment -// ConsumerAddrsToPrune: (chainID, pruneTs time.Time) -> consumerAddrs +// ConsumerAddrsToPrune: (consumerID, pruneTs time.Time) -> consumerAddrs // AddressList type ConsumerAddrsToPrune struct { - ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + ConsumerId uint64 `protobuf:"varint,1,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` PruneTs time.Time `protobuf:"bytes,2,opt,name=prune_ts,json=pruneTs,proto3,stdtime" json:"prune_ts"` ConsumerAddrs *AddressList `protobuf:"bytes,3,opt,name=consumer_addrs,json=consumerAddrs,proto3" json:"consumer_addrs,omitempty"` } @@ -489,11 +489,11 @@ func (m *ConsumerAddrsToPrune) XXX_DiscardUnknown() { var xxx_messageInfo_ConsumerAddrsToPrune proto.InternalMessageInfo -func (m *ConsumerAddrsToPrune) GetChainId() string { +func (m *ConsumerAddrsToPrune) GetConsumerId() uint64 { if m != nil { - return m.ChainId + return m.ConsumerId } - return "" + return 0 } func (m *ConsumerAddrsToPrune) GetPruneTs() time.Time { @@ -768,9 +768,8 @@ func (m *ConsumerInitializationParameters) GetHistoricalEntries() int64 { } // ConsumerIds contains consumer ids of chains -// Used so we can easily (de)serialize slices of strings type ConsumerIds struct { - Ids []string `protobuf:"bytes,1,rep,name=ids,proto3" json:"ids,omitempty"` + Ids []uint64 `protobuf:"varint,1,rep,packed,name=ids,proto3" json:"ids,omitempty"` } func (m *ConsumerIds) Reset() { *m = ConsumerIds{} } @@ -806,7 +805,7 @@ func (m *ConsumerIds) XXX_DiscardUnknown() { var xxx_messageInfo_ConsumerIds proto.InternalMessageInfo -func (m *ConsumerIds) GetIds() []string { +func (m *ConsumerIds) GetIds() []uint64 { if m != nil { return m.Ids } @@ -942,94 +941,94 @@ func init() { proto.RegisterFile("vaas/provider/v1/provider.proto", fileDescript var fileDescriptor_6404dd5d21545279 = []byte{ // 1400 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0x4f, 0x6f, 0x1b, 0x45, - 0x14, 0xcf, 0xc6, 0x69, 0x9b, 0x8c, 0x9d, 0xe0, 0x4e, 0xa3, 0xd6, 0x49, 0x5b, 0x3b, 0x35, 0x2a, - 0x44, 0x85, 0xee, 0x2a, 0x45, 0x42, 0x08, 0x0e, 0x55, 0x62, 0x6f, 0x1b, 0x93, 0x34, 0xb5, 0xd6, - 0x2e, 0x87, 0x0a, 0xb4, 0x9a, 0xdd, 0x9d, 0xda, 0xd3, 0xec, 0xce, 0xac, 0x76, 0xc6, 0x4e, 0xcd, - 0x81, 0x1b, 0x12, 0xc7, 0x22, 0x71, 0x40, 0xbd, 0x21, 0x2e, 0x1c, 0x7b, 0x40, 0x88, 0x8f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 0x8a, 0x0e, 0xd7, 0xac, 0x3d, 0x92, 0x64, 0x61, 0x5e, 0x98, 0xc0, - 0xf8, 0xc9, 0x28, 0x16, 0xcc, 0xda, 0xc5, 0x23, 0x5d, 0x82, 0xfa, 0x77, 0x05, 0x70, 0xb2, 0x8d, - 0x12, 0x14, 0x71, 0xf8, 0x11, 0xa8, 0x88, 0x64, 0xc0, 0x05, 0xa1, 0x3d, 0x37, 0xc6, 0x09, 0x61, - 0x81, 0x7b, 0x2f, 0x41, 0xbe, 0xcc, 0xa8, 0x62, 0xac, 0x18, 0xab, 0x73, 0xce, 0xd9, 0x4c, 0xdf, - 0x56, 0xea, 0x1b, 0x5a, 0x0b, 0x3b, 0xe0, 0x8c, 0x74, 0xec, 0xca, 0x04, 0xd9, 0x40, 0x68, 0x74, - 0x65, 0x7a, 0xc5, 0x58, 0x2d, 0x5e, 0x5b, 0x32, 0xd3, 0x3a, 0x98, 0x59, 0x1d, 0xcc, 0xa6, 0xae, - 0xd3, 0xc6, 0xec, 0x93, 0x67, 0xb5, 0xa9, 0xef, 0xff, 0xae, 0x19, 0xce, 0x69, 0x89, 0xef, 0xa6, - 0xf0, 0x74, 0x73, 0xb8, 0x0a, 0xca, 0x5e, 0xc8, 0xfc, 0x5d, 0x2e, 0xb7, 0x73, 0x71, 0xcc, 0xfc, - 0x7e, 0xa5, 0xb0, 0x62, 0xac, 0x16, 0x9c, 0x85, 0x54, 0xde, 0xc6, 0x89, 0x2d, 0xa5, 0xb0, 0x05, - 0x2e, 0x45, 0xe8, 0x81, 0x9b, 0xf1, 0xc4, 0xf5, 0x19, 0xe5, 0x98, 0xf2, 0x01, 0x77, 0x87, 0x28, - 0x24, 0x01, 0x12, 0x2c, 0xe1, 0x95, 0x19, 0x05, 0xad, 0x46, 0xe8, 0x41, 0x5b, 0xdb, 0x35, 0x32, - 0xb3, 0xcf, 0x72, 0x2b, 0xf8, 0xb5, 0x01, 0x16, 0xee, 0x61, 0x9c, 0xfa, 0x54, 0x6e, 0x2a, 0x27, - 0x74, 0x16, 0x9a, 0x39, 0x92, 0x66, 0xa6, 0x66, 0x84, 0xd9, 0x60, 0x84, 0x6e, 0x34, 0x65, 0x16, - 0xff, 0x3e, 0xab, 0xbd, 0xdb, 0x23, 0xa2, 0x3f, 0xf0, 0x4c, 0x9f, 0x45, 0x9a, 0x66, 0xfa, 0xef, - 0x2a, 0x0f, 0x76, 0x2d, 0x31, 0x8a, 0x31, 0x57, 0x80, 0x47, 0x2f, 0x1f, 0x5f, 0x29, 0x86, 0xb8, - 0x87, 0xfc, 0x91, 0x2b, 0x79, 0xfa, 0xd3, 0xcb, 0xc7, 0x57, 0x0c, 0xa7, 0x24, 0xdd, 0xb6, 0x71, - 0xb2, 0x21, 0x9d, 0xd6, 0xdf, 0x03, 0xc5, 0xf5, 0x20, 0x48, 0x30, 0xe7, 0xdb, 0x84, 0x0b, 0x78, - 0x01, 0xcc, 0xa1, 0x74, 0x89, 0x79, 0xc5, 0x58, 0x29, 0xac, 0x96, 0x9c, 0xb1, 0xa0, 0xfe, 0x39, - 0x58, 0xca, 0x53, 0xe8, 0x60, 0xd1, 0xe8, 0x23, 0xda, 0xc3, 0x6d, 0xe4, 0xef, 0x62, 0xc1, 0xe1, - 0x75, 0x30, 0x13, 0x12, 0x2e, 0x14, 0xaa, 0x78, 0xed, 0xb2, 0xa9, 0xae, 0xd4, 0x70, 0xcd, 0x7c, - 0x15, 0xa2, 0x89, 0x04, 0xda, 0x98, 0x91, 0x29, 0x39, 0x0a, 0x58, 0xff, 0xd6, 0x00, 0x95, 0x2d, - 0x3c, 0x5a, 0xe7, 0x9c, 0xf4, 0x68, 0x84, 0xa9, 0x70, 0x70, 0x1c, 0x22, 0x1f, 0xcb, 0x4f, 0xf8, - 0x36, 0x98, 0xcf, 0xcb, 0x2e, 0x03, 0x52, 0x44, 0x29, 0x39, 0xa5, 0x4c, 0x28, 0x93, 0x80, 0x1f, - 0x03, 0x10, 0x27, 0x78, 0xe8, 0xfa, 0x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0x84, 0xef, 0x03, 0xb8, - 0xef, 0x72, 0x4f, 0x52, 0xad, 0x1c, 0x4f, 0x5c, 0x67, 0x55, 0xa4, 0x9c, 0x32, 0xd3, 0x13, 0x94, - 0x81, 0x9f, 0x00, 0x10, 0xab, 0xf3, 0x3a, 0xf6, 0xa1, 0xce, 0xc5, 0xd9, 0x27, 0xac, 0x81, 0xe2, - 0x7d, 0x46, 0xa8, 0xdb, 0xc7, 0xb2, 0x19, 0xeb, 0x5e, 0x02, 0xa4, 0x68, 0x53, 0x49, 0xea, 0x01, - 0x28, 0x67, 0x25, 0xbf, 0x85, 0x05, 0x0a, 0x90, 0x40, 0x10, 0x82, 0x19, 0x8a, 0x22, 0xac, 0x4b, - 0xad, 0xbe, 0xe1, 0x0a, 0x28, 0x06, 0x98, 0xfb, 0x09, 0x89, 0x55, 0x5b, 0x9d, 0x56, 0xaa, 0x49, - 0x11, 0x5c, 0x06, 0xb3, 0x91, 0xde, 0x41, 0x45, 0x39, 0xe7, 0xe4, 0xeb, 0xfa, 0x93, 0x02, 0x58, - 0xc9, 0xdc, 0xb4, 0x28, 0x11, 0x04, 0x85, 0xe4, 0x4b, 0xd5, 0x4a, 0x55, 0x0b, 0xc7, 0x02, 0x27, - 0x1c, 0xde, 0x04, 0x0b, 0x24, 0xd5, 0x65, 0xe1, 0x1a, 0xfa, 0x40, 0x89, 0xe7, 0x9b, 0x72, 0xdc, - 0x98, 0x7a, 0xc8, 0x0c, 0xd7, 0xcc, 0x34, 0x7c, 0x7d, 0xdf, 0xe7, 0x35, 0x2e, 0x15, 0xc2, 0x4b, - 0xa0, 0xd4, 0xc3, 0x14, 0x73, 0xc2, 0xdd, 0x3e, 0xe2, 0x7d, 0x4d, 0xc8, 0xa2, 0x96, 0x6d, 0x22, - 0xde, 0x97, 0x75, 0xf1, 0x08, 0x45, 0xc9, 0x28, 0xb5, 0x48, 0xd9, 0x08, 0x52, 0x91, 0x32, 0x68, - 0x00, 0xc0, 0x63, 0xb4, 0x47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8, 0x4e, 0xdd, - 0xb5, 0x26, 0x9e, 0x2d, 0x28, 0x0c, 0x09, 0xf5, 0x88, 0xe0, 0x96, 0x7a, 0x48, 0x3e, 0xb0, 0xf6, - 0xbf, 0xd0, 0xd5, 0x1b, 0xc6, 0x3b, 0xa9, 0xea, 0xfb, 0xc1, 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, - 0x00, 0x57, 0x58, 0xf0, 0xbf, 0x0b, 0x00, 0x00, + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0xcd, 0x6f, 0xdb, 0x46, + 0x16, 0x37, 0x2d, 0x25, 0xb1, 0x47, 0xb2, 0x57, 0x99, 0x18, 0x89, 0xec, 0x24, 0x92, 0xa3, 0x45, + 0x76, 0x8d, 0xec, 0x86, 0x84, 0x52, 0xa0, 0x28, 0xda, 0x43, 0x60, 0x49, 0x4c, 0xac, 0xda, 0x71, + 0x04, 0x4a, 0xe9, 0x21, 0x68, 0x41, 0x0c, 0xc9, 0x89, 0x34, 0x31, 0xc9, 0x21, 0x38, 0x23, 0x39, + 0xea, 0xb9, 0x05, 0x7a, 0x4c, 0x81, 0x1e, 0x8a, 0x9e, 0x5a, 0xf4, 0xd2, 0x63, 0x0e, 0x45, 0x8f, + 0x3d, 0xa7, 0xb7, 0xa0, 0xa7, 0xa2, 0x28, 0xd2, 0x22, 0x39, 0xe4, 0x7f, 0xe8, 0xa9, 0x98, 0xe1, + 0x90, 0xa2, 0x3f, 0x82, 0x3a, 0xe8, 0x45, 0xe2, 0xfc, 0xde, 0xfb, 0xcd, 0xfb, 0x98, 0x37, 0xef, + 0x0d, 0xa8, 0x4f, 0x10, 0x62, 0x46, 0x14, 0xd3, 0x09, 0xf1, 0x70, 0x6c, 0x4c, 0x9a, 0xd9, 0xb7, + 0x1e, 0xc5, 0x94, 0x53, 0x58, 0x11, 0x0a, 0x7a, 0x06, 0x4e, 0x9a, 0x6b, 0x67, 0x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0x08, 0x41, 0x31, 0x44, 0x01, 0x56, 0xed, + 0x54, 0x7e, 0xc3, 0x75, 0x50, 0xf2, 0x30, 0x73, 0x63, 0x12, 0xc9, 0x4e, 0x3b, 0x2f, 0x45, 0x79, + 0x08, 0xae, 0x81, 0x85, 0x40, 0xed, 0x20, 0xbd, 0x5c, 0xb4, 0xb2, 0x75, 0xe3, 0x69, 0x01, 0xac, + 0xa7, 0x66, 0xba, 0x21, 0xe1, 0x04, 0xf9, 0xe4, 0x63, 0xd9, 0x5d, 0x65, 0x57, 0xc7, 0x1c, 0xc7, + 0x0c, 0xde, 0x06, 0xcb, 0x24, 0x91, 0xa5, 0xee, 0x6a, 0xea, 0x40, 0x89, 0xe3, 0xea, 0x62, 0x02, + 0xe9, 0x6a, 0xee, 0x4c, 0x9a, 0x7a, 0xe2, 0xbe, 0x6a, 0x01, 0x4b, 0x8a, 0x97, 0x80, 0xf0, 0x0a, + 0x28, 0x0f, 0x71, 0x88, 0x19, 0x61, 0xf6, 0x08, 0xb1, 0x91, 0x2a, 0xcb, 0x92, 0xc2, 0xb6, 0x10, + 0x1b, 0x89, 0xbc, 0x38, 0x24, 0x44, 0xf1, 0x34, 0xd1, 0x48, 0x6a, 0x12, 0x24, 0x90, 0x54, 0x68, + 0x03, 0xc0, 0x22, 0xb4, 0x1f, 0xca, 0x69, 0x21, 0xf3, 0x76, 0xd2, 0xca, 0x5a, 0x94, 0x3c, 0x21, + 0x81, 0xbb, 0xa0, 0x32, 0x0e, 0x1d, 0x1a, 0x7a, 0xb3, 0x61, 0x95, 0x35, 0xea, 0x13, 0x8c, 0x9b, + 0x7f, 0x65, 0x64, 0x35, 0x6c, 0x5e, 0x33, 0xc1, 0x4e, 0xff, 0xa3, 0x09, 0x76, 0x1d, 0xc0, 0x11, + 0x61, 0x9c, 0xc6, 0xc4, 0x45, 0xbe, 0x8d, 0x43, 0x1e, 0x13, 0xcc, 0xaa, 0x67, 0x64, 0xa5, 0x9c, + 0x9d, 0x49, 0x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xdd, 0xdb, 0xda, 0xec, 0x9b, 0xf6, + 0xbd, 0xdd, 0x7e, 0xcf, 0x6c, 0x77, 0x6f, 0x75, 0xcd, 0x4e, 0x65, 0x0e, 0x5e, 0x06, 0xab, 0x87, + 0xe4, 0x96, 0x79, 0xbb, 0xdb, 0x1f, 0x98, 0x96, 0xd9, 0xa9, 0x68, 0xc7, 0xd0, 0xbb, 0xbb, 0xdd, + 0x41, 0x77, 0x73, 0xa7, 0x7b, 0xdf, 0xec, 0x54, 0xe6, 0xe1, 0x45, 0x70, 0xe1, 0x90, 0x7c, 0x67, + 0xf3, 0xde, 0x6e, 0x7b, 0xcb, 0xec, 0x54, 0x0a, 0x70, 0x0d, 0x9c, 0x3f, 0x24, 0xec, 0x0f, 0xee, + 0xf6, 0x7a, 0x66, 0xa7, 0x52, 0x3c, 0x46, 0xd6, 0x31, 0x77, 0xcc, 0x81, 0xd9, 0xa9, 0x9c, 0x5a, + 0x2b, 0x7e, 0xf6, 0x6d, 0x6d, 0xae, 0xd5, 0x7d, 0xfa, 0xa2, 0xa6, 0x3d, 0x7b, 0x51, 0xd3, 0xfe, + 0x78, 0x51, 0xd3, 0x1e, 0xbf, 0xac, 0xcd, 0x3d, 0x7b, 0x59, 0x9b, 0xfb, 0xe5, 0x65, 0x6d, 0xee, + 0xbe, 0x91, 0x7b, 0xc9, 0x20, 0xdf, 0x27, 0xa1, 0x43, 0x38, 0x33, 0xe4, 0xdb, 0xf2, 0x91, 0x71, + 0xf0, 0xd1, 0x2e, 0x9f, 0x35, 0xce, 0x69, 0x99, 0xdf, 0xb7, 0xfe, 0x0a, 0x00, 0x00, 0xff, 0xff, + 0x42, 0xd8, 0xe2, 0x59, 0xd2, 0x0b, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -1245,12 +1244,10 @@ func (m *ValidatorConsumerPubKey) MarshalToSizedBuffer(dAtA []byte) (int, error) i-- dAtA[i] = 0x12 } - if len(m.ChainId) > 0 { - i -= len(m.ChainId) - copy(dAtA[i:], m.ChainId) - i = encodeVarintProvider(dAtA, i, uint64(len(m.ChainId))) + if m.ConsumerId != 0 { + i = encodeVarintProvider(dAtA, i, uint64(m.ConsumerId)) i-- - dAtA[i] = 0xa + dAtA[i] = 0x8 } return len(dAtA) - i, nil } @@ -1289,12 +1286,10 @@ func (m *ValidatorByConsumerAddr) MarshalToSizedBuffer(dAtA []byte) (int, error) i-- dAtA[i] = 0x12 } - if len(m.ChainId) > 0 { - i -= len(m.ChainId) - copy(dAtA[i:], m.ChainId) - i = encodeVarintProvider(dAtA, i, uint64(len(m.ChainId))) + if m.ConsumerId != 0 { + i = encodeVarintProvider(dAtA, i, uint64(m.ConsumerId)) i-- - dAtA[i] = 0xa + dAtA[i] = 0x8 } return len(dAtA) - i, nil } @@ -1339,12 +1334,10 @@ func (m *ConsumerAddrsToPrune) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintProvider(dAtA, i, uint64(n6)) i-- dAtA[i] = 0x12 - if len(m.ChainId) > 0 { - i -= len(m.ChainId) - copy(dAtA[i:], m.ChainId) - i = encodeVarintProvider(dAtA, i, uint64(len(m.ChainId))) + if m.ConsumerId != 0 { + i = encodeVarintProvider(dAtA, i, uint64(m.ConsumerId)) i-- - dAtA[i] = 0xa + dAtA[i] = 0x8 } return len(dAtA) - i, nil } @@ -1542,13 +1535,22 @@ func (m *ConsumerIds) MarshalToSizedBuffer(dAtA []byte) (int, error) { var l int _ = l if len(m.Ids) > 0 { - for iNdEx := len(m.Ids) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Ids[iNdEx]) - copy(dAtA[i:], m.Ids[iNdEx]) - i = encodeVarintProvider(dAtA, i, uint64(len(m.Ids[iNdEx]))) - i-- - dAtA[i] = 0xa - } + dAtA13 := make([]byte, len(m.Ids)*10) + var j12 int + for _, num := range m.Ids { + for num >= 1<<7 { + dAtA13[j12] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j12++ + } + dAtA13[j12] = uint8(num) + j12++ + } + i -= j12 + copy(dAtA[i:], dAtA13[:j12]) + i = encodeVarintProvider(dAtA, i, uint64(j12)) + i-- + dAtA[i] = 0xa } return len(dAtA) - i, nil } @@ -1630,12 +1632,12 @@ func (m *SlashJailParameters) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x18 } - n14, err14 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(m.JailDuration, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.JailDuration):]) - if err14 != nil { - return 0, err14 + n16, err16 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(m.JailDuration, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.JailDuration):]) + if err16 != nil { + return 0, err16 } - i -= n14 - i = encodeVarintProvider(dAtA, i, uint64(n14)) + i -= n16 + i = encodeVarintProvider(dAtA, i, uint64(n16)) i-- dAtA[i] = 0x12 { @@ -1741,9 +1743,8 @@ func (m *ValidatorConsumerPubKey) Size() (n int) { } var l int _ = l - l = len(m.ChainId) - if l > 0 { - n += 1 + l + sovProvider(uint64(l)) + if m.ConsumerId != 0 { + n += 1 + sovProvider(uint64(m.ConsumerId)) } l = len(m.ProviderAddr) if l > 0 { @@ -1762,9 +1763,8 @@ func (m *ValidatorByConsumerAddr) Size() (n int) { } var l int _ = l - l = len(m.ChainId) - if l > 0 { - n += 1 + l + sovProvider(uint64(l)) + if m.ConsumerId != 0 { + n += 1 + sovProvider(uint64(m.ConsumerId)) } l = len(m.ConsumerAddr) if l > 0 { @@ -1783,9 +1783,8 @@ func (m *ConsumerAddrsToPrune) Size() (n int) { } var l int _ = l - l = len(m.ChainId) - if l > 0 { - n += 1 + l + sovProvider(uint64(l)) + if m.ConsumerId != 0 { + n += 1 + sovProvider(uint64(m.ConsumerId)) } l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.PruneTs) n += 1 + l + sovProvider(uint64(l)) @@ -1875,10 +1874,11 @@ func (m *ConsumerIds) Size() (n int) { var l int _ = l if len(m.Ids) > 0 { - for _, s := range m.Ids { - l = len(s) - n += 1 + l + sovProvider(uint64(l)) + l = 0 + for _, e := range m.Ids { + l += sovProvider(uint64(e)) } + n += 1 + sovProvider(uint64(l)) + l } return n } @@ -2443,10 +2443,10 @@ func (m *ValidatorConsumerPubKey) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ConsumerId", wireType) } - var stringLen uint64 + m.ConsumerId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowProvider @@ -2456,24 +2456,11 @@ func (m *ValidatorConsumerPubKey) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.ConsumerId |= uint64(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthProvider - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthProvider - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ChainId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ProviderAddr", wireType) @@ -2595,10 +2582,10 @@ func (m *ValidatorByConsumerAddr) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ConsumerId", wireType) } - var stringLen uint64 + m.ConsumerId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowProvider @@ -2608,24 +2595,11 @@ func (m *ValidatorByConsumerAddr) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.ConsumerId |= uint64(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthProvider - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthProvider - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ChainId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ConsumerAddr", wireType) @@ -2745,10 +2719,10 @@ func (m *ConsumerAddrsToPrune) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ConsumerId", wireType) } - var stringLen uint64 + m.ConsumerId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowProvider @@ -2758,24 +2732,11 @@ func (m *ConsumerAddrsToPrune) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.ConsumerId |= uint64(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthProvider - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthProvider - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ChainId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field PruneTs", wireType) @@ -3469,37 +3430,81 @@ func (m *ConsumerIds) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Ids", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProvider - } - if iNdEx >= l { + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProvider + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Ids = append(m.Ids, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProvider + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthProvider + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthProvider + } + if postIndex > l { return io.ErrUnexpectedEOF } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthProvider - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthProvider - } - if postIndex > l { - return io.ErrUnexpectedEOF + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Ids) == 0 { + m.Ids = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProvider + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Ids = append(m.Ids, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field Ids", wireType) } - m.Ids = append(m.Ids, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipProvider(dAtA[iNdEx:]) diff --git a/x/vaas/provider/types/query.pb.go b/x/vaas/provider/types/query.pb.go index 0b48ea4..4447664 100644 --- a/x/vaas/provider/types/query.pb.go +++ b/x/vaas/provider/types/query.pb.go @@ -40,7 +40,7 @@ var _ = time.Kitchen const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type QueryConsumerGenesisRequest struct { - ConsumerId string `protobuf:"bytes,1,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` + ConsumerId uint64 `protobuf:"varint,1,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` } func (m *QueryConsumerGenesisRequest) Reset() { *m = QueryConsumerGenesisRequest{} } @@ -76,11 +76,11 @@ func (m *QueryConsumerGenesisRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryConsumerGenesisRequest proto.InternalMessageInfo -func (m *QueryConsumerGenesisRequest) GetConsumerId() string { +func (m *QueryConsumerGenesisRequest) GetConsumerId() uint64 { if m != nil { return m.ConsumerId } - return "" + return 0 } type QueryConsumerGenesisResponse struct { @@ -240,7 +240,7 @@ type Chain struct { Phase string `protobuf:"bytes,3,opt,name=phase,proto3" json:"phase,omitempty"` // The metadata of the consumer chain Metadata ConsumerMetadata `protobuf:"bytes,4,opt,name=metadata,proto3" json:"metadata"` - ConsumerId string `protobuf:"bytes,5,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` + ConsumerId uint64 `protobuf:"varint,5,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` // Infraction parameters for slashing and jailing InfractionParameters *InfractionParameters `protobuf:"bytes,6,opt,name=infraction_parameters,json=infractionParameters,proto3" json:"infraction_parameters,omitempty"` // The deterministic provider-side account that must be funded @@ -309,11 +309,11 @@ func (m *Chain) GetMetadata() ConsumerMetadata { return ConsumerMetadata{} } -func (m *Chain) GetConsumerId() string { +func (m *Chain) GetConsumerId() uint64 { if m != nil { return m.ConsumerId } - return "" + return 0 } func (m *Chain) GetInfractionParameters() *InfractionParameters { @@ -334,7 +334,7 @@ type QueryValidatorConsumerAddrRequest struct { // The consensus address of the validator on the provider chain ProviderAddress string `protobuf:"bytes,1,opt,name=provider_address,json=providerAddress,proto3" json:"provider_address,omitempty" yaml:"address"` // The id of the consumer chain - ConsumerId string `protobuf:"bytes,2,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` + ConsumerId uint64 `protobuf:"varint,2,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` } func (m *QueryValidatorConsumerAddrRequest) Reset() { *m = QueryValidatorConsumerAddrRequest{} } @@ -419,7 +419,7 @@ type QueryValidatorProviderAddrRequest struct { // The consensus address of the validator on the consumer chain ConsumerAddress string `protobuf:"bytes,1,opt,name=consumer_address,json=consumerAddress,proto3" json:"consumer_address,omitempty" yaml:"address"` // The id of the consumer chain - ConsumerId string `protobuf:"bytes,2,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` + ConsumerId uint64 `protobuf:"varint,2,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` } func (m *QueryValidatorProviderAddrRequest) Reset() { *m = QueryValidatorProviderAddrRequest{} } @@ -502,7 +502,7 @@ func (m *QueryValidatorProviderAddrResponse) GetProviderAddress() string { type QueryAllPairsValConsAddrByConsumerRequest struct { // The id of the consumer chain - ConsumerId string `protobuf:"bytes,1,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` + ConsumerId uint64 `protobuf:"varint,1,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` } func (m *QueryAllPairsValConsAddrByConsumerRequest) Reset() { @@ -542,11 +542,11 @@ func (m *QueryAllPairsValConsAddrByConsumerRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryAllPairsValConsAddrByConsumerRequest proto.InternalMessageInfo -func (m *QueryAllPairsValConsAddrByConsumerRequest) GetConsumerId() string { +func (m *QueryAllPairsValConsAddrByConsumerRequest) GetConsumerId() uint64 { if m != nil { return m.ConsumerId } - return "" + return 0 } type QueryAllPairsValConsAddrByConsumerResponse struct { @@ -740,7 +740,7 @@ func (m *QueryParamsResponse) GetParams() Params { } type QueryConsumerValidatorsRequest struct { - ConsumerId string `protobuf:"bytes,1,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` + ConsumerId uint64 `protobuf:"varint,1,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` } func (m *QueryConsumerValidatorsRequest) Reset() { *m = QueryConsumerValidatorsRequest{} } @@ -776,11 +776,11 @@ func (m *QueryConsumerValidatorsRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryConsumerValidatorsRequest proto.InternalMessageInfo -func (m *QueryConsumerValidatorsRequest) GetConsumerId() string { +func (m *QueryConsumerValidatorsRequest) GetConsumerId() uint64 { if m != nil { return m.ConsumerId } - return "" + return 0 } type QueryConsumerValidatorsValidator struct { @@ -1075,7 +1075,7 @@ func (m *QueryConsumerIdFromClientIdRequest) GetClientId() string { type QueryConsumerIdFromClientIdResponse struct { // the consumer id of the chain associated with this client id - ConsumerId string `protobuf:"bytes,1,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` + ConsumerId uint64 `protobuf:"varint,1,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` } func (m *QueryConsumerIdFromClientIdResponse) Reset() { *m = QueryConsumerIdFromClientIdResponse{} } @@ -1111,15 +1111,15 @@ func (m *QueryConsumerIdFromClientIdResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryConsumerIdFromClientIdResponse proto.InternalMessageInfo -func (m *QueryConsumerIdFromClientIdResponse) GetConsumerId() string { +func (m *QueryConsumerIdFromClientIdResponse) GetConsumerId() uint64 { if m != nil { return m.ConsumerId } - return "" + return 0 } type QueryConsumerChainRequest struct { - ConsumerId string `protobuf:"bytes,1,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` + ConsumerId uint64 `protobuf:"varint,1,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` } func (m *QueryConsumerChainRequest) Reset() { *m = QueryConsumerChainRequest{} } @@ -1155,15 +1155,15 @@ func (m *QueryConsumerChainRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryConsumerChainRequest proto.InternalMessageInfo -func (m *QueryConsumerChainRequest) GetConsumerId() string { +func (m *QueryConsumerChainRequest) GetConsumerId() uint64 { if m != nil { return m.ConsumerId } - return "" + return 0 } type QueryConsumerChainResponse struct { - ConsumerId string `protobuf:"bytes,1,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` + ConsumerId uint64 `protobuf:"varint,1,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` ChainId string `protobuf:"bytes,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` OwnerAddress string `protobuf:"bytes,3,opt,name=owner_address,json=ownerAddress,proto3" json:"owner_address,omitempty"` Phase string `protobuf:"bytes,4,opt,name=phase,proto3" json:"phase,omitempty"` @@ -1210,11 +1210,11 @@ func (m *QueryConsumerChainResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryConsumerChainResponse proto.InternalMessageInfo -func (m *QueryConsumerChainResponse) GetConsumerId() string { +func (m *QueryConsumerChainResponse) GetConsumerId() uint64 { if m != nil { return m.ConsumerId } - return "" + return 0 } func (m *QueryConsumerChainResponse) GetChainId() string { @@ -1274,7 +1274,7 @@ func (m *QueryConsumerChainResponse) GetFeePoolAddress() string { } type QueryConsumerGenesisTimeRequest struct { - ConsumerId string `protobuf:"bytes,1,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` + ConsumerId uint64 `protobuf:"varint,1,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` } func (m *QueryConsumerGenesisTimeRequest) Reset() { *m = QueryConsumerGenesisTimeRequest{} } @@ -1310,11 +1310,11 @@ func (m *QueryConsumerGenesisTimeRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryConsumerGenesisTimeRequest proto.InternalMessageInfo -func (m *QueryConsumerGenesisTimeRequest) GetConsumerId() string { +func (m *QueryConsumerGenesisTimeRequest) GetConsumerId() uint64 { if m != nil { return m.ConsumerId } - return "" + return 0 } type QueryConsumerGenesisTimeResponse struct { @@ -1392,7 +1392,7 @@ func init() { func init() { proto.RegisterFile("vaas/provider/v1/query.proto", fileDescriptor_71b3f55ed407aa51) } var fileDescriptor_71b3f55ed407aa51 = []byte{ - // 1795 bytes of a gzipped FileDescriptorProto + // 1794 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x58, 0x4d, 0x6c, 0x1b, 0x41, 0x15, 0xce, 0x3a, 0x3f, 0x75, 0xc6, 0x6d, 0x1a, 0x86, 0x84, 0x38, 0x6e, 0x12, 0xb7, 0xdb, 0x1f, 0xd2, 0x9f, 0xec, 0xd6, 0x4e, 0x53, 0xa1, 0x50, 0x40, 0x71, 0x4a, 0x82, 0x55, 0x4a, 0xcd, 0x26, @@ -1413,7 +1413,7 @@ var fileDescriptor_71b3f55ed407aa51 = []byte{ 0x0d, 0x2e, 0x55, 0x47, 0x1e, 0x66, 0x21, 0x0b, 0x05, 0x1d, 0xd4, 0x24, 0x16, 0x0d, 0x0b, 0x93, 0x95, 0xbf, 0x0d, 0x2e, 0xfc, 0x30, 0x90, 0x58, 0xe7, 0xa8, 0x37, 0xb1, 0x85, 0x3d, 0xe2, 0x69, 0xf8, 0x69, 0x1b, 0x7b, 0x3e, 0x2c, 0x82, 0x9c, 0xf0, 0x47, 0x27, 0x46, 0x5e, 0xba, 0x28, 0x2d, - 0x8e, 0x6b, 0x40, 0x2c, 0x55, 0x0d, 0x79, 0x17, 0xcc, 0x25, 0x9f, 0xf7, 0x1c, 0xdb, 0xf2, 0x30, + 0x8e, 0x68, 0x40, 0x2c, 0x55, 0x0d, 0x79, 0x17, 0xcc, 0x25, 0x9f, 0xf7, 0x1c, 0xdb, 0xf2, 0x30, 0xfc, 0x1e, 0x38, 0xd7, 0x64, 0x4b, 0xba, 0xe7, 0x23, 0x1f, 0x53, 0x15, 0xb9, 0xf2, 0xbc, 0x42, 0x6f, 0xaf, 0x53, 0x52, 0x62, 0x07, 0xb7, 0x02, 0xa1, 0xca, 0xc8, 0xeb, 0xc3, 0xe2, 0x90, 0x76, 0xb6, 0xd9, 0xb3, 0x26, 0xff, 0x4e, 0x02, 0x85, 0x88, 0xa9, 0xf5, 0x5d, 0x44, 0xac, 0x10, 0xe9, @@ -1423,89 +1423,89 @@ var fileDescriptor_71b3f55ed407aa51 = []byte{ 0xf2, 0x6f, 0xa5, 0x58, 0x20, 0x05, 0x3a, 0x1e, 0x07, 0x15, 0x8c, 0x35, 0xe8, 0x4a, 0x5e, 0xba, 0x38, 0xbc, 0x98, 0x2b, 0xcf, 0x24, 0xe0, 0x0b, 0xf6, 0x35, 0x2e, 0x06, 0x37, 0x13, 0x80, 0x7d, 0xbd, 0x2f, 0x30, 0x66, 0x2d, 0x82, 0xec, 0xaf, 0x19, 0x30, 0x4a, 0x55, 0xc3, 0x59, 0x90, 0xa5, - 0xca, 0x8f, 0x6e, 0xf2, 0x0c, 0xfd, 0xae, 0x1a, 0xf0, 0x02, 0x18, 0x6f, 0x98, 0x04, 0x5b, 0x7e, - 0xb0, 0x97, 0xa1, 0x7b, 0x59, 0xb6, 0x50, 0x35, 0xe0, 0x94, 0x08, 0xed, 0x30, 0xdd, 0xe0, 0x91, - 0xbb, 0x0f, 0xb2, 0x2d, 0xec, 0x23, 0x03, 0xf9, 0x28, 0x3f, 0x42, 0xe1, 0xc9, 0xe9, 0x31, 0x7f, - 0xc8, 0x25, 0xf9, 0xcd, 0x86, 0x27, 0xe3, 0x09, 0x36, 0x1a, 0x4f, 0x30, 0xf8, 0x63, 0x30, 0x4d, - 0xac, 0x1d, 0x17, 0x35, 0x02, 0x67, 0x74, 0x07, 0xb9, 0xa8, 0x85, 0x7d, 0xec, 0x7a, 0xf9, 0x31, - 0x7e, 0x57, 0xc7, 0x6c, 0x56, 0x43, 0xf1, 0x5a, 0x28, 0xad, 0x4d, 0x91, 0x84, 0x55, 0xb8, 0x08, - 0x26, 0x77, 0x30, 0xd6, 0x1d, 0xdb, 0x36, 0x75, 0x64, 0x18, 0x2e, 0xf6, 0xbc, 0xfc, 0x19, 0x0a, - 0x61, 0x62, 0x07, 0xe3, 0x9a, 0x6d, 0x9b, 0x6b, 0x6c, 0x55, 0xfe, 0xb5, 0x04, 0x2e, 0xd1, 0xfb, - 0x7d, 0x8c, 0x4c, 0x62, 0x20, 0xdf, 0x76, 0x85, 0x6b, 0x81, 0x84, 0x48, 0xc2, 0x6f, 0x81, 0x49, - 0x81, 0x24, 0xd4, 0x47, 0x23, 0x5d, 0x81, 0x9f, 0x0e, 0x8b, 0x13, 0x5d, 0xd4, 0x32, 0x57, 0x65, - 0xbe, 0x21, 0x6b, 0xe7, 0x85, 0x2c, 0x37, 0x12, 0x0f, 0x46, 0x26, 0x1e, 0x8c, 0xd5, 0xec, 0x2f, - 0x5f, 0x16, 0x87, 0xfe, 0xf5, 0xb2, 0x38, 0x24, 0x3f, 0x02, 0xf2, 0x49, 0x70, 0x78, 0xd6, 0x5d, - 0x07, 0x93, 0xa1, 0xc2, 0x08, 0x1e, 0xed, 0x7c, 0xa3, 0x47, 0x3e, 0xd9, 0xc1, 0x5a, 0x0f, 0xba, - 0x1e, 0x07, 0x93, 0x15, 0x26, 0x3b, 0x18, 0x33, 0xf2, 0x45, 0x0e, 0x46, 0xe1, 0x1c, 0x39, 0x98, - 0x1c, 0xf0, 0x63, 0xc1, 0x95, 0xbf, 0x0f, 0xae, 0x53, 0x85, 0x6b, 0xa6, 0x59, 0x43, 0xc4, 0xf5, - 0x1e, 0x23, 0x33, 0x88, 0x59, 0xb0, 0x5d, 0x09, 0x5f, 0xed, 0xc0, 0x75, 0xef, 0x57, 0x12, 0xb8, - 0x31, 0x88, 0x3a, 0x8e, 0xf3, 0xa7, 0xe0, 0x2b, 0x0e, 0x22, 0xae, 0xde, 0x41, 0x66, 0xd0, 0x20, - 0x28, 0x56, 0x5e, 0x09, 0x96, 0x8f, 0x67, 0x70, 0xa0, 0x90, 0xe9, 0x0b, 0xd4, 0x85, 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c, 0x19, 0xaf, 0x2b, 0xa7, 0x2b, 0xaa, + 0x5a, 0xc4, 0x27, 0xc8, 0x24, 0x3f, 0x47, 0x31, 0x8e, 0x07, 0x02, 0x35, 0xac, 0x84, 0xa7, 0xd3, + 0xc6, 0x33, 0xff, 0x07, 0xda, 0x18, 0x49, 0x98, 0x6c, 0x8c, 0x2d, 0x27, 0x71, 0xca, 0xf1, 0x44, + 0x4e, 0x59, 0x89, 0x3d, 0x4a, 0x3e, 0x02, 0x6d, 0x93, 0x16, 0x1e, 0x38, 0x31, 0xf6, 0x62, 0x8d, + 0x25, 0xa2, 0x83, 0x67, 0xc7, 0x26, 0x10, 0x93, 0x94, 0x1e, 0x4c, 0xb7, 0xbc, 0xfd, 0x15, 0x14, + 0x36, 0xfa, 0x2a, 0x62, 0xf4, 0x55, 0xb6, 0xc5, 0xe8, 0x5b, 0xc9, 0x06, 0x57, 0xf4, 0xe2, 0xef, + 0x45, 0x49, 0xcb, 0x35, 0x8f, 0x14, 0x96, 0xff, 0x73, 0x1e, 0x8c, 0x52, 0x6b, 0xf0, 0x8f, 0x12, + 0x98, 0x4a, 0xb2, 0x0b, 0x97, 0xfa, 0x54, 0x8c, 0xe8, 0x7c, 0x59, 0x50, 0x06, 0x15, 0x67, 0xae, + 0xc8, 0x2b, 0xbf, 0x78, 0xf7, 0xcf, 0xdf, 0x64, 0x54, 0xb8, 0xa4, 0x46, 0xc7, 0xf2, 0x30, 0x48, + 0x1c, 0xae, 0xba, 0xdf, 0x13, 0xb6, 0x03, 0xf8, 0x7b, 0x89, 0x53, 0x82, 0xe8, 0x74, 0x06, 0x6f, + 0xf5, 0x31, 0x1f, 0x19, 0x31, 0x0b, 0x4b, 0x03, 0x4a, 0x73, 0xac, 0x0a, 0xc5, 0xba, 0x08, 0xaf, + 0xa5, 0x61, 0x65, 0x93, 0x9e, 0xba, 0x4f, 0x1f, 0xd3, 0x01, 0x7c, 0x2f, 0x06, 0xdc, 0x44, 0x4e, + 0x0f, 0x97, 0x53, 0xac, 0x9f, 0x34, 0x90, 0x14, 0xee, 0x9c, 0xee, 0x10, 0x47, 0xfe, 0x88, 0x22, + 0xaf, 0xc2, 0xcd, 0x18, 0xf2, 0xb0, 0xb2, 0xeb, 0x11, 0x72, 0x17, 0x0d, 0xb6, 0xba, 0x1f, 0x67, + 0x31, 0x49, 0xae, 0xf5, 0xb2, 0xf9, 0xfe, 0xae, 0x25, 0x8c, 0x22, 0xfd, 0x5d, 0x4b, 0x1a, 0x18, + 0x06, 0x70, 0x2d, 0x82, 0x3e, 0xee, 0x5a, 0x9c, 0xd4, 0x1e, 0xc0, 0x77, 0x12, 0xef, 0x31, 0x27, + 0x0e, 0x02, 0xf0, 0x9b, 0x29, 0x68, 0x07, 0x99, 0x46, 0x0a, 0xf7, 0x3e, 0xef, 0x30, 0x77, 0xb9, + 0x4c, 0x5d, 0xbe, 0x05, 0x6f, 0xc4, 0x5c, 0xe6, 0x2e, 0xe8, 0xc1, 0x28, 0x11, 0x7f, 0x30, 0x5d, + 0x90, 0xeb, 0xa1, 0xd0, 0xf0, 0x4a, 0x0a, 0x80, 0x08, 0xef, 0x2e, 0x5c, 0xed, 0x23, 0xc5, 0xf1, + 0xcc, 0x53, 0x3c, 0x33, 0x70, 0x3a, 0x86, 0x87, 0xd5, 0x7f, 0xf8, 0x27, 0x09, 0xcc, 0xa4, 0x90, + 0x0c, 0x78, 0x7b, 0x60, 0x3e, 0x22, 0x30, 0x95, 0x4e, 0x71, 0x82, 0xe3, 0xfb, 0x06, 0xc5, 0x57, + 0x86, 0xb7, 0xd3, 0xde, 0xed, 0x11, 0xc1, 0x89, 0x45, 0xed, 0x95, 0xc4, 0x9b, 0x7c, 0x12, 0x97, + 0x81, 0x69, 0x64, 0xea, 0x04, 0x72, 0x54, 0x58, 0x3e, 0xd5, 0x99, 0x3e, 0x85, 0x27, 0x85, 0x41, + 0xc1, 0x3f, 0xc7, 0xff, 0xbb, 0x8a, 0x72, 0x1c, 0x78, 0xa7, 0x4f, 0x0c, 0x13, 0x59, 0x55, 0x61, + 0xe5, 0x94, 0xa7, 0x06, 0xad, 0x9a, 0xc4, 0x50, 0xf7, 0xc3, 0xee, 0x7b, 0x00, 0xff, 0x20, 0xf1, + 0x19, 0x30, 0x52, 0x85, 0xe1, 0xcd, 0x41, 0x6a, 0xb5, 0x80, 0x7a, 0x6b, 0x30, 0x61, 0x8e, 0x70, + 0x99, 0x22, 0x5c, 0x82, 0x37, 0x4f, 0xac, 0xeb, 0xb1, 0xd4, 0xf8, 0x8b, 0x04, 0xf2, 0x69, 0x8d, + 0x1a, 0x96, 0x06, 0xeb, 0x82, 0x3d, 0xc4, 0xa0, 0x50, 0x3e, 0xcd, 0x11, 0x0e, 0x7c, 0x95, 0x02, + 0xbf, 0x03, 0xcb, 0x7d, 0x9a, 0x27, 0x65, 0x09, 0x51, 0xfc, 0x95, 0xea, 0xeb, 0x0f, 0x0b, 0xd2, + 0x9b, 0x0f, 0x0b, 0xd2, 0x3f, 0x3e, 0x2c, 0x48, 0x2f, 0x3e, 0x2e, 0x0c, 0xbd, 0xf9, 0xb8, 0x30, + 0xf4, 0xfe, 0xe3, 0xc2, 0xd0, 0x13, 0xb5, 0x49, 0xfc, 0xdd, 0x76, 0x5d, 0x69, 0xd8, 0x2d, 0x15, + 0x99, 0x26, 0xb1, 0xea, 0xc4, 0xf7, 0x98, 0x85, 0xe7, 0x31, 0x43, 0x7e, 0xd7, 0xc1, 0x5e, 0x7d, + 0x8c, 0x12, 0x8e, 0xe5, 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, 0x16, 0x20, 0x71, 0xbb, 0xdf, 0x17, + 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -2012,12 +2012,10 @@ func (m *QueryConsumerGenesisRequest) MarshalToSizedBuffer(dAtA []byte) (int, er _ = i var l int _ = l - if len(m.ConsumerId) > 0 { - i -= len(m.ConsumerId) - copy(dAtA[i:], m.ConsumerId) - i = encodeVarintQuery(dAtA, i, uint64(len(m.ConsumerId))) + if m.ConsumerId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.ConsumerId)) i-- - dAtA[i] = 0xa + dAtA[i] = 0x8 } return len(dAtA) - i, nil } @@ -2183,12 +2181,10 @@ func (m *Chain) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x32 } - if len(m.ConsumerId) > 0 { - i -= len(m.ConsumerId) - copy(dAtA[i:], m.ConsumerId) - i = encodeVarintQuery(dAtA, i, uint64(len(m.ConsumerId))) + if m.ConsumerId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.ConsumerId)) i-- - dAtA[i] = 0x2a + dAtA[i] = 0x28 } { size, err := m.Metadata.MarshalToSizedBuffer(dAtA[:i]) @@ -2244,12 +2240,10 @@ func (m *QueryValidatorConsumerAddrRequest) MarshalToSizedBuffer(dAtA []byte) (i _ = i var l int _ = l - if len(m.ConsumerId) > 0 { - i -= len(m.ConsumerId) - copy(dAtA[i:], m.ConsumerId) - i = encodeVarintQuery(dAtA, i, uint64(len(m.ConsumerId))) + if m.ConsumerId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.ConsumerId)) i-- - dAtA[i] = 0x12 + dAtA[i] = 0x10 } if len(m.ProviderAddress) > 0 { i -= len(m.ProviderAddress) @@ -2311,12 +2305,10 @@ func (m *QueryValidatorProviderAddrRequest) MarshalToSizedBuffer(dAtA []byte) (i _ = i var l int _ = l - if len(m.ConsumerId) > 0 { - i -= len(m.ConsumerId) - copy(dAtA[i:], m.ConsumerId) - i = encodeVarintQuery(dAtA, i, uint64(len(m.ConsumerId))) + if m.ConsumerId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.ConsumerId)) i-- - dAtA[i] = 0x12 + dAtA[i] = 0x10 } if len(m.ConsumerAddress) > 0 { i -= len(m.ConsumerAddress) @@ -2378,12 +2370,10 @@ func (m *QueryAllPairsValConsAddrByConsumerRequest) MarshalToSizedBuffer(dAtA [] _ = i var l int _ = l - if len(m.ConsumerId) > 0 { - i -= len(m.ConsumerId) - copy(dAtA[i:], m.ConsumerId) - i = encodeVarintQuery(dAtA, i, uint64(len(m.ConsumerId))) + if m.ConsumerId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.ConsumerId)) i-- - dAtA[i] = 0xa + dAtA[i] = 0x8 } return len(dAtA) - i, nil } @@ -2550,12 +2540,10 @@ func (m *QueryConsumerValidatorsRequest) MarshalToSizedBuffer(dAtA []byte) (int, _ = i var l int _ = l - if len(m.ConsumerId) > 0 { - i -= len(m.ConsumerId) - copy(dAtA[i:], m.ConsumerId) - i = encodeVarintQuery(dAtA, i, uint64(len(m.ConsumerId))) + if m.ConsumerId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.ConsumerId)) i-- - dAtA[i] = 0xa + dAtA[i] = 0x8 } return len(dAtA) - i, nil } @@ -2802,12 +2790,10 @@ func (m *QueryConsumerIdFromClientIdResponse) MarshalToSizedBuffer(dAtA []byte) _ = i var l int _ = l - if len(m.ConsumerId) > 0 { - i -= len(m.ConsumerId) - copy(dAtA[i:], m.ConsumerId) - i = encodeVarintQuery(dAtA, i, uint64(len(m.ConsumerId))) + if m.ConsumerId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.ConsumerId)) i-- - dAtA[i] = 0xa + dAtA[i] = 0x8 } return len(dAtA) - i, nil } @@ -2832,12 +2818,10 @@ func (m *QueryConsumerChainRequest) MarshalToSizedBuffer(dAtA []byte) (int, erro _ = i var l int _ = l - if len(m.ConsumerId) > 0 { - i -= len(m.ConsumerId) - copy(dAtA[i:], m.ConsumerId) - i = encodeVarintQuery(dAtA, i, uint64(len(m.ConsumerId))) + if m.ConsumerId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.ConsumerId)) i-- - dAtA[i] = 0xa + dAtA[i] = 0x8 } return len(dAtA) - i, nil } @@ -2931,12 +2915,10 @@ func (m *QueryConsumerChainResponse) MarshalToSizedBuffer(dAtA []byte) (int, err i-- dAtA[i] = 0x12 } - if len(m.ConsumerId) > 0 { - i -= len(m.ConsumerId) - copy(dAtA[i:], m.ConsumerId) - i = encodeVarintQuery(dAtA, i, uint64(len(m.ConsumerId))) + if m.ConsumerId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.ConsumerId)) i-- - dAtA[i] = 0xa + dAtA[i] = 0x8 } return len(dAtA) - i, nil } @@ -2961,12 +2943,10 @@ func (m *QueryConsumerGenesisTimeRequest) MarshalToSizedBuffer(dAtA []byte) (int _ = i var l int _ = l - if len(m.ConsumerId) > 0 { - i -= len(m.ConsumerId) - copy(dAtA[i:], m.ConsumerId) - i = encodeVarintQuery(dAtA, i, uint64(len(m.ConsumerId))) + if m.ConsumerId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.ConsumerId)) i-- - dAtA[i] = 0xa + dAtA[i] = 0x8 } return len(dAtA) - i, nil } @@ -3019,9 +2999,8 @@ func (m *QueryConsumerGenesisRequest) Size() (n int) { } var l int _ = l - l = len(m.ConsumerId) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) + if m.ConsumerId != 0 { + n += 1 + sovQuery(uint64(m.ConsumerId)) } return n } @@ -3092,9 +3071,8 @@ func (m *Chain) Size() (n int) { } l = m.Metadata.Size() n += 1 + l + sovQuery(uint64(l)) - l = len(m.ConsumerId) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) + if m.ConsumerId != 0 { + n += 1 + sovQuery(uint64(m.ConsumerId)) } if m.InfractionParameters != nil { l = m.InfractionParameters.Size() @@ -3117,9 +3095,8 @@ func (m *QueryValidatorConsumerAddrRequest) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } - l = len(m.ConsumerId) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) + if m.ConsumerId != 0 { + n += 1 + sovQuery(uint64(m.ConsumerId)) } return n } @@ -3147,9 +3124,8 @@ func (m *QueryValidatorProviderAddrRequest) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } - l = len(m.ConsumerId) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) + if m.ConsumerId != 0 { + n += 1 + sovQuery(uint64(m.ConsumerId)) } return n } @@ -3173,9 +3149,8 @@ func (m *QueryAllPairsValConsAddrByConsumerRequest) Size() (n int) { } var l int _ = l - l = len(m.ConsumerId) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) + if m.ConsumerId != 0 { + n += 1 + sovQuery(uint64(m.ConsumerId)) } return n } @@ -3242,9 +3217,8 @@ func (m *QueryConsumerValidatorsRequest) Size() (n int) { } var l int _ = l - l = len(m.ConsumerId) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) + if m.ConsumerId != 0 { + n += 1 + sovQuery(uint64(m.ConsumerId)) } return n } @@ -3344,9 +3318,8 @@ func (m *QueryConsumerIdFromClientIdResponse) Size() (n int) { } var l int _ = l - l = len(m.ConsumerId) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) + if m.ConsumerId != 0 { + n += 1 + sovQuery(uint64(m.ConsumerId)) } return n } @@ -3357,9 +3330,8 @@ func (m *QueryConsumerChainRequest) Size() (n int) { } var l int _ = l - l = len(m.ConsumerId) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) + if m.ConsumerId != 0 { + n += 1 + sovQuery(uint64(m.ConsumerId)) } return n } @@ -3370,9 +3342,8 @@ func (m *QueryConsumerChainResponse) Size() (n int) { } var l int _ = l - l = len(m.ConsumerId) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) + if m.ConsumerId != 0 { + n += 1 + sovQuery(uint64(m.ConsumerId)) } l = len(m.ChainId) if l > 0 { @@ -3413,9 +3384,8 @@ func (m *QueryConsumerGenesisTimeRequest) Size() (n int) { } var l int _ = l - l = len(m.ConsumerId) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) + if m.ConsumerId != 0 { + n += 1 + sovQuery(uint64(m.ConsumerId)) } return n } @@ -3467,10 +3437,10 @@ func (m *QueryConsumerGenesisRequest) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: - if wireType != 2 { + if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field ConsumerId", wireType) } - var stringLen uint64 + m.ConsumerId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -3480,24 +3450,11 @@ func (m *QueryConsumerGenesisRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.ConsumerId |= uint64(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ConsumerId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -3986,10 +3943,10 @@ func (m *Chain) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 5: - if wireType != 2 { + if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field ConsumerId", wireType) } - var stringLen uint64 + m.ConsumerId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -3999,24 +3956,11 @@ func (m *Chain) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.ConsumerId |= uint64(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ConsumerId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field InfractionParameters", wireType) @@ -4168,10 +4112,10 @@ func (m *QueryValidatorConsumerAddrRequest) Unmarshal(dAtA []byte) error { m.ProviderAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: - if wireType != 2 { + if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field ConsumerId", wireType) } - var stringLen uint64 + m.ConsumerId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -4181,24 +4125,11 @@ func (m *QueryValidatorConsumerAddrRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.ConsumerId |= uint64(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ConsumerId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -4364,10 +4295,10 @@ func (m *QueryValidatorProviderAddrRequest) Unmarshal(dAtA []byte) error { m.ConsumerAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: - if wireType != 2 { + if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field ConsumerId", wireType) } - var stringLen uint64 + m.ConsumerId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -4377,24 +4308,11 @@ func (m *QueryValidatorProviderAddrRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.ConsumerId |= uint64(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ConsumerId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -4528,10 +4446,10 @@ func (m *QueryAllPairsValConsAddrByConsumerRequest) Unmarshal(dAtA []byte) error } switch fieldNum { case 1: - if wireType != 2 { + if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field ConsumerId", wireType) } - var stringLen uint64 + m.ConsumerId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -4541,24 +4459,11 @@ func (m *QueryAllPairsValConsAddrByConsumerRequest) Unmarshal(dAtA []byte) error } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.ConsumerId |= uint64(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ConsumerId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -4977,10 +4882,10 @@ func (m *QueryConsumerValidatorsRequest) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: - if wireType != 2 { + if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field ConsumerId", wireType) } - var stringLen uint64 + m.ConsumerId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -4990,24 +4895,11 @@ func (m *QueryConsumerValidatorsRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.ConsumerId |= uint64(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ConsumerId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -5658,10 +5550,10 @@ func (m *QueryConsumerIdFromClientIdResponse) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: - if wireType != 2 { + if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field ConsumerId", wireType) } - var stringLen uint64 + m.ConsumerId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -5671,24 +5563,11 @@ func (m *QueryConsumerIdFromClientIdResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.ConsumerId |= uint64(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ConsumerId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -5740,10 +5619,10 @@ func (m *QueryConsumerChainRequest) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: - if wireType != 2 { + if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field ConsumerId", wireType) } - var stringLen uint64 + m.ConsumerId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -5753,24 +5632,11 @@ func (m *QueryConsumerChainRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.ConsumerId |= uint64(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ConsumerId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -5822,10 +5688,10 @@ func (m *QueryConsumerChainResponse) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: - if wireType != 2 { + if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field ConsumerId", wireType) } - var stringLen uint64 + m.ConsumerId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -5835,24 +5701,11 @@ func (m *QueryConsumerChainResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.ConsumerId |= uint64(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ConsumerId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType) @@ -6169,10 +6022,10 @@ func (m *QueryConsumerGenesisTimeRequest) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: - if wireType != 2 { + if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field ConsumerId", wireType) } - var stringLen uint64 + m.ConsumerId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -6182,24 +6035,11 @@ func (m *QueryConsumerGenesisTimeRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.ConsumerId |= uint64(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ConsumerId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) diff --git a/x/vaas/provider/types/query.pb.gw.go b/x/vaas/provider/types/query.pb.gw.go index c4dc91c..d28b805 100644 --- a/x/vaas/provider/types/query.pb.gw.go +++ b/x/vaas/provider/types/query.pb.gw.go @@ -49,7 +49,7 @@ func request_Query_QueryConsumerGenesis_0(ctx context.Context, marshaler runtime return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "consumer_id") } - protoReq.ConsumerId, err = runtime.String(val) + protoReq.ConsumerId, err = runtime.Uint64(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "consumer_id", err) @@ -76,7 +76,7 @@ func local_request_Query_QueryConsumerGenesis_0(ctx context.Context, marshaler r return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "consumer_id") } - protoReq.ConsumerId, err = runtime.String(val) + protoReq.ConsumerId, err = runtime.Uint64(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "consumer_id", err) @@ -181,7 +181,7 @@ func request_Query_QueryValidatorConsumerAddr_0(ctx context.Context, marshaler r return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "consumer_id") } - protoReq.ConsumerId, err = runtime.String(val) + protoReq.ConsumerId, err = runtime.Uint64(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "consumer_id", err) @@ -219,7 +219,7 @@ func local_request_Query_QueryValidatorConsumerAddr_0(ctx context.Context, marsh return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "consumer_id") } - protoReq.ConsumerId, err = runtime.String(val) + protoReq.ConsumerId, err = runtime.Uint64(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "consumer_id", err) @@ -257,7 +257,7 @@ func request_Query_QueryValidatorProviderAddr_0(ctx context.Context, marshaler r return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "consumer_id") } - protoReq.ConsumerId, err = runtime.String(val) + protoReq.ConsumerId, err = runtime.Uint64(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "consumer_id", err) @@ -295,7 +295,7 @@ func local_request_Query_QueryValidatorProviderAddr_0(ctx context.Context, marsh return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "consumer_id") } - protoReq.ConsumerId, err = runtime.String(val) + protoReq.ConsumerId, err = runtime.Uint64(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "consumer_id", err) @@ -333,7 +333,7 @@ func request_Query_QueryAllPairsValConsAddrByConsumer_0(ctx context.Context, mar return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "consumer_id") } - protoReq.ConsumerId, err = runtime.String(val) + protoReq.ConsumerId, err = runtime.Uint64(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "consumer_id", err) @@ -360,7 +360,7 @@ func local_request_Query_QueryAllPairsValConsAddrByConsumer_0(ctx context.Contex return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "consumer_id") } - protoReq.ConsumerId, err = runtime.String(val) + protoReq.ConsumerId, err = runtime.Uint64(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "consumer_id", err) @@ -405,7 +405,7 @@ func request_Query_QueryConsumerValidators_0(ctx context.Context, marshaler runt return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "consumer_id") } - protoReq.ConsumerId, err = runtime.String(val) + protoReq.ConsumerId, err = runtime.Uint64(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "consumer_id", err) @@ -432,7 +432,7 @@ func local_request_Query_QueryConsumerValidators_0(ctx context.Context, marshale return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "consumer_id") } - protoReq.ConsumerId, err = runtime.String(val) + protoReq.ConsumerId, err = runtime.Uint64(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "consumer_id", err) @@ -531,7 +531,7 @@ func request_Query_QueryConsumerChain_0(ctx context.Context, marshaler runtime.M return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "consumer_id") } - protoReq.ConsumerId, err = runtime.String(val) + protoReq.ConsumerId, err = runtime.Uint64(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "consumer_id", err) @@ -558,7 +558,7 @@ func local_request_Query_QueryConsumerChain_0(ctx context.Context, marshaler run return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "consumer_id") } - protoReq.ConsumerId, err = runtime.String(val) + protoReq.ConsumerId, err = runtime.Uint64(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "consumer_id", err) @@ -585,7 +585,7 @@ func request_Query_QueryConsumerGenesisTime_0(ctx context.Context, marshaler run return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "consumer_id") } - protoReq.ConsumerId, err = runtime.String(val) + protoReq.ConsumerId, err = runtime.Uint64(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "consumer_id", err) @@ -612,7 +612,7 @@ func local_request_Query_QueryConsumerGenesisTime_0(ctx context.Context, marshal return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "consumer_id") } - protoReq.ConsumerId, err = runtime.String(val) + protoReq.ConsumerId, err = runtime.Uint64(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "consumer_id", err) diff --git a/x/vaas/provider/types/tx.pb.go b/x/vaas/provider/types/tx.pb.go index 9dadc4e..812b224 100644 --- a/x/vaas/provider/types/tx.pb.go +++ b/x/vaas/provider/types/tx.pb.go @@ -40,7 +40,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type MsgAssignConsumerKey struct { // the consumer id of the consumer chain to assign a consensus public key to - ConsumerId string `protobuf:"bytes,1,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` + ConsumerId uint64 `protobuf:"varint,1,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` // The validator address on the provider ProviderAddr string `protobuf:"bytes,2,opt,name=provider_addr,json=providerAddr,proto3" json:"provider_addr,omitempty" yaml:"address"` // The consensus public key to use on the consumer. @@ -127,7 +127,7 @@ type MsgSubmitConsumerMisbehaviour struct { // two conflicting IBC headers Misbehaviour *_07_tendermint.Misbehaviour `protobuf:"bytes,2,opt,name=misbehaviour,proto3" json:"misbehaviour,omitempty"` // the consumer id of the consumer chain where the misbehaviour occurred - ConsumerId string `protobuf:"bytes,3,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` + ConsumerId uint64 `protobuf:"varint,3,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` } func (m *MsgSubmitConsumerMisbehaviour) Reset() { *m = MsgSubmitConsumerMisbehaviour{} } @@ -209,7 +209,7 @@ type MsgSubmitConsumerDoubleVoting struct { // The light client header of the infraction block InfractionBlockHeader *_07_tendermint.Header `protobuf:"bytes,3,opt,name=infraction_block_header,json=infractionBlockHeader,proto3" json:"infraction_block_header,omitempty"` // the consumer id of the consumer chain where the double-voting took place - ConsumerId string `protobuf:"bytes,4,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` + ConsumerId uint64 `protobuf:"varint,4,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` } func (m *MsgSubmitConsumerDoubleVoting) Reset() { *m = MsgSubmitConsumerDoubleVoting{} } @@ -376,7 +376,7 @@ var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo // If it passes, all the consumer chain's state is eventually removed from the provider chain. type MsgRemoveConsumer struct { // the consumer id of the consumer chain to be stopped - ConsumerId string `protobuf:"bytes,1,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` + ConsumerId uint64 `protobuf:"varint,1,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` // the address of the owner of the consumer chain to be stopped Owner string `protobuf:"bytes,2,opt,name=owner,proto3" json:"owner,omitempty"` } @@ -414,11 +414,11 @@ func (m *MsgRemoveConsumer) XXX_DiscardUnknown() { var xxx_messageInfo_MsgRemoveConsumer proto.InternalMessageInfo -func (m *MsgRemoveConsumer) GetConsumerId() string { +func (m *MsgRemoveConsumer) GetConsumerId() uint64 { if m != nil { return m.ConsumerId } - return "" + return 0 } func (m *MsgRemoveConsumer) GetOwner() string { @@ -548,7 +548,7 @@ func (m *MsgCreateConsumer) GetInfractionParameters() *InfractionParameters { // MsgCreateConsumerResponse defines response type for MsgCreateConsumer type MsgCreateConsumerResponse struct { - ConsumerId string `protobuf:"bytes,1,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` + ConsumerId uint64 `protobuf:"varint,1,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` } func (m *MsgCreateConsumerResponse) Reset() { *m = MsgCreateConsumerResponse{} } @@ -584,11 +584,11 @@ func (m *MsgCreateConsumerResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgCreateConsumerResponse proto.InternalMessageInfo -func (m *MsgCreateConsumerResponse) GetConsumerId() string { +func (m *MsgCreateConsumerResponse) GetConsumerId() uint64 { if m != nil { return m.ConsumerId } - return "" + return 0 } // MsgUpdateConsumer defines the message used to modify a consumer chain. @@ -596,7 +596,7 @@ type MsgUpdateConsumer struct { // the address of the owner of the consumer chain to be updated Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"` // the consumer id of the consumer chain to be updated - ConsumerId string `protobuf:"bytes,2,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` + ConsumerId uint64 `protobuf:"varint,2,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` // the new owner of the consumer when updated NewOwnerAddress string `protobuf:"bytes,3,opt,name=new_owner_address,json=newOwnerAddress,proto3" json:"new_owner_address,omitempty"` // the metadata of the consumer when updated @@ -651,11 +651,11 @@ func (m *MsgUpdateConsumer) GetOwner() string { return "" } -func (m *MsgUpdateConsumer) GetConsumerId() string { +func (m *MsgUpdateConsumer) GetConsumerId() uint64 { if m != nil { return m.ConsumerId } - return "" + return 0 } func (m *MsgUpdateConsumer) GetNewOwnerAddress() string { @@ -750,76 +750,76 @@ func init() { func init() { proto.RegisterFile("vaas/provider/v1/tx.proto", fileDescriptor_a07778b1d094765c) } var fileDescriptor_a07778b1d094765c = []byte{ - // 1100 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 0x4d, 0x8f, 0xdb, 0x44, - 0x18, 0x8e, 0xf7, 0xab, 0xed, 0xec, 0xb2, 0x65, 0xcd, 0x96, 0x4d, 0x42, 0x49, 0x5a, 0x23, 0x28, - 0x14, 0xb0, 0xd9, 0x45, 0x6a, 0xa5, 0x08, 0x21, 0xed, 0x07, 0x12, 0x11, 0x8a, 0x58, 0xb9, 0xa2, - 0x07, 0x40, 0x58, 0x63, 0x7b, 0xea, 0x8c, 0xd6, 0x9e, 0xb1, 0x3c, 0x93, 0x6c, 0xc3, 0x09, 0x71, + // 1104 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 0x4d, 0x6f, 0xdc, 0x44, + 0x18, 0x5e, 0xe7, 0xab, 0xed, 0x24, 0xa4, 0xc4, 0xa4, 0x64, 0x77, 0x29, 0xbb, 0xa9, 0x11, 0xb4, + 0x14, 0xb0, 0x49, 0x90, 0x5a, 0x29, 0x42, 0x48, 0xf9, 0x40, 0x62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xf6, 0x66, 0x22, 0x16, 0x52, 0xc2, 0x90, - 0x76, 0xa6, 0x80, 0x97, 0x7b, 0xcc, 0xbb, 0x33, 0xb0, 0x03, 0xcc, 0x53, 0x40, 0x0f, 0x33, 0x1b, - 0xf5, 0xe1, 0x10, 0xd3, 0x41, 0xa4, 0xde, 0x02, 0x97, 0x98, 0xf0, 0x72, 0x14, 0x25, 0x1c, 0xcc, - 0xe8, 0x65, 0x0c, 0x55, 0x8f, 0xc1, 0x46, 0x90, 0xcb, 0x23, 0xb8, 0x59, 0xdf, 0x7b, 0x4b, 0xc7, - 0xb6, 0xa3, 0xe7, 0x07, 0xac, 0xe7, 0x46, 0x3a, 0xdc, 0xd5, 0xf3, 0xb5, 0xcd, 0x42, 0x86, 0xf2, - 0x3c, 0x96, 0xcb, 0xf3, 0xe8, 0xbc, 0x98, 0x67, 0x60, 0xdc, 0x8a, 0x76, 0x03, 0xbc, 0x3a, 0x73, - 0x8f, 0x19, 0x1b, 0x3f, 0x2f, 0x55, 0xb0, 0x71, 0x44, 0x07, 0xb6, 0x8f, 0xee, 0x52, 0x8e, 0x89, - 0xf7, 0xcc, 0x6c, 0x58, 0x60, 0xc7, 0x1d, 0x84, 0x3e, 0x76, 0x20, 0x47, 0xd6, 0x90, 0x72, 0x64, - 0xa5, 0x32, 0x95, 0xc4, 0xdc, 0xc8, 0xf3, 0x20, 0x84, 0xac, 0x1f, 0xa5, 0x01, 0x77, 0x29, 0x47, - 0x1f, 0x48, 0xb8, 0x79, 0xc5, 0xad, 0x32, 0xab, 0x5f, 0x80, 0x1d, 0x4c, 0xee, 0x45, 0xd0, 0x89, - 0x8f, 0xa3, 0x65, 0xfb, 0xd4, 0x39, 0xb1, 0xfa, 0x08, 0xba, 0x28, 0x12, 0x44, 0xad, 0xef, 0xbd, - 0x36, 0x8f, 0xf9, 0x0f, 0x05, 0xda, 0xbc, 0x32, 0x4e, 0x73, 0x10, 0x67, 0x49, 0xcc, 0x65, 0xf2, - 0x57, 0xf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 0xbe, 0x1e, 0x46, 0x94, 0x53, 0xf5, 0xc5, + 0xd8, 0xa5, 0xa7, 0x2e, 0x7d, 0xb0, 0xd3, 0xdc, 0x80, 0x01, 0x26, 0xd4, 0x10, 0xbf, 0x09, 0xa8, + 0xb9, 0xe5, 0x50, 0x16, 0x50, 0x66, 0x04, 0xcc, 0x8b, 0x83, 0x03, 0xe6, 0x49, 0x47, 0x23, 0x71, + 0x58, 0x62, 0x65, 0x24, 0x0b, 0xe9, 0xda, 0xf4, 0xa8, 0x47, 0x13, 0x7b, 0xfc, 0x24, 0xad, 0x57, + 0x3d, 0x4a, 0x3d, 0x1f, 0x19, 0x30, 0xc4, 0x06, 0x24, 0x84, 0x72, 0xc8, 0x31, 0x25, 0x69, 0x4c, + 0x43, 0x7a, 0xc5, 0xca, 0xee, 0xdf, 0x33, 0x20, 0x19, 0x4a, 0x57, 0xab, 0xec, 0x72, 0xfb, 0x91, + 0x88, 0x95, 0xfe, 0x76, 0xd9, 0xcf, 0x71, 0x80, 0x18, 0x87, 0x41, 0x98, 0x02, 0xb0, 0xed, 0x18, + 0x0e, 0x8d, 0x90, 0xe1, 0xf8, 0x18, 0x11, 0x1e, 0x6f, 0x24, 0x79, 0x92, 0x00, 0x23, 0x06, 0xf8, + 0xd8, 0xeb, 0xf1, 0xc4, 0xcc, 0x0c, 0x8e, 0x88, 0x8b, 0xa2, 0x00, 0x27, 0xe0, 0xd1, 0x2a, 0xcd, + 0x98, 0xf3, 0xf3, 0x61, 0x88, 0x98, 0x81, 0x62, 0x12, 0x89, 0x83, 0x52, 0xc0, 0x18, 0xed, 0x19, + 0xcf, 0x02, 0xa0, 0xfd, 0xae, 0x80, 0xcd, 0x2e, 0xf3, 0xf6, 0x19, 0xc3, 0x1e, 0x39, 0xa4, 0x84, + 0xf5, 0x03, 0x14, 0x7d, 0x8c, 0x86, 0x6a, 0x1b, 0xac, 0x3a, 0x72, 0x69, 0x61, 0xb7, 0xae, 0x6c, + 0x2b, 0x37, 0x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0x97, 0x79, + 0x26, 0x0a, 0xe8, 0x00, 0xa5, 0xfb, 0x9a, 0xfd, 0xca, 0xd0, 0xc1, 0x32, 0x3d, 0x8d, 0x4f, 0xf5, + 0xc2, 0x8c, 0xcd, 0x24, 0xb0, 0x3d, 0x10, 0x37, 0x94, 0x3c, 0x6b, 0xaf, 0x80, 0xc6, 0x58, 0xc5, + 0xac, 0x9d, 0xef, 0x17, 0x45, 0x3f, 0x87, 0x11, 0x82, 0x7c, 0xd4, 0xcf, 0xb3, 0xca, 0xb5, 0x01, + 0x2e, 0x3a, 0x3d, 0x88, 0x49, 0xbc, 0x09, 0xd1, 0xa9, 0x79, 0x41, 0xac, 0x3b, 0xae, 0x7a, 0x04, + 0x2e, 0x06, 0x88, 0x43, 0x17, 0x72, 0x28, 0x95, 0xa5, 0x8d, 0x93, 0x9b, 0x9d, 0x32, 0x89, 0x94, + 0x34, 0x67, 0x91, 0x2a, 0x05, 0x0d, 0x4c, 0x30, 0xc7, 0xd0, 0xc7, 0x5f, 0x89, 0x1b, 0xc4, 0x12, + 0x13, 0x40, 0x1c, 0x45, 0x4c, 0x88, 0x6b, 0x75, 0x77, 0x77, 0x72, 0xda, 0x4e, 0x21, 0xf4, 0x38, + 0x8b, 0x34, 0xeb, 0x78, 0x82, 0x47, 0xfd, 0x1c, 0xe4, 0x84, 0x9d, 0x2f, 0xb6, 0x2c, 0x4f, 0xc7, + 0x58, 0xb1, 0x4e, 0x06, 0xcf, 0x15, 0xd8, 0xc4, 0x15, 0x56, 0x29, 0x9b, 0x91, 0xe6, 0xdf, 0x17, + 0x93, 0x2a, 0xce, 0x22, 0x9d, 0xd4, 0x4c, 0x8d, 0x68, 0x7f, 0x26, 0xa3, 0x4c, 0x54, 0x97, 0x8d, + 0x32, 0x53, 0x8e, 0x32, 0x97, 0x72, 0xca, 0x65, 0x16, 0xc6, 0xa4, 0x78, 0x04, 0x36, 0x08, 0x3a, + 0xb5, 0x04, 0xda, 0x92, 0x17, 0x55, 0x72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0xb3, 0x96, 0xf2, 0xf8, 0xac, + 0xa5, 0xfc, 0x71, 0xd6, 0x52, 0x7e, 0x38, 0x6f, 0xd5, 0x1e, 0x9f, 0xb7, 0x6a, 0xbf, 0x9d, 0xb7, + 0x6a, 0x9f, 0x19, 0x1e, 0xe6, 0xbd, 0xbe, 0xad, 0x3b, 0x34, 0x30, 0xa0, 0xef, 0x63, 0x62, 0x63, + 0xce, 0x0c, 0xf1, 0xf9, 0x7f, 0xdf, 0x28, 0xfe, 0x0b, 0x10, 0x1f, 0x58, 0xf6, 0x8a, 0xf8, 0x03, + 0xf0, 0xde, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x54, 0xa0, 0xc5, 0xf0, 0x9a, 0x0d, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1159,12 +1159,10 @@ func (m *MsgAssignConsumerKey) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x12 } - if len(m.ConsumerId) > 0 { - i -= len(m.ConsumerId) - copy(dAtA[i:], m.ConsumerId) - i = encodeVarintTx(dAtA, i, uint64(len(m.ConsumerId))) + if m.ConsumerId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.ConsumerId)) i-- - dAtA[i] = 0xa + dAtA[i] = 0x8 } return len(dAtA) - i, nil } @@ -1212,12 +1210,10 @@ func (m *MsgSubmitConsumerMisbehaviour) MarshalToSizedBuffer(dAtA []byte) (int, _ = i var l int _ = l - if len(m.ConsumerId) > 0 { - i -= len(m.ConsumerId) - copy(dAtA[i:], m.ConsumerId) - i = encodeVarintTx(dAtA, i, uint64(len(m.ConsumerId))) + if m.ConsumerId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.ConsumerId)) i-- - dAtA[i] = 0x1a + dAtA[i] = 0x18 } if m.Misbehaviour != nil { { @@ -1284,12 +1280,10 @@ func (m *MsgSubmitConsumerDoubleVoting) MarshalToSizedBuffer(dAtA []byte) (int, _ = i var l int _ = l - if len(m.ConsumerId) > 0 { - i -= len(m.ConsumerId) - copy(dAtA[i:], m.ConsumerId) - i = encodeVarintTx(dAtA, i, uint64(len(m.ConsumerId))) + if m.ConsumerId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.ConsumerId)) i-- - dAtA[i] = 0x22 + dAtA[i] = 0x20 } if m.InfractionBlockHeader != nil { { @@ -1438,12 +1432,10 @@ func (m *MsgRemoveConsumer) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x12 } - if len(m.ConsumerId) > 0 { - i -= len(m.ConsumerId) - copy(dAtA[i:], m.ConsumerId) - i = encodeVarintTx(dAtA, i, uint64(len(m.ConsumerId))) + if m.ConsumerId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.ConsumerId)) i-- - dAtA[i] = 0xa + dAtA[i] = 0x8 } return len(dAtA) - i, nil } @@ -1562,12 +1554,10 @@ func (m *MsgCreateConsumerResponse) MarshalToSizedBuffer(dAtA []byte) (int, erro _ = i var l int _ = l - if len(m.ConsumerId) > 0 { - i -= len(m.ConsumerId) - copy(dAtA[i:], m.ConsumerId) - i = encodeVarintTx(dAtA, i, uint64(len(m.ConsumerId))) + if m.ConsumerId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.ConsumerId)) i-- - dAtA[i] = 0xa + dAtA[i] = 0x8 } return len(dAtA) - i, nil } @@ -1642,12 +1632,10 @@ func (m *MsgUpdateConsumer) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x1a } - if len(m.ConsumerId) > 0 { - i -= len(m.ConsumerId) - copy(dAtA[i:], m.ConsumerId) - i = encodeVarintTx(dAtA, i, uint64(len(m.ConsumerId))) + if m.ConsumerId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.ConsumerId)) i-- - dAtA[i] = 0x12 + dAtA[i] = 0x10 } if len(m.Owner) > 0 { i -= len(m.Owner) @@ -1699,9 +1687,8 @@ func (m *MsgAssignConsumerKey) Size() (n int) { } var l int _ = l - l = len(m.ConsumerId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if m.ConsumerId != 0 { + n += 1 + sovTx(uint64(m.ConsumerId)) } l = len(m.ProviderAddr) if l > 0 { @@ -1741,9 +1728,8 @@ func (m *MsgSubmitConsumerMisbehaviour) Size() (n int) { l = m.Misbehaviour.Size() n += 1 + l + sovTx(uint64(l)) } - l = len(m.ConsumerId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if m.ConsumerId != 0 { + n += 1 + sovTx(uint64(m.ConsumerId)) } return n } @@ -1775,9 +1761,8 @@ func (m *MsgSubmitConsumerDoubleVoting) Size() (n int) { l = m.InfractionBlockHeader.Size() n += 1 + l + sovTx(uint64(l)) } - l = len(m.ConsumerId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if m.ConsumerId != 0 { + n += 1 + sovTx(uint64(m.ConsumerId)) } return n } @@ -1821,9 +1806,8 @@ func (m *MsgRemoveConsumer) Size() (n int) { } var l int _ = l - l = len(m.ConsumerId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if m.ConsumerId != 0 { + n += 1 + sovTx(uint64(m.ConsumerId)) } l = len(m.Owner) if l > 0 { @@ -1874,9 +1858,8 @@ func (m *MsgCreateConsumerResponse) Size() (n int) { } var l int _ = l - l = len(m.ConsumerId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if m.ConsumerId != 0 { + n += 1 + sovTx(uint64(m.ConsumerId)) } return n } @@ -1891,9 +1874,8 @@ func (m *MsgUpdateConsumer) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.ConsumerId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if m.ConsumerId != 0 { + n += 1 + sovTx(uint64(m.ConsumerId)) } l = len(m.NewOwnerAddress) if l > 0 { @@ -1963,10 +1945,10 @@ func (m *MsgAssignConsumerKey) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: - if wireType != 2 { + if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field ConsumerId", wireType) } - var stringLen uint64 + m.ConsumerId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -1976,24 +1958,11 @@ func (m *MsgAssignConsumerKey) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.ConsumerId |= uint64(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ConsumerId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ProviderAddr", wireType) @@ -2259,10 +2228,10 @@ func (m *MsgSubmitConsumerMisbehaviour) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 3: - if wireType != 2 { + if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field ConsumerId", wireType) } - var stringLen uint64 + m.ConsumerId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -2272,24 +2241,11 @@ func (m *MsgSubmitConsumerMisbehaviour) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.ConsumerId |= uint64(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ConsumerId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -2495,10 +2451,10 @@ func (m *MsgSubmitConsumerDoubleVoting) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 4: - if wireType != 2 { + if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field ConsumerId", wireType) } - var stringLen uint64 + m.ConsumerId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -2508,24 +2464,11 @@ func (m *MsgSubmitConsumerDoubleVoting) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.ConsumerId |= uint64(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ConsumerId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -2792,10 +2735,10 @@ func (m *MsgRemoveConsumer) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: - if wireType != 2 { + if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field ConsumerId", wireType) } - var stringLen uint64 + m.ConsumerId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -2805,24 +2748,11 @@ func (m *MsgRemoveConsumer) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.ConsumerId |= uint64(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ConsumerId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) @@ -3175,10 +3105,10 @@ func (m *MsgCreateConsumerResponse) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: - if wireType != 2 { + if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field ConsumerId", wireType) } - var stringLen uint64 + m.ConsumerId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -3188,24 +3118,11 @@ func (m *MsgCreateConsumerResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.ConsumerId |= uint64(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ConsumerId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -3289,10 +3206,10 @@ func (m *MsgUpdateConsumer) Unmarshal(dAtA []byte) error { m.Owner = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: - if wireType != 2 { + if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field ConsumerId", wireType) } - var stringLen uint64 + m.ConsumerId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -3302,24 +3219,11 @@ func (m *MsgUpdateConsumer) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.ConsumerId |= uint64(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ConsumerId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field NewOwnerAddress", wireType) diff --git a/x/vaas/types/errors.go b/x/vaas/types/errors.go index 7340c85..581e277 100644 --- a/x/vaas/types/errors.go +++ b/x/vaas/types/errors.go @@ -22,5 +22,4 @@ var ( ErrInvalidDoubleVotingEvidence = errorsmod.Register(ModuleName, 14, "invalid consumer double voting evidence") ErrStoreKeyNotFound = errorsmod.Register(ModuleName, 15, "store key not found") ErrStoreUnmarshal = errorsmod.Register(ModuleName, 16, "cannot unmarshal value from store") - ErrInvalidConsumerId = errorsmod.Register(ModuleName, 17, "invalid consumer id") ) diff --git a/x/vaas/types/shared_params.go b/x/vaas/types/shared_params.go index 57bf88e..b073de3 100644 --- a/x/vaas/types/shared_params.go +++ b/x/vaas/types/shared_params.go @@ -3,11 +3,8 @@ package types import ( "errors" fmt "fmt" - "strconv" - "strings" "time" - errorsmod "cosmossdk.io/errors" "cosmossdk.io/math" sdktypes "github.com/cosmos/cosmos-sdk/types" @@ -121,18 +118,3 @@ func CalculateTrustPeriod(unbondingPeriod time.Duration, defaultTrustPeriodFract return trustPeriod, nil } - -// ValidateConsumerId validates the provided consumer id and returns an error if it is not valid -func ValidateConsumerId(consumerId string) error { - if strings.TrimSpace(consumerId) == "" { - return errorsmod.Wrapf(ErrInvalidConsumerId, "consumer id cannot be blank") - } - - // check that `consumerId` corresponds to a `uint64` - _, err := strconv.ParseUint(consumerId, 10, 64) - if err != nil { - return errorsmod.Wrapf(ErrInvalidConsumerId, "consumer id (%s) cannot be parsed: %s", consumerId, err.Error()) - } - - return nil -} diff --git a/x/vaas/types/shared_params_test.go b/x/vaas/types/shared_params_test.go deleted file mode 100644 index 9f08dee..0000000 --- a/x/vaas/types/shared_params_test.go +++ /dev/null @@ -1,23 +0,0 @@ -package types_test - -import ( - "testing" - - "github.com/stretchr/testify/require" - - "github.com/allinbits/vaas/x/vaas/types" -) - -func TestValidateConsumerId(t *testing.T) { - // empty consumer id - require.Error(t, types.ValidateConsumerId("")) - - // not a `uint64` where `uint64` is in the range [0, 2^64) - require.Error(t, types.ValidateConsumerId("a")) - require.Error(t, types.ValidateConsumerId("-2545")) - require.Error(t, types.ValidateConsumerId("18446744073709551616")) // 2^64 - - // valid consumer id - require.NoError(t, types.ValidateConsumerId("0")) - require.NoError(t, types.ValidateConsumerId("18446744073709551615")) // 2^64 - 1 -}