farcasterxyz / contracts

Implementation of the Farcaster contracts
https://www.farcaster.xyz/
MIT License
340 stars 122 forks source link

bug: is L2 event history preserved? #265

Closed varunsrin closed 1 year ago

varunsrin commented 1 year ago

What is the bug? KeyRegistry and other aspects of our contract assume that event history will be preserved, and rely on events to communicate state. If this will not always be true, we should consider using storage instead.

tynes commented 1 year ago

Just copying my reply over from https://github.com/ethereum-optimism/optimism/issues/6253

The L2 event history is going to be permanently available given some caveats around the definition of "permanent". L1 has this concept of state expiry, where the nodes are expected to stop sending blocks older than a specific number over the p2p network and the nodes can start at a non 0 blocknumber. This technique can be used to remove the constantly increasing history in the database. This is to help make sure that the database doesn't grow too large, because it will push many users off of the network. Power users should be able to run without this mode on and keep all history around. The same sort of logic applies to L2s. With EIP 4844, the L2 p2p network will be responsible for sending blocks/logs around p2p since L1 nodes will expire the data, so it won't be recoverable from L1, but there will certainly eventually be software that indexes the 4844 blobs in a way that syncing L2 nodes can read. So you should be able to assume that the logs will be around permanently, altho the database sizes will be very large and sharded in 10+ years.

jakerockland commented 1 year ago

Optimism is still only supported via the Hosted Service, but if you're needing to index and cache events it may be worth exploring making use of Subgraphs.

jakerockland commented 1 year ago

Optimism is still only supported via the Hosted Service, but if you're needing to index and cache events it may be worth exploring making use of Subgraphs.

Note, if exploring other L2s outside of Optimism there is currently beta decentralized network support for Arbitrum indexing and this likely will expand over time.

https://thegraph.com/docs/en/developing/supported-networks/

varunsrin commented 1 year ago

closing, we seem to have reasonable persistence guarantees for now