Skip to content

Commit

Permalink
fix: ✅ Replace manual calculation of next challenge tick, with use of…
Browse files Browse the repository at this point in the history
… runtime API
  • Loading branch information
ffarall committed Dec 27, 2024
1 parent 72d0ca8 commit 5e4dea0
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions test/util/bspNet/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,22 +375,16 @@ export const advanceToBlock = async (
if (options.watchForBspProofs) {
let txsToWaitFor = 0;
for (const bspId of options.watchForBspProofs) {
// TODO: Change this to a runtime API that gets the next challenge tick for a BSP.
// First we get the last tick for which the BSP submitted a proof.
const lastTickResult =
await api.call.proofsDealerApi.getLastTickProviderSubmittedProof(bspId);
if (lastTickResult.isErr) {
options.verbose && console.log(`Failed to get last tick for BSP ${bspId}`);
// Get the next challenge tick.
const nextChallengeTickResult =
await api.call.proofsDealerApi.getNextTickToSubmitProofFor(bspId);

if (nextChallengeTickResult.isErr) {
options.verbose && console.log(`Failed to get next challenge tick for BSP ${bspId}`);
continue;
}
const lastTickBspSubmittedProof = lastTickResult.asOk.toNumber();
// Then we get the challenge period for the BSP.
const challengePeriodResult = await api.call.proofsDealerApi.getChallengePeriod(bspId);
assert(challengePeriodResult.isOk);
const challengePeriod = challengePeriodResult.asOk.toNumber();
// Then we calculate the next challenge tick.
const nextChallengeTick = lastTickBspSubmittedProof + challengePeriod;

const nextChallengeTick = nextChallengeTickResult.asOk.toNumber();
if (currentBlockNumber === nextChallengeTick) {
txsToWaitFor++;
}
Expand Down

0 comments on commit 5e4dea0

Please sign in to comment.