From c27321b9b3d4a7105760731f4b600ec83ba561ba Mon Sep 17 00:00:00 2001 From: Noah Prince <83885631+ChewingGlass@users.noreply.github.com> Date: Fri, 31 Jan 2025 12:03:42 -0800 Subject: [PATCH] Remove temporary endpoints for 138 (#803) * Remove temporary endpoints for 138 * Bump cargo --- Cargo.lock | 2 +- .../src/fix-claimed-epochs.ts | 67 ------ .../src/migrate-to-hip-138.ts | 223 ------------------ programs/helium-sub-daos/Cargo.toml | 2 +- .../helium-sub-daos/src/instructions/mod.rs | 4 - .../instructions/temp_fix_claimed_epoch.rs | 23 -- .../src/instructions/temp_resize_account.rs | 48 ---- programs/helium-sub-daos/src/lib.rs | 8 - 8 files changed, 2 insertions(+), 375 deletions(-) delete mode 100644 packages/helium-admin-cli/src/fix-claimed-epochs.ts delete mode 100644 packages/helium-admin-cli/src/migrate-to-hip-138.ts delete mode 100644 programs/helium-sub-daos/src/instructions/temp_fix_claimed_epoch.rs delete mode 100644 programs/helium-sub-daos/src/instructions/temp_resize_account.rs diff --git a/Cargo.lock b/Cargo.lock index f6dd7bb71..21fcfbc40 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1964,7 +1964,7 @@ dependencies = [ [[package]] name = "helium-sub-daos" -version = "0.2.6" +version = "0.2.7" dependencies = [ "anchor-lang", "anchor-spl", diff --git a/packages/helium-admin-cli/src/fix-claimed-epochs.ts b/packages/helium-admin-cli/src/fix-claimed-epochs.ts deleted file mode 100644 index 6f94efd9a..000000000 --- a/packages/helium-admin-cli/src/fix-claimed-epochs.ts +++ /dev/null @@ -1,67 +0,0 @@ -import * as anchor from "@coral-xyz/anchor"; -import { - lazyDistributorKey -} from "@helium/lazy-distributor-sdk"; -import { init as initHsd } from "@helium/helium-sub-daos-sdk"; -import { organizationKey } from "@helium/organization-sdk"; -import { oracleSignerKey } from "@helium/rewards-oracle-sdk"; -import { - batchParallelInstructionsWithPriorityFee -} from "@helium/spl-utils"; -import { getAssociatedTokenAddressSync } from "@solana/spl-token"; -import { PublicKey, TransactionInstruction } from "@solana/web3.js"; -import Squads from "@sqds/sdk"; -import fs from "fs"; -import os from "os"; -import yargs from "yargs/yargs"; -import { - loadKeypair, - parseEmissionsSchedule, - sendInstructionsOrSquads, -} from "./utils"; - -export async function run(args: any = process.argv) { - const yarg = yargs(args).options({ - wallet: { - alias: "k", - describe: "Anchor wallet keypair", - default: `${os.homedir()}/.config/solana/id.json`, - }, - url: { - alias: "u", - default: "http://127.0.0.1:8899", - describe: "The solana url", - }, - delegatedPositions: { - type: "string", - describe: "Path to the delegated positions file", - default: __dirname + "/delegatedPositions.txt", - }, - }); - const argv = await yarg.argv; - process.env.ANCHOR_WALLET = argv.wallet; - process.env.ANCHOR_PROVIDER_URL = argv.url; - anchor.setProvider(anchor.AnchorProvider.local(argv.url)); - const provider = anchor.getProvider() as anchor.AnchorProvider; - const wallet = new anchor.Wallet(loadKeypair(argv.wallet)); - const hsdProgram = await initHsd(provider); - - const delegatedPositions = fs.readFileSync(argv.delegatedPositions, "utf-8") - .split("\n") - .filter(line => line.trim() !== ""); // Remove empty lines - - const instructions: TransactionInstruction[] = []; - for (const delegatedPosition of delegatedPositions) { - console.log(delegatedPosition, new PublicKey(delegatedPosition).toBase58()); - instructions.push( - await hsdProgram.methods - .tempFixClaimedEpoch() - .accounts({ - authority: wallet.publicKey, - delegatedPosition: new PublicKey(delegatedPosition), - }) - .instruction() - ); - } - await batchParallelInstructionsWithPriorityFee(provider, instructions, {maxSignatureBatch: 100}); -} diff --git a/packages/helium-admin-cli/src/migrate-to-hip-138.ts b/packages/helium-admin-cli/src/migrate-to-hip-138.ts deleted file mode 100644 index 0eafd2a4e..000000000 --- a/packages/helium-admin-cli/src/migrate-to-hip-138.ts +++ /dev/null @@ -1,223 +0,0 @@ -import * as anchor from "@coral-xyz/anchor"; -import { ThresholdType } from "@helium/circuit-breaker-sdk"; -import { - daoKey, - delegatorRewardsPercent, - init as initHsd, -} from "@helium/helium-sub-daos-sdk"; -import { - init as initLazy, - lazyDistributorKey, -} from "@helium/lazy-distributor-sdk"; -import { organizationKey } from "@helium/organization-sdk"; -import { oracleSignerKey } from "@helium/rewards-oracle-sdk"; -import { - batchParallelInstructionsWithPriorityFee, - HNT_MINT, - IOT_MINT, - MOBILE_MINT, -} from "@helium/spl-utils"; -import { getAssociatedTokenAddressSync } from "@solana/spl-token"; -import { PublicKey, TransactionInstruction } from "@solana/web3.js"; -import Squads from "@sqds/sdk"; -import os from "os"; -import yargs from "yargs/yargs"; -import { - loadKeypair, - parseEmissionsSchedule, - sendInstructionsOrSquads, -} from "./utils"; - -export async function run(args: any = process.argv) { - const yarg = yargs(args).options({ - wallet: { - alias: "k", - describe: "Anchor wallet keypair", - default: `${os.homedir()}/.config/solana/id.json`, - }, - url: { - alias: "u", - default: "http://127.0.0.1:8899", - describe: "The solana url", - }, - iotMint: { - type: "string", - describe: "IOT mint of the subdao to migrate", - default: IOT_MINT.toBase58(), - }, - hntMint: { - type: "string", - describe: "HNT mint of the subdao to migrate", - default: HNT_MINT.toBase58(), - }, - mobileMint: { - type: "string", - describe: "Mobile mint of the subdao to migrate", - default: MOBILE_MINT.toBase58(), - }, - rewardsOracleUrl: { - alias: "ro", - type: "string", - describe: "The rewards oracle URL", - required: true, - }, - oracleKey: { - type: "string", - describe: "Pubkey of the oracle", - required: true, - }, - emissionSchedulePath: { - required: true, - describe: "Path to file that contains the hnt emissions schedule", - type: "string", - }, - hstEmissionsSchedulePath: { - required: true, - describe: "Path to file that contains the new HST emissions schedule", - type: "string", - }, - executeTransaction: { - type: "boolean", - }, - multisig: { - type: "string", - describe: - "Address of the squads multisig to be authority. If not provided, your wallet will be the authority", - }, - authorityIndex: { - type: "number", - describe: "Authority index for squads. Defaults to 1", - default: 1, - }, - }); - const argv = await yarg.argv; - process.env.ANCHOR_WALLET = argv.wallet; - process.env.ANCHOR_PROVIDER_URL = argv.url; - anchor.setProvider(anchor.AnchorProvider.local(argv.url)); - const provider = anchor.getProvider() as anchor.AnchorProvider; - const wallet = new anchor.Wallet(loadKeypair(argv.wallet)); - const lazyDistProgram = await initLazy(provider); - const hsdProgram = await initHsd(provider); - - const instructions: TransactionInstruction[] = []; - - const hntMint = new PublicKey(argv.hntMint); - const dao = daoKey(hntMint)[0]; - - const resizes: TransactionInstruction[] = []; - resizes.push( - await hsdProgram.methods - .tempResizeAccount() - .accounts({ - account: dao, - payer: wallet.publicKey, - }) - .instruction() - ); - const daoEpochInfos = await hsdProgram.account.daoEpochInfoV0.all(); - for (const daoEpochInfo of daoEpochInfos) { - resizes.push( - await hsdProgram.methods - .tempResizeAccount() - .accounts({ - account: daoEpochInfo.publicKey, - payer: wallet.publicKey, - }) - .instruction() - ); - } - console.log("Resizing accounts"); - await batchParallelInstructionsWithPriorityFee(provider, resizes); - - const daoAcc = await hsdProgram.account.daoV0.fetch(dao); - const authority = daoAcc.authority; - const oracleKey = new PublicKey(argv.oracleKey!); - const emissionSchedule = await parseEmissionsSchedule( - argv.emissionSchedulePath - ); - - const ld = lazyDistributorKey(hntMint)[0]; - const ldAcc = await lazyDistProgram.account.lazyDistributorV0.fetchNullable( - ld - ); - if (ldAcc) { - console.warn("Lazy distributor already exists, skipping."); - } else { - instructions.push( - await lazyDistProgram.methods - .initializeLazyDistributorV0({ - authority: daoAcc.authority, - oracles: [ - { - oracle: oracleKey, - url: argv.rewardsOracleUrl, - }, - ], - // 5 x epoch rewards in a 24 hour period - windowConfig: { - windowSizeSeconds: new anchor.BN(24 * 60 * 60), - thresholdType: ThresholdType.Absolute as never, - threshold: new anchor.BN(emissionSchedule[0].emissionsPerEpoch).mul( - new anchor.BN(5) - ), - }, - approver: oracleSignerKey()[0], - }) - .accounts({ - payer: authority, - rewardsMint: hntMint, - }) - .instruction() - ); - } - - instructions.push( - await hsdProgram.methods - .updateDaoV0({ - authority: null, - emissionSchedule: null, - hstEmissionSchedule: await parseEmissionsSchedule( - argv.hstEmissionsSchedulePath! - ), - netEmissionsCap: null, - hstPool: null, - proposalNamespace: organizationKey("Helium")[0], - delegatorRewardsPercent: delegatorRewardsPercent(6), - rewardsEscrow: getAssociatedTokenAddressSync(hntMint, ld, true), - }) - .accounts({ - dao, - authority: daoAcc.authority, - payer: daoAcc.authority, - }) - .instruction() - ); - - if (!daoAcc.delegatorPool || daoAcc.delegatorPool.equals(PublicKey.default)) { - instructions.push( - await hsdProgram.methods - .initializeHntDelegatorPool() - .accounts({ - dao, - payer: daoAcc.authority, - delegatorPool: getAssociatedTokenAddressSync(hntMint, dao, true), - authority: daoAcc.authority, - }) - .instruction() - ); - } - - const squads = Squads.endpoint(process.env.ANCHOR_PROVIDER_URL, wallet, { - commitmentOrConfig: "finalized", - }); - - await sendInstructionsOrSquads({ - provider, - instructions, - executeTransaction: argv.executeTransaction, - squads, - multisig: argv.multisig ? new PublicKey(argv.multisig) : undefined, - authorityIndex: argv.authorityIndex, - signers: [], - }); -} diff --git a/programs/helium-sub-daos/Cargo.toml b/programs/helium-sub-daos/Cargo.toml index ffa75c50a..d14abfd2b 100644 --- a/programs/helium-sub-daos/Cargo.toml +++ b/programs/helium-sub-daos/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "helium-sub-daos" -version = "0.2.6" +version = "0.2.7" description = "Created with Anchor" edition = "2021" diff --git a/programs/helium-sub-daos/src/instructions/mod.rs b/programs/helium-sub-daos/src/instructions/mod.rs index a8061204e..4f9f98ea7 100644 --- a/programs/helium-sub-daos/src/instructions/mod.rs +++ b/programs/helium-sub-daos/src/instructions/mod.rs @@ -7,8 +7,6 @@ pub mod initialize_hnt_delegator_pool; pub mod initialize_sub_dao_v0; pub mod issue_rewards_v0; pub mod switch_mobile_ops_fund; -pub mod temp_fix_claimed_epoch; -pub mod temp_resize_account; pub mod temp_update_sub_dao_epoch_info; pub mod track_dc_burn_v0; pub mod track_dc_onboarding_fees_v0; @@ -25,8 +23,6 @@ pub use initialize_hnt_delegator_pool::*; pub use initialize_sub_dao_v0::*; pub use issue_rewards_v0::*; pub use switch_mobile_ops_fund::*; -pub use temp_fix_claimed_epoch::*; -pub use temp_resize_account::*; pub use temp_update_sub_dao_epoch_info::*; pub use track_dc_burn_v0::*; pub use track_dc_onboarding_fees_v0::*; diff --git a/programs/helium-sub-daos/src/instructions/temp_fix_claimed_epoch.rs b/programs/helium-sub-daos/src/instructions/temp_fix_claimed_epoch.rs deleted file mode 100644 index 0413e3081..000000000 --- a/programs/helium-sub-daos/src/instructions/temp_fix_claimed_epoch.rs +++ /dev/null @@ -1,23 +0,0 @@ -use std::str::FromStr; - -use anchor_lang::prelude::*; - -use crate::DelegatedPositionV0; - -#[derive(Accounts)] -pub struct TempFixClaimedEpoch<'info> { - #[account( - mut, - address = Pubkey::from_str("hprdnjkbziK8NqhThmAn5Gu4XqrBbctX8du4PfJdgvW").unwrap() - )] - pub authority: Signer<'info>, - #[account(mut)] - pub delegated_position: Account<'info, DelegatedPositionV0>, - pub system_program: Program<'info, System>, -} - -pub fn handler(ctx: Context) -> Result<()> { - ctx.accounts.delegated_position.set_unclaimed(20117)?; - - Ok(()) -} diff --git a/programs/helium-sub-daos/src/instructions/temp_resize_account.rs b/programs/helium-sub-daos/src/instructions/temp_resize_account.rs deleted file mode 100644 index f3091c4b5..000000000 --- a/programs/helium-sub-daos/src/instructions/temp_resize_account.rs +++ /dev/null @@ -1,48 +0,0 @@ -use std::str::FromStr; - -use anchor_lang::{ - prelude::*, - solana_program::{program::invoke, system_instruction}, -}; -use voter_stake_registry::TESTING; - -use crate::RecentProposal; - -#[derive(Accounts)] -pub struct TempResizeAccount<'info> { - #[account( - mut, - address = if TESTING { payer.key() } else { Pubkey::from_str("hprdnjkbziK8NqhThmAn5Gu4XqrBbctX8du4PfJdgvW").unwrap() } - )] - pub payer: Signer<'info>, - /// CHECK: Resizing account - #[account(mut)] - pub account: AccountInfo<'info>, - pub system_program: Program<'info, System>, -} - -pub fn handler(ctx: Context) -> Result<()> { - let account = &mut ctx.accounts.account; - let mut new_size = account.data_len() + std::mem::size_of::() * 4; - // This is the dao account. - if account.key() == Pubkey::from_str("BQ3MCuTT5zVBhNfQ4SjMh3NPVhFy73MPV8rjfq5d1zie").unwrap() { - new_size += 104; // Add space for rewards_escrow, delegator_pool, delegator_rewards_percent, proposal_namespace - } else { - new_size += 8; // Delegation rewards issued - } - let rent = Rent::get()?; - let new_minimum_balance = rent.minimum_balance(new_size); - let lamports_diff = new_minimum_balance.saturating_sub(account.to_account_info().lamports()); - - invoke( - &system_instruction::transfer(ctx.accounts.payer.key, &account.key(), lamports_diff), - &[ - ctx.accounts.payer.to_account_info().clone(), - account.to_account_info().clone(), - ctx.accounts.system_program.to_account_info().clone(), - ], - )?; - account.to_account_info().realloc(new_size, false)?; - - Ok(()) -} diff --git a/programs/helium-sub-daos/src/lib.rs b/programs/helium-sub-daos/src/lib.rs index 156c136df..328f87364 100644 --- a/programs/helium-sub-daos/src/lib.rs +++ b/programs/helium-sub-daos/src/lib.rs @@ -140,15 +140,7 @@ pub mod helium_sub_daos { extend_expiration_ts_v0::handler(ctx) } - pub fn temp_resize_account(ctx: Context) -> Result<()> { - temp_resize_account::handler(ctx) - } - pub fn track_vote_v0(ctx: Context) -> Result<()> { track_vote_v0::handler(ctx) } - - pub fn temp_fix_claimed_epoch(ctx: Context) -> Result<()> { - temp_fix_claimed_epoch::handler(ctx) - } }