reth
reth copied to clipboard
feat: add `TableSet` generic to the node builder pattern
Following https://github.com/paradigmxyz/reth/pull/13222
This PR adds the possibility for external users that uses reth as a dependency to create custom tables inside the reth libmdbx database.
You need to overwrite (or wrap) the EthStorage (or OpStorage) struct and create a new one that implements the TableSet trait. And use that as the Storage type inside the implementation of the NodeTypes trait.
@mattsse
it is also probably needed to change all the references to Tables::ALL in the code, next
could you pls give some context on which rollups would be interested in using this feature and how? think this feature should be gated behind experimental usage, as it will invalidate assumptions about reth's db, for example pruner logic
could you pls give some context on which rollups would be interested in using this feature and how? think this feature should be gated behind experimental usage, as it will invalidate assumptions about reth's db, for example pruner logic
hey sure. For instance we're building a custom sequencer (for op stack) that needs to track additional information about what's happening onchain (so not only the usual evm state and history). Of course we could create some external database that work at the same time, but it would be perfect to just use reth db to save these data.
Some of these additional data:
- data related to the mempool: we need to track some addresses that perform specific operations
- data related to what happens during the payload building function
This way it's also easier to do a backup as you only need to do a snapshot of the reth db folder and that's it. It's actually already possible to do this even without this PR. Only cons is that you need to manually add custom tables to the database on the main function. With this PR you could do it in a cleaner way.
ah yikes, forgot about this again, sorry @alessandromazza98
nextup are some db ergonomics changes planned, so bumping this again
we recently added
https://github.com/paradigmxyz/reth/blob/3f86efc3bba5419a3bcf7c12dfb6eb4e80ad1c12/crates/node/builder/src/builder/mod.rs#L186-L192
which should be sufficient as an entrypoint to register new tables on launch