diff --git a/apps/commune-worker/src/db/index.ts b/apps/commune-worker/src/db/index.ts index 9d8fdd9b..58e98d89 100644 --- a/apps/commune-worker/src/db/index.ts +++ b/apps/commune-worker/src/db/index.ts @@ -12,7 +12,7 @@ import { export type NewVote = typeof daoVoteSchema.$inferInsert; export type Module = typeof moduleData.$inferInsert; -export type Subnet = typeof subnetDataSchema.$inferInsert +export type Subnet = typeof subnetDataSchema.$inferInsert; export type NewNotification = typeof governanceNotificationSchema.$inferInsert; @@ -40,7 +40,8 @@ export async function upsertSubnetData(subnets: Subnet[]) { proposalExpiration: s.proposalExpiration, voteMode: s.voteMode, proposalRewardTreasuryAllocation: s.proposalRewardTreasuryAllocation, - maxProposalRewardTreasuryAllocation: s.maxProposalRewardTreasuryAllocation, + maxProposalRewardTreasuryAllocation: + s.maxProposalRewardTreasuryAllocation, proposalRewardInterval: s.proposalRewardInterval, minBurn: s.minBurn, maxBurn: s.maxBurn, @@ -51,7 +52,7 @@ export async function upsertSubnetData(subnets: Subnet[]) { minValidatorStake: s.minValidatorStake, maxAllowedValidators: s.maxAllowedValidators, atBlock: s.atBlock, - + subnetEmission: s.subnetEmission, })), ) .onConflictDoUpdate({ diff --git a/apps/commune-worker/src/db/type-transformations.ts b/apps/commune-worker/src/db/type-transformations.ts index 8a438759..b5bd9abb 100644 --- a/apps/commune-worker/src/db/type-transformations.ts +++ b/apps/commune-worker/src/db/type-transformations.ts @@ -1,4 +1,4 @@ -import type { SubspaceModule, NetworkSubnetConfig } from "@commune-ts/types"; +import type { NetworkSubnetConfig, SubspaceModule } from "@commune-ts/types"; import type { Module, Subnet } from "./index.js"; @@ -25,8 +25,10 @@ export function SubspaceModuleToDatabase( }; } - -export function SubnetToDatabase(subnet: NetworkSubnetConfig, atBlock: number): Subnet { +export function SubnetToDatabase( + subnet: NetworkSubnetConfig, + atBlock: number, +): Subnet { return { netuid: subnet.netuid, name: subnet.subnetNames, @@ -42,22 +44,28 @@ export function SubnetToDatabase(subnet: NetworkSubnetConfig, atBlock: number): maxWeightAge: subnet.maxWeightAge, bondsMa: subnet.bondsMovingAverage ?? null, maximumSetWeightCallsPerEpoch: subnet.maximumSetWeightCallsPerEpoch ?? null, - minValidatorStake: subnet.minValidatorStake ?? null, + minValidatorStake: subnet.minValidatorStake, maxAllowedValidators: subnet.maxAllowedValidators ?? null, subnetMetadata: subnet.subnetMetadata, minBurn: subnet.moduleBurnConfig.minBurn, maxBurn: subnet.moduleBurnConfig.maxBurn, adjustmentAlpha: subnet.moduleBurnConfig.adjustmentAlpha, - targetRegistrationsInterval: subnet.moduleBurnConfig.targetRegistrationsInterval, - maxRegistrationsPerInterval: subnet.moduleBurnConfig.maxRegistrationsPerInterval, + targetRegistrationsInterval: + subnet.moduleBurnConfig.targetRegistrationsInterval, + maxRegistrationsPerInterval: + subnet.moduleBurnConfig.maxRegistrationsPerInterval, proposalCost: subnet.subnetGovernanceConfig.proposalCost, proposalExpiration: subnet.subnetGovernanceConfig.proposalExpiration, - maxProposalRewardTreasuryAllocation: subnet.subnetGovernanceConfig.maxProposalRewardTreasuryAllocation, - proposalRewardTreasuryAllocation: subnet.subnetGovernanceConfig.proposalRewardTreasuryAllocation, - proposalRewardInterval: subnet.subnetGovernanceConfig.proposalRewardInterval, - targetRegistrationsPerInterval: subnet.moduleBurnConfig.targetRegistrationsPerInterval, + maxProposalRewardTreasuryAllocation: + subnet.subnetGovernanceConfig.maxProposalRewardTreasuryAllocation, + proposalRewardTreasuryAllocation: + subnet.subnetGovernanceConfig.proposalRewardTreasuryAllocation, + proposalRewardInterval: + subnet.subnetGovernanceConfig.proposalRewardInterval, + targetRegistrationsPerInterval: + subnet.moduleBurnConfig.targetRegistrationsPerInterval, subnetEmission: subnet.subnetEmission, atBlock: atBlock, voteMode: subnet.subnetGovernanceConfig.voteMode, }; -} \ No newline at end of file +} diff --git a/packages/db/src/schema.ts b/packages/db/src/schema.ts index d006ea45..73d6e752 100644 --- a/packages/db/src/schema.ts +++ b/packages/db/src/schema.ts @@ -3,12 +3,12 @@ import { bigint, index, integer, + numeric, pgEnum, pgTableCreator, pgView, real, serial, - numeric, text, timestamp, unique, @@ -103,7 +103,10 @@ export const subnetDataSchema = createTable( minAllowedWeights: integer("min_allowed_weights").notNull(), maxAllowedWeights: integer("max_allowed_weights").notNull(), maxAllowedUids: integer("max_allowed_uids").notNull(), - maxWeightAge: numeric("max_weight_age", { precision: 20, scale: 0 }).notNull(), + maxWeightAge: numeric("max_weight_age", { + precision: 20, + scale: 0, + }).notNull(), trustRatio: integer("trust_ratio").notNull(), founderShare: integer("founder_share").notNull(), incentiveRatio: integer("incentive_ratio").notNull(), @@ -111,6 +114,7 @@ export const subnetDataSchema = createTable( maximumSetWeightCallsPerEpoch: integer( "maximum_set_weight_calls_per_epoch", ), + subnetEmission: bigint("subnet_emission", { mode: "bigint" }).notNull(), bondsMa: integer("bonds_ma"), immunityPeriod: integer("immunity_period").notNull(), subnetMetadata: text("subnet_metadata"), @@ -129,7 +133,10 @@ export const subnetDataSchema = createTable( // BurnConfiguration fields minBurn: bigint("min_burn", { mode: "bigint" }).notNull(), maxBurn: bigint("max_burn", { mode: "bigint" }).notNull(), - adjustmentAlpha: numeric("adjustment_alpha", { precision: 20, scale: 0 }).notNull(), + adjustmentAlpha: numeric("adjustment_alpha", { + precision: 20, + scale: 0, + }).notNull(), targetRegistrationsInterval: integer( "target_registrations_interval", ).notNull(), diff --git a/packages/types/types.ts b/packages/types/types.ts index 1691cfe3..f4cdd9ae 100644 --- a/packages/types/types.ts +++ b/packages/types/types.ts @@ -245,18 +245,18 @@ export interface UnrewardedProposal { export type NetworkSubnetConfig = z.infer; export const GOVERNANCE_CONFIG_SCHEMA = z.object({ - proposalCost: z.coerce.number().int(), + proposalCost: z.coerce.bigint(), voteMode: z.string(), - maxProposalRewardTreasuryAllocation: z.coerce.number().int(), + maxProposalRewardTreasuryAllocation: z.coerce.bigint(), proposalRewardInterval: z.coerce.number().int(), proposalRewardTreasuryAllocation: z.coerce.number(), proposalExpiration: z.coerce.number().int(), }); export const MODULE_BURN_CONFIG_SCHEMA = z.object({ - minBurn: z.coerce.number().int(), - maxBurn: z.coerce.number().int(), - adjustmentAlpha: z.coerce.number().int(), + minBurn: z.coerce.bigint(), + maxBurn: z.coerce.bigint(), + adjustmentAlpha: z.coerce.string(), targetRegistrationsInterval: z.coerce.number().int(), targetRegistrationsPerInterval: z.coerce.number().int(), maxRegistrationsPerInterval: z.coerce.number().int(), @@ -275,14 +275,14 @@ export const NetworkSubnetConfigSchema = z.object({ founderShare: z.coerce.number(), incentiveRatio: z.coerce.number().int(), trustRatio: z.coerce.number().int(), - maxWeightAge: z.coerce.number().int(), + maxWeightAge: z.coerce.string(), bondsMovingAverage: z.coerce.number().int().optional(), maximumSetWeightCallsPerEpoch: z.coerce.number().int().optional(), - minValidatorStake: z.coerce.number().int(), + minValidatorStake: z.coerce.bigint(), maxAllowedValidators: z.coerce.number().int().optional(), moduleBurnConfig: MODULE_BURN_CONFIG_SCHEMA, subnetGovernanceConfig: GOVERNANCE_CONFIG_SCHEMA, - subnetEmission: z.coerce.number().int(), + subnetEmission: z.coerce.bigint(), subnetMetadata: z.string().optional(), });