ethereum-optimism / optimistic-specs

Optimistic: Bedrock, is a protocol that strives to be an extremely simple optimistic rollup that maintains 1:1 compatibility with Ethereum
MIT License
167 stars 35 forks source link

opnode: Avoid busy-waiting while L2 head is behind L1 #413

Closed Inphi closed 2 years ago

Inphi commented 2 years ago

In the state select loop, we immediately request for new L2 blocks whenever the latest L1 origin is behind L1. This can be an issue as we attempt to re-request the latest L2 block without any delay. This is a DoS hazard particularly when an L2 block cannot be retrieved because either the L1Chain or L2Chain backends have errors.

Another problem with this is that other, more useful events in the state select loop, are less likely to be scheduled by the Go runtime due to the busy-wait.

Adding a small delay, before calling reql2BlockCreation of about 10ms should be enough to prevent issues.