status-im / nimbus-eth1

Nimbus: an Ethereum Execution Client for Resource-Restricted Devices
https://status-im.github.io/nimbus-eth1/
Apache License 2.0
567 stars 115 forks source link

FCU ignored after payload is processed #2641

Closed advaita-saha closed 1 month ago

advaita-saha commented 1 month ago

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 https://github.com/status-im/nimbus-eth1/blob/ea74e035ab019619fc00b46ab97496b502a188dd/nimbus/core/chain/forked_chain.nim#L88-L95

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 https://github.com/status-im/nimbus-eth1/blob/ea74e035ab019619fc00b46ab97496b502a188dd/nimbus/beacon/api_handler/api_forkchoice.nim#L158-L163

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

advaita-saha commented 1 month ago

A probable fix to this might be to use the state, @jangko can comment further if it's viable or not https://github.com/status-im/nimbus-eth1/blob/ea74e035ab019619fc00b46ab97496b502a188dd/nimbus/beacon/api_handler/api_forkchoice.nim#L159

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)