status-im / nimbus-eth1

Nimbus: an Ethereum Execution Client for Resource-Restricted Devices

Home Page:https://status-im.github.io/nimbus-eth1/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FCU ignored after payload is processed

advaita-saha opened this issue · comments

When a payload is sent to eth1, it processes and validates fine
but then fcu is called, and says it is updating to the old head and thus ignoring the request

Shouldn't behave like that, but it is because of the payload processing
In the new_payload, we are also persisting the header to the db

# We still need to write header to database
# because validateUncles still need it
let blockHash = header.blockHash()
if not c.db.persistHeader(
blockHash,
header,
c.com.startOfHistory):
return err("Could not persist header")

Then when the fcu call takes place, it checks if the header is there in the db, and it is thus ignoring the fcu call

var canonHash: common.Hash256
if db.getBlockHash(header.number, canonHash) and canonHash == blockHash:
notice "Ignoring beacon update to old head",
blockHash=blockHash.short,
blockNumber=header.number
return validFCU(Opt.none(PayloadID), blockHash)

A similar issue arising from the same persistence of header #2588

A probable fix to this might be to use the state, @jangko can comment further if it's viable or not

if db.getBlockHash(header.number, canonHash) and canonHash == blockHash:

This can be changed to

if db.getSavedStateBlockNumber() >= header.number :
  notice "Ignoring beacon update to old head", 
     blockHash=blockHash.short, 
     blockNumber=header.number 
   return validFCU(Opt.none(PayloadID), blockHash)