From 8a9430d43145a397f134ffa7030ad17c10f308ae Mon Sep 17 00:00:00 2001 From: Maxime Beauchamp <15185355+baktun14@users.noreply.github.com> Date: Fri, 24 Jan 2025 10:42:36 -0500 Subject: [PATCH 01/27] feat(dx): added new queries to the example queries --- doc/Example_Queries.md | 140 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 139 insertions(+), 1 deletion(-) diff --git a/doc/Example_Queries.md b/doc/Example_Queries.md index 63d4c24dc..3fed0eb69 100644 --- a/doc/Example_Queries.md +++ b/doc/Example_Queries.md @@ -179,4 +179,142 @@ INNER JOIN "deployment" ON "deployment".id = "message"."relatedDeploymentId" WHERE "owner" = '' AND "dseq"='' ORDER BY "height" DESC ``` -![Get all messages related to a deployment](./get-all-messages-related-to-a-deployment.png) \ No newline at end of file +![Get all messages related to a deployment](./get-all-messages-related-to-a-deployment.png) + +## Get the total amount of total leases, akt spent, usdc spent and usd spent per address sorted by total leases + +You can also filter for only gpu leases by adding `WHERE l."gpuUnits" > 0` to the `active_lease` query + +``` +WITH current_block AS ( + SELECT MAX(height) as height + FROM block +), +active_leases AS ( + SELECT + l.id, + l.owner, + l.denom, + l.price, + l."createdHeight", + LEAST((SELECT height FROM current_block), COALESCE(l."closedHeight" ,l."predictedClosedHeight")) as end_height, + d."aktPrice" + FROM lease l + INNER JOIN block b ON b.height = l."createdHeight" + INNER JOIN day d ON d.id = b."dayId" +), +lease_costs AS ( + SELECT + owner, + ROUND(CAST(SUM(CASE + WHEN denom = 'uakt' + THEN (end_height - "createdHeight") * price / 1000000.0 + ELSE 0 + END) as numeric), 2) as total_akt_spent, + ROUND(CAST(SUM(CASE + WHEN denom = 'uusdc' + THEN (end_height - "createdHeight") * price / 1000000.0 + ELSE 0 + END) as numeric), 2) as total_usdc_spent, + ROUND(CAST(SUM(CASE + WHEN denom = 'uakt' + THEN (end_height - "createdHeight") * price * "aktPrice" / 1000000.0 + WHEN denom = 'uusdc' + THEN (end_height - "createdHeight") * price / 1000000.0 + ELSE 0 + END) as numeric), 2) as total_usd_spent + FROM active_leases + GROUP BY owner +) +SELECT + al.owner, + COUNT(DISTINCT al.id) as active_lease_count, + COALESCE(lc.total_akt_spent, 0.00) as total_akt_spent, + COALESCE(lc.total_usdc_spent, 0.00) as total_usdc_spent, + COALESCE(lc.total_usd_spent, 0.00) as total_usd_spent +FROM active_leases al +LEFT JOIN lease_costs lc ON lc.owner = al.owner +GROUP BY + al.owner, + lc.total_akt_spent, + lc.total_usdc_spent, + lc.total_usd_spent +ORDER BY active_lease_count DESC; +``` + + +## Cross database queries from chain-db (indexer) and user db + +User db stores the addresses of the managed wallet users and if we want to query the indexer db to compute amount spent, we need to do a cross database query. + +This query will fetch the sum of all spent for all the users per day. + +``` +-- First, enable postgres_fdw extension in both databases +CREATE EXTENSION postgres_fdw; + +-- In the user db database, create the foreign server connection to the chain database +CREATE SERVER chain_db + FOREIGN DATA WRAPPER postgres_fdw + OPTIONS (host 'localhost', port '5432', dbname 'console-akash'); + +-- Create user mapping +CREATE USER MAPPING FOR CURRENT_USER + SERVER chain_db + OPTIONS (user 'postgres', password 'your_password'); + +IMPORT FOREIGN SCHEMA public + LIMIT TO (lease, block, day) + FROM SERVER chain_db + INTO public; + +-- Create foreign tables for the tables we need +CREATE FOREIGN TABLE chain_lease ( + id uuid, + owner character varying(255), + denom character varying(255), + price double precision, + "createdHeight" integer, + "closedHeight" integer, + "predictedClosedHeight" numeric(30,0) +) SERVER chain_db +OPTIONS (schema_name 'public', table_name 'lease'); + +CREATE FOREIGN TABLE chain_block ( + height integer, + datetime timestamp with time zone, + "dayId" uuid +) SERVER chain_db +OPTIONS (schema_name 'public', table_name 'block'); + +CREATE FOREIGN TABLE chain_day ( + id uuid, + date timestamp with time zone, + "aktPrice" double precision, + "firstBlockHeight" integer, + "lastBlockHeight" integer, + "lastBlockHeightYet" integer +) SERVER chain_db +OPTIONS (schema_name 'public', table_name 'day'); + +-- Query the amount spent per day for all the trial or non-trial users, just change w.trial = true or false +WITH daily_leases AS ( + SELECT + d.date, + l.id, + ((LEAST(d."lastBlockHeightYet", COALESCE(l."closedHeight", l."predictedClosedHeight")) - GREATEST(d."firstBlockHeight", l."createdHeight")) * l.price) AS "uusdc_spent" + FROM chain_day d + INNER JOIN chain_lease l ON l."createdHeight" < d."lastBlockHeightYet" AND COALESCE(l."closedHeight", l."predictedClosedHeight") > d."firstBlockHeight" + INNER JOIN user_wallets w ON w.address = l.owner AND w.trial = true + WHERE l.denom='uusdc' +) +SELECT + date AS "Date", + COUNT(l.id) AS "Lease Count", + ROUND(SUM(l.uusdc_spent)::decimal / 1000000, 2) AS "USDC Spent", + ROUND(SUM(SUM(l.uusdc_spent)::decimal) OVER (ORDER BY date) / 1000000, 2) AS "Cummulative USDC Spent" +FROM daily_leases l +GROUP BY date +ORDER BY date DESC + +``` \ No newline at end of file From 55169437891a3ed9ab1059cdd5e07040d8c9bfdb Mon Sep 17 00:00:00 2001 From: Maxime Beauchamp <15185355+baktun14@users.noreply.github.com> Date: Fri, 24 Jan 2025 17:18:06 -0500 Subject: [PATCH 02/27] chore: added example queries --- doc/Example_Queries.md | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/Example_Queries.md b/doc/Example_Queries.md index 3fed0eb69..31a97475d 100644 --- a/doc/Example_Queries.md +++ b/doc/Example_Queries.md @@ -242,7 +242,6 @@ GROUP BY ORDER BY active_lease_count DESC; ``` - ## Cross database queries from chain-db (indexer) and user db User db stores the addresses of the managed wallet users and if we want to query the indexer db to compute amount spent, we need to do a cross database query. From a03e71869e7577f42d5759a29021f52fc47f7c2c Mon Sep 17 00:00:00 2001 From: Maxime Beauchamp <15185355+baktun14@users.noreply.github.com> Date: Fri, 24 Jan 2025 17:19:25 -0500 Subject: [PATCH 03/27] chore: added comments to akash block --- .../database/dbSchemas/akash/akashBlock.ts | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/packages/database/dbSchemas/akash/akashBlock.ts b/packages/database/dbSchemas/akash/akashBlock.ts index 2e41addad..d9d8baf3b 100644 --- a/packages/database/dbSchemas/akash/akashBlock.ts +++ b/packages/database/dbSchemas/akash/akashBlock.ts @@ -4,20 +4,59 @@ import { Column, Table } from "sequelize-typescript"; import { Block } from "../base"; import { tableConfig } from "../base/block"; +/** + * Custom Block model for Akash + * + * This model extends the base Block model and adds additional columns for Akash specific metrics updated by the indexer for every block. + * It makes it easier to query for Akash specific metrics with the most precision. + */ @Table({ ...tableConfig, indexes: [...tableConfig.indexes, { name: "block_totaluusdspent_is_null", unique: false, fields: ["height"], where: { totalUUsdSpent: null } }] }) export class AkashBlock extends Block { + /** + * Total amount of AKT spent at current block height in uakt + */ @Column(DataTypes.DOUBLE) totalUAktSpent?: number; + /** + * Total amount of USDC spent at current block height in uusdc + */ @Column(DataTypes.DOUBLE) totalUUsdcSpent?: number; + /** + * Total amount of USD spent at current block height in usd + */ @Column(DataTypes.DOUBLE) totalUUsdSpent?: number; + /** + * Total amount of active leases at current block height + */ @Column activeLeaseCount?: number; + /** + * Total amount of leases at current block height + */ @Column totalLeaseCount?: number; + /** + * Total amount of active CPU at current block height + */ @Column activeCPU?: number; + /** + * Total amount of active GPU at current block height + */ @Column activeGPU?: number; + /** + * Total amount of active memory at current block height in bytes + */ @Column(DataTypes.BIGINT) activeMemory?: number; + /** + * Total amount of active ephemeral storage at current block height in bytes + */ @Column(DataTypes.BIGINT) activeEphemeralStorage?: number; + /** + * Total amount of active persistent storage at current block height in bytes + */ @Column(DataTypes.BIGINT) activePersistentStorage?: number; + /** + * Total amount of active providers at current block height + */ @Column activeProviderCount?: number; } From ff1f37b172836f4c56be47eb4c5239e369ecedd6 Mon Sep 17 00:00:00 2001 From: Maxime Beauchamp <15185355+baktun14@users.noreply.github.com> Date: Fri, 24 Jan 2025 17:19:51 -0500 Subject: [PATCH 04/27] chore: added comments to akash message --- packages/database/dbSchemas/akash/akashMessage.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/database/dbSchemas/akash/akashMessage.ts b/packages/database/dbSchemas/akash/akashMessage.ts index b2161130c..d12c22bc3 100644 --- a/packages/database/dbSchemas/akash/akashMessage.ts +++ b/packages/database/dbSchemas/akash/akashMessage.ts @@ -4,10 +4,18 @@ import { Column, Table } from "sequelize-typescript"; import { Message } from "../base"; import { tableConfig } from "../base/message"; +/** + * Custom Message model for Akash + * + * This model extends the base Message model and adds additional columns for Akash specific metrics + */ @Table({ ...tableConfig, indexes: [...tableConfig.indexes, { unique: false, fields: ["relatedDeploymentId"] }] }) export class AkashMessage extends Message { + /** + * The ID of the deployment that this message is related to + */ @Column(DataTypes.UUID) relatedDeploymentId?: string; } From f9483f540aa0b3688947afc4f8d500de7e5ecf4d Mon Sep 17 00:00:00 2001 From: Maxime Beauchamp <15185355+baktun14@users.noreply.github.com> Date: Fri, 24 Jan 2025 17:20:18 -0500 Subject: [PATCH 05/27] chore: added comments to bid --- packages/database/dbSchemas/akash/bid.ts | 28 ++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/packages/database/dbSchemas/akash/bid.ts b/packages/database/dbSchemas/akash/bid.ts index d6768cfe0..1111422a0 100644 --- a/packages/database/dbSchemas/akash/bid.ts +++ b/packages/database/dbSchemas/akash/bid.ts @@ -3,16 +3,44 @@ import { Column, Model, Table } from "sequelize-typescript"; import { Required } from "../decorators/requiredDecorator"; +/** + * Bid model for Akash + * + * Bids are created when a provider makes a bid for a deployment. + * When a bid is accepted by the deployment owner, a lease is created with the same dseq, gseq, oseq, and provider. + * This is a 1:1 with the blockchain MsgCreateBid message. + */ @Table({ modelName: "bid", indexes: [{ unique: false, fields: ["owner", "dseq", "gseq", "oseq", "provider"] }] }) export class Bid extends Model { + /** + * The owner of the deployment that this bid is for + */ @Required @Column owner: string; + /** + * The dseq of the deployment that this bid is for + */ @Required @Column dseq: string; + /** + * The gseq of the deployment that this bid is for + */ @Required @Column gseq: number; + /** + * The oseq of the deployment that this bid is for + */ @Required @Column oseq: number; + /** + * The provider address that made the bid + */ @Required @Column provider: string; + /** + * The price of the bid in uakt per block + */ @Required @Column(DataTypes.DOUBLE) price: number; + /** + * The block height at which the bid was created (MsgCreateBid) + */ @Required @Column createdHeight: number; } From 636db8349a4fd130230572c4c8661fdee5056059 Mon Sep 17 00:00:00 2001 From: Maxime Beauchamp <15185355+baktun14@users.noreply.github.com> Date: Fri, 24 Jan 2025 20:04:46 -0500 Subject: [PATCH 06/27] chore: document deployment schema --- packages/database/dbSchemas/akash/bid.ts | 3 +- .../database/dbSchemas/akash/deployment.ts | 56 ++++++++++++++++++- 2 files changed, 56 insertions(+), 3 deletions(-) diff --git a/packages/database/dbSchemas/akash/bid.ts b/packages/database/dbSchemas/akash/bid.ts index 1111422a0..b9a872735 100644 --- a/packages/database/dbSchemas/akash/bid.ts +++ b/packages/database/dbSchemas/akash/bid.ts @@ -6,9 +6,8 @@ import { Required } from "../decorators/requiredDecorator"; /** * Bid model for Akash * - * Bids are created when a provider makes a bid for a deployment. + * Bids are created when a provider makes a bid for a deployment. (MsgCreateBid) * When a bid is accepted by the deployment owner, a lease is created with the same dseq, gseq, oseq, and provider. - * This is a 1:1 with the blockchain MsgCreateBid message. */ @Table({ modelName: "bid", diff --git a/packages/database/dbSchemas/akash/deployment.ts b/packages/database/dbSchemas/akash/deployment.ts index 87420cac1..fce7970ec 100644 --- a/packages/database/dbSchemas/akash/deployment.ts +++ b/packages/database/dbSchemas/akash/deployment.ts @@ -6,6 +6,12 @@ import { Required } from "../decorators/requiredDecorator"; import { DeploymentGroup } from "./deploymentGroup"; import { Lease } from "./lease"; +/** + * Deployment model for Akash + * + * Deployments are created when a user creates a deployment on the blockchain. (MsgCreateDeployment) + * They are used to track the state of a deployment and the associated leases. + */ @Table({ modelName: "deployment", indexes: [ @@ -18,20 +24,68 @@ import { Lease } from "./lease"; ] }) export class Deployment extends Model { + /** + * The unique identifier for the database deployment + */ @Required @PrimaryKey @Default(UUIDV4) @Column(DataTypes.UUID) id: string; + /** + * Address of the wallet that owns this deployment + */ @Required @Column owner: string; + /** + * The dseq of the deployment (unique identifier for the deployment on the blockchain) + */ @Required @Column dseq: string; + /** + * The block height at which the deployment was created (MsgCreateDeployment) + */ @Required @Column createdHeight: number; + /** + * The balance of the deployment in the denom specified in the denom column + * Remaining balance based on deposits and MsgWithdrawLease + */ @Required @Column(DataTypes.DOUBLE) balance: number; + /** + * The deposit of the deployment in the denom specified in the denom column + * Deposited amount based on MsgCreateDeployment and MsgDepositDeployment + */ @Required @Column(DataTypes.BIGINT) deposit: number; + /** + * The denom of the deployment + * This can be uakt or uusdc + */ @Required @Column denom: string; + /** + * Last block height where an account settlement occurred. This happens on create, withdraw and close. + * This is used to calculate the predicted closed height of the deployment and account settlement. + */ @Column lastWithdrawHeight?: number; + /** + * Withdrawn amount as of now. Updated on account settlement (create lease MsgCreateLease, withdraw lease MsgWithdrawLease, close lease MsgCloseLease). + */ @Required @Column(DataTypes.DOUBLE) withdrawnAmount!: number; + /** + * Block height the deployment got closed on-chain. Can happen from MsgCloseDeployment or as a side-effect through transaction events of having no active leases remaining. + */ @Column closedHeight?: number; - + /** + * The block at which the deployment was created + */ @BelongsTo(() => Block, "createdHeight") createdBlock: Block; + /** + * The block at which the deployment was closed + */ @BelongsTo(() => Block, "closedHeight") closedBlock: Block; + /** + * The deployment groups associated with the deployment + */ @HasMany(() => DeploymentGroup, "deploymentId") deploymentGroups: DeploymentGroup[]; + /** + * The leases associated with the deployment + */ @HasMany(() => Lease, "deploymentId") leases: Lease[]; + /** + * The messages associated with the deployment + */ @HasMany(() => Message, { foreignKey: "relatedDeploymentId", constraints: false }) relatedMessages: Message[]; } From d835ee6794d2b7b44af4473843c90fcd17978a61 Mon Sep 17 00:00:00 2001 From: Maxime Beauchamp <15185355+baktun14@users.noreply.github.com> Date: Fri, 24 Jan 2025 20:09:12 -0500 Subject: [PATCH 07/27] chore: document deployment group schema --- .../dbSchemas/akash/deploymentGroup.ts | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/packages/database/dbSchemas/akash/deploymentGroup.ts b/packages/database/dbSchemas/akash/deploymentGroup.ts index 3ab8963a7..e57de02da 100644 --- a/packages/database/dbSchemas/akash/deploymentGroup.ts +++ b/packages/database/dbSchemas/akash/deploymentGroup.ts @@ -6,6 +6,12 @@ import { Deployment } from "./deployment"; import { DeploymentGroupResource } from "./deploymentGroupResource"; import { Lease } from "./lease"; +/** + * DeploymentGroup model for Akash + * + * A DeploymentGroup is a group of resources that are associated with a deployment. + * It is created when a deployment is created and is used to track the resources group associated with the deployment. + */ @Table({ modelName: "deploymentGroup", indexes: [ @@ -16,13 +22,36 @@ import { Lease } from "./lease"; ] }) export class DeploymentGroup extends Model { + /** + * The unique identifier for the database deployment group + */ @Required @PrimaryKey @Default(DataTypes.UUIDV4) @Column(DataTypes.UUID) id: string; + /** + * The unique identifier for the database deployment + */ @Required @Column(DataTypes.UUID) deploymentId: string; + /** + * The owner address of the deployment + */ @Required @Column owner: string; + /** + * The dseq of the deployment + */ @Required @Column dseq: string; + /** + * The gseq of the deployment group (unique identifier for the deployment group on the blockchain) + */ @Required @Column gseq: number; - + /** + * The deployment associated with the deployment group + */ @BelongsTo(() => Deployment, "deploymentId") deployment: Deployment; + /** + * The leases associated with the deployment group + */ @HasMany(() => Lease, "deploymentGroupId") leases: Lease[]; + /** + * The resources associated with the deployment group + */ @HasMany(() => DeploymentGroupResource, "deploymentGroupId") deploymentGroupResources: DeploymentGroupResource[]; } From d820ec99eeacda9c140692b9cf5b3f3f020bed98 Mon Sep 17 00:00:00 2001 From: Maxime Beauchamp <15185355+baktun14@users.noreply.github.com> Date: Fri, 24 Jan 2025 20:19:47 -0500 Subject: [PATCH 08/27] chore: add documentation to deployment group resource --- .../akash/deploymentGroupResource.ts | 42 ++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/packages/database/dbSchemas/akash/deploymentGroupResource.ts b/packages/database/dbSchemas/akash/deploymentGroupResource.ts index 0faa58474..a45976900 100644 --- a/packages/database/dbSchemas/akash/deploymentGroupResource.ts +++ b/packages/database/dbSchemas/akash/deploymentGroupResource.ts @@ -4,18 +4,58 @@ import { BelongsTo, Column, Model, Table } from "sequelize-typescript"; import { Required } from "../decorators/requiredDecorator"; import { DeploymentGroup } from "./deploymentGroup"; +/** + * DeploymentGroupResource model for Akash + * + * A DeploymentGroupResource is a resource that is associated with a deployment group. + * It is created when a deployment group is created and is used to track the resources associated with the deployment group. + */ @Table({ modelName: "deploymentGroupResource", indexes: [{ unique: false, fields: ["deploymentGroupId"] }] }) export class DeploymentGroupResource extends Model { + /** + * The unique identifier for the database deployment group resource + */ @Required @Column(DataTypes.UUID) deploymentGroupId: string; + /** + * The cpu units of the deployment group resource in thousandths of a CPU + * 1000 CPU units = 1 CPU + */ @Required @Column cpuUnits: number; + /** + * The gpu units of the deployment group resource + * 1 GPU unit = 1 GPU + */ @Required @Column gpuUnits: number; + /** + * The gpu vendor of the deployment group resource + */ @Column gpuVendor: string; + /** + * The gpu model of the deployment group resource + */ @Column gpuModel: string; + /** + * The memory quantity of the deployment group resource in bytes + */ @Required @Column(DataTypes.BIGINT) memoryQuantity: number; + /** + * The ephemeral storage quantity of the deployment group resource in bytes + */ @Required @Column(DataTypes.BIGINT) ephemeralStorageQuantity: number; + /** + * The persistent storage quantity of the deployment group resource in bytes + */ @Required @Column(DataTypes.BIGINT) persistentStorageQuantity: number; + /** + * The count of the deployment group resource + */ @Required @Column count: number; + /** + * The price of the deployment group resource in the denom specified in the denom column of the deployment + */ @Required @Column(DataTypes.DOUBLE) price: number; - + /** + * The deployment group associated with the deployment group resource + */ @BelongsTo(() => DeploymentGroup, "deploymentGroupId") deploymentGroup: DeploymentGroup; } From aa4c866f4dcafe869674fdcc0ebc38c045d814a3 Mon Sep 17 00:00:00 2001 From: Maxime Beauchamp <15185355+baktun14@users.noreply.github.com> Date: Sat, 25 Jan 2025 14:18:57 -0500 Subject: [PATCH 09/27] chore: add comprehensive documentation to lease schema --- .../database/dbSchemas/akash/deployment.ts | 6 ++ packages/database/dbSchemas/akash/lease.ts | 89 +++++++++++++++++++ 2 files changed, 95 insertions(+) diff --git a/packages/database/dbSchemas/akash/deployment.ts b/packages/database/dbSchemas/akash/deployment.ts index fce7970ec..434fc5556 100644 --- a/packages/database/dbSchemas/akash/deployment.ts +++ b/packages/database/dbSchemas/akash/deployment.ts @@ -34,6 +34,12 @@ export class Deployment extends Model { @Required @Column owner: string; /** * The dseq of the deployment (unique identifier for the deployment on the blockchain) + * It can be any string, but ususally it's the block height at which the deployment was created. + * Unique Identifier: DSEQ is a unique identifier assigned to each deployment on the Akash Network, enabling precise tracking and management of deployments + * Order Sequence Number (OSEQ): DSEQ is associated with an Order Sequence Number (OSEQ), which indicates the order in which deployments are created and managed within the network + * Deployment Management: DSEQ facilitates the management of deployments by providing a specific reference point for each deployment instance, ensuring clarity and organization in the deployment process + * Lease Creation: When creating a lease with a provider on the Akash Network, DSEQ is a key parameter used to establish the terms of the lease and finalize the deployment process + * Deployment Status: DSEQ allows users to check the status of their deployments, access application endpoints, and monitor the progress of container image pulling and container startup */ @Required @Column dseq: string; /** diff --git a/packages/database/dbSchemas/akash/lease.ts b/packages/database/dbSchemas/akash/lease.ts index 20ce3f54f..953573ec0 100644 --- a/packages/database/dbSchemas/akash/lease.ts +++ b/packages/database/dbSchemas/akash/lease.ts @@ -7,6 +7,13 @@ import { Deployment } from "./deployment"; import { DeploymentGroup } from "./deploymentGroup"; import { Provider } from "./provider"; +/** + * Lease model for Akash + * + * A Lease is a lease that is associated with a deployment. (MsgCreateLease) + * It is created after a deployment is created and is used to track the leases made with the associated provider. + * A lease is created for each provider in the deployment group. + */ @Table({ modelName: "lease", indexes: [ @@ -18,31 +25,113 @@ import { Provider } from "./provider"; ] }) export class Lease extends Model { + /** + * The unique identifier for the database lease + */ @Required @PrimaryKey @Default(DataTypes.UUIDV4) @Column(DataTypes.UUID) id: string; + /** + * The unique identifier for the database deployment + */ @Required @Column(DataTypes.UUID) deploymentId: string; + /** + * The unique identifier for the database deployment group + */ @Required @Column(DataTypes.UUID) deploymentGroupId: string; + /** + * The owner address of the lease + */ @Required @Column owner: string; + /** + * The dseq of the deployment + */ @Required @Column dseq: string; + /** + * The oseq of the lease (Order Sequence Number) + * Akash OSEQ distinguishes multiple orders associated with a single deployment. + * Typically, Akash deployments use OSEQ=1 with only a single order associated with the deployment. + * OSEQ is incremented when a lease associated with an existing deployment is closed, and a new order is generated. + */ @Required @Column oseq: number; + /** + * The gseq of the lease (Group Sequence Number) + * Akash GSEQ distinguishes “groups” of containers in a deployment, allowing each group to be leased independently. Orders, bids, and leases all act on a single group. + * Typically, Akash deployments use GSEQ=1, with all pods associated with the deployment using a single provider. + */ @Required @Column gseq: number; + /** + * The provider address of the lease + */ @Required @Column providerAddress: string; + /** + * The block height at which the lease was created. Happens when a bid is accepted with MsgCreateLease. + */ @Required @Column createdHeight: number; + /** + * Block height at which the lease is closed on-chain. Happens from MsgCloseLease, MsgCloseHeight or if the deployment become overdrawn during an account settlement. + * It can also happen during transaction events when an authz is revoked for the wallet owning the lease. + */ @Column closedHeight?: number; + /** + * Block height at which the lease should theoretically expire. This is calculated based on the balance and price with the indexer. + * It will usually not match the closedHeight since leases can be closed early (MsgCloseLease & MsgCloseBid) or closed late since the closing wont happen until the provider does a MsgWithdrawLease. + */ @Required @Column(DataTypes.DECIMAL(30, 0)) predictedClosedHeight: string; + /** + * The price per block of the lease in the denom specified in the denom column (uakt or uusd) + */ @Required @Column(DataTypes.DOUBLE) price: number; + /** + * Withdrawn amount as of now for this lease. Updated on account settlement (MsgWithdrawLease, MsgWithdrawLease, MsgCloseLease). + */ @Required @Default(0) @Column(DataTypes.DOUBLE) withdrawnAmount: number; + /** + * The denom of the lease + * This can be uakt or uusdc + */ @Required @Column denom: string; // Stats + /** + * The cpu units of the lease in thousandths of a CPU + * 1000 CPU units = 1 CPU + */ @Required @Column cpuUnits: number; + /** + * The gpu units of the lease + * 1 GPU unit = 1 GPU + */ @Required @Column gpuUnits: number; + /** + * The memory quantity of the lease in bytes + */ @Required @Column(DataTypes.BIGINT) memoryQuantity: number; + /** + * The ephemeral storage quantity of the lease in bytes + */ @Required @Column(DataTypes.BIGINT) ephemeralStorageQuantity: number; + /** + * The persistent storage quantity of the lease in bytes + */ @Required @Column(DataTypes.BIGINT) persistentStorageQuantity: number; + /** + * The block at which the lease was created + */ @BelongsTo(() => Block, "createdHeight") createdBlock: Block; + /** + * The block at which the lease was closed + */ @BelongsTo(() => Block, "closedHeight") closedBlock: Block; + /** + * The deployment group associated with the lease + */ @BelongsTo(() => DeploymentGroup, "deploymentGroupId") deploymentGroup: DeploymentGroup; + /** + * The deployment associated with the lease + */ @BelongsTo(() => Deployment, "deploymentId") deployment: Deployment; + /** + * The provider associated with the lease + */ @BelongsTo(() => Provider, "providerAddress") provider: Provider; } From 6c960691e6b72cca72d2ece15d2ef75d861d4772 Mon Sep 17 00:00:00 2001 From: Maxime Beauchamp <15185355+baktun14@users.noreply.github.com> Date: Sat, 25 Jan 2025 14:34:13 -0500 Subject: [PATCH 10/27] chore: add comprehensive documentation to provider schema --- packages/database/dbSchemas/akash/provider.ts | 113 ++++++++++++++++++ 1 file changed, 113 insertions(+) diff --git a/packages/database/dbSchemas/akash/provider.ts b/packages/database/dbSchemas/akash/provider.ts index 3f681e5aa..2206a0c82 100644 --- a/packages/database/dbSchemas/akash/provider.ts +++ b/packages/database/dbSchemas/akash/provider.ts @@ -7,47 +7,160 @@ import { ProviderAttribute } from "./providerAttribute"; import { ProviderAttributeSignature } from "./providerAttributeSignature"; import { ProviderSnapshot } from "./providerSnapshot"; +/** + * Provider model for Akash + * + * A Provider on Akash is an entity that offers compute resources to the network. + * When a deployment is created, the providers automatically bid for the deployment. + * The deployment owner then has to select which provider bid they want to accept and create a lease with that provider. + */ @Table({ modelName: "provider", indexes: [{ unique: false, fields: ["owner"] }] }) export class Provider extends Model { + /** + * The owner address of the provider + */ @Required @PrimaryKey @Column owner: string; + /** + * The hostUri of the provider + * ex: https://provider.europlots.com:8443 + */ @Required @Column hostUri: string; + /** + * The block height at which the provider was created (MsgCreateProvider) + */ @Required @Column createdHeight: number; + /** + * The block height at which the provider was updated (MsgUpdateProvider) + */ @Column updatedHeight?: number; + /** + * The block height at which the provider was deleted (MsgDeleteProvider) + */ @Column deletedHeight?: number; + /** + * The email of the provider + */ @Column email?: string; + /** + * The website of the provider + */ @Column website?: string; + /** + * The Akash version of the provider is running on + */ @Column akashVersion?: string; + /** + * The Cosmos SDK version of the provider is running on + */ @Column cosmosSdkVersion?: string; // Stats + /** + * The last snapshot id of the provider + * Snapshots are taken periodically by the indexer to check if the provider is online and to get the provider's stats + */ @Column(DataTypes.UUID) lastSnapshotId?: string; + /** + * Snapshot ID of the last successful check + */ @Column(DataTypes.UUID) lastSuccessfulSnapshotId?: string; + /** + * Snapshot ID of the first failed check of the current downtime period. NULL if currently online. + * It is used to calculate the nextCheckDate + */ @Column(DataTypes.UUID) downtimeFirstSnapshotId?: string; + /** + * Whether the provider is online + * This is based on if the provider status endpoint returns a 200 status code + */ @Column isOnline?: boolean; + /** + * Date & Time of the latest uptime check + */ @Column lastCheckDate?: Date; + /** + * Planned Date & Time of the next uptime check + */ @Required @Default(DataTypes.NOW) @Column nextCheckDate: Date; + /** + * Amount of consecutive failed checks, NULL if currently online. + */ @Required @Default(0) @Column failedCheckCount: number; + /** + * NULL if the latest uptime check was successful, otherwise this will contain the error message. + */ @Column(DataTypes.TEXT) error?: string; + /** + * IP obtained by resolving DNS for the hostUri + */ @Column ip?: string; + /** + * The ip region of the provider + */ @Column ipRegion?: string; + /** + * The ip region code of the provider + */ @Column ipRegionCode?: string; + /** + * The ip country of the provider + */ @Column ipCountry?: string; + /** + * The ip country code of the provider + */ @Column ipCountryCode?: string; + /** + * The ip lat of the provider + */ @Column ipLat?: string; + /** + * The ip lon of the provider + */ @Column ipLon?: string; + /** + * The uptime of the provider in the last 1 day + */ @Column(DataTypes.DOUBLE) uptime1d?: number; + /** + * The uptime of the provider in the last 7 days + */ @Column(DataTypes.DOUBLE) uptime7d?: number; + /** + * The uptime of the provider in the last 30 days + */ @Column(DataTypes.DOUBLE) uptime30d?: number; + /** + * The provider attributes associated with the provider + */ @HasMany(() => ProviderAttribute, "provider") providerAttributes: ProviderAttribute[]; + /** + * The provider attribute signatures associated with the provider + */ @HasMany(() => ProviderAttributeSignature, "provider") providerAttributeSignatures: ProviderAttributeSignature[]; + /** + * The provider snapshots associated with the provider + */ @HasMany(() => ProviderSnapshot, "owner") providerSnapshots: ProviderSnapshot[]; + /** + * The block at which the provider was created + */ @BelongsTo(() => AkashBlock, "createdHeight") createdBlock: AkashBlock; + /** + * The last snapshot of the provider + */ @BelongsTo(() => ProviderSnapshot, "lastSnapshotId") lastSnapshot: ProviderSnapshot; + /** + * The last successful snapshot of the provider + */ @BelongsTo(() => ProviderSnapshot, "lastSuccessfulSnapshotId") lastSuccessfulSnapshot: ProviderSnapshot; + /** + * The first snapshot of the provider + */ @BelongsTo(() => ProviderSnapshot, "downtimeFirstSnapshotId") downtimeFirstSnapshot: ProviderSnapshot; } From 83fb3e62b7ded246cb9171ee9d269c83c80fe3ca Mon Sep 17 00:00:00 2001 From: Maxime Beauchamp <15185355+baktun14@users.noreply.github.com> Date: Sat, 25 Jan 2025 14:39:26 -0500 Subject: [PATCH 11/27] chore: add documentation to provider attribute schema --- .../database/dbSchemas/akash/providerAttribute.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/database/dbSchemas/akash/providerAttribute.ts b/packages/database/dbSchemas/akash/providerAttribute.ts index b5f6cea61..d8a18d9b6 100644 --- a/packages/database/dbSchemas/akash/providerAttribute.ts +++ b/packages/database/dbSchemas/akash/providerAttribute.ts @@ -2,12 +2,27 @@ import { Column, Model, Table } from "sequelize-typescript"; import { Required } from "../decorators/requiredDecorator"; +/** + * ProviderAttribute model for Akash + * + * Provider attributes are used to store additional information about a provider. + * This is used to store information about the provider's location, resource specifications, such as the country, region, city, etc. + */ @Table({ modelName: "providerAttribute", indexes: [{ unique: false, fields: ["provider"] }] }) export class ProviderAttribute extends Model { + /** + * The provider address that the attribute belongs to + */ @Required @Column provider: string; + /** + * The key of the attribute + */ @Required @Column key: string; + /** + * The value of the attribute + */ @Required @Column value: string; } From 7031d2e545d0eb5bceb0bb6e8b3f0e1f0edd98e5 Mon Sep 17 00:00:00 2001 From: Maxime Beauchamp <15185355+baktun14@users.noreply.github.com> Date: Sat, 25 Jan 2025 14:44:27 -0500 Subject: [PATCH 12/27] chore: enhance documentation for provider attribute signature schema --- .../dbSchemas/akash/providerAttribute.ts | 2 +- .../akash/providerAttributeSignature.ts | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/packages/database/dbSchemas/akash/providerAttribute.ts b/packages/database/dbSchemas/akash/providerAttribute.ts index d8a18d9b6..905e5137e 100644 --- a/packages/database/dbSchemas/akash/providerAttribute.ts +++ b/packages/database/dbSchemas/akash/providerAttribute.ts @@ -5,7 +5,7 @@ import { Required } from "../decorators/requiredDecorator"; /** * ProviderAttribute model for Akash * - * Provider attributes are used to store additional information about a provider. + * Provider attributes are used to store additional information about a provider. (MsgCreateProvider & MsgUpdateProvider) * This is used to store information about the provider's location, resource specifications, such as the country, region, city, etc. */ @Table({ diff --git a/packages/database/dbSchemas/akash/providerAttributeSignature.ts b/packages/database/dbSchemas/akash/providerAttributeSignature.ts index 40bbd9dc5..fe78357fc 100644 --- a/packages/database/dbSchemas/akash/providerAttributeSignature.ts +++ b/packages/database/dbSchemas/akash/providerAttributeSignature.ts @@ -2,13 +2,32 @@ import { Column, Model, Table } from "sequelize-typescript"; import { Required } from "../decorators/requiredDecorator"; +/** + * ProviderAttributeSignature model for Akash + * + * This is used to store the signature of the provider attribute. (MsgSignProviderAttributes & MsgDeleteProviderAttributes) + * It is used to verify the authenticity of the attribute. + * The auditor is the address of the auditor that signed the attribute. + */ @Table({ modelName: "providerAttributeSignature", indexes: [{ unique: false, fields: ["provider"] }] }) export class ProviderAttributeSignature extends Model { + /** + * The provider address that the attribute belongs to + */ @Required @Column provider: string; + /** + * The auditor address that signed the attribute + */ @Required @Column auditor: string; + /** + * The key of the attribute that was signed + */ @Required @Column key: string; + /** + * The value of the attribute that was signed + */ @Required @Column value: string; } From 4eaae5bc3eb1883e5f99026cfc6a08c0082b4bfa Mon Sep 17 00:00:00 2001 From: Maxime Beauchamp <15185355+baktun14@users.noreply.github.com> Date: Sat, 25 Jan 2025 16:23:32 -0500 Subject: [PATCH 13/27] chore: add comprehensive documentation to provider snapshot schema --- .../dbSchemas/akash/providerSnapshot.ts | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/packages/database/dbSchemas/akash/providerSnapshot.ts b/packages/database/dbSchemas/akash/providerSnapshot.ts index 10d87eca7..f35d123b5 100644 --- a/packages/database/dbSchemas/akash/providerSnapshot.ts +++ b/packages/database/dbSchemas/akash/providerSnapshot.ts @@ -5,6 +5,15 @@ import { Required } from "../decorators/requiredDecorator"; import { ProviderSnapshotNode } from "./providerSnapshotNode"; import { ProviderSnapshotStorage } from "./providerSnapshotStorage"; +/** + * ProviderSnapshot model for Akash + * + * This is used to store the snapshot of a provider resources at a given time. + * It is used to track the provider's stats, such as the amount of CPU, GPU, memory, etc. + * Active resources are the resources that are currently being used by leases on the provider. + * Pending resources are the resources that are currently being requested by the provider for leases. + * Available resources are the resources that are currently available to the provider. + */ @Table({ modelName: "providerSnapshot", indexes: [ @@ -15,33 +24,113 @@ import { ProviderSnapshotStorage } from "./providerSnapshotStorage"; ] }) export class ProviderSnapshot extends Model { + /** + * The ID of the snapshot + */ @Required @PrimaryKey @Default(DataTypes.UUIDV4) @Column(DataTypes.UUID) id: string; + /** + * The owner address of the provider + */ @Required @Column owner: string; + /** + * Whether this is the last snapshot of the day for the associated provider + */ @Required @Default(false) @Column isLastOfDay: boolean; + /** + * Whether this is the last successful snapshot of the day for the associated provider + */ @Required @Default(false) @Column isLastSuccessOfDay: boolean; // Stats + /** + * Whether the provider is online + */ @Required @Column isOnline: boolean; + /** + * The date & time of the snapshot + */ @Required @Column checkDate: Date; + /** + * null if the uptime check was successful, otherwise this will contain the error message. + */ @Column(DataTypes.TEXT) error?: string; + /** + * The amount of deployments the provider has + */ @Column deploymentCount?: number; + /** + * The amount of leases the provider has + */ @Column leaseCount?: number; + /** + * The amount of active CPU the provider has in thousands of vCPUs + * 1000 vCPUs = 1 CPU + */ @Column(DataTypes.BIGINT) activeCPU?: number; + /** + * The amount of active GPU the provider has + * 1 GPU = 1 GPU + */ @Column(DataTypes.BIGINT) activeGPU?: number; + /** + * The amount of active memory the provider has in bytes + */ @Column(DataTypes.BIGINT) activeMemory?: number; + /** + * The amount of active ephemeral storage the provider has in bytes + */ @Column(DataTypes.BIGINT) activeEphemeralStorage?: number; + /** + * The amount of active persistent storage the provider has in bytes + */ @Column(DataTypes.BIGINT) activePersistentStorage?: number; + /** + * The amount of pending CPU the provider has in thousands of vCPUs + */ @Column(DataTypes.BIGINT) pendingCPU?: number; + /** + * The amount of pending GPU the provider has + */ @Column(DataTypes.BIGINT) pendingGPU?: number; + /** + * The amount of pending memory the provider has in bytes + */ @Column(DataTypes.BIGINT) pendingMemory?: number; + /** + * The amount of pending ephemeral storage the provider has + */ @Column(DataTypes.BIGINT) pendingEphemeralStorage?: number; + /** + * The amount of pending persistent storage the provider has in bytes + */ @Column(DataTypes.BIGINT) pendingPersistentStorage?: number; + /** + * The amount of available CPU the provider has in thousands of vCPUs + */ @Column(DataTypes.BIGINT) availableCPU?: number; + /** + * The amount of available GPU the provider has + */ @Column(DataTypes.BIGINT) availableGPU?: number; + /** + * The amount of available GPU the provider has in bytes + */ @Column(DataTypes.BIGINT) availableMemory?: number; + /** + * The amount of available ephemeral storage the provider has in bytes + */ @Column(DataTypes.BIGINT) availableEphemeralStorage?: number; + /** + * The amount of available persistent storage the provider has in bytes + */ @Column(DataTypes.BIGINT) availablePersistentStorage?: number; + /** + * The nodes of the provider at the time of the snapshot + */ @HasMany(() => ProviderSnapshotNode, "snapshotId") nodes: ProviderSnapshotNode[]; + /** + * The storage of the provider at the time of the snapshot + */ @HasMany(() => ProviderSnapshotStorage, "snapshotId") storage: ProviderSnapshotStorage[]; } From 1437ca248ae1826ca82151c1e9abc0706ed8b988 Mon Sep 17 00:00:00 2001 From: Maxime Beauchamp <15185355+baktun14@users.noreply.github.com> Date: Sat, 25 Jan 2025 16:30:55 -0500 Subject: [PATCH 14/27] chore: add detailed documentation to provider snapshot node schema --- .../dbSchemas/akash/providerSnapshotNode.ts | 58 +++++++++++++++++-- 1 file changed, 54 insertions(+), 4 deletions(-) diff --git a/packages/database/dbSchemas/akash/providerSnapshotNode.ts b/packages/database/dbSchemas/akash/providerSnapshotNode.ts index 50053551b..4b862ad33 100644 --- a/packages/database/dbSchemas/akash/providerSnapshotNode.ts +++ b/packages/database/dbSchemas/akash/providerSnapshotNode.ts @@ -5,32 +5,82 @@ import { Required } from "../decorators/requiredDecorator"; import { ProviderSnapshotNodeCPU } from "./providerSnapshotNodeCPU"; import { ProviderSnapshotNodeGPU } from "./providerSnapshotNodeGPU"; +/** + * ProviderSnapshotNode model for Akash + * + * This is used to store the snapshot of a node at a given time. + */ @Table({ modelName: "providerSnapshotNode", indexes: [{ unique: false, fields: ["snapshotId"] }] }) export class ProviderSnapshotNode extends Model { + /** + * The ID of the snapshot node + */ @Required @PrimaryKey @Default(DataTypes.UUIDV4) @Column(DataTypes.UUID) id: string; + /** + * The ID of the database snapshot that this node belongs to + */ @Required @Column(DataTypes.UUID) snapshotId: string; // Stats + /** + * The name of the node + */ @Column name: string; + /** + * The amount of allocatable CPU the node has in thousands of vCPUs + * 1000 vCPUs = 1 CPU + */ @Column(DataTypes.BIGINT) cpuAllocatable: number; + /** + * The amount of allocated CPU the node has in thousands of vCPUs + */ @Column(DataTypes.BIGINT) cpuAllocated: number; - + /** + * The amount of allocatable memory the node has in bytes + */ @Column(DataTypes.BIGINT) memoryAllocatable: number; + /** + * The amount of allocated memory the node has in bytes + */ @Column(DataTypes.BIGINT) memoryAllocated: number; - + /** + * The amount of allocatable ephemeral storage the node has in bytes + */ @Column(DataTypes.BIGINT) ephemeralStorageAllocatable: number; + /** + * The amount of allocated ephemeral storage the node has in bytes + */ @Column(DataTypes.BIGINT) ephemeralStorageAllocated: number; - + /** + * Whether the node has HDD storage capabilities + */ @Column capabilitiesStorageHDD: boolean; + /** + * Whether the node has SSD storage capabilities + */ @Column capabilitiesStorageSSD: boolean; + /** + * Whether the node has NVMe storage capabilities + */ @Column capabilitiesStorageNVME: boolean; - + /** + * The amount of allocatable GPU the node has + */ @Column(DataTypes.BIGINT) gpuAllocatable: number; + /** + * The amount of allocated GPU the node has + */ @Column(DataTypes.BIGINT) gpuAllocated: number; + /** + * The GPUs of the node + */ @HasMany(() => ProviderSnapshotNodeGPU, "snapshotNodeId") gpus: ProviderSnapshotNodeGPU[]; + /** + * The CPUs of the node + */ @HasMany(() => ProviderSnapshotNodeCPU, "snapshotNodeId") cpus: ProviderSnapshotNodeCPU[]; } From 0415a6fef3ea53c0f2d59454dde833fd775d511a Mon Sep 17 00:00:00 2001 From: Maxime Beauchamp <15185355+baktun14@users.noreply.github.com> Date: Sat, 25 Jan 2025 16:36:17 -0500 Subject: [PATCH 15/27] chore: add detailed documentation to provider snapshot node GPU and CPU schemas --- .../akash/providerSnapshotNodeCPU.ts | 23 ++++++++++++++ .../akash/providerSnapshotNodeGPU.ts | 31 +++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/packages/database/dbSchemas/akash/providerSnapshotNodeCPU.ts b/packages/database/dbSchemas/akash/providerSnapshotNodeCPU.ts index 9504e5e9a..3d2db4577 100644 --- a/packages/database/dbSchemas/akash/providerSnapshotNodeCPU.ts +++ b/packages/database/dbSchemas/akash/providerSnapshotNodeCPU.ts @@ -3,15 +3,38 @@ import { Column, Default, Model, PrimaryKey, Table } from "sequelize-typescript" import { Required } from "../decorators/requiredDecorator"; +/** + * ProviderSnapshotNodeCPU model for Akash + * + * This is used to store the snapshot of a node's CPU at a given time. + */ @Table({ modelName: "providerSnapshotNodeCPU", indexes: [{ unique: false, fields: ["snapshotNodeId"] }] }) export class ProviderSnapshotNodeCPU extends Model { + /** + * The ID of the snapshot node CPU + */ @Required @PrimaryKey @Default(DataTypes.UUIDV4) @Column(DataTypes.UUID) id: string; + /** + * The ID of the snapshot node that this CPU belongs to + */ @Required @Column(DataTypes.UUID) snapshotNodeId: string; + /** + * The vendor of the CPU + * ex: GenuineIntel + */ @Column vendor: string; + /** + * The model of the CPU + * ex: Intel(R) Xeon(R) CPU @ 2.30GHz + */ @Column model: string; + /** + * The number of vCPUs the CPU has + * 1 vCPUs = 1 CPU + */ @Column(DataTypes.SMALLINT) vcores: number; } diff --git a/packages/database/dbSchemas/akash/providerSnapshotNodeGPU.ts b/packages/database/dbSchemas/akash/providerSnapshotNodeGPU.ts index e7e344b40..8fc92f5e1 100644 --- a/packages/database/dbSchemas/akash/providerSnapshotNodeGPU.ts +++ b/packages/database/dbSchemas/akash/providerSnapshotNodeGPU.ts @@ -3,18 +3,49 @@ import { Column, Default, Model, PrimaryKey, Table } from "sequelize-typescript" import { Required } from "../decorators/requiredDecorator"; +/** + * ProviderSnapshotNodeGPU model for Akash + * + * This is used to store the snapshot of a node's GPU at a given time. + */ @Table({ modelName: "providerSnapshotNodeGPU", indexes: [{ unique: false, fields: ["snapshotNodeId"] }] }) export class ProviderSnapshotNodeGPU extends Model { + /** + * The ID of the snapshot node GPU + */ @Required @PrimaryKey @Default(DataTypes.UUIDV4) @Column(DataTypes.UUID) id: string; + /** + * The ID of the snapshot node that this GPU belongs to + */ @Required @Column(DataTypes.UUID) snapshotNodeId: string; // Stats + /** + * The vendor of the GPU + * ex: nvidia + */ @Column vendor: string; + /** + * The name of the GPU + * Model name (ex: rtx4090) + */ @Column name: string; + /** + * The model ID of the GPU + * On the provider, this gets mapped to vendor, name, interface and memorySize based on this file https://github.com/akash-network/provider-configs/blob/main/devices/pcie/gpus.json + */ @Column modelId: string; + /** + * The interface of the GPU + * ex: PCIe + */ @Column interface: string; + /** + * The memory size of the GPU + * ex: 24Gi + */ @Column memorySize: string; } From 88bf8aba9c88cc829e6bcd4c35bd1a7b73a94a9d Mon Sep 17 00:00:00 2001 From: Maxime Beauchamp <15185355+baktun14@users.noreply.github.com> Date: Sat, 25 Jan 2025 18:17:13 -0500 Subject: [PATCH 16/27] chore: add detailed documentation to provider snapshot storage schema --- .../akash/providerSnapshotStorage.ts | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/packages/database/dbSchemas/akash/providerSnapshotStorage.ts b/packages/database/dbSchemas/akash/providerSnapshotStorage.ts index 35274aced..81d454656 100644 --- a/packages/database/dbSchemas/akash/providerSnapshotStorage.ts +++ b/packages/database/dbSchemas/akash/providerSnapshotStorage.ts @@ -3,15 +3,36 @@ import { Column, Default, Model, PrimaryKey, Table } from "sequelize-typescript" import { Required } from "../decorators/requiredDecorator"; +/** + * ProviderSnapshotStorage model for Akash + * + * This is used to store the snapshot of a provider's storage at a given time. + */ @Table({ modelName: "providerSnapshotStorage", indexes: [{ unique: false, fields: ["snapshotId"] }] }) export class ProviderSnapshotStorage extends Model { + /** + * The database ID of the snapshot storage + */ @Required @PrimaryKey @Default(DataTypes.UUIDV4) @Column(DataTypes.UUID) id: string; + /** + * The ID of the snapshot that this storage belongs to + */ @Required @Column(DataTypes.UUID) snapshotId: string; + /** + * The class of the storage + * ex: hdd, ssd, nvme + */ @Required @Column class: string; + /** + * The amount of allocatable storage the provider has in bytes + */ @Required @Column(DataTypes.BIGINT) allocatable: number; + /** + * The amount of allocated storage the provider has in bytes + */ @Required @Column(DataTypes.BIGINT) allocated: number; } From 8c62d202850b2256966a3e45f9ab5286db69abec Mon Sep 17 00:00:00 2001 From: Maxime Beauchamp <15185355+baktun14@users.noreply.github.com> Date: Sun, 26 Jan 2025 21:43:31 -0500 Subject: [PATCH 17/27] chore: add detailed documentation to address reference schema --- .../dbSchemas/base/addressReference.ts | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/packages/database/dbSchemas/base/addressReference.ts b/packages/database/dbSchemas/base/addressReference.ts index 1ffef657d..32c8c2dc6 100644 --- a/packages/database/dbSchemas/base/addressReference.ts +++ b/packages/database/dbSchemas/base/addressReference.ts @@ -5,6 +5,11 @@ import { Required } from "../decorators/requiredDecorator"; import { Message } from "./message"; import { Transaction } from "./transaction"; +/** + * AddressReference model for Base + * + * This is used to store the reference of an address to a transaction or message + */ @Table({ modelName: "addressReference", indexes: [ @@ -13,11 +18,30 @@ import { Transaction } from "./transaction"; ] }) export class AddressReference extends Model { + /** + * The ID of the database transaction that this address reference belongs to + */ @Required @Column(DataTypes.UUID) transactionId: string; + /** + * The ID of the database message that this address reference belongs to + */ @Column(DataTypes.UUID) messageId?: string; + /** + * The address that this reference belongs to + */ @Required @Column address: string; + /** + * The type of the reference + * ex: Signer, Receiver, Sender. + */ @Required @Column type: string; + /** + * The message that this address reference belongs to + */ @BelongsTo(() => Message, "messageId") message?: Message; + /** + * The transaction that this address reference belongs to + */ @BelongsTo(() => Transaction, "transactionId") transaction: Transaction; } From f1a1e0d0820f6e58fa51d708c325252caa716288 Mon Sep 17 00:00:00 2001 From: Maxime Beauchamp <15185355+baktun14@users.noreply.github.com> Date: Sun, 26 Jan 2025 21:47:50 -0500 Subject: [PATCH 18/27] chore: add detailed documentation to block schema --- .../dbSchemas/base/addressReference.ts | 2 +- packages/database/dbSchemas/base/block.ts | 42 +++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/packages/database/dbSchemas/base/addressReference.ts b/packages/database/dbSchemas/base/addressReference.ts index 32c8c2dc6..c5c31a06e 100644 --- a/packages/database/dbSchemas/base/addressReference.ts +++ b/packages/database/dbSchemas/base/addressReference.ts @@ -6,7 +6,7 @@ import { Message } from "./message"; import { Transaction } from "./transaction"; /** - * AddressReference model for Base + * AddressReference model for Akash * * This is used to store the reference of an address to a transaction or message */ diff --git a/packages/database/dbSchemas/base/block.ts b/packages/database/dbSchemas/base/block.ts index 7c4449245..c8c39df61 100644 --- a/packages/database/dbSchemas/base/block.ts +++ b/packages/database/dbSchemas/base/block.ts @@ -16,20 +16,62 @@ export const tableConfig = { ] }; +/** + * Block model for Akash + * + * This is used to store the block data + */ @Table(tableConfig) export class Block extends Model { + /** + * The height of the block + */ @PrimaryKey @Column height: number; + /** + * The datetime of the block + */ @Required @Column datetime: Date; + /** + * The hash of the block + */ @Required @Column hash: string; + /** + * The proposer of the block (validator) + */ @Required @Column proposer: string; + /** + * The ID of the day that this block belongs to + */ @Required @Column(DataTypes.UUID) dayId: string; + /** + * The number of transactions in the block + */ @Required @Column txCount: number; + // Stats + /** + * Whether the block has been processed by the indexer + */ @Required @Default(false) @Column isProcessed: boolean; + /** + * The total number of transactions in the block + */ @Required @Column(DataTypes.BIGINT) totalTxCount: number; + /** + * The day that this block belongs to + */ @BelongsTo(() => Day, { foreignKey: "dayId", constraints: false }) day: Day; + /** + * The validator that proposed this block + */ @BelongsTo(() => Validator, { foreignKey: "proposer", targetKey: "hexAddress", constraints: false }) proposerValidator: Validator; + /** + * The transactions in the block + */ @HasMany(() => Transaction, "height") transactions: Transaction[]; + /** + * The messages in the block + */ @HasMany(() => Message, "height") messages: Message[]; } From 2d4f0d71ceac062e5b1f64b0779b7a1cf1d60142 Mon Sep 17 00:00:00 2001 From: Maxime Beauchamp <15185355+baktun14@users.noreply.github.com> Date: Sun, 26 Jan 2025 22:02:58 -0500 Subject: [PATCH 19/27] chore: add detailed documentation to day schema --- packages/database/dbSchemas/base/day.ts | 38 +++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/packages/database/dbSchemas/base/day.ts b/packages/database/dbSchemas/base/day.ts index 2944a4213..e5594f385 100644 --- a/packages/database/dbSchemas/base/day.ts +++ b/packages/database/dbSchemas/base/day.ts @@ -4,6 +4,11 @@ import { BelongsTo, Column, Default, HasMany, Model, PrimaryKey, Table } from "s import { Required } from "../decorators/requiredDecorator"; import { Block } from "./block"; +/** + * Day model for Akash + * + * This is used to store the day data + */ @Table({ modelName: "day", indexes: [ @@ -13,16 +18,49 @@ import { Block } from "./block"; ] }) export class Day extends Model { + /** + * The database ID of the day + */ @Required @PrimaryKey @Default(UUIDV4) @Column(DataTypes.UUID) id: string; + /** + * The date of the day + */ @Required @Column date: Date; + /** + * The price of AKT on this day + */ @Column(DataTypes.DOUBLE) aktPrice?: number; + /** + * The height of the first block in this day + */ @Required @Column firstBlockHeight: number; + /** + * The height of the last block in this day + */ @Column lastBlockHeight?: number; + /** + * The height of the last block in this day that has been processed by the indexer yet + */ @Required @Column lastBlockHeightYet: number; + /** + * Whether the price of AKT has changed on this day + */ @Required @Default(false) @Column aktPriceChanged: boolean; + /** + * The blocks in this day + */ @HasMany(() => Block, { foreignKey: "dayId", constraints: false }) blocks: Block[]; + /** + * The first block in this day + */ @BelongsTo(() => Block, { foreignKey: "firstBlockHeight", constraints: false }) firstBlock: Block; + /** + * The last block in this day + */ @BelongsTo(() => Block, { foreignKey: "lastBlockHeight", constraints: false }) lastBlock?: Block; + /** + * The last block in this day that has been processed by the indexer + */ @BelongsTo(() => Block, { foreignKey: "lastBlockHeightYet", constraints: false }) lastBlockYet: Block; } From 7405fe8d21846edc87767e62ba6e973287bea91f Mon Sep 17 00:00:00 2001 From: Maxime Beauchamp <15185355+baktun14@users.noreply.github.com> Date: Sun, 26 Jan 2025 22:12:11 -0500 Subject: [PATCH 20/27] chore: add detailed documentation to message schema --- packages/database/dbSchemas/base/message.ts | 48 +++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/packages/database/dbSchemas/base/message.ts b/packages/database/dbSchemas/base/message.ts index 9d067d6bf..bd2531d2d 100644 --- a/packages/database/dbSchemas/base/message.ts +++ b/packages/database/dbSchemas/base/message.ts @@ -19,21 +19,69 @@ export const tableConfig = { ] }; +/** + * Message model for Akash + * + * This is used to store the transaction message data + */ @Table(tableConfig) export class Message extends Model { + /** + * The database ID of the message + */ @Required @PrimaryKey @Default(UUIDV4) @Column(DataTypes.UUID) id!: string; + /** + * The ID of the transaction that this message belongs to + */ @Required @Column(DataTypes.UUID) txId: string; + /** + * The height of the block that this message belongs to + */ @Required @Column height: number; + /** + * The type of the message (ex: /akash.market.v1beta4.MsgWithdrawLease) + */ @Required @Column type: string; + /** + * The category of the message (ex: ibc, akash, cosmos) + */ @Required @Column typeCategory: string; + /** + * The index of the message in the transaction + */ @Required @Column index: number; + /** + * The index of the message in the block + */ @Required @Column indexInBlock: number; + /** + * Whether the message has been processed by the indexer + */ @Required @Default(false) @Column isProcessed: boolean; + /** + * Whether the message has been processed by the notification service + */ @Required @Default(false) @Column isNotificationProcessed: boolean; + /** + * The amount of the message + * This is only used for messages that have an amount (ex: MsgDelegate, MsgSend, etc.) + */ @Column(DataTypes.DECIMAL(30, 0)) amount?: string; + /** + * The data of the message + */ @Required @Column(DataTypes.BLOB) data: Uint8Array; + /** + * The transaction that this message belongs to + */ @BelongsTo(() => Transaction, "txId") transaction: Transaction; + /** + * The block that this message belongs to + */ @BelongsTo(() => Block, "height") block: Block; + /** + * The address references of the message + */ @HasMany(() => AddressReference, "messageId") addressReferences: AddressReference[]; } From b204711adb721e463764311c459f852b2828d6fc Mon Sep 17 00:00:00 2001 From: Maxime Beauchamp <15185355+baktun14@users.noreply.github.com> Date: Sun, 26 Jan 2025 22:39:29 -0500 Subject: [PATCH 21/27] chore: add detailed documentation to monitored value schema --- packages/database/dbSchemas/base/message.ts | 2 +- .../database/dbSchemas/base/monitoredValue.ts | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/packages/database/dbSchemas/base/message.ts b/packages/database/dbSchemas/base/message.ts index bd2531d2d..845bea6f8 100644 --- a/packages/database/dbSchemas/base/message.ts +++ b/packages/database/dbSchemas/base/message.ts @@ -68,7 +68,7 @@ export class Message extends Model { */ @Column(DataTypes.DECIMAL(30, 0)) amount?: string; /** - * The data of the message + * The protobuf encoded data of the message */ @Required @Column(DataTypes.BLOB) data: Uint8Array; diff --git a/packages/database/dbSchemas/base/monitoredValue.ts b/packages/database/dbSchemas/base/monitoredValue.ts index be300f42f..d67188179 100644 --- a/packages/database/dbSchemas/base/monitoredValue.ts +++ b/packages/database/dbSchemas/base/monitoredValue.ts @@ -3,14 +3,34 @@ import { Column, Default, Model, PrimaryKey, Table } from "sequelize-typescript" import { Required } from "../decorators/requiredDecorator"; +/** + * MonitoredValue model for Akash + * + * This is used to store the monitored value data for notification process + */ @Table({ modelName: "monitoredValue", indexes: [{ unique: true, fields: ["tracker", "target"] }] }) export class MonitoredValue extends Model { + /** + * The database ID of the monitored value + */ @Required @PrimaryKey @Default(UUIDV4) @Column(DataTypes.UUID) id: string; + /** + * The tracker of the monitored value + */ @Required @Column tracker: string; + /** + * The target of the monitored value + */ @Required @Column target: string; + /** + * The value of the monitored value + */ @Column value?: string; + /** + * The last update date of the monitored value + */ @Column lastUpdateDate?: Date; } From f06f90fe1fad73d1e1df87c354a123ab6e31209b Mon Sep 17 00:00:00 2001 From: Maxime Beauchamp <15185355+baktun14@users.noreply.github.com> Date: Sun, 26 Jan 2025 22:42:57 -0500 Subject: [PATCH 22/27] chore: add detailed documentation to transaction schema --- .../database/dbSchemas/base/transaction.ts | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/packages/database/dbSchemas/base/transaction.ts b/packages/database/dbSchemas/base/transaction.ts index 6e2a1d68f..11136697c 100644 --- a/packages/database/dbSchemas/base/transaction.ts +++ b/packages/database/dbSchemas/base/transaction.ts @@ -6,6 +6,11 @@ import { AddressReference } from "./addressReference"; import { Block } from "./block"; import { Message } from "./message"; +/** + * Transaction model for Akash + * + * This is used to store the transaction data + */ @Table({ modelName: "transaction", indexes: [ @@ -16,21 +21,69 @@ import { Message } from "./message"; ] }) export class Transaction extends Model { + /** + * The database ID of the transaction + */ @Required @PrimaryKey @Default(DataTypes.UUIDV4) @Column(DataTypes.UUID) id: string; + /** + * The hash of the transaction + */ @Required @Column hash: string; + /** + * The index of the transaction in the block + */ @Required @Column index: number; + /** + * The height of the block that this transaction belongs to + */ @Required @Column height: number; + /** + * The number of messages in the transaction + */ @Required @Column msgCount: number; + /** + * The threshold of the multisig transaction + */ @Column multisigThreshold?: number; + /** + * The amount of gas used in the transaction + */ @Required @Column gasUsed: number; + /** + * The amount of gas wanted in the transaction + */ @Required @Column gasWanted: number; + /** + * The fee of the transaction + */ @Required @Column(DataTypes.DECIMAL(30, 0)) fee: string; + /** + * The memo of the transaction + */ @Required @Column(DataTypes.TEXT) memo: string; + /** + * Whether the transaction has been processed by the indexer + */ @Required @Default(false) @Column isProcessed: boolean; + /** + * Whether the transaction has processing error + */ @Required @Default(false) @Column hasProcessingError: boolean; + /** + * The error message if the transaction failed + */ @Column(DataTypes.TEXT) log?: string; + /** + * The block that this transaction belongs to + */ @BelongsTo(() => Block, "height") block: Block; + /** + * The messages in this transaction + */ @HasMany(() => Message, "txId") messages?: Message[]; + /** + * The address references in this transaction + */ @HasMany(() => AddressReference, "transactionId") addressReferences?: AddressReference[]; } From d9eeea039acc26ec8ad84f40d104dad676c54e99 Mon Sep 17 00:00:00 2001 From: Maxime Beauchamp <15185355+baktun14@users.noreply.github.com> Date: Sun, 26 Jan 2025 22:45:30 -0500 Subject: [PATCH 23/27] chore: add detailed documentation to validator schema --- packages/database/dbSchemas/base/validator.ts | 55 ++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/packages/database/dbSchemas/base/validator.ts b/packages/database/dbSchemas/base/validator.ts index 72ddae443..25ff7aba1 100644 --- a/packages/database/dbSchemas/base/validator.ts +++ b/packages/database/dbSchemas/base/validator.ts @@ -3,6 +3,11 @@ import { Column, Default, Model, PrimaryKey, Table } from "sequelize-typescript" import { Required } from "../decorators/requiredDecorator"; +/** + * Validator model for Akash + * + * This is used to store the validator data + */ @Table({ modelName: "validator", indexes: [ @@ -13,21 +18,69 @@ import { Required } from "../decorators/requiredDecorator"; ] }) export class Validator extends Model { + /** + * The database ID of the validator + */ @Required @PrimaryKey @Default(UUIDV4) @Column(DataTypes.UUID) id!: string; + /** + * The operator address of the validator + */ @Required @Column operatorAddress: string; + /** + * The account address of the validator + */ @Required @Column accountAddress: string; + /** + * The hex address of the validator + */ @Required @Column hexAddress: string; + /** + * The ID of the message that created this validator + * Message which created the validator (MsgCreateValidator). + */ @Column(DataTypes.UUID) createdMsgId?: string; + /** + * The moniker of the validator + */ @Required @Column moniker: string; + /** + * The identity of the validator + */ @Column identity?: string; + /** + * The website of the validator + */ @Column website?: string; + /** + * The description of the validator + */ @Column(DataTypes.TEXT) description?: string; + /** + * The security contact of the validator + */ @Column securityContact?: string; + /** + * The rate of the validator + */ @Required @Column(DataTypes.DOUBLE) rate: number; + /** + * The maximum rate of the validator + */ @Required @Column(DataTypes.DOUBLE) maxRate: number; + /** + * The maximum change rate of the validator + */ @Required @Column(DataTypes.DOUBLE) maxChangeRate: number; + /** + * The minimum self delegation of the validator + */ @Required @Column(DataTypes.BIGINT) minSelfDelegation: number; - + /** + * The keybase username of the validator + */ @Column keybaseUsername?: string; + /** + * The keybase avatar URL of the validator + */ @Column keybaseAvatarUrl?: string; } From b0411e929be3b3e84a74b3f4e51e338d3b2b8140 Mon Sep 17 00:00:00 2001 From: Maxime Beauchamp <15185355+baktun14@users.noreply.github.com> Date: Sun, 26 Jan 2025 22:49:50 -0500 Subject: [PATCH 24/27] chore: add detailed documentation to template schema --- packages/database/dbSchemas/user/template.ts | 49 ++++++++++++++++++-- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/packages/database/dbSchemas/user/template.ts b/packages/database/dbSchemas/user/template.ts index a5c8b9f45..cdce8b0d0 100644 --- a/packages/database/dbSchemas/user/template.ts +++ b/packages/database/dbSchemas/user/template.ts @@ -5,22 +5,65 @@ import { Required } from "../decorators/requiredDecorator"; import { TemplateFavorite } from "./templateFavorite"; import { UserSetting } from "./userSetting"; +/** + * Template model for Akash users + * + * This is used to store the template data of a user + */ @Table({ modelName: "template", indexes: [{ fields: ["userId"] }] }) export class Template extends Model { + /** + * The database ID of the template + */ @Required @PrimaryKey @Default(UUIDV4) @Column(DataTypes.UUID) id: string; + /** + * The user ID of the template + */ @Required @Column userId: string; + /** + * The template ID that this template was copied from + */ @Column(DataTypes.UUID) copiedFromId?: string; + /** + * The title of the template + */ @Required @Column title: string; + /** + * The description of the template + */ @Column(DataTypes.TEXT) description?: string; + /** + * Whether the template is public + */ @Required @Default(false) @Column isPublic: boolean; + /** + * The CPU of the template in thousandths of CPU + * 1000 = 1 CPU + */ @Required @Column(DataTypes.BIGINT) cpu: number; + /** + * The RAM of the template in bytes + */ @Required @Column(DataTypes.BIGINT) ram: number; + /** + * The storage of the template in bytes + */ @Required @Column(DataTypes.BIGINT) storage: number; + /** + * The SDL of the template + */ @Required @Column(DataTypes.TEXT) sdl: string; - + /** + * The user setting of the template + */ @BelongsTo(() => UserSetting, { foreignKey: "userId", targetKey: "userId" }) userSetting: UserSetting; + /** + * The template favorites of the template + */ @HasMany(() => TemplateFavorite, "templateId") templateFavorites: TemplateFavorite[]; - - // Self reference to keep track of Save as + /** + * The template that this template was copied from + * Self reference to keep track of Save as + */ @BelongsTo(() => Template, "copiedFromId") copiedFrom: Template; } From a29795d92d21a1530485151bef744400b8ccd1f5 Mon Sep 17 00:00:00 2001 From: Maxime Beauchamp <15185355+baktun14@users.noreply.github.com> Date: Sun, 26 Jan 2025 22:50:43 -0500 Subject: [PATCH 25/27] chore: add detailed documentation to template favorite schema --- .../dbSchemas/user/templateFavorite.ts | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/packages/database/dbSchemas/user/templateFavorite.ts b/packages/database/dbSchemas/user/templateFavorite.ts index 8b1a186e1..8246a7cc3 100644 --- a/packages/database/dbSchemas/user/templateFavorite.ts +++ b/packages/database/dbSchemas/user/templateFavorite.ts @@ -4,12 +4,31 @@ import { BelongsTo, Column, Default, Model, PrimaryKey, Table } from "sequelize- import { Required } from "../decorators/requiredDecorator"; import { Template } from "./template"; +/** + * Template favorite model for Akash users + * + * This is used to store the template favorite data of a user + */ @Table({ modelName: "templateFavorite", indexes: [{ unique: true, fields: ["userId", "templateId"] }] }) export class TemplateFavorite extends Model { + /** + * The database ID of the template favorite + */ @Required @PrimaryKey @Default(UUIDV4) @Column(DataTypes.UUID) id: string; + /** + * The user ID of the template favorite + */ @Required @Column userId: string; + /** + * The template ID of the template favorite + */ @Required @Column(DataTypes.UUID) templateId: string; + /** + * The date when the template was added + */ @Required @Column addedDate: Date; - + /** + * The template that this template favorite belongs to + */ @BelongsTo(() => Template, "templateId") template: Template; } From 39d2d6ab14c40bd4b7579725317187cff93c9855 Mon Sep 17 00:00:00 2001 From: Maxime Beauchamp <15185355+baktun14@users.noreply.github.com> Date: Mon, 27 Jan 2025 11:16:44 -0500 Subject: [PATCH 26/27] chore: add detailed documentation to user setting schema --- .../database/dbSchemas/user/userSetting.ts | 52 ++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/packages/database/dbSchemas/user/userSetting.ts b/packages/database/dbSchemas/user/userSetting.ts index a2060ed9b..f55472a09 100644 --- a/packages/database/dbSchemas/user/userSetting.ts +++ b/packages/database/dbSchemas/user/userSetting.ts @@ -4,6 +4,11 @@ import { Column, Default, HasMany, Model, PrimaryKey, Table } from "sequelize-ty import { Required } from "../decorators/requiredDecorator"; import { Template } from "./template"; +/** + * User setting model for Akash users + * + * This is used to store the user setting data of a user + */ @Table({ modelName: "userSetting", indexes: [ @@ -12,20 +17,65 @@ import { Template } from "./template"; ] }) export class UserSetting extends Model { + /** + * The database ID of the user setting + */ @Required @PrimaryKey @Default(UUIDV4) @Column(DataTypes.UUID) id: string; + /** + * The user ID of the user + * This is the auth0 ID of the user + */ @Column userId: string; + /** + * The username of the user + */ @Column username: string; + /** + * The email of the user + */ @Column email?: string; + /** + * Whether the email of the user setting is verified + */ @Required @Default(false) @Column emailVerified: boolean; + /** + * The Stripe customer ID of the user setting + */ @Column stripeCustomerId?: string; + /** + * The bio of the user setting + */ @Column(DataTypes.TEXT) bio?: string; + /** + * Whether the user setting is subscribed to the newsletter + */ @Required @Default(false) @Column subscribedToNewsletter: boolean; + /** + * The YouTube username of the user setting + */ @Column youtubeUsername?: string; + /** + * The Twitter username of the user setting + */ @Column twitterUsername?: string; + /** + * The GitHub username of the user setting + */ @Column githubUsername?: string; + /** + * The last IP address of the user setting + */ @Column({ field: "last_ip" }) lastIp?: string; + /** + * The last user agent of the user setting + */ @Column({ field: "last_user_agent" }) lastUserAgent?: string; + /** + * The last fingerprint of the user setting + */ @Column({ field: "last_fingerprint" }) lastFingerprint?: string; - + /** + * The templates of the user setting + */ @HasMany(() => Template, { foreignKey: "userId", sourceKey: "userId" }) templates: Template[]; } From 7de9c4b0d289a2da3dc6fbe9f41e356981d9a5ef Mon Sep 17 00:00:00 2001 From: Maxime Beauchamp <15185355+baktun14@users.noreply.github.com> Date: Tue, 28 Jan 2025 14:44:19 -0500 Subject: [PATCH 27/27] chore: add detailed documentation to Akash block schema --- packages/database/dbSchemas/akash/akashBlock.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/database/dbSchemas/akash/akashBlock.ts b/packages/database/dbSchemas/akash/akashBlock.ts index d9d8baf3b..80a291dc6 100644 --- a/packages/database/dbSchemas/akash/akashBlock.ts +++ b/packages/database/dbSchemas/akash/akashBlock.ts @@ -36,11 +36,13 @@ export class AkashBlock extends Block { */ @Column totalLeaseCount?: number; /** - * Total amount of active CPU at current block height + * Total amount of active CPU in thousandths of a CPU at current block height + * 1 CPU = 1000 thousandths of a CPU */ @Column activeCPU?: number; /** * Total amount of active GPU at current block height + * 1 GPU = 1 unit of a GPU */ @Column activeGPU?: number; /**