Skip to content

Commit

Permalink
handle an edge case in newpayload block execution (#3131)
Browse files Browse the repository at this point in the history
* handle an edge case in newpayload block execution

* comment cleanup

---------

Co-authored-by: Holger Drewes <Holger.Drewes@gmail.com>
  • Loading branch information
g11tech and holgerd77 authored Nov 1, 2023
1 parent 6795fa6 commit ce9ff22
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions packages/client/src/rpc/modules/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -924,20 +924,35 @@ export class Engine {
}
}
} catch (error) {
const latestValidHash = await validHash(
headBlock.header.parentHash,
this.chain,
this.chainCache
)

const errorMsg = `${error}`.toLowerCase()
if (errorMsg.includes('block') && errorMsg.includes('not found')) {
throw {
code: INTERNAL_ERROR,
message: errorMsg,
if (blocks.length > 1) {
// this error can come if the block tries to load a previous block yet not in the chain via BLOCKHASH
// opcode.
//
// i) error coding of the evm errors should be a better way to handle this OR
// ii) figure out a way to pass let the evm access the above blocks which is what connects this
// chain to vmhead. to be handled in skeleton refactoring to blockchain class

const response = { status: Status.SYNCING, latestValidHash, validationError: null }
return response
} else {
throw {
code: INTERNAL_ERROR,
message: errorMsg,
}
}
}

const validationError = `Error verifying block while running: ${errorMsg}`
this.config.logger.error(validationError)
const latestValidHash = await validHash(
headBlock.header.parentHash,
this.chain,
this.chainCache
)

const response = { status: Status.INVALID, latestValidHash, validationError }
this.invalidBlocks.set(blockHash.slice(2), error as Error)
this.remoteBlocks.delete(blockHash.slice(2))
Expand Down

0 comments on commit ce9ff22

Please sign in to comment.