-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow Modules to Store and Serve Data outside of the JMT #615
Comments
cc @bkolad |
The functionality has to also support |
I would say that if possible it would be natural to use a column family here. We probably don't need 1 right now. |
We should ensure that the DB writes are atomic across the JMT and non-JMT, so the data remains consistent even if the rollup shuts down in the middle of the db-write. |
Background
Currently, modules have access to
#[state]
variables. Under the hood, these variables are stored in the authenticated data store backed by the JMT.Recently, the EVM and Optimistic rollup workstreams have both encountered the need to serve data via RPC which does not need to be authenticated. (For the EVM, this is receipt and log data; for ORUs, this is storage proofs). While we always can store extra data in state, it's significantly preferable to avoid the overhead in these cases. Instead, we should add a new field type to modules which is write-only within the state machine, but can be read in RPC calls.
Desired Outcome
Modules should be able to efficiently store and retrieve arbitrary auxiliary data using a non-provable data store. The store should be accessible for reading in RPC handlers but must not be readable during execution.
Potential Designs
Off the top of my head, I can see at least three possible designs:
Option 1: Add a new API for registering module-defined DBs
In this design, we create a new trait which allows modules to bring their own (non-provable) database and have it opened/initialized during node startup. The motivating example for this design is to allow the EVM module to use Reth's existing LMDB/MDBX database rather than attempting to port their storage model to RocksDB.
A very rough sketch of the design is like this:
Option 2: Allow modules to define and write to their own RocksDB tables
In this design, we don't allow modules to bring their own DBs, but we do allow them to create and write to custom tables in our current DB. This will require us to separate our current SchemaDB crate into at least two pieces, and expose the schema definition traits/macros from sov-modules-api. We will also have to modify our DB intialization code...
Option 3: Allow modules to read/write to their own prefix in a single (predefined) RocksDB table
This is the least flexible option, but the simplest to implement. We can simply create a new database schema and add a couple of methods to the working set.
The text was updated successfully, but these errors were encountered: