Skip to content

Commit

Permalink
Merge pull request #747 from helium/revert/HIP-124
Browse files Browse the repository at this point in the history
Revert/hip 124
  • Loading branch information
ChewingGlass authored Dec 5, 2024
2 parents 2ac6142 + df5cde2 commit 8291dc1
Show file tree
Hide file tree
Showing 106 changed files with 244 additions and 6,706 deletions.
1 change: 0 additions & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ jobs:
- tests/voter-stake-registry.ts
- tests/fanout.ts
- tests/sus.ts
- tests/position-voting-rewards.ts
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/build-anchor/
Expand Down
2 changes: 0 additions & 2 deletions Anchor.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ fanout = "fanqeMu3fw8R4LwKNbahPtYXJsyLL6NXyfe2BqzhfB6"
mobile_entity_manager = "memMa1HG4odAFmUbGWfPwS1WWfK95k99F2YTkGvyxZr"
hexboosting = "hexbnKYoA2GercNNhHUCCfrTRWrHjT6ujKPXTa5NPqJ"
no_emit = "noEmmgLmQdk6DLiPV8CSwQv3qQDyGEhz9m5A4zhtByv"
position_voting_rewards = "pvr1pJdeAcW6tzFyPRSmkL5Xwysi1Tq79f7KF2XB4zM"

[workspace]
members = [
Expand All @@ -35,7 +34,6 @@ members = [
"programs/mobile-entity-manager",
"programs/hexboosting",
"programs/no-emit",
"programs/position-voting-rewards",
]

[registry]
Expand Down
5 changes: 1 addition & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

## [0.9.9](https://github.com/helium/helium-program-library/compare/v0.9.2...v0.9.9) (2024-10-28)


### Reverts

* Revert "Add temp endpoint to fix mobile hotspots (#683)" (#685) ([3f5a4be](https://github.com/helium/helium-program-library/commit/3f5a4be5fc7da0dcbcd10c0ade199831fc538a9b)), closes [#683](https://github.com/helium/helium-program-library/issues/683) [#685](https://github.com/helium/helium-program-library/issues/685) [#683](https://github.com/helium/helium-program-library/issues/683)
**Note:** Version bump only for package helium-program-library



Expand Down
18 changes: 2 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions packages/anchor-resolvers/src/heliumCommonResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ export const heliumCommonResolver = resolveIndividual(async ({ path }) => {
return new PublicKey("Sysvar1nstructions1111111111111111111111111");
case "lazyDistributorProgram":
return new PublicKey("1azyuavdMyvsivtNxPoz6SucD18eDHeXzFCUPq5XU7w");
case "positionVotingRewardsProgram":
return new PublicKey("pvr1pJdeAcW6tzFyPRSmkL5Xwysi1Tq79f7KF2XB4zM");
case "positionVotingRewards":
return new PublicKey("pvr1pJdeAcW6tzFyPRSmkL5Xwysi1Tq79f7KF2XB4zM");
case "noEmitProgram":
return new PublicKey("noEmmgLmQdk6DLiPV8CSwQv3qQDyGEhz9m5A4zhtByv");
default:
Expand Down
1 change: 0 additions & 1 deletion packages/crons/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
"@helium/nft-proxy-sdk": "^0.0.12",
"@helium/no-emit-sdk": "^0.9.15",
"@helium/organization-sdk": "^0.0.12",
"@helium/position-voting-rewards-sdk": "^0.9.15",
"@helium/price-oracle-sdk": "^0.9.15",
"@helium/proposal-sdk": "^0.0.12",
"@helium/rewards-oracle-sdk": "^0.9.15",
Expand Down
83 changes: 24 additions & 59 deletions packages/crons/src/end-epoch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,12 @@ import {
truthy,
} from "@helium/spl-utils";
import { getAccount } from "@solana/spl-token";
import { init as initPVR, vsrEpochInfoKey } from "@helium/position-voting-rewards-sdk";
import { ComputeBudgetProgram as CBP, Connection, Keypair, PublicKey, SYSVAR_CLOCK_PUBKEY } from "@solana/web3.js";
import {
ComputeBudgetProgram as CBP,
Connection,
Keypair,
SYSVAR_CLOCK_PUBKEY,
} from "@solana/web3.js";
import BN from "bn.js";
import bs58 from "bs58";

Expand All @@ -43,7 +47,7 @@ const IOT_OPERATIONS_FUND = "iot_operations_fund";
const NOT_EMITTED = "not_emitted";
const MAX_CLAIM_AMOUNT = new BN("207020547945205");

const BASE_PRIORITY_FEE = Number(process.env.BASE_PRIORITY_FEE || "1")
const BASE_PRIORITY_FEE = Number(process.env.BASE_PRIORITY_FEE || "1");

async function getSolanaUnixTimestamp(connection: Connection): Promise<bigint> {
const clock = await connection.getAccountInfo(SYSVAR_CLOCK_PUBKEY);
Expand All @@ -64,7 +68,6 @@ async function getSolanaUnixTimestamp(connection: Connection): Promise<bigint> {
const errors: string[] = [];
const provider = anchor.getProvider() as anchor.AnchorProvider;
const heliumSubDaosProgram = await initDao(provider);
const pvrProgram = await initPVR(provider);
const hntMint = HNT_MINT;
const iotMint = IOT_MINT;
const unixNow = new Date().valueOf() / 1000;
Expand All @@ -78,21 +81,13 @@ async function getSolanaUnixTimestamp(connection: Connection): Promise<bigint> {
},
},
]);
const vetokenTrackers = subDaos.map(subDao => subDao.account.vetokenTracker).filter(tracker => !tracker.equals(PublicKey.default));
const vetokenTrackerAccounts = await Promise.all(vetokenTrackers.map(tracker => pvrProgram.account.veTokenTrackerV0.fetch(tracker)));
const targetTsVetokenTrackers = vetokenTrackerAccounts.reduce(
(acc, tracker) => BN.min(acc, tracker.vetokenLastCalculatedTs),
// Start one day back to ensure we at least close the epoch that the job is running in.
new BN(unixNow - 24 * 60 * 60)
);

let targetTsSubdao = subDaos.reduce(
let targetTs = subDaos.reduce(
(acc, subDao) => BN.min(acc, subDao.account.vehntLastCalculatedTs),
// Start one day back to ensure we at least close the epoch that the job is running in.
new BN(unixNow - 24 * 60 * 60)
);
let targetTs = BN.min(targetTsSubdao, targetTsVetokenTrackers);
const solanaTime = await getSolanaUnixTimestamp(provider.connection)
const solanaTime = await getSolanaUnixTimestamp(provider.connection);

mainLoop: while (targetTs.toNumber() < unixNow) {
const epoch = currentEpoch(targetTs);
Expand Down Expand Up @@ -155,7 +150,6 @@ async function getSolanaUnixTimestamp(connection: Connection): Promise<bigint> {
}
}


for (const subDao of subDaos) {
if (!daoEpochInfo?.doneIssuingRewards) {
const [subDaoEpoch] = subDaoEpochInfoKey(subDao.publicKey, targetTs);
Expand Down Expand Up @@ -185,42 +179,6 @@ async function getSolanaUnixTimestamp(connection: Connection): Promise<bigint> {
}
}
}

const hasVeTokenTracker = !subDao.account.vetokenTracker.equals(
PublicKey.default
);

if (hasVeTokenTracker) {
const [vsrEpoch] = vsrEpochInfoKey(
subDao.account.vetokenTracker,
targetTs
);
const vsrEpochInfo =
await pvrProgram.account.vsrEpochInfoV0.fetchNullable(vsrEpoch);
if (!vsrEpochInfo || !vsrEpochInfo.rewardsIssuedAt) {
try {
await sendInstructionsWithPriorityFee(
provider,
[
await heliumSubDaosProgram.methods
.issueVotingRewardsV0({ epoch })
.accounts({
subDao: subDao.publicKey,
vsrEpochInfo: vsrEpoch,
})
.instruction(),
],
{
basePriorityFee: BASE_PRIORITY_FEE,
}
);
} catch (err: any) {
errors.push(
`Failed to issue voting rewards for ${subDao.account.dntMint.toBase58()}: ${err}`
);
}
}
}
}

if (!daoEpochInfo?.doneIssuingHstPool) {
Expand Down Expand Up @@ -301,9 +259,13 @@ async function getSolanaUnixTimestamp(connection: Connection): Promise<bigint> {
mint: assetId,
});

await sendInstructionsWithPriorityFee(provider, [await method.instruction()], {
basePriorityFee: BASE_PRIORITY_FEE
});
await sendInstructionsWithPriorityFee(
provider,
[await method.instruction()],
{
basePriorityFee: BASE_PRIORITY_FEE,
}
);
}

const rewards = await client.getCurrentRewards(
Expand Down Expand Up @@ -395,9 +357,13 @@ async function getSolanaUnixTimestamp(connection: Connection): Promise<bigint> {
lazyDistributor,
mint: assetId,
});
await sendInstructionsWithPriorityFee(provider, [await method.instruction()], {
basePriorityFee: BASE_PRIORITY_FEE
});
await sendInstructionsWithPriorityFee(
provider,
[await method.instruction()],
{
basePriorityFee: BASE_PRIORITY_FEE,
}
);
}

const rewards = await client.getCurrentRewards(
Expand Down Expand Up @@ -447,6 +413,5 @@ async function getSolanaUnixTimestamp(connection: Connection): Promise<bigint> {
})();

function sleep(ms: number): Promise<void> {
return new Promise(resolve => setTimeout(resolve, ms))
return new Promise((resolve) => setTimeout(resolve, ms));
}

3 changes: 0 additions & 3 deletions packages/crons/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
{
"path": "../no-emit-sdk"
},
{
"path": "../position-voting-rewards-sdk"
},
{
"path": "../helium-sub-daos-sdk"
},
Expand Down
19 changes: 0 additions & 19 deletions packages/crons/yarn.deploy.lock
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ __metadata:
"@helium/nft-proxy-sdk": ^0.0.12
"@helium/no-emit-sdk": ^0.9.15
"@helium/organization-sdk": ^0.0.12
"@helium/position-voting-rewards-sdk": ^0.9.15
"@helium/price-oracle-sdk": ^0.9.15
"@helium/proposal-sdk": ^0.0.12
"@helium/rewards-oracle-sdk": ^0.9.15
Expand Down Expand Up @@ -447,24 +446,6 @@ __metadata:
languageName: node
linkType: hard

"@helium/position-voting-rewards-sdk@^0.9.15":
version: 0.0.0-use.local
resolution: "@helium/position-voting-rewards-sdk@workspace:packages/position-voting-rewards-sdk"
dependencies:
"@coral-xyz/anchor": ^0.28.0
"@helium/anchor-resolvers": ^0.9.15
"@helium/idls": ^0.9.15
"@helium/spl-utils": ^0.9.15
"@solana/spl-token": ^0.3.8
bn.js: ^5.2.0
bs58: ^4.0.1
git-format-staged: ^2.1.3
ts-loader: ^9.2.3
ts-node: ^10.9.1
typescript: ^5.2.2
languageName: unknown
linkType: soft

"@helium/price-oracle-sdk@^0.9.15":
version: 0.0.0-use.local
resolution: "@helium/price-oracle-sdk@workspace:packages/price-oracle-sdk"
Expand Down
5 changes: 1 addition & 4 deletions packages/helium-admin-cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

## [0.9.9](https://github.com/helium/helium-program-libary/compare/v0.9.2...v0.9.9) (2024-10-28)


### Reverts

* Revert "Add temp endpoint to fix mobile hotspots (#683)" (#685) ([3f5a4be](https://github.com/helium/helium-program-libary/commit/3f5a4be5fc7da0dcbcd10c0ade199831fc538a9b)), closes [#683](https://github.com/helium/helium-program-libary/issues/683) [#685](https://github.com/helium/helium-program-libary/issues/685) [#683](https://github.com/helium/helium-program-libary/issues/683)
**Note:** Version bump only for package @helium/helium-admin-cli



Expand Down
1 change: 0 additions & 1 deletion packages/helium-admin-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
"@helium/mobile-entity-manager-sdk": "^0.9.15",
"@helium/nft-proxy-sdk": "^0.0.12",
"@helium/organization-sdk": "^0.0.13",
"@helium/position-voting-rewards-sdk": "^0.9.15",
"@helium/price-oracle-sdk": "^0.9.15",
"@helium/spl-utils": "^0.9.15",
"@helium/treasury-management-sdk": "^0.9.15",
Expand Down
1 change: 0 additions & 1 deletion packages/helium-admin-cli/src/create-dao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,6 @@ export async function run(args: any = process.argv) {
await heliumVsrProgram.methods
.initializeRegistrarV0({
positionUpdateAuthority: (await daoKey(hntKeypair.publicKey))[0],
positionFreezeAuthorities: [],
})
.accounts({
realm,
Expand Down
3 changes: 0 additions & 3 deletions packages/helium-admin-cli/src/create-subdao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,6 @@ export async function run(args: any = process.argv) {
await heliumVsrProgram.methods
.initializeRegistrarV0({
positionUpdateAuthority: null,
positionFreezeAuthorities: [],
})
.accounts({
realm,
Expand Down Expand Up @@ -513,8 +512,6 @@ export async function run(args: any = process.argv) {
instructions: [
await heliumSubDaosProgram.methods
.updateSubDaoV0({
vetokenTracker: null,
votingRewardsPercent: null,
authority,
emissionSchedule,
dcBurnAuthority: null,
Expand Down
Loading

0 comments on commit 8291dc1

Please sign in to comment.