Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# This file is auto-generated from Ignite. You can edit
# the file content but do not change the file name or path.
#
# buf.gen.ts.yaml
#
version: v2
clean: true
managed:
enabled: true
inputs:
- module: buf.build/gogo/protobuf
- module: buf.build/cosmos/cosmos-proto
- module: buf.build/cosmos/cosmos-sdk
- git_repo: https://github.com/pokt-network/poktroll.git
branch: main
subdir: proto
plugins:
- remote: buf.build/community/stephenh-ts-proto
out: ./src/client
opt:
- logtostderr=true
- allow_merge=true
- json_names_for_fields=false
- ts_proto_opt=snakeToCamel=true
- ts_proto_opt=esModuleInterop=true
- ts_proto_out=.
1 change: 0 additions & 1 deletion docker/postgres/load-extensions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<EOF
CREATE EXTENSION IF NOT EXISTS btree_gist;
CREATE EXTENSION IF NOT EXISTS pg_stat_statements;
CREATE EXTENSION IF NOT EXISTS system_stats;
EOF
10 changes: 5 additions & 5 deletions docker/postgres/pg.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ RUN apk add --no-cache --virtual .build-deps \
curl

# Clone, build, and install system_stats extension
RUN git clone https://github.com/EnterpriseDB/system_stats.git /tmp/system_stats && \
cd /tmp/system_stats && \
PATH="/usr/local/pgsql/bin:$PATH" make USE_PGXS=1 && \
PATH="/usr/local/pgsql/bin:$PATH" make install USE_PGXS=1 && \
cd .. && rm -rf /tmp/system_stats
#RUN git clone https://github.com/EnterpriseDB/system_stats.git /tmp/system_stats && \
# cd /tmp/system_stats && \
# PATH="/usr/local/pgsql/bin:$PATH" make USE_PGXS=1 && \
# PATH="/usr/local/pgsql/bin:$PATH" make install USE_PGXS=1 && \
# cd .. && rm -rf /tmp/system_stats

# Copy in the load-extensions script
COPY docker/postgres/load-extensions.sh /docker-entrypoint-initdb.d/
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"poktroll:proxy:start": "./scripts/proxy-tunnel.sh start",
"poktroll:proxy:stop": "./scripts/proxy-tunnel.sh stop",
"poktroll:update-proto-files": "scripts/copy-poktroll-files.sh",
"poktroll:generate-ts-from-proto": "buf generate",
"docker:check-env:production": "env sh ./scripts/dotenv-check.sh production",
"docker:build:production": "yarn run docker:compose production build",
"docker:build:no-cache:production": "yarn run docker:compose production build --no-cache",
Expand Down
1 change: 1 addition & 0 deletions proto/pocket/application/event.proto
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import "pocket/application/types.proto";
enum ApplicationUnbondingReason {
APPLICATION_UNBONDING_REASON_ELECTIVE = 0;
APPLICATION_UNBONDING_REASON_BELOW_MIN_STAKE = 1;
APPLICATION_UNBONDING_REASON_MIGRATION = 2;
}

// EventApplicationStaked is emitted when an application is staked or up-staked.
Expand Down
40 changes: 27 additions & 13 deletions proto/pocket/application/types.proto
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// 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.
// TODO_AUTOMATE: Add a CI workflow that automatically detects .proto files with names incompatible with the package name (e.g., files named exactly as the package, like "application.proto").
// NB: This file CANNOT be named "application.proto" due to an unresolved issue in how cosmos-proto generates the pulsar plugin output Go source code.
// See: https://github.com/pokt-network/poktroll/issues/XXX for tracking and future resolution.

syntax = "proto3";
package pocket.application;
Expand All @@ -23,23 +23,24 @@ message Application {
cosmos.base.v1beta1.Coin stake = 2;

// CRITICAL: Must contain EXACTLY ONE service config
// This prevents applications from over-servicing.
// Kept as repeated field for legacy and future compatibility
// Refs:
// - Enforces a single service configuration per application to prevent over-servicing.
// - Field is repeated for legacy reasons and potential future compatibility.
// - References for rationale:
// - https://github.com/pokt-network/poktroll/pull/750#discussion_r1735025033
// - https://www.notion.so/buildwithgrove/Off-chain-Application-Stake-Tracking-6a8bebb107db4f7f9dc62cbe7ba555f7
repeated pocket.shared.ApplicationServiceConfig service_configs = 3;

// TODO_MAINNET_MIGRATION(@bryanchriswhite): Rename `delegatee_gateway_addresses` to `gateway_addresses_delegated_to`.
// Ensure to rename all relevant configs, comments, variables, function names, etc as well.
// Non-nullable list of Bech32 encoded delegatee Gateway addresses
// TODO_MAINNET_MIGRATION(@bryanchriswhite): Rename `delegatee_gateway_addresses` to `gateway_addresses_delegated_to` for better clarity and consistency.
// - Update all related configs, comments, variables, and function names throughout the codebase to reflect this change.
// - This field is a non-nullable list of Bech32-encoded delegatee Gateway addresses.
repeated string delegatee_gateway_addresses = 4 [(cosmos_proto.scalar) = "cosmos.AddressString", (gogoproto.nullable) = false];

// Mapping of session end heights to gateways being undelegated from
// - Key: Height of the last block of the session when undelegation tx was committed
// - Value: 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.
// - Key: Height of the last block of the session when the undelegation transaction was committed
// - Value: List of gateways being undelegated from at that session end height
// TODO_DOCUMENT(@red-0ne): Document the complete flow and rationale behind this mapping.
// - Ensure the documentation explains why tracking pending undelegations by session end height is necessary.
// - See: https://github.com/pokt-network/poktroll/issues/476#issuecomment-2052639906 for context and examples.
map<uint64, UndelegatingGatewayList> pending_undelegations = 5 [(gogoproto.nullable) = false];

// Session end height when application initiated unstaking (0 if not unstaking)
Expand All @@ -61,3 +62,16 @@ message PendingApplicationTransfer {
string destination_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
uint64 session_end_height = 2;
}

// Undelegation represents a connection between an application and a gateway that
// is in the process of being removed.
//
// This record is stored in the undelegation index
// and used to track and process pending undelegations after the unbonding period has elapsed.
message PendingUndelegation {
// Address of the application that is undelegating from the gateway.
string application_address = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];

// Address of the gateway that the application is undelegating from.
string gateway_address = 2 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
}
2 changes: 1 addition & 1 deletion proto/pocket/gateway/event.proto
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ message EventGatewayUnbondingCanceled {
pocket.gateway.Gateway gateway = 1 [(gogoproto.jsontag) = "gateway"];
// The end height of the session in which the unbonding was canceled.
int64 session_end_height = 2 [(gogoproto.jsontag) = "session_end_height"];
}
}
105 changes: 79 additions & 26 deletions proto/pocket/migration/event.proto
Original file line number Diff line number Diff line change
Expand Up @@ -13,68 +13,121 @@ import "pocket/migration/morse_onchain.proto";
import "pocket/application/types.proto";
import "pocket/shared/supplier.proto";

// EventImportMorseClaimableAccounts is emitted when the MorseClaimableAccounts are created on-chain.
// EventImportMorseClaimableAccounts
// - Emitted when MorseClaimableAccounts are created on-chain
// - Represents import event for Morse claimable accounts
message EventImportMorseClaimableAccounts {
// The height (on Shannon) at which the MorseAccountState was created on-chain.
// Shannon height at which MorseAccountState was created on-chain
int64 created_at_height = 1 [(gogoproto.jsontag) = "created_at_height"];

// The onchain computed sha256 hash of the entire MorseAccountState containing the MorseClaimableAccounts which were imported.
// On-chain computed sha256 hash of the MorseAccountState
// - Contains all imported MorseClaimableAccounts
bytes morse_account_state_hash = 2 [(gogoproto.jsontag) = "morse_account_state_hash"];

// Number of claimable accounts (EOAs) collected from Morse state export
// NOTE: Account balances include consolidated application and supplier actor stakes
// Number of claimable accounts (EOAs) imported from Morse state export
// - Account balances include consolidated application and supplier actor stakes
uint64 num_accounts = 3 [(gogoproto.jsontag) = "num_accounts"];
}

// EventMorseAccountClaimed is emitted when a MorseAccount is claimed on-chain.
// EventMorseAccountClaimed
// - Emitted when a MorseAccount is claimed on-chain
message EventMorseAccountClaimed {
// The session end height (on Shannon) in which the claim was committed (i.e. claimed).
// Shannon session end height in which the claim was committed
int64 session_end_height = 1 [(gogoproto.jsontag) = "session_end_height"];

// The unstaked balance which was claimed.
// Unstaked balance claimed from Morse
cosmos.base.v1beta1.Coin claimed_balance = 2 [(gogoproto.jsontag) = "claimed_balance", (gogoproto.nullable) = false];

// The bech32-encoded address of the Shannon account to which the claimed balance will be minted.
// bech32-encoded Shannon address to mint claimed balance
string shannon_dest_address = 3 [(cosmos_proto.scalar) = "cosmos.AddressString", (gogoproto.jsontag) = "shannon_dest_address"];

// The hex-encoded address of the Morse account whose balance will be claimed.
// Hex-encoded Morse account address whose balance was claimed
string morse_src_address = 4 [(gogoproto.jsontag) = "morse_src_address"];
}

// EventMorseApplicationClaimed is emitted when a MorseAccount is claimed on-chain as a staked application.
// EventMorseApplicationClaimed
// - Emitted when a MorseAccount is claimed on-chain as a staked application
message EventMorseApplicationClaimed {
// The session end height (on Shannon) in which the claim was committed (i.e. claimed).
// Shannon session end height in which the claim was committed
int64 session_end_height = 1 [(gogoproto.jsontag) = "session_end_height"];

// The unstaked balance which was claimed.
// Unstaked balance claimed from Morse
cosmos.base.v1beta1.Coin claimed_balance = 2 [(gogoproto.jsontag) = "claimed_balance", (gogoproto.nullable) = false];

// The hex-encoded address of the Morse account whose balance will be claimed.
// Hex-encoded Morse account address whose balance was claimed
string morse_src_address = 3 [(gogoproto.jsontag) = "morse_src_address"];

// The stake of the application which was staked as a result of the claim.
// Application stake claimed as a result of the claim
// - Equivalent to Morse application staked amount
cosmos.base.v1beta1.Coin claimed_application_stake = 4 [(gogoproto.nullable) = false, (gogoproto.jsontag) = "claimed_application_stake"];

// The application which was staked as a result of the claim.
// This is equivalent to the amount it had staked on Morse.
// Application staked as a result of the claim
// - Mirrors Morse application stake
application.Application application = 5 [(gogoproto.jsontag) = "application"];
}

// EventMorseSupplierClaimed is emitted when a MorseAccount is claimed on-chain as a staked Supplier.
// EventMorseSupplierClaimed
// - Emitted when a MorseAccount is claimed on-chain as a staked Supplier
message EventMorseSupplierClaimed {
// The session end height (on Shannon) in which the claim was committed (i.e. claimed).
// Next free index: 9
reserved 3;

// Shannon session end height in which the claim was committed
int64 session_end_height = 1 [(gogoproto.jsontag) = "session_end_height"];

// The unstaked balance which was claimed.
// Unstaked balance claimed from Morse
cosmos.base.v1beta1.Coin claimed_balance = 2 [(gogoproto.jsontag) = "claimed_balance", (gogoproto.nullable) = false];

// The hex-encoded address of the Morse account whose balance will be claimed.
string morse_src_address = 3 [(gogoproto.jsontag) = "morse_src_address"];

// The stake of the Supplier which was staked as a result of the claim.
// This will be equivalent to the amount it had staked on Morse.
// The hex-encoded address of the Morse non-custodial (i.e. operator) account.
// - Unstaked balance was migrated 1:1
// - Stake was migrated 1:1 from morse_node_address to shannon_operator_address
// - Morse non-custodial (i.e. operator) address.
// If morse_output_address was not set, this is the custodial address.
// - See 'pocket nodes --help' for more information. Note that this refers to the Morse CLI.
// E.g.: 00f9900606fa3d5c9179fc0c8513078a53a2073e
string morse_node_address = 8 [(gogoproto.jsontag) = "morse_node_address"];

// ONLY applicable to Morse node/supplier accounts.
// Hex-encoded address of the Morse output account/wallet associated with the Morse node/supplier.
// - E.g.: 00f9900606fa3d5c9179fc0c8513078a53a2073e
// - Morse custodial (i.e. owner) address, which owned the staked tokens of the operator.
// See 'pocket nodes --help' for more information. Note that this refers to the Morse CLI.
string morse_output_address = 6 [(gogoproto.jsontag) = "morse_output_address"];

// The type of supplier claim signer, indicating which actor executed the claim
// and whether it was a custodial or non-custodial claim.
// - MORSE_SUPPLIER_CLAIM_SIGNER_TYPE_NON_CUSTODIAL_SIGNED_BY_ADDR
// - MORSE_SUPPLIER_CLAIM_SIGNER_TYPE_CUSTODIAL_SIGNED_BY_OPERATOR
// - MORSE_SUPPLIER_CLAIM_SIGNER_TYPE_CUSTODIAL_SIGNED_BY_OWNER
MorseSupplierClaimSignerType claim_signer_type = 7 [(gogoproto.jsontag) = "claim_signer_type"];

// Supplier stake claimed as a result of the claim
// - Equivalent to Morse supplier staked amount
cosmos.base.v1beta1.Coin claimed_supplier_stake = 4 [(gogoproto.nullable) = false, (gogoproto.jsontag) = "claimed_supplier_stake"];

// The Supplier which was staked as a result of the claim.
// Supplier staked as a result of the claim
// - Mirrors Morse supplier stake
shared.Supplier supplier = 5 [(gogoproto.jsontag) = "supplier"];
}

// EventMorseAccountRecovered
// - Emitted when a Morse account is recovered on-chain
message EventMorseAccountRecovered {
// The session end height (on Shannon) in which the recovery was committed (i.e. claimed).
int64 session_end_height = 1 [(gogoproto.jsontag) = "session_end_height"];

// The total balance which was recovered:
// - Includes both unstaked and staked balances (consolidated)
// - Auto-liquidates both unstaked and staked balances at once
cosmos.base.v1beta1.Coin recovered_balance = 2 [(gogoproto.jsontag) = "recovered_balance", (gogoproto.nullable) = false];

// The bech32-encoded address of the Shannon account to which the recovered balance was minted.
string shannon_dest_address = 3 [(cosmos_proto.scalar) = "cosmos.AddressString", (gogoproto.jsontag) = "shannon_dest_address"];

// The hex-encoded address of the Morse account whose balance and stakes have been recovered.
// This address MUST be in the recovery allow list and could be of types such as:
// - Unreachable/Locked EOA, Supplier or Application address
// - Module account
// - Invalid address (too short, too long, or non-hexadecimal format)
string morse_src_address = 4 [(gogoproto.jsontag) = "morse_src_address"];
}
2 changes: 1 addition & 1 deletion proto/pocket/migration/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ option (gogoproto.stable_marshaler_all) = true;

// GenesisState defines the migration module's genesis state.
message GenesisState {

// params defines all the parameters of the module.
Params params = 1 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
repeated MorseClaimableAccount morseClaimableAccountList = 2 [(gogoproto.nullable) = false] ;
Expand Down
Loading
Loading