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

client: fix double execution of a newplayload block on fcu #3777

Merged
merged 3 commits into from
Oct 30, 2024
Merged
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
18 changes: 10 additions & 8 deletions packages/client/src/service/skeleton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1091,13 +1091,15 @@
async blockingFillWithCutoff(cutoffLen: number): Promise<void> {
const subchain0 = this.status.progress.subchains[0]
if (this.status.linked && subchain0 !== undefined) {
const fillPromise = this.fillCanonicalChain().catch((_e) => {})
// if subchain0Head is not too ahead, then fill blocking as it gives better sync
// log experience else just trigger
if (
const isChainHeadNearEnough =

Check warning on line 1094 in packages/client/src/service/skeleton.ts

View check run for this annotation

Codecov / codecov/patch

packages/client/src/service/skeleton.ts#L1094

Added line #L1094 was not covered by tests
subchain0.head - BigInt(cutoffLen) <
(this.status.canonicalHeadReset ? subchain0.tail : this.chain.blocks.height)
) {
// do fillCanonicalChain and don't send update event as blockingFillWithCutoff called
// from fcU which should send its own event once done
const fillPromise = this.fillCanonicalChain(isChainHeadNearEnough).catch((_e) => {})
// if subchain0Head is not too ahead, then fill blocking as it gives better sync
// log experience else just trigger
if (isChainHeadNearEnough) {

Check warning on line 1102 in packages/client/src/service/skeleton.ts

View check run for this annotation

Codecov / codecov/patch

packages/client/src/service/skeleton.ts#L1097-L1102

Added lines #L1097 - L1102 were not covered by tests
this.config.logger.debug('Attempting blocking fill')
await fillPromise
}
Expand Down Expand Up @@ -1159,7 +1161,7 @@
/**
* Inserts skeleton blocks into canonical chain and runs execution.
*/
async fillCanonicalChain() {
async fillCanonicalChain(skipUpdateEmit: boolean = false) {

Check warning on line 1164 in packages/client/src/service/skeleton.ts

View check run for this annotation

Codecov / codecov/patch

packages/client/src/service/skeleton.ts#L1164

Added line #L1164 was not covered by tests
if (this.filling) return
this.filling = true

Expand Down Expand Up @@ -1192,7 +1194,7 @@
const start = canonicalHead
// This subchain is a reference to update the tail for the very subchain we are filling the data for
this.config.logger.debug(
`Starting canonical chain fill canonicalHead=${canonicalHead} subchainHead=${subchain.head}`,
`Starting canonical chain fill canonicalHead=${canonicalHead} subchainHead=${subchain.head} skipUpdateEmit=${skipUpdateEmit}`,

Check warning on line 1197 in packages/client/src/service/skeleton.ts

View check run for this annotation

Codecov / codecov/patch

packages/client/src/service/skeleton.ts#L1197

Added line #L1197 was not covered by tests
)

// run till it has not been determined that tail reset is required by concurrent setHead calls
Expand Down Expand Up @@ -1234,7 +1236,7 @@
// putBlocks should fail causing the fill to exit with skeleton stepback
if (this.chain.blocks.height <= block.header.number) {
try {
numBlocksInserted = await this.chain.putBlocks([block], true)
numBlocksInserted = await this.chain.putBlocks([block], true, skipUpdateEmit)

Check warning on line 1239 in packages/client/src/service/skeleton.ts

View check run for this annotation

Codecov / codecov/patch

packages/client/src/service/skeleton.ts#L1239

Added line #L1239 was not covered by tests
if (numBlocksInserted > 0) {
this.fillStatus = {
status: PutStatus.VALID,
Expand Down
Loading