From 519266ca28d49a0addf698b236a31334b03c7009 Mon Sep 17 00:00:00 2001 From: "Jorge S. Cuesta" Date: Tue, 3 Sep 2024 11:31:32 -0400 Subject: [PATCH 1/2] General enhancements and fix #1 *. Introduced several new .proto files in 'poktroll/application', 'poktroll/proof', 'poktroll/gateway', and 'poktroll/session' directories *. Updated already existent .proto files of cosmos to the files on cosmos-sdk at v0.50.7 *. Added a new environment variable to add extra params to subquery node *. Fixed an issue with pgadmin that caused default servers do not be loaded *. Added lodash and json-bigint dependencies *. Updated few dependencies to the latest version --- .dockerignore | 5 +- docker-compose.development.yml | 1 + docker/pgadmin/servers.json | 4 +- package.json | 7 +- proto/cosmos/base/v1beta1/coin.proto | 25 +- proto/cosmos/gov/v1beta1/genesis.proto | 28 +- proto/cosmos/gov/v1beta1/gov.proto | 180 ++++--- proto/cosmos/gov/v1beta1/query.proto | 44 +- proto/cosmos/gov/v1beta1/tx.proto | 109 +++-- proto/cosmos/slashing/v1beta1/query.proto | 14 +- proto/cosmos/slashing/v1beta1/slashing.proto | 57 ++- proto/cosmos/slashing/v1beta1/tx.proto | 45 +- proto/poktroll/application/event.proto | 8 +- proto/poktroll/application/genesis.proto | 3 +- .../poktroll/application/module/module.proto | 3 + proto/poktroll/application/params.proto | 6 +- proto/poktroll/application/query.proto | 3 +- proto/poktroll/application/tx.proto | 11 +- proto/poktroll/application/types.proto | 45 ++ proto/poktroll/gateway/event.proto | 13 + proto/poktroll/gateway/genesis.proto | 3 +- proto/poktroll/gateway/module/module.proto | 5 +- proto/poktroll/gateway/params.proto | 3 +- proto/poktroll/gateway/query.proto | 3 +- proto/poktroll/gateway/tx.proto | 1 + proto/poktroll/gateway/types.proto | 19 + proto/poktroll/proof/event.proto | 36 ++ proto/poktroll/proof/genesis.proto | 4 +- proto/poktroll/proof/module/module.proto | 5 +- proto/poktroll/proof/params.proto | 9 +- proto/poktroll/proof/query.proto | 16 +- proto/poktroll/proof/tx.proto | 20 +- proto/poktroll/proof/types.proto | 45 ++ proto/poktroll/service/genesis.proto | 1 + proto/poktroll/service/module/module.proto | 5 +- proto/poktroll/service/params.proto | 3 +- proto/poktroll/service/query.proto | 1 + proto/poktroll/service/relay.proto | 17 +- proto/poktroll/service/tx.proto | 7 +- proto/poktroll/session/genesis.proto | 1 + proto/poktroll/session/module/module.proto | 5 +- proto/poktroll/session/params.proto | 3 +- proto/poktroll/session/query.proto | 5 +- proto/poktroll/session/tx.proto | 3 +- proto/poktroll/session/types.proto | 44 ++ proto/poktroll/shared/genesis.proto | 1 + proto/poktroll/shared/module/module.proto | 5 +- proto/poktroll/shared/params.proto | 26 +- proto/poktroll/shared/query.proto | 3 +- proto/poktroll/shared/service.proto | 28 +- proto/poktroll/shared/supplier.proto | 24 +- proto/poktroll/shared/tx.proto | 7 +- proto/poktroll/supplier/genesis.proto | 1 + proto/poktroll/supplier/module/module.proto | 5 +- proto/poktroll/supplier/params.proto | 3 +- proto/poktroll/supplier/query.proto | 5 +- proto/poktroll/supplier/tx.proto | 18 +- proto/poktroll/tokenomics/event.proto | 33 +- proto/poktroll/tokenomics/genesis.proto | 1 + proto/poktroll/tokenomics/module/module.proto | 5 +- proto/poktroll/tokenomics/params.proto | 3 +- proto/poktroll/tokenomics/query.proto | 1 + .../tokenomics/relay_mining_difficulty.proto | 5 +- proto/poktroll/tokenomics/tx.proto | 3 +- src/mappings/bank/balanceChange.ts | 17 +- src/mappings/bank/transfer.ts | 6 +- src/mappings/constants.ts | 1 + src/mappings/primitives.ts | 173 ++++--- src/mappings/utils.ts | 105 ++-- yarn.lock | 451 ++++++++++++++---- 70 files changed, 1310 insertions(+), 495 deletions(-) create mode 100644 proto/poktroll/application/types.proto create mode 100644 proto/poktroll/gateway/event.proto create mode 100644 proto/poktroll/gateway/types.proto create mode 100644 proto/poktroll/proof/event.proto create mode 100644 proto/poktroll/proof/types.proto create mode 100644 proto/poktroll/session/types.proto create mode 100644 src/mappings/constants.ts diff --git a/.dockerignore b/.dockerignore index 8ff5155..e2af0a4 100644 --- a/.dockerignore +++ b/.dockerignore @@ -14,7 +14,10 @@ src/types project.yaml # dotenv files -.env* +.env.sample +.env.development +.env.production +.env.test # not needed docs diff --git a/docker-compose.development.yml b/docker-compose.development.yml index c74444c..203d886 100644 --- a/docker-compose.development.yml +++ b/docker-compose.development.yml @@ -74,6 +74,7 @@ services: - ./src:/app/src - ignore_types:/app/src/types command: + - ${SUBQUERY_NODE_EXTRA_PARAMS:-} - --unfinalized-blocks=true healthcheck: test: ["CMD", "curl", "-f", "http://subquery-node:3000/ready"] diff --git a/docker/pgadmin/servers.json b/docker/pgadmin/servers.json index fccc92d..dfb32f2 100644 --- a/docker/pgadmin/servers.json +++ b/docker/pgadmin/servers.json @@ -1,7 +1,7 @@ { - "DefaultServers": { + "Servers": { "1": { - "Name": "admin@local.dev", + "Name": "Pocketdex", "Group": "Localnet", "Host": "postgres", "Port": 5432, diff --git a/package.json b/package.json index 8b6efd2..2a7615c 100644 --- a/package.json +++ b/package.json @@ -69,15 +69,18 @@ "eslint-plugin-jest": "^27.2.3", "eslint-plugin-prettier": "^4.0.0", "eslint-plugin-sort-destructure-keys": "^1.4.0", + "lodash": "^4.17.21", "nodemon": "^3.1.4", "prettier": "^2.5.1", "pretty-quick": "^3.1.3", "typescript": "^5.2.2" }, "dependencies": { - "@subql/node-cosmos": "4.0.1", - "@subql/types-cosmos": "3.5.0", + "@subql/node-cosmos": "^4.1.1", + "@subql/types-cosmos": "^3.5.2", + "@types/json-bigint": "^1.0.4", "@types/node": "^22.0.0", + "json-bigint": "^1.0.0", "pino": "^7.8.0", "ts-proto": "^1.112.1", "tslib": "^2.3.1" diff --git a/proto/cosmos/base/v1beta1/coin.proto b/proto/cosmos/base/v1beta1/coin.proto index 226052e..1447d64 100644 --- a/proto/cosmos/base/v1beta1/coin.proto +++ b/proto/cosmos/base/v1beta1/coin.proto @@ -19,7 +19,7 @@ message Coin { string denom = 1; string amount = 2 [ (cosmos_proto.scalar) = "cosmos.Int", - (gogoproto.customtype) = "Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; @@ -33,16 +33,29 @@ message DecCoin { option (gogoproto.equal) = true; string denom = 1; - string amount = 2 - [(cosmos_proto.scalar) = "cosmos.Dec", (gogoproto.customtype) = "Dec", (gogoproto.nullable) = false]; + string amount = 2 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false + ]; } // IntProto defines a Protobuf wrapper around an Int object. +// Deprecated: Prefer to use math.Int directly. It supports binary Marshal and Unmarshal. message IntProto { - string int = 1 [(cosmos_proto.scalar) = "cosmos.Int", (gogoproto.customtype) = "Int", (gogoproto.nullable) = false]; + string int = 1 [ + (cosmos_proto.scalar) = "cosmos.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", + (gogoproto.nullable) = false + ]; } // DecProto defines a Protobuf wrapper around a Dec object. +// Deprecated: Prefer to use math.LegacyDec directly. It supports binary Marshal and Unmarshal. message DecProto { - string dec = 1 [(cosmos_proto.scalar) = "cosmos.Dec", (gogoproto.customtype) = "Dec", (gogoproto.nullable) = false]; -} \ No newline at end of file + string dec = 1 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false + ]; +} diff --git a/proto/cosmos/gov/v1beta1/genesis.proto b/proto/cosmos/gov/v1beta1/genesis.proto index 4dd9df6..f0c679a 100644 --- a/proto/cosmos/gov/v1beta1/genesis.proto +++ b/proto/cosmos/gov/v1beta1/genesis.proto @@ -4,23 +4,27 @@ package cosmos.gov.v1beta1; import "gogoproto/gogo.proto"; import "cosmos/gov/v1beta1/gov.proto"; +import "amino/amino.proto"; -option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types"; +option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"; // GenesisState defines the gov module's genesis state. message GenesisState { // starting_proposal_id is the ID of the starting proposal. - uint64 starting_proposal_id = 1 [(gogoproto.moretags) = "yaml:\"starting_proposal_id\""]; + uint64 starting_proposal_id = 1; // deposits defines all the deposits present at genesis. - repeated Deposit deposits = 2 [(gogoproto.castrepeated) = "Deposits", (gogoproto.nullable) = false]; + repeated Deposit deposits = 2 + [(gogoproto.castrepeated) = "Deposits", (gogoproto.nullable) = false, (amino.dont_omitempty) = true]; // votes defines all the votes present at genesis. - repeated Vote votes = 3 [(gogoproto.castrepeated) = "Votes", (gogoproto.nullable) = false]; + repeated Vote votes = 3 + [(gogoproto.castrepeated) = "Votes", (gogoproto.nullable) = false, (amino.dont_omitempty) = true]; // proposals defines all the proposals present at genesis. - repeated Proposal proposals = 4 [(gogoproto.castrepeated) = "Proposals", (gogoproto.nullable) = false]; - // params defines all the paramaters of related to deposit. - DepositParams deposit_params = 5 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"deposit_params\""]; - // params defines all the paramaters of related to voting. - VotingParams voting_params = 6 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"voting_params\""]; - // params defines all the paramaters of related to tally. - TallyParams tally_params = 7 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"tally_params\""]; -} \ No newline at end of file + repeated Proposal proposals = 4 + [(gogoproto.castrepeated) = "Proposals", (gogoproto.nullable) = false, (amino.dont_omitempty) = true]; + // deposit_params defines all the parameters related to deposit. + DepositParams deposit_params = 5 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; + // voting_params defines all the parameters related to voting. + VotingParams voting_params = 6 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; + // tally_params defines all the parameters related to tally. + TallyParams tally_params = 7 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; +} diff --git a/proto/cosmos/gov/v1beta1/gov.proto b/proto/cosmos/gov/v1beta1/gov.proto index a2df1bd..99b9719 100644 --- a/proto/cosmos/gov/v1beta1/gov.proto +++ b/proto/cosmos/gov/v1beta1/gov.proto @@ -3,15 +3,15 @@ package cosmos.gov.v1beta1; import "cosmos/base/v1beta1/coin.proto"; import "gogoproto/gogo.proto"; -import "cosmos_proto/cosmos.proto"; import "google/protobuf/timestamp.proto"; import "google/protobuf/any.proto"; import "google/protobuf/duration.proto"; +import "cosmos_proto/cosmos.proto"; +import "amino/amino.proto"; -option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types"; -option (gogoproto.goproto_stringer_all) = false; -option (gogoproto.stringer_all) = false; -option (gogoproto.goproto_getters_all) = false; +option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"; + +option (gogoproto.goproto_getters_all) = false; // VoteOption enumerates the valid vote options for a given governance proposal. enum VoteOption { @@ -33,22 +33,30 @@ enum VoteOption { // // Since: cosmos-sdk 0.43 message WeightedVoteOption { + // option defines the valid vote options, it must not contain duplicate vote options. VoteOption option = 1; - string weight = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false, - (gogoproto.moretags) = "yaml:\"weight\"" + + // weight is the vote weight associated with the vote option. + string weight = 2 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (amino.dont_omitempty) = true, + (gogoproto.nullable) = false ]; } // TextProposal defines a standard text proposal whose changes need to be // manually updated in case of approval. message TextProposal { - option (cosmos_proto.implements_interface) = "Content"; + option (cosmos_proto.implements_interface) = "cosmos.gov.v1beta1.Content"; + option (amino.name) = "cosmos-sdk/TextProposal"; option (gogoproto.equal) = true; - string title = 1; + // title of the proposal. + string title = 1; + + // description associated with the proposal. string description = 2; } @@ -58,41 +66,67 @@ message Deposit { option (gogoproto.goproto_getters) = false; option (gogoproto.equal) = false; - uint64 proposal_id = 1 [(gogoproto.moretags) = "yaml:\"proposal_id\""]; - string depositor = 2; - repeated cosmos.base.v1beta1.Coin amount = 3 - [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; + // proposal_id defines the unique id of the proposal. + uint64 proposal_id = 1; + + // depositor defines the deposit addresses from the proposals. + string depositor = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + + // amount to be deposited by depositor. + repeated cosmos.base.v1beta1.Coin amount = 3 [ + (gogoproto.nullable) = false, + (amino.dont_omitempty) = true, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; } // Proposal defines the core field members of a governance proposal. message Proposal { option (gogoproto.equal) = true; - uint64 proposal_id = 1 [(gogoproto.jsontag) = "id", (gogoproto.moretags) = "yaml:\"id\""]; - google.protobuf.Any content = 2 [(cosmos_proto.accepts_interface) = "Content"]; - ProposalStatus status = 3 [(gogoproto.moretags) = "yaml:\"proposal_status\""]; - TallyResult final_tally_result = 4 - [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"final_tally_result\""]; + // proposal_id defines the unique id of the proposal. + uint64 proposal_id = 1; + + // content is the proposal's content. + google.protobuf.Any content = 2 [(cosmos_proto.accepts_interface) = "cosmos.gov.v1beta1.Content"]; + + // status defines the proposal status. + ProposalStatus status = 3; + + // final_tally_result is the final tally result of the proposal. When + // querying a proposal via gRPC, this field is not populated until the + // proposal's voting period has ended. + TallyResult final_tally_result = 4 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; + + // submit_time is the time of proposal submission. google.protobuf.Timestamp submit_time = 5 - [(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"submit_time\""]; + [(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (amino.dont_omitempty) = true]; + + // deposit_end_time is the end time for deposition. google.protobuf.Timestamp deposit_end_time = 6 - [(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"deposit_end_time\""]; + [(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (amino.dont_omitempty) = true]; + + // total_deposit is the total deposit on the proposal. repeated cosmos.base.v1beta1.Coin total_deposit = 7 [ (gogoproto.nullable) = false, - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", - (gogoproto.moretags) = "yaml:\"total_deposit\"" + (amino.dont_omitempty) = true, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" ]; + + // voting_start_time is the starting time to vote on a proposal. google.protobuf.Timestamp voting_start_time = 8 - [(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"voting_start_time\""]; + [(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (amino.dont_omitempty) = true]; + + // voting_end_time is the end time of voting on a proposal. google.protobuf.Timestamp voting_end_time = 9 - [(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"voting_end_time\""]; + [(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (amino.dont_omitempty) = true]; } // ProposalStatus enumerates the valid statuses of a proposal. enum ProposalStatus { option (gogoproto.goproto_enum_prefix) = false; - // PROPOSAL_STATUS_UNSPECIFIED defines the default propopsal status. + // PROPOSAL_STATUS_UNSPECIFIED defines the default proposal status. PROPOSAL_STATUS_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "StatusNil"]; // PROPOSAL_STATUS_DEPOSIT_PERIOD defines a proposal status during the deposit // period. @@ -115,86 +149,106 @@ enum ProposalStatus { message TallyResult { option (gogoproto.equal) = true; - string yes = 1 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; - string abstain = 2 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; - string no = 3 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; + // yes is the number of yes votes on a proposal. + string yes = 1 [ + (cosmos_proto.scalar) = "cosmos.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", + (gogoproto.nullable) = false + ]; + + // abstain is the number of abstain votes on a proposal. + string abstain = 2 [ + (cosmos_proto.scalar) = "cosmos.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", + (gogoproto.nullable) = false + ]; + + // no is the number of no votes on a proposal. + string no = 3 [ + (cosmos_proto.scalar) = "cosmos.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", + (gogoproto.nullable) = false + ]; + + // no_with_veto is the number of no with veto votes on a proposal. string no_with_veto = 4 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false, - (gogoproto.moretags) = "yaml:\"no_with_veto\"" + (cosmos_proto.scalar) = "cosmos.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", + (gogoproto.nullable) = false ]; } // Vote defines a vote on a governance proposal. // A Vote consists of a proposal ID, the voter, and the vote option. message Vote { - option (gogoproto.goproto_stringer) = false; - option (gogoproto.equal) = false; + option (gogoproto.equal) = false; - uint64 proposal_id = 1 [(gogoproto.moretags) = "yaml:\"proposal_id\""]; - string voter = 2; + // proposal_id defines the unique id of the proposal. + uint64 proposal_id = 1 [(gogoproto.jsontag) = "id", (amino.field_name) = "id", (amino.dont_omitempty) = true]; + + // voter is the voter address of the proposal. + string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // Deprecated: Prefer to use `options` instead. This field is set in queries // if and only if `len(options) == 1` and that option has weight 1. In all // other cases, this field will default to VOTE_OPTION_UNSPECIFIED. - VoteOption option = 3 [deprecated = true]; + VoteOption option = 3 [deprecated = true]; + + // options is the weighted vote options. + // // Since: cosmos-sdk 0.43 - repeated WeightedVoteOption options = 4 [(gogoproto.nullable) = false]; + repeated WeightedVoteOption options = 4 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; } // DepositParams defines the params for deposits on governance proposals. message DepositParams { - // Minimum deposit for a proposal to enter voting period. + // Minimum deposit for a proposal to enter voting period. repeated cosmos.base.v1beta1.Coin min_deposit = 1 [ (gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", - (gogoproto.moretags) = "yaml:\"min_deposit\"", (gogoproto.jsontag) = "min_deposit,omitempty" ]; - // Maximum period for Atom holders to deposit on a proposal. Initial value: 2 - // months. + // Maximum period for Atom holders to deposit on a proposal. Initial value: 2 + // months. google.protobuf.Duration max_deposit_period = 2 [ (gogoproto.nullable) = false, (gogoproto.stdduration) = true, - (gogoproto.jsontag) = "max_deposit_period,omitempty", - (gogoproto.moretags) = "yaml:\"max_deposit_period\"" + (gogoproto.jsontag) = "max_deposit_period,omitempty" ]; } // VotingParams defines the params for voting on governance proposals. message VotingParams { - // Length of the voting period. - google.protobuf.Duration voting_period = 1 [ - (gogoproto.nullable) = false, - (gogoproto.stdduration) = true, - (gogoproto.jsontag) = "voting_period,omitempty", - (gogoproto.moretags) = "yaml:\"voting_period\"" - ]; + // Duration of the voting period. + google.protobuf.Duration voting_period = 1 + [(gogoproto.nullable) = false, (gogoproto.stdduration) = true, (gogoproto.jsontag) = "voting_period,omitempty"]; } // TallyParams defines the params for tallying votes on governance proposals. message TallyParams { - // Minimum percentage of total stake needed to vote for a result to be - // considered valid. + // Minimum percentage of total stake needed to vote for a result to be + // considered valid. bytes quorum = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false, (gogoproto.jsontag) = "quorum,omitempty" ]; - // Minimum proportion of Yes votes for proposal to pass. Default value: 0.5. + // Minimum proportion of Yes votes for proposal to pass. Default value: 0.5. bytes threshold = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false, (gogoproto.jsontag) = "threshold,omitempty" ]; - // Minimum value of Veto votes to Total votes ratio for proposal to be - // vetoed. Default value: 1/3. + // Minimum value of Veto votes to Total votes ratio for proposal to be + // vetoed. Default value: 1/3. bytes veto_threshold = 3 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false, - (gogoproto.jsontag) = "veto_threshold,omitempty", - (gogoproto.moretags) = "yaml:\"veto_threshold\"" + (gogoproto.jsontag) = "veto_threshold,omitempty" ]; -} \ No newline at end of file +} diff --git a/proto/cosmos/gov/v1beta1/query.proto b/proto/cosmos/gov/v1beta1/query.proto index 232d9e9..28352ed 100644 --- a/proto/cosmos/gov/v1beta1/query.proto +++ b/proto/cosmos/gov/v1beta1/query.proto @@ -5,8 +5,10 @@ import "cosmos/base/query/v1beta1/pagination.proto"; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; import "cosmos/gov/v1beta1/gov.proto"; +import "cosmos_proto/cosmos.proto"; +import "amino/amino.proto"; -option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types"; +option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"; // Query defines the gRPC querier service for gov module service Query { @@ -35,7 +37,7 @@ service Query { option (google.api.http).get = "/cosmos/gov/v1beta1/params/{params_type}"; } - // Deposit queries single deposit information based proposalID, depositAddr. + // Deposit queries single deposit information based on proposalID, depositor address. rpc Deposit(QueryDepositRequest) returns (QueryDepositResponse) { option (google.api.http).get = "/cosmos/gov/v1beta1/proposals/{proposal_id}/deposits/{depositor}"; } @@ -59,7 +61,7 @@ message QueryProposalRequest { // QueryProposalResponse is the response type for the Query/Proposal RPC method. message QueryProposalResponse { - Proposal proposal = 1 [(gogoproto.nullable) = false]; + Proposal proposal = 1 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; } // QueryProposalsRequest is the request type for the Query/Proposals RPC method. @@ -71,10 +73,10 @@ message QueryProposalsRequest { ProposalStatus proposal_status = 1; // voter defines the voter address for the proposals. - string voter = 2; + string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // depositor defines the deposit addresses from the proposals. - string depositor = 3; + string depositor = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // pagination defines an optional pagination for the request. cosmos.base.query.v1beta1.PageRequest pagination = 4; @@ -83,7 +85,8 @@ message QueryProposalsRequest { // QueryProposalsResponse is the response type for the Query/Proposals RPC // method. message QueryProposalsResponse { - repeated Proposal proposals = 1 [(gogoproto.nullable) = false]; + // proposals defines all the requested governance proposals. + repeated Proposal proposals = 1 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; // pagination defines the pagination in the response. cosmos.base.query.v1beta1.PageResponse pagination = 2; @@ -97,14 +100,14 @@ message QueryVoteRequest { // proposal_id defines the unique id of the proposal. uint64 proposal_id = 1; - // voter defines the oter address for the proposals. - string voter = 2; + // voter defines the voter address for the proposals. + string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; } // QueryVoteResponse is the response type for the Query/Vote RPC method. message QueryVoteResponse { - // vote defined the queried vote. - Vote vote = 1 [(gogoproto.nullable) = false]; + // vote defines the queried vote. + Vote vote = 1 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; } // QueryVotesRequest is the request type for the Query/Votes RPC method. @@ -118,8 +121,8 @@ message QueryVotesRequest { // QueryVotesResponse is the response type for the Query/Votes RPC method. message QueryVotesResponse { - // votes defined the queried votes. - repeated Vote votes = 1 [(gogoproto.nullable) = false]; + // votes defines the queried votes. + repeated Vote votes = 1 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; // pagination defines the pagination in the response. cosmos.base.query.v1beta1.PageResponse pagination = 2; @@ -135,11 +138,11 @@ message QueryParamsRequest { // QueryParamsResponse is the response type for the Query/Params RPC method. message QueryParamsResponse { // voting_params defines the parameters related to voting. - VotingParams voting_params = 1 [(gogoproto.nullable) = false]; + VotingParams voting_params = 1 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; // deposit_params defines the parameters related to deposit. - DepositParams deposit_params = 2 [(gogoproto.nullable) = false]; + DepositParams deposit_params = 2 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; // tally_params defines the parameters related to tally. - TallyParams tally_params = 3 [(gogoproto.nullable) = false]; + TallyParams tally_params = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; } // QueryDepositRequest is the request type for the Query/Deposit RPC method. @@ -151,13 +154,13 @@ message QueryDepositRequest { uint64 proposal_id = 1; // depositor defines the deposit addresses from the proposals. - string depositor = 2; + string depositor = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; } // QueryDepositResponse is the response type for the Query/Deposit RPC method. message QueryDepositResponse { // deposit defines the requested deposit. - Deposit deposit = 1 [(gogoproto.nullable) = false]; + Deposit deposit = 1 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; } // QueryDepositsRequest is the request type for the Query/Deposits RPC method. @@ -171,7 +174,8 @@ message QueryDepositsRequest { // QueryDepositsResponse is the response type for the Query/Deposits RPC method. message QueryDepositsResponse { - repeated Deposit deposits = 1 [(gogoproto.nullable) = false]; + // deposits defines the requested deposits. + repeated Deposit deposits = 1 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; // pagination defines the pagination in the response. cosmos.base.query.v1beta1.PageResponse pagination = 2; @@ -186,5 +190,5 @@ message QueryTallyResultRequest { // QueryTallyResultResponse is the response type for the Query/Tally RPC method. message QueryTallyResultResponse { // tally defines the requested tally. - TallyResult tally = 1 [(gogoproto.nullable) = false]; -} \ No newline at end of file + TallyResult tally = 1 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; +} diff --git a/proto/cosmos/gov/v1beta1/tx.proto b/proto/cosmos/gov/v1beta1/tx.proto index eb08f3c..9de763b 100644 --- a/proto/cosmos/gov/v1beta1/tx.proto +++ b/proto/cosmos/gov/v1beta1/tx.proto @@ -6,11 +6,15 @@ import "cosmos/gov/v1beta1/gov.proto"; import "cosmos_proto/cosmos.proto"; import "gogoproto/gogo.proto"; import "google/protobuf/any.proto"; +import "cosmos/msg/v1/msg.proto"; +import "amino/amino.proto"; -option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types"; +option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"; -// Msg defines the bank Msg service. +// Msg defines the gov Msg service. service Msg { + option (cosmos.msg.v1.service) = true; + // SubmitProposal defines a method to create new proposal given a content. rpc SubmitProposal(MsgSubmitProposal) returns (MsgSubmitProposalResponse); @@ -29,35 +33,49 @@ service Msg { // MsgSubmitProposal defines an sdk.Msg type that supports submitting arbitrary // proposal Content. message MsgSubmitProposal { - option (gogoproto.equal) = false; - option (gogoproto.goproto_stringer) = false; - option (gogoproto.stringer) = false; - option (gogoproto.goproto_getters) = false; + option (cosmos.msg.v1.signer) = "proposer"; + option (amino.name) = "cosmos-sdk/MsgSubmitProposal"; + + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // content is the proposal's content. + google.protobuf.Any content = 1 [(cosmos_proto.accepts_interface) = "cosmos.gov.v1beta1.Content"]; - google.protobuf.Any content = 1 [(cosmos_proto.accepts_interface) = "Content"]; + // initial_deposit is the deposit value that must be paid at proposal submission. repeated cosmos.base.v1beta1.Coin initial_deposit = 2 [ (gogoproto.nullable) = false, - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", - (gogoproto.moretags) = "yaml:\"initial_deposit\"" + (amino.dont_omitempty) = true, + (amino.encoding) = "legacy_coins", + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" ]; - string proposer = 3; + + // proposer is the account address of the proposer. + string proposer = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"]; } // MsgSubmitProposalResponse defines the Msg/SubmitProposal response type. message MsgSubmitProposalResponse { - uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (gogoproto.moretags) = "yaml:\"proposal_id\""]; + // proposal_id defines the unique id of the proposal. + uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (amino.dont_omitempty) = true]; } // MsgVote defines a message to cast a vote. message MsgVote { - option (gogoproto.equal) = false; - option (gogoproto.goproto_stringer) = false; - option (gogoproto.stringer) = false; - option (gogoproto.goproto_getters) = false; - - uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (gogoproto.moretags) = "yaml:\"proposal_id\""]; - string voter = 2; - VoteOption option = 3; + option (cosmos.msg.v1.signer) = "voter"; + option (amino.name) = "cosmos-sdk/MsgVote"; + + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // proposal_id defines the unique id of the proposal. + uint64 proposal_id = 1; + + // voter is the voter address for the proposal. + string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + + // option defines the vote option. + VoteOption option = 3; } // MsgVoteResponse defines the Msg/Vote response type. @@ -67,14 +85,20 @@ message MsgVoteResponse {} // // Since: cosmos-sdk 0.43 message MsgVoteWeighted { - option (gogoproto.equal) = false; - option (gogoproto.goproto_stringer) = false; - option (gogoproto.stringer) = false; - option (gogoproto.goproto_getters) = false; - - uint64 proposal_id = 1 [(gogoproto.moretags) = "yaml:\"proposal_id\""]; - string voter = 2; - repeated WeightedVoteOption options = 3 [(gogoproto.nullable) = false]; + option (cosmos.msg.v1.signer) = "voter"; + option (amino.name) = "cosmos-sdk/MsgVoteWeighted"; + + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // proposal_id defines the unique id of the proposal. + uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (amino.dont_omitempty) = true]; + + // voter is the voter address for the proposal. + string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + + // options defines the weighted vote options. + repeated WeightedVoteOption options = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; } // MsgVoteWeightedResponse defines the Msg/VoteWeighted response type. @@ -84,16 +108,27 @@ message MsgVoteWeightedResponse {} // MsgDeposit defines a message to submit a deposit to an existing proposal. message MsgDeposit { - option (gogoproto.equal) = false; - option (gogoproto.goproto_stringer) = false; - option (gogoproto.stringer) = false; - option (gogoproto.goproto_getters) = false; - - uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (gogoproto.moretags) = "yaml:\"proposal_id\""]; - string depositor = 2; - repeated cosmos.base.v1beta1.Coin amount = 3 - [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; + option (cosmos.msg.v1.signer) = "depositor"; + option (amino.name) = "cosmos-sdk/MsgDeposit"; + + option (gogoproto.equal) = false; + option (gogoproto.stringer) = false; + option (gogoproto.goproto_getters) = false; + + // proposal_id defines the unique id of the proposal. + uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (amino.dont_omitempty) = true]; + + // depositor defines the deposit addresses from the proposals. + string depositor = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + + // amount to be deposited by depositor. + repeated cosmos.base.v1beta1.Coin amount = 3 [ + (gogoproto.nullable) = false, + (amino.dont_omitempty) = true, + (amino.encoding) = "legacy_coins", + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; } // MsgDepositResponse defines the Msg/Deposit response type. -message MsgDepositResponse {} \ No newline at end of file +message MsgDepositResponse {} diff --git a/proto/cosmos/slashing/v1beta1/query.proto b/proto/cosmos/slashing/v1beta1/query.proto index bd1ee0c..e727970 100644 --- a/proto/cosmos/slashing/v1beta1/query.proto +++ b/proto/cosmos/slashing/v1beta1/query.proto @@ -6,6 +6,7 @@ import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; import "cosmos/slashing/v1beta1/slashing.proto"; import "cosmos_proto/cosmos.proto"; +import "amino/amino.proto"; option go_package = "github.com/cosmos/cosmos-sdk/x/slashing/types"; @@ -32,21 +33,21 @@ message QueryParamsRequest {} // QueryParamsResponse is the response type for the Query/Params RPC method message QueryParamsResponse { - Params params = 1 [(gogoproto.nullable) = false]; + Params params = 1 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; } // QuerySigningInfoRequest is the request type for the Query/SigningInfo RPC // method message QuerySigningInfoRequest { // cons_address is the address to query signing info of - string cons_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string cons_address = 1 [(cosmos_proto.scalar) = "cosmos.ConsensusAddressString"]; } // QuerySigningInfoResponse is the response type for the Query/SigningInfo RPC // method message QuerySigningInfoResponse { // val_signing_info is the signing info of requested val cons address - ValidatorSigningInfo val_signing_info = 1 [(gogoproto.nullable) = false]; + ValidatorSigningInfo val_signing_info = 1 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; } // QuerySigningInfosRequest is the request type for the Query/SigningInfos RPC @@ -59,6 +60,7 @@ message QuerySigningInfosRequest { // method message QuerySigningInfosResponse { // info is the signing info of all validators - repeated cosmos.slashing.v1beta1.ValidatorSigningInfo info = 1 [(gogoproto.nullable) = false]; - cosmos.base.query.v1beta1.PageResponse pagination = 2; -} \ No newline at end of file + repeated cosmos.slashing.v1beta1.ValidatorSigningInfo info = 1 + [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} diff --git a/proto/cosmos/slashing/v1beta1/slashing.proto b/proto/cosmos/slashing/v1beta1/slashing.proto index 081dc5a..2347f34 100644 --- a/proto/cosmos/slashing/v1beta1/slashing.proto +++ b/proto/cosmos/slashing/v1beta1/slashing.proto @@ -8,38 +8,55 @@ import "gogoproto/gogo.proto"; import "google/protobuf/duration.proto"; import "google/protobuf/timestamp.proto"; import "cosmos_proto/cosmos.proto"; +import "amino/amino.proto"; // ValidatorSigningInfo defines a validator's signing info for monitoring their // liveness activity. message ValidatorSigningInfo { - option (gogoproto.equal) = true; - option (gogoproto.goproto_stringer) = false; + option (gogoproto.equal) = true; - string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - // Height at which validator was first a candidate OR was unjailed + string address = 1 [(cosmos_proto.scalar) = "cosmos.ConsensusAddressString"]; + // Height at which validator was first a candidate OR was un-jailed int64 start_height = 2; - // Index which is incremented each time the validator was a bonded - // in a block and may have signed a precommit or not. This in conjunction with the - // `SignedBlocksWindow` param determines the index in the `MissedBlocksBitArray`. + // Index which is incremented every time a validator is bonded in a block and + // _may_ have signed a pre-commit or not. This in conjunction with the + // signed_blocks_window param determines the index in the missed block bitmap. int64 index_offset = 3; // Timestamp until which the validator is jailed due to liveness downtime. - google.protobuf.Timestamp jailed_until = 4 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; - // Whether or not a validator has been tombstoned (killed out of validator set). It is set - // once the validator commits an equivocation or for any other configured misbehiavor. + google.protobuf.Timestamp jailed_until = 4 + [(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (amino.dont_omitempty) = true]; + // Whether or not a validator has been tombstoned (killed out of validator + // set). It is set once the validator commits an equivocation or for any other + // configured misbehavior. bool tombstoned = 5; - // A counter kept to avoid unnecessary array reads. - // Note that `Sum(MissedBlocksBitArray)` always equals `MissedBlocksCounter`. + // A counter of missed (unsigned) blocks. It is used to avoid unnecessary + // reads in the missed block bitmap. int64 missed_blocks_counter = 6; } // Params represents the parameters used for by the slashing module. message Params { + option (amino.name) = "cosmos-sdk/x/slashing/Params"; + int64 signed_blocks_window = 1; - bytes min_signed_per_window = 2 - [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; - google.protobuf.Duration downtime_jail_duration = 3 [(gogoproto.nullable) = false, (gogoproto.stdduration) = true]; - bytes slash_fraction_double_sign = 4 - [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; - bytes slash_fraction_downtime = 5 - [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; -} \ No newline at end of file + bytes min_signed_per_window = 2 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false, + (amino.dont_omitempty) = true + ]; + google.protobuf.Duration downtime_jail_duration = 3 + [(gogoproto.nullable) = false, (amino.dont_omitempty) = true, (gogoproto.stdduration) = true]; + bytes slash_fraction_double_sign = 4 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false, + (amino.dont_omitempty) = true + ]; + bytes slash_fraction_downtime = 5 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false, + (amino.dont_omitempty) = true + ]; +} diff --git a/proto/cosmos/slashing/v1beta1/tx.proto b/proto/cosmos/slashing/v1beta1/tx.proto index 12595a6..2499b4f 100644 --- a/proto/cosmos/slashing/v1beta1/tx.proto +++ b/proto/cosmos/slashing/v1beta1/tx.proto @@ -5,26 +5,63 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/slashing/types"; option (gogoproto.equal_all) = true; import "gogoproto/gogo.proto"; +import "cosmos/slashing/v1beta1/slashing.proto"; import "cosmos_proto/cosmos.proto"; import "cosmos/msg/v1/msg.proto"; +import "amino/amino.proto"; // Msg defines the slashing Msg service. service Msg { + option (cosmos.msg.v1.service) = true; + // Unjail defines a method for unjailing a jailed validator, thus returning // them into the bonded validator set, so they can begin receiving provisions // and rewards again. rpc Unjail(MsgUnjail) returns (MsgUnjailResponse); + + // UpdateParams defines a governance operation for updating the x/slashing module + // parameters. The authority defaults to the x/gov module account. + // + // Since: cosmos-sdk 0.47 + rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); } // MsgUnjail defines the Msg/Unjail request type message MsgUnjail { option (cosmos.msg.v1.signer) = "validator_addr"; + option (amino.name) = "cosmos-sdk/MsgUnjail"; - option (gogoproto.goproto_getters) = false; - option (gogoproto.goproto_stringer) = true; + option (gogoproto.goproto_getters) = false; - string validator_addr = 1 [(cosmos_proto.scalar) = "cosmos.AddressString", (gogoproto.jsontag) = "address"]; + string validator_addr = 1 [ + (cosmos_proto.scalar) = "cosmos.ValidatorAddressString", + (gogoproto.jsontag) = "address", + (amino.field_name) = "address", + (amino.dont_omitempty) = true + ]; } // MsgUnjailResponse defines the Msg/Unjail response type -message MsgUnjailResponse {} \ No newline at end of file +message MsgUnjailResponse {} + +// MsgUpdateParams is the Msg/UpdateParams request type. +// +// Since: cosmos-sdk 0.47 +message MsgUpdateParams { + option (cosmos.msg.v1.signer) = "authority"; + option (amino.name) = "cosmos-sdk/x/slashing/MsgUpdateParams"; + + // authority is the address that controls the module (defaults to x/gov unless overwritten). + string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + + // params defines the x/slashing parameters to update. + // + // NOTE: All parameters must be supplied. + Params params = 2 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; +} + +// MsgUpdateParamsResponse defines the response structure for executing a +// MsgUpdateParams message. +// +// Since: cosmos-sdk 0.47 +message MsgUpdateParamsResponse {} diff --git a/proto/poktroll/application/event.proto b/proto/poktroll/application/event.proto index 16d70a7..40b2aa8 100644 --- a/proto/poktroll/application/event.proto +++ b/proto/poktroll/application/event.proto @@ -2,13 +2,15 @@ syntax = "proto3"; package poktroll.application; option go_package = "github.com/pokt-network/poktroll/x/application/types"; +option (gogoproto.stable_marshaler_all) = true; import "cosmos_proto/cosmos.proto"; +import "gogoproto/gogo.proto"; // EventRedelegation is an event emitted whenever an application changes its // delegatee gateways on chain. This is in response to both a DelegateToGateway // and UndelegateFromGateway message. message EventRedelegation { - string app_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the application, using cosmos' ScalarDescriptor to ensure deterministic encoding - string gateway_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the gateway the application has changed their delegation of, using cosmos' ScalarDescriptor to ensure deterministic encoding -} \ No newline at end of file + string app_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the application. + string gateway_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the gateway the application has changed their delegation of. +} diff --git a/proto/poktroll/application/genesis.proto b/proto/poktroll/application/genesis.proto index 98d6818..06b3905 100644 --- a/proto/poktroll/application/genesis.proto +++ b/proto/poktroll/application/genesis.proto @@ -2,12 +2,13 @@ syntax = "proto3"; package poktroll.application; option go_package = "github.com/pokt-network/poktroll/x/application/types"; +option (gogoproto.stable_marshaler_all) = true; import "amino/amino.proto"; import "gogoproto/gogo.proto"; import "poktroll/application/params.proto"; -import "poktroll/application/application.proto"; +import "poktroll/application/types.proto"; // GenesisState defines the application module's genesis state. message GenesisState { diff --git a/proto/poktroll/application/module/module.proto b/proto/poktroll/application/module/module.proto index cae4297..5e198dd 100644 --- a/proto/poktroll/application/module/module.proto +++ b/proto/poktroll/application/module/module.proto @@ -1,7 +1,10 @@ syntax = "proto3"; package poktroll.application.module; +option (gogoproto.stable_marshaler_all) = true; + import "cosmos/app/v1alpha1/module.proto"; +import "gogoproto/gogo.proto"; // Module is the config object for the module. message Module { diff --git a/proto/poktroll/application/params.proto b/proto/poktroll/application/params.proto index 42bb37d..74811d6 100644 --- a/proto/poktroll/application/params.proto +++ b/proto/poktroll/application/params.proto @@ -2,6 +2,7 @@ syntax = "proto3"; package poktroll.application; option go_package = "github.com/pokt-network/poktroll/x/application/types"; +option (gogoproto.stable_marshaler_all) = true; import "amino/amino.proto"; import "gogoproto/gogo.proto"; @@ -10,5 +11,8 @@ import "gogoproto/gogo.proto"; message Params { option (amino.name) = "poktroll/x/application/Params"; option (gogoproto.equal) = true; + // max_delegated_gateways defines the maximum number of gateways that a single + // application can delegate to. This is used to prevent performance issues + // in case the relay ring signature becomes too large. uint64 max_delegated_gateways = 1 [(gogoproto.jsontag) = "max_delegated_gateways", (gogoproto.moretags) = "yaml:\"max_delegated_gateways\""]; -} \ No newline at end of file +} diff --git a/proto/poktroll/application/query.proto b/proto/poktroll/application/query.proto index 71e0536..1625c66 100644 --- a/proto/poktroll/application/query.proto +++ b/proto/poktroll/application/query.proto @@ -2,6 +2,7 @@ syntax = "proto3"; package poktroll.application; option go_package = "github.com/pokt-network/poktroll/x/application/types"; +option (gogoproto.stable_marshaler_all) = true; import "amino/amino.proto"; import "gogoproto/gogo.proto"; @@ -10,7 +11,7 @@ import "cosmos/base/query/v1beta1/pagination.proto"; import "cosmos/base/v1beta1/coin.proto"; import "poktroll/application/params.proto"; -import "poktroll/application/application.proto"; +import "poktroll/application/types.proto"; // Query defines the gRPC querier service. diff --git a/proto/poktroll/application/tx.proto b/proto/poktroll/application/tx.proto index f76eaa8..a208d06 100644 --- a/proto/poktroll/application/tx.proto +++ b/proto/poktroll/application/tx.proto @@ -2,6 +2,7 @@ syntax = "proto3"; package poktroll.application; option go_package = "github.com/pokt-network/poktroll/x/application/types"; +option (gogoproto.stable_marshaler_all) = true; import "amino/amino.proto"; import "cosmos_proto/cosmos.proto"; @@ -49,7 +50,7 @@ message MsgUpdateParamsResponse {} message MsgStakeApplication { option (cosmos.msg.v1.signer) = "address"; - string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the application using cosmos' ScalarDescriptor to ensure deterministic encoding + string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the application. cosmos.base.v1beta1.Coin stake = 2; // The total amount of uPOKT the application has staked. Must be ≥ to the current amount that the application has staked (if any) repeated poktroll.shared.ApplicationServiceConfig services = 3; // The list of services this application is staked to request service for } @@ -65,8 +66,8 @@ message MsgUnstakeApplicationResponse {} message MsgDelegateToGateway { option (cosmos.msg.v1.signer) = "app_address"; // https://docs.cosmos.network/main/build/building-modules/messages-and-queries - string app_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the application using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding - string gateway_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the gateway the application wants to delegate to using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding + string app_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the application. + string gateway_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the gateway the application wants to delegate to. } @@ -74,8 +75,8 @@ message MsgDelegateToGatewayResponse {} message MsgUndelegateFromGateway { option (cosmos.msg.v1.signer) = "app_address"; // https://docs.cosmos.network/main/build/building-modules/messages-and-queries - string app_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the application using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding - string gateway_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the gateway the application wants to undelegate from using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding + string app_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the application. + string gateway_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the gateway the application wants to undelegate from. } message MsgUndelegateFromGatewayResponse {} diff --git a/proto/poktroll/application/types.proto b/proto/poktroll/application/types.proto new file mode 100644 index 0000000..187e661 --- /dev/null +++ b/proto/poktroll/application/types.proto @@ -0,0 +1,45 @@ +// TODO_AUTOMATE: Add a CI workflow which detects .proto files with incompatible names (i.e. same as the package). +// NB: This file CANNOT be named "application.proto" due to an as of yet unidentified +// issue in how cosmos-proto generates the pulsar plugin output go source code. + +syntax = "proto3"; +package poktroll.application; + +option go_package = "github.com/pokt-network/poktroll/x/application/types"; +option (gogoproto.stable_marshaler_all) = true; + +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; +import "cosmos_proto/cosmos.proto"; + +import "poktroll/shared/service.proto"; + +// Application defines the type used to store an on-chain definition and state for an application +message Application { + string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the application. + cosmos.base.v1beta1.Coin stake = 2; // The total amount of uPOKT the application has staked + // TODO_BETA(@red-0ne, @olshansk): Limit this to one service_config. + // Remove `repeated`, drop the `s` from service_configs and document why + // this is the case in the app config (and here) per this discussion: + // https://github.com/pokt-network/poktroll/pull/750#discussion_r1735025033 + repeated poktroll.shared.ApplicationServiceConfig service_configs = 3; // The list of services this appliccation is configured to request service for + // TODO_BETA: Rename `delegatee_gateway_addresses` to `gateway_addresses_delegated_to`. + // Ensure to rename all relevant configs, comments, variables, function names, etc as well. + repeated string delegatee_gateway_addresses = 4 [(cosmos_proto.scalar) = "cosmos.AddressString", (gogoproto.nullable) = false]; // The Bech32 encoded addresses for all delegatee Gateways, in a non-nullable slice + // A map from sessionEndHeights to a list of Gateways. + // The key is the height of the last block of the session during which the + // respective undelegation was committed. + // The value is a list of gateways being undelegated from. + // TODO_DOCUMENT(@red-0ne): Need to document the flow from this comment + // so its clear to everyone why this is necessary; https://github.com/pokt-network/poktroll/issues/476#issuecomment-2052639906. + map pending_undelegations = 5 [(gogoproto.nullable) = false]; + // The end height of the session at which an application initiated its unstaking process. + // If the application did not unstake, this value will be 0. + uint64 unstake_session_end_height = 6; +} + +// UndelegatingGatewayList is used as the Value of `pending_undelegations`. +// It is required to store a repeated list of strings as a map value. +message UndelegatingGatewayList { + repeated string gateway_addresses = 2 [(cosmos_proto.scalar) = "cosmos.AddressString", (gogoproto.nullable) = false]; +} diff --git a/proto/poktroll/gateway/event.proto b/proto/poktroll/gateway/event.proto new file mode 100644 index 0000000..61789a5 --- /dev/null +++ b/proto/poktroll/gateway/event.proto @@ -0,0 +1,13 @@ +syntax = "proto3"; +package poktroll.gateway; + +option go_package = "github.com/pokt-network/poktroll/x/gateway/types"; +option (gogoproto.stable_marshaler_all) = true; + +import "cosmos_proto/cosmos.proto"; +import "gogoproto/gogo.proto"; + +// GatewayStaked defines the event emitted when a gateway has been unstaked. +message EventGatewayUnstaked { + string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the gateway the application has changed their delegation of. +} diff --git a/proto/poktroll/gateway/genesis.proto b/proto/poktroll/gateway/genesis.proto index f315878..62611af 100644 --- a/proto/poktroll/gateway/genesis.proto +++ b/proto/poktroll/gateway/genesis.proto @@ -2,12 +2,13 @@ syntax = "proto3"; package poktroll.gateway; option go_package = "github.com/pokt-network/poktroll/x/gateway/types"; +option (gogoproto.stable_marshaler_all) = true; import "amino/amino.proto"; import "gogoproto/gogo.proto"; import "poktroll/gateway/params.proto"; -import "poktroll/gateway/gateway.proto"; +import "poktroll/gateway/types.proto"; // GenesisState defines the gateway module's genesis state. message GenesisState { diff --git a/proto/poktroll/gateway/module/module.proto b/proto/poktroll/gateway/module/module.proto index a60bd4c..f7276a6 100644 --- a/proto/poktroll/gateway/module/module.proto +++ b/proto/poktroll/gateway/module/module.proto @@ -1,7 +1,10 @@ syntax = "proto3"; package poktroll.gateway.module; +option (gogoproto.stable_marshaler_all) = true; + import "cosmos/app/v1alpha1/module.proto"; +import "gogoproto/gogo.proto"; // Module is the config object for the module. message Module { @@ -11,4 +14,4 @@ message Module { // authority defines the custom module authority. If not set, defaults to the governance module. string authority = 1; -} \ No newline at end of file +} diff --git a/proto/poktroll/gateway/params.proto b/proto/poktroll/gateway/params.proto index 8ec48a4..4b1671a 100644 --- a/proto/poktroll/gateway/params.proto +++ b/proto/poktroll/gateway/params.proto @@ -2,6 +2,7 @@ syntax = "proto3"; package poktroll.gateway; option go_package = "github.com/pokt-network/poktroll/x/gateway/types"; +option (gogoproto.stable_marshaler_all) = true; import "amino/amino.proto"; import "gogoproto/gogo.proto"; @@ -10,4 +11,4 @@ import "gogoproto/gogo.proto"; message Params { option (amino.name) = "poktroll/x/gateway/Params"; option (gogoproto.equal) = true; -} \ No newline at end of file +} diff --git a/proto/poktroll/gateway/query.proto b/proto/poktroll/gateway/query.proto index 100070c..dd276cc 100644 --- a/proto/poktroll/gateway/query.proto +++ b/proto/poktroll/gateway/query.proto @@ -2,6 +2,7 @@ syntax = "proto3"; package poktroll.gateway; option go_package = "github.com/pokt-network/poktroll/x/gateway/types"; +option (gogoproto.stable_marshaler_all) = true; import "amino/amino.proto"; import "cosmos_proto/cosmos.proto"; @@ -11,7 +12,7 @@ import "cosmos/base/query/v1beta1/pagination.proto"; import "cosmos/base/v1beta1/coin.proto"; import "poktroll/gateway/params.proto"; -import "poktroll/gateway/gateway.proto"; +import "poktroll/gateway/types.proto"; // Query defines the gRPC querier service. service Query { diff --git a/proto/poktroll/gateway/tx.proto b/proto/poktroll/gateway/tx.proto index 194a9d2..922659e 100644 --- a/proto/poktroll/gateway/tx.proto +++ b/proto/poktroll/gateway/tx.proto @@ -2,6 +2,7 @@ syntax = "proto3"; package poktroll.gateway; option go_package = "github.com/pokt-network/poktroll/x/gateway/types"; +option (gogoproto.stable_marshaler_all) = true; import "amino/amino.proto"; import "cosmos/msg/v1/msg.proto"; diff --git a/proto/poktroll/gateway/types.proto b/proto/poktroll/gateway/types.proto new file mode 100644 index 0000000..94f2ab2 --- /dev/null +++ b/proto/poktroll/gateway/types.proto @@ -0,0 +1,19 @@ +// TODO_AUTOMATE: Add a CI workflow which detects .proto files with incompatible names (i.e. same as the package). +// NB: This file CANNOT be named "application.proto" due to an as of yet unidentified +// issue in how cosmos-proto generates the pulsar plugin output go source code. + +syntax = "proto3"; +package poktroll.gateway; + +option go_package = "github.com/pokt-network/poktroll/x/gateway/types"; +option (gogoproto.stable_marshaler_all) = true; + +import "cosmos_proto/cosmos.proto"; +import "cosmos/base/v1beta1/coin.proto"; +import "gogoproto/gogo.proto"; + +message Gateway { + string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the gateway + cosmos.base.v1beta1.Coin stake = 2; // The total amount of uPOKT the gateway has staked +} + diff --git a/proto/poktroll/proof/event.proto b/proto/poktroll/proof/event.proto new file mode 100644 index 0000000..c1a53ce --- /dev/null +++ b/proto/poktroll/proof/event.proto @@ -0,0 +1,36 @@ +syntax = "proto3"; +package poktroll.proof; + +option go_package = "github.com/pokt-network/poktroll/x/proof/types"; +option (gogoproto.stable_marshaler_all) = true; + +import "gogoproto/gogo.proto"; +import "poktroll/proof/types.proto"; + +message EventClaimCreated { + poktroll.proof.Claim claim = 1 [(gogoproto.jsontag) = "claim"]; + uint64 num_relays = 2 [(gogoproto.jsontag) = "num_relays"]; + uint64 num_compute_units = 3 [(gogoproto.jsontag) = "num_compute_units"]; +} + +// TODO_TEST: Add coverage for claim updates. +message EventClaimUpdated { + poktroll.proof.Claim claim = 1 [(gogoproto.jsontag) = "claim"]; + uint64 num_relays = 2 [(gogoproto.jsontag) = "num_relays"]; + uint64 num_compute_units = 3 [(gogoproto.jsontag) = "num_compute_units"]; +} + +message EventProofSubmitted { + poktroll.proof.Claim claim = 1 [(gogoproto.jsontag) = "claim"]; + poktroll.proof.Proof proof = 2 [(gogoproto.jsontag) = "proof"]; + uint64 num_relays = 3 [(gogoproto.jsontag) = "num_relays"]; + uint64 num_compute_units = 4 [(gogoproto.jsontag) = "num_compute_units"]; +} + +// TODO_TEST: Add coverage for proof updates. +message EventProofUpdated { + poktroll.proof.Claim claim = 1 [(gogoproto.jsontag) = "claim"]; + poktroll.proof.Proof proof = 2 [(gogoproto.jsontag) = "proof"]; + uint64 num_relays = 3 [(gogoproto.jsontag) = "num_relays"]; + uint64 num_compute_units = 4 [(gogoproto.jsontag) = "num_compute_units"]; +} diff --git a/proto/poktroll/proof/genesis.proto b/proto/poktroll/proof/genesis.proto index bc5dd15..6428c37 100644 --- a/proto/poktroll/proof/genesis.proto +++ b/proto/poktroll/proof/genesis.proto @@ -2,13 +2,13 @@ syntax = "proto3"; package poktroll.proof; option go_package = "github.com/pokt-network/poktroll/x/proof/types"; +option (gogoproto.stable_marshaler_all) = true; import "amino/amino.proto"; import "gogoproto/gogo.proto"; import "poktroll/proof/params.proto"; -import "poktroll/proof/claim.proto"; -import "poktroll/proof/proof.proto"; +import "poktroll/proof/types.proto"; // GenesisState defines the proof module's genesis state. message GenesisState { diff --git a/proto/poktroll/proof/module/module.proto b/proto/poktroll/proof/module/module.proto index dea1c09..e282f2b 100644 --- a/proto/poktroll/proof/module/module.proto +++ b/proto/poktroll/proof/module/module.proto @@ -1,7 +1,10 @@ syntax = "proto3"; package poktroll.proof.module; +option (gogoproto.stable_marshaler_all) = true; + import "cosmos/app/v1alpha1/module.proto"; +import "gogoproto/gogo.proto"; // Module is the config object for the module. message Module { @@ -11,4 +14,4 @@ message Module { // authority defines the custom module authority. If not set, defaults to the governance module. string authority = 1; -} \ No newline at end of file +} diff --git a/proto/poktroll/proof/params.proto b/proto/poktroll/proof/params.proto index 0183990..cd02b63 100644 --- a/proto/poktroll/proof/params.proto +++ b/proto/poktroll/proof/params.proto @@ -2,6 +2,7 @@ syntax = "proto3"; package poktroll.proof; option go_package = "github.com/pokt-network/poktroll/x/proof/types"; +option (gogoproto.stable_marshaler_all) = true; import "amino/amino.proto"; import "gogoproto/gogo.proto"; @@ -12,9 +13,9 @@ message Params { option (amino.name) = "poktroll/x/proof/Params"; option (gogoproto.equal) = true; - // min_relay_difficulty_bits is the minimum difficulty in bits for a relay to - // be included in a Merkle proof. - uint64 min_relay_difficulty_bits = 1 [(gogoproto.jsontag) = "min_relay_difficulty_bits"]; + // TODO_FOLLOWUP(@olshansk, #690): Either delete this or change it to be named "minimum" + // relay_difficulty_target_hash is the maximum value a relay hash must be less than to be volume/reward applicable. + bytes relay_difficulty_target_hash = 1 [(gogoproto.jsontag) = "relay_difficulty_target_hash"]; // proof_request_probability is the probability of a session requiring a proof // if it's cost (i.e. compute unit consumption) is below the ProofRequirementThreshold. @@ -36,4 +37,4 @@ message Params { // IMPORTANT: Make sure to update all related files if you're modifying or adding a new parameter. // Try the following grep to find all related places: `grep -r compute_units_to_tokens_multiplier` // TODO_IMPROVE: Look into an opportunity to use an enum to avoid using strings throughout the codebase. -} \ No newline at end of file +} diff --git a/proto/poktroll/proof/query.proto b/proto/poktroll/proof/query.proto index 9e57951..8074ce0 100644 --- a/proto/poktroll/proof/query.proto +++ b/proto/poktroll/proof/query.proto @@ -2,6 +2,7 @@ syntax = "proto3"; package poktroll.proof; option go_package = "github.com/pokt-network/poktroll/x/proof/types"; +option (gogoproto.stable_marshaler_all) = true; import "amino/amino.proto"; import "gogoproto/gogo.proto"; @@ -10,8 +11,7 @@ import "cosmos_proto/cosmos.proto"; import "cosmos/base/query/v1beta1/pagination.proto"; import "poktroll/proof/params.proto"; -import "poktroll/proof/claim.proto"; -import "poktroll/proof/proof.proto"; +import "poktroll/proof/types.proto"; // Query defines the gRPC querier service. service Query { @@ -24,7 +24,7 @@ service Query { // Queries a list of Claim items. rpc Claim (QueryGetClaimRequest ) returns (QueryGetClaimResponse ) { - option (google.api.http).get = "/pokt-network/poktroll/proof/claim/{session_id}/{supplier_address}"; + option (google.api.http).get = "/pokt-network/poktroll/proof/claim/{session_id}/{supplier_operator_address}"; } rpc AllClaims (QueryAllClaimsRequest) returns (QueryAllClaimsResponse) { @@ -34,7 +34,7 @@ service Query { // Queries a list of Proof items. rpc Proof (QueryGetProofRequest) returns (QueryGetProofResponse) { - option (google.api.http).get = "/pokt-network/poktroll/proof/proof/{session_id}/{supplier_address}"; + option (google.api.http).get = "/pokt-network/poktroll/proof/proof/{session_id}/{supplier_operator_address}"; } rpc AllProofs (QueryAllProofsRequest) returns (QueryAllProofsResponse) { @@ -53,7 +53,7 @@ message QueryParamsResponse { message QueryGetClaimRequest { string session_id = 1; - string supplier_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string supplier_operator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; } message QueryGetClaimResponse { @@ -64,7 +64,7 @@ message QueryAllClaimsRequest { cosmos.base.query.v1beta1.PageRequest pagination = 1; oneof filter { - string supplier_address= 2; + string supplier_operator_address= 2; string session_id = 3; uint64 session_end_height = 4; } @@ -77,7 +77,7 @@ message QueryAllClaimsResponse { message QueryGetProofRequest { string session_id = 1; - string supplier_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string supplier_operator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; } message QueryGetProofResponse { @@ -88,7 +88,7 @@ message QueryAllProofsRequest { cosmos.base.query.v1beta1.PageRequest pagination = 1; oneof filter { - string supplier_address = 2; + string supplier_operator_address = 2; string session_id = 3; uint64 session_end_height = 4; } diff --git a/proto/poktroll/proof/tx.proto b/proto/poktroll/proof/tx.proto index 0cb5ddb..6ac2a59 100644 --- a/proto/poktroll/proof/tx.proto +++ b/proto/poktroll/proof/tx.proto @@ -3,6 +3,7 @@ syntax = "proto3"; package poktroll.proof; option go_package = "github.com/pokt-network/poktroll/x/proof/types"; +option (gogoproto.stable_marshaler_all) = true; import "amino/amino.proto"; import "cosmos/base/v1beta1/coin.proto"; @@ -10,7 +11,8 @@ import "cosmos/msg/v1/msg.proto"; import "cosmos_proto/cosmos.proto"; import "gogoproto/gogo.proto"; import "poktroll/proof/params.proto"; -import "poktroll/session/session.proto"; +import "poktroll/proof/types.proto"; +import "poktroll/session/types.proto"; import "poktroll/shared/service.proto"; // Msg defines the Msg service. @@ -72,23 +74,27 @@ message MsgUpdateParamResponse { } message MsgCreateClaim { - option (cosmos.msg.v1.signer) = "supplier_address"; - string supplier_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + option (cosmos.msg.v1.signer) = "supplier_operator_address"; + string supplier_operator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; poktroll.session.SessionHeader session_header = 2; // root returned from smt.SMST#Root() bytes root_hash = 3; } -message MsgCreateClaimResponse {} +message MsgCreateClaimResponse { + poktroll.proof.Claim claim = 1; +} message MsgSubmitProof { - option (cosmos.msg.v1.signer) = "supplier_address"; - string supplier_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + option (cosmos.msg.v1.signer) = "supplier_operator_address"; + string supplier_operator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; poktroll.session.SessionHeader session_header = 2; // serialized version of *smt.SparseMerkleClosestProof bytes proof = 3; } -message MsgSubmitProofResponse {} \ No newline at end of file +message MsgSubmitProofResponse { + poktroll.proof.Proof proof = 1; +} diff --git a/proto/poktroll/proof/types.proto b/proto/poktroll/proof/types.proto new file mode 100644 index 0000000..f968e4c --- /dev/null +++ b/proto/poktroll/proof/types.proto @@ -0,0 +1,45 @@ +// TODO_AUTOMATE: Add a CI workflow which detects .proto files with incompatible names (i.e. same as the package). +// NB: This file CANNOT be named "application.proto" due to an as of yet unidentified +// issue in how cosmos-proto generates the pulsar plugin output go source code. + +syntax = "proto3"; +package poktroll.proof; + +option go_package = "github.com/pokt-network/poktroll/x/proof/types"; +option (gogoproto.stable_marshaler_all) = true; + +import "cosmos_proto/cosmos.proto"; + +import "poktroll/session/types.proto"; +import "gogoproto/gogo.proto"; + +message Proof { + // Address of the supplier's operator that submitted this proof. + string supplier_operator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // The session header of the session that this claim is for. + poktroll.session.SessionHeader session_header = 2; + // The serialized SMST proof from the `#ClosestProof()` method. + bytes closest_merkle_proof = 3; +} + +// Claim is the serialized object stored on-chain for claims pending to be proven +message Claim { + string supplier_operator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // the address of the supplier's operator that submitted this claim + // The session header of the session that this claim is for. + poktroll.session.SessionHeader session_header = 2; + // Root hash returned from smt.SMST#Root(). + bytes root_hash = 3; +} + +enum ProofRequirementReason { + NOT_REQUIRED = 0; + PROBABILISTIC = 1; + THRESHOLD = 2; +} + +enum ClaimProofStage { + CLAIMED = 0; + PROVEN = 1; + SETTLED = 2; + EXPIRED = 3; +} diff --git a/proto/poktroll/service/genesis.proto b/proto/poktroll/service/genesis.proto index 698660b..e8f5053 100644 --- a/proto/poktroll/service/genesis.proto +++ b/proto/poktroll/service/genesis.proto @@ -2,6 +2,7 @@ syntax = "proto3"; package poktroll.service; option go_package = "github.com/pokt-network/poktroll/x/service/types"; +option (gogoproto.stable_marshaler_all) = true; import "amino/amino.proto"; import "gogoproto/gogo.proto"; diff --git a/proto/poktroll/service/module/module.proto b/proto/poktroll/service/module/module.proto index d057936..3359601 100644 --- a/proto/poktroll/service/module/module.proto +++ b/proto/poktroll/service/module/module.proto @@ -1,7 +1,10 @@ syntax = "proto3"; package poktroll.service.module; +option (gogoproto.stable_marshaler_all) = true; + import "cosmos/app/v1alpha1/module.proto"; +import "gogoproto/gogo.proto"; // Module is the config object for the module. message Module { @@ -11,4 +14,4 @@ message Module { // authority defines the custom module authority. If not set, defaults to the governance module. string authority = 1; -} \ No newline at end of file +} diff --git a/proto/poktroll/service/params.proto b/proto/poktroll/service/params.proto index 111ee5c..8778822 100644 --- a/proto/poktroll/service/params.proto +++ b/proto/poktroll/service/params.proto @@ -2,6 +2,7 @@ syntax = "proto3"; package poktroll.service; option go_package = "github.com/pokt-network/poktroll/x/service/types"; +option (gogoproto.stable_marshaler_all) = true; import "amino/amino.proto"; import "gogoproto/gogo.proto"; @@ -16,4 +17,4 @@ message Params { // This will be deducted from the signer's account balance, // and transferred to the pocket network foundation. uint64 add_service_fee = 1 [(gogoproto.jsontag) = "add_service_fee", (gogoproto.moretags) = "yaml:\"add_service_fee\""]; -} \ No newline at end of file +} diff --git a/proto/poktroll/service/query.proto b/proto/poktroll/service/query.proto index 6b60c1d..4b49a3e 100644 --- a/proto/poktroll/service/query.proto +++ b/proto/poktroll/service/query.proto @@ -2,6 +2,7 @@ syntax = "proto3"; package poktroll.service; option go_package = "github.com/pokt-network/poktroll/x/service/types"; +option (gogoproto.stable_marshaler_all) = true; import "amino/amino.proto"; import "gogoproto/gogo.proto"; diff --git a/proto/poktroll/service/relay.proto b/proto/poktroll/service/relay.proto index cffd71a..c840c33 100644 --- a/proto/poktroll/service/relay.proto +++ b/proto/poktroll/service/relay.proto @@ -2,11 +2,12 @@ syntax = "proto3"; package poktroll.service; option go_package = "github.com/pokt-network/poktroll/x/service/types"; +option (gogoproto.stable_marshaler_all) = true; import "cosmos_proto/cosmos.proto"; import "gogoproto/gogo.proto"; -import "poktroll/session/session.proto"; +import "poktroll/session/types.proto"; // Relay contains both the RelayRequest (signed by the Application) and the RelayResponse (signed by the Supplier). // The serialized tuple is inserted into the SMST leaves as values in the Claim/Proof lifecycle. @@ -24,12 +25,12 @@ message RelayRequestMetadata { // application in both cases. bytes signature = 2; - // TODO_MAINNET: make sure we're checking/verifying this address on-chain (if needed). + // TODO_MAINNET: make sure we're checking/verifying this address on-chain (if needed). // Relevant conversation: https://github.com/pokt-network/poktroll/pull/567#discussion_r1628722168 - // - // The supplier address the relay is sent to. It is being used on the RelayMiner to - // route to the correct supplier. - string supplier_address = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the application, using cosmos' ScalarDescriptor to ensure deterministic encoding + // + // The supplier operator address the relay is sent to. It is being used on the + // RelayMiner to route to the correct supplier. + string supplier_operator_address = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the application. } // RelayRequest holds the request details for a relay. @@ -46,12 +47,12 @@ message RelayResponse { RelayResponseMetadata meta = 1 [(gogoproto.nullable) = false]; // payload is the serialized payload for the response. // The payload is passed directly from the service and as such can be any - // format the the service responds with: JSON-RPC, REST, gRPC, etc. + // format the service responds with: JSON-RPC, REST, gRPC, etc. bytes payload = 2; } // RelayResponseMetadata contains the metadata for a RelayResponse. message RelayResponseMetadata { session.SessionHeader session_header = 1; // Session header associated with the relay. - bytes supplier_signature = 2; // Signature of the supplier on the response. + bytes supplier_operator_signature = 2; // Signature of the supplier's operator on the response. } diff --git a/proto/poktroll/service/tx.proto b/proto/poktroll/service/tx.proto index 2cd44a2..b2f0b27 100644 --- a/proto/poktroll/service/tx.proto +++ b/proto/poktroll/service/tx.proto @@ -2,6 +2,7 @@ syntax = "proto3"; package poktroll.service; option go_package = "github.com/pokt-network/poktroll/x/service/types"; +option (gogoproto.stable_marshaler_all) = true; import "amino/amino.proto"; import "cosmos/msg/v1/msg.proto"; @@ -44,9 +45,9 @@ message MsgUpdateParamsResponse {} // permissionless. // TODO_BETA: Add Champions / Sources once its fully defined. message MsgAddService { - option (cosmos.msg.v1.signer) = "address"; // https://docs.cosmos.network/main/build/building-modules/messages-and-queries - string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the service supplier using cosmos' ScalarDescriptor - poktroll.shared.Service service = 2 [(gogoproto.nullable) = false]; // The Service for which the supplier is adding to the network + option (cosmos.msg.v1.signer) = "owner_address"; // https://docs.cosmos.network/main/build/building-modules/messages-and-queries + string owner_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the service owner. + poktroll.shared.Service service = 2 [(gogoproto.nullable) = false]; // The Service being added to the network } message MsgAddServiceResponse {} diff --git a/proto/poktroll/session/genesis.proto b/proto/poktroll/session/genesis.proto index 263c0d0..bff591f 100644 --- a/proto/poktroll/session/genesis.proto +++ b/proto/poktroll/session/genesis.proto @@ -2,6 +2,7 @@ syntax = "proto3"; package poktroll.session; option go_package = "github.com/pokt-network/poktroll/x/session/types"; +option (gogoproto.stable_marshaler_all) = true; import "amino/amino.proto"; import "gogoproto/gogo.proto"; diff --git a/proto/poktroll/session/module/module.proto b/proto/poktroll/session/module/module.proto index b3c5e43..aa904a7 100644 --- a/proto/poktroll/session/module/module.proto +++ b/proto/poktroll/session/module/module.proto @@ -1,7 +1,10 @@ syntax = "proto3"; package poktroll.session.module; +option (gogoproto.stable_marshaler_all) = true; + import "cosmos/app/v1alpha1/module.proto"; +import "gogoproto/gogo.proto"; // Module is the config object for the module. message Module { @@ -11,4 +14,4 @@ message Module { // authority defines the custom module authority. If not set, defaults to the governance module. string authority = 1; -} \ No newline at end of file +} diff --git a/proto/poktroll/session/params.proto b/proto/poktroll/session/params.proto index cbe3559..342e64f 100644 --- a/proto/poktroll/session/params.proto +++ b/proto/poktroll/session/params.proto @@ -2,6 +2,7 @@ syntax = "proto3"; package poktroll.session; option go_package = "github.com/pokt-network/poktroll/x/session/types"; +option (gogoproto.stable_marshaler_all) = true; import "amino/amino.proto"; import "gogoproto/gogo.proto"; @@ -10,4 +11,4 @@ import "gogoproto/gogo.proto"; message Params { option (amino.name) = "poktroll/x/session/Params"; option (gogoproto.equal) = true; -} \ No newline at end of file +} diff --git a/proto/poktroll/session/query.proto b/proto/poktroll/session/query.proto index f695a5f..09a4795 100644 --- a/proto/poktroll/session/query.proto +++ b/proto/poktroll/session/query.proto @@ -2,6 +2,7 @@ syntax = "proto3"; package poktroll.session; option go_package = "github.com/pokt-network/poktroll/x/session/types"; +option (gogoproto.stable_marshaler_all) = true; import "amino/amino.proto"; import "gogoproto/gogo.proto"; @@ -9,7 +10,7 @@ import "google/api/annotations.proto"; import "cosmos_proto/cosmos.proto"; import "poktroll/session/params.proto"; -import "poktroll/session/session.proto"; +import "poktroll/session/types.proto"; import "poktroll/shared/service.proto"; // Query defines the gRPC querier service. @@ -36,7 +37,7 @@ message QueryParamsResponse { } message QueryGetSessionRequest { - string application_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the application using cosmos' ScalarDescriptor to ensure deterministic encoding + string application_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the application. poktroll.shared.Service service = 2; // The service to query the session for int64 block_height = 3; // The block height to query the session for } diff --git a/proto/poktroll/session/tx.proto b/proto/poktroll/session/tx.proto index c043440..6e72f8d 100644 --- a/proto/poktroll/session/tx.proto +++ b/proto/poktroll/session/tx.proto @@ -2,6 +2,7 @@ syntax = "proto3"; package poktroll.session; option go_package = "github.com/pokt-network/poktroll/x/session/types"; +option (gogoproto.stable_marshaler_all) = true; import "amino/amino.proto"; import "cosmos/msg/v1/msg.proto"; @@ -38,4 +39,4 @@ message MsgUpdateParams { // MsgUpdateParamsResponse defines the response structure for executing a // MsgUpdateParams message. -message MsgUpdateParamsResponse {} \ No newline at end of file +message MsgUpdateParamsResponse {} diff --git a/proto/poktroll/session/types.proto b/proto/poktroll/session/types.proto new file mode 100644 index 0000000..1c205ec --- /dev/null +++ b/proto/poktroll/session/types.proto @@ -0,0 +1,44 @@ +// TODO_AUTOMATE: Add a CI workflow which detects .proto files with incompatible names (i.e. same as the package). +// NB: This file CANNOT be named "application.proto" due to an as of yet unidentified +// issue in how cosmos-proto generates the pulsar plugin output go source code. + +syntax = "proto3"; +package poktroll.session; + +option go_package = "github.com/pokt-network/poktroll/x/session/types"; +option (gogoproto.stable_marshaler_all) = true; + +import "cosmos_proto/cosmos.proto"; + +import "poktroll/shared/service.proto"; +import "poktroll/application/types.proto"; +import "poktroll/shared/supplier.proto"; +import "gogoproto/gogo.proto"; + +// NOTE: Using signed integers for consistency with the cosmos SDK + +// SessionHeader is a lightweight header for a session that can be passed around. +// It is the minimal amount of data required to hydrate & retrieve all data relevant to the session. +message SessionHeader { + string application_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the application. + poktroll.shared.Service service = 2; // The service this session is for + // NOTE: session_id can be derived from the above values using on-chain but is included in the header for convenience + string session_id = 3; // A unique pseudoranom ID for this session + int64 session_start_block_height = 4; // The height at which this session started + // Note that`session_end_block_height` is a derivative of (`start` + `num_blocks_per_session`) + // as goverened by on-chain params at the time of the session start. + // It is stored as an additional field to simplofy business logic in case + // the number of blocks_per_session changes during the session. + int64 session_end_block_height = 5; // The height at which this session ended, this is the last block of the session +} + +// Session is a fully hydrated session object that contains all the information for the Session +// and its parcipants. +message Session { + SessionHeader header = 1; // The header of the session containing lightweight data + string session_id = 2; // A unique pseudoranom ID for this session + int64 session_number = 3; // The session number since genesis + int64 num_blocks_per_session = 4; // The number of blocks per session when this session started + poktroll.application.Application application = 5; // A fully hydrated application object this session is for + repeated poktroll.shared.Supplier suppliers = 6; // A fully hydrated set of servicers that are serving the application +} diff --git a/proto/poktroll/shared/genesis.proto b/proto/poktroll/shared/genesis.proto index b2867ab..32e9c68 100644 --- a/proto/poktroll/shared/genesis.proto +++ b/proto/poktroll/shared/genesis.proto @@ -6,6 +6,7 @@ import "gogoproto/gogo.proto"; import "poktroll/shared/params.proto"; option go_package = "github.com/pokt-network/poktroll/x/shared/types"; +option (gogoproto.stable_marshaler_all) = true; // GenesisState defines the shared module's genesis state. message GenesisState { diff --git a/proto/poktroll/shared/module/module.proto b/proto/poktroll/shared/module/module.proto index 4deb64e..3206a52 100644 --- a/proto/poktroll/shared/module/module.proto +++ b/proto/poktroll/shared/module/module.proto @@ -1,7 +1,10 @@ syntax = "proto3"; package poktroll.shared.module; +option (gogoproto.stable_marshaler_all) = true; + import "cosmos/app/v1alpha1/module.proto"; +import "gogoproto/gogo.proto"; // Module is the config object for the module. message Module { @@ -11,4 +14,4 @@ message Module { // authority defines the custom module authority. If not set, defaults to the governance module. string authority = 1; -} \ No newline at end of file +} diff --git a/proto/poktroll/shared/params.proto b/proto/poktroll/shared/params.proto index 47c3e1e..765f456 100644 --- a/proto/poktroll/shared/params.proto +++ b/proto/poktroll/shared/params.proto @@ -5,6 +5,7 @@ import "amino/amino.proto"; import "gogoproto/gogo.proto"; option go_package = "github.com/pokt-network/poktroll/x/shared/types"; +option (gogoproto.stable_marshaler_all) = true; // Params defines the parameters for the module. message Params { @@ -13,16 +14,31 @@ message Params { // num_blocks_per_session is the number of blocks between the session start & end heights. uint64 num_blocks_per_session = 1 [(gogoproto.jsontag) = "num_blocks_per_session"]; + // grace_period_end_offset_blocks is the number of blocks, after the session end height, + // during which the supplier can still service payable relays. + // Suppliers will need to recreate a claim for the previous session (if already created) to + // get paid for the additional relays. + uint64 grace_period_end_offset_blocks = 2 [(gogoproto.jsontag) = "grace_period_end_offset_blocks"]; // claim_window_open_offset_blocks is the number of blocks after the session grace // period height, at which the claim window opens. - uint64 claim_window_open_offset_blocks = 2 [(gogoproto.jsontag) = "claim_window_open_offset_blocks"]; + uint64 claim_window_open_offset_blocks = 3 [(gogoproto.jsontag) = "claim_window_open_offset_blocks"]; // claim_window_close_offset_blocks is the number of blocks after the claim window // open height, at which the claim window closes. - uint64 claim_window_close_offset_blocks = 3 [(gogoproto.jsontag) = "claim_window_close_offset_blocks"]; + uint64 claim_window_close_offset_blocks = 4 [(gogoproto.jsontag) = "claim_window_close_offset_blocks"]; // proof_window_open_offset_blocks is the number of blocks after the claim window // close height, at which the proof window opens. - uint64 proof_window_open_offset_blocks = 4 [(gogoproto.jsontag) = "proof_window_open_offset_blocks"]; + uint64 proof_window_open_offset_blocks = 5 [(gogoproto.jsontag) = "proof_window_open_offset_blocks"]; // proof_window_close_offset_blocks is the number of blocks after the proof window // open height, at which the proof window closes. - uint64 proof_window_close_offset_blocks = 5 [(gogoproto.jsontag) = "proof_window_close_offset_blocks"]; -} \ No newline at end of file + uint64 proof_window_close_offset_blocks = 6 [(gogoproto.jsontag) = "proof_window_close_offset_blocks"]; + // supplier_unbonding_period_sessions is the number of sessions that a supplier must wait after + // unstaking before their staked assets are moved to their account balance. + // On-chain business logic requires, and ensures, that the corresponding block count of the unbonding + // period will exceed the end of any active claim & proof lifecycles. + uint64 supplier_unbonding_period_sessions = 7 [(gogoproto.jsontag) = "supplier_unbonding_period_sessions"]; + // application_unbonding_period_sessions is the number of sessions that an application must wait after + // unstaking before their staked assets are moved to their account balance. + // On-chain business logic requires, and ensures, that the corresponding block count of the + // application unbonding period will exceed the end of its corresponding proof window close height. + uint64 application_unbonding_period_sessions = 8 [(gogoproto.jsontag) = "application_unbonding_period_sessions"]; +} diff --git a/proto/poktroll/shared/query.proto b/proto/poktroll/shared/query.proto index 7445dcb..9ad5f97 100644 --- a/proto/poktroll/shared/query.proto +++ b/proto/poktroll/shared/query.proto @@ -8,6 +8,7 @@ import "cosmos/base/query/v1beta1/pagination.proto"; import "poktroll/shared/params.proto"; option go_package = "github.com/pokt-network/poktroll/x/shared/types"; +option (gogoproto.stable_marshaler_all) = true; // Query defines the gRPC querier service. service Query { @@ -27,4 +28,4 @@ message QueryParamsResponse { (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; -} \ No newline at end of file +} diff --git a/proto/poktroll/shared/service.proto b/proto/poktroll/shared/service.proto index 5ba16f7..fb46500 100644 --- a/proto/poktroll/shared/service.proto +++ b/proto/poktroll/shared/service.proto @@ -4,19 +4,35 @@ syntax = "proto3"; // but rather a manually created package to resolve circular type dependencies. package poktroll.shared; +import "cosmos_proto/cosmos.proto"; + +import "gogoproto/gogo.proto"; option go_package = "github.com/pokt-network/poktroll/x/shared/types"; +option (gogoproto.stable_marshaler_all) = true; // Service message to encapsulate unique and semantic identifiers for a service on the network message Service { // For example, what if we want to request a session for a certain service but with some additional configs that identify it? string id = 1; // Unique identifier for the service - // TODO_BETA: Name is currently unused but acts as a reminder that an optional onchain representation of the service is necessary + // TODO_MAINNET: Remove this. string name = 2; // (Optional) Semantic human readable name for the service + + // The cost of a single relay for this service in terms of compute units. + // Must be used alongside the global 'compute_units_to_tokens_multipler' to calculate the cost of a relay for this service. + // cost_per_relay_for_specific_service = compute_units_per_relay_for_specific_service * compute_units_to_tokens_multipler_global_value + uint64 compute_units_per_relay = 3; // Compute units required per relay for this service + + // The owner address that created the service. + // It is the address that receives rewards based on the Service's on-chain usage + // It is the only address that can update the service configuration (e.g. compute_units_per_relay), + // or make other updates to it. + string owner_address = 4 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the service owner / creator } // ApplicationServiceConfig holds the service configuration the application stakes for message ApplicationServiceConfig { + // TODO_MAINNET: Avoid embedding the full Service because we just need the ID. Service service = 1; // The Service for which the application is configured // TODO_MAINNET: There is an opportunity for applications to advertise the max @@ -26,8 +42,10 @@ message ApplicationServiceConfig { // SupplierServiceConfig holds the service configuration the supplier stakes for message SupplierServiceConfig { + // TODO_MAINNET: Avoid embedding the full Service because we just need the ID. Service service = 1; // The Service for which the supplier is configured repeated SupplierEndpoint endpoints = 2; // List of endpoints for the service + repeated ServiceRevenueShare rev_share = 3; // List of revenue share configurations for the service // TODO_MAINNET: There is an opportunity for supplier to advertise the min // they're willing to earn for a certain configuration/price, but this is outside of scope. } @@ -39,6 +57,12 @@ message SupplierEndpoint { repeated ConfigOption configs = 3; // Additional configuration options for the endpoint } +// ServiceRevenueShare message to hold revenue share configuration details +message ServiceRevenueShare { + string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the revenue share recipient + float rev_share_percentage = 2; // The percentage of revenue share the recipient will receive +} + // Enum to define RPC types enum RPCType { UNKNOWN_RPC = 0; // Undefined RPC type @@ -46,7 +70,7 @@ enum RPCType { WEBSOCKET = 2; // WebSocket JSON_RPC = 3; // JSON-RPC REST = 4; // REST - // Add new RPC types here as needed +// Add new RPC types here as needed } // Enum to define configuration options diff --git a/proto/poktroll/shared/supplier.proto b/proto/poktroll/shared/supplier.proto index 5553f56..be58d1a 100644 --- a/proto/poktroll/shared/supplier.proto +++ b/proto/poktroll/shared/supplier.proto @@ -2,16 +2,32 @@ syntax = "proto3"; package poktroll.shared; option go_package = "github.com/pokt-network/poktroll/x/shared/types"; +option (gogoproto.stable_marshaler_all) = true; import "cosmos_proto/cosmos.proto"; import "cosmos/base/v1beta1/coin.proto"; import "poktroll/shared/service.proto"; +import "gogoproto/gogo.proto"; // Supplier is the type defining the actor in Pocket Network that provides RPC services. message Supplier { - string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the supplier using cosmos' ScalarDescriptor to ensure deterministic encoding - cosmos.base.v1beta1.Coin stake = 2; // The total amount of uPOKT the supplier has staked - repeated SupplierServiceConfig services = 3; // The service configs this supplier can support + // The address of the owner (i.e. staker, custodial) that owns the funds for staking. + // By default, this address is the one that receives all the rewards unless owtherwise specified. + // This property cannot be updated by the operator. + string owner_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // Bech32 cosmos address + // The operator address of the supplier operator (i.e. the one managing the off-chain server). + // The operator address can update the supplier's configurations excluding the owner address. + // This property does not change over the supplier's lifespan, the supplier must be unstaked + // and re-staked to effectively update this value. + string operator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // Bech32 cosmos address + cosmos.base.v1beta1.Coin stake = 3; // The total amount of uPOKT the supplier has staked + repeated SupplierServiceConfig services = 4; // The service configs this supplier can support + // The session end height at which an actively unbonding supplier unbonds its stake. + // If the supplier did not unstake, this value will be 0. + uint64 unstake_session_end_height = 5; + // services_activation_heights_map is a map of serviceIds to the height at + // which the staked supplier will become active for that service. + // Activation heights are session start heights. + map services_activation_heights_map = 6; } - diff --git a/proto/poktroll/shared/tx.proto b/proto/poktroll/shared/tx.proto index 12f0bd6..c4097c4 100644 --- a/proto/poktroll/shared/tx.proto +++ b/proto/poktroll/shared/tx.proto @@ -9,11 +9,12 @@ import "gogoproto/gogo.proto"; import "poktroll/shared/params.proto"; option go_package = "github.com/pokt-network/poktroll/x/shared/types"; +option (gogoproto.stable_marshaler_all) = true; // Msg defines the Msg service. service Msg { option (cosmos.msg.v1.service) = true; - + // UpdateParams defines a (governance) operation for updating the module // parameters. The authority defaults to the x/gov module account. rpc UpdateParams (MsgUpdateParams) returns (MsgUpdateParamsResponse); @@ -23,12 +24,12 @@ service Msg { message MsgUpdateParams { option (cosmos.msg.v1.signer) = "authority"; option (amino.name) = "poktroll/x/shared/MsgUpdateParams"; - + // authority is the address that controls the module (defaults to x/gov unless overwritten). string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // params defines the module parameters to update. - + // NOTE: All parameters must be supplied. Params params = 2 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; } diff --git a/proto/poktroll/supplier/genesis.proto b/proto/poktroll/supplier/genesis.proto index dbda0e2..ac93e1b 100644 --- a/proto/poktroll/supplier/genesis.proto +++ b/proto/poktroll/supplier/genesis.proto @@ -2,6 +2,7 @@ syntax = "proto3"; package poktroll.supplier; option go_package = "github.com/pokt-network/poktroll/x/supplier/types"; +option (gogoproto.stable_marshaler_all) = true; import "amino/amino.proto"; import "gogoproto/gogo.proto"; diff --git a/proto/poktroll/supplier/module/module.proto b/proto/poktroll/supplier/module/module.proto index b0b5704..d136117 100644 --- a/proto/poktroll/supplier/module/module.proto +++ b/proto/poktroll/supplier/module/module.proto @@ -1,7 +1,10 @@ syntax = "proto3"; package poktroll.supplier.module; +option (gogoproto.stable_marshaler_all) = true; + import "cosmos/app/v1alpha1/module.proto"; +import "gogoproto/gogo.proto"; // Module is the config object for the module. message Module { @@ -11,4 +14,4 @@ message Module { // authority defines the custom module authority. If not set, defaults to the governance module. string authority = 1; -} \ No newline at end of file +} diff --git a/proto/poktroll/supplier/params.proto b/proto/poktroll/supplier/params.proto index a27a7ba..ea532e6 100644 --- a/proto/poktroll/supplier/params.proto +++ b/proto/poktroll/supplier/params.proto @@ -2,6 +2,7 @@ syntax = "proto3"; package poktroll.supplier; option go_package = "github.com/pokt-network/poktroll/x/supplier/types"; +option (gogoproto.stable_marshaler_all) = true; import "amino/amino.proto"; import "gogoproto/gogo.proto"; @@ -10,4 +11,4 @@ import "gogoproto/gogo.proto"; message Params { option (amino.name) = "poktroll/x/supplier/Params"; option (gogoproto.equal) = true; -} \ No newline at end of file +} diff --git a/proto/poktroll/supplier/query.proto b/proto/poktroll/supplier/query.proto index 4220f9a..cb7a4d3 100644 --- a/proto/poktroll/supplier/query.proto +++ b/proto/poktroll/supplier/query.proto @@ -2,6 +2,7 @@ syntax = "proto3"; package poktroll.supplier; option go_package = "github.com/pokt-network/poktroll/x/supplier/types"; +option (gogoproto.stable_marshaler_all) = true; import "amino/amino.proto"; import "gogoproto/gogo.proto"; @@ -24,7 +25,7 @@ service Query { // Queries a list of Supplier items. rpc Supplier (QueryGetSupplierRequest) returns (QueryGetSupplierResponse) { - option (google.api.http).get = "/pokt-network/poktroll/supplier/supplier/{address}"; + option (google.api.http).get = "/pokt-network/poktroll/supplier/supplier/{operator_address}"; } rpc AllSuppliers (QueryAllSuppliersRequest) returns (QueryAllSuppliersResponse) { @@ -43,7 +44,7 @@ message QueryParamsResponse { } message QueryGetSupplierRequest { - string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string operator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; } message QueryGetSupplierResponse { diff --git a/proto/poktroll/supplier/tx.proto b/proto/poktroll/supplier/tx.proto index ef75baa..1e13c9d 100644 --- a/proto/poktroll/supplier/tx.proto +++ b/proto/poktroll/supplier/tx.proto @@ -2,6 +2,7 @@ syntax = "proto3"; package poktroll.supplier; option go_package = "github.com/pokt-network/poktroll/x/supplier/types"; +option (gogoproto.stable_marshaler_all) = true; import "amino/amino.proto"; import "cosmos/msg/v1/msg.proto"; @@ -45,17 +46,22 @@ message MsgUpdateParams { message MsgUpdateParamsResponse {} message MsgStakeSupplier { - option (cosmos.msg.v1.signer) = "address"; // https://docs.cosmos.network/main/build/building-modules/messages-and-queries - string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the supplier using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding - cosmos.base.v1beta1.Coin stake = 2; // The total amount of uPOKT the supplier has staked. Must be ≥ to the current amount that the supplier has staked (if any) - repeated poktroll.shared.SupplierServiceConfig services = 3; // The list of services this supplier is staked to provide service for + option (cosmos.msg.v1.signer) = "signer"; // https://docs.cosmos.network/main/build/building-modules/messages-and-queries + + string signer = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the message signer (i.e. owner or operator) + string owner_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the owner (i.e. custodial, staker) + string operator_address = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the operator (i.e. provider, non-custodial) + cosmos.base.v1beta1.Coin stake = 4; // The total amount of uPOKT the supplier has staked. Must be ≥ to the current amount that the supplier has staked (if any) + repeated poktroll.shared.SupplierServiceConfig services = 5; // The list of services this supplier is staked to provide service for } message MsgStakeSupplierResponse {} message MsgUnstakeSupplier { - option (cosmos.msg.v1.signer) = "address"; - string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the supplier using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding using cosmos' ScalarDescriptor to ensure deterministic deterministic encoding + option (cosmos.msg.v1.signer) = "signer"; + + string signer = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the message signer (i.e. owner or operator) + string operator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the operator (i.e. provider, non-custodial) } message MsgUnstakeSupplierResponse {} diff --git a/proto/poktroll/tokenomics/event.proto b/proto/poktroll/tokenomics/event.proto index 5fe5c89..a5a6047 100644 --- a/proto/poktroll/tokenomics/event.proto +++ b/proto/poktroll/tokenomics/event.proto @@ -2,23 +2,36 @@ syntax = "proto3"; package poktroll.tokenomics; option go_package = "github.com/pokt-network/poktroll/x/tokenomics/types"; +option (gogoproto.stable_marshaler_all) = true; -import "poktroll/proof/claim.proto"; +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; +import "poktroll/proof/types.proto"; + +enum ClaimExpirationReason { + EXPIRATION_REASON_UNSPECIFIED = 0; // Default value, means may be valid + PROOF_MISSING = 1; + PROOF_INVALID = 2; +} // EventClaimExpired is an event emitted during settlement whenever a claim requiring // an on-chain proof doesn't have one. The claim cannot be settled, leading to that work // never being rewarded. message EventClaimExpired { - poktroll.proof.Claim claim = 1; - uint64 compute_units = 2; + poktroll.proof.Claim claim = 1 [(gogoproto.jsontag) = "claim"]; + // TODO_MAINNET: Shold we include the proof here too? + uint64 num_relays = 2 [(gogoproto.jsontag) = "num_relays"]; + uint64 num_compute_units = 3 [(gogoproto.jsontag) = "num_compute_units"]; + ClaimExpirationReason expiration_reason = 4 [(gogoproto.jsontag) = "expiration_reason"]; } // EventClaimSettled is an event emitted whenever a claim is settled. // The proof_required determines whether the claim requires a proof that has been submitted or not message EventClaimSettled { - poktroll.proof.Claim claim = 1; - uint64 compute_units = 2; - bool proof_required = 3; + poktroll.proof.Claim claim = 1 [(gogoproto.jsontag) = "claim"]; + uint64 num_relays = 2 [(gogoproto.jsontag) = "num_relays"]; + uint64 num_compute_units = 3 [(gogoproto.jsontag) = "num_compute_units"]; + poktroll.proof.ProofRequirementReason proof_requirement = 4 [(gogoproto.jsontag) = "proof_requirement"]; } // EventRelayMiningDifficultyUpdated is an event emitted whenever the relay mining difficulty is updated @@ -30,3 +43,11 @@ message EventRelayMiningDifficultyUpdated { uint64 prev_num_relays_ema = 4; uint64 new_num_relays_ema = 5; } + +// EventApplicationOverserviced is emitted when an application has less stake +// than the expected burn. +message EventApplicationOverserviced { + string application_addr = 1; + cosmos.base.v1beta1.Coin expected_burn = 2; + cosmos.base.v1beta1.Coin effective_burn = 3; +} diff --git a/proto/poktroll/tokenomics/genesis.proto b/proto/poktroll/tokenomics/genesis.proto index 51a9f4b..a6fe912 100644 --- a/proto/poktroll/tokenomics/genesis.proto +++ b/proto/poktroll/tokenomics/genesis.proto @@ -3,6 +3,7 @@ syntax = "proto3"; package poktroll.tokenomics; option go_package = "github.com/pokt-network/poktroll/x/tokenomics/types"; +option (gogoproto.stable_marshaler_all) = true; import "amino/amino.proto"; import "gogoproto/gogo.proto"; diff --git a/proto/poktroll/tokenomics/module/module.proto b/proto/poktroll/tokenomics/module/module.proto index 8dfd4de..d1ac682 100644 --- a/proto/poktroll/tokenomics/module/module.proto +++ b/proto/poktroll/tokenomics/module/module.proto @@ -1,7 +1,10 @@ syntax = "proto3"; package poktroll.tokenomics.module; +option (gogoproto.stable_marshaler_all) = true; + import "cosmos/app/v1alpha1/module.proto"; +import "gogoproto/gogo.proto"; // Module is the config object for the module. message Module { @@ -11,4 +14,4 @@ message Module { // authority defines the custom module authority. If not set, defaults to the governance module. string authority = 1; -} \ No newline at end of file +} diff --git a/proto/poktroll/tokenomics/params.proto b/proto/poktroll/tokenomics/params.proto index 2a0d16c..636787c 100644 --- a/proto/poktroll/tokenomics/params.proto +++ b/proto/poktroll/tokenomics/params.proto @@ -2,6 +2,7 @@ syntax = "proto3"; package poktroll.tokenomics; option go_package = "github.com/pokt-network/poktroll/x/tokenomics/types"; +option (gogoproto.stable_marshaler_all) = true; import "amino/amino.proto"; import "gogoproto/gogo.proto"; @@ -28,4 +29,4 @@ message Params { // - RevDistr.PercentageToDAO // - RevDistr.PercentageToPNF // - RevDistr.PercentageToDelegators -} \ No newline at end of file +} diff --git a/proto/poktroll/tokenomics/query.proto b/proto/poktroll/tokenomics/query.proto index 31b0277..23888d8 100644 --- a/proto/poktroll/tokenomics/query.proto +++ b/proto/poktroll/tokenomics/query.proto @@ -3,6 +3,7 @@ syntax = "proto3"; package poktroll.tokenomics; option go_package = "github.com/pokt-network/poktroll/x/tokenomics/types"; +option (gogoproto.stable_marshaler_all) = true; import "amino/amino.proto"; import "gogoproto/gogo.proto"; diff --git a/proto/poktroll/tokenomics/relay_mining_difficulty.proto b/proto/poktroll/tokenomics/relay_mining_difficulty.proto index 7ed4637..36a671d 100644 --- a/proto/poktroll/tokenomics/relay_mining_difficulty.proto +++ b/proto/poktroll/tokenomics/relay_mining_difficulty.proto @@ -2,11 +2,14 @@ syntax = "proto3"; package poktroll.tokenomics; option go_package = "github.com/pokt-network/poktroll/x/tokenomics/types"; +option (gogoproto.stable_marshaler_all) = true; + +import "gogoproto/gogo.proto"; // RelayMiningDifficulty is a message used to store the on-chain Relay Mining // difficulty associated with a specific service ID. message RelayMiningDifficulty { - // The service ID the the relay mining difficulty is associated with. + // The service ID the relay mining difficulty is associated with. string service_id = 1; // The block height at which this relay mining difficulty was computed. diff --git a/proto/poktroll/tokenomics/tx.proto b/proto/poktroll/tokenomics/tx.proto index 1b407d1..c7185b4 100644 --- a/proto/poktroll/tokenomics/tx.proto +++ b/proto/poktroll/tokenomics/tx.proto @@ -3,6 +3,7 @@ syntax = "proto3"; package poktroll.tokenomics; option go_package = "github.com/pokt-network/poktroll/x/tokenomics/types"; +option (gogoproto.stable_marshaler_all) = true; import "amino/amino.proto"; import "cosmos/msg/v1/msg.proto"; @@ -49,7 +50,7 @@ message MsgUpdateParam { string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The (name, as_type) tuple must match the corresponding name and type as - // specified in the `Params`` message in `proof/params.proto.` + // specified in the `Params` message in `proof/params.proto.` string name = 2; oneof as_type { string as_string = 3 [(gogoproto.jsontag) = "as_string"]; diff --git a/src/mappings/bank/balanceChange.ts b/src/mappings/bank/balanceChange.ts index e872337..59a2de9 100644 --- a/src/mappings/bank/balanceChange.ts +++ b/src/mappings/bank/balanceChange.ts @@ -5,8 +5,9 @@ import { attemptHandling, checkBalancesAccount, messageId, - unprocessedEventHandler -} from "../utils"; + stringify, + unprocessedEventHandler, +} from '../utils' export async function saveNativeBalanceEvent(id: string, address: string, amount: bigint, denom: string, event: CosmosEvent): Promise { await checkBalancesAccount(address, event.block.block.header.chainId); @@ -61,8 +62,8 @@ export async function handleNativeBalanceIncrement(event: CosmosEvent): Promise< async function _handleNativeBalanceDecrement(event: CosmosEvent): Promise { // logger.info(`[handleNativeBalanceDecrement] (tx ${event.tx.hash}): indexing event ${event.idx + 1} / ${event.tx.tx.events.length}`); - logger.debug(`[handleNativeBalanceDecrement] (event.event): ${JSON.stringify(event.event, null, 2)}`); - logger.debug(`[handleNativeBalanceDecrement] (event.log): ${JSON.stringify(event.log, null, 2)}`); + logger.debug(`[handleNativeBalanceDecrement] (event.event): ${stringify(event.event, undefined, 2)}`); + logger.debug(`[handleNativeBalanceDecrement] (event.log): ${stringify(event.log, undefined, 2)}`); // sample event.event.attributes: // [ @@ -77,7 +78,7 @@ async function _handleNativeBalanceDecrement(event: CosmosEvent): Promise continue; } const spender = e.value; - const amountStr = event.event.attributes[parseInt(i) + 1].value; + const amountStr = event.event.attributes[parseInt(i) + 1].value as string; // NB: some events contain empty string amounts if (amountStr === "") { @@ -107,8 +108,8 @@ async function _handleNativeBalanceDecrement(event: CosmosEvent): Promise async function _handleNativeBalanceIncrement(event: CosmosEvent): Promise { // logger.info(`[handleNativeBalanceIncrement] (tx ${event.tx.hash}): indexing event ${event.idx + 1} / ${event.tx.tx.events.length}`); - logger.debug(`[handleNativeBalanceIncrement] (event.event): ${JSON.stringify(event.event, null, 2)}`); - logger.debug(`[handleNativeBalanceIncrement] (event.log): ${JSON.stringify(event.log, null, 2)}`); + logger.debug(`[handleNativeBalanceIncrement] (event.event): ${stringify(event.event, undefined, 2)}`); + logger.debug(`[handleNativeBalanceIncrement] (event.log): ${stringify(event.log, undefined, 2)}`); // sample event.event.attributes: // [ @@ -123,7 +124,7 @@ async function _handleNativeBalanceIncrement(event: CosmosEvent): Promise continue; } const receiver = e.value; - const amountStr = event.event.attributes[parseInt(i) + 1].value; + const amountStr = event.event.attributes[parseInt(i) + 1].value as string; // NB: some events contain empty string amounts if (amountStr === "") { diff --git a/src/mappings/bank/transfer.ts b/src/mappings/bank/transfer.ts index 9819dd1..1f8c513 100644 --- a/src/mappings/bank/transfer.ts +++ b/src/mappings/bank/transfer.ts @@ -1,7 +1,7 @@ import {CosmosEvent, CosmosMessage} from "@subql/types-cosmos"; import {NativeTransfer} from "../../types"; import {NativeTransferMsg} from "../types"; -import {attemptHandling, messageId, unprocessedEventHandler} from "../utils"; +import {attemptHandling, messageId, unprocessedEventHandler, stringify} from "../utils"; export async function handleNativeTransfer(event: CosmosEvent): Promise { await attemptHandling(event, _handleNativeTransfer, unprocessedEventHandler); @@ -10,7 +10,7 @@ export async function handleNativeTransfer(event: CosmosEvent): Promise { async function _handleNativeTransfer(event: CosmosEvent): Promise { const msg: CosmosMessage = event.msg; logger.info(`[handleNativeTransfer] (tx ${msg.tx.hash}): indexing message ${msg.idx + 1} / ${msg.tx.decodedTx.body.messages.length}`); - logger.debug(`[handleNativeTransfer] (msg.msg): ${JSON.stringify(msg.msg, null, 2)}`); + logger.debug(`[handleNativeTransfer] (msg.msg): ${stringify(msg.msg, undefined, 2)}`); // const timeline = getTimeline(event); const fromAddress = msg.msg?.decodedMsg?.fromAddress; @@ -18,7 +18,7 @@ async function _handleNativeTransfer(event: CosmosEvent): Promise { const amounts = msg.msg?.decodedMsg?.amount; if (!fromAddress || !amounts || !toAddress) { - logger.warn(`[handleNativeTransfer] (tx ${event.tx.hash}): cannot index event (event.event): ${JSON.stringify(event.event, null, 2)}`); + logger.warn(`[handleNativeTransfer] (tx ${event.tx.hash}): cannot index event (event.event): ${stringify(event.event, undefined, 2)}`); return; } diff --git a/src/mappings/constants.ts b/src/mappings/constants.ts new file mode 100644 index 0000000..900c18e --- /dev/null +++ b/src/mappings/constants.ts @@ -0,0 +1 @@ +const PREFIX = "poktroll" diff --git a/src/mappings/primitives.ts b/src/mappings/primitives.ts index 7d3e36e..5d7e20b 100644 --- a/src/mappings/primitives.ts +++ b/src/mappings/primitives.ts @@ -1,83 +1,98 @@ -import {createHash} from "crypto"; -import {toBech32} from "@cosmjs/encoding"; -import {CosmosBlock, CosmosEvent, CosmosMessage, CosmosTransaction} from "@subql/types-cosmos"; -import {Block, Event, EventAttribute, Message, Transaction, TxStatus} from "../types"; +import { createHash } from 'crypto' +import { toBech32 } from '@cosmjs/encoding' +import { + CosmosBlock, + CosmosEvent, + CosmosMessage, + CosmosTransaction, +} from '@subql/types-cosmos' +import { + isEmpty, + isString, +} from 'lodash' +import { + Block, + Event, + EventAttribute, + Message, + Transaction, + TxStatus, +} from '../types' import { attemptHandling, messageId, + parseJson, primitivesFromMsg, primitivesFromTx, + stringify, trackUnprocessed, - unprocessedEventHandler -} from "./utils"; + unprocessedEventHandler, +} from './utils' export async function handleBlock(block: CosmosBlock): Promise { - await attemptHandling(block, _handleBlock, _handleBlockError); + await attemptHandling(block, _handleBlock, _handleBlockError) } export async function handleTransaction(tx: CosmosTransaction): Promise { - await attemptHandling(tx, _handleTransaction, _handleTransactionError); + await attemptHandling(tx, _handleTransaction, _handleTransactionError) } export async function handleMessage(msg: CosmosMessage): Promise { - await attemptHandling(msg, _handleMessage, _handleMessageError); + await attemptHandling(msg, _handleMessage, _handleMessageError) } export async function handleEvent(event: CosmosEvent): Promise { - await attemptHandling(event, _handleEvent, unprocessedEventHandler); + await attemptHandling(event, _handleEvent, unprocessedEventHandler) } async function _handleBlock(block: CosmosBlock): Promise { - logger.info(`[handleBlock] (block.header.height): indexing block ${block.block.header.height}`); + logger.info(`[handleBlock] (block.header.height): indexing block ${block.block.header.height}`) - const {header: {chainId, height, time}, id} = block.block; - const timestamp = new Date(time.getTime()); + const { header: { chainId, height, time }, id } = block.block + const timestamp = new Date(time.getTime()) const blockEntity = Block.create({ id, chainId, height: BigInt(height), - timestamp - }); + timestamp, + }) - await blockEntity.save(); + await blockEntity.save() } async function _handleTransaction(tx: CosmosTransaction): Promise { - logger.info(`[handleTransaction] (block ${tx.block.block.header.height}): indexing transaction ${tx.idx + 1} / ${tx.block.txs.length}`); - // logger.debug(`[handleTransaction] (tx.decodedTx): ${JSON.stringify(tx.decodedTx, null, 2)}`); + logger.info(`[handleTransaction] (block ${tx.block.block.header.height}): indexing transaction ${tx.idx + 1} / ${tx.block.txs.length}`) logger.debug(`[handleTransaction] (tx.tx.log): ${tx.tx.log}`); - let status = TxStatus.Error; + let status = TxStatus.Error if (tx.tx.log) { try { - JSON.parse(tx.tx.log); - status = TxStatus.Success; + parseJson(tx.tx.log) + status = TxStatus.Success } catch { // NB: assume tx failed } } - // const timeline = BigInt((tx.block.block.header.height * 100000) + tx.idx); - const pubKey: Uint8Array | undefined = tx.decodedTx.authInfo.signerInfos[0]?.publicKey?.value; - let signerAddress; - if (typeof (pubKey) !== "undefined") { + const pubKey: Uint8Array | undefined = tx.decodedTx.authInfo.signerInfos[0]?.publicKey?.value + let signerAddress + if (typeof (pubKey) !== 'undefined') { // TODO: check key type and handle respectively // NB: ripemd160(sha256(pubKey)) only works for secp256k1 keys - const ripemd160 = createHash("ripemd160"); - const sha256 = createHash("sha256"); + const ripemd160 = createHash('ripemd160') + const sha256 = createHash('sha256') // TODO: understand why!!! // NB: pubKey has 2 "extra" bytes at the beginning as compared to the // base64-decoded representation/ of the same key when imported to // fetchd (`fetchd keys add --recover`) and shown (`fetchd keys show`). - sha256.update(pubKey.slice(2)); - ripemd160.update(sha256.digest()); - // TODO: move prefix to config value or constant - signerAddress = toBech32("fetch", ripemd160.digest()); + sha256.update(pubKey.slice(2)) + ripemd160.update(sha256.digest()) + signerAddress = toBech32(PREFIX, ripemd160.digest()) } - const feeAmount = typeof(tx.decodedTx.authInfo.fee) !== "undefined" ? - tx.decodedTx.authInfo.fee.amount : []; + const feeAmount = typeof (tx.decodedTx.authInfo.fee) !== 'undefined' ? + tx.decodedTx.authInfo.fee.amount : [] const txEntity = Transaction.create({ id: tx.hash, @@ -86,23 +101,29 @@ async function _handleTransaction(tx: CosmosTransaction): Promise { gasUsed: tx.tx.gasUsed, gasWanted: tx.tx.gasWanted, memo: tx.decodedTx.body.memo, - timeoutHeight: BigInt(tx.decodedTx.body.timeoutHeight.toString()), + timeoutHeight: tx.decodedTx.body.timeoutHeight, fees: feeAmount, - log: tx.tx.log || "", + log: tx.tx.log || '', status, signerAddress, - }); - - await txEntity.save(); + }) + await txEntity.save() } async function _handleMessage(msg: CosmosMessage): Promise { - logger.info(`[handleMessage] (tx ${msg.tx.hash}): indexing message ${msg.idx + 1} / ${msg.tx.decodedTx.body.messages.length}`); - // logger.debug(`[handleMessage] (msg.msg): ${JSON.stringify(msg.msg, null, 2)}`); + if (msg.tx.hash === 'E5F4CAB95F9DF7642E89067FA3F736F37FA8DC06CAD0D40AC1BD16525836387C') { + try { + logger.info(`[handleMessage] (try) ${stringify(msg)}`) + } catch (e) { + logger.error(e, `[handleMessage] (catch) ${msg}`) + } + } + logger.info(`[handleMessage] (tx ${msg.tx.hash}): indexing message ${msg.idx + 1} / ${msg.tx.decodedTx.body.messages.length}`) + logger.debug(`[handleMessage] (msg.msg): ${stringify(msg.msg)}`) // const timeline = getTimeline(msg); - - delete msg.msg?.decodedMsg?.wasmByteCode; - const json = JSON.stringify(msg.msg.decodedMsg); + + delete msg.msg?.decodedMsg?.wasmByteCode + const json = stringify(msg.msg.decodedMsg) const msgEntity = Message.create({ id: messageId(msg), typeUrl: msg.msg.typeUrl, @@ -110,69 +131,73 @@ async function _handleMessage(msg: CosmosMessage): Promise { // timeline, transactionId: msg.tx.hash, blockId: msg.block.block.id, - }); + }) - await msgEntity.save(); + await msgEntity.save() } async function _handleEvent(event: CosmosEvent): Promise { - // if (!!event.tx.hash) { - // logger.info(`[handleEvent] (tx ${event.tx.hash}): indexing event ${event.idx + 1} / ${event.tx.tx.events.length}`); - // } else { - // logger.info(`[handleEvent]: indexing event ${event.idx + 1} / ${event.tx.tx.events.length}`); - // } - // logger.debug(`[handleEvent] (event.event): ${JSON.stringify(event.event, null, 2)}`); - // logger.debug(`[handleEvent] (event.log): ${JSON.stringify(event.log, null, 2)}`); - - // logger.debug("HANDLE EVENT"); - - // NB: sanitize attribute values (may contain non-text characters) - const sanitize = (value: unknown) => { - const json = JSON.stringify(value); - return json.substring(1, json.length - 1); - }; - const attributes = event.event.attributes.map((attribute) => { - const {key, value} = attribute; - return {key, value: sanitize(value)}; - }); + // TODO: generate an ID that will match on the event.event.type source depending on what type is. + if (!isEmpty(event.tx.hash)) { + logger.info(`[handleEvent] (tx ${event.tx.hash}): indexing event ${event.idx + 1} / ${event.tx.tx.events.length}`) + } else { + logger.info(`[handleEvent]: indexing event ${event.idx + 1} / ${event.tx.tx.events.length}`) + } let id if (event.tx) { - id = `${messageId(event)}-${event.idx}`; + id = `${messageId(event)}-${event.idx}` } else { id = `${event.block.blockId}-${event.idx}` } + // NB: sanitize attribute values (may contain non-text characters) + const sanitize = (value: unknown): string => { + // avoid stringify an string + if (isString(value)) return value + // otherwise return it as a stringifies object + return stringify(value) + } + const attributes = event.event.attributes.map((attribute) => { + const { key, value } = attribute + return { key, value: sanitize(value) } + }) + + logger.debug(`[handleEvent] (event.event): ${stringify(event.event, undefined, 2)}`); + logger.debug(`[handleEvent] (event.log): ${stringify(event.log, undefined, 2)}`); + logger.debug(`[handleEvent] (event.attributes): ${stringify(attributes, undefined, 2)}`); + const eventEntity = Event.create({ id, type: event.event.type, + // sourceId: event // transactionId: event.tx.hash, blockId: event.block.block.id, - }); - await eventEntity.save(); + }) + await eventEntity.save() for (const [i, attribute] of Object.entries(attributes)) { - const attrId = `${id}-${i}`; - const {key, value} = attribute; + const attrId = `${id}-${i}` + const { key, value } = attribute await EventAttribute.create({ id: attrId, - key, + key: key as string, value, eventId: eventEntity.id, - }).save(); + }).save() } } // eslint-disable-next-line @typescript-eslint/no-unused-vars async function _handleBlockError(err: Error, _: CosmosBlock): Promise { // NB: we won't have persisted any related entities yet. - await trackUnprocessed(err, {}); + await trackUnprocessed(err, {}) } async function _handleTransactionError(err: Error, tx: CosmosTransaction): Promise { - await trackUnprocessed(err, primitivesFromTx(tx)); + await trackUnprocessed(err, primitivesFromTx(tx)) } async function _handleMessageError(err: Error, msg: CosmosMessage): Promise { - await trackUnprocessed(err, primitivesFromMsg(msg)); + await trackUnprocessed(err, primitivesFromMsg(msg)) } diff --git a/src/mappings/utils.ts b/src/mappings/utils.ts index d0f42a7..0089427 100644 --- a/src/mappings/utils.ts +++ b/src/mappings/utils.ts @@ -1,6 +1,15 @@ -import {createHash} from "crypto"; -import {CosmosBlock, CosmosEvent, CosmosMessage, CosmosTransaction} from "@subql/types-cosmos"; -import {Account, UnprocessedEntity} from "../types"; +import { createHash } from 'crypto' +import { + CosmosBlock, + CosmosEvent, + CosmosMessage, + CosmosTransaction, +} from '@subql/types-cosmos' +import { default as JSONBig } from 'json-bigint' +import { + Account, + UnprocessedEntity, +} from '../types' export type Primitive = CosmosEvent | CosmosMessage | CosmosTransaction | CosmosBlock; @@ -11,95 +20,103 @@ export interface Primitives { block?: CosmosBlock; } +export function parseJson(str: string, reviver?: (this: unknown, key: string, value: unknown) => unknown): T { + return JSONBig.parse(str, reviver) as T +} + +export function stringify(value: unknown, replacer?: (this: unknown, key: string, value: unknown) => unknown, space?: string | number): string { + return JSONBig.stringify(value, replacer, space) +} + // messageId returns the id of the message passed or // that of the message which generated the event passed. export function messageId(msg: CosmosMessage | CosmosEvent): string { - return `${msg.tx.hash}-${msg.idx}`; + return `${msg.tx.hash}-${msg.idx}` } export async function checkBalancesAccount(address: string, chainId: string): Promise { - let accountEntity = await Account.get(address); - if (typeof (accountEntity) === "undefined") { - accountEntity = Account.create({id: address, chainId}); - await accountEntity.save(); + let accountEntity = await Account.get(address) + if (typeof (accountEntity) === 'undefined') { + accountEntity = Account.create({ id: address, chainId }) + await accountEntity.save() } } -export function getTimeline(entity: CosmosMessage|CosmosEvent): bigint { - const K2 = 100, K1 = K2 * 1000; - const txIndex = entity.tx.idx; - const blockHeight = entity.block.block.header.height; +export function getTimeline(entity: CosmosMessage | CosmosEvent): bigint { + const K2 = 100, K1 = K2 * 1000 + const txIndex = entity.tx.idx + const blockHeight = entity.block.block.header.height // check if the entity is an Event or a Message and set msgIndex appropriately const msgIndex = (entity).msg?.idx === undefined ? - (entity).idx : (entity).msg.idx; - const timeline = (K1 * blockHeight) + (K2 * txIndex) + msgIndex; - return BigInt(timeline); + (entity).idx : (entity).msg.idx + const timeline = (K1 * blockHeight) + (K2 * txIndex) + msgIndex + return BigInt(timeline) } export async function attemptHandling(input: Primitive, - // eslint-disable-next-line @typescript-eslint/no-explicit-any - handlerFn: (primitive: any) => Promise, - // eslint-disable-next-line @typescript-eslint/no-explicit-any - errorFn: (Error: Error, Primitive: any) => Promise | void): Promise { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + handlerFn: (primitive: any) => Promise, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + errorFn: (Error: Error, Primitive: any) => Promise | void): Promise { try { - await handlerFn(input); + await handlerFn(input) } catch (error: unknown) { - await errorFn(error as Error, input); + await errorFn(error as Error, input) } } export async function unprocessedEventHandler(err: Error, event: CosmosEvent): Promise { - await trackUnprocessed(err, primitivesFromEvent(event)); + await trackUnprocessed(err, primitivesFromEvent(event)) } export function primitivesFromTx(tx: CosmosTransaction): Primitives { - return {block: tx.block, tx: tx}; + return { block: tx.block, tx: tx } } export function primitivesFromMsg(msg: CosmosMessage): Primitives { - return {block: msg.block, tx: msg.tx}; + return { block: msg.block, tx: msg.tx } } export function primitivesFromEvent(event: CosmosEvent): Primitives { - return {block: event.block, tx: event.tx}; + return { block: event.block, tx: event.tx } } export async function trackUnprocessed(error: Error, primitives: Primitives): Promise { - logger.warn(`[trackUnprocessable] (error.message): ${error.message}`); - logger.warn(`[trackUnprocessable] (error.stack): ${error.stack}`); + logger.warn(`[trackUnprocessable] (error.message): ${error.message}`) + logger.warn(`[trackUnprocessable] (error.stack): ${error.stack}`) // NB: failsafe try/catch try { - const {block, event, msg, tx} = primitives; - const sha256 = createHash("sha256"); + const { block, event, msg, tx } = primitives + const sha256 = createHash('sha256') // NB: use error stack if no primitives available (i.e. block handler). const hashInput = event ? - (event.tx ? messageId(event): `${event.block.blockId}-${event.idx}`) : msg ? - // messageId(event) : msg ? + (event.tx ? messageId(event) : `${event.block.blockId}-${event.idx}`) : msg ? + // messageId(event) : msg ? messageId(msg) : tx ? tx.hash : block ? - block.block.id : error.stack; - sha256.write(hashInput); - sha256.end(); + block.block.id : error.stack + sha256.write(hashInput) + sha256.end() // NB: ID is a base64 encoded representation of the sha256 of either: // 1. the conventional ID of the "highest-level" primitive available or // 2. the error stacktrace, if none are available (i.e., handle block error) - const id = sha256.read().toString("base64"); - const eventId = event ? messageId(event) : undefined; - const _messageId = event ? messageId(event) : undefined; - const transactionId = tx ? tx.hash : undefined; - const blockId = block ? block.block.id : ""; + const id = sha256.read().toString('base64') + const eventId = event ? messageId(event) : undefined + const _messageId = event ? messageId(event) : undefined + const transactionId = tx ? tx.hash : undefined + const blockId = block ? block.block.id : '' const unprocessedEntity = UnprocessedEntity.create({ id, - error: error.stack || "", + error: error.stack || '', eventId, messageId: _messageId, transactionId, blockId: blockId, - }); - return await unprocessedEntity.save(); + }) + return await unprocessedEntity.save() } catch { - logger.error("[trackUnprocessable] (ERROR): unable to persist unprocessable entity"); - logger.error(`[trackUnprocessable] (ERROR | stack): ${error.stack}`); + logger.error('[trackUnprocessable] (ERROR): unable to persist unprocessable entity') + logger.error(`[trackUnprocessable] (ERROR | stack): ${error.stack}`) } } diff --git a/yarn.lock b/yarn.lock index 0449102..1473911 100644 --- a/yarn.lock +++ b/yarn.lock @@ -15,9 +15,9 @@ __metadata: languageName: node linkType: hard -"@apollo/client@npm:^3.8.8": - version: 3.10.6 - resolution: "@apollo/client@npm:3.10.6" +"@apollo/client@npm:^3.11.2": + version: 3.11.5 + resolution: "@apollo/client@npm:3.11.5" dependencies: "@graphql-typed-document-node/core": ^3.1.1 "@wry/caches": ^1.0.0 @@ -36,8 +36,8 @@ __metadata: peerDependencies: graphql: ^15.0.0 || ^16.0.0 graphql-ws: ^5.5.5 - react: ^16.8.0 || ^17.0.0 || ^18.0.0 - react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 + react: ^16.8.0 || ^17.0.0 || ^18.0.0 || >=19.0.0-rc <19.0.0 + react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 || >=19.0.0-rc <19.0.0 subscriptions-transport-ws: ^0.9.0 || ^0.11.0 peerDependenciesMeta: graphql-ws: @@ -48,7 +48,7 @@ __metadata: optional: true subscriptions-transport-ws: optional: true - checksum: b37a49af0f5315f0de890b8f8bd03d16d88477fba861985582a6c101c3522e60c10bce399f2eff18a094bb094301ee94abe2301648131739f1eddf52c1eb9992 + checksum: 70feb94acfadc114b27b268e8544217d2b50d1987421b20b2f5f43ba8f3f14f8472198c9f5dd3e842ac72a29b1975b7710960de766ec6d42fc1f17b66e64c9ab languageName: node linkType: hard @@ -2377,24 +2377,6 @@ __metadata: languageName: node linkType: hard -"@cosmjs/cosmwasm-stargate@npm:^0.32.3": - version: 0.32.3 - resolution: "@cosmjs/cosmwasm-stargate@npm:0.32.3" - dependencies: - "@cosmjs/amino": ^0.32.3 - "@cosmjs/crypto": ^0.32.3 - "@cosmjs/encoding": ^0.32.3 - "@cosmjs/math": ^0.32.3 - "@cosmjs/proto-signing": ^0.32.3 - "@cosmjs/stargate": ^0.32.3 - "@cosmjs/tendermint-rpc": ^0.32.3 - "@cosmjs/utils": ^0.32.3 - cosmjs-types: ^0.9.0 - pako: ^2.0.2 - checksum: 7b4174381758cfccb00e6b6af5341f147125b4b7094015cd4e3f25661b4f55c0f99b253f6bb589bce70816eef0907be0772591235763526624edf151637cf424 - languageName: node - linkType: hard - "@cosmjs/cosmwasm-stargate@npm:^0.32.4": version: 0.32.4 resolution: "@cosmjs/cosmwasm-stargate@npm:0.32.4" @@ -3832,6 +3814,15 @@ __metadata: languageName: node linkType: hard +"@isaacs/fs-minipass@npm:^4.0.0": + version: 4.0.1 + resolution: "@isaacs/fs-minipass@npm:4.0.1" + dependencies: + minipass: ^7.0.4 + checksum: 5d36d289960e886484362d9eb6a51d1ea28baed5f5d0140bbe62b99bac52eaf06cc01c2bc0d3575977962f84f6b2c4387b043ee632216643d4787b0999465bf2 + languageName: node + linkType: hard + "@istanbuljs/load-nyc-config@npm:^1.0.0": version: 1.1.0 resolution: "@istanbuljs/load-nyc-config@npm:1.1.0" @@ -4539,6 +4530,13 @@ __metadata: languageName: node linkType: hard +"@opentelemetry/api@npm:^1.4.0": + version: 1.9.0 + resolution: "@opentelemetry/api@npm:1.9.0" + checksum: 9e88e59d53ced668f3daaecfd721071c5b85a67dd386f1c6f051d1be54375d850016c881f656ffbe9a03bedae85f7e89c2f2b635313f9c9b195ad033cdc31020 + languageName: node + linkType: hard + "@parcel/watcher@npm:2.0.4": version: 2.0.4 resolution: "@parcel/watcher@npm:2.0.4" @@ -4568,6 +4566,17 @@ __metadata: languageName: node linkType: hard +"@polkadot/networks@npm:13.0.2": + version: 13.0.2 + resolution: "@polkadot/networks@npm:13.0.2" + dependencies: + "@polkadot/util": 13.0.2 + "@substrate/ss58-registry": ^1.46.0 + tslib: ^2.6.2 + checksum: 4bc02ae6a95c0bf770ab2ba99af59013665edf4e759a228148289859dcc171be61d93359f6846a5d248707eb215bcbf2ca69ae9f63eb1720caa38ceb3dab7587 + languageName: node + linkType: hard + "@polkadot/util-crypto@npm:^12.6.2": version: 12.6.2 resolution: "@polkadot/util-crypto@npm:12.6.2" @@ -4588,6 +4597,26 @@ __metadata: languageName: node linkType: hard +"@polkadot/util-crypto@npm:^13.0.2": + version: 13.0.2 + resolution: "@polkadot/util-crypto@npm:13.0.2" + dependencies: + "@noble/curves": ^1.3.0 + "@noble/hashes": ^1.3.3 + "@polkadot/networks": 13.0.2 + "@polkadot/util": 13.0.2 + "@polkadot/wasm-crypto": ^7.3.2 + "@polkadot/wasm-util": ^7.3.2 + "@polkadot/x-bigint": 13.0.2 + "@polkadot/x-randomvalues": 13.0.2 + "@scure/base": ^1.1.5 + tslib: ^2.6.2 + peerDependencies: + "@polkadot/util": 13.0.2 + checksum: 025bb2179d77b73dd8af775192627fe31e985e365fbecf38d7903a663aa11b703fa3f23fbb65e53d0a9710cc087e0cb9a113b0a660d8e9b36de21c36c1bc40d7 + languageName: node + linkType: hard + "@polkadot/util@npm:12.6.2, @polkadot/util@npm:^12.6.2": version: 12.6.2 resolution: "@polkadot/util@npm:12.6.2" @@ -4603,6 +4632,21 @@ __metadata: languageName: node linkType: hard +"@polkadot/util@npm:13.0.2, @polkadot/util@npm:^13.0.2": + version: 13.0.2 + resolution: "@polkadot/util@npm:13.0.2" + dependencies: + "@polkadot/x-bigint": 13.0.2 + "@polkadot/x-global": 13.0.2 + "@polkadot/x-textdecoder": 13.0.2 + "@polkadot/x-textencoder": 13.0.2 + "@types/bn.js": ^5.1.5 + bn.js: ^5.2.1 + tslib: ^2.6.2 + checksum: c7d71898395d2e9fb994ed53be10e9b44e9cb6f6bd502ce31a48848dda032a9e3f462a6039759798023425c6e17d5a7515784f0a8c0ab74c1a0a2691b0ef3660 + languageName: node + linkType: hard + "@polkadot/wasm-bridge@npm:7.3.2": version: 7.3.2 resolution: "@polkadot/wasm-bridge@npm:7.3.2" @@ -4693,6 +4737,16 @@ __metadata: languageName: node linkType: hard +"@polkadot/x-bigint@npm:13.0.2": + version: 13.0.2 + resolution: "@polkadot/x-bigint@npm:13.0.2" + dependencies: + "@polkadot/x-global": 13.0.2 + tslib: ^2.6.2 + checksum: a1c9d9ab3aa27f7a68a879c76cea38ca4757ae4802c6d2a7402dbfbf31468c4dd3c4f1e852e62c0a1bff18889fccac1ccbc38649bf96e9473948ea7d7c2899f3 + languageName: node + linkType: hard + "@polkadot/x-global@npm:12.6.2": version: 12.6.2 resolution: "@polkadot/x-global@npm:12.6.2" @@ -4702,6 +4756,15 @@ __metadata: languageName: node linkType: hard +"@polkadot/x-global@npm:13.0.2": + version: 13.0.2 + resolution: "@polkadot/x-global@npm:13.0.2" + dependencies: + tslib: ^2.6.2 + checksum: b487bf2a15d77681efae5e928364526102cff48207a871662515c500404ae58d9d08df813fd675c8bf0a2744dbf4648db6a0fe927993e597e8391349295560c8 + languageName: node + linkType: hard + "@polkadot/x-randomvalues@npm:12.6.2": version: 12.6.2 resolution: "@polkadot/x-randomvalues@npm:12.6.2" @@ -4715,6 +4778,19 @@ __metadata: languageName: node linkType: hard +"@polkadot/x-randomvalues@npm:13.0.2": + version: 13.0.2 + resolution: "@polkadot/x-randomvalues@npm:13.0.2" + dependencies: + "@polkadot/x-global": 13.0.2 + tslib: ^2.6.2 + peerDependencies: + "@polkadot/util": 13.0.2 + "@polkadot/wasm-util": "*" + checksum: 3968ca273ccdc3055466a8bdeae64141ef20dd5451f7fc750eaef28465460e41d28cdd4eadedf3b4ca94024c9ebae023a8a04eb946b9fd17a1ff9c105ebfe39c + languageName: node + linkType: hard + "@polkadot/x-textdecoder@npm:12.6.2": version: 12.6.2 resolution: "@polkadot/x-textdecoder@npm:12.6.2" @@ -4725,6 +4801,16 @@ __metadata: languageName: node linkType: hard +"@polkadot/x-textdecoder@npm:13.0.2": + version: 13.0.2 + resolution: "@polkadot/x-textdecoder@npm:13.0.2" + dependencies: + "@polkadot/x-global": 13.0.2 + tslib: ^2.6.2 + checksum: 586c970c66a014471b5354d41a55aa6dbeaa4aec041153d294205d7f86f93cfb6cb5c274b6ef38b0923b515b531bc8608fea7cdc6116c6dc61c370d892b207e4 + languageName: node + linkType: hard + "@polkadot/x-textencoder@npm:12.6.2": version: 12.6.2 resolution: "@polkadot/x-textencoder@npm:12.6.2" @@ -4735,6 +4821,16 @@ __metadata: languageName: node linkType: hard +"@polkadot/x-textencoder@npm:13.0.2": + version: 13.0.2 + resolution: "@polkadot/x-textencoder@npm:13.0.2" + dependencies: + "@polkadot/x-global": 13.0.2 + tslib: ^2.6.2 + checksum: b2db5ab0fd94b8a13816f028f9fb52e0f00c43df4a727c01911902b5fc11bec476b02b92aee5a98adabf4696907e828752c6e0eb9bece79f0440675e4eb030c9 + languageName: node + linkType: hard + "@protobufjs/aspromise@npm:^1.1.1, @protobufjs/aspromise@npm:^1.1.2": version: 1.1.2 resolution: "@protobufjs/aspromise@npm:1.1.2" @@ -5665,9 +5761,9 @@ __metadata: languageName: node linkType: hard -"@subql/common-cosmos@npm:5.0.1": - version: 5.0.1 - resolution: "@subql/common-cosmos@npm:5.0.1" +"@subql/common-cosmos@npm:5.0.3": + version: 5.0.3 + resolution: "@subql/common-cosmos@npm:5.0.3" dependencies: "@cosmwasm/ts-codegen": ^1.11.1 "@protobufs/cosmos": ^0.1.0 @@ -5677,8 +5773,8 @@ __metadata: "@protobufs/google": ^0.0.10 "@protobufs/ibc": ^0.1.0 "@protobufs/tendermint": ^0.0.10 - "@subql/common": ^4.1.1 - "@subql/types-cosmos": 3.5.1 + "@subql/common": ^5.1.1 + "@subql/types-cosmos": 3.5.3-0 "@subql/x-cosmology-telescope": ^1.4.14 fs-extra: ^11.1.1 js-yaml: ^4.1.0 @@ -5687,11 +5783,11 @@ __metadata: class-transformer: "*" class-validator: "*" ejs: "*" - checksum: 7aa28b485cd82ed4065eaff4248653b3ee7a604fa37530b0af0fa270226bb26d780c76fdd1dbceabda5e8528eba6ec72e3aabb6c3dec136103fefa96fb162334 + checksum: fa50ff96b1be4fa7594d8f614c744853f6c5313e0fc90f75aca5bea5678502899d3d60f5ec94cf69f66003cf7638ecdaec6888c651518aef87b4dce76200155b languageName: node linkType: hard -"@subql/common@npm:4.1.1, @subql/common@npm:^4.1.1": +"@subql/common@npm:4.1.1": version: 4.1.1 resolution: "@subql/common@npm:4.1.1" dependencies: @@ -5708,42 +5804,57 @@ __metadata: languageName: node linkType: hard -"@subql/node-core@npm:^13.0.1": - version: 13.0.1 - resolution: "@subql/node-core@npm:13.0.1" +"@subql/common@npm:5.1.1, @subql/common@npm:^5.1.1": + version: 5.1.1 + resolution: "@subql/common@npm:5.1.1" dependencies: - "@apollo/client": ^3.8.8 + "@subql/types-core": 1.1.1 + axios: ^0.28.0 + class-transformer: ^0.5.1 + class-validator: ^0.14.1 + js-yaml: ^4.1.0 + reflect-metadata: ^0.1.14 + semver: ^7.6.3 + update-notifier: ^5.1.0 + checksum: 7e8eeb5bb0242c178df8f68d38f078799d896837bd260804abcdf44eaa8b2ea1f28823d611d3b1a271e5216d0fc1b4a764a417ad9ac83b5c061e9761cc838ffc + languageName: node + linkType: hard + +"@subql/node-core@npm:^14.1.2": + version: 14.1.3 + resolution: "@subql/node-core@npm:14.1.3" + dependencies: + "@apollo/client": ^3.11.2 "@nestjs/common": ^9.4.0 "@nestjs/event-emitter": ^2.0.0 "@nestjs/schedule": ^3.0.1 - "@subql/common": 4.1.1 + "@subql/common": 5.1.1 "@subql/testing": 2.2.1 - "@subql/types": 3.9.0 - "@subql/utils": 2.13.1 + "@subql/types": 3.11.2 + "@subql/utils": 2.14.0 "@willsoto/nestjs-prometheus": ^5.4.0 - async-lock: ^1.4.0 - async-mutex: ^0.4.0 + async-mutex: ^0.5.0 cron-converter: ^2.0.1 cross-fetch: ^3.1.6 - csv-stringify: ^6.4.5 - dayjs: ^1.10.7 + csv-stringify: ^6.5.1 + dayjs: ^1.11.12 lodash: ^4.17.21 lru-cache: 10.1.0 merkle-tools: ^1.4.1 - pg: ^8.11.5 - prom-client: ^14.0.1 + pg: ^8.12.0 + prom-client: ^15.1.3 source-map: ^0.7.4 - tar: ^6.2.1 + tar: ^7.4.3 toposort-class: ^1.0.1 vm2: ^3.9.19 yargs: ^16.2.0 - checksum: 6946a95cd4ec14c9d1a00ecb830a8d92174923db85b89ba340c76afa5fa96bc07c83f6051dbd87ccb65085f43093437ebd2e24ee9de4285a576f84f5e5e5cda3 + checksum: 64059af71e59d1956e6eaae4b2f33268c99c644f56c0cee79bfb4a8c2682c22f000bf636b98938a39a33c1a24449fff58912c4b7f74e7ff715c1a6e2f7a4f273 languageName: node linkType: hard -"@subql/node-cosmos@npm:4.0.1": - version: 4.0.1 - resolution: "@subql/node-cosmos@npm:4.0.1" +"@subql/node-cosmos@npm:^4.1.1": + version: 4.1.1 + resolution: "@subql/node-cosmos@npm:4.1.1" dependencies: "@cosmjs/cosmwasm-stargate": ^0.32.4 "@cosmjs/proto-signing": ^0.32.4 @@ -5755,10 +5866,10 @@ __metadata: "@nestjs/event-emitter": ^2.0.0 "@nestjs/platform-express": ^9.4.0 "@nestjs/schedule": ^3.0.1 - "@subql/common": ^4.1.1 - "@subql/common-cosmos": 5.0.1 - "@subql/node-core": ^13.0.1 - "@subql/types-cosmos": 3.5.1 + "@subql/common": ^5.1.1 + "@subql/common-cosmos": 5.0.3 + "@subql/node-core": ^14.1.2 + "@subql/types-cosmos": 3.5.3-0 lodash: ^4.17.21 protobufjs: ^6.11.4 reflect-metadata: ^0.1.13 @@ -5768,7 +5879,7 @@ __metadata: "@subql/utils": "*" bin: subql-node-cosmos: ./bin/run - checksum: 185d086b5c2b4df952e55f520ca04adcfb7c7577d69b6f8d64e89061ed7158097f0f05d2adeb54046109646cd0515f59def9b530013c0e8c87e49e8cd4c8f2e1 + checksum: 99cfeeadd21c51549ac553360886effd9afea10192f3fa6e2dbae08538f910dc45dbe81ba2b390d6aef755776b5741f80e3633ee399420d5b82013adbab6d4a9 languageName: node linkType: hard @@ -5781,7 +5892,7 @@ __metadata: languageName: node linkType: hard -"@subql/types-core@npm:0.10.0, @subql/types-core@npm:^0.10.0": +"@subql/types-core@npm:0.10.0": version: 0.10.0 resolution: "@subql/types-core@npm:0.10.0" dependencies: @@ -5790,7 +5901,14 @@ __metadata: languageName: node linkType: hard -"@subql/types-core@npm:0.9.1, @subql/types-core@npm:^0.9.0, @subql/types-core@npm:^0.9.1": +"@subql/types-core@npm:1.1.1, @subql/types-core@npm:^1.1.1": + version: 1.1.1 + resolution: "@subql/types-core@npm:1.1.1" + checksum: d804ba8f9a9a8bbce36e98ef3dd03e33602495e96ca8e04438c38b6631de102772b5f209de17d78657bcacc9c91f9af02dabd68edb8e6e24a2ca6e681e4636fc + languageName: node + linkType: hard + +"@subql/types-core@npm:^0.9.1": version: 0.9.1 resolution: "@subql/types-core@npm:0.9.1" dependencies: @@ -5799,38 +5917,38 @@ __metadata: languageName: node linkType: hard -"@subql/types-cosmos@npm:3.5.0": - version: 3.5.0 - resolution: "@subql/types-cosmos@npm:3.5.0" +"@subql/types-cosmos@npm:3.5.3-0": + version: 3.5.3-0 + resolution: "@subql/types-cosmos@npm:3.5.3-0" dependencies: - "@cosmjs/cosmwasm-stargate": ^0.32.3 - "@cosmjs/proto-signing": ^0.32.3 - "@cosmjs/stargate": ^0.32.3 - "@subql/types-core": ^0.9.0 - checksum: 7612f034df1f5d39e91e90031ba34252f009e2d2c719a6f7efedc7f5873fe8fdd427e3221c942a83b7a1cd37fe56ceb8f0ef5a3e554f2cf983cfeb8318f66bfe + "@cosmjs/cosmwasm-stargate": ^0.32.4 + "@cosmjs/proto-signing": ^0.32.4 + "@cosmjs/stargate": ^0.32.4 + "@subql/types-core": ^1.1.1 + checksum: cd7dd1f2c693a2d21c7018deb004ecc9bcea22598fd309af79f50fe478f541ab7077dfaba5cd3ec534ef281a5004d5cc37b40f6f5174ac5c155db6df103b336f languageName: node linkType: hard -"@subql/types-cosmos@npm:3.5.1": - version: 3.5.1 - resolution: "@subql/types-cosmos@npm:3.5.1" +"@subql/types-cosmos@npm:^3.5.2": + version: 3.5.2 + resolution: "@subql/types-cosmos@npm:3.5.2" dependencies: "@cosmjs/cosmwasm-stargate": ^0.32.4 "@cosmjs/proto-signing": ^0.32.4 "@cosmjs/stargate": ^0.32.4 - "@subql/types-core": ^0.10.0 - checksum: 6d6e0799ca981ae0457b7a5839950b0ef4a8deea6931923fe4f60642328c51bd0900bc81871dc6b192e9fcf13cf1e59d48f7cbd64007b97e0eeed67708d5ab76 + "@subql/types-core": ^1.1.1 + checksum: 8d45b7996b8bc61b80a23734505b4d897697045c876d42525123e6ab8a02f7331b5d17a89949bce2e2714d4a9153581ca0e1883e133d6446a481a365d09f47e0 languageName: node linkType: hard -"@subql/types@npm:3.9.0": - version: 3.9.0 - resolution: "@subql/types@npm:3.9.0" +"@subql/types@npm:3.11.2": + version: 3.11.2 + resolution: "@subql/types@npm:3.11.2" dependencies: - "@subql/types-core": 0.9.1 + "@subql/types-core": 1.1.1 peerDependencies: - "@polkadot/api": ^11 - checksum: 3f44c8ade916b9957cb09ada9d78383df56b668c2fa5515576bca2bedb7db97760f47e8d87f0c3ce475ae12538bdff4e0d93a3ab998cf8919d199be81e6816aa + "@polkadot/api": ^12 + checksum: ef8e9f6bd73e9071ec267cb90259472d9ecb595d02bf52e44e4f93e90016ed0a897f09f6c8496455368b7ecb42a9a5aac7fc715ac5df5697936e8c1c1956e13f languageName: node linkType: hard @@ -5856,6 +5974,25 @@ __metadata: languageName: node linkType: hard +"@subql/utils@npm:2.14.0": + version: 2.14.0 + resolution: "@subql/utils@npm:2.14.0" + dependencies: + "@polkadot/util": ^13.0.2 + "@polkadot/util-crypto": ^13.0.2 + "@subql/x-sequelize": 6.32.0-0.0.4 + chalk: ^4.1.2 + detect-port: ^1.6.1 + flatted: ^3.3.1 + graphql: ^15.8.0 + graphql-tag: ^2.12.6 + lodash: ^4.17.21 + pino: ^6.13.3 + rotating-file-stream: ^3.2.3 + checksum: 0a56114494cb5e8c5dcf62e1d24fb7b2ba7b445472e61661ab9eec61df7a09449dd7251d78d6cd11a6da9939c5d54d2d57e16639b5d0986756513ab8810cf3e5 + languageName: node + linkType: hard + "@subql/x-cosmology-ast@npm:^1.4.10": version: 1.4.10 resolution: "@subql/x-cosmology-ast@npm:1.4.10" @@ -5988,6 +6125,13 @@ __metadata: languageName: node linkType: hard +"@substrate/ss58-registry@npm:^1.46.0": + version: 1.50.0 + resolution: "@substrate/ss58-registry@npm:1.50.0" + checksum: d19d933fadf9bfbebd1c4a62c750620de34bd920ca6beb3ad8d66147c6d672e0773b57fce8394ec52a36c60d0564a92b7961ed1eac8508bca0248e23f62b8460 + languageName: node + linkType: hard + "@supercharge/promise-pool@npm:^2.1.0": version: 2.4.0 resolution: "@supercharge/promise-pool@npm:2.4.0" @@ -6158,6 +6302,13 @@ __metadata: languageName: node linkType: hard +"@types/json-bigint@npm:^1.0.4": + version: 1.0.4 + resolution: "@types/json-bigint@npm:1.0.4" + checksum: 7aee137b3796121cec755247ea56577611c8e5df89224c567fa71999764d01e12199c4089c6be8a9e4e6a6a8f5c6f309eee2965cc3dd8d576f4c4ba432566041 + languageName: node + linkType: hard + "@types/json-schema@npm:*, @types/json-schema@npm:^7.0.11, @types/json-schema@npm:^7.0.8, @types/json-schema@npm:^7.0.9": version: 7.0.15 resolution: "@types/json-schema@npm:7.0.15" @@ -7299,19 +7450,12 @@ __metadata: languageName: node linkType: hard -"async-lock@npm:^1.4.0": - version: 1.4.1 - resolution: "async-lock@npm:1.4.1" - checksum: 29e70cd892932b7c202437786cedc39ff62123cb6941014739bd3cabd6106326416e9e7c21285a5d1dc042cad239a0f7ec9c44658491ee4a615fd36a21c1d10a - languageName: node - linkType: hard - -"async-mutex@npm:^0.4.0": - version: 0.4.1 - resolution: "async-mutex@npm:0.4.1" +"async-mutex@npm:^0.5.0": + version: 0.5.0 + resolution: "async-mutex@npm:0.5.0" dependencies: tslib: ^2.4.0 - checksum: cb529c0d257c8ff8e5b26c81b36127a255e545edee2c42c76247d533b89a7664037d95f33130f964de49b111ad3324ead8dcccd419c47acdfeb7413ed93063a1 + checksum: be1587f4875f3bb15e34e9fcce82eac2966daef4432c8d0046e61947fb9a1b95405284601bc7ce4869319249bc07c75100880191db6af11d1498931ac2a2f9ea languageName: node linkType: hard @@ -8094,6 +8238,13 @@ __metadata: languageName: node linkType: hard +"chownr@npm:^3.0.0": + version: 3.0.0 + resolution: "chownr@npm:3.0.0" + checksum: fd73a4bab48b79e66903fe1cafbdc208956f41ea4f856df883d0c7277b7ab29fd33ee65f93b2ec9192fc0169238f2f8307b7735d27c155821d886b84aa97aa8d + languageName: node + linkType: hard + "chrome-trace-event@npm:^1.0.2": version: 1.0.4 resolution: "chrome-trace-event@npm:1.0.4" @@ -8132,7 +8283,7 @@ __metadata: languageName: node linkType: hard -"class-validator@npm:^0.14.0": +"class-validator@npm:^0.14.0, class-validator@npm:^0.14.1": version: 0.14.1 resolution: "class-validator@npm:0.14.1" dependencies: @@ -8651,13 +8802,20 @@ __metadata: languageName: node linkType: hard -"csv-stringify@npm:^6.4.5, csv-stringify@npm:^6.5.0": +"csv-stringify@npm:^6.5.0": version: 6.5.0 resolution: "csv-stringify@npm:6.5.0" checksum: c4009bc691b30314ff17cb2918d2f43dd42de5a1d3cd7889fd523f131d0e37d2a3c3c2601de93e8b71e2d8f3f52a9e4fb2a5f2ede9991e2895c1daa268694d78 languageName: node linkType: hard +"csv-stringify@npm:^6.5.1": + version: 6.5.1 + resolution: "csv-stringify@npm:6.5.1" + checksum: 5eb8167ee944f5328c53c733d8c4b1eea88fb9e510abec430e2fcb4be6c4ce008b92e90da7825d424fe74d22c85405add7f89b9dcf82ffe2bf0a1cf31536057a + languageName: node + linkType: hard + "csv@npm:^6.0.5": version: 6.3.9 resolution: "csv@npm:6.3.9" @@ -8720,10 +8878,10 @@ __metadata: languageName: node linkType: hard -"dayjs@npm:^1.10.7": - version: 1.11.11 - resolution: "dayjs@npm:1.11.11" - checksum: 84788275aad8a87fee4f1ce4be08861df29687aae6b7b43dd65350118a37dda56772a3902f802cb2dc651dfed447a5a8df62d88f0fb900dba8333e411190a5d5 +"dayjs@npm:^1.11.12": + version: 1.11.13 + resolution: "dayjs@npm:1.11.13" + checksum: f388db88a6aa93956c1f6121644e783391c7b738b73dbc54485578736565c8931bdfba4bb94e9b1535c6e509c97d5deb918bbe1ae6b34358d994de735055cca9 languageName: node linkType: hard @@ -8890,7 +9048,7 @@ __metadata: languageName: node linkType: hard -"detect-port@npm:^1.3.0": +"detect-port@npm:^1.3.0, detect-port@npm:^1.6.1": version: 1.6.1 resolution: "detect-port@npm:1.6.1" dependencies: @@ -10044,7 +10202,7 @@ __metadata: languageName: node linkType: hard -"flatted@npm:^3.2.5, flatted@npm:^3.2.9": +"flatted@npm:^3.2.5, flatted@npm:^3.2.9, flatted@npm:^3.3.1": version: 3.3.1 resolution: "flatted@npm:3.3.1" checksum: 85ae7181650bb728c221e7644cbc9f4bf28bc556f2fc89bb21266962bdf0ce1029cc7acc44bb646cd469d9baac7c317f64e841c4c4c00516afa97320cdac7f94 @@ -10383,6 +10541,22 @@ __metadata: languageName: node linkType: hard +"glob@npm:^10.3.7": + version: 10.4.5 + resolution: "glob@npm:10.4.5" + dependencies: + foreground-child: ^3.1.0 + jackspeak: ^3.1.2 + minimatch: ^9.0.4 + minipass: ^7.1.2 + package-json-from-dist: ^1.0.0 + path-scurry: ^1.11.1 + bin: + glob: dist/esm/bin.mjs + checksum: 0bc725de5e4862f9f387fd0f2b274baf16850dcd2714502ccf471ee401803997983e2c05590cb65f9675a3c6f2a58e7a53f9e365704108c6ad3cbf1d60934c4a + languageName: node + linkType: hard + "glob@npm:^7.0.0, glob@npm:^7.1.3, glob@npm:^7.1.4, glob@npm:^7.1.6": version: 7.2.3 resolution: "glob@npm:7.2.3" @@ -12230,7 +12404,7 @@ __metadata: languageName: node linkType: hard -"minipass@npm:^5.0.0 || ^6.0.2 || ^7.0.0, minipass@npm:^7.0.2, minipass@npm:^7.0.3, minipass@npm:^7.1.2": +"minipass@npm:^5.0.0 || ^6.0.2 || ^7.0.0, minipass@npm:^7.0.2, minipass@npm:^7.0.3, minipass@npm:^7.0.4, minipass@npm:^7.1.2": version: 7.1.2 resolution: "minipass@npm:7.1.2" checksum: 2bfd325b95c555f2b4d2814d49325691c7bee937d753814861b0b49d5edcda55cbbf22b6b6a60bb91eddac8668771f03c5ff647dcd9d0f798e9548b9cdc46ee3 @@ -12247,6 +12421,16 @@ __metadata: languageName: node linkType: hard +"minizlib@npm:^3.0.1": + version: 3.0.1 + resolution: "minizlib@npm:3.0.1" + dependencies: + minipass: ^7.0.4 + rimraf: ^5.0.5 + checksum: da0a53899252380475240c587e52c824f8998d9720982ba5c4693c68e89230718884a209858c156c6e08d51aad35700a3589987e540593c36f6713fe30cd7338 + languageName: node + linkType: hard + "mkdirp@npm:1.0.4, mkdirp@npm:^1.0.3, mkdirp@npm:^1.0.4": version: 1.0.4 resolution: "mkdirp@npm:1.0.4" @@ -12276,6 +12460,15 @@ __metadata: languageName: node linkType: hard +"mkdirp@npm:^3.0.1": + version: 3.0.1 + resolution: "mkdirp@npm:3.0.1" + bin: + mkdirp: dist/cjs/src/bin.js + checksum: 972deb188e8fb55547f1e58d66bd6b4a3623bf0c7137802582602d73e6480c1c2268dcbafbfb1be466e00cc7e56ac514d7fd9334b7cf33e3e2ab547c16f83a8d + languageName: node + linkType: hard + "module-error@npm:^1.0.1, module-error@npm:^1.0.2": version: 1.0.2 resolution: "module-error@npm:1.0.2" @@ -13132,7 +13325,7 @@ __metadata: languageName: node linkType: hard -"pg@npm:^8.11.5": +"pg@npm:^8.12.0": version: 8.12.0 resolution: "pg@npm:8.12.0" dependencies: @@ -13259,9 +13452,10 @@ __metadata: dependencies: "@cosmjs/stargate": ^0.28.9 "@subql/cli": 5.1.1 - "@subql/node-cosmos": 4.0.1 + "@subql/node-cosmos": ^4.1.1 "@subql/testing": 2.2.1 - "@subql/types-cosmos": 3.5.0 + "@subql/types-cosmos": ^3.5.2 + "@types/json-bigint": ^1.0.4 "@types/node": ^22.0.0 "@typescript-eslint/eslint-plugin": ^5.10.2 "@typescript-eslint/parser": ^5.10.2 @@ -13273,6 +13467,8 @@ __metadata: eslint-plugin-jest: ^27.2.3 eslint-plugin-prettier: ^4.0.0 eslint-plugin-sort-destructure-keys: ^1.4.0 + json-bigint: ^1.0.0 + lodash: ^4.17.21 nodemon: ^3.1.4 pino: ^7.8.0 prettier: ^2.5.1 @@ -13413,7 +13609,7 @@ __metadata: languageName: node linkType: hard -"prom-client@npm:^14.0.1, prom-client@npm:^14.1.0": +"prom-client@npm:^14.1.0": version: 14.2.0 resolution: "prom-client@npm:14.2.0" dependencies: @@ -13422,6 +13618,16 @@ __metadata: languageName: node linkType: hard +"prom-client@npm:^15.1.3": + version: 15.1.3 + resolution: "prom-client@npm:15.1.3" + dependencies: + "@opentelemetry/api": ^1.4.0 + tdigest: ^0.1.1 + checksum: 9a57f3c16f39aa9a03da021883a4231c0bb56fc9d02f6ef9c28f913379f275640a5a33b98d9946ebf53c71011a29b580e9d2d6e3806cb1c229a3f59c65993968 + languageName: node + linkType: hard + "promise-retry@npm:^2.0.1": version: 2.0.1 resolution: "promise-retry@npm:2.0.1" @@ -13721,7 +13927,7 @@ __metadata: languageName: node linkType: hard -"reflect-metadata@npm:^0.1.13": +"reflect-metadata@npm:^0.1.13, reflect-metadata@npm:^0.1.14": version: 0.1.14 resolution: "reflect-metadata@npm:0.1.14" checksum: 155ad339319cec3c2d9d84719f730f8b6a6cd2a074733ec29dbae6c89d48a2914c7d07a2350212594f3aae160fa4da4f903e6512f27ceaf968443a7c692bcad0 @@ -13963,6 +14169,17 @@ __metadata: languageName: node linkType: hard +"rimraf@npm:^5.0.5": + version: 5.0.10 + resolution: "rimraf@npm:5.0.10" + dependencies: + glob: ^10.3.7 + bin: + rimraf: dist/esm/bin.mjs + checksum: 50e27388dd2b3fa6677385fc1e2966e9157c89c86853b96d02e6915663a96b7ff4d590e14f6f70e90f9b554093aa5dbc05ac3012876be558c06a65437337bc05 + languageName: node + linkType: hard + "ripemd160@npm:^2.0.0, ripemd160@npm:^2.0.1, ripemd160@npm:^2.0.2": version: 2.0.2 resolution: "ripemd160@npm:2.0.2" @@ -13973,7 +14190,7 @@ __metadata: languageName: node linkType: hard -"rotating-file-stream@npm:^3.0.2": +"rotating-file-stream@npm:^3.0.2, rotating-file-stream@npm:^3.2.3": version: 3.2.3 resolution: "rotating-file-stream@npm:3.2.3" checksum: 9ccfb04ee9763c0c9ddce5aaa93bf17268f3bb672ae3b0f98a2eca718ce5d9d293590df6071386660a75dcb047e259190ed5cacb83090e8bda55ef36848e2e33 @@ -14187,6 +14404,15 @@ __metadata: languageName: node linkType: hard +"semver@npm:^7.6.3": + version: 7.6.3 + resolution: "semver@npm:7.6.3" + bin: + semver: bin/semver.js + checksum: 4110ec5d015c9438f322257b1c51fe30276e5f766a3f64c09edd1d7ea7118ecbc3f379f3b69032bacf13116dc7abc4ad8ce0d7e2bd642e26b0d271b56b61a7d8 + languageName: node + linkType: hard + "send@npm:0.18.0": version: 0.18.0 resolution: "send@npm:0.18.0" @@ -14802,6 +15028,20 @@ __metadata: languageName: node linkType: hard +"tar@npm:^7.4.3": + version: 7.4.3 + resolution: "tar@npm:7.4.3" + dependencies: + "@isaacs/fs-minipass": ^4.0.0 + chownr: ^3.0.0 + minipass: ^7.1.2 + minizlib: ^3.0.1 + mkdirp: ^3.0.1 + yallist: ^5.0.0 + checksum: 8485350c0688331c94493031f417df069b778aadb25598abdad51862e007c39d1dd5310702c7be4a6784731a174799d8885d2fde0484269aea205b724d7b2ffa + languageName: node + linkType: hard + "tdigest@npm:^0.1.1": version: 0.1.2 resolution: "tdigest@npm:0.1.2" @@ -15455,7 +15695,7 @@ __metadata: languageName: node linkType: hard -"update-notifier@npm:5.1.0": +"update-notifier@npm:5.1.0, update-notifier@npm:^5.1.0": version: 5.1.0 resolution: "update-notifier@npm:5.1.0" dependencies: @@ -15983,6 +16223,13 @@ __metadata: languageName: node linkType: hard +"yallist@npm:^5.0.0": + version: 5.0.0 + resolution: "yallist@npm:5.0.0" + checksum: eba51182400b9f35b017daa7f419f434424410691bbc5de4f4240cc830fdef906b504424992700dc047f16b4d99100a6f8b8b11175c193f38008e9c96322b6a5 + languageName: node + linkType: hard + "yaml-loader@npm:^0.6.0": version: 0.6.0 resolution: "yaml-loader@npm:0.6.0" From e4338dc3b0db24ce2d6998ce7e01875492ae9357 Mon Sep 17 00:00:00 2001 From: "Jorge S. Cuesta" Date: Tue, 3 Sep 2024 12:05:20 -0400 Subject: [PATCH 2/2] Add missing semicolons and adjust import quotes Reformatted imports to use consistent double quotes and added missing semicolons across various files for better code consistency and readability. Also updated `.prettierrc` configuration to enforce these styles. --- .prettierrc | 5 +- src/mappings/bank/balanceChange.ts | 12 ++- src/mappings/bank/transfer.ts | 14 +++- src/mappings/constants.ts | 2 +- src/mappings/primitives.ts | 120 ++++++++++++++--------------- src/mappings/types/messages.ts | 2 +- src/mappings/utils.ts | 80 +++++++++---------- 7 files changed, 125 insertions(+), 110 deletions(-) diff --git a/.prettierrc b/.prettierrc index 8ad06aa..e60e02c 100644 --- a/.prettierrc +++ b/.prettierrc @@ -3,5 +3,8 @@ "trailingComma": "es5", "tabWidth": 2, "singleQuote": false, - "bracketSpacing": false + "bracketSpacing": false, + "semi": true, + "quoteProps": "consistent", + "jsxSingleQuote": false } diff --git a/src/mappings/bank/balanceChange.ts b/src/mappings/bank/balanceChange.ts index 59a2de9..531a8d4 100644 --- a/src/mappings/bank/balanceChange.ts +++ b/src/mappings/bank/balanceChange.ts @@ -1,24 +1,27 @@ import {CosmosEvent} from "@subql/types-cosmos"; import {parseCoins} from "../../cosmjs/utils"; -import {NativeBalanceChange, Transaction} from "../../types"; +import { + NativeBalanceChange, + Transaction, +} from "../../types"; import { attemptHandling, checkBalancesAccount, messageId, stringify, unprocessedEventHandler, -} from '../utils' +} from "../utils"; export async function saveNativeBalanceEvent(id: string, address: string, amount: bigint, denom: string, event: CosmosEvent): Promise { await checkBalancesAccount(address, event.block.block.header.chainId); - let eventId + let eventId; if (event.tx) { eventId = `${messageId(event)}-${event.idx}`; } else { eventId = `${event.block.blockId}-${event.idx}`; } - + const nativeBalanceChangeEntity = NativeBalanceChange.create({ id, balanceOffset: amount.valueOf(), @@ -32,6 +35,7 @@ export async function saveNativeBalanceEvent(id: string, address: string, amount await nativeBalanceChangeEntity.save(); } +// eslint-disable-next-line @typescript-eslint/no-unused-vars async function saveNativeFeesEvent(event: CosmosEvent) { const transaction = await Transaction.get(event.tx.hash); if (!transaction) { diff --git a/src/mappings/bank/transfer.ts b/src/mappings/bank/transfer.ts index 1f8c513..025c990 100644 --- a/src/mappings/bank/transfer.ts +++ b/src/mappings/bank/transfer.ts @@ -1,7 +1,15 @@ -import {CosmosEvent, CosmosMessage} from "@subql/types-cosmos"; +import { + CosmosEvent, + CosmosMessage, +} from "@subql/types-cosmos"; import {NativeTransfer} from "../../types"; import {NativeTransferMsg} from "../types"; -import {attemptHandling, messageId, unprocessedEventHandler, stringify} from "../utils"; +import { + attemptHandling, + messageId, + stringify, + unprocessedEventHandler, +} from "../utils"; export async function handleNativeTransfer(event: CosmosEvent): Promise { await attemptHandling(event, _handleNativeTransfer, unprocessedEventHandler); @@ -34,7 +42,7 @@ async function _handleNativeTransfer(event: CosmosEvent): Promise { // timeline, messageId: id, transactionId: msg.tx.hash, - blockId: msg.block.block.id + blockId: msg.block.block.id, }); await transferEntity.save(); diff --git a/src/mappings/constants.ts b/src/mappings/constants.ts index 900c18e..3e3f781 100644 --- a/src/mappings/constants.ts +++ b/src/mappings/constants.ts @@ -1 +1 @@ -const PREFIX = "poktroll" +export const PREFIX = "poktroll"; diff --git a/src/mappings/primitives.ts b/src/mappings/primitives.ts index 5d7e20b..82e0f70 100644 --- a/src/mappings/primitives.ts +++ b/src/mappings/primitives.ts @@ -1,15 +1,15 @@ -import { createHash } from 'crypto' -import { toBech32 } from '@cosmjs/encoding' +import {createHash} from "crypto"; +import {toBech32} from "@cosmjs/encoding"; import { CosmosBlock, CosmosEvent, CosmosMessage, CosmosTransaction, -} from '@subql/types-cosmos' +} from "@subql/types-cosmos"; import { isEmpty, isString, -} from 'lodash' +} from "lodash"; import { Block, Event, @@ -17,7 +17,7 @@ import { Message, Transaction, TxStatus, -} from '../types' +} from "../types"; import { attemptHandling, messageId, @@ -27,72 +27,72 @@ import { stringify, trackUnprocessed, unprocessedEventHandler, -} from './utils' +} from "./utils"; export async function handleBlock(block: CosmosBlock): Promise { - await attemptHandling(block, _handleBlock, _handleBlockError) + await attemptHandling(block, _handleBlock, _handleBlockError); } export async function handleTransaction(tx: CosmosTransaction): Promise { - await attemptHandling(tx, _handleTransaction, _handleTransactionError) + await attemptHandling(tx, _handleTransaction, _handleTransactionError); } export async function handleMessage(msg: CosmosMessage): Promise { - await attemptHandling(msg, _handleMessage, _handleMessageError) + await attemptHandling(msg, _handleMessage, _handleMessageError); } export async function handleEvent(event: CosmosEvent): Promise { - await attemptHandling(event, _handleEvent, unprocessedEventHandler) + await attemptHandling(event, _handleEvent, unprocessedEventHandler); } async function _handleBlock(block: CosmosBlock): Promise { - logger.info(`[handleBlock] (block.header.height): indexing block ${block.block.header.height}`) + logger.info(`[handleBlock] (block.header.height): indexing block ${block.block.header.height}`); - const { header: { chainId, height, time }, id } = block.block - const timestamp = new Date(time.getTime()) + const {header: {chainId, height, time}, id} = block.block; + const timestamp = new Date(time.getTime()); const blockEntity = Block.create({ id, chainId, height: BigInt(height), timestamp, - }) + }); - await blockEntity.save() + await blockEntity.save(); } async function _handleTransaction(tx: CosmosTransaction): Promise { - logger.info(`[handleTransaction] (block ${tx.block.block.header.height}): indexing transaction ${tx.idx + 1} / ${tx.block.txs.length}`) + logger.info(`[handleTransaction] (block ${tx.block.block.header.height}): indexing transaction ${tx.idx + 1} / ${tx.block.txs.length}`); logger.debug(`[handleTransaction] (tx.tx.log): ${tx.tx.log}`); - let status = TxStatus.Error + let status = TxStatus.Error; if (tx.tx.log) { try { - parseJson(tx.tx.log) - status = TxStatus.Success + parseJson(tx.tx.log); + status = TxStatus.Success; } catch { // NB: assume tx failed } } // const timeline = BigInt((tx.block.block.header.height * 100000) + tx.idx); - const pubKey: Uint8Array | undefined = tx.decodedTx.authInfo.signerInfos[0]?.publicKey?.value - let signerAddress - if (typeof (pubKey) !== 'undefined') { + const pubKey: Uint8Array | undefined = tx.decodedTx.authInfo.signerInfos[0]?.publicKey?.value; + let signerAddress; + if (typeof (pubKey) !== "undefined") { // TODO: check key type and handle respectively // NB: ripemd160(sha256(pubKey)) only works for secp256k1 keys - const ripemd160 = createHash('ripemd160') - const sha256 = createHash('sha256') + const ripemd160 = createHash("ripemd160"); + const sha256 = createHash("sha256"); // TODO: understand why!!! // NB: pubKey has 2 "extra" bytes at the beginning as compared to the // base64-decoded representation/ of the same key when imported to // fetchd (`fetchd keys add --recover`) and shown (`fetchd keys show`). - sha256.update(pubKey.slice(2)) - ripemd160.update(sha256.digest()) - signerAddress = toBech32(PREFIX, ripemd160.digest()) + sha256.update(pubKey.slice(2)); + ripemd160.update(sha256.digest()); + signerAddress = toBech32(PREFIX, ripemd160.digest()); } - const feeAmount = typeof (tx.decodedTx.authInfo.fee) !== 'undefined' ? - tx.decodedTx.authInfo.fee.amount : [] + const feeAmount = typeof (tx.decodedTx.authInfo.fee) !== "undefined" ? + tx.decodedTx.authInfo.fee.amount : []; const txEntity = Transaction.create({ id: tx.hash, @@ -103,27 +103,27 @@ async function _handleTransaction(tx: CosmosTransaction): Promise { memo: tx.decodedTx.body.memo, timeoutHeight: tx.decodedTx.body.timeoutHeight, fees: feeAmount, - log: tx.tx.log || '', + log: tx.tx.log || "", status, signerAddress, - }) - await txEntity.save() + }); + await txEntity.save(); } async function _handleMessage(msg: CosmosMessage): Promise { - if (msg.tx.hash === 'E5F4CAB95F9DF7642E89067FA3F736F37FA8DC06CAD0D40AC1BD16525836387C') { + if (msg.tx.hash === "E5F4CAB95F9DF7642E89067FA3F736F37FA8DC06CAD0D40AC1BD16525836387C") { try { - logger.info(`[handleMessage] (try) ${stringify(msg)}`) + logger.info(`[handleMessage] (try) ${stringify(msg)}`); } catch (e) { - logger.error(e, `[handleMessage] (catch) ${msg}`) + logger.error(e, `[handleMessage] (catch) ${msg}`); } } - logger.info(`[handleMessage] (tx ${msg.tx.hash}): indexing message ${msg.idx + 1} / ${msg.tx.decodedTx.body.messages.length}`) - logger.debug(`[handleMessage] (msg.msg): ${stringify(msg.msg)}`) + logger.info(`[handleMessage] (tx ${msg.tx.hash}): indexing message ${msg.idx + 1} / ${msg.tx.decodedTx.body.messages.length}`); + logger.debug(`[handleMessage] (msg.msg): ${stringify(msg.msg)}`); // const timeline = getTimeline(msg); - delete msg.msg?.decodedMsg?.wasmByteCode - const json = stringify(msg.msg.decodedMsg) + delete msg.msg?.decodedMsg?.wasmByteCode; + const json = stringify(msg.msg.decodedMsg); const msgEntity = Message.create({ id: messageId(msg), typeUrl: msg.msg.typeUrl, @@ -131,37 +131,37 @@ async function _handleMessage(msg: CosmosMessage): Promise { // timeline, transactionId: msg.tx.hash, blockId: msg.block.block.id, - }) + }); - await msgEntity.save() + await msgEntity.save(); } async function _handleEvent(event: CosmosEvent): Promise { // TODO: generate an ID that will match on the event.event.type source depending on what type is. if (!isEmpty(event.tx.hash)) { - logger.info(`[handleEvent] (tx ${event.tx.hash}): indexing event ${event.idx + 1} / ${event.tx.tx.events.length}`) + logger.info(`[handleEvent] (tx ${event.tx.hash}): indexing event ${event.idx + 1} / ${event.tx.tx.events.length}`); } else { - logger.info(`[handleEvent]: indexing event ${event.idx + 1} / ${event.tx.tx.events.length}`) + logger.info(`[handleEvent]: indexing event ${event.idx + 1} / ${event.tx.tx.events.length}`); } - let id + let id; if (event.tx) { - id = `${messageId(event)}-${event.idx}` + id = `${messageId(event)}-${event.idx}`; } else { - id = `${event.block.blockId}-${event.idx}` + id = `${event.block.blockId}-${event.idx}`; } // NB: sanitize attribute values (may contain non-text characters) const sanitize = (value: unknown): string => { // avoid stringify an string - if (isString(value)) return value + if (isString(value)) return value; // otherwise return it as a stringifies object - return stringify(value) - } + return stringify(value); + }; const attributes = event.event.attributes.map((attribute) => { - const { key, value } = attribute - return { key, value: sanitize(value) } - }) + const {key, value} = attribute; + return {key, value: sanitize(value)}; + }); logger.debug(`[handleEvent] (event.event): ${stringify(event.event, undefined, 2)}`); logger.debug(`[handleEvent] (event.log): ${stringify(event.log, undefined, 2)}`); @@ -173,31 +173,31 @@ async function _handleEvent(event: CosmosEvent): Promise { // sourceId: event // transactionId: event.tx.hash, blockId: event.block.block.id, - }) - await eventEntity.save() + }); + await eventEntity.save(); for (const [i, attribute] of Object.entries(attributes)) { - const attrId = `${id}-${i}` - const { key, value } = attribute + const attrId = `${id}-${i}`; + const {key, value} = attribute; await EventAttribute.create({ id: attrId, key: key as string, value, eventId: eventEntity.id, - }).save() + }).save(); } } // eslint-disable-next-line @typescript-eslint/no-unused-vars async function _handleBlockError(err: Error, _: CosmosBlock): Promise { // NB: we won't have persisted any related entities yet. - await trackUnprocessed(err, {}) + await trackUnprocessed(err, {}); } async function _handleTransactionError(err: Error, tx: CosmosTransaction): Promise { - await trackUnprocessed(err, primitivesFromTx(tx)) + await trackUnprocessed(err, primitivesFromTx(tx)); } async function _handleMessageError(err: Error, msg: CosmosMessage): Promise { - await trackUnprocessed(err, primitivesFromMsg(msg)) + await trackUnprocessed(err, primitivesFromMsg(msg)); } diff --git a/src/mappings/types/messages.ts b/src/mappings/types/messages.ts index c33fe2c..209eda2 100644 --- a/src/mappings/types/messages.ts +++ b/src/mappings/types/messages.ts @@ -23,7 +23,7 @@ export interface DistDelegatorClaimMsg { validatorAddress: string; } -export interface LegacyBridgeSwapMsg extends ExecuteContractMsg{ +export interface LegacyBridgeSwapMsg extends ExecuteContractMsg { msg: { swap: { destination: string, diff --git a/src/mappings/utils.ts b/src/mappings/utils.ts index 0089427..94b4686 100644 --- a/src/mappings/utils.ts +++ b/src/mappings/utils.ts @@ -1,15 +1,15 @@ -import { createHash } from 'crypto' +import {createHash} from "crypto"; import { CosmosBlock, CosmosEvent, CosmosMessage, CosmosTransaction, -} from '@subql/types-cosmos' -import { default as JSONBig } from 'json-bigint' +} from "@subql/types-cosmos"; +import {default as JSONBig} from "json-bigint"; import { Account, UnprocessedEntity, -} from '../types' +} from "../types"; export type Primitive = CosmosEvent | CosmosMessage | CosmosTransaction | CosmosBlock; @@ -21,36 +21,36 @@ export interface Primitives { } export function parseJson(str: string, reviver?: (this: unknown, key: string, value: unknown) => unknown): T { - return JSONBig.parse(str, reviver) as T + return JSONBig.parse(str, reviver) as T; } export function stringify(value: unknown, replacer?: (this: unknown, key: string, value: unknown) => unknown, space?: string | number): string { - return JSONBig.stringify(value, replacer, space) + return JSONBig.stringify(value, replacer, space); } // messageId returns the id of the message passed or // that of the message which generated the event passed. export function messageId(msg: CosmosMessage | CosmosEvent): string { - return `${msg.tx.hash}-${msg.idx}` + return `${msg.tx.hash}-${msg.idx}`; } export async function checkBalancesAccount(address: string, chainId: string): Promise { - let accountEntity = await Account.get(address) - if (typeof (accountEntity) === 'undefined') { - accountEntity = Account.create({ id: address, chainId }) - await accountEntity.save() + let accountEntity = await Account.get(address); + if (typeof (accountEntity) === "undefined") { + accountEntity = Account.create({id: address, chainId}); + await accountEntity.save(); } } export function getTimeline(entity: CosmosMessage | CosmosEvent): bigint { - const K2 = 100, K1 = K2 * 1000 - const txIndex = entity.tx.idx - const blockHeight = entity.block.block.header.height + const K2 = 100, K1 = K2 * 1000; + const txIndex = entity.tx.idx; + const blockHeight = entity.block.block.header.height; // check if the entity is an Event or a Message and set msgIndex appropriately const msgIndex = (entity).msg?.idx === undefined ? - (entity).idx : (entity).msg.idx - const timeline = (K1 * blockHeight) + (K2 * txIndex) + msgIndex - return BigInt(timeline) + (entity).idx : (entity).msg.idx; + const timeline = (K1 * blockHeight) + (K2 * txIndex) + msgIndex; + return BigInt(timeline); } export async function attemptHandling(input: Primitive, @@ -59,64 +59,64 @@ export async function attemptHandling(input: Primitive, // eslint-disable-next-line @typescript-eslint/no-explicit-any errorFn: (Error: Error, Primitive: any) => Promise | void): Promise { try { - await handlerFn(input) + await handlerFn(input); } catch (error: unknown) { - await errorFn(error as Error, input) + await errorFn(error as Error, input); } } export async function unprocessedEventHandler(err: Error, event: CosmosEvent): Promise { - await trackUnprocessed(err, primitivesFromEvent(event)) + await trackUnprocessed(err, primitivesFromEvent(event)); } export function primitivesFromTx(tx: CosmosTransaction): Primitives { - return { block: tx.block, tx: tx } + return {block: tx.block, tx: tx}; } export function primitivesFromMsg(msg: CosmosMessage): Primitives { - return { block: msg.block, tx: msg.tx } + return {block: msg.block, tx: msg.tx}; } export function primitivesFromEvent(event: CosmosEvent): Primitives { - return { block: event.block, tx: event.tx } + return {block: event.block, tx: event.tx}; } export async function trackUnprocessed(error: Error, primitives: Primitives): Promise { - logger.warn(`[trackUnprocessable] (error.message): ${error.message}`) - logger.warn(`[trackUnprocessable] (error.stack): ${error.stack}`) + logger.warn(`[trackUnprocessable] (error.message): ${error.message}`); + logger.warn(`[trackUnprocessable] (error.stack): ${error.stack}`); // NB: failsafe try/catch try { - const { block, event, msg, tx } = primitives - const sha256 = createHash('sha256') + const {block, event, msg, tx} = primitives; + const sha256 = createHash("sha256"); // NB: use error stack if no primitives available (i.e. block handler). const hashInput = event ? (event.tx ? messageId(event) : `${event.block.blockId}-${event.idx}`) : msg ? // messageId(event) : msg ? messageId(msg) : tx ? tx.hash : block ? - block.block.id : error.stack - sha256.write(hashInput) - sha256.end() + block.block.id : error.stack; + sha256.write(hashInput); + sha256.end(); // NB: ID is a base64 encoded representation of the sha256 of either: // 1. the conventional ID of the "highest-level" primitive available or // 2. the error stacktrace, if none are available (i.e., handle block error) - const id = sha256.read().toString('base64') - const eventId = event ? messageId(event) : undefined - const _messageId = event ? messageId(event) : undefined - const transactionId = tx ? tx.hash : undefined - const blockId = block ? block.block.id : '' + const id = sha256.read().toString("base64"); + const eventId = event ? messageId(event) : undefined; + const _messageId = event ? messageId(event) : undefined; + const transactionId = tx ? tx.hash : undefined; + const blockId = block ? block.block.id : ""; const unprocessedEntity = UnprocessedEntity.create({ id, - error: error.stack || '', + error: error.stack || "", eventId, messageId: _messageId, transactionId, blockId: blockId, - }) - return await unprocessedEntity.save() + }); + return await unprocessedEntity.save(); } catch { - logger.error('[trackUnprocessable] (ERROR): unable to persist unprocessable entity') - logger.error(`[trackUnprocessable] (ERROR | stack): ${error.stack}`) + logger.error("[trackUnprocessable] (ERROR): unable to persist unprocessable entity"); + logger.error(`[trackUnprocessable] (ERROR | stack): ${error.stack}`); } }