Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: abort if different bundle round was returned from api #113

Merged
merged 1 commit into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common/protocol/src/methods/main/runNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export async function runNode(this: Validator): Promise<void> {
continue;
}

// temp save proposal creation time to detect if a new proposal is
// temp save proposal creation time to detect if a different proposal is
// available in the meantime
const updatedAt = parseInt(this.pool.bundle_proposal!.updated_at);

Expand Down
6 changes: 3 additions & 3 deletions common/protocol/src/methods/queries/canPropose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ export async function canPropose(
};
}

// abort if a new bundle proposal was found
if (parseInt(this.pool.bundle_proposal!.updated_at) > updatedAt) {
// abort if a different bundle proposal was found
if (parseInt(this.pool.bundle_proposal!.updated_at) !== updatedAt) {
return {
possible: false,
reason: "New bundle proposal was found",
reason: "Different bundle proposal was found",
};
}

Expand Down
6 changes: 3 additions & 3 deletions common/protocol/src/methods/queries/canVote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ export async function canVote(
};
}

// abort if a new bundle proposal was found
if (parseInt(this.pool.bundle_proposal!.updated_at) > updatedAt) {
// abort if a different bundle proposal was found
if (parseInt(this.pool.bundle_proposal!.updated_at) !== updatedAt) {
return {
possible: false,
reason: "New bundle proposal was found",
reason: "Different bundle proposal was found",
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export async function waitForCacheContinuation(
this: Validator,
updatedAt: number
): Promise<void> {
// continue if a new proposal is available
// continue if a different proposal is available
while (updatedAt === parseInt(this.pool.bundle_proposal!.updated_at)) {
await sleep(1000);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export async function waitForNextBundleProposal(
this.m.bundles_wait_for_next_round_time.startTimer();

// continue if the creation time of the bundle proposal increased
// we have an smaller equal check here, because we only want to continue,
// if we find a NEW bundle proposal
while (parseInt(this.pool.bundle_proposal!.updated_at) <= updatedAt) {
await this.syncPoolState();

Expand Down
4 changes: 2 additions & 2 deletions common/protocol/src/methods/validate/saveBundleDownload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ export async function saveBundleDownload(
.plus(this.pool.data!.upload_interval)
.multipliedBy(1000);

// check if new proposal is available in the meantime
if (parseInt(this.pool.bundle_proposal!.updated_at) > updatedAt) {
// check if different proposal is available in the meantime
if (parseInt(this.pool.bundle_proposal!.updated_at) !== updatedAt) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ export async function saveLoadValidationBundle(
.plus(this.pool.data!.upload_interval)
.multipliedBy(1000);

// check if new proposal is available in the meantime
if (parseInt(this.pool.bundle_proposal!.updated_at) > updatedAt) {
// check if different proposal is available in the meantime
if (parseInt(this.pool.bundle_proposal!.updated_at) !== updatedAt) {
return null;
}

Expand Down